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