peredOS/kernel/gdt.asm
msh356 884b58f304 MULTIPLE: 2 изменения
CHORE: удалено лишнее
ROADMAP: закрыто 2 пункта
2026-07-01 19:18:37 +03:00

24 lines
819 B
NASM
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

bits 32
global gdt_flush
gdt_flush:
; Берем адрес gdtp, переданный как аргумент функции (лежит в стеке)
mov eax, [esp + 4]
lgdt [eax] ; Загружаем новую GDT
; Обновляем сегменты данных. 0x10 — это смещение Kernel Data в нашей GDT (индекс 2 * 8 = 16 = 0x10)
mov ax, 0x10
mov ds, ax
mov es, ax
mov fs, ax
mov gs, ax
mov ss, ax
; Делаем дальний прыжок, чтобы обновить регистр CS.
; 0x08 — это смещение Kernel Code (индекс 1 * 8 = 8 = 0x08).
; Процессор прыгнет на метку .flush, но уже с новым селектором CS.
jmp 0x08:.flush
.flush:
ret