protect mode 1 switch to protect mode

he Global Descriptor Table (GDT) is a binary data structure specific to the IA-32 and x86-64 architectures. It contains entries telling the CPU about memory segments.

Segment Descriptor

63 56 55 52 51 48 47 40 39 32
Base 31 24 Flags 3 0 Limit 19 16 Access Byte 7 0 Base 23 16
31 16 15 0
Base 15 0 Limit 15 0
  1. Entry 0 in a descriptor table, or the Null Descriptor
  2. A DPL 0 Code Segment descriptor
  3. A Data Segment descriptor
    增加gdt,jmp to protected mode,使用命令target remote | qemu-system-x86_64 -hda ./boot.bin -S -gdb stdio
    输入c继续,ctrl+c停止,输入layout asm查看执行的汇编代码。

enable a20 line

    in al, 0x92
    or al, 2
    out 0x92, al

cross compile

https://wiki.osdev.org/GCC_Cross-Compiler
gdb进入后
add-symbol-file ./build/kernelfull.o 0x100000添加符号,break _start设置断点,目标连接后停在了0x100000 _start 位置。

posted @ 2025-08-13 19:56  fangshuo  阅读(8)  评论(0)    收藏  举报