kern

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