sal.h 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef _ASM_IA64_SAL_H
  3. #define _ASM_IA64_SAL_H
  4. /*
  5. * System Abstraction Layer definitions.
  6. *
  7. * This is based on version 2.5 of the manual "IA-64 System
  8. * Abstraction Layer".
  9. *
  10. * Copyright (C) 2001 Intel
  11. * Copyright (C) 2002 Jenna Hall <jenna.s.hall@intel.com>
  12. * Copyright (C) 2001 Fred Lewis <frederick.v.lewis@intel.com>
  13. * Copyright (C) 1998, 1999, 2001, 2003 Hewlett-Packard Co
  14. * David Mosberger-Tang <davidm@hpl.hp.com>
  15. * Copyright (C) 1999 Srinivasa Prasad Thirumalachar <sprasad@sprasad.engr.sgi.com>
  16. *
  17. * 02/01/04 J. Hall Updated Error Record Structures to conform to July 2001
  18. * revision of the SAL spec.
  19. * 01/01/03 fvlewis Updated Error Record Structures to conform with Nov. 2000
  20. * revision of the SAL spec.
  21. * 99/09/29 davidm Updated for SAL 2.6.
  22. * 00/03/29 cfleck Updated SAL Error Logging info for processor (SAL 2.6)
  23. * (plus examples of platform error info structures from smariset @ Intel)
  24. */
  25. #define IA64_SAL_PLATFORM_FEATURE_BUS_LOCK_BIT 0
  26. #define IA64_SAL_PLATFORM_FEATURE_IRQ_REDIR_HINT_BIT 1
  27. #define IA64_SAL_PLATFORM_FEATURE_IPI_REDIR_HINT_BIT 2
  28. #define IA64_SAL_PLATFORM_FEATURE_ITC_DRIFT_BIT 3
  29. #define IA64_SAL_PLATFORM_FEATURE_BUS_LOCK (1<<IA64_SAL_PLATFORM_FEATURE_BUS_LOCK_BIT)
  30. #define IA64_SAL_PLATFORM_FEATURE_IRQ_REDIR_HINT (1<<IA64_SAL_PLATFORM_FEATURE_IRQ_REDIR_HINT_BIT)
  31. #define IA64_SAL_PLATFORM_FEATURE_IPI_REDIR_HINT (1<<IA64_SAL_PLATFORM_FEATURE_IPI_REDIR_HINT_BIT)
  32. #define IA64_SAL_PLATFORM_FEATURE_ITC_DRIFT (1<<IA64_SAL_PLATFORM_FEATURE_ITC_DRIFT_BIT)
  33. #ifndef __ASSEMBLY__
  34. #include <linux/bcd.h>
  35. #include <linux/spinlock.h>
  36. #include <linux/efi.h>
  37. #include <asm/pal.h>
  38. #include <asm/fpu.h>
  39. extern 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. long status;
  94. unsigned long v0;
  95. unsigned long v1;
  96. unsigned long 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 PROCESSOR_ABSTRACTION_LAYER_OVERWRITE_GUID \
  259. EFI_GUID(0x6cb0a200, 0x893a, 0x11da, 0x96, 0xd2, 0x0, 0x10, 0x83, 0xff, \
  260. 0xca, 0x4d)
  261. #define MAX_CACHE_ERRORS 6
  262. #define MAX_TLB_ERRORS 6
  263. #define MAX_BUS_ERRORS 1
  264. /* Definition of version according to SAL spec for logging purposes */
  265. typedef struct sal_log_revision {
  266. u8 minor; /* BCD (0..99) */
  267. u8 major; /* BCD (0..99) */
  268. } sal_log_revision_t;
  269. /* Definition of timestamp according to SAL spec for logging purposes */
  270. typedef struct sal_log_timestamp {
  271. u8 slh_second; /* Second (0..59) */
  272. u8 slh_minute; /* Minute (0..59) */
  273. u8 slh_hour; /* Hour (0..23) */
  274. u8 slh_reserved;
  275. u8 slh_day; /* Day (1..31) */
  276. u8 slh_month; /* Month (1..12) */
  277. u8 slh_year; /* Year (00..99) */
  278. u8 slh_century; /* Century (19, 20, 21, ...) */
  279. } sal_log_timestamp_t;
  280. /* Definition of log record header structures */
  281. typedef struct sal_log_record_header {
  282. u64 id; /* Unique monotonically increasing ID */
  283. sal_log_revision_t revision; /* Major and Minor revision of header */
  284. u8 severity; /* Error Severity */
  285. u8 validation_bits; /* 0: platform_guid, 1: !timestamp */
  286. u32 len; /* Length of this error log in bytes */
  287. sal_log_timestamp_t timestamp; /* Timestamp */
  288. efi_guid_t platform_guid; /* Unique OEM Platform ID */
  289. } sal_log_record_header_t;
  290. #define sal_log_severity_recoverable 0
  291. #define sal_log_severity_fatal 1
  292. #define sal_log_severity_corrected 2
  293. /*
  294. * Error Recovery Info (ERI) bit decode. From SAL Spec section B.2.2 Table B-3
  295. * Error Section Error_Recovery_Info Field Definition.
  296. */
  297. #define ERI_NOT_VALID 0x0 /* Error Recovery Field is not valid */
  298. #define ERI_NOT_ACCESSIBLE 0x30 /* Resource not accessible */
  299. #define ERI_CONTAINMENT_WARN 0x22 /* Corrupt data propagated */
  300. #define ERI_UNCORRECTED_ERROR 0x20 /* Uncorrected error */
  301. #define ERI_COMPONENT_RESET 0x24 /* Component must be reset */
  302. #define ERI_CORR_ERROR_LOG 0x21 /* Corrected error, needs logging */
  303. #define ERI_CORR_ERROR_THRESH 0x29 /* Corrected error threshold exceeded */
  304. /* Definition of log section header structures */
  305. typedef struct sal_log_sec_header {
  306. efi_guid_t guid; /* Unique Section ID */
  307. sal_log_revision_t revision; /* Major and Minor revision of Section */
  308. u8 error_recovery_info; /* Platform error recovery status */
  309. u8 reserved;
  310. u32 len; /* Section length */
  311. } sal_log_section_hdr_t;
  312. typedef struct sal_log_mod_error_info {
  313. struct {
  314. u64 check_info : 1,
  315. requestor_identifier : 1,
  316. responder_identifier : 1,
  317. target_identifier : 1,
  318. precise_ip : 1,
  319. reserved : 59;
  320. } valid;
  321. u64 check_info;
  322. u64 requestor_identifier;
  323. u64 responder_identifier;
  324. u64 target_identifier;
  325. u64 precise_ip;
  326. } sal_log_mod_error_info_t;
  327. typedef struct sal_processor_static_info {
  328. struct {
  329. u64 minstate : 1,
  330. br : 1,
  331. cr : 1,
  332. ar : 1,
  333. rr : 1,
  334. fr : 1,
  335. reserved : 58;
  336. } valid;
  337. pal_min_state_area_t min_state_area;
  338. u64 br[8];
  339. u64 cr[128];
  340. u64 ar[128];
  341. u64 rr[8];
  342. struct ia64_fpreg __attribute__ ((packed)) fr[128];
  343. } sal_processor_static_info_t;
  344. struct sal_cpuid_info {
  345. u64 regs[5];
  346. u64 reserved;
  347. };
  348. typedef struct sal_log_processor_info {
  349. sal_log_section_hdr_t header;
  350. struct {
  351. u64 proc_error_map : 1,
  352. proc_state_param : 1,
  353. proc_cr_lid : 1,
  354. psi_static_struct : 1,
  355. num_cache_check : 4,
  356. num_tlb_check : 4,
  357. num_bus_check : 4,
  358. num_reg_file_check : 4,
  359. num_ms_check : 4,
  360. cpuid_info : 1,
  361. reserved1 : 39;
  362. } valid;
  363. u64 proc_error_map;
  364. u64 proc_state_parameter;
  365. u64 proc_cr_lid;
  366. /*
  367. * The rest of this structure consists of variable-length arrays, which can't be
  368. * expressed in C.
  369. */
  370. sal_log_mod_error_info_t info[0];
  371. /*
  372. * This is what the rest looked like if C supported variable-length arrays:
  373. *
  374. * sal_log_mod_error_info_t cache_check_info[.valid.num_cache_check];
  375. * sal_log_mod_error_info_t tlb_check_info[.valid.num_tlb_check];
  376. * sal_log_mod_error_info_t bus_check_info[.valid.num_bus_check];
  377. * sal_log_mod_error_info_t reg_file_check_info[.valid.num_reg_file_check];
  378. * sal_log_mod_error_info_t ms_check_info[.valid.num_ms_check];
  379. * struct sal_cpuid_info cpuid_info;
  380. * sal_processor_static_info_t processor_static_info;
  381. */
  382. } sal_log_processor_info_t;
  383. /* Given a sal_log_processor_info_t pointer, return a pointer to the processor_static_info: */
  384. #define SAL_LPI_PSI_INFO(l) \
  385. ({ sal_log_processor_info_t *_l = (l); \
  386. ((sal_processor_static_info_t *) \
  387. ((char *) _l->info + ((_l->valid.num_cache_check + _l->valid.num_tlb_check \
  388. + _l->valid.num_bus_check + _l->valid.num_reg_file_check \
  389. + _l->valid.num_ms_check) * sizeof(sal_log_mod_error_info_t) \
  390. + sizeof(struct sal_cpuid_info)))); \
  391. })
  392. /* platform error log structures */
  393. typedef struct sal_log_mem_dev_err_info {
  394. sal_log_section_hdr_t header;
  395. struct {
  396. u64 error_status : 1,
  397. physical_addr : 1,
  398. addr_mask : 1,
  399. node : 1,
  400. card : 1,
  401. module : 1,
  402. bank : 1,
  403. device : 1,
  404. row : 1,
  405. column : 1,
  406. bit_position : 1,
  407. requestor_id : 1,
  408. responder_id : 1,
  409. target_id : 1,
  410. bus_spec_data : 1,
  411. oem_id : 1,
  412. oem_data : 1,
  413. reserved : 47;
  414. } valid;
  415. u64 error_status;
  416. u64 physical_addr;
  417. u64 addr_mask;
  418. u16 node;
  419. u16 card;
  420. u16 module;
  421. u16 bank;
  422. u16 device;
  423. u16 row;
  424. u16 column;
  425. u16 bit_position;
  426. u64 requestor_id;
  427. u64 responder_id;
  428. u64 target_id;
  429. u64 bus_spec_data;
  430. u8 oem_id[16];
  431. u8 oem_data[1]; /* Variable length data */
  432. } sal_log_mem_dev_err_info_t;
  433. typedef struct sal_log_sel_dev_err_info {
  434. sal_log_section_hdr_t header;
  435. struct {
  436. u64 record_id : 1,
  437. record_type : 1,
  438. generator_id : 1,
  439. evm_rev : 1,
  440. sensor_type : 1,
  441. sensor_num : 1,
  442. event_dir : 1,
  443. event_data1 : 1,
  444. event_data2 : 1,
  445. event_data3 : 1,
  446. reserved : 54;
  447. } valid;
  448. u16 record_id;
  449. u8 record_type;
  450. u8 timestamp[4];
  451. u16 generator_id;
  452. u8 evm_rev;
  453. u8 sensor_type;
  454. u8 sensor_num;
  455. u8 event_dir;
  456. u8 event_data1;
  457. u8 event_data2;
  458. u8 event_data3;
  459. } sal_log_sel_dev_err_info_t;
  460. typedef struct sal_log_pci_bus_err_info {
  461. sal_log_section_hdr_t header;
  462. struct {
  463. u64 err_status : 1,
  464. err_type : 1,
  465. bus_id : 1,
  466. bus_address : 1,
  467. bus_data : 1,
  468. bus_cmd : 1,
  469. requestor_id : 1,
  470. responder_id : 1,
  471. target_id : 1,
  472. oem_data : 1,
  473. reserved : 54;
  474. } valid;
  475. u64 err_status;
  476. u16 err_type;
  477. u16 bus_id;
  478. u32 reserved;
  479. u64 bus_address;
  480. u64 bus_data;
  481. u64 bus_cmd;
  482. u64 requestor_id;
  483. u64 responder_id;
  484. u64 target_id;
  485. u8 oem_data[1]; /* Variable length data */
  486. } sal_log_pci_bus_err_info_t;
  487. typedef struct sal_log_smbios_dev_err_info {
  488. sal_log_section_hdr_t header;
  489. struct {
  490. u64 event_type : 1,
  491. length : 1,
  492. time_stamp : 1,
  493. data : 1,
  494. reserved1 : 60;
  495. } valid;
  496. u8 event_type;
  497. u8 length;
  498. u8 time_stamp[6];
  499. u8 data[1]; /* data of variable length, length == slsmb_length */
  500. } sal_log_smbios_dev_err_info_t;
  501. typedef struct sal_log_pci_comp_err_info {
  502. sal_log_section_hdr_t header;
  503. struct {
  504. u64 err_status : 1,
  505. comp_info : 1,
  506. num_mem_regs : 1,
  507. num_io_regs : 1,
  508. reg_data_pairs : 1,
  509. oem_data : 1,
  510. reserved : 58;
  511. } valid;
  512. u64 err_status;
  513. struct {
  514. u16 vendor_id;
  515. u16 device_id;
  516. u8 class_code[3];
  517. u8 func_num;
  518. u8 dev_num;
  519. u8 bus_num;
  520. u8 seg_num;
  521. u8 reserved[5];
  522. } comp_info;
  523. u32 num_mem_regs;
  524. u32 num_io_regs;
  525. u64 reg_data_pairs[1];
  526. /*
  527. * array of address/data register pairs is num_mem_regs + num_io_regs elements
  528. * long. Each array element consists of a u64 address followed by a u64 data
  529. * value. The oem_data array immediately follows the reg_data_pairs array
  530. */
  531. u8 oem_data[1]; /* Variable length data */
  532. } sal_log_pci_comp_err_info_t;
  533. typedef struct sal_log_plat_specific_err_info {
  534. sal_log_section_hdr_t header;
  535. struct {
  536. u64 err_status : 1,
  537. guid : 1,
  538. oem_data : 1,
  539. reserved : 61;
  540. } valid;
  541. u64 err_status;
  542. efi_guid_t guid;
  543. u8 oem_data[1]; /* platform specific variable length data */
  544. } sal_log_plat_specific_err_info_t;
  545. typedef struct sal_log_host_ctlr_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_host_ctlr_err_info_t;
  563. typedef struct sal_log_plat_bus_err_info {
  564. sal_log_section_hdr_t header;
  565. struct {
  566. u64 err_status : 1,
  567. requestor_id : 1,
  568. responder_id : 1,
  569. target_id : 1,
  570. bus_spec_data : 1,
  571. oem_data : 1,
  572. reserved : 58;
  573. } valid;
  574. u64 err_status;
  575. u64 requestor_id;
  576. u64 responder_id;
  577. u64 target_id;
  578. u64 bus_spec_data;
  579. u8 oem_data[1]; /* Variable length OEM data */
  580. } sal_log_plat_bus_err_info_t;
  581. /* Overall platform error section structure */
  582. typedef union sal_log_platform_err_info {
  583. sal_log_mem_dev_err_info_t mem_dev_err;
  584. sal_log_sel_dev_err_info_t sel_dev_err;
  585. sal_log_pci_bus_err_info_t pci_bus_err;
  586. sal_log_smbios_dev_err_info_t smbios_dev_err;
  587. sal_log_pci_comp_err_info_t pci_comp_err;
  588. sal_log_plat_specific_err_info_t plat_specific_err;
  589. sal_log_host_ctlr_err_info_t host_ctlr_err;
  590. sal_log_plat_bus_err_info_t plat_bus_err;
  591. } sal_log_platform_err_info_t;
  592. /* SAL log over-all, multi-section error record structure (processor+platform) */
  593. typedef struct err_rec {
  594. sal_log_record_header_t sal_elog_header;
  595. sal_log_processor_info_t proc_err;
  596. sal_log_platform_err_info_t plat_err;
  597. u8 oem_data_pad[1024];
  598. } ia64_err_rec_t;
  599. /*
  600. * Now define a couple of inline functions for improved type checking
  601. * and convenience.
  602. */
  603. extern s64 ia64_sal_cache_flush (u64 cache_type);
  604. extern void __init check_sal_cache_flush (void);
  605. /* Initialize all the processor and platform level instruction and data caches */
  606. static inline s64
  607. ia64_sal_cache_init (void)
  608. {
  609. struct ia64_sal_retval isrv;
  610. SAL_CALL(isrv, SAL_CACHE_INIT, 0, 0, 0, 0, 0, 0, 0);
  611. return isrv.status;
  612. }
  613. /*
  614. * Clear the processor and platform information logged by SAL with respect to the machine
  615. * state at the time of MCA's, INITs, CMCs, or CPEs.
  616. */
  617. static inline s64
  618. ia64_sal_clear_state_info (u64 sal_info_type)
  619. {
  620. struct ia64_sal_retval isrv;
  621. SAL_CALL_REENTRANT(isrv, SAL_CLEAR_STATE_INFO, sal_info_type, 0,
  622. 0, 0, 0, 0, 0);
  623. return isrv.status;
  624. }
  625. /* Get the processor and platform information logged by SAL with respect to the machine
  626. * state at the time of the MCAs, INITs, CMCs, or CPEs.
  627. */
  628. static inline u64
  629. ia64_sal_get_state_info (u64 sal_info_type, u64 *sal_info)
  630. {
  631. struct ia64_sal_retval isrv;
  632. SAL_CALL_REENTRANT(isrv, SAL_GET_STATE_INFO, sal_info_type, 0,
  633. sal_info, 0, 0, 0, 0);
  634. if (isrv.status)
  635. return 0;
  636. return isrv.v0;
  637. }
  638. /*
  639. * Get the maximum size of the information logged by SAL with respect to the machine state
  640. * at the time of MCAs, INITs, CMCs, or CPEs.
  641. */
  642. static inline u64
  643. ia64_sal_get_state_info_size (u64 sal_info_type)
  644. {
  645. struct ia64_sal_retval isrv;
  646. SAL_CALL_REENTRANT(isrv, SAL_GET_STATE_INFO_SIZE, sal_info_type, 0,
  647. 0, 0, 0, 0, 0);
  648. if (isrv.status)
  649. return 0;
  650. return isrv.v0;
  651. }
  652. /*
  653. * Causes the processor to go into a spin loop within SAL where SAL awaits a wakeup from
  654. * the monarch processor. Must not lock, because it will not return on any cpu until the
  655. * monarch processor sends a wake up.
  656. */
  657. static inline s64
  658. ia64_sal_mc_rendez (void)
  659. {
  660. struct ia64_sal_retval isrv;
  661. SAL_CALL_NOLOCK(isrv, SAL_MC_RENDEZ, 0, 0, 0, 0, 0, 0, 0);
  662. return isrv.status;
  663. }
  664. /*
  665. * Allow the OS to specify the interrupt number to be used by SAL to interrupt OS during
  666. * the machine check rendezvous sequence as well as the mechanism to wake up the
  667. * non-monarch processor at the end of machine check processing.
  668. * Returns the complete ia64_sal_retval because some calls return more than just a status
  669. * value.
  670. */
  671. static inline struct ia64_sal_retval
  672. ia64_sal_mc_set_params (u64 param_type, u64 i_or_m, u64 i_or_m_val, u64 timeout, u64 rz_always)
  673. {
  674. struct ia64_sal_retval isrv;
  675. SAL_CALL(isrv, SAL_MC_SET_PARAMS, param_type, i_or_m, i_or_m_val,
  676. timeout, rz_always, 0, 0);
  677. return isrv;
  678. }
  679. /* Read from PCI configuration space */
  680. static inline s64
  681. ia64_sal_pci_config_read (u64 pci_config_addr, int type, u64 size, u64 *value)
  682. {
  683. struct ia64_sal_retval isrv;
  684. SAL_CALL(isrv, SAL_PCI_CONFIG_READ, pci_config_addr, size, type, 0, 0, 0, 0);
  685. if (value)
  686. *value = isrv.v0;
  687. return isrv.status;
  688. }
  689. /* Write to PCI configuration space */
  690. static inline s64
  691. ia64_sal_pci_config_write (u64 pci_config_addr, int type, u64 size, u64 value)
  692. {
  693. struct ia64_sal_retval isrv;
  694. SAL_CALL(isrv, SAL_PCI_CONFIG_WRITE, pci_config_addr, size, value,
  695. type, 0, 0, 0);
  696. return isrv.status;
  697. }
  698. /*
  699. * Register physical addresses of locations needed by SAL when SAL procedures are invoked
  700. * in virtual mode.
  701. */
  702. static inline s64
  703. ia64_sal_register_physical_addr (u64 phys_entry, u64 phys_addr)
  704. {
  705. struct ia64_sal_retval isrv;
  706. SAL_CALL(isrv, SAL_REGISTER_PHYSICAL_ADDR, phys_entry, phys_addr,
  707. 0, 0, 0, 0, 0);
  708. return isrv.status;
  709. }
  710. /*
  711. * Register software dependent code locations within SAL. These locations are handlers or
  712. * entry points where SAL will pass control for the specified event. These event handlers
  713. * are for the bott rendezvous, MCAs and INIT scenarios.
  714. */
  715. static inline s64
  716. ia64_sal_set_vectors (u64 vector_type,
  717. u64 handler_addr1, u64 gp1, u64 handler_len1,
  718. u64 handler_addr2, u64 gp2, u64 handler_len2)
  719. {
  720. struct ia64_sal_retval isrv;
  721. SAL_CALL(isrv, SAL_SET_VECTORS, vector_type,
  722. handler_addr1, gp1, handler_len1,
  723. handler_addr2, gp2, handler_len2);
  724. return isrv.status;
  725. }
  726. /* Update the contents of PAL block in the non-volatile storage device */
  727. static inline s64
  728. ia64_sal_update_pal (u64 param_buf, u64 scratch_buf, u64 scratch_buf_size,
  729. u64 *error_code, u64 *scratch_buf_size_needed)
  730. {
  731. struct ia64_sal_retval isrv;
  732. SAL_CALL(isrv, SAL_UPDATE_PAL, param_buf, scratch_buf, scratch_buf_size,
  733. 0, 0, 0, 0);
  734. if (error_code)
  735. *error_code = isrv.v0;
  736. if (scratch_buf_size_needed)
  737. *scratch_buf_size_needed = isrv.v1;
  738. return isrv.status;
  739. }
  740. /* Get physical processor die mapping in the platform. */
  741. static inline s64
  742. ia64_sal_physical_id_info(u16 *splid)
  743. {
  744. struct ia64_sal_retval isrv;
  745. if (sal_revision < SAL_VERSION_CODE(3,2))
  746. return -1;
  747. SAL_CALL(isrv, SAL_PHYSICAL_ID_INFO, 0, 0, 0, 0, 0, 0, 0);
  748. if (splid)
  749. *splid = isrv.v0;
  750. return isrv.status;
  751. }
  752. extern unsigned long sal_platform_features;
  753. extern int (*salinfo_platform_oemdata)(const u8 *, u8 **, u64 *);
  754. struct sal_ret_values {
  755. long r8; long r9; long r10; long r11;
  756. };
  757. #define IA64_SAL_OEMFUNC_MIN 0x02000000
  758. #define IA64_SAL_OEMFUNC_MAX 0x03ffffff
  759. extern int ia64_sal_oemcall(struct ia64_sal_retval *, u64, u64, u64, u64, u64,
  760. u64, u64, u64);
  761. extern int ia64_sal_oemcall_nolock(struct ia64_sal_retval *, u64, u64, u64,
  762. u64, u64, u64, u64, u64);
  763. extern int ia64_sal_oemcall_reentrant(struct ia64_sal_retval *, u64, u64, u64,
  764. u64, u64, u64, u64, u64);
  765. extern long
  766. ia64_sal_freq_base (unsigned long which, unsigned long *ticks_per_second,
  767. unsigned long *drift_info);
  768. #ifdef CONFIG_HOTPLUG_CPU
  769. /*
  770. * System Abstraction Layer Specification
  771. * Section 3.2.5.1: OS_BOOT_RENDEZ to SAL return State.
  772. * Note: region regs are stored first in head.S _start. Hence they must
  773. * stay up front.
  774. */
  775. struct sal_to_os_boot {
  776. u64 rr[8]; /* Region Registers */
  777. u64 br[6]; /* br0:
  778. * return addr into SAL boot rendez routine */
  779. u64 gr1; /* SAL:GP */
  780. u64 gr12; /* SAL:SP */
  781. u64 gr13; /* SAL: Task Pointer */
  782. u64 fpsr;
  783. u64 pfs;
  784. u64 rnat;
  785. u64 unat;
  786. u64 bspstore;
  787. u64 dcr; /* Default Control Register */
  788. u64 iva;
  789. u64 pta;
  790. u64 itv;
  791. u64 pmv;
  792. u64 cmcv;
  793. u64 lrr[2];
  794. u64 gr[4];
  795. u64 pr; /* Predicate registers */
  796. u64 lc; /* Loop Count */
  797. struct ia64_fpreg fp[20];
  798. };
  799. /*
  800. * Global array allocated for NR_CPUS at boot time
  801. */
  802. extern struct sal_to_os_boot sal_boot_rendez_state[NR_CPUS];
  803. extern void ia64_jump_to_sal(struct sal_to_os_boot *);
  804. #endif
  805. extern void ia64_sal_handler_init(void *entry_point, void *gpval);
  806. #define PALO_MAX_TLB_PURGES 0xFFFF
  807. #define PALO_SIG "PALO"
  808. struct palo_table {
  809. u8 signature[4]; /* Should be "PALO" */
  810. u32 length;
  811. u8 minor_revision;
  812. u8 major_revision;
  813. u8 checksum;
  814. u8 reserved1[5];
  815. u16 max_tlb_purges;
  816. u8 reserved2[6];
  817. };
  818. #define NPTCG_FROM_PAL 0
  819. #define NPTCG_FROM_PALO 1
  820. #define NPTCG_FROM_KERNEL_PARAMETER 2
  821. #endif /* __ASSEMBLY__ */
  822. #endif /* _ASM_IA64_SAL_H */