+++ /dev/null
-#------------------------------------------------------------------------------\r
-# IA32 assembly file for AP startup vector.\r
-#\r
-# Copyright (c) 2009 - 2012, Intel Corporation. All rights reserved.<BR>\r
-# This program and the accompanying materials\r
-# are licensed and made available under the terms and conditions of the BSD License\r
-# which accompanies this distribution. The full text of the license may be found at\r
-# http://opensource.org/licenses/bsd-license.php\r
-#\r
-# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-#\r
-#------------------------------------------------------------------------------\r
-\r
-#define VacantFlag 0x0\r
-#define NotVacantFlag 0xff\r
-\r
-#define LockLocation RendezvousFunnelProcEnd - RendezvousFunnelProcStart\r
-#define StackStart RendezvousFunnelProcEnd - RendezvousFunnelProcStart + 0x04\r
-#define StackSize RendezvousFunnelProcEnd - RendezvousFunnelProcStart + 0x08\r
-#define RendezvousProc RendezvousFunnelProcEnd - RendezvousFunnelProcStart + 0x0C\r
-#define GdtrProfile RendezvousFunnelProcEnd - RendezvousFunnelProcStart + 0x10\r
-#define IdtrProfile RendezvousFunnelProcEnd - RendezvousFunnelProcStart + 0x16\r
-#define BufferStart RendezvousFunnelProcEnd - RendezvousFunnelProcStart + 0x1C\r
-#define ProcessorNumber RendezvousFunnelProcEnd - RendezvousFunnelProcStart + 0x20\r
-\r
-#-------------------------------------------------------------------------------------\r
-#RendezvousFunnelProc procedure follows. All APs execute their procedure. This\r
-#procedure serializes all the AP processors through an Init sequence. It must be\r
-#noted that APs arrive here very raw...ie: real mode, no stack.\r
-#ALSO THIS PROCEDURE IS EXECUTED BY APs ONLY ON 16 BIT MODE. HENCE THIS PROC\r
-#IS IN MACHINE CODE.\r
-#-------------------------------------------------------------------------------------\r
-#RendezvousFunnelProc (&WakeUpBuffer,MemAddress);\r
-\r
-ASM_GLOBAL ASM_PFX(RendezvousFunnelProc)\r
-ASM_PFX(RendezvousFunnelProc):\r
-RendezvousFunnelProcStart:\r
-\r
-\r
-# At this point CS = 0x(vv00) and ip= 0x0.\r
-\r
- .byte 0x8c,0xc8 # mov ax, cs\r
- .byte 0x8e,0xd8 # mov ds, ax\r
- .byte 0x8e,0xc0 # mov es, ax\r
- .byte 0x8e,0xd0 # mov ss, ax \r
- .byte 0x33,0xc0 # xor ax, ax\r
- .byte 0x8e,0xe0 # mov fs, ax\r
- .byte 0x8e,0xe8 # mov gs, ax\r
-\r
-# Switch to flat mode.\r
-\r
- .byte 0xBE\r
- .word BufferStart\r
- .byte 0x66,0x8B,0xC # mov ecx,dword ptr [si] ; ECX is keeping the start address of wakeup buffer\r
-\r
- .byte 0xFA # cli\r
- .byte 0xBE\r
- .word GdtrProfile\r
- .byte 0x66 # db 66h\r
- .byte 0x2E,0xF,0x1,0x14 # lgdt fword ptr cs:[si]\r
-\r
- .byte 0xBE\r
- .word IdtrProfile\r
- .byte 0x66 # db 66h\r
- .byte 0x2E,0xF,0x1,0x1C # lidt fword ptr cs:[si]\r
-\r
- .byte 0x33,0xC0 # xor ax, ax\r
- .byte 0x8E,0xD8 # mov ds, ax\r
- .byte 0xF,0x20,0xC0 # mov eax, cr0 ; Get control register 0\r
- .byte 0x66,0x83,0xC8,0x1 # or eax, 000000001h ; Set PE bit (bit #0)\r
- .byte 0xF,0x22,0xC0 # mov cr0, eax\r
-\r
-\r
-#step-4:\r
-\r
-FLAT32_JUMP:\r
- .byte 0x66\r
- .byte 0x67\r
- .byte 0xEA # far jump\r
- .long 0x0\r
- .word 0x10\r
-\r
-ProtectedModeStart: # protected mode entry point\r
-\r
- movw $0x8,%ax\r
- .byte 0x66\r
- movw %ax,%ds\r
- .byte 0x66\r
- movw %ax,%es\r
- .byte 0x66\r
- movw %ax,%fs\r
- .byte 0x66\r
- movw %ax,%gs\r
- .byte 0x66\r
- movw %ax,%ss # Flat mode setup.\r
-\r
- #\r
- # ProgramStack\r
- #\r
- movl $0x1b, %ecx\r
- rdmsr\r
-\r
- btl $10, %eax # Check for x2apic mode\r
- jnc LegacyApicMode\r
- movl $0x802, %ecx # Read APIC_ID\r
- rdmsr\r
- movl %eax, %ebx # ebx == apicid\r
- jmp GetCpuNumber\r
-\r
-LegacyApicMode:\r
- andl $0xfffff000, %eax\r
- addl $0x20, %eax\r
- movl (%eax), %ebx\r
- shrl $24, %ebx # ebx == apicid\r
-\r
-GetCpuNumber: \r
- xorl %ecx, %ecx\r
- movl %esi,%edi\r
- addl $ProcessorNumber, %edi\r
- movl (%edi, %ebx, 4), %ecx\r
-\r
- movl %esi,%edi\r
- addl $StackSize, %edi\r
- movl (%edi), %eax\r
- incl %ecx\r
- mull %ecx\r
-\r
- movl %esi,%edi\r
- addl $StackStart, %edi\r
- movl (%edi), %ebx\r
- addl %ebx, %eax\r
-\r
- movl %eax, %esp\r
-\r
- #\r
- # Call C Function\r
- #\r
- movl %esi,%edi\r
- addl $RendezvousProc, %edi\r
- movl (%edi), %ebx\r
-\r
- testl %ebx,%ebx\r
- jz GoToSleep\r
- call *%ebx # Call C function\r
-\r
-#Step-6: Sleep\r
-\r
-GoToSleep:\r
-\r
- cli\r
- hlt\r
- jmp GoToSleep\r
-\r
-RendezvousFunnelProcEnd:\r
-#-------------------------------------------------------------------------------------\r
-# AsmGetAddressMap (&AddressMap);\r
-#-------------------------------------------------------------------------------------\r
-ASM_GLOBAL ASM_PFX(AsmGetAddressMap)\r
-ASM_PFX(AsmGetAddressMap):\r
-\r
- pushal\r
- movl %esp,%ebp\r
-\r
- movl 0x24(%ebp), %ebx\r
- movl $RendezvousFunnelProcStart, (%ebx)\r
- movl $(ProtectedModeStart - RendezvousFunnelProcStart), 0x4(%ebx)\r
- movl $(FLAT32_JUMP - RendezvousFunnelProcStart), 0x8(%ebx)\r
- movl $0, 0x0c(%ebx)\r
- movl $0, 0x10(%ebx)\r
- movl $(RendezvousFunnelProcEnd - RendezvousFunnelProcStart), 0x14(%ebx)\r
-\r
- popal\r
- ret\r