ps3-hv-asm.awk revision 217044
1153203Sobrien# This script generates the PS3 hypervisor call stubs from an HV 2144073Sobrien# interface definition file. The PS3 HV calling convention is very 3143442Sobrien# similar to the PAPR one, except that the function token is passed in 4143442Sobrien# r11 instead of r3. 5143442Sobrien# 6143442Sobrien# Invoke like so: awk -f ps3-hv-asm.awk < ps3-hvcall.master > ps3-hvcall.S 7143442Sobrien# 8143442Sobrien 9143442Sobrien# $FreeBSD: head/sys/powerpc/ps3/ps3-hv-asm.awk 217044 2011-01-06 04:12:29Z nwhitehorn $ 10143442Sobrien 11143442SobrienBEGIN { 12143442Sobrien printf("#include <machine/asm.h>\n\n"); 13143442Sobrien printf("#define hc .long 0x44000022\n\n"); 14143442Sobrien} 15143442Sobrien 16143442Sobrien/HVCALL.*/ { 17143442Sobrien code = $2; 18143442Sobrien ins = split($4, a, ",") 19143442Sobrien outs = split($5, a, ",") 20143442Sobrien 21143442Sobrien printf("ASENTRY(%s)\n",$3); 22143442Sobrien printf("\tmflr %%r0\n"); 23143442Sobrien printf("\tstd %%r0,16(%%r1)\n"); 24143442Sobrien printf("\tstdu %%r1,-%d(%%r1)\n", 48+8*outs); 25143442Sobrien 26143442Sobrien if ($4 == "UNUSED") 27143442Sobrien ins = 0 28143442Sobrien 29143442Sobrien # Save output reg addresses to the stack 30143442Sobrien for (i = 0; i < outs; i++) { 31143442Sobrien if (ins+i >= 8) { 32143442Sobrien printf("\tld %%r11,%d(%%r1)\n", 48+8*outs + 48 + 8*(i+ins)); 33143442Sobrien printf("\tstd %%r11,%d(%%r1)\n", 48+8*i); 34143442Sobrien } else { 35143442Sobrien printf("\tstd %%r%d,%d(%%r1)\n", 3+ins+i, 48+8*i); 36143442Sobrien } 37143442Sobrien } 38143442Sobrien 39143442Sobrien printf("\tli %%r11,%d\n", code); 40143442Sobrien printf("\thc\n"); 41143442Sobrien printf("\textsw %%r3,%%r3\n"); 42143442Sobrien 43143442Sobrien for (i = 0; i < outs; i++) { 44143442Sobrien printf("\tld %%r11,%d(%%r1)\n", 48+8*i); 45143442Sobrien printf("\tstd %%r%d,0(%%r11)\n", 4+i); 46143442Sobrien } 47143442Sobrien 48143442Sobrien printf("\tld %%r1,0(%%r1)\n"); 49143442Sobrien printf("\tld %%r0,16(%%r1)\n"); 50143442Sobrien printf("\tmtlr %%r0\n"); 51143442Sobrien printf("\tblr\n\n"); 52143442Sobrien} 53143442Sobrien