sal.h 25 KB

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