Skip to content

Commit c7f2f01

Browse files
authored
Merge pull request #92 from fltt/patches
Fix awk locale and enable SSE
2 parents e5207b2 + 3c157b5 commit c7f2f01

4 files changed

Lines changed: 37 additions & 6 deletions

File tree

AUTHORS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@ Sebastian Wicki <[email protected]>
1111
Dan Skorupski <[email protected]>
1212
Matt Gray <[email protected]>
1313
Ian Eyberg <[email protected]>
14+
Francesco Lattanzio <[email protected]>

platform/hw/arch/amd64/locore.S

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ ENTRY(_start)
7171

7272
/* clear console */
7373
pushl %eax
74-
movw $0x20, %ax
74+
movw $' ', %ax
7575
movl $(CONS_ADDRESS), %edi
7676
movl $(CONS_WIDTH*CONS_HEIGHT), %ecx
7777
rep stosw
@@ -102,13 +102,13 @@ ENTRY(_start)
102102

103103
/* 1: enable pae and sse */
104104
movl %cr4, %eax
105-
orl $0x620, %eax
105+
orl $(CR4_OSXMMEXCPT|CR4_OSFXSR|CR4_PAE), %eax
106106
movl %eax, %cr4
107107

108108
/* 2: enable long mode */
109-
movl $0xc0000080, %ecx
109+
movl $MSR_EFER, %ecx
110110
rdmsr
111-
movl $0x100, %eax
111+
movl $MSR_EFER_LME, %eax
112112
wrmsr
113113

114114
/* 3: load pml4 pointer */
@@ -117,7 +117,7 @@ ENTRY(_start)
117117

118118
/* 4: enable paging */
119119
movl %cr0, %eax
120-
orl $0x80010001, %eax
120+
orl $(CR0_PG|CR0_WP|CR0_PE), %eax
121121
movl %eax, %cr0
122122

123123
/* 5: poetically longjump to longmode */

platform/hw/arch/i386/locore.S

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ ENTRY(_start)
5252

5353
/* clear console */
5454
pushl %eax
55-
movw $0x20, %ax
55+
movw $' ', %ax
5656
movl $(CONS_ADDRESS), %edi
5757
movl $(CONS_WIDTH*CONS_HEIGHT), %ecx
5858
rep stosw
@@ -62,6 +62,18 @@ ENTRY(_start)
6262
cmpl $MULTIBOOT_BOOTLOADER_MAGIC, %eax
6363
jne nomultiboot
6464

65+
/* test the sse feature flag */
66+
movl $CPUID_01H_LEAF, %eax
67+
cpuid
68+
test $CPUID_01H_EDX_SSE, %edx
69+
jz no_sse
70+
71+
/* enable sse */
72+
movl %cr4, %eax
73+
orl $(CR4_OSXMMEXCPT|CR4_OSFXSR), %eax
74+
movl %eax, %cr4
75+
76+
no_sse:
6577
call x86_boot
6678

6779
jmp haltme
@@ -74,6 +86,7 @@ nomultiboot:
7486
movsbl (%ebx), %eax
7587
test %al, %al
7688
je haltme
89+
7790
orl $0x500, %eax
7891
movl %eax, (%ecx)
7992
inc %ebx

platform/hw/include/arch/x86/reg.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
1+
#define CPUID_01H_LEAF 0x01
2+
3+
#define CPUID_01H_EDX_SSE 0x02000000 /* SSE Extensions */
4+
5+
#define CR0_PG 0x80000000 /* Paging */
6+
#define CR0_WP 0x00010000 /* Write Protect */
7+
#define CR0_PE 0x00000001 /* Protection Enable */
8+
9+
#define CR4_OSXMMEXCPT 0x00000400 /* OS support for unmasked SIMD FP exceptions */
10+
#define CR4_OSFXSR 0x00000200 /* OS support for FXSAVE & FXRSTOR */
11+
#define CR4_PAE 0x00000020 /* Physical Address Extension */
12+
13+
/* Extended Feature Enable Register */
14+
#define MSR_EFER 0xc0000080
15+
16+
#define MSR_EFER_LME 0x00000100 /* Long Mode Enable */
17+
118
#define PIC1_CMD 0x20
219
#define PIC1_DATA 0x21
320
#define PIC2_CMD 0xa0

0 commit comments

Comments
 (0)