kern
changeset 32:2cb5ab18e76e
merged the task bits, not completed
also removed the memory-manager debugging calls from main
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Sat, 28 May 2011 08:06:47 +0300 |
parents | 3ed041d07ae1 a2c6110bd24b |
children | 928b0ebfff4d |
files | src/main.c |
diffstat | 6 files changed, 59 insertions(+), 22 deletions(-) [+] |
line diff
1.1 --- a/src/intr.c Fri May 27 13:08:23 2011 +0300 1.2 +++ b/src/intr.c Sat May 28 08:06:47 2011 +0300 1.3 @@ -156,7 +156,7 @@ 1.4 desc->d[3] = (addr & 0xffff0000) >> 16; 1.5 } 1.6 1.7 -#define IS_TRAP(n) ((n) < 32) 1.8 +#define IS_TRAP(n) ((n) >= 32 && !IS_IRQ(n)) 1.9 static void set_intr_entry(int num, void (*handler)(void)) 1.10 { 1.11 int type = IS_TRAP(num) ? GATE_TRAP : GATE_INTR;
2.1 --- a/src/main.c Fri May 27 13:08:23 2011 +0300 2.2 +++ b/src/main.c Sat May 28 08:06:47 2011 +0300 2.3 @@ -66,26 +66,6 @@ 2.4 /* initialization complete, enable interrupts */ 2.5 enable_intr(); 2.6 2.7 - dbg_print_vm(MEM_USER); 2.8 - dbg_print_vm(MEM_KERNEL); 2.9 - 2.10 - { 2.11 - void *foo, *bar, *xyzzy, *koko, *lala; 2.12 - 2.13 - foo = malloc(128); 2.14 - bar = malloc(32 * 1024); 2.15 - xyzzy = malloc(8000); 2.16 - 2.17 - free(bar); 2.18 - 2.19 - koko = malloc(700); 2.20 - lala = malloc(6 * 1024 * 1024); 2.21 - 2.22 - free(xyzzy); 2.23 - free(foo); 2.24 - free(koko); 2.25 - free(lala); 2.26 - } 2.27 2.28 for(;;) { 2.29 char c, keypress;
3.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 3.2 +++ b/src/proc.h Sat May 28 08:06:47 2011 +0300 3.3 @@ -0,0 +1,14 @@ 3.4 +#ifndef PROC_H_ 3.5 +#define PROC_H_ 3.6 + 3.7 +#include "tss.h" 3.8 + 3.9 +struct process { 3.10 + int id; 3.11 + 3.12 + struct task_state tss; 3.13 + 3.14 + struct process *next; 3.15 +}; 3.16 + 3.17 +#endif /* PROC_H_ */
4.1 --- a/src/segm.c Fri May 27 13:08:23 2011 +0300 4.2 +++ b/src/segm.c Sat May 28 08:06:47 2011 +0300 4.3 @@ -11,6 +11,8 @@ 4.4 #define BIT_CODE (1 << 11) 4.5 #define BIT_NOSYS (1 << 12) 4.6 #define BIT_PRESENT (1 << 15) 4.7 +/* TSS busy bit */ 4.8 +#define BIT_BUSY (1 << 9) 4.9 4.10 /* bits for the last 16bit part of the descriptor */ 4.11 #define BIT_BIG (1 << 6) 4.12 @@ -19,7 +21,11 @@ 4.13 4.14 enum {TYPE_DATA, TYPE_CODE}; 4.15 4.16 +#define TSS_TYPE_BITS 0x900 4.17 +#define TSS_BUSY BIT_BUSY 4.18 + 4.19 static void segm_desc(desc_t *desc, uint32_t base, uint32_t limit, int dpl, int type); 4.20 +static void task_desc(desc_t *desc, uint32_t base, uint32_t limit, int dpl, unsigned int busy); 4.21 4.22 /* these functions are implemented in segm-asm.S */ 4.23 void setup_selectors(uint16_t code, uint16_t data); 4.24 @@ -27,7 +33,7 @@ 4.25 4.26 4.27 /* our global descriptor table */ 4.28 -static desc_t gdt[3]; 4.29 +static desc_t gdt[6]; 4.30 4.31 4.32 void init_segm(void) 4.33 @@ -35,6 +41,9 @@ 4.34 memset(gdt, 0, sizeof gdt); 4.35 segm_desc(gdt + SEGM_KCODE, 0, 0xffffffff, 0, TYPE_CODE); 4.36 segm_desc(gdt + SEGM_KDATA, 0, 0xffffffff, 0, TYPE_DATA); 4.37 + segm_desc(gdt + SEGM_UCODE, 0, 0xffffffff, 3, TYPE_CODE); 4.38 + segm_desc(gdt + SEGM_UDATA, 0, 0xffffffff, 3, TYPE_DATA); 4.39 + /*task_desc(gdt + SEGM_TASK, 0, 0xffffffff, 3, TSS_BUSY);*/ 4.40 4.41 set_gdt((uint32_t)gdt, sizeof gdt - 1); 4.42 4.43 @@ -64,3 +73,13 @@ 4.44 */ 4.45 desc->d[3] = ((limit >> 16) & 0xf) | ((base >> 16) & 0xff00) | BIT_GRAN | BIT_BIG; 4.46 } 4.47 + 4.48 +static void task_desc(desc_t *desc, uint32_t base, uint32_t limit, int dpl, unsigned int busy) 4.49 +{ 4.50 + desc->d[0] = limit & 0xffff; 4.51 + desc->d[1] = base & 0xffff; 4.52 + 4.53 + desc->d[2] = ((base >> 16) & 0xff) | ((dpl & 3) << 13) | BIT_PRESENT | 4.54 + TSS_TYPE_BITS | busy; 4.55 + desc->d[3] = ((limit >> 16) & 0xf) | ((base >> 16) & 0xff00) | BIT_GRAN; 4.56 +}
5.1 --- a/src/segm.h Fri May 27 13:08:23 2011 +0300 5.2 +++ b/src/segm.h Sat May 28 08:06:47 2011 +0300 5.3 @@ -3,6 +3,9 @@ 5.4 5.5 #define SEGM_KCODE 1 5.6 #define SEGM_KDATA 2 5.7 +#define SEGM_UCODE 3 5.8 +#define SEGM_UDATA 4 5.9 +#define SEGM_TASK 5 5.10 5.11 void init_segm(void); 5.12
6.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 6.2 +++ b/src/tss.h Sat May 28 08:06:47 2011 +0300 6.3 @@ -0,0 +1,21 @@ 6.4 +#ifndef TSS_H_ 6.5 +#define TSS_H_ 6.6 + 6.7 +#include <inttypes.h> 6.8 + 6.9 +struct task_state { 6.10 + uint32_t prev_task; 6.11 + uint32_t esp0, ss0; 6.12 + uint32_t esp1, ss1; 6.13 + uint32_t esp2, ss2; 6.14 + uint32_t cr3; 6.15 + uint32_t eip; 6.16 + uint32_t eflags; 6.17 + uint32_t eax, ecx, edx, ebx; 6.18 + uint32_t esp, ebp, esi, edi; 6.19 + uint32_t es, cs, ss, ds, fs, gs; 6.20 + uint32_t ldt_sel; 6.21 + uint16_t trap, iomap_addr; 6.22 +} __attribute__((packed)); 6.23 + 6.24 +#endif /* TSS_H_ */