|
1 // Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of the License "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // e32\nkernsmp\x86\nccpu.cia |
|
15 // |
|
16 // |
|
17 |
|
18 #include <x86.h> |
|
19 #include <apic.h> |
|
20 |
|
21 __NAKED__ void cmos_write(TUint32 val, TUint32 addr) |
|
22 { |
|
23 asm("mov eax, [esp+8]"); |
|
24 asm("out 0x70, al"); |
|
25 asm("mov eax, [esp+4]"); |
|
26 asm("out 0x71, al"); |
|
27 asm("ret"); |
|
28 } |
|
29 |
|
30 __NAKED__ void SetupApInitInfo(volatile SApInitInfo&) |
|
31 { |
|
32 asm("mov ecx, [esp+4]"); |
|
33 asm("sgdt [ecx+%0]": :"i"_FOFF(SApInitInfo, iGdtr)); |
|
34 asm("sidt [ecx+%0]": :"i"_FOFF(SApInitInfo, iIdtr)); |
|
35 asm("mov eax, cr0"); |
|
36 asm("mov [ecx+%0], eax": :"i"_FOFF(SApInitInfo, iCr0)); |
|
37 asm("mov eax, cr3"); |
|
38 asm("mov [ecx+%0], eax": :"i"_FOFF(SApInitInfo, iCr3)); |
|
39 MOV_EAX_CR4; |
|
40 asm("mov [ecx+%0], eax": :"i"_FOFF(SApInitInfo, iCr4)); |
|
41 asm("ret"); |
|
42 } |
|
43 |
|
44 __NAKED__ void _ApMain() |
|
45 { |
|
46 asm("mov eax, %0" : : "i" (RING0_DS)); |
|
47 asm("mov ss, ax "); |
|
48 asm("mov ds, ax "); |
|
49 asm("mov es, ax "); |
|
50 asm("mov fs, ax "); |
|
51 asm("mov gs, ax "); |
|
52 asm("lgdt [edi+%0]" : : "i" _FOFF(SApInitInfo, iGdtr)); |
|
53 asm("lidt [edi+%0]" : : "i" _FOFF(SApInitInfo, iIdtr)); |
|
54 asm("mov esp, [edi+%0]" : : "i" _FOFF(SApInitInfo, iRgs.iEsp)); |
|
55 asm("mov eax, [edi+%0]" : : "i" _FOFF(SApInitInfo, iBootFlag)); |
|
56 asm("lock dec dword ptr [edi+%0]" : : "i" _FOFF(SApInitInfo, iBootFlag)); |
|
57 asm("sub eax, 2 "); |
|
58 asm("wait_for_bp: "); |
|
59 asm("cmp eax, [edi+%0]" : : "i" _FOFF(SApInitInfo, iBootFlag)); |
|
60 X86_PAUSE |
|
61 asm("jne wait_for_bp "); |
|
62 |
|
63 asm("mov eax, cr0 "); |
|
64 asm("and al, 0xf7 "); // enable access to FPU |
|
65 asm("mov cr0, eax "); |
|
66 asm("fninit "); // initialise coprocessor |
|
67 asm("fwait "); |
|
68 asm("or al, 8 "); |
|
69 asm("mov cr0, eax "); // disable access to coprocessor |
|
70 |
|
71 asm("mov ecx, [edi+%0]" : : "i" _FOFF(SApInitInfo, iExtra)); |
|
72 asm("mov eax, [ecx+%0]" : : "i" _FOFF(SAPBootInfo, iMain)); |
|
73 asm("push ecx "); |
|
74 asm("call eax "); |
|
75 asm("add esp, 4 "); |
|
76 asm("spin: "); |
|
77 asm("hlt "); |
|
78 asm("jmp spin "); |
|
79 } |