sal.h 25 KB

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