ps3-hv-asm.awk 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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. # $FreeBSD$
  9. BEGIN {
  10. printf("/* $FreeBSD$ */\n\n");
  11. printf("#include <machine/asm.h>\n\n");
  12. printf("#define hc .long 0x44000022\n\n");
  13. }
  14. /HVCALL.*/ {
  15. code = $2;
  16. ins = split($4, a, ",")
  17. outs = split($5, a, ",")
  18. printf("ASENTRY(%s)\n",$3);
  19. printf("\tmflr %%r0\n");
  20. printf("\tstd %%r0,16(%%r1)\n");
  21. printf("\tstdu %%r1,-%d(%%r1)\n", 48+8*outs);
  22. if ($4 == "UNUSED")
  23. ins = 0
  24. # Save output reg addresses to the stack
  25. for (i = 0; i < outs; i++) {
  26. if (ins+i >= 8) {
  27. printf("\tld %%r11,%d(%%r1)\n", 48+8*outs + 48 + 8*(i+ins));
  28. printf("\tstd %%r11,%d(%%r1)\n", 48+8*i);
  29. } else {
  30. printf("\tstd %%r%d,%d(%%r1)\n", 3+ins+i, 48+8*i);
  31. }
  32. }
  33. printf("\tli %%r11,%d\n", code);
  34. printf("\thc\n");
  35. printf("\textsw %%r3,%%r3\n");
  36. for (i = 0; i < outs; i++) {
  37. printf("\tld %%r11,%d(%%r1)\n", 48+8*i);
  38. printf("\tstd %%r%d,0(%%r11)\n", 4+i);
  39. }
  40. printf("\tld %%r1,0(%%r1)\n");
  41. printf("\tld %%r0,16(%%r1)\n");
  42. printf("\tmtlr %%r0\n");
  43. printf("\tblr\n\n");
  44. }