sal.h 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890
  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. u16 severity; /* Error Severity */
  280. u32 len; /* Length of this error log in bytes */
  281. sal_log_timestamp_t timestamp; /* Timestamp */
  282. efi_guid_t platform_guid; /* Unique OEM Platform ID */
  283. } sal_log_record_header_t;
  284. #define sal_log_severity_recoverable 0
  285. #define sal_log_severity_fatal 1
  286. #define sal_log_severity_corrected 2
  287. /* Definition of log section header structures */
  288. typedef struct sal_log_sec_header {
  289. efi_guid_t guid; /* Unique Section ID */
  290. sal_log_revision_t revision; /* Major and Minor revision of Section */
  291. u16 reserved;
  292. u32 len; /* Section length */
  293. } sal_log_section_hdr_t;
  294. typedef struct sal_log_mod_error_info {
  295. struct {
  296. u64 check_info : 1,
  297. requestor_identifier : 1,
  298. responder_identifier : 1,
  299. target_identifier : 1,
  300. precise_ip : 1,
  301. reserved : 59;
  302. } valid;
  303. u64 check_info;
  304. u64 requestor_identifier;
  305. u64 responder_identifier;
  306. u64 target_identifier;
  307. u64 precise_ip;
  308. } sal_log_mod_error_info_t;
  309. typedef struct sal_processor_static_info {
  310. struct {
  311. u64 minstate : 1,
  312. br : 1,
  313. cr : 1,
  314. ar : 1,
  315. rr : 1,
  316. fr : 1,
  317. reserved : 58;
  318. } valid;
  319. pal_min_state_area_t min_state_area;
  320. u64 br[8];
  321. u64 cr[128];
  322. u64 ar[128];
  323. u64 rr[8];
  324. struct ia64_fpreg __attribute__ ((packed)) fr[128];
  325. } sal_processor_static_info_t;
  326. struct sal_cpuid_info {
  327. u64 regs[5];
  328. u64 reserved;
  329. };
  330. typedef struct sal_log_processor_info {
  331. sal_log_section_hdr_t header;
  332. struct {
  333. u64 proc_error_map : 1,
  334. proc_state_param : 1,
  335. proc_cr_lid : 1,
  336. psi_static_struct : 1,
  337. num_cache_check : 4,
  338. num_tlb_check : 4,
  339. num_bus_check : 4,
  340. num_reg_file_check : 4,
  341. num_ms_check : 4,
  342. cpuid_info : 1,
  343. reserved1 : 39;
  344. } valid;
  345. u64 proc_error_map;
  346. u64 proc_state_parameter;
  347. u64 proc_cr_lid;
  348. /*
  349. * The rest of this structure consists of variable-length arrays, which can't be
  350. * expressed in C.
  351. */
  352. sal_log_mod_error_info_t info[0];
  353. /*
  354. * This is what the rest looked like if C supported variable-length arrays:
  355. *
  356. * sal_log_mod_error_info_t cache_check_info[.valid.num_cache_check];
  357. * sal_log_mod_error_info_t tlb_check_info[.valid.num_tlb_check];
  358. * sal_log_mod_error_info_t bus_check_info[.valid.num_bus_check];
  359. * sal_log_mod_error_info_t reg_file_check_info[.valid.num_reg_file_check];
  360. * sal_log_mod_error_info_t ms_check_info[.valid.num_ms_check];
  361. * struct sal_cpuid_info cpuid_info;
  362. * sal_processor_static_info_t processor_static_info;
  363. */
  364. } sal_log_processor_info_t;
  365. /* Given a sal_log_processor_info_t pointer, return a pointer to the processor_static_info: */
  366. #define SAL_LPI_PSI_INFO(l) \
  367. ({ sal_log_processor_info_t *_l = (l); \
  368. ((sal_processor_static_info_t *) \
  369. ((char *) _l->info + ((_l->valid.num_cache_check + _l->valid.num_tlb_check \
  370. + _l->valid.num_bus_check + _l->valid.num_reg_file_check \
  371. + _l->valid.num_ms_check) * sizeof(sal_log_mod_error_info_t) \
  372. + sizeof(struct sal_cpuid_info)))); \
  373. })
  374. /* platform error log structures */
  375. typedef struct sal_log_mem_dev_err_info {
  376. sal_log_section_hdr_t header;
  377. struct {
  378. u64 error_status : 1,
  379. physical_addr : 1,
  380. addr_mask : 1,
  381. node : 1,
  382. card : 1,
  383. module : 1,
  384. bank : 1,
  385. device : 1,
  386. row : 1,
  387. column : 1,
  388. bit_position : 1,
  389. requestor_id : 1,
  390. responder_id : 1,
  391. target_id : 1,
  392. bus_spec_data : 1,
  393. oem_id : 1,
  394. oem_data : 1,
  395. reserved : 47;
  396. } valid;
  397. u64 error_status;
  398. u64 physical_addr;
  399. u64 addr_mask;
  400. u16 node;
  401. u16 card;
  402. u16 module;
  403. u16 bank;
  404. u16 device;
  405. u16 row;
  406. u16 column;
  407. u16 bit_position;
  408. u64 requestor_id;
  409. u64 responder_id;
  410. u64 target_id;
  411. u64 bus_spec_data;
  412. u8 oem_id[16];
  413. u8 oem_data[1]; /* Variable length data */
  414. } sal_log_mem_dev_err_info_t;
  415. typedef struct sal_log_sel_dev_err_info {
  416. sal_log_section_hdr_t header;
  417. struct {
  418. u64 record_id : 1,
  419. record_type : 1,
  420. generator_id : 1,
  421. evm_rev : 1,
  422. sensor_type : 1,
  423. sensor_num : 1,
  424. event_dir : 1,
  425. event_data1 : 1,
  426. event_data2 : 1,
  427. event_data3 : 1,
  428. reserved : 54;
  429. } valid;
  430. u16 record_id;
  431. u8 record_type;
  432. u8 timestamp[4];
  433. u16 generator_id;
  434. u8 evm_rev;
  435. u8 sensor_type;
  436. u8 sensor_num;
  437. u8 event_dir;
  438. u8 event_data1;
  439. u8 event_data2;
  440. u8 event_data3;
  441. } sal_log_sel_dev_err_info_t;
  442. typedef struct sal_log_pci_bus_err_info {
  443. sal_log_section_hdr_t header;
  444. struct {
  445. u64 err_status : 1,
  446. err_type : 1,
  447. bus_id : 1,
  448. bus_address : 1,
  449. bus_data : 1,
  450. bus_cmd : 1,
  451. requestor_id : 1,
  452. responder_id : 1,
  453. target_id : 1,
  454. oem_data : 1,
  455. reserved : 54;
  456. } valid;
  457. u64 err_status;
  458. u16 err_type;
  459. u16 bus_id;
  460. u32 reserved;
  461. u64 bus_address;
  462. u64 bus_data;
  463. u64 bus_cmd;
  464. u64 requestor_id;
  465. u64 responder_id;
  466. u64 target_id;
  467. u8 oem_data[1]; /* Variable length data */
  468. } sal_log_pci_bus_err_info_t;
  469. typedef struct sal_log_smbios_dev_err_info {
  470. sal_log_section_hdr_t header;
  471. struct {
  472. u64 event_type : 1,
  473. length : 1,
  474. time_stamp : 1,
  475. data : 1,
  476. reserved1 : 60;
  477. } valid;
  478. u8 event_type;
  479. u8 length;
  480. u8 time_stamp[6];
  481. u8 data[1]; /* data of variable length, length == slsmb_length */
  482. } sal_log_smbios_dev_err_info_t;
  483. typedef struct sal_log_pci_comp_err_info {
  484. sal_log_section_hdr_t header;
  485. struct {
  486. u64 err_status : 1,
  487. comp_info : 1,
  488. num_mem_regs : 1,
  489. num_io_regs : 1,
  490. reg_data_pairs : 1,
  491. oem_data : 1,
  492. reserved : 58;
  493. } valid;
  494. u64 err_status;
  495. struct {
  496. u16 vendor_id;
  497. u16 device_id;
  498. u8 class_code[3];
  499. u8 func_num;
  500. u8 dev_num;
  501. u8 bus_num;
  502. u8 seg_num;
  503. u8 reserved[5];
  504. } comp_info;
  505. u32 num_mem_regs;
  506. u32 num_io_regs;
  507. u64 reg_data_pairs[1];
  508. /*
  509. * array of address/data register pairs is num_mem_regs + num_io_regs elements
  510. * long. Each array element consists of a u64 address followed by a u64 data
  511. * value. The oem_data array immediately follows the reg_data_pairs array
  512. */
  513. u8 oem_data[1]; /* Variable length data */
  514. } sal_log_pci_comp_err_info_t;
  515. typedef struct sal_log_plat_specific_err_info {
  516. sal_log_section_hdr_t header;
  517. struct {
  518. u64 err_status : 1,
  519. guid : 1,
  520. oem_data : 1,
  521. reserved : 61;
  522. } valid;
  523. u64 err_status;
  524. efi_guid_t guid;
  525. u8 oem_data[1]; /* platform specific variable length data */
  526. } sal_log_plat_specific_err_info_t;
  527. typedef struct sal_log_host_ctlr_err_info {
  528. sal_log_section_hdr_t header;
  529. struct {
  530. u64 err_status : 1,
  531. requestor_id : 1,
  532. responder_id : 1,
  533. target_id : 1,
  534. bus_spec_data : 1,
  535. oem_data : 1,
  536. reserved : 58;
  537. } valid;
  538. u64 err_status;
  539. u64 requestor_id;
  540. u64 responder_id;
  541. u64 target_id;
  542. u64 bus_spec_data;
  543. u8 oem_data[1]; /* Variable length OEM data */
  544. } sal_log_host_ctlr_err_info_t;
  545. typedef struct sal_log_plat_bus_err_info {
  546. sal_log_section_hdr_t header;
  547. struct {
  548. u64 err_status : 1,
  549. requestor_id : 1,
  550. responder_id : 1,
  551. target_id : 1,
  552. bus_spec_data : 1,
  553. oem_data : 1,
  554. reserved : 58;
  555. } valid;
  556. u64 err_status;
  557. u64 requestor_id;
  558. u64 responder_id;
  559. u64 target_id;
  560. u64 bus_spec_data;
  561. u8 oem_data[1]; /* Variable length OEM data */
  562. } sal_log_plat_bus_err_info_t;
  563. /* Overall platform error section structure */
  564. typedef union sal_log_platform_err_info {
  565. sal_log_mem_dev_err_info_t mem_dev_err;
  566. sal_log_sel_dev_err_info_t sel_dev_err;
  567. sal_log_pci_bus_err_info_t pci_bus_err;
  568. sal_log_smbios_dev_err_info_t smbios_dev_err;
  569. sal_log_pci_comp_err_info_t pci_comp_err;
  570. sal_log_plat_specific_err_info_t plat_specific_err;
  571. sal_log_host_ctlr_err_info_t host_ctlr_err;
  572. sal_log_plat_bus_err_info_t plat_bus_err;
  573. } sal_log_platform_err_info_t;
  574. /* SAL log over-all, multi-section error record structure (processor+platform) */
  575. typedef struct err_rec {
  576. sal_log_record_header_t sal_elog_header;
  577. sal_log_processor_info_t proc_err;
  578. sal_log_platform_err_info_t plat_err;
  579. u8 oem_data_pad[1024];
  580. } ia64_err_rec_t;
  581. /*
  582. * Now define a couple of inline functions for improved type checking
  583. * and convenience.
  584. */
  585. static inline long
  586. ia64_sal_freq_base (unsigned long which, unsigned long *ticks_per_second,
  587. unsigned long *drift_info)
  588. {
  589. struct ia64_sal_retval isrv;
  590. SAL_CALL(isrv, SAL_FREQ_BASE, which, 0, 0, 0, 0, 0, 0);
  591. *ticks_per_second = isrv.v0;
  592. *drift_info = isrv.v1;
  593. return isrv.status;
  594. }
  595. /* Flush all the processor and platform level instruction and/or data caches */
  596. static inline s64
  597. ia64_sal_cache_flush (u64 cache_type)
  598. {
  599. struct ia64_sal_retval isrv;
  600. SAL_CALL(isrv, SAL_CACHE_FLUSH, cache_type, 0, 0, 0, 0, 0, 0);
  601. return isrv.status;
  602. }
  603. /* Initialize all the processor and platform level instruction and data caches */
  604. static inline s64
  605. ia64_sal_cache_init (void)
  606. {
  607. struct ia64_sal_retval isrv;
  608. SAL_CALL(isrv, SAL_CACHE_INIT, 0, 0, 0, 0, 0, 0, 0);
  609. return isrv.status;
  610. }
  611. /*
  612. * Clear the processor and platform information logged by SAL with respect to the machine
  613. * state at the time of MCA's, INITs, CMCs, or CPEs.
  614. */
  615. static inline s64
  616. ia64_sal_clear_state_info (u64 sal_info_type)
  617. {
  618. struct ia64_sal_retval isrv;
  619. SAL_CALL_REENTRANT(isrv, SAL_CLEAR_STATE_INFO, sal_info_type, 0,
  620. 0, 0, 0, 0, 0);
  621. return isrv.status;
  622. }
  623. /* Get the processor and platform information logged by SAL with respect to the machine
  624. * state at the time of the MCAs, INITs, CMCs, or CPEs.
  625. */
  626. static inline u64
  627. ia64_sal_get_state_info (u64 sal_info_type, u64 *sal_info)
  628. {
  629. struct ia64_sal_retval isrv;
  630. SAL_CALL_REENTRANT(isrv, SAL_GET_STATE_INFO, sal_info_type, 0,
  631. sal_info, 0, 0, 0, 0);
  632. if (isrv.status)
  633. return 0;
  634. return isrv.v0;
  635. }
  636. /*
  637. * Get the maximum size of the information logged by SAL with respect to the machine state
  638. * at the time of MCAs, INITs, CMCs, or CPEs.
  639. */
  640. static inline u64
  641. ia64_sal_get_state_info_size (u64 sal_info_type)
  642. {
  643. struct ia64_sal_retval isrv;
  644. SAL_CALL_REENTRANT(isrv, SAL_GET_STATE_INFO_SIZE, sal_info_type, 0,
  645. 0, 0, 0, 0, 0);
  646. if (isrv.status)
  647. return 0;
  648. return isrv.v0;
  649. }
  650. /*
  651. * Causes the processor to go into a spin loop within SAL where SAL awaits a wakeup from
  652. * the monarch processor. Must not lock, because it will not return on any cpu until the
  653. * monarch processor sends a wake up.
  654. */
  655. static inline s64
  656. ia64_sal_mc_rendez (void)
  657. {
  658. struct ia64_sal_retval isrv;
  659. SAL_CALL_NOLOCK(isrv, SAL_MC_RENDEZ, 0, 0, 0, 0, 0, 0, 0);
  660. return isrv.status;
  661. }
  662. /*
  663. * Allow the OS to specify the interrupt number to be used by SAL to interrupt OS during
  664. * the machine check rendezvous sequence as well as the mechanism to wake up the
  665. * non-monarch processor at the end of machine check processing.
  666. * Returns the complete ia64_sal_retval because some calls return more than just a status
  667. * value.
  668. */
  669. static inline struct ia64_sal_retval
  670. ia64_sal_mc_set_params (u64 param_type, u64 i_or_m, u64 i_or_m_val, u64 timeout, u64 rz_always)
  671. {
  672. struct ia64_sal_retval isrv;
  673. SAL_CALL(isrv, SAL_MC_SET_PARAMS, param_type, i_or_m, i_or_m_val,
  674. timeout, rz_always, 0, 0);
  675. return isrv;
  676. }
  677. /* Read from PCI configuration space */
  678. static inline s64
  679. ia64_sal_pci_config_read (u64 pci_config_addr, int type, u64 size, u64 *value)
  680. {
  681. struct ia64_sal_retval isrv;
  682. SAL_CALL(isrv, SAL_PCI_CONFIG_READ, pci_config_addr, size, type, 0, 0, 0, 0);
  683. if (value)
  684. *value = isrv.v0;
  685. return isrv.status;
  686. }
  687. /* Write to PCI configuration space */
  688. static inline s64
  689. ia64_sal_pci_config_write (u64 pci_config_addr, int type, u64 size, u64 value)
  690. {
  691. struct ia64_sal_retval isrv;
  692. SAL_CALL(isrv, SAL_PCI_CONFIG_WRITE, pci_config_addr, size, value,
  693. type, 0, 0, 0);
  694. return isrv.status;
  695. }
  696. /*
  697. * Register physical addresses of locations needed by SAL when SAL procedures are invoked
  698. * in virtual mode.
  699. */
  700. static inline s64
  701. ia64_sal_register_physical_addr (u64 phys_entry, u64 phys_addr)
  702. {
  703. struct ia64_sal_retval isrv;
  704. SAL_CALL(isrv, SAL_REGISTER_PHYSICAL_ADDR, phys_entry, phys_addr,
  705. 0, 0, 0, 0, 0);
  706. return isrv.status;
  707. }
  708. /*
  709. * Register software dependent code locations within SAL. These locations are handlers or
  710. * entry points where SAL will pass control for the specified event. These event handlers
  711. * are for the bott rendezvous, MCAs and INIT scenarios.
  712. */
  713. static inline s64
  714. ia64_sal_set_vectors (u64 vector_type,
  715. u64 handler_addr1, u64 gp1, u64 handler_len1,
  716. u64 handler_addr2, u64 gp2, u64 handler_len2)
  717. {
  718. struct ia64_sal_retval isrv;
  719. SAL_CALL(isrv, SAL_SET_VECTORS, vector_type,
  720. handler_addr1, gp1, handler_len1,
  721. handler_addr2, gp2, handler_len2);
  722. return isrv.status;
  723. }
  724. /* Update the contents of PAL block in the non-volatile storage device */
  725. static inline s64
  726. ia64_sal_update_pal (u64 param_buf, u64 scratch_buf, u64 scratch_buf_size,
  727. u64 *error_code, u64 *scratch_buf_size_needed)
  728. {
  729. struct ia64_sal_retval isrv;
  730. SAL_CALL(isrv, SAL_UPDATE_PAL, param_buf, scratch_buf, scratch_buf_size,
  731. 0, 0, 0, 0);
  732. if (error_code)
  733. *error_code = isrv.v0;
  734. if (scratch_buf_size_needed)
  735. *scratch_buf_size_needed = isrv.v1;
  736. return isrv.status;
  737. }
  738. /* Get physical processor die mapping in the platform. */
  739. static inline s64
  740. ia64_sal_physical_id_info(u16 *splid)
  741. {
  742. struct ia64_sal_retval isrv;
  743. SAL_CALL(isrv, SAL_PHYSICAL_ID_INFO, 0, 0, 0, 0, 0, 0, 0);
  744. if (splid)
  745. *splid = isrv.v0;
  746. return isrv.status;
  747. }
  748. extern unsigned long sal_platform_features;
  749. extern int (*salinfo_platform_oemdata)(const u8 *, u8 **, u64 *);
  750. struct sal_ret_values {
  751. long r8; long r9; long r10; long r11;
  752. };
  753. #define IA64_SAL_OEMFUNC_MIN 0x02000000
  754. #define IA64_SAL_OEMFUNC_MAX 0x03ffffff
  755. extern int ia64_sal_oemcall(struct ia64_sal_retval *, u64, u64, u64, u64, u64,
  756. u64, u64, u64);
  757. extern int ia64_sal_oemcall_nolock(struct ia64_sal_retval *, u64, u64, u64,
  758. u64, u64, u64, u64, u64);
  759. extern int ia64_sal_oemcall_reentrant(struct ia64_sal_retval *, u64, u64, u64,
  760. u64, u64, u64, u64, u64);
  761. #ifdef CONFIG_HOTPLUG_CPU
  762. /*
  763. * System Abstraction Layer Specification
  764. * Section 3.2.5.1: OS_BOOT_RENDEZ to SAL return State.
  765. * Note: region regs are stored first in head.S _start. Hence they must
  766. * stay up front.
  767. */
  768. struct sal_to_os_boot {
  769. u64 rr[8]; /* Region Registers */
  770. u64 br[6]; /* br0: return addr into SAL boot rendez routine */
  771. u64 gr1; /* SAL:GP */
  772. u64 gr12; /* SAL:SP */
  773. u64 gr13; /* SAL: Task Pointer */
  774. u64 fpsr;
  775. u64 pfs;
  776. u64 rnat;
  777. u64 unat;
  778. u64 bspstore;
  779. u64 dcr; /* Default Control Register */
  780. u64 iva;
  781. u64 pta;
  782. u64 itv;
  783. u64 pmv;
  784. u64 cmcv;
  785. u64 lrr[2];
  786. u64 gr[4];
  787. u64 pr; /* Predicate registers */
  788. u64 lc; /* Loop Count */
  789. struct ia64_fpreg fp[20];
  790. };
  791. /*
  792. * Global array allocated for NR_CPUS at boot time
  793. */
  794. extern struct sal_to_os_boot sal_boot_rendez_state[NR_CPUS];
  795. extern void ia64_jump_to_sal(struct sal_to_os_boot *);
  796. #endif
  797. extern void ia64_sal_handler_init(void *entry_point, void *gpval);
  798. #endif /* __ASSEMBLY__ */
  799. #endif /* _ASM_IA64_SAL_H */