kern
diff src/segm-asm.S @ 7:611b2d66420b
segment descriptors
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Wed, 16 Feb 2011 07:26:03 +0200 |
parents | |
children | 78d5c304ddd0 |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/segm-asm.S Wed Feb 16 07:26:03 2011 +0200 1.3 @@ -0,0 +1,41 @@ 1.4 + .data 1.5 +off:.long 0 1.6 +seg:.short 0 1.7 + 1.8 + .align 1.9 + .short 0 1.10 +gdt_lim: 1.11 + .short 0 1.12 +gdt_addr: 1.13 + .long 0 1.14 + 1.15 + .text 1.16 +/* setup_selectors(uint16_t code, uint16_t data) 1.17 + * loads the requested selectors to all the selector registers */ 1.18 + .globl setup_selectors 1.19 +setup_selectors: 1.20 + /* setup data selectors */ 1.21 + movl 8(%esp), %eax 1.22 + movw %ax, %ss 1.23 + movw %ax, %es 1.24 + movw %ax, %ds 1.25 + movw %ax, %gs 1.26 + movw %ax, %fs 1.27 + /* setup code selector */ 1.28 + movl 4(%esp), %eax 1.29 + movw %ax, (seg) 1.30 + movl $ldcs, (off) 1.31 + ljmp *off 1.32 +ldcs: 1.33 + ret 1.34 + 1.35 +/* set_gdt(uint32_t addr, uint16_t limit) 1.36 + * loads the GDTR with the new address and limit for the GDT */ 1.37 + .globl set_gdt 1.38 +set_gdt: 1.39 + movl 4(%esp), %eax 1.40 + movl %eax, (gdt_addr) 1.41 + movw 8(%esp), %ax 1.42 + movw %ax, (gdt_lim) 1.43 + lgdt (gdt_lim) 1.44 + ret