I'm trying to implement paging on my OS. I prepared a page directory, and page table for kernel. Page directory starts from 0x00100000 and page table for kernel starts from 0x00101000.
After enabling paging, I tried JMP 0xC0000000, but kernel codes weren't executed. Without -no-shutdown and -no-reboot options, QEMU reboots infinitely.
Code: Select all
DIR EQU 0x00100000
MOV EAX, DIR
MOV CR3, EAX
MOV EAX, CR0
OR EAX, 0x80000000
MOV CR0, EAX
MOV ESP,0xC0080FFF
MOV EBP,ESP
JMP 0xC0000000
paging.asm: https://gist.github.com/720ff535ee9cad7 ... 9e36ede536
vbe.asm: https://gist.github.com/0e8d23d03ad9b97 ... d779778c0f
(I don't think vbe.asm is related to this problem.)
QEMU execution:
Code: Select all
qemu-system-i386 -drive file=build/ramen_os.img,format=raw,if=floppy -monitor stdio -no-shutdown -no-reboot
Kernel code (This code isn't the actual kernel code, but for testing paging) :(qemu) info status
VM status: paused (shutdown)
(qemu) info registers
EAX=80000011 EBX=0000418b ECX=00000000 EDX=00100000
ESI=0008c400 EDI=00102400 EBP=c0080fff ESP=c0080ff7
EIP=000068da EFL=00000002 [-------] CPL=0 II=0 A20=1 SMM=0 HLT=0
ES =0000 00000000 00000000 00000000
CS =0000 00000000 0000ffff 00009b00 DPL=0 CS16 [-RA]
SS =0008 00000000 ffffffff 00cf9300 DPL=0 DS [-WA]
DS =0008 00000000 ffffffff 00cf9300 DPL=0 DS [-WA]
FS =0008 00000000 ffffffff 00cf9300 DPL=0 DS [-WA]
GS =0008 00000000 ffffffff 00cf9300 DPL=0 DS [-WA]
LDT=0000 00000000 0000ffff 00008200 DPL=0 LDT
TR =0000 00000000 0000ffff 00008b00 DPL=0 TSS32-busy
GDT= 0000c3e0 00000017
IDT= 00000000 000003ff
CR0=80000011 CR2=00000000 CR3=00100000 CR4=00000000
DR0=00000000 DR1=00000000 DR2=00000000 DR3=00000000
DR6=ffff0ff0 DR7=00000400
EFER=0000000000000000
FCW=037f FSW=0000 [ST=0] FTW=00 MXCSR=00001f80
FPR0=0000000000000000 0000 FPR1=0000000000000000 0000
FPR2=0000000000000000 0000 FPR3=0000000000000000 0000
FPR4=0000000000000000 0000 FPR5=0000000000000000 0000
FPR6=0000000000000000 0000 FPR7=0000000000000000 0000
XMM00=00000000000000000000000000000000 XMM01=00000000000000000000000000000000
XMM02=00000000000000000000000000000000 XMM03=00000000000000000000000000000000
XMM04=00000000000000000000000000000000 XMM05=00000000000000000000000000000000
XMM06=00000000000000000000000000000000 XMM07=00000000000000000000000000000000
(qemu) info mem
0000000000000000-0000000000100000 0000000000100000 -r-
00000000c0000000-00000000c0081000 0000000000081000 -r-
(qemu) xp /4w 0x00100000 + 0x300 * 4
0000000000100c00: 0x00101021 0x00000000 0x00000000 0x0000000
(qemu) xp /4w 0x00101000
0000000000101000: 0x00501001 0x00502001 0x00503001 0x00504001
(qemu) xp /4w 0x00501000
0000000000501000: 0x0000feeb 0x00000000 0x00000000 0x00000000
(qemu) info mem
0000000000000000-0000000000100000 0000000000100000 -r-
00000000c0000000-00000000c0081000 0000000000081000 -r-
(qemu) info tlb
0000000000000000: 0000000000000000 ---DA----
0000000000001000: 0000000000001000 ---------
0000000000002000: 0000000000002000 ----A----
0000000000003000: 0000000000003000 ---------
0000000000004000: 0000000000004000 ----A----
0000000000005000: 0000000000005000 ---DA----
0000000000006000: 0000000000006000 ----A----
0000000000007000: 0000000000007000 ---------
0000000000008000: 0000000000008000 ---------
0000000000009000: 0000000000009000 ---------
000000000000a000: 000000000000a000 ---------
000000000000b000: 000000000000b000 ---------
000000000000c000: 000000000000c000 ---DA----
000000000000d000: 000000000000d000 ---------
...
00000000000fe000: 00000000000fe000 ---------
00000000000ff000: 00000000000ff000 ---------
00000000c0000000: 0000000000501000 ---------
00000000c0001000: 0000000000502000 ---------
...
00000000c007f000: 0000000000580000 ---------
00000000c0080000: 0000000000582000 ---DA----
Code: Select all
EXTERN os_main
os_main:
HLT
JMP os_main
Code: Select all
OUTPUT_FORMAT(binary);
OUTPUT_ARCH(i386);
ENTRY(os_main)
SECTIONS
{
.text 0xC0000000 : { *(.text*) }
.data : {
*(.data)
*(.rodata*)
*(.bss)
}
/DISCARD/ : { *(.eh_frame) }
}