1 #ifndef _ASM_IA64_SAL_H
2 #define _ASM_IA64_SAL_H
5 * System Abstraction Layer definitions.
7 * This is based on version 2.5 of the manual "IA-64 System
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 Hewlett-Packard Co
14 * Copyright (C) 1998, 1999, 2001 David Mosberger-Tang <davidm@hpl.hp.com>
15 * Copyright (C) 1999 Srinivasa Prasad Thirumalachar <sprasad@sprasad.engr.sgi.com>
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)
26 #include <linux/spinlock.h>
27 #include <linux/efi.h>
30 #include <asm/system.h>
33 extern spinlock_t sal_lock;
35 /* SAL spec _requires_ eight args for each call. */
36 #define __SAL_CALL(result,a0,a1,a2,a3,a4,a5,a6,a7) \
37 result = (*ia64_sal)(a0,a1,a2,a3,a4,a5,a6,a7)
39 # define SAL_CALL(result,args...) do { \
40 unsigned long flags; \
41 struct ia64_fpreg fr[6]; \
42 ia64_save_scratch_fpregs(fr); \
43 spin_lock_irqsave(&sal_lock, flags); \
44 __SAL_CALL(result,args); \
45 spin_unlock_irqrestore(&sal_lock, flags); \
46 ia64_load_scratch_fpregs(fr); \
49 #define SAL_SET_VECTORS 0x01000000
50 #define SAL_GET_STATE_INFO 0x01000001
51 #define SAL_GET_STATE_INFO_SIZE 0x01000002
52 #define SAL_CLEAR_STATE_INFO 0x01000003
53 #define SAL_MC_RENDEZ 0x01000004
54 #define SAL_MC_SET_PARAMS 0x01000005
55 #define SAL_REGISTER_PHYSICAL_ADDR 0x01000006
57 #define SAL_CACHE_FLUSH 0x01000008
58 #define SAL_CACHE_INIT 0x01000009
59 #define SAL_PCI_CONFIG_READ 0x01000010
60 #define SAL_PCI_CONFIG_WRITE 0x01000011
61 #define SAL_FREQ_BASE 0x01000012
63 #define SAL_UPDATE_PAL 0x01000020
65 struct ia64_sal_retval {
67 * A zero status value indicates call completed without error.
68 * A negative status value indicates reason of call failure.
69 * A positive status value indicates success but an
70 * informational value should be printed (e.g., "reboot for
71 * change to take effect").
79 typedef struct ia64_sal_retval (*ia64_sal_handler) (u64, ...);
82 SAL_FREQ_BASE_PLATFORM = 0,
83 SAL_FREQ_BASE_INTERVAL_TIMER = 1,
84 SAL_FREQ_BASE_REALTIME_CLOCK = 2
88 * The SAL system table is followed by a variable number of variable
89 * length descriptors. The structure of these descriptors follows
91 * The defininition follows SAL specs from July 2000
93 struct ia64_sal_systab {
94 u8 signature[4]; /* should be "SST_" */
95 u32 size; /* size of this table in bytes */
98 u16 entry_count; /* # of entries in variable portion */
105 /* oem_id & product_id: terminating NUL is missing if string is exactly 32 bytes long. */
107 u8 product_id[32]; /* ASCII product id */
111 enum sal_systab_entry_type {
112 SAL_DESC_ENTRY_POINT = 0,
114 SAL_DESC_PLATFORM_FEATURE = 2,
117 SAL_DESC_AP_WAKEUP = 5
129 #define SAL_DESC_SIZE(type) "\060\040\020\040\020\020"[(unsigned) type]
131 typedef struct ia64_sal_desc_entry_point {
138 }ia64_sal_desc_entry_point_t;
140 typedef struct ia64_sal_desc_memory {
142 u8 used_by_sal; /* needs to be mapped for SAL? */
143 u8 mem_attr; /* current memory attribute setting */
144 u8 access_rights; /* access rights set up by SAL */
145 u8 mem_attr_mask; /* mask of supported memory attributes */
147 u8 mem_type; /* memory type */
148 u8 mem_usage; /* memory usage */
149 u64 addr; /* physical address of memory */
150 u32 length; /* length (multiple of 4KB pages) */
153 } ia64_sal_desc_memory_t;
155 #define IA64_SAL_PLATFORM_FEATURE_BUS_LOCK (1 << 0)
156 #define IA64_SAL_PLATFORM_FEATURE_IRQ_REDIR_HINT (1 << 1)
157 #define IA64_SAL_PLATFORM_FEATURE_IPI_REDIR_HINT (1 << 2)
158 #define IA64_SAL_PLATFORM_FEATURE_ITC_DRIFT (1 << 3)
160 typedef struct ia64_sal_desc_platform_feature {
164 } ia64_sal_desc_platform_feature_t;
166 typedef struct ia64_sal_desc_tr {
168 u8 tr_type; /* 0 == instruction, 1 == data */
169 u8 regnum; /* translation register number */
171 u64 addr; /* virtual address of area covered */
172 u64 page_size; /* encoded page size */
174 } ia64_sal_desc_tr_t;
176 typedef struct ia64_sal_desc_ptc {
179 u32 num_domains; /* # of coherence domains */
180 u64 domain_info; /* physical address of domain info table */
181 } ia64_sal_desc_ptc_t;
183 typedef struct ia64_sal_ptc_domain_info {
184 u64 proc_count; /* number of processors in domain */
185 u64 proc_list; /* physical address of LID array */
186 } ia64_sal_ptc_domain_info_t;
188 typedef struct ia64_sal_ptc_domain_proc_entry {
189 u64 id : 8; /* id of processor */
190 u64 eid : 8; /* eid of processor */
191 } ia64_sal_ptc_domain_proc_entry_t;
194 #define IA64_SAL_AP_EXTERNAL_INT 0
196 typedef struct ia64_sal_desc_ap_wakeup {
198 u8 mechanism; /* 0 == external interrupt */
200 u64 vector; /* interrupt vector in range 0x10-0xff */
201 } ia64_sal_desc_ap_wakeup_t ;
203 extern ia64_sal_handler ia64_sal;
204 extern struct ia64_sal_desc_ptc *ia64_ptc_domain_info;
206 extern const char *ia64_sal_strerror (long status);
207 extern void ia64_sal_init (struct ia64_sal_systab *sal_systab);
209 /* SAL information type encodings */
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 */
217 /* Encodings for machine check parameter types */
219 SAL_MC_PARAM_RENDEZ_INT = 1, /* Rendezevous interrupt */
220 SAL_MC_PARAM_RENDEZ_WAKEUP = 2, /* Wakeup */
221 SAL_MC_PARAM_CPE_INT = 3 /* Corrected Platform Error Int */
224 /* Encodings for rendezvous mechanisms */
226 SAL_MC_PARAM_MECHANISM_INT = 1, /* Use interrupt */
227 SAL_MC_PARAM_MECHANISM_MEM = 2 /* Use memory synchronization variable*/
230 /* Encodings for vectors which can be registered by the OS with SAL */
232 SAL_VECTOR_OS_MCA = 0,
233 SAL_VECTOR_OS_INIT = 1,
234 SAL_VECTOR_OS_BOOT_RENDEZ = 2
237 /* Encodings for mca_opt parameter sent to SAL_MC_SET_PARAMS */
238 #define SAL_MC_PARAM_RZ_ALWAYS 0x1
239 #define SAL_MC_PARAM_BINIT_ESCALATE 0x10
242 ** Definition of the SAL Error Log from the SAL spec
245 /* SAL Error Record Section GUID Definitions */
246 #define SAL_PROC_DEV_ERR_SECT_GUID \
247 EFI_GUID ( 0xe429faf1, 0x3cb7, 0x11d4, 0xbc, 0xa7, 0x0, 0x80, \
248 0xc7, 0x3c, 0x88, 0x81 )
249 #define SAL_PLAT_MEM_DEV_ERR_SECT_GUID \
250 EFI_GUID( 0xe429faf2, 0x3cb7, 0x11d4, 0xbc, 0xa7, 0x0, 0x80, \
251 0xc7, 0x3c, 0x88, 0x81 )
252 #define SAL_PLAT_SEL_DEV_ERR_SECT_GUID \
253 EFI_GUID( 0xe429faf3, 0x3cb7, 0x11d4, 0xbc, 0xa7, 0x0, 0x80, \
254 0xc7, 0x3c, 0x88, 0x81 )
255 #define SAL_PLAT_PCI_BUS_ERR_SECT_GUID \
256 EFI_GUID( 0xe429faf4, 0x3cb7, 0x11d4, 0xbc, 0xa7, 0x0, 0x80, \
257 0xc7, 0x3c, 0x88, 0x81 )
258 #define SAL_PLAT_SMBIOS_DEV_ERR_SECT_GUID \
259 EFI_GUID( 0xe429faf5, 0x3cb7, 0x11d4, 0xbc, 0xa7, 0x0, 0x80, \
260 0xc7, 0x3c, 0x88, 0x81 )
261 #define SAL_PLAT_PCI_COMP_ERR_SECT_GUID \
262 EFI_GUID( 0xe429faf6, 0x3cb7, 0x11d4, 0xbc, 0xa7, 0x0, 0x80, \
263 0xc7, 0x3c, 0x88, 0x81 )
264 #define SAL_PLAT_SPECIFIC_ERR_SECT_GUID \
265 EFI_GUID( 0xe429faf7, 0x3cb7, 0x11d4, 0xbc, 0xa7, 0x0, 0x80, \
266 0xc7, 0x3c, 0x88, 0x81 )
267 #define SAL_PLAT_HOST_CTLR_ERR_SECT_GUID \
268 EFI_GUID( 0xe429faf8, 0x3cb7, 0x11d4, 0xbc, 0xa7, 0x0, 0x80, \
269 0xc7, 0x3c, 0x88, 0x81 )
270 #define SAL_PLAT_BUS_ERR_SECT_GUID \
271 EFI_GUID( 0xe429faf9, 0x3cb7, 0x11d4, 0xbc, 0xa7, 0x0, 0x80, \
272 0xc7, 0x3c, 0x88, 0x81 )
274 #define MAX_CACHE_ERRORS 6
275 #define MAX_TLB_ERRORS 6
276 #define MAX_BUS_ERRORS 1
278 /* Definition of version according to SAL spec for logging purposes */
279 typedef struct sal_log_revision
281 u8 minor; /* BCD (0..99) */
282 u8 major; /* BCD (0..99) */
283 } sal_log_revision_t;
285 /* Definition of timestamp according to SAL spec for logging purposes */
286 typedef struct sal_log_timestamp
288 u8 slh_second; /* Second (0..59) */
289 u8 slh_minute; /* Minute (0..59) */
290 u8 slh_hour; /* Hour (0..23) */
292 u8 slh_day; /* Day (1..31) */
293 u8 slh_month; /* Month (1..12) */
294 u8 slh_year; /* Year (00..99) */
295 u8 slh_century; /* Century (19, 20, 21, ...) */
296 } sal_log_timestamp_t;
298 /* Definition of log record header structures */
299 typedef struct sal_log_record_header
301 u64 id; /* Unique monotonically increasing ID */
302 sal_log_revision_t revision; /* Major and Minor revision of header */
303 u16 severity; /* Error Severity */
304 u32 len; /* Length of this error log in bytes */
305 sal_log_timestamp_t timestamp; /* Timestamp */
306 efi_guid_t platform_guid; /* Unique OEM Platform ID */
307 } sal_log_record_header_t;
309 /* Definition of log section header structures */
310 typedef struct sal_log_sec_header
312 efi_guid_t guid; /* Unique Section ID */
313 sal_log_revision_t revision; /* Major and Minor revision of Section */
315 u32 len; /* Section length */
316 } sal_log_section_hdr_t;
318 typedef struct sal_log_mod_error_info
323 requestor_identifier : 1,
324 responder_identifier : 1,
325 target_identifier : 1,
330 u64 requestor_identifier;
331 u64 responder_identifier;
332 u64 target_identifier;
334 } sal_log_mod_error_info_t;
336 typedef struct sal_processor_static_info
348 pal_min_state_area_t min_state_area;
353 struct ia64_fpreg fr[128];
354 } sal_processor_static_info_t;
356 typedef struct sal_log_processor_info
358 sal_log_section_hdr_t header;
361 u64 proc_error_map : 1,
362 proc_state_param : 1,
364 psi_static_struct : 1,
368 num_reg_file_check : 4,
374 u64 proc_state_parameter;
376 sal_log_mod_error_info_t cache_check_info[16];
377 sal_log_mod_error_info_t tlb_check_info[16];
378 sal_log_mod_error_info_t bus_check_info[16];
379 sal_log_mod_error_info_t reg_file_check_info[16];
380 sal_log_mod_error_info_t ms_check_info[16];
386 sal_processor_static_info_t processor_static_info;
387 } sal_log_processor_info_t;
389 /* platform error log structures */
391 typedef struct sal_log_mem_dev_err_info
393 sal_log_section_hdr_t header;
396 u64 error_status : 1,
431 u8 oem_data[1]; /* Variable length data */
432 } sal_log_mem_dev_err_info_t;
434 typedef struct sal_log_sel_dev_err_info
436 sal_log_section_hdr_t header;
462 } sal_log_sel_dev_err_info_t;
464 typedef struct sal_log_pci_bus_err_info
466 sal_log_section_hdr_t header;
491 u8 oem_data[1]; /* Variable length data */
492 } sal_log_pci_bus_err_info_t;
494 typedef struct sal_log_smbios_dev_err_info
496 sal_log_section_hdr_t header;
508 u8 data[1]; // data of variable length, length == slsmb_length
509 } sal_log_smbios_dev_err_info_t;
511 typedef struct sal_log_pci_comp_err_info
513 sal_log_section_hdr_t header;
538 u64 reg_data_pairs[1];
539 /* array of address/data register pairs is num_mem_regs + num_io_regs
540 elements long. Each array element consists of a u64 address followed
541 by a u64 data value. The oem_data array immediately follows the the
542 reg_data_pairs array */
543 u8 oem_data[1]; /* Variable length data */
544 } sal_log_pci_comp_err_info_t;
546 typedef struct sal_log_plat_specific_err_info
548 sal_log_section_hdr_t header;
558 u8 oem_data[1]; /* platform specific variable length data */
559 } sal_log_plat_specific_err_info_t;
561 typedef struct sal_log_host_ctlr_err_info
563 sal_log_section_hdr_t header;
579 u8 oem_data[1]; /* Variable length OEM data */
580 } sal_log_host_ctlr_err_info_t;
582 typedef struct sal_log_plat_bus_err_info
584 sal_log_section_hdr_t header;
600 u8 oem_data[1]; /* Variable length OEM data */
601 } sal_log_plat_bus_err_info_t;
603 /* Overall platform error section structure */
604 typedef union sal_log_platform_err_info
606 sal_log_mem_dev_err_info_t mem_dev_err;
607 sal_log_sel_dev_err_info_t sel_dev_err;
608 sal_log_pci_bus_err_info_t pci_bus_err;
609 sal_log_smbios_dev_err_info_t smbios_dev_err;
610 sal_log_pci_comp_err_info_t pci_comp_err;
611 sal_log_plat_specific_err_info_t plat_specific_err;
612 sal_log_host_ctlr_err_info_t host_ctlr_err;
613 sal_log_plat_bus_err_info_t plat_bus_err;
614 } sal_log_platform_err_info_t;
616 /* SAL log over-all, multi-section error record structure (processor+platform) */
617 typedef struct err_rec
619 sal_log_record_header_t sal_elog_header;
620 sal_log_processor_info_t proc_err;
621 sal_log_platform_err_info_t plat_err;
622 u8 oem_data_pad[1024];
626 * Now define a couple of inline functions for improved type checking
630 ia64_sal_freq_base (unsigned long which, unsigned long *ticks_per_second,
631 unsigned long *drift_info)
633 struct ia64_sal_retval isrv;
635 SAL_CALL(isrv, SAL_FREQ_BASE, which, 0, 0, 0, 0, 0, 0);
636 *ticks_per_second = isrv.v0;
637 *drift_info = isrv.v1;
641 /* Flush all the processor and platform level instruction and/or data caches */
643 ia64_sal_cache_flush (u64 cache_type)
645 struct ia64_sal_retval isrv;
646 SAL_CALL(isrv, SAL_CACHE_FLUSH, cache_type, 0, 0, 0, 0, 0, 0);
652 /* Initialize all the processor and platform level instruction and data caches */
654 ia64_sal_cache_init (void)
656 struct ia64_sal_retval isrv;
657 SAL_CALL(isrv, SAL_CACHE_INIT, 0, 0, 0, 0, 0, 0, 0);
661 /* Clear the processor and platform information logged by SAL with respect to the
662 * machine state at the time of MCA's, INITs, CMCs, or CPEs.
665 ia64_sal_clear_state_info (u64 sal_info_type)
667 struct ia64_sal_retval isrv;
668 SAL_CALL(isrv, SAL_CLEAR_STATE_INFO, sal_info_type, 0,
674 /* Get the processor and platform information logged by SAL with respect to the machine
675 * state at the time of the MCAs, INITs, CMCs, or CPEs.
678 ia64_sal_get_state_info (u64 sal_info_type, u64 *sal_info)
680 struct ia64_sal_retval isrv;
681 SAL_CALL(isrv, SAL_GET_STATE_INFO, sal_info_type, 0,
682 sal_info, 0, 0, 0, 0);
688 /* Get the maximum size of the information logged by SAL with respect to the machine
689 * state at the time of MCAs, INITs, CMCs, or CPEs.
692 ia64_sal_get_state_info_size (u64 sal_info_type)
694 struct ia64_sal_retval isrv;
695 SAL_CALL(isrv, SAL_GET_STATE_INFO_SIZE, sal_info_type, 0,
702 /* Causes the processor to go into a spin loop within SAL where SAL awaits a wakeup
703 * from the monarch processor.
706 ia64_sal_mc_rendez (void)
708 struct ia64_sal_retval isrv;
709 SAL_CALL(isrv, SAL_MC_RENDEZ, 0, 0, 0, 0, 0, 0, 0);
713 /* Allow the OS to specify the interrupt number to be used by SAL to interrupt OS during
714 * the machine check rendezvous sequence as well as the mechanism to wake up the
715 * non-monarch processor at the end of machine check processing.
718 ia64_sal_mc_set_params (u64 param_type, u64 i_or_m, u64 i_or_m_val, u64 timeout, u64 rz_always)
720 struct ia64_sal_retval isrv;
721 SAL_CALL(isrv, SAL_MC_SET_PARAMS, param_type, i_or_m, i_or_m_val, timeout, rz_always, 0, 0);
725 /* Read from PCI configuration space */
727 ia64_sal_pci_config_read (u64 pci_config_addr, u64 size, u64 *value)
729 struct ia64_sal_retval isrv;
730 SAL_CALL(isrv, SAL_PCI_CONFIG_READ, pci_config_addr, size, 0, 0, 0, 0, 0);
736 /* Write to PCI configuration space */
738 ia64_sal_pci_config_write (u64 pci_config_addr, u64 size, u64 value)
740 struct ia64_sal_retval isrv;
741 SAL_CALL(isrv, SAL_PCI_CONFIG_WRITE, pci_config_addr, size, value,
747 * Register physical addresses of locations needed by SAL when SAL
748 * procedures are invoked in virtual mode.
751 ia64_sal_register_physical_addr (u64 phys_entry, u64 phys_addr)
753 struct ia64_sal_retval isrv;
754 SAL_CALL(isrv, SAL_REGISTER_PHYSICAL_ADDR, phys_entry, phys_addr,
759 /* Register software dependent code locations within SAL. These locations are handlers
760 * or entry points where SAL will pass control for the specified event. These event
761 * handlers are for the bott rendezvous, MCAs and INIT scenarios.
764 ia64_sal_set_vectors (u64 vector_type,
765 u64 handler_addr1, u64 gp1, u64 handler_len1,
766 u64 handler_addr2, u64 gp2, u64 handler_len2)
768 struct ia64_sal_retval isrv;
769 SAL_CALL(isrv, SAL_SET_VECTORS, vector_type,
770 handler_addr1, gp1, handler_len1,
771 handler_addr2, gp2, handler_len2);
775 /* Update the contents of PAL block in the non-volatile storage device */
777 ia64_sal_update_pal (u64 param_buf, u64 scratch_buf, u64 scratch_buf_size,
778 u64 *error_code, u64 *scratch_buf_size_needed)
780 struct ia64_sal_retval isrv;
781 SAL_CALL(isrv, SAL_UPDATE_PAL, param_buf, scratch_buf, scratch_buf_size,
784 *error_code = isrv.v0;
785 if (scratch_buf_size_needed)
786 *scratch_buf_size_needed = isrv.v1;
790 extern unsigned long sal_platform_features;
792 #endif /* _ASM_IA64_PAL_H */