1b2441318SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 */ 27f30491cSTony Luck /* 37f30491cSTony Luck * File: mca.h 47f30491cSTony Luck * Purpose: Machine check handling specific defines 57f30491cSTony Luck * 67f30491cSTony Luck * Copyright (C) 1999, 2004 Silicon Graphics, Inc. 77f30491cSTony Luck * Copyright (C) Vijay Chander <vijay@engr.sgi.com> 87f30491cSTony Luck * Copyright (C) Srinivasa Thirumalachar <sprasad@engr.sgi.com> 97f30491cSTony Luck * Copyright (C) Russ Anderson <rja@sgi.com> 107f30491cSTony Luck */ 117f30491cSTony Luck 127f30491cSTony Luck #ifndef _ASM_IA64_MCA_H 137f30491cSTony Luck #define _ASM_IA64_MCA_H 147f30491cSTony Luck 157f30491cSTony Luck #if !defined(__ASSEMBLY__) 167f30491cSTony Luck 17*a5b7c61eSMasahiro Yamada #include <linux/percpu.h> 18*a5b7c61eSMasahiro Yamada #include <linux/threads.h> 197f30491cSTony Luck #include <linux/types.h> 20*a5b7c61eSMasahiro Yamada #include <asm/ptrace.h> 217f30491cSTony Luck 227f30491cSTony Luck #define IA64_MCA_RENDEZ_TIMEOUT (20 * 1000) /* value in milliseconds - 20 seconds */ 237f30491cSTony Luck 247f30491cSTony Luck typedef struct ia64_fptr { 257f30491cSTony Luck unsigned long fp; 267f30491cSTony Luck unsigned long gp; 277f30491cSTony Luck } ia64_fptr_t; 287f30491cSTony Luck 297f30491cSTony Luck typedef union cmcv_reg_u { 307f30491cSTony Luck u64 cmcv_regval; 317f30491cSTony Luck struct { 327f30491cSTony Luck u64 cmcr_vector : 8; 337f30491cSTony Luck u64 cmcr_reserved1 : 4; 347f30491cSTony Luck u64 cmcr_ignored1 : 1; 357f30491cSTony Luck u64 cmcr_reserved2 : 3; 367f30491cSTony Luck u64 cmcr_mask : 1; 377f30491cSTony Luck u64 cmcr_ignored2 : 47; 387f30491cSTony Luck } cmcv_reg_s; 397f30491cSTony Luck 407f30491cSTony Luck } cmcv_reg_t; 417f30491cSTony Luck 427f30491cSTony Luck #define cmcv_mask cmcv_reg_s.cmcr_mask 437f30491cSTony Luck #define cmcv_vector cmcv_reg_s.cmcr_vector 447f30491cSTony Luck 457f30491cSTony Luck enum { 467f30491cSTony Luck IA64_MCA_RENDEZ_CHECKIN_NOTDONE = 0x0, 477f30491cSTony Luck IA64_MCA_RENDEZ_CHECKIN_DONE = 0x1, 487f30491cSTony Luck IA64_MCA_RENDEZ_CHECKIN_INIT = 0x2, 497f30491cSTony Luck IA64_MCA_RENDEZ_CHECKIN_CONCURRENT_MCA = 0x3, 507f30491cSTony Luck }; 517f30491cSTony Luck 527f30491cSTony Luck /* Information maintained by the MC infrastructure */ 537f30491cSTony Luck typedef struct ia64_mc_info_s { 547f30491cSTony Luck u64 imi_mca_handler; 557f30491cSTony Luck size_t imi_mca_handler_size; 567f30491cSTony Luck u64 imi_monarch_init_handler; 577f30491cSTony Luck size_t imi_monarch_init_handler_size; 587f30491cSTony Luck u64 imi_slave_init_handler; 597f30491cSTony Luck size_t imi_slave_init_handler_size; 607f30491cSTony Luck u8 imi_rendez_checkin[NR_CPUS]; 617f30491cSTony Luck 627f30491cSTony Luck } ia64_mc_info_t; 637f30491cSTony Luck 647f30491cSTony Luck /* Handover state from SAL to OS and vice versa, for both MCA and INIT events. 657f30491cSTony Luck * Besides the handover state, it also contains some saved registers from the 667f30491cSTony Luck * time of the event. 677f30491cSTony Luck * Note: mca_asm.S depends on the precise layout of this structure. 687f30491cSTony Luck */ 697f30491cSTony Luck 707f30491cSTony Luck struct ia64_sal_os_state { 717f30491cSTony Luck 727f30491cSTony Luck /* SAL to OS */ 73e088a4adSMatthew Wilcox unsigned long os_gp; /* GP of the os registered with the SAL, physical */ 74e088a4adSMatthew Wilcox unsigned long pal_proc; /* PAL_PROC entry point, physical */ 75e088a4adSMatthew Wilcox unsigned long sal_proc; /* SAL_PROC entry point, physical */ 76e088a4adSMatthew Wilcox unsigned long rv_rc; /* MCA - Rendezvous state, INIT - reason code */ 77e088a4adSMatthew Wilcox unsigned long proc_state_param; /* from R18 */ 78e088a4adSMatthew Wilcox unsigned long monarch; /* 1 for a monarch event, 0 for a slave */ 797f30491cSTony Luck 807f30491cSTony Luck /* common */ 81e088a4adSMatthew Wilcox unsigned long sal_ra; /* Return address in SAL, physical */ 82e088a4adSMatthew Wilcox unsigned long sal_gp; /* GP of the SAL - physical */ 832770ef7cSMasahiro Yamada struct pal_min_state_area *pal_min_state; /* from R17. physical in asm, virtual in C */ 847f30491cSTony Luck /* Previous values of IA64_KR(CURRENT) and IA64_KR(CURRENT_STACK). 857f30491cSTony Luck * Note: if the MCA/INIT recovery code wants to resume to a new context 867f30491cSTony Luck * then it must change these values to reflect the new kernel stack. 877f30491cSTony Luck */ 88e088a4adSMatthew Wilcox unsigned long prev_IA64_KR_CURRENT; /* previous value of IA64_KR(CURRENT) */ 89e088a4adSMatthew Wilcox unsigned long prev_IA64_KR_CURRENT_STACK; 907f30491cSTony Luck struct task_struct *prev_task; /* previous task, NULL if it is not useful */ 917f30491cSTony Luck /* Some interrupt registers are not saved in minstate, pt_regs or 927f30491cSTony Luck * switch_stack. Because MCA/INIT can occur when interrupts are 937f30491cSTony Luck * disabled, we need to save the additional interrupt registers over 947f30491cSTony Luck * MCA/INIT and resume. 957f30491cSTony Luck */ 96e088a4adSMatthew Wilcox unsigned long isr; 97e088a4adSMatthew Wilcox unsigned long ifa; 98e088a4adSMatthew Wilcox unsigned long itir; 99e088a4adSMatthew Wilcox unsigned long iipa; 100e088a4adSMatthew Wilcox unsigned long iim; 101e088a4adSMatthew Wilcox unsigned long iha; 1027f30491cSTony Luck 1037f30491cSTony Luck /* OS to SAL */ 104e088a4adSMatthew Wilcox unsigned long os_status; /* OS status to SAL, enum below */ 105e088a4adSMatthew Wilcox unsigned long context; /* 0 if return to same context 1067f30491cSTony Luck 1 if return to new context */ 1079ee27c76STakao Indoh 1089ee27c76STakao Indoh /* I-resources */ 1099ee27c76STakao Indoh unsigned long iip; 1109ee27c76STakao Indoh unsigned long ipsr; 1119ee27c76STakao Indoh unsigned long ifs; 1127f30491cSTony Luck }; 1137f30491cSTony Luck 1147f30491cSTony Luck enum { 1157f30491cSTony Luck IA64_MCA_CORRECTED = 0x0, /* Error has been corrected by OS_MCA */ 1167f30491cSTony Luck IA64_MCA_WARM_BOOT = -1, /* Warm boot of the system need from SAL */ 1177f30491cSTony Luck IA64_MCA_COLD_BOOT = -2, /* Cold boot of the system need from SAL */ 1187f30491cSTony Luck IA64_MCA_HALT = -3 /* System to be halted by SAL */ 1197f30491cSTony Luck }; 1207f30491cSTony Luck 1217f30491cSTony Luck enum { 1227f30491cSTony Luck IA64_INIT_RESUME = 0x0, /* Resume after return from INIT */ 1237f30491cSTony Luck IA64_INIT_WARM_BOOT = -1, /* Warm boot of the system need from SAL */ 1247f30491cSTony Luck }; 1257f30491cSTony Luck 1267f30491cSTony Luck enum { 1277f30491cSTony Luck IA64_MCA_SAME_CONTEXT = 0x0, /* SAL to return to same context */ 1287f30491cSTony Luck IA64_MCA_NEW_CONTEXT = -1 /* SAL to return to new context */ 1297f30491cSTony Luck }; 1307f30491cSTony Luck 1317f30491cSTony Luck /* Per-CPU MCA state that is too big for normal per-CPU variables. */ 1327f30491cSTony Luck 1337f30491cSTony Luck struct ia64_mca_cpu { 1347f30491cSTony Luck u64 mca_stack[KERNEL_STACK_SIZE/8]; 1357f30491cSTony Luck u64 init_stack[KERNEL_STACK_SIZE/8]; 1367f30491cSTony Luck }; 1377f30491cSTony Luck 1387f30491cSTony Luck /* Array of physical addresses of each CPU's MCA area. */ 1397f30491cSTony Luck extern unsigned long __per_cpu_mca[NR_CPUS]; 1407f30491cSTony Luck 1417f30491cSTony Luck extern int cpe_vector; 1427f30491cSTony Luck extern int ia64_cpe_irq; 1437f30491cSTony Luck extern void ia64_mca_init(void); 144d303e9e9STony Luck extern void ia64_mca_irq_init(void); 1457f30491cSTony Luck extern void ia64_mca_cpu_init(void *); 1467f30491cSTony Luck extern void ia64_os_mca_dispatch(void); 1477f30491cSTony Luck extern void ia64_os_mca_dispatch_end(void); 1487f30491cSTony Luck extern void ia64_mca_ucmc_handler(struct pt_regs *, struct ia64_sal_os_state *); 1497f30491cSTony Luck extern void ia64_init_handler(struct pt_regs *, 1507f30491cSTony Luck struct switch_stack *, 1517f30491cSTony Luck struct ia64_sal_os_state *); 15207a6a4aeSHidetoshi Seto extern void ia64_os_init_on_kdump(void); 1537f30491cSTony Luck extern void ia64_monarch_init_handler(void); 1547f30491cSTony Luck extern void ia64_slave_init_handler(void); 1557f30491cSTony Luck extern void ia64_mca_cmc_vector_setup(void); 1567f30491cSTony Luck extern int ia64_reg_MCA_extension(int (*fn)(void *, struct ia64_sal_os_state *)); 1577f30491cSTony Luck extern void ia64_unreg_MCA_extension(void); 158e088a4adSMatthew Wilcox extern unsigned long ia64_get_rnat(unsigned long *); 1594295ab34SHidetoshi Seto extern void ia64_set_psr_mc(void); 1607f30491cSTony Luck extern void ia64_mca_printk(const char * fmt, ...) 1617f30491cSTony Luck __attribute__ ((format (printf, 1, 2))); 1627f30491cSTony Luck 1637f30491cSTony Luck struct ia64_mca_notify_die { 1647f30491cSTony Luck struct ia64_sal_os_state *sos; 1657f30491cSTony Luck int *monarch_cpu; 1667f30491cSTony Luck int *data; 1677f30491cSTony Luck }; 1687f30491cSTony Luck 1697f30491cSTony Luck DECLARE_PER_CPU(u64, ia64_mca_pal_base); 1707f30491cSTony Luck 1717f30491cSTony Luck #else /* __ASSEMBLY__ */ 1727f30491cSTony Luck 1737f30491cSTony Luck #define IA64_MCA_CORRECTED 0x0 /* Error has been corrected by OS_MCA */ 1747f30491cSTony Luck #define IA64_MCA_WARM_BOOT -1 /* Warm boot of the system need from SAL */ 1757f30491cSTony Luck #define IA64_MCA_COLD_BOOT -2 /* Cold boot of the system need from SAL */ 1767f30491cSTony Luck #define IA64_MCA_HALT -3 /* System to be halted by SAL */ 1777f30491cSTony Luck 1787f30491cSTony Luck #define IA64_INIT_RESUME 0x0 /* Resume after return from INIT */ 1797f30491cSTony Luck #define IA64_INIT_WARM_BOOT -1 /* Warm boot of the system need from SAL */ 1807f30491cSTony Luck 1817f30491cSTony Luck #define IA64_MCA_SAME_CONTEXT 0x0 /* SAL to return to same context */ 1827f30491cSTony Luck #define IA64_MCA_NEW_CONTEXT -1 /* SAL to return to new context */ 1837f30491cSTony Luck 1847f30491cSTony Luck #endif /* !__ASSEMBLY__ */ 1857f30491cSTony Luck #endif /* _ASM_IA64_MCA_H */ 186