mca.h 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * File: mca.h
  4. * Purpose: Machine check handling specific defines
  5. *
  6. * Copyright (C) 1999, 2004 Silicon Graphics, Inc.
  7. * Copyright (C) Vijay Chander <vijay@engr.sgi.com>
  8. * Copyright (C) Srinivasa Thirumalachar <sprasad@engr.sgi.com>
  9. * Copyright (C) Russ Anderson <rja@sgi.com>
  10. */
  11. #ifndef _ASM_IA64_MCA_H
  12. #define _ASM_IA64_MCA_H
  13. #if !defined(__ASSEMBLY__)
  14. #include <linux/interrupt.h>
  15. #include <linux/types.h>
  16. #include <asm/param.h>
  17. #include <asm/sal.h>
  18. #include <asm/processor.h>
  19. #include <asm/mca_asm.h>
  20. #define IA64_MCA_RENDEZ_TIMEOUT (20 * 1000) /* value in milliseconds - 20 seconds */
  21. typedef struct ia64_fptr {
  22. unsigned long fp;
  23. unsigned long gp;
  24. } ia64_fptr_t;
  25. typedef union cmcv_reg_u {
  26. u64 cmcv_regval;
  27. struct {
  28. u64 cmcr_vector : 8;
  29. u64 cmcr_reserved1 : 4;
  30. u64 cmcr_ignored1 : 1;
  31. u64 cmcr_reserved2 : 3;
  32. u64 cmcr_mask : 1;
  33. u64 cmcr_ignored2 : 47;
  34. } cmcv_reg_s;
  35. } cmcv_reg_t;
  36. #define cmcv_mask cmcv_reg_s.cmcr_mask
  37. #define cmcv_vector cmcv_reg_s.cmcr_vector
  38. enum {
  39. IA64_MCA_RENDEZ_CHECKIN_NOTDONE = 0x0,
  40. IA64_MCA_RENDEZ_CHECKIN_DONE = 0x1,
  41. IA64_MCA_RENDEZ_CHECKIN_INIT = 0x2,
  42. IA64_MCA_RENDEZ_CHECKIN_CONCURRENT_MCA = 0x3,
  43. };
  44. /* Information maintained by the MC infrastructure */
  45. typedef struct ia64_mc_info_s {
  46. u64 imi_mca_handler;
  47. size_t imi_mca_handler_size;
  48. u64 imi_monarch_init_handler;
  49. size_t imi_monarch_init_handler_size;
  50. u64 imi_slave_init_handler;
  51. size_t imi_slave_init_handler_size;
  52. u8 imi_rendez_checkin[NR_CPUS];
  53. } ia64_mc_info_t;
  54. /* Handover state from SAL to OS and vice versa, for both MCA and INIT events.
  55. * Besides the handover state, it also contains some saved registers from the
  56. * time of the event.
  57. * Note: mca_asm.S depends on the precise layout of this structure.
  58. */
  59. struct ia64_sal_os_state {
  60. /* SAL to OS */
  61. unsigned long os_gp; /* GP of the os registered with the SAL, physical */
  62. unsigned long pal_proc; /* PAL_PROC entry point, physical */
  63. unsigned long sal_proc; /* SAL_PROC entry point, physical */
  64. unsigned long rv_rc; /* MCA - Rendezvous state, INIT - reason code */
  65. unsigned long proc_state_param; /* from R18 */
  66. unsigned long monarch; /* 1 for a monarch event, 0 for a slave */
  67. /* common */
  68. unsigned long sal_ra; /* Return address in SAL, physical */
  69. unsigned long sal_gp; /* GP of the SAL - physical */
  70. pal_min_state_area_t *pal_min_state; /* from R17. physical in asm, virtual in C */
  71. /* Previous values of IA64_KR(CURRENT) and IA64_KR(CURRENT_STACK).
  72. * Note: if the MCA/INIT recovery code wants to resume to a new context
  73. * then it must change these values to reflect the new kernel stack.
  74. */
  75. unsigned long prev_IA64_KR_CURRENT; /* previous value of IA64_KR(CURRENT) */
  76. unsigned long prev_IA64_KR_CURRENT_STACK;
  77. struct task_struct *prev_task; /* previous task, NULL if it is not useful */
  78. /* Some interrupt registers are not saved in minstate, pt_regs or
  79. * switch_stack. Because MCA/INIT can occur when interrupts are
  80. * disabled, we need to save the additional interrupt registers over
  81. * MCA/INIT and resume.
  82. */
  83. unsigned long isr;
  84. unsigned long ifa;
  85. unsigned long itir;
  86. unsigned long iipa;
  87. unsigned long iim;
  88. unsigned long iha;
  89. /* OS to SAL */
  90. unsigned long os_status; /* OS status to SAL, enum below */
  91. unsigned long context; /* 0 if return to same context
  92. 1 if return to new context */
  93. /* I-resources */
  94. unsigned long iip;
  95. unsigned long ipsr;
  96. unsigned long ifs;
  97. };
  98. enum {
  99. IA64_MCA_CORRECTED = 0x0, /* Error has been corrected by OS_MCA */
  100. IA64_MCA_WARM_BOOT = -1, /* Warm boot of the system need from SAL */
  101. IA64_MCA_COLD_BOOT = -2, /* Cold boot of the system need from SAL */
  102. IA64_MCA_HALT = -3 /* System to be halted by SAL */
  103. };
  104. enum {
  105. IA64_INIT_RESUME = 0x0, /* Resume after return from INIT */
  106. IA64_INIT_WARM_BOOT = -1, /* Warm boot of the system need from SAL */
  107. };
  108. enum {
  109. IA64_MCA_SAME_CONTEXT = 0x0, /* SAL to return to same context */
  110. IA64_MCA_NEW_CONTEXT = -1 /* SAL to return to new context */
  111. };
  112. /* Per-CPU MCA state that is too big for normal per-CPU variables. */
  113. struct ia64_mca_cpu {
  114. u64 mca_stack[KERNEL_STACK_SIZE/8];
  115. u64 init_stack[KERNEL_STACK_SIZE/8];
  116. };
  117. /* Array of physical addresses of each CPU's MCA area. */
  118. extern unsigned long __per_cpu_mca[NR_CPUS];
  119. extern int cpe_vector;
  120. extern int ia64_cpe_irq;
  121. extern void ia64_mca_init(void);
  122. extern void ia64_mca_irq_init(void);
  123. extern void ia64_mca_cpu_init(void *);
  124. extern void ia64_os_mca_dispatch(void);
  125. extern void ia64_os_mca_dispatch_end(void);
  126. extern void ia64_mca_ucmc_handler(struct pt_regs *, struct ia64_sal_os_state *);
  127. extern void ia64_init_handler(struct pt_regs *,
  128. struct switch_stack *,
  129. struct ia64_sal_os_state *);
  130. extern void ia64_os_init_on_kdump(void);
  131. extern void ia64_monarch_init_handler(void);
  132. extern void ia64_slave_init_handler(void);
  133. extern void ia64_mca_cmc_vector_setup(void);
  134. extern int ia64_reg_MCA_extension(int (*fn)(void *, struct ia64_sal_os_state *));
  135. extern void ia64_unreg_MCA_extension(void);
  136. extern unsigned long ia64_get_rnat(unsigned long *);
  137. extern void ia64_set_psr_mc(void);
  138. extern void ia64_mca_printk(const char * fmt, ...)
  139. __attribute__ ((format (printf, 1, 2)));
  140. struct ia64_mca_notify_die {
  141. struct ia64_sal_os_state *sos;
  142. int *monarch_cpu;
  143. int *data;
  144. };
  145. DECLARE_PER_CPU(u64, ia64_mca_pal_base);
  146. #else /* __ASSEMBLY__ */
  147. #define IA64_MCA_CORRECTED 0x0 /* Error has been corrected by OS_MCA */
  148. #define IA64_MCA_WARM_BOOT -1 /* Warm boot of the system need from SAL */
  149. #define IA64_MCA_COLD_BOOT -2 /* Cold boot of the system need from SAL */
  150. #define IA64_MCA_HALT -3 /* System to be halted by SAL */
  151. #define IA64_INIT_RESUME 0x0 /* Resume after return from INIT */
  152. #define IA64_INIT_WARM_BOOT -1 /* Warm boot of the system need from SAL */
  153. #define IA64_MCA_SAME_CONTEXT 0x0 /* SAL to return to same context */
  154. #define IA64_MCA_NEW_CONTEXT -1 /* SAL to return to new context */
  155. #endif /* !__ASSEMBLY__ */
  156. #endif /* _ASM_IA64_MCA_H */