]> CyberLeo.Net >> Repos - FreeBSD/releng/9.0.git/blob - sys/powerpc/ps3/ps3-hv-asm.awk
Copy stable/9 to releng/9.0 as part of the FreeBSD 9.0-RELEASE release
[FreeBSD/releng/9.0.git] / sys / powerpc / ps3 / ps3-hv-asm.awk
1 # This script generates the PS3 hypervisor call stubs from an HV
2 # interface definition file. The PS3 HV calling convention is very
3 # similar to the PAPR one, except that the function token is passed in
4 # r11 instead of r3.
5 #
6 # Invoke like so: awk -f ps3-hv-asm.awk < ps3-hvcall.master > ps3-hvcall.S
7 #
8
9 # $FreeBSD$
10
11 BEGIN {
12         printf("#include <machine/asm.h>\n\n");
13         printf("#define hc .long 0x44000022\n\n");
14 }
15
16 /HVCALL.*/ {
17         code = $2;
18         ins = split($4, a, ",")
19         outs = split($5, a, ",")
20         
21         printf("ASENTRY(%s)\n",$3);
22         printf("\tmflr  %%r0\n");
23         printf("\tstd   %%r0,16(%%r1)\n");
24         printf("\tstdu  %%r1,-%d(%%r1)\n", 48+8*outs);
25
26         if ($4 == "UNUSED")
27                 ins = 0
28         
29         # Save output reg addresses to the stack
30         for (i = 0; i < outs; i++) {
31                 if (ins+i >= 8) {
32                    printf("\tld %%r11,%d(%%r1)\n", 48+8*outs + 48 + 8*(i+ins));
33                    printf("\tstd        %%r11,%d(%%r1)\n", 48+8*i);
34                 } else {
35                    printf("\tstd        %%r%d,%d(%%r1)\n", 3+ins+i, 48+8*i);
36                 }
37         }
38
39         printf("\tli    %%r11,%d\n", code);
40         printf("\thc\n");
41         printf("\textsw %%r3,%%r3\n");
42                 
43         for (i = 0; i < outs; i++) {
44                 printf("\tld    %%r11,%d(%%r1)\n", 48+8*i);
45                 printf("\tstd   %%r%d,0(%%r11)\n", 4+i);
46         }
47
48         printf("\tld    %%r1,0(%%r1)\n");
49         printf("\tld    %%r0,16(%%r1)\n");
50         printf("\tmtlr  %%r0\n");
51         printf("\tblr\n\n");
52 }