Dan Skorupski <dan.skorupski@gmail.com>
Matt Gray <matthew.thomas.gray@gmail.com>
Ian Eyberg <ian@deferpanic.com>
+Francesco Lattanzio <franz.lattanzio@gmail.com>
/* clear console */
pushl %eax
- movw $0x20, %ax
+ movw $' ', %ax
movl $(CONS_ADDRESS), %edi
movl $(CONS_WIDTH*CONS_HEIGHT), %ecx
rep stosw
/* 1: enable pae and sse */
movl %cr4, %eax
- orl $0x620, %eax
+ orl $(CR4_OSXMMEXCPT|CR4_OSFXSR|CR4_PAE), %eax
movl %eax, %cr4
/* 2: enable long mode */
- movl $0xc0000080, %ecx
+ movl $MSR_EFER, %ecx
rdmsr
- movl $0x100, %eax
+ movl $MSR_EFER_LME, %eax
wrmsr
/* 3: load pml4 pointer */
/* 4: enable paging */
movl %cr0, %eax
- orl $0x80010001, %eax
+ orl $(CR0_PG|CR0_WP|CR0_PE), %eax
movl %eax, %cr0
/* 5: poetically longjump to longmode */
/* clear console */
pushl %eax
- movw $0x20, %ax
+ movw $' ', %ax
movl $(CONS_ADDRESS), %edi
movl $(CONS_WIDTH*CONS_HEIGHT), %ecx
rep stosw
cmpl $MULTIBOOT_BOOTLOADER_MAGIC, %eax
jne nomultiboot
+ /* test the sse feature flag */
+ movl $CPUID_01H_LEAF, %eax
+ cpuid
+ test $CPUID_01H_EDX_SSE, %edx
+ jz no_sse
+
+ /* enable sse */
+ movl %cr4, %eax
+ orl $(CR4_OSXMMEXCPT|CR4_OSFXSR), %eax
+ movl %eax, %cr4
+
+no_sse:
call x86_boot
jmp haltme
movsbl (%ebx), %eax
test %al, %al
je haltme
+
orl $0x500, %eax
movl %eax, (%ecx)
inc %ebx
+#define CPUID_01H_LEAF 0x01
+
+#define CPUID_01H_EDX_SSE 0x02000000 /* SSE Extensions */
+
+#define CR0_PG 0x80000000 /* Paging */
+#define CR0_WP 0x00010000 /* Write Protect */
+#define CR0_PE 0x00000001 /* Protection Enable */
+
+#define CR4_OSXMMEXCPT 0x00000400 /* OS support for unmasked SIMD FP exceptions */
+#define CR4_OSFXSR 0x00000200 /* OS support for FXSAVE & FXRSTOR */
+#define CR4_PAE 0x00000020 /* Physical Address Extension */
+
+/* Extended Feature Enable Register */
+#define MSR_EFER 0xc0000080
+
+#define MSR_EFER_LME 0x00000100 /* Long Mode Enable */
+
#define PIC1_CMD 0x20
#define PIC1_DATA 0x21
#define PIC2_CMD 0xa0