提交 a50ed4a7 编写于 作者: R rain

0.487s-boot: access 4GB memory in real-mode

上级 d611a60e
...@@ -10,3 +10,5 @@ ...@@ -10,3 +10,5 @@
2021-2-15 0.466: 466 lines, 5 files, rain 2021-2-15 0.466: 466 lines, 5 files, rain
2021-2-15 0.487: 487 lines, 5 files, rain
...@@ -23,6 +23,14 @@ Cunix kernel ...@@ -23,6 +23,14 @@ Cunix kernel
`0.451s-boot`: `0.451s-boot`:
&#9`boot` can load 8 sectors (4KB) of loader (not 1 sector). &#9`boot` can load 8 sectors (4KB) of loader (not 1 sector).
`0.466s-boot`: `0.466s-boot`:
&#9rebuild `boot` &#9rebuild `boot`
`0.487s-boot`:
&#9`loader` let FS can access 4GB memory in real-mode. because
&#9`loader` loaded GDT and load a data-segment to fs, then disable
&#9protect-mode.
</pre> </pre>
...@@ -20,6 +20,8 @@ ...@@ -20,6 +20,8 @@
org 0x8000 org 0x8000
jmp _start
%include "arch/x86/segment.inc" %include "arch/x86/segment.inc"
%include "arch/x86/paging.inc" %include "arch/x86/paging.inc"
...@@ -29,15 +31,34 @@ _start: ...@@ -29,15 +31,34 @@ _start:
mov si, message mov si, message
call print call print
.to_protect_mode: ; init segment register fs
.init_fs:
; enable A20 address 20 line ; enable A20 address 20 line
.open_a20 .open_a20:
in al, 0x92 in al, 0x92
or al, 2 or al, 0x02
out 0x92, al out 0x92, al
cli cli
lgdt [gdt32_descriptor] lgdt [gdt32_descriptor]
mov eax, cr0
or eax, 0x01
mov cr0, eax
mov ax, data32
mov fs, ax
mov eax, cr0
and eax, 11111111111111111111111111111110b
mov cr0, eax
; interrupt is disable
; now, FS has addressing out of 1MB like protect-mode.
.to_protect_mode:
; GDT is already load by .init_fs
mov eax, cr0 mov eax, cr0
; set CR0.bit 1 (Protect-mode Enable) ; set CR0.bit 1 (Protect-mode Enable)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册