-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
zeyu
committed
Jul 26, 2020
1 parent
2a516cb
commit 263d802
Showing
12 changed files
with
48 additions
and
54 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,27 @@ | ||
[section .data] | ||
randstr db "Welcome to kernel by techlog.cn", 0 | ||
SELECTOR_KERNEL_CS equ 8 | ||
|
||
; 导入函数与全局变量 | ||
extern copy_gdt | ||
extern gdt_ptr | ||
|
||
[SECTION .bss] | ||
StackSpace resb 2 * 1024 * 1024 | ||
StackTop: | ||
|
||
[section .text] | ||
global _start | ||
|
||
_start: | ||
push dword randstr | ||
call DispStr | ||
add esp, 4 | ||
jmp $ | ||
|
||
DispStr: | ||
push ebp | ||
mov ebp, esp | ||
push ebx | ||
push esi | ||
push edi | ||
|
||
mov esi, [ebp + 8] ; pszInfo | ||
mov edi, (80 * 7) * 2 | ||
mov ah, 0Fh | ||
.1: | ||
lodsb | ||
test al, al | ||
jz .2 | ||
.3: | ||
mov [gs:edi], ax | ||
add edi, 2 | ||
jmp .1 | ||
|
||
.2: | ||
pop edi | ||
pop esi | ||
pop ebx | ||
pop ebp | ||
ret | ||
mov esp, StackTop ; 堆栈在 bss 段中 | ||
|
||
sgdt [gdt_ptr] ; cstart() 中将会用到 gdt_ptr | ||
call copy_gdt ; 在此函数中改变了gdt_ptr,让它指向新的GDT | ||
lgdt [gdt_ptr] ; 使用新的GDT | ||
|
||
jmp SELECTOR_KERNEL_CS:csinit | ||
csinit: ; 长跳转,让 GDT 切换生效 | ||
|
||
push 0 | ||
popfd | ||
|
||
hlt |