kern

changeset 8:78d5c304ddd0

minor changes
author John Tsiombikas <nuclear@member.fsf.org>
date Wed, 16 Feb 2011 07:50:25 +0200
parents 611b2d66420b
children af6f4adc43d6
files src/segm-asm.S src/segm.c src/segm.h
diffstat 3 files changed, 18 insertions(+), 17 deletions(-) [+]
line diff
     1.1 --- a/src/segm-asm.S	Wed Feb 16 07:26:03 2011 +0200
     1.2 +++ b/src/segm-asm.S	Wed Feb 16 07:50:25 2011 +0200
     1.3 @@ -1,27 +1,25 @@
     1.4  	.data
     1.5 +	.align 4
     1.6 +/* memory reserved for setup_selectors */
     1.7  off:.long 0
     1.8  seg:.short 0
     1.9 -
    1.10 -	.align
    1.11 -	.short 0
    1.12 -gdt_lim:
    1.13 -	.short 0
    1.14 -gdt_addr:
    1.15 -	.long 0
    1.16 +/* memory reserved for set_gdt */
    1.17 +lim:.short 0
    1.18 +addr:.long 0
    1.19  
    1.20  	.text
    1.21  /* setup_selectors(uint16_t code, uint16_t data)
    1.22   * loads the requested selectors to all the selector registers */
    1.23  	.globl setup_selectors
    1.24  setup_selectors:
    1.25 -	/* setup data selectors */
    1.26 +	/* set data selectors directly */
    1.27  	movl 8(%esp), %eax
    1.28  	movw %ax, %ss
    1.29  	movw %ax, %es
    1.30  	movw %ax, %ds
    1.31  	movw %ax, %gs
    1.32  	movw %ax, %fs
    1.33 -	/* setup code selector */
    1.34 +	/* set cs using a long jump */
    1.35  	movl 4(%esp), %eax
    1.36  	movw %ax, (seg)
    1.37  	movl $ldcs, (off)
    1.38 @@ -34,8 +32,8 @@
    1.39  	.globl set_gdt
    1.40  set_gdt:
    1.41  	movl 4(%esp), %eax
    1.42 -	movl %eax, (gdt_addr)
    1.43 +	movl %eax, (addr)
    1.44  	movw 8(%esp), %ax
    1.45 -	movw %ax, (gdt_lim)
    1.46 -	lgdt (gdt_lim)	
    1.47 +	movw %ax, (lim)
    1.48 +	lgdt (lim)	
    1.49  	ret
     2.1 --- a/src/segm.c	Wed Feb 16 07:26:03 2011 +0200
     2.2 +++ b/src/segm.c	Wed Feb 16 07:50:25 2011 +0200
     2.3 @@ -1,6 +1,7 @@
     2.4  #include <string.h>
     2.5  #include "segm.h"
     2.6  
     2.7 +/* bits for the 3rd 16bt part of the descriptor */
     2.8  #define BIT_ACCESSED	(1 << 8)
     2.9  #define BIT_WR			(1 << 9)
    2.10  #define BIT_RD			(1 << 9)
    2.11 @@ -10,6 +11,7 @@
    2.12  #define BIT_NOSYS		(1 << 12)
    2.13  #define BIT_PRESENT		(1 << 15)
    2.14  
    2.15 +/* bits for the last 16bit part of the descriptor */
    2.16  #define BIT_BIG			(1 << 6)
    2.17  #define BIT_DEFAULT		(1 << 6)
    2.18  #define BIT_GRAN		(1 << 7)
    2.19 @@ -18,7 +20,12 @@
    2.20  
    2.21  static void segm_desc(desc_t *desc, uint32_t base, uint32_t limit, int dpl, int type);
    2.22  
    2.23 +/* these functions are implemented in segm-asm.S */
    2.24 +void setup_selectors(uint16_t code, uint16_t data);
    2.25 +void set_gdt(uint32_t addr, uint16_t limit);
    2.26  
    2.27 +
    2.28 +/* our global descriptor table */
    2.29  static desc_t gdt[4];
    2.30  
    2.31  
    2.32 @@ -33,6 +40,7 @@
    2.33  	setup_selectors(selector(SEGM_KCODE, 0), selector(SEGM_KDATA, 0));
    2.34  }
    2.35  
    2.36 +/* constructs a GDT selector based on index and priviledge level */
    2.37  uint16_t selector(int idx, int rpl)
    2.38  {
    2.39  	return (idx << 3) | (rpl & 3);
     3.1 --- a/src/segm.h	Wed Feb 16 07:26:03 2011 +0200
     3.2 +++ b/src/segm.h	Wed Feb 16 07:50:25 2011 +0200
     3.3 @@ -12,10 +12,5 @@
     3.4  
     3.5  uint16_t selector(int idx, int rpl);
     3.6  
     3.7 -/* these functions are implemented in segm-asm.S */
     3.8 -void setup_selectors(uint16_t code, uint16_t data);
     3.9 -void set_gdt(uint32_t addr, uint16_t limit);
    3.10 -
    3.11 -
    3.12  
    3.13  #endif	/* SEGM_H_ */