kern

annotate 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
rev   line source
nuclear@7 1 .data
nuclear@7 2 off:.long 0
nuclear@7 3 seg:.short 0
nuclear@7 4
nuclear@7 5 .align
nuclear@7 6 .short 0
nuclear@7 7 gdt_lim:
nuclear@7 8 .short 0
nuclear@7 9 gdt_addr:
nuclear@7 10 .long 0
nuclear@7 11
nuclear@7 12 .text
nuclear@7 13 /* setup_selectors(uint16_t code, uint16_t data)
nuclear@7 14 * loads the requested selectors to all the selector registers */
nuclear@7 15 .globl setup_selectors
nuclear@7 16 setup_selectors:
nuclear@7 17 /* setup data selectors */
nuclear@7 18 movl 8(%esp), %eax
nuclear@7 19 movw %ax, %ss
nuclear@7 20 movw %ax, %es
nuclear@7 21 movw %ax, %ds
nuclear@7 22 movw %ax, %gs
nuclear@7 23 movw %ax, %fs
nuclear@7 24 /* setup code selector */
nuclear@7 25 movl 4(%esp), %eax
nuclear@7 26 movw %ax, (seg)
nuclear@7 27 movl $ldcs, (off)
nuclear@7 28 ljmp *off
nuclear@7 29 ldcs:
nuclear@7 30 ret
nuclear@7 31
nuclear@7 32 /* set_gdt(uint32_t addr, uint16_t limit)
nuclear@7 33 * loads the GDTR with the new address and limit for the GDT */
nuclear@7 34 .globl set_gdt
nuclear@7 35 set_gdt:
nuclear@7 36 movl 4(%esp), %eax
nuclear@7 37 movl %eax, (gdt_addr)
nuclear@7 38 movw 8(%esp), %ax
nuclear@7 39 movw %ax, (gdt_lim)
nuclear@7 40 lgdt (gdt_lim)
nuclear@7 41 ret