summaryrefslogtreecommitdiff
path: root/stage3/init.c
blob: 2e26e196f4244b00caf49aee55dc4c138688bc31 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#include "def.h"
void kmain();

void init()
{
	// enable SSE. long mode demands it is present
	u64 cr0;
	asm volatile("mov %%cr0, %0 \n":"=r"(cr0));
	asm volatile("mov %0, %%cr0"::"r"((cr0 & ~(1 << 2)) | (1 << 1)));

	u64 cr4;
	asm volatile("mov %%cr4, %0":"=r"(cr4));
	asm volatile("mov %0, %%cr4"::"r"(cr4 | (1 << 9) | (1 << 10)));

	u16 fpu_cw = 0x37a;
	asm volatile("fldcw %0"::"m"(fpu_cw));
	kmain();
}