Advertisement
Guest User

Trampoline.asm

a guest
Dec 12th, 2015
206
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.03 KB | None | 0 0
  1. ;==============================================================================
  2. ;= Digos Operating v 0.0.1 =
  3. ;= =
  4. ;= Startup code for AP´s =
  5. ;= =
  6. ;= by Rodrigo Fagner =
  7. ;= =
  8. ;= Sao Jose do Rio Preto - SP 10/10/2015 08:39 =
  9. ;==============================================================================
  10.  
  11. SECTION .text
  12. BITS 16
  13.  
  14. _entry:
  15.  
  16. JMP ap_boot
  17. ALIGN 4
  18. GDTPointer dd 0xA1A2A3A4 ; + 1
  19. IDTPointer dd 0x02020202 ; + 2
  20. StackPointer dd 0x03030303 ; + 3
  21. StackTest dd 0xBA000001 ; + 4
  22. APCPUBooted dd 0xBABBBCBD ; + 5
  23.  
  24. ALIGN 4
  25. ap_boot:
  26. cli
  27. cld
  28.  
  29. mov ax, cs
  30. mov ds, ax
  31. mov es, ax
  32. mov fs, ax
  33. mov gs, ax
  34. mov ss, ax
  35.  
  36. mov EAX, StackTest
  37. mov EBX, [EAX]
  38. mov ESP, EBX
  39.  
  40. MOV EAX, APCPUBooted
  41. MOV [EAX], DWORD 0xA1B2C3D4
  42.  
  43. mov EAX, GDTPointer ; Loaded from smp.c
  44. lgdt [EAX] ; load GDT into GDTR
  45.  
  46. mov EAX, IDTPointer ; Loaded from smp.c
  47. lidt [EAX] ; load IDT into IDTR
  48.  
  49. ;===============================
  50. ;= Enable PMODE =
  51. ;===============================
  52.  
  53. mov eax, cr0 ; set bit 0 in CR0-go to pmode
  54. or eax, 1
  55. mov cr0, eax
  56.  
  57. ; Just small delay...
  58. nop
  59. nop
  60. nop
  61. nop
  62. nop
  63. nop
  64. nop
  65.  
  66. ;===============================
  67. ;= Jump Far =
  68. ;===============================
  69.  
  70. jmp 0x08:.Stage3
  71.  
  72. BITS 32
  73.  
  74. .Stage3:
  75. CLI
  76. CLD
  77.  
  78. ;===============================
  79. ;= Set registers =
  80. ;===============================
  81.  
  82. mov ax, 0x10
  83. mov ds, ax
  84. mov es, ax
  85. mov fs, ax
  86. mov gs, ax
  87. mov ss, ax
  88.  
  89. mov eax, StackPointer
  90. call [eax]
  91.  
  92. .halt: ; Just to make shure in some case...
  93.  
  94. jmp .halt
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement