]> rtime.felk.cvut.cz Git - jailhouse.git/blob - inmates/lib/x86/header-32.S
inmates: x86: align code after 32-bit page table
[jailhouse.git] / inmates / lib / x86 / header-32.S
1 /*
2  * Jailhouse, a Linux-based partitioning hypervisor
3  *
4  * Copyright (c) Siemens AG, 2014
5  *
6  * Authors:
7  *  Jan Kiszka <jan.kiszka@siemens.com>
8  *
9  * This work is licensed under the terms of the GNU GPL, version 2.  See
10  * the COPYING file in the top-level directory.
11  */
12
13 #include <inmate.h>
14
15 #define X86_CR0_PE      0x00000001
16 #define X86_CR0_WP      0x00010000
17 #define X86_CR0_PG      0x80000000
18
19 #define X86_CR4_PSE     0x00000010
20
21         .code16
22         .section ".boot", "ax"
23
24         ljmp $0xf000,$start16
25
26
27         .section ".startup", "ax"
28
29 start16:
30         lgdtl %cs:gdt_ptr
31
32         mov %cr0,%eax
33         or $X86_CR0_PE,%al
34         mov %eax,%cr0
35
36         ljmpl $INMATE_CS32,$start32 + FSEGMENT_BASE
37
38
39         .code32
40 start32:
41         mov %cr4,%eax
42         or $X86_CR4_PSE,%eax
43         mov %eax,%cr4
44
45         mov $loader_pdpt + FSEGMENT_BASE,%eax
46         mov %eax,%cr3
47
48         mov $(X86_CR0_PG | X86_CR0_WP | X86_CR0_PE),%eax
49         mov %eax,%cr0
50
51         mov $stack_top,%esp
52
53         mov $INMATE_DS32,%eax
54         mov %eax,%ds
55         mov %eax,%es
56         mov %eax,%ss
57
58         xor %eax,%eax
59         mov $bss_start,%edi
60         mov $bss_dwords,%ecx
61         rep stosl
62
63         mov $inmate_main,%eax
64         call *%eax
65
66 stop:   cli
67         hlt
68         jmp stop
69
70
71         .align(16)
72         .global loader_gdt
73 loader_gdt:
74         .quad   0
75         .quad   0x00cf9b000000ffff
76         .quad   0x00af9b000000ffff
77         .quad   0x00cf93000000ffff
78
79 gdt_ptr:
80         .short  gdt_ptr - loader_gdt - 1
81         .long   loader_gdt + FSEGMENT_BASE
82
83         .align(4096)
84         .global loader_pdpt
85 loader_pdpt:
86         .long   0x00000083
87         .align(4096)