xref: /minix/minix/kernel/arch/i386/trampoline.S (revision 83133719)
1#include <machine/asm.h>
2#include <machine/vm.h>
3#include "archconst.h"
4
5.balign 4096
6.text
7.code16
8ENTRY(trampoline)
9	cli
10
11	/* %cs has some value and we must use the same for data */
12	mov	%cs, %ax
13	mov	%ax, %ds
14
15	/* load gdt and idt prepared by bsp */
16	lgdtl	_C_LABEL(__ap_gdt) - _C_LABEL(trampoline)
17	lidtl	_C_LABEL(__ap_idt) - _C_LABEL(trampoline)
18
19	/* switch to protected mode */
20	mov	%cr0, %eax
21	orb	$1, %al
22	mov	%eax, %cr0
23
24	/* set page table feature flags: cr4.PSE on, cr4.PGE off */
25	movl	%cr4, %eax
26	orl	$I386_CR4_PSE, %eax	/* Turn on PSE */
27	andl	$~I386_CR4_PGE, %eax	/* Turn off PGE */
28	movl	%eax, %cr4
29
30	/* load boot cr3 and turn PG on so CPU can see all of memory */
31	movl	_C_LABEL(__ap_pt) - _C_LABEL(trampoline), %eax
32	movl	%eax, %cr3
33	movl	%cr0, %ecx
34	orl	$I386_CR0_PG, %ecx
35	movl	%ecx, %cr0
36
37	/* turn on cr4.PGE after cr0.PG is on */
38	movl	%cr4, %eax
39	orl	$I386_CR4_PGE, %eax
40	movl	%eax, %cr4
41
42	/* jump into regular highly mapped kernel */
43	ljmpl	$KERN_CS_SELECTOR, $_C_LABEL(startup_ap_32)
44
45.balign 4
46LABEL(__ap_id)
47.space 4
48LABEL(__ap_pt)
49.space 4
50LABEL(__ap_gdt)
51.space 8
52LABEL(__ap_idt)
53.space 8
54LABEL(__ap_gdt_tab)
55.space GDT_SIZE*DESC_SIZE
56LABEL(__ap_idt_tab)
57.space IDT_SIZE*DESC_SIZE
58LABEL(__trampoline_end)
59