1#ifndef _ASM_IA64_PAL_H
2#define _ASM_IA64_PAL_H
3
4#ifdef __KERNEL__
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32#define PAL_CACHE_FLUSH 1
33#define PAL_CACHE_INFO 2
34#define PAL_CACHE_INIT 3
35#define PAL_CACHE_SUMMARY 4
36#define PAL_MEM_ATTRIB 5
37#define PAL_PTCE_INFO 6
38#define PAL_VM_INFO 7
39#define PAL_VM_SUMMARY 8
40#define PAL_BUS_GET_FEATURES 9
41#define PAL_BUS_SET_FEATURES 10
42#define PAL_DEBUG_INFO 11
43#define PAL_FIXED_ADDR 12
44#define PAL_FREQ_BASE 13
45#define PAL_FREQ_RATIOS 14
46#define PAL_PERF_MON_INFO 15
47#define PAL_PLATFORM_ADDR 16
48#define PAL_PROC_GET_FEATURES 17
49#define PAL_PROC_SET_FEATURES 18
50#define PAL_RSE_INFO 19
51#define PAL_VERSION 20
52#define PAL_MC_CLEAR_LOG 21
53#define PAL_MC_DRAIN 22
54#define PAL_MC_EXPECTED 23
55#define PAL_MC_DYNAMIC_STATE 24
56#define PAL_MC_ERROR_INFO 25
57#define PAL_MC_RESUME 26
58#define PAL_MC_REGISTER_MEM 27
59#define PAL_HALT 28
60#define PAL_HALT_LIGHT 29
61#define PAL_COPY_INFO 30
62#define PAL_CACHE_LINE_INIT 31
63#define PAL_PMI_ENTRYPOINT 32
64#define PAL_ENTER_IA_32_ENV 33
65#define PAL_VM_PAGE_SIZE 34
66
67#define PAL_MEM_FOR_TEST 37
68#define PAL_CACHE_PROT_INFO 38
69#define PAL_REGISTER_INFO 39
70#define PAL_SHUTDOWN 40
71#define PAL_PREFETCH_VISIBILITY 41
72
73#define PAL_COPY_PAL 256
74#define PAL_HALT_INFO 257
75#define PAL_TEST_PROC 258
76#define PAL_CACHE_READ 259
77#define PAL_CACHE_WRITE 260
78#define PAL_VM_TR_READ 261
79
80#ifndef __ASSEMBLY__
81
82#include <linux/types.h>
83#include <asm/fpu.h>
84
85
86
87
88
89
90
91typedef s64 pal_status_t;
92
93#define PAL_STATUS_SUCCESS 0
94#define PAL_STATUS_UNIMPLEMENTED (-1)
95#define PAL_STATUS_EINVAL (-2)
96#define PAL_STATUS_ERROR (-3)
97#define PAL_STATUS_CACHE_INIT_FAIL (-4)
98
99
100
101
102
103
104typedef u64 pal_cache_level_t;
105#define PAL_CACHE_LEVEL_L0 0
106#define PAL_CACHE_LEVEL_L1 1
107#define PAL_CACHE_LEVEL_L2 2
108
109
110
111
112typedef u64 pal_cache_type_t;
113#define PAL_CACHE_TYPE_INSTRUCTION 1
114#define PAL_CACHE_TYPE_DATA 2
115#define PAL_CACHE_TYPE_INSTRUCTION_DATA 3
116
117
118#define PAL_CACHE_FLUSH_INVALIDATE 1
119#define PAL_CACHE_FLUSH_CHK_INTRS 2
120
121
122typedef int pal_cache_line_size_t;
123
124
125typedef u64 pal_cache_line_state_t;
126#define PAL_CACHE_LINE_STATE_INVALID 0
127#define PAL_CACHE_LINE_STATE_SHARED 1
128#define PAL_CACHE_LINE_STATE_EXCLUSIVE 2
129#define PAL_CACHE_LINE_STATE_MODIFIED 3
130
131typedef struct pal_freq_ratio {
132 u64 den : 32, num : 32;
133} itc_ratio, proc_ratio;
134
135typedef union pal_cache_config_info_1_s {
136 struct {
137 u64 u : 1,
138 at : 2,
139 reserved : 5,
140 associativity : 8,
141 line_size : 8,
142 stride : 8,
143 store_latency : 8,
144 load_latency : 8,
145 store_hints : 8,
146 load_hints : 8;
147 } pcci1_bits;
148 u64 pcci1_data;
149} pal_cache_config_info_1_t;
150
151typedef union pal_cache_config_info_2_s {
152 struct {
153 u64 cache_size : 32,
154
155
156 alias_boundary : 8,
157
158
159
160 tag_ls_bit : 8,
161 tag_ms_bit : 8,
162 reserved : 8;
163 } pcci2_bits;
164 u64 pcci2_data;
165} pal_cache_config_info_2_t;
166
167
168typedef struct pal_cache_config_info_s {
169 pal_status_t pcci_status;
170 pal_cache_config_info_1_t pcci_info_1;
171 pal_cache_config_info_2_t pcci_info_2;
172 u64 pcci_reserved;
173} pal_cache_config_info_t;
174
175#define pcci_ld_hints pcci_info_1.pcci1_bits.load_hints
176#define pcci_st_hints pcci_info_1.pcci1_bits.store_hints
177#define pcci_ld_latency pcci_info_1.pcci1_bits.load_latency
178#define pcci_st_latency pcci_info_1.pcci1_bits.store_latency
179#define pcci_stride pcci_info_1.pcci1_bits.stride
180#define pcci_line_size pcci_info_1.pcci1_bits.line_size
181#define pcci_assoc pcci_info_1.pcci1_bits.associativity
182#define pcci_cache_attr pcci_info_1.pcci1_bits.at
183#define pcci_unified pcci_info_1.pcci1_bits.u
184#define pcci_tag_msb pcci_info_2.pcci2_bits.tag_ms_bit
185#define pcci_tag_lsb pcci_info_2.pcci2_bits.tag_ls_bit
186#define pcci_alias_boundary pcci_info_2.pcci2_bits.alias_boundary
187#define pcci_cache_size pcci_info_2.pcci2_bits.cache_size
188
189
190
191
192
193#define PAL_CACHE_ATTR_WT 0
194#define PAL_CACHE_ATTR_WB 1
195#define PAL_CACHE_ATTR_WT_OR_WB 2
196
197
198
199
200
201
202
203#define PAL_CACHE_HINT_TEMP_1 0
204#define PAL_CACHE_HINT_NTEMP_1 1
205#define PAL_CACHE_HINT_NTEMP_ALL 3
206
207
208typedef union pal_cache_protection_element_u {
209 u32 pcpi_data;
210 struct {
211 u32 data_bits : 8,
212
213
214
215 tagprot_lsb : 6,
216 tagprot_msb : 6,
217
218
219
220 prot_bits : 6,
221 method : 4,
222 t_d : 2;
223
224
225
226
227 } pcp_info;
228} pal_cache_protection_element_t;
229
230#define pcpi_cache_prot_part pcp_info.t_d
231#define pcpi_prot_method pcp_info.method
232#define pcpi_prot_bits pcp_info.prot_bits
233#define pcpi_tagprot_msb pcp_info.tagprot_msb
234#define pcpi_tagprot_lsb pcp_info.tagprot_lsb
235#define pcpi_data_bits pcp_info.data_bits
236
237
238#define PAL_CACHE_PROT_PART_DATA 0
239#define PAL_CACHE_PROT_PART_TAG 1
240#define PAL_CACHE_PROT_PART_TAG_DATA 2
241
242
243#define PAL_CACHE_PROT_PART_DATA_TAG 3
244
245
246#define PAL_CACHE_PROT_PART_MAX 6
247
248
249typedef struct pal_cache_protection_info_s {
250 pal_status_t pcpi_status;
251 pal_cache_protection_element_t pcp_info[PAL_CACHE_PROT_PART_MAX];
252} pal_cache_protection_info_t;
253
254
255
256#define PAL_CACHE_PROT_METHOD_NONE 0
257#define PAL_CACHE_PROT_METHOD_ODD_PARITY 1
258#define PAL_CACHE_PROT_METHOD_EVEN_PARITY 2
259#define PAL_CACHE_PROT_METHOD_ECC 3
260
261
262
263typedef union pal_cache_line_id_u {
264 u64 pclid_data;
265 struct {
266 u64 cache_type : 8,
267 level : 8,
268
269
270
271 way : 8,
272
273 part : 8,
274
275
276 reserved : 32;
277 } pclid_info_read;
278 struct {
279 u64 cache_type : 8,
280 level : 8,
281
282
283
284 way : 8,
285
286 part : 8,
287
288
289 mesi : 8,
290
291
292 start : 8,
293
294
295 length : 8,
296
297
298 trigger : 8;
299
300
301
302
303 } pclid_info_write;
304} pal_cache_line_id_u_t;
305
306#define pclid_read_part pclid_info_read.part
307#define pclid_read_way pclid_info_read.way
308#define pclid_read_level pclid_info_read.level
309#define pclid_read_cache_type pclid_info_read.cache_type
310
311#define pclid_write_trigger pclid_info_write.trigger
312#define pclid_write_length pclid_info_write.length
313#define pclid_write_start pclid_info_write.start
314#define pclid_write_mesi pclid_info_write.mesi
315#define pclid_write_part pclid_info_write.part
316#define pclid_write_way pclid_info_write.way
317#define pclid_write_level pclid_info_write.level
318#define pclid_write_cache_type pclid_info_write.cache_type
319
320
321#define PAL_CACHE_LINE_ID_PART_DATA 0
322#define PAL_CACHE_LINE_ID_PART_TAG 1
323#define PAL_CACHE_LINE_ID_PART_DATA_PROT 2
324#define PAL_CACHE_LINE_ID_PART_TAG_PROT 3
325#define PAL_CACHE_LINE_ID_PART_DATA_TAG_PROT 4
326
327
328typedef struct pal_cache_line_info_s {
329 pal_status_t pcli_status;
330
331
332 u64 pcli_data;
333 u64 pcli_data_len;
334 pal_cache_line_state_t pcli_cache_line_state;
335
336} pal_cache_line_info_t;
337
338
339
340
341
342typedef u64 pal_mc_pending_events_t;
343
344#define PAL_MC_PENDING_MCA (1 << 0)
345#define PAL_MC_PENDING_INIT (1 << 1)
346
347
348typedef u64 pal_mc_info_index_t;
349
350#define PAL_MC_INFO_PROCESSOR 0
351#define PAL_MC_INFO_CACHE_CHECK 1
352#define PAL_MC_INFO_TLB_CHECK 2
353#define PAL_MC_INFO_BUS_CHECK 3
354#define PAL_MC_INFO_REQ_ADDR 4
355#define PAL_MC_INFO_RESP_ADDR 5
356#define PAL_MC_INFO_TARGET_ADDR 6
357#define PAL_MC_INFO_IMPL_DEP 7
358
359
360
361
362typedef struct pal_process_state_info_s {
363 u64 reserved1 : 2,
364 rz : 1,
365
366
367
368
369 ra : 1,
370
371
372 me : 1,
373
374
375
376 mn : 1,
377
378
379
380
381 sy : 1,
382
383
384
385
386 co : 1,
387 ci : 1,
388 us : 1,
389
390
391
392
393 hd : 1,
394
395
396
397
398
399
400
401 tl : 1,
402
403
404
405
406
407
408
409
410 mi : 1,
411
412
413 pi : 1,
414 pm : 1,
415
416 dy : 1,
417
418
419
420
421 in : 1,
422 rs : 1,
423 cm : 1,
424 ex : 1,
425 cr : 1,
426 pc : 1,
427 dr : 1,
428 tr : 1,
429
430
431 rr : 1,
432 ar : 1,
433 br : 1,
434 pr : 1,
435
436
437
438 fp : 1,
439 b1 : 1,
440
441
442
443 b0 : 1,
444
445
446
447 gr : 1,
448
449
450
451 dsize : 16,
452
453
454
455
456 reserved2 : 11,
457 cc : 1,
458 tc : 1,
459 bc : 1,
460 rc : 1,
461 uc : 1;
462
463} pal_processor_state_info_t;
464
465typedef struct pal_cache_check_info_s {
466 u64 op : 4,
467
468
469
470
471 level : 2,
472 reserved1 : 2,
473 dl : 1,
474
475
476 tl : 1,
477
478
479 dc : 1,
480 ic : 1,
481 mesi : 3,
482 mv : 1,
483 way : 5,
484
485
486 wiv : 1,
487 reserved2 : 10,
488
489 index : 20,
490 reserved3 : 2,
491
492 is : 1,
493 iv : 1,
494 pl : 2,
495 pv : 1,
496 mcc : 1,
497 tv : 1,
498
499
500 rq : 1,
501
502
503 rp : 1,
504
505
506 pi : 1;
507
508
509} pal_cache_check_info_t;
510
511typedef struct pal_tlb_check_info_s {
512
513 u64 tr_slot : 8,
514
515
516 trv : 1,
517 reserved1 : 1,
518 level : 2,
519 reserved2 : 4,
520 dtr : 1,
521 itr : 1,
522 dtc : 1,
523 itc : 1,
524 op : 4,
525 reserved3 : 30,
526
527 is : 1,
528 iv : 1,
529 pl : 2,
530 pv : 1,
531 mcc : 1,
532 tv : 1,
533
534
535 rq : 1,
536
537
538 rp : 1,
539
540
541 pi : 1;
542
543
544} pal_tlb_check_info_t;
545
546typedef struct pal_bus_check_info_s {
547 u64 size : 5,
548 ib : 1,
549 eb : 1,
550 cc : 1,
551
552
553
554 type : 8,
555 sev : 5,
556 hier : 2,
557 reserved1 : 1,
558 bsi : 8,
559
560
561 reserved2 : 22,
562
563 is : 1,
564 iv : 1,
565 pl : 2,
566 pv : 1,
567 mcc : 1,
568 tv : 1,
569
570
571 rq : 1,
572
573
574 rp : 1,
575
576
577 pi : 1;
578
579
580} pal_bus_check_info_t;
581
582typedef struct pal_reg_file_check_info_s {
583 u64 id : 4,
584 op : 4,
585
586
587
588
589 reg_num : 7,
590 rnv : 1,
591 reserved2 : 38,
592
593 is : 1,
594 iv : 1,
595 pl : 2,
596 pv : 1,
597 mcc : 1,
598 reserved3 : 3,
599 pi : 1;
600
601
602} pal_reg_file_check_info_t;
603
604typedef struct pal_uarch_check_info_s {
605 u64 sid : 5,
606 level : 3,
607 array_id : 4,
608 op : 4,
609
610
611
612
613 way : 6,
614 wv : 1,
615 xv : 1,
616 reserved1 : 8,
617 index : 8,
618
619
620 reserved2 : 24,
621
622 is : 1,
623 iv : 1,
624 pl : 2,
625 pv : 1,
626 mcc : 1,
627 tv : 1,
628
629
630 rq : 1,
631
632
633 rp : 1,
634
635
636 pi : 1;
637
638
639} pal_uarch_check_info_t;
640
641typedef union pal_mc_error_info_u {
642 u64 pmei_data;
643 pal_processor_state_info_t pme_processor;
644 pal_cache_check_info_t pme_cache;
645 pal_tlb_check_info_t pme_tlb;
646 pal_bus_check_info_t pme_bus;
647 pal_reg_file_check_info_t pme_reg_file;
648 pal_uarch_check_info_t pme_uarch;
649} pal_mc_error_info_t;
650
651#define pmci_proc_unknown_check pme_processor.uc
652#define pmci_proc_bus_check pme_processor.bc
653#define pmci_proc_tlb_check pme_processor.tc
654#define pmci_proc_cache_check pme_processor.cc
655#define pmci_proc_dynamic_state_size pme_processor.dsize
656#define pmci_proc_gpr_valid pme_processor.gr
657#define pmci_proc_preserved_bank0_gpr_valid pme_processor.b0
658#define pmci_proc_preserved_bank1_gpr_valid pme_processor.b1
659#define pmci_proc_fp_valid pme_processor.fp
660#define pmci_proc_predicate_regs_valid pme_processor.pr
661#define pmci_proc_branch_regs_valid pme_processor.br
662#define pmci_proc_app_regs_valid pme_processor.ar
663#define pmci_proc_region_regs_valid pme_processor.rr
664#define pmci_proc_translation_regs_valid pme_processor.tr
665#define pmci_proc_debug_regs_valid pme_processor.dr
666#define pmci_proc_perf_counters_valid pme_processor.pc
667#define pmci_proc_control_regs_valid pme_processor.cr
668#define pmci_proc_machine_check_expected pme_processor.ex
669#define pmci_proc_machine_check_corrected pme_processor.cm
670#define pmci_proc_rse_valid pme_processor.rs
671#define pmci_proc_machine_check_or_init pme_processor.in
672#define pmci_proc_dynamic_state_valid pme_processor.dy
673#define pmci_proc_operation pme_processor.op
674#define pmci_proc_trap_lost pme_processor.tl
675#define pmci_proc_hardware_damage pme_processor.hd
676#define pmci_proc_uncontained_storage_damage pme_processor.us
677#define pmci_proc_machine_check_isolated pme_processor.ci
678#define pmci_proc_continuable pme_processor.co
679#define pmci_proc_storage_intergrity_synced pme_processor.sy
680#define pmci_proc_min_state_save_area_regd pme_processor.mn
681#define pmci_proc_distinct_multiple_errors pme_processor.me
682#define pmci_proc_pal_attempted_rendezvous pme_processor.ra
683#define pmci_proc_pal_rendezvous_complete pme_processor.rz
684
685
686#define pmci_cache_level pme_cache.level
687#define pmci_cache_line_state pme_cache.mesi
688#define pmci_cache_line_state_valid pme_cache.mv
689#define pmci_cache_line_index pme_cache.index
690#define pmci_cache_instr_cache_fail pme_cache.ic
691#define pmci_cache_data_cache_fail pme_cache.dc
692#define pmci_cache_line_tag_fail pme_cache.tl
693#define pmci_cache_line_data_fail pme_cache.dl
694#define pmci_cache_operation pme_cache.op
695#define pmci_cache_way_valid pme_cache.wv
696#define pmci_cache_target_address_valid pme_cache.tv
697#define pmci_cache_way pme_cache.way
698#define pmci_cache_mc pme_cache.mc
699
700#define pmci_tlb_instr_translation_cache_fail pme_tlb.itc
701#define pmci_tlb_data_translation_cache_fail pme_tlb.dtc
702#define pmci_tlb_instr_translation_reg_fail pme_tlb.itr
703#define pmci_tlb_data_translation_reg_fail pme_tlb.dtr
704#define pmci_tlb_translation_reg_slot pme_tlb.tr_slot
705#define pmci_tlb_mc pme_tlb.mc
706
707#define pmci_bus_status_info pme_bus.bsi
708#define pmci_bus_req_address_valid pme_bus.rq
709#define pmci_bus_resp_address_valid pme_bus.rp
710#define pmci_bus_target_address_valid pme_bus.tv
711#define pmci_bus_error_severity pme_bus.sev
712#define pmci_bus_transaction_type pme_bus.type
713#define pmci_bus_cache_cache_transfer pme_bus.cc
714#define pmci_bus_transaction_size pme_bus.size
715#define pmci_bus_internal_error pme_bus.ib
716#define pmci_bus_external_error pme_bus.eb
717#define pmci_bus_mc pme_bus.mc
718
719
720
721
722
723
724
725typedef struct pal_min_state_area_s {
726 u64 pmsa_nat_bits;
727 u64 pmsa_gr[15];
728 u64 pmsa_bank0_gr[16];
729 u64 pmsa_bank1_gr[16];
730 u64 pmsa_pr;
731 u64 pmsa_br0;
732 u64 pmsa_rsc;
733 u64 pmsa_iip;
734 u64 pmsa_ipsr;
735 u64 pmsa_ifs;
736 u64 pmsa_xip;
737 u64 pmsa_xpsr;
738 u64 pmsa_xfs;
739 u64 pmsa_br1;
740 u64 pmsa_reserved[70];
741} pal_min_state_area_t;
742
743
744struct ia64_pal_retval {
745
746
747
748
749
750
751
752 s64 status;
753 u64 v0;
754 u64 v1;
755 u64 v2;
756};
757
758
759
760
761
762
763
764extern struct ia64_pal_retval ia64_pal_call_static (u64, u64, u64, u64, u64);
765extern struct ia64_pal_retval ia64_pal_call_stacked (u64, u64, u64, u64);
766extern struct ia64_pal_retval ia64_pal_call_phys_static (u64, u64, u64, u64);
767extern struct ia64_pal_retval ia64_pal_call_phys_stacked (u64, u64, u64, u64);
768
769extern void ia64_save_scratch_fpregs(struct ia64_fpreg *);
770extern void ia64_load_scratch_fpregs(struct ia64_fpreg *);
771
772#define PAL_CALL(iprv,a0,a1,a2,a3) do { \
773 struct ia64_fpreg fr[6]; \
774 ia64_save_scratch_fpregs(fr); \
775 iprv = ia64_pal_call_static(a0, a1, a2, a3, 0); \
776 ia64_load_scratch_fpregs(fr); \
777} while (0)
778
779#define PAL_CALL_IC_OFF(iprv,a0,a1,a2,a3) do { \
780 struct ia64_fpreg fr[6]; \
781 ia64_save_scratch_fpregs(fr); \
782 iprv = ia64_pal_call_static(a0, a1, a2, a3, 1); \
783 ia64_load_scratch_fpregs(fr); \
784} while (0)
785
786#define PAL_CALL_STK(iprv,a0,a1,a2,a3) do { \
787 struct ia64_fpreg fr[6]; \
788 ia64_save_scratch_fpregs(fr); \
789 iprv = ia64_pal_call_stacked(a0, a1, a2, a3); \
790 ia64_load_scratch_fpregs(fr); \
791} while (0)
792
793#define PAL_CALL_PHYS(iprv,a0,a1,a2,a3) do { \
794 struct ia64_fpreg fr[6]; \
795 ia64_save_scratch_fpregs(fr); \
796 iprv = ia64_pal_call_phys_static(a0, a1, a2, a3);\
797 ia64_load_scratch_fpregs(fr); \
798} while (0)
799
800#define PAL_CALL_PHYS_STK(iprv,a0,a1,a2,a3) do { \
801 struct ia64_fpreg fr[6]; \
802 ia64_save_scratch_fpregs(fr); \
803 iprv = ia64_pal_call_phys_stacked(a0, a1, a2, a3); \
804 ia64_load_scratch_fpregs(fr); \
805} while (0)
806
807typedef int (*ia64_pal_handler) (u64, ...);
808extern ia64_pal_handler ia64_pal;
809extern void ia64_pal_handler_init (void *);
810
811extern ia64_pal_handler ia64_pal;
812
813extern pal_cache_config_info_t l0d_cache_config_info;
814extern pal_cache_config_info_t l0i_cache_config_info;
815extern pal_cache_config_info_t l1_cache_config_info;
816extern pal_cache_config_info_t l2_cache_config_info;
817
818extern pal_cache_protection_info_t l0d_cache_protection_info;
819extern pal_cache_protection_info_t l0i_cache_protection_info;
820extern pal_cache_protection_info_t l1_cache_protection_info;
821extern pal_cache_protection_info_t l2_cache_protection_info;
822
823extern pal_cache_config_info_t pal_cache_config_info_get(pal_cache_level_t,
824 pal_cache_type_t);
825
826extern pal_cache_protection_info_t pal_cache_protection_info_get(pal_cache_level_t,
827 pal_cache_type_t);
828
829
830extern void pal_error(int);
831
832
833
834
835typedef union pal_bus_features_u {
836 u64 pal_bus_features_val;
837 struct {
838 u64 pbf_reserved1 : 29;
839 u64 pbf_req_bus_parking : 1;
840 u64 pbf_bus_lock_mask : 1;
841 u64 pbf_enable_half_xfer_rate : 1;
842 u64 pbf_reserved2 : 22;
843 u64 pbf_disable_xaction_queueing : 1;
844 u64 pbf_disable_resp_err_check : 1;
845 u64 pbf_disable_berr_check : 1;
846 u64 pbf_disable_bus_req_internal_err_signal : 1;
847 u64 pbf_disable_bus_req_berr_signal : 1;
848 u64 pbf_disable_bus_init_event_check : 1;
849 u64 pbf_disable_bus_init_event_signal : 1;
850 u64 pbf_disable_bus_addr_err_check : 1;
851 u64 pbf_disable_bus_addr_err_signal : 1;
852 u64 pbf_disable_bus_data_err_check : 1;
853 } pal_bus_features_s;
854} pal_bus_features_u_t;
855
856extern void pal_bus_features_print (u64);
857
858
859static inline s64
860ia64_pal_bus_get_features (pal_bus_features_u_t *features_avail,
861 pal_bus_features_u_t *features_status,
862 pal_bus_features_u_t *features_control)
863{
864 struct ia64_pal_retval iprv;
865 PAL_CALL_PHYS(iprv, PAL_BUS_GET_FEATURES, 0, 0, 0);
866 if (features_avail)
867 features_avail->pal_bus_features_val = iprv.v0;
868 if (features_status)
869 features_status->pal_bus_features_val = iprv.v1;
870 if (features_control)
871 features_control->pal_bus_features_val = iprv.v2;
872 return iprv.status;
873}
874
875
876static inline s64
877ia64_pal_bus_set_features (pal_bus_features_u_t feature_select)
878{
879 struct ia64_pal_retval iprv;
880 PAL_CALL_PHYS(iprv, PAL_BUS_SET_FEATURES, feature_select.pal_bus_features_val, 0, 0);
881 return iprv.status;
882}
883
884
885static inline s64
886ia64_pal_cache_config_info (u64 cache_level, u64 cache_type, pal_cache_config_info_t *conf)
887{
888 struct ia64_pal_retval iprv;
889
890 PAL_CALL(iprv, PAL_CACHE_INFO, cache_level, cache_type, 0);
891
892 if (iprv.status == 0) {
893 conf->pcci_status = iprv.status;
894 conf->pcci_info_1.pcci1_data = iprv.v0;
895 conf->pcci_info_2.pcci2_data = iprv.v1;
896 conf->pcci_reserved = iprv.v2;
897 }
898 return iprv.status;
899
900}
901
902
903static inline s64
904ia64_pal_cache_prot_info (u64 cache_level, u64 cache_type, pal_cache_protection_info_t *prot)
905{
906 struct ia64_pal_retval iprv;
907
908 PAL_CALL(iprv, PAL_CACHE_PROT_INFO, cache_level, cache_type, 0);
909
910 if (iprv.status == 0) {
911 prot->pcpi_status = iprv.status;
912 prot->pcp_info[0].pcpi_data = iprv.v0 & 0xffffffff;
913 prot->pcp_info[1].pcpi_data = iprv.v0 >> 32;
914 prot->pcp_info[2].pcpi_data = iprv.v1 & 0xffffffff;
915 prot->pcp_info[3].pcpi_data = iprv.v1 >> 32;
916 prot->pcp_info[4].pcpi_data = iprv.v2 & 0xffffffff;
917 prot->pcp_info[5].pcpi_data = iprv.v2 >> 32;
918 }
919 return iprv.status;
920}
921
922
923
924
925
926static inline s64
927ia64_pal_cache_flush (u64 cache_type, u64 invalidate, u64 *progress, u64 *vector)
928{
929 struct ia64_pal_retval iprv;
930 PAL_CALL_IC_OFF(iprv, PAL_CACHE_FLUSH, cache_type, invalidate, *progress);
931 if (vector)
932 *vector = iprv.v0;
933 *progress = iprv.v1;
934 return iprv.status;
935}
936
937
938
939static inline s64
940ia64_pal_cache_init (u64 level, u64 cache_type, u64 restrict)
941{
942 struct ia64_pal_retval iprv;
943 PAL_CALL(iprv, PAL_CACHE_INIT, level, cache_type, restrict);
944 return iprv.status;
945}
946
947
948
949
950
951static inline s64
952ia64_pal_cache_line_init (u64 physical_addr, u64 data_value)
953{
954 struct ia64_pal_retval iprv;
955 PAL_CALL(iprv, PAL_CACHE_LINE_INIT, physical_addr, data_value, 0);
956 return iprv.status;
957}
958
959
960
961static inline s64
962ia64_pal_cache_read (pal_cache_line_id_u_t line_id, u64 physical_addr)
963{
964 struct ia64_pal_retval iprv;
965 PAL_CALL(iprv, PAL_CACHE_READ, line_id.pclid_data, physical_addr, 0);
966 return iprv.status;
967}
968
969
970static inline s64
971ia64_pal_cache_summary (u64 *cache_levels, u64 *unique_caches)
972{
973 struct ia64_pal_retval iprv;
974 PAL_CALL(iprv, PAL_CACHE_SUMMARY, 0, 0, 0);
975 if (cache_levels)
976 *cache_levels = iprv.v0;
977 if (unique_caches)
978 *unique_caches = iprv.v1;
979 return iprv.status;
980}
981
982
983static inline s64
984ia64_pal_cache_write (pal_cache_line_id_u_t line_id, u64 physical_addr, u64 data)
985{
986 struct ia64_pal_retval iprv;
987 PAL_CALL(iprv, PAL_CACHE_WRITE, line_id.pclid_data, physical_addr, data);
988 return iprv.status;
989}
990
991
992
993static inline s64
994ia64_pal_copy_info (u64 copy_type, u64 num_procs, u64 num_iopics,
995 u64 *buffer_size, u64 *buffer_align)
996{
997 struct ia64_pal_retval iprv;
998 PAL_CALL(iprv, PAL_COPY_INFO, copy_type, num_procs, num_iopics);
999 if (buffer_size)
1000 *buffer_size = iprv.v0;
1001 if (buffer_align)
1002 *buffer_align = iprv.v1;
1003 return iprv.status;
1004}
1005
1006
1007static inline s64
1008ia64_pal_copy_pal (u64 target_addr, u64 alloc_size, u64 processor, u64 *pal_proc_offset)
1009{
1010 struct ia64_pal_retval iprv;
1011 PAL_CALL(iprv, PAL_COPY_PAL, target_addr, alloc_size, processor);
1012 if (pal_proc_offset)
1013 *pal_proc_offset = iprv.v0;
1014 return iprv.status;
1015}
1016
1017
1018static inline s64
1019ia64_pal_debug_info (u64 *inst_regs, u64 *data_regs)
1020{
1021 struct ia64_pal_retval iprv;
1022 PAL_CALL(iprv, PAL_DEBUG_INFO, 0, 0, 0);
1023 if (inst_regs)
1024 *inst_regs = iprv.v0;
1025 if (data_regs)
1026 *data_regs = iprv.v1;
1027
1028 return iprv.status;
1029}
1030
1031#ifdef TBD
1032
1033static inline s64
1034ia64_pal_enter_ia32_env (ia32_env1, ia32_env2, ia32_env3)
1035{
1036 struct ia64_pal_retval iprv;
1037 PAL_CALL(iprv, PAL_ENTER_IA_32_ENV, ia32_env1, ia32_env2, ia32_env3);
1038 return iprv.status;
1039}
1040#endif
1041
1042
1043static inline s64
1044ia64_pal_fixed_addr (u64 *global_unique_addr)
1045{
1046 struct ia64_pal_retval iprv;
1047 PAL_CALL(iprv, PAL_FIXED_ADDR, 0, 0, 0);
1048 if (global_unique_addr)
1049 *global_unique_addr = iprv.v0;
1050 return iprv.status;
1051}
1052
1053
1054static inline s64
1055ia64_pal_freq_base (u64 *platform_base_freq)
1056{
1057 struct ia64_pal_retval iprv;
1058 PAL_CALL(iprv, PAL_FREQ_BASE, 0, 0, 0);
1059 if (platform_base_freq)
1060 *platform_base_freq = iprv.v0;
1061 return iprv.status;
1062}
1063
1064
1065
1066
1067
1068static inline s64
1069ia64_pal_freq_ratios (struct pal_freq_ratio *proc_ratio, struct pal_freq_ratio *bus_ratio,
1070 struct pal_freq_ratio *itc_ratio)
1071{
1072 struct ia64_pal_retval iprv;
1073 PAL_CALL(iprv, PAL_FREQ_RATIOS, 0, 0, 0);
1074 if (proc_ratio)
1075 *(u64 *)proc_ratio = iprv.v0;
1076 if (bus_ratio)
1077 *(u64 *)bus_ratio = iprv.v1;
1078 if (itc_ratio)
1079 *(u64 *)itc_ratio = iprv.v2;
1080 return iprv.status;
1081}
1082
1083
1084
1085
1086
1087static inline s64
1088ia64_pal_halt (u64 halt_state)
1089{
1090 struct ia64_pal_retval iprv;
1091 PAL_CALL(iprv, PAL_HALT, halt_state, 0, 0);
1092 return iprv.status;
1093}
1094
1095typedef union pal_power_mgmt_info_u {
1096 u64 ppmi_data;
1097 struct {
1098 u64 exit_latency : 16,
1099 entry_latency : 16,
1100 power_consumption : 28,
1101 im : 1,
1102 co : 1,
1103 reserved : 2;
1104 } pal_power_mgmt_info_s;
1105} pal_power_mgmt_info_u_t;
1106
1107
1108static inline s64
1109ia64_pal_halt_info (pal_power_mgmt_info_u_t *power_buf)
1110{
1111 struct ia64_pal_retval iprv;
1112 PAL_CALL_STK(iprv, PAL_HALT_INFO, (unsigned long) power_buf, 0, 0);
1113 return iprv.status;
1114}
1115
1116
1117
1118
1119static inline s64
1120ia64_pal_halt_light (void)
1121{
1122 struct ia64_pal_retval iprv;
1123 PAL_CALL(iprv, PAL_HALT_LIGHT, 0, 0, 0);
1124 return iprv.status;
1125}
1126
1127
1128
1129
1130
1131static inline s64
1132ia64_pal_mc_clear_log (u64 *pending_vector)
1133{
1134 struct ia64_pal_retval iprv;
1135 PAL_CALL(iprv, PAL_MC_CLEAR_LOG, 0, 0, 0);
1136 if (pending_vector)
1137 *pending_vector = iprv.v0;
1138 return iprv.status;
1139}
1140
1141
1142
1143
1144static inline s64
1145ia64_pal_mc_drain (void)
1146{
1147 struct ia64_pal_retval iprv;
1148 PAL_CALL(iprv, PAL_MC_DRAIN, 0, 0, 0);
1149 return iprv.status;
1150}
1151
1152
1153static inline s64
1154ia64_pal_mc_dynamic_state (u64 offset, u64 *size, u64 *pds)
1155{
1156 struct ia64_pal_retval iprv;
1157 PAL_CALL(iprv, PAL_MC_DYNAMIC_STATE, offset, 0, 0);
1158 if (size)
1159 *size = iprv.v0;
1160 if (pds)
1161 *pds = iprv.v1;
1162 return iprv.status;
1163}
1164
1165
1166static inline s64
1167ia64_pal_mc_error_info (u64 info_index, u64 type_index, u64 *size, u64 *error_info)
1168{
1169 struct ia64_pal_retval iprv;
1170 PAL_CALL(iprv, PAL_MC_ERROR_INFO, info_index, type_index, 0);
1171 if (size)
1172 *size = iprv.v0;
1173 if (error_info)
1174 *error_info = iprv.v1;
1175 return iprv.status;
1176}
1177
1178
1179
1180
1181static inline s64
1182ia64_pal_mc_expected (u64 expected, u64 *previous)
1183{
1184 struct ia64_pal_retval iprv;
1185 PAL_CALL(iprv, PAL_MC_EXPECTED, expected, 0, 0);
1186 if (previous)
1187 *previous = iprv.v0;
1188 return iprv.status;
1189}
1190
1191
1192
1193
1194
1195static inline s64
1196ia64_pal_mc_register_mem (u64 physical_addr)
1197{
1198 struct ia64_pal_retval iprv;
1199 PAL_CALL(iprv, PAL_MC_REGISTER_MEM, physical_addr, 0, 0);
1200 return iprv.status;
1201}
1202
1203
1204
1205
1206static inline s64
1207ia64_pal_mc_resume (u64 set_cmci, u64 save_ptr)
1208{
1209 struct ia64_pal_retval iprv;
1210 PAL_CALL(iprv, PAL_MC_RESUME, set_cmci, save_ptr, 0);
1211 return iprv.status;
1212}
1213
1214
1215static inline s64
1216ia64_pal_mem_attrib (u64 *mem_attrib)
1217{
1218 struct ia64_pal_retval iprv;
1219 PAL_CALL(iprv, PAL_MEM_ATTRIB, 0, 0, 0);
1220 if (mem_attrib)
1221 *mem_attrib = iprv.v0 & 0xff;
1222 return iprv.status;
1223}
1224
1225
1226
1227
1228static inline s64
1229ia64_pal_mem_for_test (u64 *bytes_needed, u64 *alignment)
1230{
1231 struct ia64_pal_retval iprv;
1232 PAL_CALL(iprv, PAL_MEM_FOR_TEST, 0, 0, 0);
1233 if (bytes_needed)
1234 *bytes_needed = iprv.v0;
1235 if (alignment)
1236 *alignment = iprv.v1;
1237 return iprv.status;
1238}
1239
1240typedef union pal_perf_mon_info_u {
1241 u64 ppmi_data;
1242 struct {
1243 u64 generic : 8,
1244 width : 8,
1245 cycles : 8,
1246 retired : 8,
1247 reserved : 32;
1248 } pal_perf_mon_info_s;
1249} pal_perf_mon_info_u_t;
1250
1251
1252
1253
1254static inline s64
1255ia64_pal_perf_mon_info (u64 *pm_buffer, pal_perf_mon_info_u_t *pm_info)
1256{
1257 struct ia64_pal_retval iprv;
1258 PAL_CALL(iprv, PAL_PERF_MON_INFO, (unsigned long) pm_buffer, 0, 0);
1259 if (pm_info)
1260 pm_info->ppmi_data = iprv.v0;
1261 return iprv.status;
1262}
1263
1264
1265
1266
1267static inline s64
1268ia64_pal_platform_addr (u64 type, u64 physical_addr)
1269{
1270 struct ia64_pal_retval iprv;
1271 PAL_CALL(iprv, PAL_PLATFORM_ADDR, type, physical_addr, 0);
1272 return iprv.status;
1273}
1274
1275
1276static inline s64
1277ia64_pal_pmi_entrypoint (u64 sal_pmi_entry_addr)
1278{
1279 struct ia64_pal_retval iprv;
1280 PAL_CALL(iprv, PAL_PMI_ENTRYPOINT, sal_pmi_entry_addr, 0, 0);
1281 return iprv.status;
1282}
1283
1284struct pal_features_s;
1285
1286static inline s64
1287ia64_pal_proc_get_features (u64 *features_avail,
1288 u64 *features_status,
1289 u64 *features_control)
1290{
1291 struct ia64_pal_retval iprv;
1292 PAL_CALL_PHYS(iprv, PAL_PROC_GET_FEATURES, 0, 0, 0);
1293 if (iprv.status == 0) {
1294 *features_avail = iprv.v0;
1295 *features_status = iprv.v1;
1296 *features_control = iprv.v2;
1297 }
1298 return iprv.status;
1299}
1300
1301
1302static inline s64
1303ia64_pal_proc_set_features (u64 feature_select)
1304{
1305 struct ia64_pal_retval iprv;
1306 PAL_CALL_PHYS(iprv, PAL_PROC_SET_FEATURES, feature_select, 0, 0);
1307 return iprv.status;
1308}
1309
1310
1311
1312
1313
1314typedef struct ia64_ptce_info_s {
1315 u64 base;
1316 u32 count[2];
1317 u32 stride[2];
1318} ia64_ptce_info_t;
1319
1320
1321
1322
1323static inline s64
1324ia64_get_ptce (ia64_ptce_info_t *ptce)
1325{
1326 struct ia64_pal_retval iprv;
1327
1328 if (!ptce)
1329 return -1;
1330
1331 PAL_CALL(iprv, PAL_PTCE_INFO, 0, 0, 0);
1332 if (iprv.status == 0) {
1333 ptce->base = iprv.v0;
1334 ptce->count[0] = iprv.v1 >> 32;
1335 ptce->count[1] = iprv.v1 & 0xffffffff;
1336 ptce->stride[0] = iprv.v2 >> 32;
1337 ptce->stride[1] = iprv.v2 & 0xffffffff;
1338 }
1339 return iprv.status;
1340}
1341
1342
1343static inline s64
1344ia64_pal_register_info (u64 info_request, u64 *reg_info_1, u64 *reg_info_2)
1345{
1346 struct ia64_pal_retval iprv;
1347 PAL_CALL(iprv, PAL_REGISTER_INFO, info_request, 0, 0);
1348 if (reg_info_1)
1349 *reg_info_1 = iprv.v0;
1350 if (reg_info_2)
1351 *reg_info_2 = iprv.v1;
1352 return iprv.status;
1353}
1354
1355typedef union pal_hints_u {
1356 u64 ph_data;
1357 struct {
1358 u64 si : 1,
1359 li : 1,
1360 reserved : 62;
1361 } pal_hints_s;
1362} pal_hints_u_t;
1363
1364
1365
1366
1367static inline s64
1368ia64_pal_rse_info (u64 *num_phys_stacked, pal_hints_u_t *hints)
1369{
1370 struct ia64_pal_retval iprv;
1371 PAL_CALL(iprv, PAL_RSE_INFO, 0, 0, 0);
1372 if (num_phys_stacked)
1373 *num_phys_stacked = iprv.v0;
1374 if (hints)
1375 hints->ph_data = iprv.v1;
1376 return iprv.status;
1377}
1378
1379
1380
1381
1382
1383static inline s64
1384ia64_pal_shutdown (void)
1385{
1386 struct ia64_pal_retval iprv;
1387 PAL_CALL(iprv, PAL_SHUTDOWN, 0, 0, 0);
1388 return iprv.status;
1389}
1390
1391
1392static inline s64
1393ia64_pal_test_proc (u64 test_addr, u64 test_size, u64 attributes, u64 *self_test_state)
1394{
1395 struct ia64_pal_retval iprv;
1396 PAL_CALL(iprv, PAL_TEST_PROC, test_addr, test_size, attributes);
1397 if (self_test_state)
1398 *self_test_state = iprv.v0;
1399 return iprv.status;
1400}
1401
1402typedef union pal_version_u {
1403 u64 pal_version_val;
1404 struct {
1405 u64 pv_pal_b_rev : 8;
1406 u64 pv_pal_b_model : 8;
1407 u64 pv_reserved1 : 8;
1408 u64 pv_pal_vendor : 8;
1409 u64 pv_pal_a_rev : 8;
1410 u64 pv_pal_a_model : 8;
1411 u64 pv_reserved2 : 16;
1412 } pal_version_s;
1413} pal_version_u_t;
1414
1415
1416
1417static inline s64
1418ia64_pal_version (pal_version_u_t *pal_min_version, pal_version_u_t *pal_cur_version)
1419{
1420 struct ia64_pal_retval iprv;
1421 PAL_CALL_PHYS(iprv, PAL_VERSION, 0, 0, 0);
1422 if (pal_min_version)
1423 pal_min_version->pal_version_val = iprv.v0;
1424
1425 if (pal_cur_version)
1426 pal_cur_version->pal_version_val = iprv.v1;
1427
1428 return iprv.status;
1429}
1430
1431typedef union pal_tc_info_u {
1432 u64 pti_val;
1433 struct {
1434 u64 num_sets : 8,
1435 associativity : 8,
1436 num_entries : 16,
1437 pf : 1,
1438 unified : 1,
1439 reduce_tr : 1,
1440 reserved : 29;
1441 } pal_tc_info_s;
1442} pal_tc_info_u_t;
1443
1444#define tc_reduce_tr pal_tc_info_s.reduce_tr
1445#define tc_unified pal_tc_info_s.unified
1446#define tc_pf pal_tc_info_s.pf
1447#define tc_num_entries pal_tc_info_s.num_entries
1448#define tc_associativity pal_tc_info_s.associativity
1449#define tc_num_sets pal_tc_info_s.num_sets
1450
1451
1452
1453
1454
1455static inline s64
1456ia64_pal_vm_info (u64 tc_level, u64 tc_type, pal_tc_info_u_t *tc_info, u64 *tc_pages)
1457{
1458 struct ia64_pal_retval iprv;
1459 PAL_CALL(iprv, PAL_VM_INFO, tc_level, tc_type, 0);
1460 if (tc_info)
1461 tc_info->pti_val = iprv.v0;
1462 if (tc_pages)
1463 *tc_pages = iprv.v1;
1464 return iprv.status;
1465}
1466
1467
1468
1469
1470static inline s64
1471ia64_pal_vm_page_size (u64 *tr_pages, u64 *vw_pages)
1472{
1473 struct ia64_pal_retval iprv;
1474 PAL_CALL(iprv, PAL_VM_PAGE_SIZE, 0, 0, 0);
1475 if (tr_pages)
1476 *tr_pages = iprv.v0;
1477 if (vw_pages)
1478 *vw_pages = iprv.v1;
1479 return iprv.status;
1480}
1481
1482typedef union pal_vm_info_1_u {
1483 u64 pvi1_val;
1484 struct {
1485 u64 vw : 1,
1486 phys_add_size : 7,
1487 key_size : 8,
1488 max_pkr : 8,
1489 hash_tag_id : 8,
1490 max_dtr_entry : 8,
1491 max_itr_entry : 8,
1492 max_unique_tcs : 8,
1493 num_tc_levels : 8;
1494 } pal_vm_info_1_s;
1495} pal_vm_info_1_u_t;
1496
1497typedef union pal_vm_info_2_u {
1498 u64 pvi2_val;
1499 struct {
1500 u64 impl_va_msb : 8,
1501 rid_size : 8,
1502 reserved : 48;
1503 } pal_vm_info_2_s;
1504} pal_vm_info_2_u_t;
1505
1506
1507
1508
1509static inline s64
1510ia64_pal_vm_summary (pal_vm_info_1_u_t *vm_info_1, pal_vm_info_2_u_t *vm_info_2)
1511{
1512 struct ia64_pal_retval iprv;
1513 PAL_CALL(iprv, PAL_VM_SUMMARY, 0, 0, 0);
1514 if (vm_info_1)
1515 vm_info_1->pvi1_val = iprv.v0;
1516 if (vm_info_2)
1517 vm_info_2->pvi2_val = iprv.v1;
1518 return iprv.status;
1519}
1520
1521typedef union pal_itr_valid_u {
1522 u64 piv_val;
1523 struct {
1524 u64 access_rights_valid : 1,
1525 priv_level_valid : 1,
1526 dirty_bit_valid : 1,
1527 mem_attr_valid : 1,
1528 reserved : 60;
1529 } pal_tr_valid_s;
1530} pal_tr_valid_u_t;
1531
1532
1533static inline s64
1534ia64_pal_tr_read (u64 reg_num, u64 tr_type, u64 *tr_buffer, pal_tr_valid_u_t *tr_valid)
1535{
1536 struct ia64_pal_retval iprv;
1537 PAL_CALL_PHYS_STK(iprv, PAL_VM_TR_READ, reg_num, tr_type,(u64)__pa(tr_buffer));
1538 if (tr_valid)
1539 tr_valid->piv_val = iprv.v0;
1540 return iprv.status;
1541}
1542
1543static inline s64
1544ia64_pal_prefetch_visibility (void)
1545{
1546 struct ia64_pal_retval iprv;
1547 PAL_CALL(iprv, PAL_PREFETCH_VISIBILITY, 0, 0, 0);
1548 return iprv.status;
1549}
1550
1551#endif
1552
1553#endif
1554
1555#endif
1556