kern

changeset 16:2cbc2b922e49

adding paging
author John Tsiombikas <nuclear@member.fsf.org>
date Sat, 26 Mar 2011 12:27:57 +0200
parents 7f9af8cddc96
children 098b1cb5eeaa
files Makefile src/boot/mboot.S src/main.c
diffstat 3 files changed, 31 insertions(+), 15 deletions(-) [+]
line diff
     1.1 --- a/Makefile	Sat Mar 05 16:59:49 2011 +0200
     1.2 +++ b/Makefile	Sat Mar 26 12:27:57 2011 +0200
     1.3 @@ -8,10 +8,12 @@
     1.4  
     1.5  CC = gcc
     1.6  
     1.7 +inc = -Isrc -Isrc/klibc -Isrc/boot
     1.8 +
     1.9  # -nostdinc instructs the compiler to ignore standard include directories
    1.10  # -m32 instructs the compiler to produce 32bit code (in case we have a 64bit compiler)
    1.11 -CFLAGS = -m32 -Wall -g -nostdinc -fno-builtin -Isrc -Isrc/klibc
    1.12 -ASFLAGS = -m32 -g -nostdinc -fno-builtin -Isrc -Isrc/klibc
    1.13 +CFLAGS = -m32 -Wall -g -nostdinc -fno-builtin $(inc)
    1.14 +ASFLAGS = -m32 -g -nostdinc -fno-builtin $(inc)
    1.15  
    1.16  bin = kernel.elf
    1.17  
     2.1 --- a/src/boot/mboot.S	Sat Mar 05 16:59:49 2011 +0200
     2.2 +++ b/src/boot/mboot.S	Sat Mar 26 12:27:57 2011 +0200
     2.3 @@ -1,5 +1,6 @@
     2.4  #define MAGIC		0x1badb002
     2.5 -#define FLAGS		0
     2.6 +/* flags with bit 1 set means we need memory info */
     2.7 +#define FLAGS		2
     2.8  #define STACK_SIZE	0x4000
     2.9  
    2.10  	.text
    2.11 @@ -17,7 +18,9 @@
    2.12  	/* reset eflags register */
    2.13  	pushl $0
    2.14  	popf
    2.15 -	/* call the kernel main function */
    2.16 +	/* call the kernel main function. ebx points to the
    2.17 +     * multiboot information structure */
    2.18 +	push %ebx
    2.19  	call kmain
    2.20  	/* we dropped out of main, halt the CPU */
    2.21  	cli
     3.1 --- a/src/main.c	Sat Mar 05 16:59:49 2011 +0200
     3.2 +++ b/src/main.c	Sat Mar 26 12:27:57 2011 +0200
     3.3 @@ -1,10 +1,13 @@
     3.4  #include <stdio.h>
     3.5 +#include "mboot.h"
     3.6  #include "vid.h"
     3.7  #include "term.h"
     3.8 -#include <asmops.h>
     3.9 +#include "asmops.h"
    3.10  #include "segm.h"
    3.11  #include "intr.h"
    3.12 -#include "panic.h"
    3.13 +#include "vm.h"
    3.14 +
    3.15 +static void do_nothing();
    3.16  
    3.17  /* special keys */
    3.18  enum {
    3.19 @@ -34,22 +37,26 @@
    3.20  	0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0									/* 70 - 7f */
    3.21  };
    3.22  
    3.23 -void kmain(void)
    3.24 +void kmain(struct mboot_info *mbinf)
    3.25  {
    3.26  	clear_scr();
    3.27 +
    3.28 +	/* pointless verbal diarrhea */
    3.29 +	if(mbinf->flags & MB_LDRNAME) {
    3.30 +		printf("loaded by: %s\n", mbinf->boot_loader_name);
    3.31 +	}
    3.32 +	if(mbinf->flags & MB_CMDLINE) {
    3.33 +		printf("kernel command line: %s\n", mbinf->cmdline);
    3.34 +	}
    3.35 +
    3.36  	puts("kernel starting up");
    3.37  
    3.38  	init_segm();
    3.39  	init_intr();
    3.40 +	init_vm(mbinf);
    3.41  
    3.42 -	set_text_color(YELLOW);
    3.43 -	puts("<initialization code goes here>");
    3.44 -	set_text_color(LTGRAY);
    3.45 -	puts("hello world!");
    3.46 -
    3.47 -	asm volatile("int $0x80");
    3.48 -
    3.49 -	panic("foo\n");
    3.50 +	/* silence the blasted timer interrupt */
    3.51 +	interrupt(32, do_nothing);
    3.52  
    3.53  	for(;;) {
    3.54  		char c, keypress;
    3.55 @@ -62,3 +69,7 @@
    3.56  		}
    3.57  	}
    3.58  }
    3.59 +
    3.60 +static void do_nothing()
    3.61 +{
    3.62 +}