📄 start.s
字号:
.globl start
.code32
.text
start: jmp 1f
.org 0x10
VFS: #VFS WILL LOCATE HERE:)
.long 0,0,0,0
.align 0x10
1:
movw $0x10,%ax
movw %ax,%ds
movw %ax,%es
#Now we try to move to the page translation mode:)
#Clear 8K for page directory & page table at first.
movl $(1<<20),%edi #from 1M to 1M+8K
xorl %eax,%eax
movl $(1<<11),%ecx
cld
rep
stosl
#Then set one page directory item for kernel:
#Note: Memory e0000?-ff000?? are read only.it may be ROM?
#Note: 1<<20-1<<12:Can't work!!
movl $((1<<20)+(1<<12)+1),%eax #Item 1 locate at 1M+4K,P=1 US=00;
movl %eax,(1<<20) #Set up item 1-->1M+4K=The dir item.
#Now set the kernel page table item.size of 1M will contain 256 items
movl $0x01,%eax #the first item of kernel:base 0,present
movl $0x400,%ecx #1M/4K=256 items,but,we set up 4M...
movl $((1<<20)+(1<<12)),%ebx #from 1M+4K to 1M+8K
S_PItem:
movl %eax,(%ebx)
addl $4,%ebx
addl $(0x1<<12),%eax #to next item,as other word,next 4K memo
loop S_PItem
movl $(1<<20),%eax
movl %eax,%cr3
movl %cr0,%eax
orl $0x80000000,%eax
movl %eax,cr0 #cr0 is the global variant def in progC.c
movl %eax,%cr0
movl $_KM_Array,%eax
movl %eax,KM_Array #KM_Array is a global variant.
call main
ret_main:
movw $0x18,%ax
ltr %ax
sti
eCode: jmp eCode
.align 0x10
_KM_Array:
.long KM_DivErr,KM_Debug,0,KM_NMI,KM_Overflow
.long KM_Bounds,KM_InvalidOp,KM_DevNotAvail
.long KM_Double,KM_CopSegOver,KM_InvalidTss
.long KM_Stack,KM_General,KM_Page,0,KM_CopErr
.long KM_HdHead,KM_HdSecs,KM_Mem,KM_CR0
KM_DivErr:
.string "Divided by 0!\0"
KM_Debug:
.string "Debug interupt\0"
KM_NMI:
.string "NMI interrupt\0"
KM_Overflow:
.string "Overflow error\0"
KM_Bounds:
.string "Out of bounds\0"
KM_InvalidOp:
.string "Invalid operation!\0"
KM_DevNotAvail:
.string "Device not availble\0"
KM_Double:
.string "Double Error\0"
KM_CopSegOver:
.string "Coprocessor segment overrun\0"
KM_InvalidTss:
.string "Invalid Tss!\0"
KM_Stack:
.string "Stack errer\0"
KM_General:
.string "General protection\0"
KM_Page:
.string "Page not available\0"
KM_CopErr:
.string "Coprocessor Error\0"
KM_HdHead:
.string "Hard disk heads:\0"
KM_HdSecs:
.string "The sectors of a trace:\0"
KM_Mem: .string "Memory size:\0"
KM_CR0: .string "The value of CR0:\0"
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -