sal.h 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef _ASM_IA64_SAL_H
  3. #define _ASM_IA64_SAL_H
  4. /*
  5. * System Abstraction Layer definitions.
  6. *
  7. * This is based on version 2.5 of the manual "IA-64 System
  8. * Abstraction Layer".
  9. *
  10. * Copyright (C) 2001 Intel
  11. * Copyright (C) 2002 Jenna Hall <[email protected]>
  12. * Copyright (C) 2001 Fred Lewis <[email protected]>
  13. * Copyright (C) 1998, 1999, 2001, 2003 Hewlett-Packard Co
  14. * David Mosberger-Tang <[email protected]>
  15. * Copyright (C) 1999 Srinivasa Prasad Thirumalachar <[email protected]>
  16. *
  17. * 02/01/04 J. Hall Updated Error Record Structures to conform to July 2001
  18. * revision of the SAL spec.
  19. * 01/01/03 fvlewis Updated Error Record Structures to conform with Nov. 2000
  20. * revision of the SAL spec.
  21. * 99/09/29 davidm Updated for SAL 2.6.
  22. * 00/03/29 cfleck Updated SAL Error Logging info for processor (SAL 2.6)
  23. * (plus examples of platform error info structures from smariset @ Intel)
  24. */
  25. #define IA64_SAL_PLATFORM_FEATURE_BUS_LOCK_BIT 0
  26. #define IA64_SAL_PLATFORM_FEATURE_IRQ_REDIR_HINT_BIT 1
  27. #define IA64_SAL_PLATFORM_FEATURE_IPI_REDIR_HINT_BIT 2
  28. #define IA64_SAL_PLATFORM_FEATURE_ITC_DRIFT_BIT 3
  29. #define IA64_SAL_PLATFORM_FEATURE_BUS_LOCK (1<<IA64_SAL_PLATFORM_FEATURE_BUS_LOCK_BIT)
  30. #define IA64_SAL_PLATFORM_FEATURE_IRQ_REDIR_HINT (1<<IA64_SAL_PLATFORM_FEATURE_IRQ_REDIR_HINT_BIT)
  31. #define IA64_SAL_PLATFORM_FEATURE_IPI_REDIR_HINT (1<<IA64_SAL_PLATFORM_FEATURE_IPI_REDIR_HINT_BIT)
  32. #define IA64_SAL_PLATFORM_FEATURE_ITC_DRIFT (1<<IA64_SAL_PLATFORM_FEATURE_ITC_DRIFT_BIT)
  33. #ifndef __ASSEMBLY__
  34. #include <linux/bcd.h>
  35. #include <linux/spinlock.h>
  36. #include <linux/efi.h>
  37. #include <asm/pal.h>
  38. #include <asm/fpu.h>
  39. extern unsigned long sal_systab_phys;
  40. extern spinlock_t sal_lock;
  41. /* SAL spec _requires_ eight args for each call. */
  42. #define __IA64_FW_CALL(entry,result,a0,a1,a2,a3,a4,a5,a6,a7) \
  43. result = (*entry)(a0,a1,a2,a3,a4,a5,a6,a7)
  44. # define IA64_FW_CALL(entry,result,args...) do { \
  45. unsigned long __ia64_sc_flags; \
  46. struct ia64_fpreg __ia64_sc_fr[6]; \
  47. ia64_save_scratch_fpregs(__ia64_sc_fr); \
  48. spin_lock_irqsave(&sal_lock, __ia64_sc_flags); \
  49. __IA64_FW_CALL(entry, result, args); \
  50. spin_unlock_irqrestore(&sal_lock, __ia64_sc_flags); \
  51. ia64_load_scratch_fpregs(__ia64_sc_fr); \
  52. } while (0)
  53. # define SAL_CALL(result,args...) \
  54. IA64_FW_CALL(ia64_sal, result, args);
  55. # define SAL_CALL_NOLOCK(result,args...) do { \
  56. unsigned long __ia64_scn_flags; \
  57. struct ia64_fpreg __ia64_scn_fr[6]; \
  58. ia64_save_scratch_fpregs(__ia64_scn_fr); \
  59. local_irq_save(__ia64_scn_flags); \
  60. __IA64_FW_CALL(ia64_sal, result, args); \
  61. local_irq_restore(__ia64_scn_flags); \
  62. ia64_load_scratch_fpregs(__ia64_scn_fr); \
  63. } while (0)
  64. # define SAL_CALL_REENTRANT(result,args...) do { \
  65. struct ia64_fpreg __ia64_scs_fr[6]; \
  66. ia64_save_scratch_fpregs(__ia64_scs_fr); \
  67. preempt_disable(); \
  68. __IA64_FW_CALL(ia64_sal, result, args); \
  69. preempt_enable(); \
  70. ia64_load_scratch_fpregs(__ia64_scs_fr); \
  71. } while (0)
  72. #define SAL_SET_VECTORS 0x01000000
  73. #define SAL_GET_STATE_INFO 0x01000001
  74. #define SAL_GET_STATE_INFO_SIZE 0x01000002
  75. #define SAL_CLEAR_STATE_INFO 0x01000003
  76. #define SAL_MC_RENDEZ 0x01000004
  77. #define SAL_MC_SET_PARAMS 0x01000005
  78. #define SAL_REGISTER_PHYSICAL_ADDR 0x01000006
  79. #define SAL_CACHE_FLUSH 0x01000008
  80. #define SAL_CACHE_INIT 0x01000009
  81. #define SAL_PCI_CONFIG_READ 0x01000010
  82. #define SAL_PCI_CONFIG_WRITE 0x01000011
  83. #define SAL_FREQ_BASE 0x01000012
  84. #define SAL_PHYSICAL_ID_INFO 0x01000013
  85. #define SAL_UPDATE_PAL 0x01000020
  86. struct ia64_sal_retval {
  87. /*
  88. * A zero status value indicates call completed without error.
  89. * A negative status value indicates reason of call failure.
  90. * A positive status value indicates success but an
  91. * informational value should be printed (e.g., "reboot for
  92. * change to take effect").
  93. */
  94. long status;
  95. unsigned long v0;
  96. unsigned long v1;
  97. unsigned long v2;
  98. };
  99. typedef struct ia64_sal_retval (*ia64_sal_handler) (u64, ...);
  100. enum {
  101. SAL_FREQ_BASE_PLATFORM = 0,
  102. SAL_FREQ_BASE_INTERVAL_TIMER = 1,
  103. SAL_FREQ_BASE_REALTIME_CLOCK = 2
  104. };
  105. /*
  106. * The SAL system table is followed by a variable number of variable
  107. * length descriptors. The structure of these descriptors follows
  108. * below.
  109. * The defininition follows SAL specs from July 2000
  110. */
  111. struct ia64_sal_systab {
  112. u8 signature[4]; /* should be "SST_" */
  113. u32 size; /* size of this table in bytes */
  114. u8 sal_rev_minor;
  115. u8 sal_rev_major;
  116. u16 entry_count; /* # of entries in variable portion */
  117. u8 checksum;
  118. u8 reserved1[7];
  119. u8 sal_a_rev_minor;
  120. u8 sal_a_rev_major;
  121. u8 sal_b_rev_minor;
  122. u8 sal_b_rev_major;
  123. /* oem_id & product_id: terminating NUL is missing if string is exactly 32 bytes long. */
  124. u8 oem_id[32];
  125. u8 product_id[32]; /* ASCII product id */
  126. u8 reserved2[8];
  127. };
  128. enum sal_systab_entry_type {
  129. SAL_DESC_ENTRY_POINT = 0,
  130. SAL_DESC_MEMORY = 1,
  131. SAL_DESC_PLATFORM_FEATURE = 2,
  132. SAL_DESC_TR = 3,
  133. SAL_DESC_PTC = 4,
  134. SAL_DESC_AP_WAKEUP = 5
  135. };
  136. /*
  137. * Entry type: Size:
  138. * 0 48
  139. * 1 32
  140. * 2 16
  141. * 3 32
  142. * 4 16
  143. * 5 16
  144. */
  145. #define SAL_DESC_SIZE(type) "\060\040\020\040\020\020"[(unsigned) type]
  146. typedef struct ia64_sal_desc_entry_point {
  147. u8 type;
  148. u8 reserved1[7];
  149. u64 pal_proc;
  150. u64 sal_proc;
  151. u64 gp;
  152. u8 reserved2[16];
  153. }ia64_sal_desc_entry_point_t;
  154. typedef struct ia64_sal_desc_memory {
  155. u8 type;
  156. u8 used_by_sal; /* needs to be mapped for SAL? */
  157. u8 mem_attr; /* current memory attribute setting */
  158. u8 access_rights; /* access rights set up by SAL */
  159. u8 mem_attr_mask; /* mask of supported memory attributes */
  160. u8 reserved1;
  161. u8 mem_type; /* memory type */
  162. u8 mem_usage; /* memory usage */
  163. u64 addr; /* physical address of memory */
  164. u32 length; /* length (multiple of 4KB pages) */
  165. u32 reserved2;
  166. u8 oem_reserved[8];
  167. } ia64_sal_desc_memory_t;
  168. typedef struct ia64_sal_desc_platform_feature {
  169. u8 type;
  170. u8 feature_mask;
  171. u8 reserved1[14];
  172. } ia64_sal_desc_platform_feature_t;
  173. typedef struct ia64_sal_desc_tr {
  174. u8 type;
  175. u8 tr_type; /* 0 == instruction, 1 == data */
  176. u8 regnum; /* translation register number */
  177. u8 reserved1[5];
  178. u64 addr; /* virtual address of area covered */
  179. u64 page_size; /* encoded page size */
  180. u8 reserved2[8];
  181. } ia64_sal_desc_tr_t;
  182. typedef struct ia64_sal_desc_ptc {
  183. u8 type;
  184. u8 reserved1[3];
  185. u32 num_domains; /* # of coherence domains */
  186. u64 domain_info; /* physical address of domain info table */
  187. } ia64_sal_desc_ptc_t;
  188. typedef struct ia64_sal_ptc_domain_info {
  189. u64 proc_count; /* number of processors in domain */
  190. u64 proc_list; /* physical address of LID array */
  191. } ia64_sal_ptc_domain_info_t;
  192. typedef struct ia64_sal_ptc_domain_proc_entry {
  193. u64 id : 8; /* id of processor */
  194. u64 eid : 8; /* eid of processor */
  195. } ia64_sal_ptc_domain_proc_entry_t;
  196. #define IA64_SAL_AP_EXTERNAL_INT 0
  197. typedef struct ia64_sal_desc_ap_wakeup {
  198. u8 type;
  199. u8 mechanism; /* 0 == external interrupt */
  200. u8 reserved1[6];
  201. u64 vector; /* interrupt vector in range 0x10-0xff */
  202. } ia64_sal_desc_ap_wakeup_t ;
  203. extern ia64_sal_handler ia64_sal;
  204. extern struct ia64_sal_desc_ptc *ia64_ptc_domain_info;
  205. extern unsigned short sal_revision; /* supported SAL spec revision */
  206. extern unsigned short sal_version; /* SAL version; OEM dependent */
  207. #define SAL_VERSION_CODE(major, minor) ((bin2bcd(major) << 8) | bin2bcd(minor))
  208. extern const char *ia64_sal_strerror (long status);
  209. extern void ia64_sal_init (struct ia64_sal_systab *sal_systab);
  210. /* SAL information type encodings */
  211. enum {
  212. SAL_INFO_TYPE_MCA = 0, /* Machine check abort information */
  213. SAL_INFO_TYPE_INIT = 1, /* Init information */
  214. SAL_INFO_TYPE_CMC = 2, /* Corrected machine check information */
  215. SAL_INFO_TYPE_CPE = 3 /* Corrected platform error information */
  216. };
  217. /* Encodings for machine check parameter types */
  218. enum {
  219. SAL_MC_PARAM_RENDEZ_INT = 1, /* Rendezvous interrupt */
  220. SAL_MC_PARAM_RENDEZ_WAKEUP = 2, /* Wakeup */
  221. SAL_MC_PARAM_CPE_INT = 3 /* Corrected Platform Error Int */
  222. };
  223. /* Encodings for rendezvous mechanisms */
  224. enum {
  225. SAL_MC_PARAM_MECHANISM_INT = 1, /* Use interrupt */
  226. SAL_MC_PARAM_MECHANISM_MEM = 2 /* Use memory synchronization variable*/
  227. };
  228. /* Encodings for vectors which can be registered by the OS with SAL */
  229. enum {
  230. SAL_VECTOR_OS_MCA = 0,
  231. SAL_VECTOR_OS_INIT = 1,
  232. SAL_VECTOR_OS_BOOT_RENDEZ = 2
  233. };
  234. /* Encodings for mca_opt parameter sent to SAL_MC_SET_PARAMS */
  235. #define SAL_MC_PARAM_RZ_ALWAYS 0x1
  236. #define SAL_MC_PARAM_BINIT_ESCALATE 0x10
  237. /*
  238. * Definition of the SAL Error Log from the SAL spec
  239. */
  240. /* SAL Error Record Section GUID Definitions */
  241. #define SAL_PROC_DEV_ERR_SECT_GUID \
  242. EFI_GUID(0xe429faf1, 0x3cb7, 0x11d4, 0xbc, 0xa7, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81)
  243. #define SAL_PLAT_MEM_DEV_ERR_SECT_GUID \
  244. EFI_GUID(0xe429faf2, 0x3cb7, 0x11d4, 0xbc, 0xa7, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81)
  245. #define SAL_PLAT_SEL_DEV_ERR_SECT_GUID \
  246. EFI_GUID(0xe429faf3, 0x3cb7, 0x11d4, 0xbc, 0xa7, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81)
  247. #define SAL_PLAT_PCI_BUS_ERR_SECT_GUID \
  248. EFI_GUID(0xe429faf4, 0x3cb7, 0x11d4, 0xbc, 0xa7, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81)
  249. #define SAL_PLAT_SMBIOS_DEV_ERR_SECT_GUID \
  250. EFI_GUID(0xe429faf5, 0x3cb7, 0x11d4, 0xbc, 0xa7, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81)
  251. #define SAL_PLAT_PCI_COMP_ERR_SECT_GUID \
  252. EFI_GUID(0xe429faf6, 0x3cb7, 0x11d4, 0xbc, 0xa7, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81)
  253. #define SAL_PLAT_SPECIFIC_ERR_SECT_GUID \
  254. EFI_GUID(0xe429faf7, 0x3cb7, 0x11d4, 0xbc, 0xa7, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81)
  255. #define SAL_PLAT_HOST_CTLR_ERR_SECT_GUID \
  256. EFI_GUID(0xe429faf8, 0x3cb7, 0x11d4, 0xbc, 0xa7, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81)
  257. #define SAL_PLAT_BUS_ERR_SECT_GUID \
  258. EFI_GUID(0xe429faf9, 0x3cb7, 0x11d4, 0xbc, 0xa7, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81)
  259. #define PROCESSOR_ABSTRACTION_LAYER_OVERWRITE_GUID \
  260. EFI_GUID(0x6cb0a200, 0x893a, 0x11da, 0x96, 0xd2, 0x0, 0x10, 0x83, 0xff, \
  261. 0xca, 0x4d)
  262. #define MAX_CACHE_ERRORS 6
  263. #define MAX_TLB_ERRORS 6
  264. #define MAX_BUS_ERRORS 1
  265. /* Definition of version according to SAL spec for logging purposes */
  266. typedef struct sal_log_revision {
  267. u8 minor; /* BCD (0..99) */
  268. u8 major; /* BCD (0..99) */
  269. } sal_log_revision_t;
  270. /* Definition of timestamp according to SAL spec for logging purposes */
  271. typedef struct sal_log_timestamp {
  272. u8 slh_second; /* Second (0..59) */
  273. u8 slh_minute; /* Minute (0..59) */
  274. u8 slh_hour; /* Hour (0..23) */
  275. u8 slh_reserved;
  276. u8 slh_day; /* Day (1..31) */
  277. u8 slh_month; /* Month (1..12) */
  278. u8 slh_year; /* Year (00..99) */
  279. u8 slh_century; /* Century (19, 20, 21, ...) */
  280. } sal_log_timestamp_t;
  281. /* Definition of log record header structures */
  282. typedef struct sal_log_record_header {
  283. u64 id; /* Unique monotonically increasing ID */
  284. sal_log_revision_t revision; /* Major and Minor revision of header */
  285. u8 severity; /* Error Severity */
  286. u8 validation_bits; /* 0: platform_guid, 1: !timestamp */
  287. u32 len; /* Length of this error log in bytes */
  288. sal_log_timestamp_t timestamp; /* Timestamp */
  289. efi_guid_t platform_guid; /* Unique OEM Platform ID */
  290. } sal_log_record_header_t;
  291. #define sal_log_severity_recoverable 0
  292. #define sal_log_severity_fatal 1
  293. #define sal_log_severity_corrected 2
  294. /*
  295. * Error Recovery Info (ERI) bit decode. From SAL Spec section B.2.2 Table B-3
  296. * Error Section Error_Recovery_Info Field Definition.
  297. */
  298. #define ERI_NOT_VALID 0x0 /* Error Recovery Field is not valid */
  299. #define ERI_NOT_ACCESSIBLE 0x30 /* Resource not accessible */
  300. #define ERI_CONTAINMENT_WARN 0x22 /* Corrupt data propagated */
  301. #define ERI_UNCORRECTED_ERROR 0x20 /* Uncorrected error */
  302. #define ERI_COMPONENT_RESET 0x24 /* Component must be reset */
  303. #define ERI_CORR_ERROR_LOG 0x21 /* Corrected error, needs logging */
  304. #define ERI_CORR_ERROR_THRESH 0x29 /* Corrected error threshold exceeded */
  305. /* Definition of log section header structures */
  306. typedef struct sal_log_sec_header {
  307. efi_guid_t guid; /* Unique Section ID */
  308. sal_log_revision_t revision; /* Major and Minor revision of Section */
  309. u8 error_recovery_info; /* Platform error recovery status */
  310. u8 reserved;
  311. u32 len; /* Section length */
  312. } sal_log_section_hdr_t;
  313. typedef struct sal_log_mod_error_info {
  314. struct {
  315. u64 check_info : 1,
  316. requestor_identifier : 1,
  317. responder_identifier : 1,
  318. target_identifier : 1,
  319. precise_ip : 1,
  320. reserved : 59;
  321. } valid;
  322. u64 check_info;
  323. u64 requestor_identifier;
  324. u64 responder_identifier;
  325. u64 target_identifier;
  326. u64 precise_ip;
  327. } sal_log_mod_error_info_t;
  328. typedef struct sal_processor_static_info {
  329. struct {
  330. u64 minstate : 1,
  331. br : 1,
  332. cr : 1,
  333. ar : 1,
  334. rr : 1,
  335. fr : 1,
  336. reserved : 58;
  337. } valid;
  338. struct pal_min_state_area min_state_area;
  339. u64 br[8];
  340. u64 cr[128];
  341. u64 ar[128];
  342. u64 rr[8];
  343. struct ia64_fpreg __attribute__ ((packed)) fr[128];
  344. } sal_processor_static_info_t;
  345. struct sal_cpuid_info {
  346. u64 regs[5];
  347. u64 reserved;
  348. };
  349. typedef struct sal_log_processor_info {
  350. sal_log_section_hdr_t header;
  351. struct {
  352. u64 proc_error_map : 1,
  353. proc_state_param : 1,
  354. proc_cr_lid : 1,
  355. psi_static_struct : 1,
  356. num_cache_check : 4,
  357. num_tlb_check : 4,
  358. num_bus_check : 4,
  359. num_reg_file_check : 4,
  360. num_ms_check : 4,
  361. cpuid_info : 1,
  362. reserved1 : 39;
  363. } valid;
  364. u64 proc_error_map;
  365. u64 proc_state_parameter;
  366. u64 proc_cr_lid;
  367. /*
  368. * The rest of this structure consists of variable-length arrays, which can't be
  369. * expressed in C.
  370. */
  371. sal_log_mod_error_info_t info[];
  372. /*
  373. * This is what the rest looked like if C supported variable-length arrays:
  374. *
  375. * sal_log_mod_error_info_t cache_check_info[.valid.num_cache_check];
  376. * sal_log_mod_error_info_t tlb_check_info[.valid.num_tlb_check];
  377. * sal_log_mod_error_info_t bus_check_info[.valid.num_bus_check];
  378. * sal_log_mod_error_info_t reg_file_check_info[.valid.num_reg_file_check];
  379. * sal_log_mod_error_info_t ms_check_info[.valid.num_ms_check];
  380. * struct sal_cpuid_info cpuid_info;
  381. * sal_processor_static_info_t processor_static_info;
  382. */
  383. } sal_log_processor_info_t;
  384. /* Given a sal_log_processor_info_t pointer, return a pointer to the processor_static_info: */
  385. #define SAL_LPI_PSI_INFO(l) \
  386. ({ sal_log_processor_info_t *_l = (l); \
  387. ((sal_processor_static_info_t *) \
  388. ((char *) _l->info + ((_l->valid.num_cache_check + _l->valid.num_tlb_check \
  389. + _l->valid.num_bus_check + _l->valid.num_reg_file_check \
  390. + _l->valid.num_ms_check) * sizeof(sal_log_mod_error_info_t) \
  391. + sizeof(struct sal_cpuid_info)))); \
  392. })
  393. /* platform error log structures */
  394. typedef struct sal_log_mem_dev_err_info {
  395. sal_log_section_hdr_t header;
  396. struct {
  397. u64 error_status : 1,
  398. physical_addr : 1,
  399. addr_mask : 1,
  400. node : 1,
  401. card : 1,
  402. module : 1,
  403. bank : 1,
  404. device : 1,
  405. row : 1,
  406. column : 1,
  407. bit_position : 1,
  408. requestor_id : 1,
  409. responder_id : 1,
  410. target_id : 1,
  411. bus_spec_data : 1,
  412. oem_id : 1,
  413. oem_data : 1,
  414. reserved : 47;
  415. } valid;
  416. u64 error_status;
  417. u64 physical_addr;
  418. u64 addr_mask;
  419. u16 node;
  420. u16 card;
  421. u16 module;
  422. u16 bank;
  423. u16 device;
  424. u16 row;
  425. u16 column;
  426. u16 bit_position;
  427. u64 requestor_id;
  428. u64 responder_id;
  429. u64 target_id;
  430. u64 bus_spec_data;
  431. u8 oem_id[16];
  432. u8 oem_data[1]; /* Variable length data */
  433. } sal_log_mem_dev_err_info_t;
  434. typedef struct sal_log_sel_dev_err_info {
  435. sal_log_section_hdr_t header;
  436. struct {
  437. u64 record_id : 1,
  438. record_type : 1,
  439. generator_id : 1,
  440. evm_rev : 1,
  441. sensor_type : 1,
  442. sensor_num : 1,
  443. event_dir : 1,
  444. event_data1 : 1,
  445. event_data2 : 1,
  446. event_data3 : 1,
  447. reserved : 54;
  448. } valid;
  449. u16 record_id;
  450. u8 record_type;
  451. u8 timestamp[4];
  452. u16 generator_id;
  453. u8 evm_rev;
  454. u8 sensor_type;
  455. u8 sensor_num;
  456. u8 event_dir;
  457. u8 event_data1;
  458. u8 event_data2;
  459. u8 event_data3;
  460. } sal_log_sel_dev_err_info_t;
  461. typedef struct sal_log_pci_bus_err_info {
  462. sal_log_section_hdr_t header;
  463. struct {
  464. u64 err_status : 1,
  465. err_type : 1,
  466. bus_id : 1,
  467. bus_address : 1,
  468. bus_data : 1,
  469. bus_cmd : 1,
  470. requestor_id : 1,
  471. responder_id : 1,
  472. target_id : 1,
  473. oem_data : 1,
  474. reserved : 54;
  475. } valid;
  476. u64 err_status;
  477. u16 err_type;
  478. u16 bus_id;
  479. u32 reserved;
  480. u64 bus_address;
  481. u64 bus_data;
  482. u64 bus_cmd;
  483. u64 requestor_id;
  484. u64 responder_id;
  485. u64 target_id;
  486. u8 oem_data[1]; /* Variable length data */
  487. } sal_log_pci_bus_err_info_t;
  488. typedef struct sal_log_smbios_dev_err_info {
  489. sal_log_section_hdr_t header;
  490. struct {
  491. u64 event_type : 1,
  492. length : 1,
  493. time_stamp : 1,
  494. data : 1,
  495. reserved1 : 60;
  496. } valid;
  497. u8 event_type;
  498. u8 length;
  499. u8 time_stamp[6];
  500. u8 data[1]; /* data of variable length, length == slsmb_length */
  501. } sal_log_smbios_dev_err_info_t;
  502. typedef struct sal_log_pci_comp_err_info {
  503. sal_log_section_hdr_t header;
  504. struct {
  505. u64 err_status : 1,
  506. comp_info : 1,
  507. num_mem_regs : 1,
  508. num_io_regs : 1,
  509. reg_data_pairs : 1,
  510. oem_data : 1,
  511. reserved : 58;
  512. } valid;
  513. u64 err_status;
  514. struct {
  515. u16 vendor_id;
  516. u16 device_id;
  517. u8 class_code[3];
  518. u8 func_num;
  519. u8 dev_num;
  520. u8 bus_num;
  521. u8 seg_num;
  522. u8 reserved[5];
  523. } comp_info;
  524. u32 num_mem_regs;
  525. u32 num_io_regs;
  526. u64 reg_data_pairs[1];
  527. /*
  528. * array of address/data register pairs is num_mem_regs + num_io_regs elements
  529. * long. Each array element consists of a u64 address followed by a u64 data
  530. * value. The oem_data array immediately follows the reg_data_pairs array
  531. */
  532. u8 oem_data[1]; /* Variable length data */
  533. } sal_log_pci_comp_err_info_t;
  534. typedef struct sal_log_plat_specific_err_info {
  535. sal_log_section_hdr_t header;
  536. struct {
  537. u64 err_status : 1,
  538. guid : 1,
  539. oem_data : 1,
  540. reserved : 61;
  541. } valid;
  542. u64 err_status;
  543. efi_guid_t guid;
  544. u8 oem_data[1]; /* platform specific variable length data */
  545. } sal_log_plat_specific_err_info_t;
  546. typedef struct sal_log_host_ctlr_err_info {
  547. sal_log_section_hdr_t header;
  548. struct {
  549. u64 err_status : 1,
  550. requestor_id : 1,
  551. responder_id : 1,
  552. target_id : 1,
  553. bus_spec_data : 1,
  554. oem_data : 1,
  555. reserved : 58;
  556. } valid;
  557. u64 err_status;
  558. u64 requestor_id;
  559. u64 responder_id;
  560. u64 target_id;
  561. u64 bus_spec_data;
  562. u8 oem_data[1]; /* Variable length OEM data */
  563. } sal_log_host_ctlr_err_info_t;
  564. typedef struct sal_log_plat_bus_err_info {
  565. sal_log_section_hdr_t header;
  566. struct {
  567. u64 err_status : 1,
  568. requestor_id : 1,
  569. responder_id : 1,
  570. target_id : 1,
  571. bus_spec_data : 1,
  572. oem_data : 1,
  573. reserved : 58;
  574. } valid;
  575. u64 err_status;
  576. u64 requestor_id;
  577. u64 responder_id;
  578. u64 target_id;
  579. u64 bus_spec_data;
  580. u8 oem_data[1]; /* Variable length OEM data */
  581. } sal_log_plat_bus_err_info_t;
  582. /* Overall platform error section structure */
  583. typedef union sal_log_platform_err_info {
  584. sal_log_mem_dev_err_info_t mem_dev_err;
  585. sal_log_sel_dev_err_info_t sel_dev_err;
  586. sal_log_pci_bus_err_info_t pci_bus_err;
  587. sal_log_smbios_dev_err_info_t smbios_dev_err;
  588. sal_log_pci_comp_err_info_t pci_comp_err;
  589. sal_log_plat_specific_err_info_t plat_specific_err;
  590. sal_log_host_ctlr_err_info_t host_ctlr_err;
  591. sal_log_plat_bus_err_info_t plat_bus_err;
  592. } sal_log_platform_err_info_t;
  593. /* SAL log over-all, multi-section error record structure (processor+platform) */
  594. typedef struct err_rec {
  595. sal_log_record_header_t sal_elog_header;
  596. sal_log_processor_info_t proc_err;
  597. sal_log_platform_err_info_t plat_err;
  598. u8 oem_data_pad[1024];
  599. } ia64_err_rec_t;
  600. /*
  601. * Now define a couple of inline functions for improved type checking
  602. * and convenience.
  603. */
  604. extern s64 ia64_sal_cache_flush (u64 cache_type);
  605. extern void __init check_sal_cache_flush (void);
  606. /* Initialize all the processor and platform level instruction and data caches */
  607. static inline s64
  608. ia64_sal_cache_init (void)
  609. {
  610. struct ia64_sal_retval isrv;
  611. SAL_CALL(isrv, SAL_CACHE_INIT, 0, 0, 0, 0, 0, 0, 0);
  612. return isrv.status;
  613. }
  614. /*
  615. * Clear the processor and platform information logged by SAL with respect to the machine
  616. * state at the time of MCA's, INITs, CMCs, or CPEs.
  617. */
  618. static inline s64
  619. ia64_sal_clear_state_info (u64 sal_info_type)
  620. {
  621. struct ia64_sal_retval isrv;
  622. SAL_CALL_REENTRANT(isrv, SAL_CLEAR_STATE_INFO, sal_info_type, 0,
  623. 0, 0, 0, 0, 0);
  624. return isrv.status;
  625. }
  626. /* Get the processor and platform information logged by SAL with respect to the machine
  627. * state at the time of the MCAs, INITs, CMCs, or CPEs.
  628. */
  629. static inline u64
  630. ia64_sal_get_state_info (u64 sal_info_type, u64 *sal_info)
  631. {
  632. struct ia64_sal_retval isrv;
  633. SAL_CALL_REENTRANT(isrv, SAL_GET_STATE_INFO, sal_info_type, 0,
  634. sal_info, 0, 0, 0, 0);
  635. if (isrv.status)
  636. return 0;
  637. return isrv.v0;
  638. }
  639. /*
  640. * Get the maximum size of the information logged by SAL with respect to the machine state
  641. * at the time of MCAs, INITs, CMCs, or CPEs.
  642. */
  643. static inline u64
  644. ia64_sal_get_state_info_size (u64 sal_info_type)
  645. {
  646. struct ia64_sal_retval isrv;
  647. SAL_CALL_REENTRANT(isrv, SAL_GET_STATE_INFO_SIZE, sal_info_type, 0,
  648. 0, 0, 0, 0, 0);
  649. if (isrv.status)
  650. return 0;
  651. return isrv.v0;
  652. }
  653. /*
  654. * Causes the processor to go into a spin loop within SAL where SAL awaits a wakeup from
  655. * the monarch processor. Must not lock, because it will not return on any cpu until the
  656. * monarch processor sends a wake up.
  657. */
  658. static inline s64
  659. ia64_sal_mc_rendez (void)
  660. {
  661. struct ia64_sal_retval isrv;
  662. SAL_CALL_NOLOCK(isrv, SAL_MC_RENDEZ, 0, 0, 0, 0, 0, 0, 0);
  663. return isrv.status;
  664. }
  665. /*
  666. * Allow the OS to specify the interrupt number to be used by SAL to interrupt OS during
  667. * the machine check rendezvous sequence as well as the mechanism to wake up the
  668. * non-monarch processor at the end of machine check processing.
  669. * Returns the complete ia64_sal_retval because some calls return more than just a status
  670. * value.
  671. */
  672. static inline struct ia64_sal_retval
  673. ia64_sal_mc_set_params (u64 param_type, u64 i_or_m, u64 i_or_m_val, u64 timeout, u64 rz_always)
  674. {
  675. struct ia64_sal_retval isrv;
  676. SAL_CALL(isrv, SAL_MC_SET_PARAMS, param_type, i_or_m, i_or_m_val,
  677. timeout, rz_always, 0, 0);
  678. return isrv;
  679. }
  680. /* Read from PCI configuration space */
  681. static inline s64
  682. ia64_sal_pci_config_read (u64 pci_config_addr, int type, u64 size, u64 *value)
  683. {
  684. struct ia64_sal_retval isrv;
  685. SAL_CALL(isrv, SAL_PCI_CONFIG_READ, pci_config_addr, size, type, 0, 0, 0, 0);
  686. if (value)
  687. *value = isrv.v0;
  688. return isrv.status;
  689. }
  690. /* Write to PCI configuration space */
  691. static inline s64
  692. ia64_sal_pci_config_write (u64 pci_config_addr, int type, u64 size, u64 value)
  693. {
  694. struct ia64_sal_retval isrv;
  695. SAL_CALL(isrv, SAL_PCI_CONFIG_WRITE, pci_config_addr, size, value,
  696. type, 0, 0, 0);
  697. return isrv.status;
  698. }
  699. /*
  700. * Register physical addresses of locations needed by SAL when SAL procedures are invoked
  701. * in virtual mode.
  702. */
  703. static inline s64
  704. ia64_sal_register_physical_addr (u64 phys_entry, u64 phys_addr)
  705. {
  706. struct ia64_sal_retval isrv;
  707. SAL_CALL(isrv, SAL_REGISTER_PHYSICAL_ADDR, phys_entry, phys_addr,
  708. 0, 0, 0, 0, 0);
  709. return isrv.status;
  710. }
  711. /*
  712. * Register software dependent code locations within SAL. These locations are handlers or
  713. * entry points where SAL will pass control for the specified event. These event handlers
  714. * are for the bott rendezvous, MCAs and INIT scenarios.
  715. */
  716. static inline s64
  717. ia64_sal_set_vectors (u64 vector_type,
  718. u64 handler_addr1, u64 gp1, u64 handler_len1,
  719. u64 handler_addr2, u64 gp2, u64 handler_len2)
  720. {
  721. struct ia64_sal_retval isrv;
  722. SAL_CALL(isrv, SAL_SET_VECTORS, vector_type,
  723. handler_addr1, gp1, handler_len1,
  724. handler_addr2, gp2, handler_len2);
  725. return isrv.status;
  726. }
  727. /* Update the contents of PAL block in the non-volatile storage device */
  728. static inline s64
  729. ia64_sal_update_pal (u64 param_buf, u64 scratch_buf, u64 scratch_buf_size,
  730. u64 *error_code, u64 *scratch_buf_size_needed)
  731. {
  732. struct ia64_sal_retval isrv;
  733. SAL_CALL(isrv, SAL_UPDATE_PAL, param_buf, scratch_buf, scratch_buf_size,
  734. 0, 0, 0, 0);
  735. if (error_code)
  736. *error_code = isrv.v0;
  737. if (scratch_buf_size_needed)
  738. *scratch_buf_size_needed = isrv.v1;
  739. return isrv.status;
  740. }
  741. /* Get physical processor die mapping in the platform. */
  742. static inline s64
  743. ia64_sal_physical_id_info(u16 *splid)
  744. {
  745. struct ia64_sal_retval isrv;
  746. if (sal_revision < SAL_VERSION_CODE(3,2))
  747. return -1;
  748. SAL_CALL(isrv, SAL_PHYSICAL_ID_INFO, 0, 0, 0, 0, 0, 0, 0);
  749. if (splid)
  750. *splid = isrv.v0;
  751. return isrv.status;
  752. }
  753. extern unsigned long sal_platform_features;
  754. extern int (*salinfo_platform_oemdata)(const u8 *, u8 **, u64 *);
  755. struct sal_ret_values {
  756. long r8; long r9; long r10; long r11;
  757. };
  758. #define IA64_SAL_OEMFUNC_MIN 0x02000000
  759. #define IA64_SAL_OEMFUNC_MAX 0x03ffffff
  760. extern int ia64_sal_oemcall(struct ia64_sal_retval *, u64, u64, u64, u64, u64,
  761. u64, u64, u64);
  762. extern int ia64_sal_oemcall_nolock(struct ia64_sal_retval *, u64, u64, u64,
  763. u64, u64, u64, u64, u64);
  764. extern int ia64_sal_oemcall_reentrant(struct ia64_sal_retval *, u64, u64, u64,
  765. u64, u64, u64, u64, u64);
  766. extern long
  767. ia64_sal_freq_base (unsigned long which, unsigned long *ticks_per_second,
  768. unsigned long *drift_info);
  769. #ifdef CONFIG_HOTPLUG_CPU
  770. /*
  771. * System Abstraction Layer Specification
  772. * Section 3.2.5.1: OS_BOOT_RENDEZ to SAL return State.
  773. * Note: region regs are stored first in head.S _start. Hence they must
  774. * stay up front.
  775. */
  776. struct sal_to_os_boot {
  777. u64 rr[8]; /* Region Registers */
  778. u64 br[6]; /* br0:
  779. * return addr into SAL boot rendez routine */
  780. u64 gr1; /* SAL:GP */
  781. u64 gr12; /* SAL:SP */
  782. u64 gr13; /* SAL: Task Pointer */
  783. u64 fpsr;
  784. u64 pfs;
  785. u64 rnat;
  786. u64 unat;
  787. u64 bspstore;
  788. u64 dcr; /* Default Control Register */
  789. u64 iva;
  790. u64 pta;
  791. u64 itv;
  792. u64 pmv;
  793. u64 cmcv;
  794. u64 lrr[2];
  795. u64 gr[4];
  796. u64 pr; /* Predicate registers */
  797. u64 lc; /* Loop Count */
  798. struct ia64_fpreg fp[20];
  799. };
  800. /*
  801. * Global array allocated for NR_CPUS at boot time
  802. */
  803. extern struct sal_to_os_boot sal_boot_rendez_state[NR_CPUS];
  804. extern void ia64_jump_to_sal(struct sal_to_os_boot *);
  805. #endif
  806. extern void ia64_sal_handler_init(void *entry_point, void *gpval);
  807. #define PALO_MAX_TLB_PURGES 0xFFFF
  808. #define PALO_SIG "PALO"
  809. struct palo_table {
  810. u8 signature[4]; /* Should be "PALO" */
  811. u32 length;
  812. u8 minor_revision;
  813. u8 major_revision;
  814. u8 checksum;
  815. u8 reserved1[5];
  816. u16 max_tlb_purges;
  817. u8 reserved2[6];
  818. };
  819. #define NPTCG_FROM_PAL 0
  820. #define NPTCG_FROM_PALO 1
  821. #define NPTCG_FROM_KERNEL_PARAMETER 2
  822. #endif /* __ASSEMBLY__ */
  823. #endif /* _ASM_IA64_SAL_H */