]> git.saurik.com Git - apple/xnu.git/blame - osfmk/ppc/asm.h
xnu-344.21.73.tar.gz
[apple/xnu.git] / osfmk / ppc / asm.h
CommitLineData
1c79356b
A
1/*
2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
d7e50217 6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
1c79356b 7 *
d7e50217
A
8 * This file contains Original Code and/or Modifications of Original Code
9 * as defined in and that are subject to the Apple Public Source License
10 * Version 2.0 (the 'License'). You may not use this file except in
11 * compliance with the License. Please obtain a copy of the License at
12 * http://www.opensource.apple.com/apsl/ and read it before using this
13 * file.
14 *
15 * The Original Code and all software distributed under the License are
16 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
1c79356b
A
17 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
18 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
d7e50217
A
19 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
20 * Please see the License for the specific language governing rights and
21 * limitations under the License.
1c79356b
A
22 *
23 * @APPLE_LICENSE_HEADER_END@
24 */
25/*
26 * @OSF_COPYRIGHT@
27 */
28#ifndef _PPC_ASM_H_
29#define _PPC_ASM_H_
30
31#define __ASMNL__ @
32#define STRINGD .ascii
33
34#ifdef ASSEMBLER
35
36
37#define br0 0
38
39#define ARG0 r3
40#define ARG1 r4
41#define ARG2 r5
42#define ARG3 r6
43#define ARG4 r7
44#define ARG5 r8
45#define ARG6 r9
46#define ARG7 r10
47
48#define tmp0 r0 /* Temporary GPR remapping (603e specific) */
49#define tmp1 r1
50#define tmp2 r2
51#define tmp3 r3
52
53/* SPR registers */
54
55#define mq 0 /* MQ register for 601 emulation */
56#define rtcu 4 /* RTCU - upper word of RTC for 601 emulation */
57#define rtcl 5 /* RTCL - lower word of RTC for 601 emulation */
58#define dsisr 18
59#define ppcDAR 19
60#define ppcdar 19
61#define dar 19
62#define SDR1 25
63#define sdr1 25
64#define srr0 26
65#define srr1 27
66#define vrsave 256 /* Vector Register save */
67#define sprg0 272
68#define sprg1 273
69#define sprg2 274
70#define sprg3 275
d7e50217
A
71#define scomc 276
72#define scomd 277
1c79356b
A
73#define pvr 287
74
75#define IBAT0U 528
76#define IBAT0L 529
77#define IBAT1U 530
78#define IBAT1L 531
79#define IBAT2U 532
80#define IBAT2L 533
81#define IBAT3U 534
82#define IBAT3L 535
83#define ibat0u 528
84#define ibat0l 529
85#define ibat1u 530
86#define ibat1l 531
87#define ibat2u 532
88#define ibat2l 533
89#define ibat3u 534
90#define ibat3l 535
91
92#define DBAT0U 536
93#define DBAT0L 537
94#define DBAT1U 538
95#define DBAT1L 539
96#define DBAT2U 540
97#define DBAT2L 541
98#define DBAT3U 542
99#define DBAT3L 543
100#define dbat0u 536
101#define dbat0l 537
102#define dbat1u 538
103#define dbat1l 539
104#define dbat2u 540
105#define dbat2l 541
106#define dbat3u 542
107#define dbat3l 543
108
109#define ummcr2 928 /* Performance monitor control */
d7e50217
A
110#define upmc5 929 /* Performance monitor counter */
111#define upmc6 930 /* Performance monitor counter */
1c79356b
A
112#define ubamr 935 /* Performance monitor mask */
113#define ummcr0 936 /* Performance monitor control */
114#define upmc1 937 /* Performance monitor counter */
115#define upmc2 938 /* Performance monitor counter */
116#define usia 939 /* User sampled instruction address */
117#define ummcr1 940 /* Performance monitor control */
118#define upmc3 941 /* Performance monitor counter */
119#define upmc4 942 /* Performance monitor counter */
120#define usda 943 /* User sampled data address */
121#define mmcr2 944 /* Performance monitor control */
d7e50217
A
122#define pmc5 945 /* Performance monitor counter */
123#define pmc6 946 /* Performance monitor counter */
1c79356b
A
124#define bamr 951 /* Performance monitor mask */
125#define mmcr0 952
126#define pmc1 953
127#define pmc2 954
128#define sia 955
129#define mmcr1 956
130#define pmc3 957
131#define pmc4 958
132#define sda 959 /* Sampled data address */
133#define dmiss 976 /* ea that missed */
d7e50217 134#define trig0 976
1c79356b 135#define dcmp 977 /* compare value for the va that missed */
d7e50217 136#define trig1 977
1c79356b 137#define hash1 978 /* pointer to first hash pteg */
d7e50217 138#define trig2 978
1c79356b
A
139#define hash2 979 /* pointer to second hash pteg */
140#define imiss 980 /* ea that missed */
141#define tlbmiss 980 /* ea that missed */
142#define icmp 981 /* compare value for the va that missed */
143#define ptehi 981 /* compare value for the va that missed */
144#define rpa 982 /* required physical address register */
145#define ptelo 982 /* required physical address register */
146#define l3pdet 984 /* l3pdet */
147
148#define HID0 1008 /* Checkstop and misc enables */
149#define hid0 1008 /* Checkstop and misc enables */
150#define HID1 1009 /* Clock configuration */
151#define hid1 1009 /* Clock configuration */
d7e50217
A
152#define HID2 1016 /* Other processor controls */
153#define hid2 1016 /* Other processor controls */
1c79356b
A
154#define iabr 1010 /* Instruction address breakpoint register */
155#define ictrl 1011 /* Instruction Cache Control */
0b4e3aa0 156#define ldstdb 1012 /* Load/Store Debug */
d7e50217 157#define hid4 1012 /* Misc stuff */
1c79356b
A
158#define dabr 1013 /* Data address breakpoint register */
159#define msscr0 1014 /* Memory subsystem control */
d7e50217 160#define hid5 1014 /* Misc stuff */
1c79356b
A
161#define msscr1 1015 /* Memory subsystem debug */
162#define msssr0 1015 /* Memory Subsystem Status */
163#define ldstcr 1016 /* Load/Store Status/Control */
164#define l2cr2 1016 /* L2 Cache control 2 */
165#define l2cr 1017 /* L2 Cache control */
166#define l3cr 1018 /* L3 Cache control */
167#define ictc 1019 /* I-cache throttling control */
168#define thrm1 1020 /* Thermal management 1 */
169#define thrm2 1021 /* Thermal management 2 */
170#define thrm3 1022 /* Thermal management 3 */
171#define pir 1023 /* Processor ID Register */
172
d7e50217
A
173
174/* SPR registers (64-bit, PPC970 specific) */
175
176#define scomc_gp 276
177#define scomd_gp 277
178
179#define hsprg0 304
180#define hsprg1 305
181#define hdec 310
182#define hior 311
183#define rmor 312
184#define hrmor 313
185#define hsrr0 314
186#define hsrr1 315
187#define lpcr 318
188#define lpidr 319
189
190#define ummcra_gp 770
191#define upmc1_gp 771
192#define upmc2_gp 772
193#define upmc3_gp 773
194#define upmc4_gp 774
195#define upmc5_gp 775
196#define upmc6_gp 776
197#define upmc7_gp 777
198#define upmc8_gp 778
199#define ummcr0_gp 779
200#define usiar_gp 780
201#define usdar_gp 781
202#define ummcr1_gp 782
203#define uimc_gp 783
204
205#define mmcra_gp 786
206#define pmc1_gp 787
207#define pmc2_gp 788
208#define pmc3_gp 789
209#define pmc4_gp 790
210#define pmc5_gp 791
211#define pmc6_gp 792
212#define pmc7_gp 793
213#define pmc8_gp 794
214#define mmcr0_gp 795
215#define siar_gp 796
216#define sdar_gp 797
217#define mmcr1_gp 798
218#define imc_gp 799
219
220#define trig0_gp 976
221#define trig1_gp 977
222#define trig2_gp 978
223
224#define dabrx 1015
225
1c79356b
A
226; hid0 bits
227#define emcp 0
228#define emcpm 0x80000000
229#define dbp 1
230#define dbpm 0x40000000
231#define eba 2
232#define ebam 0x20000000
233#define ebd 3
234#define ebdm 0x10000000
235#define sbclk 4
236#define sbclkm 0x08000000
237#define eclk 6
238#define eclkm 0x02000000
239#define par 7
240#define parm 0x01000000
241#define sten 7
242#define stenm 0x01000000
243#define doze 8
244#define dozem 0x00800000
245#define nap 9
246#define napm 0x00400000
247#define sleep 10
248#define sleepm 0x00200000
249#define dpm 11
250#define dpmm 0x00100000
251#define riseg 12
252#define risegm 0x00080000
253#define eiec 13
254#define eiecm 0x00040000
d52fe63f
A
255#define mum 14
256#define mumm 0x00020000
1c79356b
A
257#define nhr 15
258#define nhrm 0x00010000
259#define ice 16
260#define icem 0x00008000
261#define dce 17
262#define dcem 0x00004000
263#define ilock 18
264#define ilockm 0x00002000
265#define dlock 19
266#define dlockm 0x00001000
d7e50217 267#define exttben 19
1c79356b
A
268#define icfi 20
269#define icfim 0x00000800
270#define dcfi 21
271#define dcfim 0x00000400
272#define spd 22
273#define spdm 0x00000200
274#define sge 24
275#define sgem 0x00000080
276#define dcfa 25
277#define dcfam 0x00000040
278#define btic 26
279#define bticm 0x00000020
280#define lrstk 27
281#define lrstkm 0x00000010
282#define abe 28
283#define abem 0x00000008
284#define fold 28
285#define foldm 0x00000008
286#define bht 29
287#define bhtm 0x00000004
288#define nopdst 30
289#define nopdstm 0x00000002
290#define nopti 31
291#define noptim 0x00000001
292
d52fe63f
A
293; hid1 bits
294#define hid1pcem 0xF8000000
295#define hid1prem 0x06000000
296#define hid1pi0 14
297#define hid1pi0m 0x00020000
d7e50217 298#define hid1FCPErr 14
d52fe63f 299#define hid1ps 15
d7e50217 300#define hid1FCD0PErr 15
d52fe63f
A
301#define hid1psm 0x00010000
302#define hid1pc0 0x0000F800
303#define hid1pr0 0x00000600
304#define hid1pc1 0x000000F8
305#define hid1pc0 0x0000F800
306#define hid1pr1 0x00000006
d7e50217
A
307#define hid1FCD1PErr 16
308#define hid1FIERATErr 17
309
310; hid2 bits
311#define hid2vmin 18
312#define hid2vminm 0x00002000
d52fe63f 313
1c79356b
A
314; msscr0 bits
315#define shden 0
316#define shdenm 0x80000000
317#define shden3 1
318#define shdenm3 0x40000000
319#define l1intvs 2
320#define l1intve 4
321#define l1intvb 0x38000000
322#define l2intvs 5
323#define l2intve 7
324#define l2intvb 0x07000000
325#define dl1hwf 8
326#define dl1hwfm 0x00800000
327#define dbsiz 9
328#define dbsizm 0x00400000
329#define emode 10
330#define emodem 0x00200000
331#define abgd 11
332#define abgdm 0x00100000
333#define tfsts 24
334#define tfste 25
335#define tfstm 0x000000C0
0b4e3aa0
A
336#define l2pfes 30
337#define l2pfee 31
338#define l2pfem 0x00000003
1c79356b
A
339
340; msscr1 bits
341#define cqd 15
342#define cqdm 0x00010000
343#define csqs 1
344#define csqe 2
345#define csqm 0x60000000
346
347; msssr1 bits - 7450
348#define vgL2PARA 0
349#define vgL3PARA 1
350#define vgL2COQEL 2
351#define vgL3COQEL 3
352#define vgL2CTR 4
353#define vgL3CTR 5
354#define vgL2COQR 6
355#define vgL3COQR 7
356#define vgLMQ 8
357#define vgSMC 9
358#define vgSNP 10
359#define vgBIU 11
360#define vgSMCE 12
361#define vgL2TAG 13
362#define vgL2DAT 14
363#define vgL3TAG 15
364#define vgL3DAT 16
365#define vgAPE 17
366#define vgDPE 18
367#define vgTEA 19
368
369; srr1 bits
370#define icmck 1
371#define icmckm 0x40000000
372#define dcmck 2
373#define dcmckm 0x20000000
374#define l2mck 3
375#define l2mckm 0x10000000
376#define tlbmck 4
377#define tlbmckm 0x08000000
378#define brmck 5
379#define brmckm 0x04000000
380#define othmck 10
381#define othmckm 0x00200000
382#define l2dpmck 11
383#define l2dpmckm 0x00100000
384#define mcpmck 12
385#define mcpmckm 0x00080000
386#define teamck 13
387#define teamckm 0x00040000
388#define dpmck 14
389#define dpmckm 0x00020000
390#define apmck 15
391#define apmckm 0x00010000
392
d7e50217
A
393#define mckIFUE 42
394#define mckLDST 43
395#define mckXCs 44
396#define mckXCe 45
397#define mckNoErr 0
398#define mckIFSLBPE 1
399#define mckIFTLBPE 2
400#define mckIFTLBUE 3
401
402; dsisr bits
403#define mckUEdfr 16
404#define mckUETwDfr 17
405#define mckL1DCPE 18
406#define mckL1DTPE 19
407#define mckDEPE 20
408#define mckTLBPE 21
409#define mckSLBPE 23
410
411; Async MCK source
412#define AsyMCKSrc 0x0226
413#define AsyMCKRSrc 0x0227
414#define AsyMCKext 0
415#define AsyMCKfir 1
416#define AsyMCKhri 2
417#define AsyMCKdbg 3
418#define AsyMCKncstp 4
419
420; Core FIR
421#define cFIR 0x0300
422#define cFIRrst 0x0310
423#define cFIRICachePE 0
424#define cFIRITagPE0 1
425#define cFIRITagPE1 2
426#define cFIRIEratPE 3
427#define cFIRIFUL2UE 4
428#define cFIRIFUCS 5
429#define cFIRDCachePE 6
430#define cFIRDTagPE 7
431#define cFIRDEratPE 8
432#define cFIRTLBPE 9
433#define cFIRSLBPE 10
434#define cFIRSL2UE 11
435
436; Core Error Inject
437#define CoreErrI 0x0350
438#define CoreIFU 0
439#define CoreLSU 1
440#define CoreRate0 2
441#define CoreRate1 3
442#define CoreOnce 0
443#define CoreSolid 2
444#define CorePulse 3
445
446; GUS Mode Register
447#define GUSModeReg 0x0430
448#define GUSMdmapen 0x00008000
449#define GUSMstgtdis 0x00000080
450#define GUSMstgttim 0x00000038
451#define GUSMstgttoff 0x00000004
452
453; HID4
454#define hid4RMCI 23
455#define hid4FAlgn 24
456#define hid4DisPF 25
457#define hid4ResPF 26
458#define hid4EnSPTW 27
459#define hid4L1DCFI 28
460#define hid4DisDERpg 31
461#define hid4DisDCTpg 36
462#define hid4DisDCpg 41
463#define hid4DisTLBpg 48
464#define hid4DisSLBpg 54
465#define hid4MckEIEna 55
466
1c79356b
A
467; L2 cache control
468#define l2e 0
469#define l2em 0x80000000
470#define l2pe 1
471#define l2pem 0x40000000
472#define l2siz 2
473#define l2sizf 3
474#define l2sizm 0x30000000
475#define l2clk 4
476#define l2clkf 6
477#define l2clkm 0x0E000000
478#define l2ram 7
479#define l2ramf 8
480#define l2ramm 0x01800000
481#define l2do 9
482#define l2dom 0x00400000
483#define l2i 10
484#define l2im 0x00200000
485#define l2ctl 11
486#define l2ctlm 0x00100000
487#define l2ionly 11
488#define l2ionlym 0x00100000
489#define l2wt 12
490#define l2wtm 0x00080000
491#define l2ts 13
492#define l2tsm 0x00040000
493#define l2oh 14
494#define l2ohf 15
495#define l2ohm 0x00030000
496#define l2donly 15
497#define l2donlym 0x00010000
498#define l2sl 16
499#define l2slm 0x00008000
500#define l2df 17
501#define l2dfm 0x00004000
502#define l2byp 18
503#define l2bypm 0x00002000
504#define l2fa 19
505#define l2fam 0x00001000
506#define l2hwf 20
507#define l2hwfm 0x00000800
508#define l2io 21
509#define l2iom 0x00000400
510#define l2clkstp 22
511#define l2clkstpm 0x00000200
512#define l2dro 23
513#define l2drom 0x00000100
514#define l2ctr 24
515#define l2ctrf 30
516#define l2ctrm 0x000000FE
517#define l2ip 31
518#define l2ipm 0x00000001
519
520; L3 cache control
521#define l3e 0
522#define l3em 0x80000000
523#define l3pe 1
524#define l3pem 0x40000000
525#define l3siz 3
526#define l3sizm 0x10000000
527#define l3clken 4
528#define l3clkenm 0x08000000
529#define l3dx 5
530#define l3dxm 0x04000000
531#define l3clk 6
532#define l3clkf 8
533#define l3clkm 0x03800000
534#define l3io 9
535#define l3iom 0x00400000
536#define l3spo 13
537#define l3spom 0x00040000
538#define l3cksp 14
539#define l3ckspf 15
540#define l3ckspm 0x00030000
541#define l3psp 16
542#define l3pspf 18
543#define l3pspm 0x0000E000
544#define l3rep 19
545#define l3repm 0x00001000
546#define l3hwf 20
547#define l3hwfm 0x00000800
548#define l3i 21
549#define l3im 0x00000400
550#define l3rt 22
551#define l3rtf 23
552#define l3rtm 0x00000300
553#define l3dro 23
554#define l3drom 0x00000100
555#define l3cya 24
556#define l3cyam 0x00000080
557#define l3donly 25
558#define l3donlym 0x00000040
559#define l3dmem 29
560#define l3dmemm 0x00000004
561#define l3dmsiz 31
562#define l3dmsizm 0x00000001
563
564#define thrmtin 0
565#define thrmtinm 0x80000000
566#define thrmtiv 1
567#define thrmtivm 0x40000000
568#define thrmthrs 2
569#define thrmthre 8
570#define thrmthrm 0x3F800000
571#define thrmtid 29
572#define thrmtidm 0x00000004
573#define thrmtie 30
574#define thrmtiem 0x00000002
575#define thrmv 31
576#define thrmvm 0x00000001
577
578#define thrmsitvs 15
579#define thrmsitve 30
580#define thrmsitvm 0x0001FFFE
581#define thrme 31
582#define thrmem 0x00000001
583
584#define ictcfib 23
585#define ictcfie 30
586#define ictcfim 0x000001FE
587#define ictce 31
588#define ictcem 0x00000001
589
590#define cr0_lt 0
591#define cr0_gt 1
592#define cr0_eq 2
593#define cr0_so 3
594#define cr0_un 3
595#define cr1_lt 4
596#define cr1_gt 5
597#define cr1_eq 6
598#define cr1_so 7
599#define cr1_un 7
600#define cr2_lt 8
601#define cr2_gt 9
602#define cr2_eq 10
603#define cr2_so 11
604#define cr2_un 11
605#define cr3_lt 12
606#define cr3_gt 13
607#define cr3_eq 14
608#define cr3_so 15
609#define cr3_un 15
610#define cr4_lt 16
611#define cr4_gt 17
612#define cr4_eq 18
613#define cr4_so 19
614#define cr4_un 19
615#define cr5_lt 20
616#define cr5_gt 21
617#define cr5_eq 22
618#define cr5_so 23
619#define cr5_un 23
620#define cr6_lt 24
621#define cr6_gt 25
622#define cr6_eq 26
623#define cr6_so 27
624#define cr6_un 27
625#define cr7_lt 28
626#define cr7_gt 29
627#define cr7_eq 30
628#define cr7_so 31
629#define cr7_un 31
630
d7e50217
A
631#define slbESID 36
632#define slbKey 52
633#define slbIndex 52
634#define slbV 36
635#define slbVm 0x08000000
636#define slbCnt 64
637
1c79356b
A
638/*
639 * Macros to access high and low word values of an address
640 */
641
642#define HIGH_CADDR(x) ha16(x)
643#define HIGH_ADDR(x) hi16(x)
644#define LOW_ADDR(x) lo16(x)
645
646#endif /* ASSEMBLER */
647
648/* Tags are placed before Immediately Following Code (IFC) for the debugger
649 * to be able to deduce where to find various registers when backtracing
650 *
651 * We only define the values as we use them, see SVR4 ABI PowerPc Supplement
652 * for more details (defined in ELF spec).
653 */
654
655#define TAG_NO_FRAME_USED 0x00000000
656
657/* (should use genassym to get these offsets) */
658
659#define FM_BACKPTR 0
660#define FM_CR_SAVE 4
661#define FM_LR_SAVE 8 /* MacOSX is NOT following the ABI at the moment.. */
662#define FM_SIZE 64 /* minimum frame contents, backptr and LR save. Make sure it is quadaligned */
663#define FM_ARG0 56
664#define FM_ALIGN(l) ((l+15)&-16)
665#define PK_SYSCALL_BEGIN 0x7000
666
667
668/* redzone is the area under the stack pointer which must be preserved
669 * when taking a trap, interrupt etc.
670 */
671#define FM_REDZONE 224 /* is ((32-14+1)*4) */
672
673#define COPYIN_ARG0_OFFSET FM_ARG0
674
675#ifdef MACH_KERNEL
676#include <mach_kdb.h>
677#else /* MACH_KERNEL */
678#define MACH_KDB 0
679#endif /* MACH_KERNEL */
680
681#define BREAKPOINT_TRAP tw 4,r4,r4
682
683/* There is another definition of ALIGN for .c sources */
684#ifndef __LANGUAGE_ASSEMBLY
685#define ALIGN 4
686#endif /* __LANGUAGE_ASSEMBLY */
687
688#ifndef FALIGN
689#define FALIGN 4 /* Align functions on words for now. Cachelines is better */
690#endif
691
692#define LB(x,n) n
693#if __STDC__
694#define LCL(x) L ## x
695#define EXT(x) _ ## x
696#define LEXT(x) _ ## x ## :
697#define LBc(x,n) n ## :
698#define LBb(x,n) n ## b
699#define LBf(x,n) n ## f
700#else /* __STDC__ */
701#define LCL(x) L/**/x
702#define EXT(x) _/**/x
703#define LEXT(x) _/**/x/**/:
704#define LBc(x,n) n/**/:
705#define LBb(x,n) n/**/b
706#define LBf(x,n) n/**/f
707#endif /* __STDC__ */
708
709#define String .asciz
710#define Value .word
711#define Times(a,b) (a*b)
712#define Divide(a,b) (a/b)
713
714#define data16 .byte 0x66
715#define addr16 .byte 0x67
716
717#if !GPROF
718#define MCOUNT
719#endif /* GPROF */
720
721#define ELF_FUNC(x)
722#define ELF_DATA(x)
723#define ELF_SIZE(x,s)
724
725#define Entry(x,tag) .text@.align FALIGN@ .globl EXT(x)@ LEXT(x)
726#define ENTRY(x,tag) Entry(x,tag)@MCOUNT
727#define ENTRY2(x,y,tag) .text@ .align FALIGN@ .globl EXT(x)@ .globl EXT(y)@ \
728 LEXT(x)@ LEXT(y) @\
729 MCOUNT
730#if __STDC__
731#define ASENTRY(x) .globl x @ .align FALIGN; x ## @ MCOUNT
732#else
733#define ASENTRY(x) .globl x @ .align FALIGN; x @ MCOUNT
734#endif /* __STDC__ */
735#define DATA(x) .globl EXT(x) @ .align ALIGN @ LEXT(x)
736
737
738#define End(x) ELF_SIZE(x,.-x)
739#define END(x) End(EXT(x))
740#define ENDDATA(x) END(x)
741#define Enddata(x) End(x)
742
743/* These defines are here for .c files that wish to reference global symbols
744 * within __asm__ statements.
745 */
746#define CC_SYM_PREFIX "_"
747
748#endif /* _PPC_ASM_H_ */