]>
Commit | Line | Data |
---|---|---|
a8c791c1 AP |
1 | ;------------------------------------------------------------------------------\r |
2 | ; @file\r | |
3 | ; An entry point use by Xen when a guest is started in PVH mode.\r | |
4 | ;\r | |
5 | ; Copyright (c) 2019, Citrix Systems, Inc.\r | |
6 | ;\r | |
7 | ; SPDX-License-Identifier: BSD-2-Clause-Patent\r | |
8 | ;\r | |
9 | ;------------------------------------------------------------------------------\r | |
10 | \r | |
11 | BITS 32\r | |
12 | \r | |
13 | xenPVHMain:\r | |
14 | ;\r | |
15 | ; 'BP' to indicate boot-strap processor\r | |
16 | ;\r | |
17 | mov di, 'BP'\r | |
18 | \r | |
93314ae5 AP |
19 | ;\r |
20 | ; Store "Start of day" struct pointer for later use\r | |
21 | ;\r | |
22 | mov dword[PVH_SPACE (0)], ebx\r | |
23 | mov dword[PVH_SPACE (4)], 'XPVH'\r | |
24 | \r | |
f198e254 AP |
25 | ;\r |
26 | ; calculate delta between build-addr and run position\r | |
27 | ;\r | |
28 | mov esp, PVH_SPACE(16) ; create a temporary stack\r | |
29 | call .delta\r | |
30 | .delta:\r | |
31 | pop edx ; get addr of .delta\r | |
32 | sub edx, ADDR_OF(.delta) ; calculate delta\r | |
33 | \r | |
34 | ;\r | |
35 | ; Find address of GDT and gdtr and fix the later\r | |
36 | ;\r | |
a8c791c1 | 37 | mov ebx, ADDR_OF(gdtr)\r |
f198e254 AP |
38 | add ebx, edx ; add delta gdtr\r |
39 | mov eax, ADDR_OF(GDT_BASE)\r | |
40 | add eax, edx ; add delta to GDT_BASE\r | |
41 | mov dword[ebx + 2], eax ; fix GDT_BASE addr in gdtr\r | |
a8c791c1 AP |
42 | lgdt [ebx]\r |
43 | \r | |
44 | mov eax, SEC_DEFAULT_CR0\r | |
45 | mov cr0, eax\r | |
46 | \r | |
f198e254 AP |
47 | ;\r |
48 | ; push return addr to the stack, then return far\r | |
49 | ;\r | |
50 | push dword LINEAR_CODE_SEL ; segment to select\r | |
51 | mov eax, ADDR_OF(.jmpToNewCodeSeg) ; return addr\r | |
52 | add eax, edx ; add delta to return addr\r | |
53 | push eax\r | |
54 | retf\r | |
a8c791c1 AP |
55 | .jmpToNewCodeSeg:\r |
56 | \r | |
57 | mov eax, SEC_DEFAULT_CR4\r | |
58 | mov cr4, eax\r | |
59 | \r | |
60 | mov ax, LINEAR_SEL\r | |
61 | mov ds, ax\r | |
62 | mov es, ax\r | |
63 | mov fs, ax\r | |
64 | mov gs, ax\r | |
65 | mov ss, ax\r | |
66 | \r | |
f198e254 AP |
67 | ;\r |
68 | ; ESP will be used as initial value of the EAX register\r | |
69 | ; in Main.asm\r | |
70 | ;\r | |
71 | xor esp, esp\r | |
72 | \r | |
73 | ;\r | |
74 | ; parameter for Flat32SearchForBfvBase\r | |
75 | ;\r | |
29280c70 | 76 | mov eax, 0 ; ADDR_OF(fourGigabytes)\r |
f198e254 AP |
77 | add eax, edx ; add delta\r |
78 | \r | |
a8c791c1 AP |
79 | ;\r |
80 | ; Jump to the main routine of the pre-SEC code\r | |
81 | ; skiping the 16-bit part of the routine and\r | |
82 | ; into the 32-bit flat mode part\r | |
83 | ;\r | |
84 | OneTimeCallRet TransitionFromReal16To32BitFlat\r |