summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile2
-rw-r--r--kernel/config.h2
-rw-r--r--kernel/console.c2
-rw-r--r--kernel/interrupts.c5
-rw-r--r--kernel/kernel.c4
-rw-r--r--kernel/smp.c49
-rw-r--r--kernel/task.c4
-rw-r--r--kernel/usermode.c7
-rw-r--r--terminal/vt52.c67
-rw-r--r--userspace/Makefile2
10 files changed, 101 insertions, 43 deletions
diff --git a/Makefile b/Makefile
index 2a8beb4..e8a2878 100644
--- a/Makefile
+++ b/Makefile
@@ -180,7 +180,7 @@ stick: $(FOOLOS)
############ cleanup ############
clean: $(CLEANDIRS)
- -rm *.bin $(FOOLOS) $(FOOLOS_VDI) $(KERNEL_ENTRY) $(ASM_MULTIBOOT_OBJ) $(KERNEL_IMG) $(ASM_OBJECTS) $(OBJECTS) $(IMG_FILLUP) $(BIN_MBR) $(BIN_MP) $(BIN_STAGE2) $(DEPS) bochs.out bochs.log ne2k-tx.log ne2k-txdump.txt tags
+ -rm *.bin $(FOOLOS) $(FOOLOS_VDI) $(KERNEL_ENTRY) $(ASM_MULTIBOOT_OBJ) $(KERNEL_IMG) $(ASM_OBJECTS) $(OBJECTS) $(IMG_FILLUP) $(BIN_MBR) $(BIN_MP) $(BIN_STAGE2) $(DEPS) bochs.out bochs.log ne2k-tx.log ne2k-txdump.txt tags mp/mp.bin
tags:
ctags --recurse=yes .
diff --git a/kernel/config.h b/kernel/config.h
index 74304d8..8329457 100644
--- a/kernel/config.h
+++ b/kernel/config.h
@@ -8,7 +8,7 @@
#define FOOLOS_CONFIG_H
#define FOOLOS_CONSOLE_AUTOBREAK // add newline automatically at end of line
-#define FOOLOS_LOG_OFF // do not log anything
+//#define FOOLOS_LOG_OFF // do not log anything
#define FOOLOS_CONSOLE // otherwise VESA will be used!
#define FOOLSOS_SHOW_VESAMODES
#define MEM_PRINT_MEMORYMAP
diff --git a/kernel/console.c b/kernel/console.c
index c46737e..593801a 100644
--- a/kernel/console.c
+++ b/kernel/console.c
@@ -18,11 +18,13 @@ uint32_t console_init(){
scr_clear();
return 0;
}
+
void console_del_char(){scr_backspace();}
void console_put_char_gray(char c){scr_put_char(c,SCR_GRAY2);}
void console_put_char_white(char c){scr_put_char(c,SCR_WHITE);}
void console_put_char_green(char c){scr_put_char(c,SCR_GREEN);}
void console_put_char_red(char c){scr_put_char(c,SCR_RED);}
+
void console_put_str_gray(char *s){scr_put_string(s,SCR_GRAY2);}
void console_put_str_white(char *s){scr_put_string(s,SCR_WHITE);}
void console_put_str_green(char *s){scr_put_string(s,SCR_GREEN);}
diff --git a/kernel/interrupts.c b/kernel/interrupts.c
index 088c94e..d75ec4d 100644
--- a/kernel/interrupts.c
+++ b/kernel/interrupts.c
@@ -172,11 +172,10 @@ void int_init(uint16_t sel)
//system calls
int_install_ir(0x80, 0b11101110, 0x08,&int_syscall_handler);
-
- int_install();
+ int_install();
// now we can enable interrupts back again
- x86_int_enable();
+ //x86_int_enable();
}
diff --git a/kernel/kernel.c b/kernel/kernel.c
index df3a573..a3df0b3 100644
--- a/kernel/kernel.c
+++ b/kernel/kernel.c
@@ -43,6 +43,7 @@ void kernel_main(uint32_t eax,uint32_t ebx)
log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"%s - compiled on %s at %s",KERNEL_VERSION,__DATE__,__TIME__);
+
//
// Configuring the PIT timer.
//
@@ -92,10 +93,11 @@ void kernel_main(uint32_t eax,uint32_t ebx)
//
// Start the other Processors (before paging because apic addr etc..?)
//
- // smp_log_procdata(&procdata);
//TODO: !!! Check commented out sleep ()!!!
+ smp_log_procdata(&procdata);
smp_start_aps(&procdata,"/boot/mp.bin"); //will be copied over mbr
+
//
// Activate Virtual Memory (paging)
//
diff --git a/kernel/smp.c b/kernel/smp.c
index f776c72..76a8b1c 100644
--- a/kernel/smp.c
+++ b/kernel/smp.c
@@ -1,3 +1,8 @@
+// http://www.intel.com/content/dam/doc/specification-update/64-architecture-x2apic-specification.pdf
+// http://download.intel.com/design/chipsets/datashts/29056601.pdf
+// http://www.scs.stanford.edu/05au-cs240c/lab/ia32/IA32-3.pdf
+
+
#define FOOLOS_MODULE_NAME "smp"
#include "lib/logger/log.h"
@@ -10,20 +15,35 @@
#define FOOLOS_APIC_SPUR_INT 0x00f0
#define FOOLOS_APIC_INT_COMMAND_LOW 0x0300
#define FOOLOS_APIC_INT_COMMAND_HIGH 0x0310
+#define FOOLOS_APIC_ID 0x020
// some multiprocessor shit that should move away TODO
uint32_t c1,c2,c3;
volatile uint8_t proc;
uint32_t cpu_counter[SMP_MAX_PROC];
-extern
+uint32_t local_apic_addr;
void smp_main()
{
- // int_install();
- // x86_int_enable();
+ while(1);
+
+ // log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"local apic_addr:0x%08X",local_apic_addr);
+ uint32_t *reg=local_apic_addr+FOOLOS_APIC_ID;
+ // log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"local apic id: 0x%08X",(*reg));
+
+ *reg=local_apic_addr+FOOLOS_APIC_SPUR_INT;
+ *reg|=0x100;//0xffffffff; // all bits 1 and interrupt 255
+// *reg=0;//xffffffff; // all bits 1 and interrupt 255
+
+ //int_install();
+ x86_int_enable();
+
+ while(1);
+
switch_to_user_mode();
+// int x=1/0;
while(1);
@@ -64,7 +84,9 @@ void smp_log_procdata(smp_processors *procdata)
// this will start all our application processors!
void smp_start_aps(smp_processors *pros,char *path)
-{
+{
+ local_apic_addr=pros->local_apic_address;
+
//lets copy the binary into mbr
fs_content(path,0x7000,0x100); // copy 0x100 bytes to 0x7000
@@ -73,8 +95,12 @@ void smp_start_aps(smp_processors *pros,char *path)
*entry=smp_main;
//bsp (boot processor) enables its local apic
- uint32_t *reg=pros->local_apic_address+FOOLOS_APIC_SPUR_INT;
-// *reg=0xffffffff; // all bits 1 and interrupt 255
+// uint32_t *reg=local_apic_addr+FOOLOS_APIC_SPUR_INT;
+// *reg=0xffffffff; // all bits 1 and interrupt 255 (is this not set anyway?)
+// *reg=0;
+
+ uint32_t *reg=local_apic_addr+FOOLOS_APIC_ID;
+ log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"local apic id: 0x%08X",(*reg));
for(int i=0;i<pros->processors;i++)
{
@@ -84,10 +110,10 @@ void smp_start_aps(smp_processors *pros,char *path)
uint8_t dest=pros->local_apic_id[i];
- reg=pros->local_apic_address+FOOLOS_APIC_INT_COMMAND_HIGH;
+ reg=local_apic_addr+FOOLOS_APIC_INT_COMMAND_HIGH;
*reg=dest<<24; // destination apic.
- reg=pros->local_apic_address+FOOLOS_APIC_INT_COMMAND_LOW;
+ reg=local_apic_addr+FOOLOS_APIC_INT_COMMAND_LOW;
*reg=(5<<8)|(1<<14); // 101 INIT
// do we really neet this?
@@ -97,14 +123,11 @@ void smp_start_aps(smp_processors *pros,char *path)
// start proc 0x7 = 0x7000; etc..
*reg=(6<<8)|(1<<14)|0x7; // 110 SIPI
-
- //bsp (boot processor) enables its local apic
- uint32_t *reg=pros->local_apic_address+FOOLOS_APIC_SPUR_INT;
- // *reg=0xffffffff; // all bits 1 and interrupt 255
-
}
+
}
+
diff --git a/kernel/task.c b/kernel/task.c
index 54381fa..495817c 100644
--- a/kernel/task.c
+++ b/kernel/task.c
@@ -83,7 +83,7 @@ volatile uint32_t my_scheduler(uint32_t oldesp)
volatile uint32_t task_switch_next(uint32_t oldesp)
{
- //syscall_write(1,"\n\n*tick*\n\n",10);
+// syscall_write(1,"*tick*",10);
timer_tick();
@@ -161,7 +161,7 @@ volatile void task_init(pdirectory *dir)
task_list[0].esp = 0; // will be set by next task_switch_next() call.
current_task=0;
- while(1);
+// while(1);
switch_to_user_mode();
//syscall_execve("/bin/foolshell",argv_init,env_init);
diff --git a/kernel/usermode.c b/kernel/usermode.c
index ff16156..e4d22d3 100644
--- a/kernel/usermode.c
+++ b/kernel/usermode.c
@@ -55,12 +55,13 @@ void install_tss(int cpu_no){
void switch_to_user_mode()
{
- char text[]="[internal] ";
+// char text[]="[internal] ";
- //asm_usermode();
- write(1,text,11);
+ asm_usermode();
+// write(1,text,11);
while(1); // will not be reached?
+// write(1,text,11);
}
char *argv_init[]={"/bin/init",NULL};
diff --git a/terminal/vt52.c b/terminal/vt52.c
index aa24435..1dc7289 100644
--- a/terminal/vt52.c
+++ b/terminal/vt52.c
@@ -8,10 +8,17 @@
// | | ---> Screen
// ------------
+// Interface:
+//
+// struct vt52_tty_struct; // TODO: check what is better to put in header!
+// vt52_tty vt52_init();
+// put(vt52_tty *tty, uint8_t c);
+//
+//
// REQUIREMENTS
-// * kballoc // block alloc
+// * kballoc // block wise in-kernel allocation
#include <stdint.h>
#include "kernel/kmalloc.h"
@@ -24,42 +31,66 @@
typedef struct vt52_tty_struct
{
- uint8_t x;
- uint8_t y;
- uint8_t *data; // screen data
+ uint32_t width;
+ uint32_t height;
+ uint32_t x;
+ uint32_t y;
+ uint32_t *data; // screen data
}vt52_tty;
-vt52_tty *vt52_init()
+vt52_tty vt52_init()
{
- vt52_tty *tty=kballoc(sizeof(vt52_tty));
- return tty;
-}
+ vt52_tty tty;
+ tty.data=kballoc(1);
-// User interaction
-void putKey(uint32_t code)
-{
+ tty.x=0;
+ tty.y=0;
+ tty.width=VT52_WIDTH;
+ tty.height=VT52_HEIGHT;
+
+ return tty;
}
-void refreshScreen()
+uint32_t index(vt52_tty *tty, uint32_t x, uint32_t y)
{
-
+ return tty->width*y+x;
}
-// Programm Interaction
-void put()
+void set_char(vt52_tty *tty, uint32_t x, uint32_t y, uint32_t c)
{
-
+ tty->data[index(tty,x,y)]=c;
}
-void get()
+// send one ASCII character to the terminal
+void put(vt52_tty *tty, uint8_t c)
{
-
+ set_char(tty,tty->x,tty->y,c);
+
+ if(tty->x>tty->width)
+ {
+ tty->x=0;
+ tty->y++;
+ }
+
+ //autoscroll
+ if(tty->y>=tty->height)
+ {
+ tty->y--;
+ for(uint32_t l=tty->y; l>0; l--)
+ {
+ for(uint32_t x=0;x<tty->width;x++)
+ {
+ tty->data[index(tty,x,l-1)] = tty->data[index(tty,x,l)];
+ }
+ }
+ }
}
+
diff --git a/userspace/Makefile b/userspace/Makefile
index 666f210..b591280 100644
--- a/userspace/Makefile
+++ b/userspace/Makefile
@@ -51,7 +51,7 @@ init: init.o
cat: cat.o
clean:
- -rm *.o $(PROGS) ext2.img
+ -rm *.o $(PROGS) ext2.img *.d
mount:
mkdir mnt