📄 head.s
字号:
.globl startup
.globl GDT
.equ GDT_ENTRIES,4
.equ GDT_ENTRY_SZ,8
.equ SEG1,1<<3 # kernel cs
.equ SEG2,2<<3 # kernel ds
.equ SEG3,3<<3 # tss
startup:
cli
lgdt GDT_pointer # redo it here
call start_kernel
# Maybe NEVER REACHED...
##########################################
# GDT & IDT data
##########################################
.align 8
.word 0,0,0,0
GDT:
# Descriptor 0 : NULL segment
#.word 0
#.word 0
#.word 0
#.word 0
.quad 0x0000000000000000
# Descriptor 1 : Kernel code segment
#.word 0xFFFF # bytes 0 and 1 of segment size
#.word 0x0000 # bytes 0 and 1 of segment base address
#.byte 0x00 # byte 2 of segment base address
#.byte 0x9A # present, DPL=0, code exec-read
#.byte 0xCF # 4kb graanularity, 32bit code
#.byte 0x00 # byte 3 of segment base address
.quad 0x00cf9a000000ffff
# Descriptor 2 : Kernel data and stack segment
#.word 0xFFFF
#.word 0x0000
#.byte 0x00
#.byte 0x92 # present, DPL=0, data read/write
#.byte 0xCF
#.byte 0x00
.quad 0x00cf92000000ffff
# Descriptor 3 : tss. will be filled in later
#.word 0x00
#.word 0x00
#.word 0x00
#.word 0x00
.quad 0x000000000000
GDT_pointer:
.word GDT_ENTRIES * GDT_ENTRY_SZ # limit
#.word 0x9A00 + GDT # base address
.long GDT
.word 0
.word 0 # padding
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -