diff options
author | Andreas Baumann <mail@andreasbaumann.cc> | 2017-06-10 20:55:56 +0200 |
---|---|---|
committer | Andreas Baumann <mail@andreasbaumann.cc> | 2017-06-10 20:55:56 +0200 |
commit | eea5bf4b859eb56c5772c58ca54937a90a10e7ee (patch) | |
tree | 391b31a28a3740d3fd52a9a9d1c651bc9f12cc2b /src/boot/stage2_switch_mode.asm | |
parent | 1625a4752545e54c439a38f3393ab9d72bfee721 (diff) | |
download | abaos-eea5bf4b859eb56c5772c58ca54937a90a10e7ee.tar.gz abaos-eea5bf4b859eb56c5772c58ca54937a90a10e7ee.tar.bz2 |
moved bootloader to subdirectory
Diffstat (limited to 'src/boot/stage2_switch_mode.asm')
-rw-r--r-- | src/boot/stage2_switch_mode.asm | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/src/boot/stage2_switch_mode.asm b/src/boot/stage2_switch_mode.asm new file mode 100644 index 0000000..9259e08 --- /dev/null +++ b/src/boot/stage2_switch_mode.asm @@ -0,0 +1,40 @@ +[bits 16] + +%include "boot/boot_gdt.asm" + +switch_to_protected_mode: + ; switch off interrupts for now, we don't + ; have a valid IDT installed yet + cli + + ; load GDT (global descriptor table) + lgdt [gdt_descriptor] + + ; do the actual switch + mov eax, cr0 + or eax, 0x1 + mov cr0, eax + + ; unconditional far jump into code segment, + ; wipes the instruction prefetch pipeline + jmp CODE_SEGMENT:init_pm + +[bits 32] + +; initialize registers and stack for protected mode +init_pm: + mov ax, DATA_SEGMENT + mov ds, ax + mov ss, ax + mov es, ax + mov fs, ax + mov gs, ax + + ; a new stack + mov ebp, 0x90000 + mov esp, ebp + + call BEGIN_PROTECTED_MODE + +[bits 16] + |