summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md12
-rw-r--r--kernel/console.c7
-rw-r--r--kernel/kernel.c63
-rw-r--r--kernel/mp.c2
-rw-r--r--kernel/vesa.c2
-rw-r--r--kernel/vmem.c16
-rw-r--r--kernel/x86.c7
7 files changed, 39 insertions, 70 deletions
diff --git a/README.md b/README.md
index 697feeb..2f40220 100644
--- a/README.md
+++ b/README.md
@@ -31,10 +31,9 @@ FoolOS is tested/developed on the following emlators/machines
* bochs 2.6.6 (compiled with: ./configure --enable-clgd54xx --enable-a20-pin --enable-debugger --enable-disasm --enable-e1000 --with-x --with-x11 --enable-smp)
* qemu 1.1.2
-
-* virtual box 4.1.18 (disable nested paging etc)
-* my laptop (Acer Aspire 1810TZ)
-* my desktop (Q6600 on Asus p5n32-e sli plus)
+* virtual box 4.1.18
+* Acer Aspire 1810TZ (Notebook)
+* Q6600 on Asus p5n32-e sli plus (Desktop PC)
Features
--------
@@ -56,11 +55,11 @@ Todos
Some things I would like to add someday:
-* port c lib and gcc
* Filesystem (probably ext2)
* e1000 driver
* drivers to read/write usb sticks
* networking stack / webserver
+* port c lib and gcc
* user space / ring3 / ELF binaries support
* mouse support
* simple window manager
@@ -69,7 +68,6 @@ Some things I would like to add someday:
* implement a real shell (in user mode)
* kernel should run in high memory (~3gb) virutal mem. why? except v86 tasks?
* let processors sleep if there is no work
-* switch from PIC to APIC!(?)
* use ACPI instead of MP spec.
Issues
@@ -81,7 +79,6 @@ Issues
* size of bitmap to track free blocks of physical memory is hardcoded to max.
* Assumed suport for VESA mode 0x114 with linear addressing!
* My Acer Aspire seems to lack MP tables, switch to ACPI
-* virtual box enables VT-x for MP, which makes FoolOS hang on VM init.
MEMORY LAYOUT
@@ -150,6 +147,7 @@ REFERENCES
* http://www.nongnu.org/ext2-doc/
* http://www.osdever.net/tutorials/view/multiprocessing-support-for-hobby-oses-explained
* http://wiki.xomb.org/index.php?title=ACPI_Tables
+* Intel 386 Programmes Ref.
* http://forum.osdev.org/viewtopic.php?f=1&t=10944
* man syscalls (posix syscalls?)
diff --git a/kernel/console.c b/kernel/console.c
index 16cf04f..e06da45 100644
--- a/kernel/console.c
+++ b/kernel/console.c
@@ -1,7 +1,6 @@
#include "console.h"
-#define FOOLOS_CONSOLE
-//#undef FOOLOS_CONSOLE
+//#define FOOLOS_CONSOLE
static int posx=0;
static int posy=0;
@@ -10,11 +9,11 @@ static int posy=0;
void print_char_col(int x, int y, char c, char col)
{
-//#ifdef FOOLOS_CONSOLE
+#ifdef FOOLOS_CONSOLE
char* video_mem=(char *)SCR_VIDEOMEM+(x+y*SCR_REAL_WIDTH)*2;
video_mem[0]=c;
video_mem[1]=col;
-//#endif
+#endif
}
void print_char(int x, int y, char c)
diff --git a/kernel/kernel.c b/kernel/kernel.c
index 429a286..373eea1 100644
--- a/kernel/kernel.c
+++ b/kernel/kernel.c
@@ -1,6 +1,7 @@
#define FOOLOS_MODULE_NAME "kernel"
#include "x86.h"
+#include "console.h"
#include "../lib/logger/log.h" // logger facilities
// TODO: WHHYY can i compile it without the includes!???
@@ -20,22 +21,20 @@ uint32_t read_eip();
//
// this is the very heart of our operating system!
//
-
void kernel_main(uint32_t initial_stack, int mp)
{
- volatile static uint32_t cpu1_counter=0;
// catch the APs (Application Processors)
- /*
if(mp==1)
{
- //while(1) { static uint16_t c=0; PutString("cpu2: %03d", 200,560,0b1111100000000000, (c++)/100); }
- while(1) { static uint16_t c=0; PutString("cpu1counter: %d", 200,560,0b1111100000000000, (cpu1_counter)); }
- }
- */
+ volatile static uint16_t proc=1;
+ int p=proc;
+ uint32_t cpu_counter=0;
+ while(1)PutString("mp: %d", 200,580,0b1111100000000000, (cpu_counter++));
+ }
//
// We want to get output to the screen as fast as possible!
@@ -67,31 +66,14 @@ void kernel_main(uint32_t initial_stack, int mp)
log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"initial esp: 0x%08X",initial_stack);
//
- // Initialize other processors
+ // Initialize other processors (run this before entering paged mode)
//
// This currently uses the MP Floating Pointer Struct.
// Should support APCI in future too.
//
-
if(!init_mp()) panic(FOOLOS_MODULE_NAME,"Can not Find _MP_");
-
- //
- // Memory Init
- //
-
- // we know that here, the bootloader placed the mamory map!
- mem_init(0x7c00+0x400,*((uint16_t *)(0x7c00+0x600)));
-
-
- // paging (pass the vesa physbase address for identity mapping)
- vmem_init(vesa_physbase);
-
- while(1) {
- PutString("cpu1counter: %d", 10,560,0b1111100000000000, (cpu1_counter));
- cpu1_counter++;
- }
//
// Setup PIC
//
@@ -101,14 +83,20 @@ void kernel_main(uint32_t initial_stack, int mp)
log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"setting up PIC.");
pic_setup();
- //while(1);
-
//
// Configuring the PIT timer.
//
timer_init();
+ //
+ // Memory Init
+ //
+
+ // we know that here, the bootloader placed the mamory map!
+ mem_init(0x7c00+0x400,*((uint16_t *)(0x7c00+0x600)));
+ // paging (pass the vesa physbase address for identity mapping)
+ vmem_init(vesa_physbase);
//
// Interrupts
@@ -133,19 +121,7 @@ void kernel_main(uint32_t initial_stack, int mp)
int_install_ir(38, 0b10001110, 0x08,&int_floppy_handler);
// now we can enable interrupts back again
-// int_enable();
-
- while(1) {
- cpu1_counter++;
- /*
- static uint16_t c=0;
- PutString("cpu1: A",20,560,0xffffff,0);
- for(int c2=0;c2<0xffff;c2++);
- PutString("cpu1: B",20,560,0xffffff,0);
- for(int c2=0;c2<0xffff;c2++);
- //PutString("cpu1: %03d", 20,560,0b1111100000000000, (c++)/100);
- */
- }
+ int_enable();
//
// Scan the PCI Bus
@@ -187,7 +163,12 @@ void kernel_main(uint32_t initial_stack, int mp)
// Just hang here.
//
- while(1);
+ while(1)
+ {
+ static uint32_t cpu1_counter=0;
+ PutString("cpu1counter: %d", 10,560,0b1111100000000000, (cpu1_counter++));
+ cpu1_counter++;
+ }
}
diff --git a/kernel/mp.c b/kernel/mp.c
index dd9fbd5..dece903 100644
--- a/kernel/mp.c
+++ b/kernel/mp.c
@@ -113,6 +113,8 @@ void show_mp_conf(mp_config *addr)
local_apic=addr->local_apic;
+
+
//bsp (boot processor) enables its local apic
uint32_t *reg=addr->local_apic+FOOLOS_APIC_SPUR_INT;
*reg=0xffffffff; // all bits 1 and interrupt 255
diff --git a/kernel/vesa.c b/kernel/vesa.c
index a3fc76c..e8b6269 100644
--- a/kernel/vesa.c
+++ b/kernel/vesa.c
@@ -37,7 +37,7 @@ typedef struct ModeInfoBlock {
uint8_t rsv_mask, rsv_position;
uint8_t directcolor_attributes;
- uint32_t physbase; // your LFB (Linear Framebuffer) address ;)
+ volatile uint32_t physbase; // your LFB (Linear Framebuffer) address ;)
uint32_t reserved1;
uint16_t reserved2;
}vbemodeinfo;
diff --git a/kernel/vmem.c b/kernel/vmem.c
index 741a1e8..cd6bc93 100644
--- a/kernel/vmem.c
+++ b/kernel/vmem.c
@@ -232,15 +232,15 @@ void vmem_init(uint32_t vesa_physbase)
//! create a new page
pt_entry page=0;
pt_entry_add_attrib (&page, I86_PTE_PRESENT);
+ pt_entry_add_attrib (&page, I86_PTE_WRITABLE);
pt_entry_set_frame (&page, frame);
//! ...and add it to the page table
table2->m_entries [PAGE_TABLE_INDEX (virt) ] = page;
}
- //! map 1mb to 3gb (where we are at)
-
- uint32_t vesa_mapped=0x1000*1024;
+ //uint32_t vesa_mapped=0x1000*1024;
+ uint32_t vesa_mapped=vesa_physbase;
for (int i=0, frame=vesa_physbase, virt=vesa_mapped; i<1024; i++, frame+=4096, virt+=4096)
{
@@ -248,7 +248,7 @@ void vmem_init(uint32_t vesa_physbase)
//! create a new page
pt_entry page=0;
pt_entry_add_attrib (&page, I86_PTE_PRESENT);
-// pt_entry_add_attrib (&page, I86_PTE_WRITABLE);
+ pt_entry_add_attrib (&page, I86_PTE_WRITABLE);
pt_entry_set_frame (&page, frame);
//! ...and add it to the page table
@@ -275,16 +275,10 @@ void vmem_init(uint32_t vesa_physbase)
log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"enabling paging...");
show_cr();
-
- // while(1);
x86_paging_enable();
- x86_paging_disable();
- x86_paging_enable();
- vesa_set_physbase(vesa_mapped);
- // x86_flush_tlb(0);
- // x86_flush_tlb(vesa_physbase);
+ vesa_set_physbase(vesa_mapped);
show_cr();
diff --git a/kernel/x86.c b/kernel/x86.c
index c1113bf..5e44424 100644
--- a/kernel/x86.c
+++ b/kernel/x86.c
@@ -88,11 +88,6 @@ void x86_paging_enable()
{
uint32_t cr0=x86_get_cr0();
cr0 |= 0x80000000; // enable paging
-
-// cr0 |= 0x40000000; // cahce disable
-// cr0 |= 0x20000000; // not-write-through
-// cr0 |= 0x10000; // write to read-only pages
-
asm volatile("mov %0, %%cr0":: "b"(cr0));
}
@@ -107,7 +102,7 @@ void x86_paging_disable()
void x86_flush_tlb(uint32_t addr)
{
- asm volatile("invlpg (%0)" ::"r" (addr) : "memory");
+ asm volatile("invlpg (%0)" ::"r" (addr) : "memory");
}