]>
Commit | Line | Data |
---|---|---|
768e2a90 | 1 | #------------------------------------------------------------------------------\r |
2 | # IA32 assembly file for AP startup vector.\r | |
3 | #\r | |
4 | # Copyright (c) 2009, Intel Corporation\r | |
5 | # All rights reserved. This program and the accompanying materials\r | |
6 | # are licensed and made available under the terms and conditions of the BSD License\r | |
7 | # which accompanies this distribution. The full text of the license may be found at\r | |
8 | # http://opensource.org/licenses/bsd-license.php\r | |
9 | #\r | |
10 | # THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
11 | # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
12 | #\r | |
13 | #------------------------------------------------------------------------------\r | |
14 | \r | |
15 | .equ VacantFlag, 0x0\r | |
16 | .equ NotVacantFlag, 0xff\r | |
17 | \r | |
18 | .equ LockLocation, RendezvousFunnelProcEnd - RendezvousFunnelProcStart\r | |
19 | .equ StackStart, LockLocation + 0x04\r | |
20 | .equ StackSize, LockLocation + 0x08\r | |
21 | .equ RendezvousProc, LockLocation + 0x0C\r | |
22 | .equ GdtrProfile, LockLocation + 0x10\r | |
23 | .equ BufferStart, LockLocation + 0x18\r | |
24 | \r | |
25 | #-------------------------------------------------------------------------------------\r | |
26 | #RendezvousFunnelProc procedure follows. All APs execute their procedure. This\r | |
27 | #procedure serializes all the AP processors through an Init sequence. It must be\r | |
28 | #noted that APs arrive here very raw...ie: real mode, no stack.\r | |
29 | #ALSO THIS PROCEDURE IS EXECUTED BY APs ONLY ON 16 BIT MODE. HENCE THIS PROC\r | |
30 | #IS IN MACHINE CODE.\r | |
31 | #-------------------------------------------------------------------------------------\r | |
32 | #RendezvousFunnelProc (&WakeUpBuffer,MemAddress);\r | |
33 | \r | |
34 | ASM_GLOBAL ASM_PFX(RendezvousFunnelProc)\r | |
35 | ASM_PFX(RendezvousFunnelProc):\r | |
36 | RendezvousFunnelProcStart:\r | |
37 | \r | |
38 | \r | |
39 | # At this point CS = 0x(vv00) and ip= 0x0.\r | |
40 | \r | |
41 | .byte 0x8c,0xc8 # mov ax, cs\r | |
42 | .byte 0x8e,0xd8 # mov ds, ax\r | |
43 | .byte 0x8e,0xc0 # mov es, ax\r | |
44 | .byte 0x8e,0xd0 # mov ss, ax \r | |
45 | .byte 0x33,0xc0 # xor ax, ax\r | |
46 | .byte 0x8e,0xe0 # mov fs, ax\r | |
47 | .byte 0x8e,0xe8 # mov gs, ax\r | |
48 | \r | |
49 | # Switch to flat mode.\r | |
50 | \r | |
51 | .byte 0xBE\r | |
52 | .word BufferStart\r | |
53 | .byte 0x66,0x8B,0xC # mov ecx,dword ptr [si] ; ECX is keeping the start address of wakeup buffer\r | |
54 | \r | |
55 | .byte 0xFA # cli\r | |
56 | .byte 0xBE\r | |
57 | .word GdtrProfile\r | |
58 | .byte 0x66 # db 66h\r | |
59 | .byte 0x2E,0xF,0x1,0x14 # lgdt fword ptr cs:[si]\r | |
60 | \r | |
61 | .byte 0x33,0xC0 # xor ax, ax\r | |
62 | .byte 0x8E,0xD8 # mov ds, ax\r | |
63 | .byte 0xF,0x20,0xC0 # mov eax, cr0 ; Get control register 0\r | |
64 | .byte 0x66,0x83,0xC8,0x1 # or eax, 000000001h ; Set PE bit (bit #0)\r | |
65 | .byte 0xF,0x22,0xC0 # mov cr0, eax\r | |
66 | \r | |
67 | \r | |
68 | #step-4:\r | |
69 | \r | |
70 | FLAT32_JUMP:\r | |
71 | .byte 0x66\r | |
72 | .byte 0x67\r | |
73 | .byte 0xEA # far jump\r | |
74 | .long 0x0\r | |
75 | .word 0x10\r | |
76 | \r | |
77 | ProtectedModeStart: # protected mode entry point\r | |
78 | \r | |
79 | movw $0x8,%ax\r | |
80 | .byte 0x66\r | |
81 | movw %ax,%ds\r | |
82 | .byte 0x66\r | |
83 | movw %ax,%es\r | |
84 | .byte 0x66\r | |
85 | movw %ax,%fs\r | |
86 | .byte 0x66\r | |
87 | movw %ax,%gs\r | |
88 | .byte 0x66\r | |
89 | movw %ax,%ss # Flat mode setup.\r | |
90 | \r | |
91 | \r | |
92 | movl %esi,%edi\r | |
93 | addl $LockLocation, %edi\r | |
94 | movb $NotVacantFlag, %al\r | |
95 | TestLock:\r | |
96 | xchgb (%edi), %al\r | |
97 | cmpb $NotVacantFlag, %al\r | |
98 | jz TestLock\r | |
99 | \r | |
100 | ProgramStack:\r | |
101 | movl %esi,%edi\r | |
102 | addl $StackSize, %edi\r | |
103 | movl (%edi), %eax\r | |
104 | movl %esi,%edi\r | |
105 | addl $StackStart, %edi\r | |
106 | addl (%edi), %eax\r | |
107 | movl %eax,%esp\r | |
108 | movl %eax, (%edi)\r | |
109 | \r | |
110 | Releaselock:\r | |
111 | movb $VacantFlag, %al\r | |
112 | movl %esi,%edi\r | |
113 | addl $LockLocation, %edi\r | |
114 | xchgb (%edi), %al\r | |
115 | \r | |
116 | #\r | |
117 | # Call C Function\r | |
118 | #\r | |
119 | movl %esi,%edi\r | |
120 | addl $RendezvousProc, %edi\r | |
121 | movl (%edi), %ebx\r | |
122 | \r | |
123 | testl %ebx,%ebx\r | |
124 | jz GoToSleep\r | |
125 | call *%ebx # Call C function\r | |
126 | \r | |
127 | #Step-6: Sleep\r | |
128 | \r | |
129 | GoToSleep:\r | |
130 | \r | |
131 | cli\r | |
132 | hlt\r | |
133 | jmp GoToSleep\r | |
134 | \r | |
135 | RendezvousFunnelProcEnd:\r | |
136 | #-------------------------------------------------------------------------------------\r | |
137 | # AsmGetAddressMap (&AddressMap);\r | |
138 | #-------------------------------------------------------------------------------------\r | |
139 | ASM_GLOBAL ASM_PFX(AsmGetAddressMap)\r | |
140 | ASM_PFX(AsmGetAddressMap):\r | |
141 | \r | |
142 | pushal\r | |
143 | movl %esp,%ebp\r | |
144 | \r | |
145 | movl 0x24(%ebp), %ebx\r | |
146 | movl $RendezvousFunnelProcStart, (%ebx)\r | |
147 | movl $(ProtectedModeStart - RendezvousFunnelProcStart), 0x4(%ebx)\r | |
148 | movl $(FLAT32_JUMP - RendezvousFunnelProcStart), 0x8(%ebx)\r | |
149 | movl $0, 0x0c(%ebx)\r | |
150 | movl $0, 0x10(%ebx)\r | |
151 | movl $(RendezvousFunnelProcEnd - RendezvousFunnelProcStart), 0x14(%ebx)\r | |
152 | \r | |
153 | popal\r | |
154 | ret\r |