sl@0: // Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of the License "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // e32\nkernsmp\x86\nccpu.cia sl@0: // sl@0: // sl@0: sl@0: #include sl@0: #include sl@0: sl@0: __NAKED__ void cmos_write(TUint32 val, TUint32 addr) sl@0: { sl@0: asm("mov eax, [esp+8]"); sl@0: asm("out 0x70, al"); sl@0: asm("mov eax, [esp+4]"); sl@0: asm("out 0x71, al"); sl@0: asm("ret"); sl@0: } sl@0: sl@0: __NAKED__ void SetupApInitInfo(volatile SApInitInfo&) sl@0: { sl@0: asm("mov ecx, [esp+4]"); sl@0: asm("sgdt [ecx+%0]": :"i"_FOFF(SApInitInfo, iGdtr)); sl@0: asm("sidt [ecx+%0]": :"i"_FOFF(SApInitInfo, iIdtr)); sl@0: asm("mov eax, cr0"); sl@0: asm("mov [ecx+%0], eax": :"i"_FOFF(SApInitInfo, iCr0)); sl@0: asm("mov eax, cr3"); sl@0: asm("mov [ecx+%0], eax": :"i"_FOFF(SApInitInfo, iCr3)); sl@0: MOV_EAX_CR4; sl@0: asm("mov [ecx+%0], eax": :"i"_FOFF(SApInitInfo, iCr4)); sl@0: asm("ret"); sl@0: } sl@0: sl@0: __NAKED__ void _ApMain() sl@0: { sl@0: asm("mov eax, %0" : : "i" (RING0_DS)); sl@0: asm("mov ss, ax "); sl@0: asm("mov ds, ax "); sl@0: asm("mov es, ax "); sl@0: asm("mov fs, ax "); sl@0: asm("mov gs, ax "); sl@0: asm("lgdt [edi+%0]" : : "i" _FOFF(SApInitInfo, iGdtr)); sl@0: asm("lidt [edi+%0]" : : "i" _FOFF(SApInitInfo, iIdtr)); sl@0: asm("mov esp, [edi+%0]" : : "i" _FOFF(SApInitInfo, iRgs.iEsp)); sl@0: asm("mov eax, [edi+%0]" : : "i" _FOFF(SApInitInfo, iBootFlag)); sl@0: asm("lock dec dword ptr [edi+%0]" : : "i" _FOFF(SApInitInfo, iBootFlag)); sl@0: asm("sub eax, 2 "); sl@0: asm("wait_for_bp: "); sl@0: asm("cmp eax, [edi+%0]" : : "i" _FOFF(SApInitInfo, iBootFlag)); sl@0: X86_PAUSE sl@0: asm("jne wait_for_bp "); sl@0: sl@0: asm("mov eax, cr0 "); sl@0: asm("and al, 0xf7 "); // enable access to FPU sl@0: asm("mov cr0, eax "); sl@0: asm("fninit "); // initialise coprocessor sl@0: asm("fwait "); sl@0: asm("or al, 8 "); sl@0: asm("mov cr0, eax "); // disable access to coprocessor sl@0: sl@0: asm("mov ecx, [edi+%0]" : : "i" _FOFF(SApInitInfo, iExtra)); sl@0: asm("mov eax, [ecx+%0]" : : "i" _FOFF(SAPBootInfo, iMain)); sl@0: asm("push ecx "); sl@0: asm("call eax "); sl@0: asm("add esp, 4 "); sl@0: asm("spin: "); sl@0: asm("hlt "); sl@0: asm("jmp spin "); sl@0: }