1/* 2 * @OSF_COPYRIGHT@ 3 */ 4 5#ifndef _PPC_ASM_H_ 6#define _PPC_ASM_H_ 7 8#ifdef __ELF__ 9#define __NO_UNDERSCORES__ 1 10#define __ASMNL__ ; 11#else 12#define __ASMNL__ @ 13#endif 14 15#ifdef ASSEMBLER 16 17#ifdef __ELF__ 18#define r0 0 19#define r1 1 20#define r2 2 21#define r3 3 22#define r4 4 23#define r5 5 24#define r6 6 25#define r7 7 26#define r8 8 27#define r9 9 28#define r10 10 29#define r11 11 30#define r12 12 31#define r13 13 32#define r14 14 33#define r15 15 34#define r16 16 35#define r17 17 36#define r18 18 37#define r19 19 38#define r20 20 39#define r21 21 40#define r22 22 41#define r23 23 42#define r24 24 43#define r25 25 44#define r26 26 45#define r27 27 46#define r28 28 47#define r29 29 48#define r30 30 49#define r31 31 50 51#define f0 0 52#define f1 1 53#define f2 2 54#define f3 3 55#define f4 4 56#define f5 5 57#define f6 6 58#define f7 7 59#define f8 8 60#define f9 9 61#define f10 10 62#define f11 11 63#define f12 12 64#define f13 13 65#define f14 14 66#define f15 15 67#define f16 16 68#define f17 17 69#define f18 18 70#define f19 19 71#define f20 20 72#define f21 21 73#define f22 22 74#define f23 23 75#define f24 24 76#define f25 25 77#define f26 26 78#define f27 27 79#define f28 28 80#define f29 29 81#define f30 30 82#define f31 31 83 84#define sr0 0 85#define sr1 1 86#define sr2 2 87#define sr3 3 88#define sr4 4 89#define sr5 5 90#define sr6 6 91#define sr7 7 92#define sr8 8 93#define sr9 9 94#define sr10 10 95#define sr11 11 96#define sr12 12 97#define sr13 13 98#define sr14 14 99#define sr15 15 100#define sr16 16 101#define sr17 17 102#define sr18 18 103#define sr19 19 104#define sr20 20 105#define sr21 21 106#define sr22 22 107#define sr23 23 108#define sr24 24 109#define sr25 25 110#define sr26 26 111#define sr27 27 112#define sr28 28 113#define sr29 29 114#define sr30 30 115#define sr31 31 116#endif 117 118#define ARG0 r3 119#define ARG1 r4 120#define ARG2 r5 121#define ARG3 r6 122#define ARG4 r7 123#define ARG5 r8 124#define ARG6 r9 125#define ARG7 r10 126 127#define tmp0 r0 /* Temporary GPR remapping (603e specific) */ 128#define tmp1 r1 129#define tmp2 r2 130#define tmp3 r3 131 132/* SPR registers */ 133 134#define dmiss 976 /* ea that missed */ 135#define dcmp 977 /* compare value for the va that missed */ 136#define hash1 978 /* pointer to first hash pteg */ 137#define hash2 979 /* pointer to second hash pteg */ 138#define imiss 980 /* ea that missed */ 139#define icmp 981 /* compare value for the va that missed */ 140#define rpa 982 /* required physical address register */ 141 142#define iabr 1010 /* instruction address breakpoint register */ 143#define pir 1023 /* Processor ID Register */ 144 145/* MQ register on the 601 */ 146#define mq 0 /* spr number for mq register on 601 */ 147 148#define IBAT0U 528 149#define IBAT0L 529 150#define IBAT1U 530 151#define IBAT1L 531 152#define IBAT2U 532 153#define IBAT2L 533 154#define IBAT3U 534 155#define IBAT3L 535 156#define ibat0u 528 157#define ibat0l 529 158#define ibat1u 530 159#define ibat1l 531 160#define ibat2u 532 161#define ibat2l 533 162#define ibat3u 534 163#define ibat3l 535 164 165#define DBAT0U 536 166#define DBAT0L 537 167#define DBAT1U 538 168#define DBAT1L 539 169#define DBAT2U 540 170#define DBAT2L 541 171#define DBAT3U 542 172#define DBAT3L 543 173#define dbat0u 536 174#define dbat0l 537 175#define dbat1u 538 176#define dbat1l 539 177#define dbat2u 540 178#define dbat2l 541 179#define dbat3u 542 180#define dbat3l 543 181 182#define HID0 1008 183#define hid0 1008 184#define HID1 1009 185#define hid1 1009 186#define SDR1 25 187#define sprg0 272 188#define sprg1 273 189#define sprg2 274 190#define sprg3 275 191#define ppcDAR 19 192#define ppcdar 19 193#define srr0 26 194#define srr1 27 195 196#define CR0 0 197#define CR1 1 198#define CR2 2 199#define CR3 3 200#define CR4 4 201#define CR5 5 202#define CR6 6 203#define CR7 7 204 205#ifdef __ELF__ 206#define cr0 0 207#define cr1 1 208#define cr2 2 209#define cr3 3 210#define cr4 4 211#define cr5 5 212#define cr6 6 213#define cr7 7 214#endif 215 216#define cr0_lt 0 217#define cr0_gt 1 218#define cr0_eq 2 219#define cr0_so 3 220#define cr0_un 3 221 222/* 223 * Macros to access high and low word values of an address 224 */ 225 226#ifndef __ELF__ 227#define HIGH_CADDR(x) ha16(x) 228#define HIGH_ADDR(x) hi16(x) 229#define LOW_ADDR(x) lo16(x) 230#else 231#define HIGH_CADDR(x) x@ha 232#define HIGH_ADDR(x) x@h 233#define LOW_ADDR(x) x@l 234#endif /* __ELF__ */ 235 236#endif /* ASSEMBLER */ 237 238/* Tags are placed before Immediately Following Code (IFC) for the debugger 239 * to be able to deduce where to find various registers when backtracing 240 * 241 * We only define the values as we use them, see SVR4 ABI PowerPc Supplement 242 * for more details (defined in ELF spec). 243 */ 244 245#define TAG_NO_FRAME_USED 0x00000000 246 247/* (should use genassym to get these offsets) */ 248 249#define FM_BACKPTR 0 250/* TODO NMGS FM_SIZE 8 is ok according to EABI specs, but gcc uses 16 */ 251#ifdef __ELF__ 252#define FM_LR_SAVE 4 /* gcc 2.7.1 is now following eabi spec correctly */ 253#define FM_SIZE 16 /* minimum frame contents, backptr and LR save */ 254#define FM_ARG0 8 255#else 256#define FM_CR_SAVE 4 257#define FM_LR_SAVE 8 /* Rhapsody iS NOT following the ABI at the moment.. */ 258#define FM_SIZE 72 /* minimum frame contents, backptr and LR save */ 259#define FM_ARG0 56 260#endif 261 262#define FM_ELF_ARG0 8 263#define FM_MACHO_ARG0 56 264#define MACHO_SYSCALL_BEGIN 0x2000 265#define PK_SYSCALL_BEGIN 0x7000 266 267 268/* redzone is the area under the stack pointer which must be preserved 269 * when taking a trap, interrupt etc. This is no longer needed as gcc 270 * (2.7.2 and above) now follows ELF spec correctly and never loads/stores 271 * below the frame pointer 272 */ 273#ifdef __ELF__ 274#define FM_REDZONE 0 /* was ((32-14+1)*4) */ 275#else 276#define FM_REDZONE 224 /* is ((32-14+1)*4) */ 277#endif 278 279#define COPYIN_ARG0_OFFSET FM_ARG0 280 281#ifdef MACH_KERNEL_BUILD 282#include <mach_kdb.h> 283#else /* MACH_KERNEL */ 284#define MACH_KDB 0 285#endif /* MACH_KERNEL */ 286 287#define BREAKPOINT_TRAP twge r2,r2 288 289/* There is another definition of ALIGN for .c sources */ 290#ifndef __LANGUAGE_ASSEMBLY 291#define ALIGN 2 292#endif /* __LANGUAGE_ASSEMBLY */ 293 294#ifndef FALIGN 295#define FALIGN 2 /* Align functions on words for now. Cachelines is better */ 296#endif 297 298#define LB(x,n) n 299#if __STDC__ 300#ifndef __NO_UNDERSCORES__ 301#define LCL(x) L ## x 302#define EXT(x) _ ## x 303#define LEXT(x) _ ## x ## : 304#else 305#define LCL(x) .L ## x 306#define EXT(x) x 307#define LEXT(x) x ## : 308#endif 309#define LBc(x,n) n ## : 310#define LBb(x,n) n ## b 311#define LBf(x,n) n ## f 312#else /* __STDC__ */ 313#ifndef __NO_UNDERSCORES__ 314#define LCL(x) L/**/x 315#define EXT(x) _/**/x 316#define LEXT(x) _/**/x/**/: 317#else /* __NO_UNDERSCORES__ */ 318#define LCL(x) .L/**/x 319#define EXT(x) x 320#define LEXT(x) x/**/: 321#endif /* __NO_UNDERSCORES__ */ 322#define LBc(x,n) n/**/: 323#define LBb(x,n) n/**/b 324#define LBf(x,n) n/**/f 325#endif /* __STDC__ */ 326 327#define String .asciz 328#define Value .word 329#define Times(a,b) (a*b) 330#define Divide(a,b) (a/b) 331 332#define data16 .byte 0x66 333#define addr16 .byte 0x67 334 335#if !GPROF 336#define MCOUNT 337 338#elif defined(__SHARED__) 339#define MCOUNT ; .data;\ 340 .align ALIGN;\ 341 LBc(x, 8) .long 0;\ 342 .text;\ 343 Gpush;\ 344 Gload;\ 345 leal Gotoff(LBb(x,8)),%edx;\ 346 Egaddr(%eax,_mcount_ptr);\ 347 Gpop;\ 348 call *(%eax); 349 350#else /* !GPROF, !__SHARED__ */ 351#define MCOUNT ; .data;\ 352 .align ALIGN;\ 353 LBc(x, 8) .long 0;\ 354 .text;\ 355 movl $LBb(x,8),%edx;\ 356 call *EXT(_mcount_ptr); 357 358#endif /* GPROF */ 359 360#ifdef __ELF__ 361#define ELF_FUNC(x) .type x,@function 362#define ELF_DATA(x) .type x,@object 363#define ELF_SIZE(x,s) .size x,s 364#else 365#define ELF_FUNC(x) 366#define ELF_DATA(x) 367#define ELF_SIZE(x,s) 368#endif 369 370#ifdef __ELF__ 371#define Entry(x,tag) .globl EXT(x); ELF_FUNC(EXT(x)); .long tag;.align FALIGN; LEXT(x) 372#define ENTRY(x,tag) Entry(x,tag) MCOUNT 373#define ENTRY2(x,y,tag) .globl EXT(x); .globl EXT(y); \ 374 ELF_FUNC(EXT(x)); ELF_FUNC(EXT(y)); \ 375 .align FALIGN; LEXT(x); LEXT(y) \ 376 MCOUNT 377#if __STDC__ 378#define ASENTRY(x) .globl x; .align FALIGN; x ## : ELF_FUNC(x) MCOUNT 379#else 380#define ASENTRY(x) .globl x; .align FALIGN; x: ELF_FUNC(x) MCOUNT 381#endif /* __STDC__ */ 382#define DATA(x) .globl EXT(x); ELF_DATA(EXT(x)); .align ALIGN; LEXT(x) 383 384#else /* __ELF__ */ 385 386#define Entry(x,tag) .text@.align FALIGN@ .globl EXT(x)@ LEXT(x) 387#define ENTRY(x,tag) Entry(x,tag)@MCOUNT 388#define ENTRY2(x,y,tag) .text@ .align FALIGN@ .globl EXT(x)@ .globl EXT(y)@ \ 389 LEXT(x)@ LEXT(y) @\ 390 MCOUNT 391#if __STDC__ 392#define ASENTRY(x) .globl x @ .align FALIGN; x ## @ MCOUNT 393#else 394#define ASENTRY(x) .globl x @ .align FALIGN; x @ MCOUNT 395#endif /* __STDC__ */ 396#define DATA(x) .globl EXT(x) @ .align ALIGN @ LEXT(x) 397#endif 398 399 400 401#define End(x) ELF_SIZE(x,.-x) 402#define END(x) End(EXT(x)) 403#define ENDDATA(x) END(x) 404#define Enddata(x) End(x) 405 406/* These defines are here for .c files that wish to reference global symbols 407 * within __asm__ statements. 408 */ 409#ifndef __NO_UNDERSCORES__ 410#define CC_SYM_PREFIX "_" 411#else 412#define CC_SYM_PREFIX "" 413#endif /* __NO_UNDERSCORES__ */ 414 415#endif /* _PPC_ASM_H_ */ 416