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