diff options
| author | Miguel <m.i@gmx.at> | 2018-09-03 00:07:20 +0200 |
|---|---|---|
| committer | Miguel <m.i@gmx.at> | 2018-09-03 00:07:20 +0200 |
| commit | 38b1273c7e3a52ae929f36fe07e29bc68ef95102 (patch) | |
| tree | 16734c1c190825159f6ca9696d9c5cfb04e89c8f /asm/asm_gdt.s | |
| parent | fd5a9b87e47bc072aa63fcaf5735232a37338303 (diff) | |
clean filenames etc
Diffstat (limited to 'asm/asm_gdt.s')
| -rw-r--r-- | asm/asm_gdt.s | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/asm/asm_gdt.s b/asm/asm_gdt.s new file mode 100644 index 0000000..0e163fc --- /dev/null +++ b/asm/asm_gdt.s @@ -0,0 +1,39 @@ +.global asm_setup_gdt + +asm_setup_gdt: + + // re-fill gdt_descriptor with new GDT location and size + movl 4(%esp),%eax + movl %eax, gdt_descriptor+2 + + movw 8(%esp),%ax + movw %ax, gdt_descriptor + // + + lgdt gdt_descriptor #load new descriptor table! + + // reload to take effect + reloadSegments: + + #Reload CS register containing code selector: + jmp $0x08,$reload_CS # 0x08 points at the new code selector + + reload_CS: + mov $0x10, %ax #0x10 points at the new data selector + mov %ax, %ds + mov %ax, %es + mov %ax, %fs + mov %ax, %gs + mov %ax, %ss + + tss_flush: + + movw $0x2B,%ax # Load the index of our TSS structure - The index is + # 0x28, as it is the 5th selector and each is 8 bytes + # long, but we set the bottom two bits (making 0x2B) + # so that it has an RPL of 3, not zero. + ltr %ax # Load 0x2B into the task state register. + + ret + +ret |
