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

void kmain(struct bootinfo *info);

void _start(struct bootinfo *info)
{
	// 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(info);
}