AMD64.EFIMachine.Mod 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. MODULE EFIMachine; (** AUTHOR ""; PURPOSE ""; *)
  2. IMPORT SYSTEM, EFI;
  3. VAR p0, p1: ADDRESS;
  4. (* I386.Machine.Mod uses following registers as arguments:
  5. eax : bootFlag (= address of boot table)
  6. esi : ?
  7. edi : address of frame buffer
  8. *)
  9. PROCEDURE JumpTo*(adr : ADDRESS; rax, rsi, rdi, rcx, rdx: HUGEINT);
  10. CODE {SYSTEM.AMD64, SYSTEM.Privileged}
  11. MOV RDI, [RBP+rdi]; fbAddr
  12. MOV RSI, [RBP+rsi]; kernelSize
  13. MOV RAX, [RBP+rax]; btAddr
  14. MOV RCX, [RBP+rcx];
  15. MOV RDX, [RBP+rdx];
  16. MOV RBX, [RBP+adr]
  17. CALL RBX
  18. END JumpTo;
  19. (*
  20. MOV R15, [RBP+fbAddr]; fbAddr
  21. MOV R14, [RBP+kernelSize]; kernelSize
  22. MOV R13, [RBP+btAddr]; btAddr
  23. MOV R12, [RBP+kernelAddr]; kernelAddr
  24. NT: CALL NZ
  25. NZ: POP RCX
  26. MOV RDI, 0
  27. MOV RSI, RCX
  28. MOV RCX, 512
  29. CLD
  30. REP MOVSQ
  31. MOV RCX, 0
  32. ADD RCX, NX-NZ
  33. JMP RCX
  34. NX:
  35. MOV RCX, R14
  36. MOV RDI, 1000H
  37. MOV RSI, R12
  38. CLD
  39. REP MOVSB
  40. XOR RCX,RCX
  41. XOR RDX,RDX
  42. MOV RDI, R15;
  43. MOV RSI, R14;
  44. MOV RAX, R13;
  45. MOV RBX, 1000H;
  46. CALL RBX
  47. END JumpTo;
  48. *)
  49. PROCEDURE {NOPAF, FIXED(401000H)} EntryPoint;
  50. CODE {SYSTEM.AMD64}
  51. MOV QWORD EFI.imageHandle, RCX;
  52. MOV QWORD EFI.table, RDX
  53. END EntryPoint;
  54. END EFIMachine.