summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichal Idziorek <m.i@gmx.at>2014-09-03 16:05:48 +0200
committerMichal Idziorek <m.i@gmx.at>2014-09-03 16:05:48 +0200
commitae361f46b092264f5107eaaf8fc594e0ca679014 (patch)
tree560ec382c3b3c9b5759996df7fdcd8f6032a763c
parente5e674724ec527c45efaa1622d0e9a1618757ca3 (diff)
fix bug in apic.c and update of Readme
-rw-r--r--Makefile2
-rw-r--r--README.md192
-rw-r--r--kernel/acpi.c6
-rw-r--r--kernel/kernel.c29
4 files changed, 35 insertions, 194 deletions
diff --git a/Makefile b/Makefile
index b591a0a..306ea65 100644
--- a/Makefile
+++ b/Makefile
@@ -23,7 +23,7 @@ MP_IMG_START=26112 #multiboot is initially at 0x6600
FONT_DATA_START=26624 #fool font initially at 0x6800
-USB_STICK=/dev/sdd
+USB_STICK=/dev/sdf
KERNEL_START=0x10000
diff --git a/README.md b/README.md
index 056ba5d..7131c48 100644
--- a/README.md
+++ b/README.md
@@ -45,88 +45,46 @@ All features are only very rudiemntary and buggy.
* PCI bus scanning
* Physical memory management
* Virtual memory managment (Paging)
-* Multitasking (2 tasks so far)
-* Multiple processors (hardcoded 2)
+* Multitasking
+* Multiple processors
* Floppy disk driver
* VESA
+* ACPI / MP (to get processor info)
Todos
-----
Some things I would like to add someday:
+* shell
+
+* drivers to read/write usb sticks
* Filesystem (probably ext2)
+* kernel should run in high memory (~3gb) virutal mem. why? except v86 tasks?
+
* e1000 driver
-* drivers to read/write usb sticks
-* networking stack / webserver
+
* port c lib and gcc
+* networking stack / webserver
* user space / ring3 / ELF binaries support
-* mouse support
-* simple window manager
-* 64-bit support
+
* alternatively grub as bootloader
-* 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
-* use ACPI instead of MP spec.
+* 64-bit support
* ARM
-* JVM?
+* JVM
+* distributed OS
+
+* mouse support
+* simple window manager
Issues
------
-* memory map and some other locations are hardcoded.
+* stack heap sizes??
+* multitasking crashes sometimes/ page faults? interrupts !?
* the first ~4mb of physical mem are reserved by mem manager (hardcoded)
-* bootloader loads only 52 sectors of kernel into mem. ~25KB!
* 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
-
-
-MEMORY LAYOUT
-=============
-
-floppy image
-------------
-* 0x0000 - MASTER BOOT RECORD
-* 0x0200 - kernel image (contains sotrage for interrupt desc. table)
-* 0x6400 - fool-font binary
-* 0x8000 - file system will go here?
-
-ram
----
-
-0x1000
- boot loader puts the kernel binary here.
-
-0x7000
- entry point for APs (Application Processors).
-
-0x7c00
- first stage boot loader (loaded by bios) boot/mbr.asm
- includes initial Global Descriptor Table!
-
-0x7c00 + 3 (after jmp boot_16)
- boot loader puts number of boot floppy disk here.
-
-0x7c00 + 0x600
- boot loader puts number of records in memory map in here!
-
-0x7c00 + 0x400
- the boot loader puts the memory map obtained from the
- bios here before switching to protected mode.
-
-0x8300
- boot loader puts the vesa modes here!
-
-0x9000
- esp (stack counts down)
-
-0x9000
- physical memory manager bitmap!!!
-
-0xb000
- memory above this is used for dma (by our floppy.c driver)
REFERENCES
@@ -135,11 +93,9 @@ REFERENCES
* LINUX KERNEL
* GNU HURD
* MINIX
-* FreeBSD etc.
+* FreeBSD
* xv6
-* distributed OS?
-
-* e1000 driver
+* e1000 linux driver
* http://www.brokenthorn.com/Resources/OSDev17.html
* http://www.jamesmolloy.co.uk/tutorial_html/9.-Multitasking.html
@@ -152,108 +108,4 @@ REFERENCES
* Intel 386 Programmes Ref.
* http://forum.osdev.org/viewtopic.php?f=1&t=10944
* man syscalls (posix syscalls?)
-
-
-MY NOTES BELOW THIS LINE
-========================
-
-Keyboard Driver
----------------
-
-//some thoughts on redesign of the keyboard driver
-//use uint8_t for proc_pos and buff_pos and a BUF_SIZE of 256 for auto wrap!?
-
-// kb input ringbuffer
-kb_scancode kb_buff[BUF_SIZE];
-
-buff_pos=0;
-proc_pos=0;
-buffered=0;
-
-void kb_irq()
-{
- cli
-
- //we get one interrupt for EACH scancode!
- kb_scancode val=get_scancode();
-
- // think about race condition if called while inside kb_proc();
- if(buffered+1<BUF_SIZE)
- {
- kb_buff[buff_pos]=val;
- buff_pos++;
- buffered++;
- }
- else
- {
- //kb ring buffer is full;
- }
- sti
-
-}
-
-
-void kb_proc()
-{
- if(proc_pos!=buff_pos)
- {
- kb_scancode val=kb_buff[proc_pos];
-
- proc_pos++;
- buffered--;
-
- stdin(scancode_to_char(val));
-
- }
-}
-
-Linux Startup x86
------------------
-~ ontogeny recapitulates phylogeny ~
-
-Some notes on the Linux statup process, or at least how I understand it.
-
-1. arch/x86/boot/header.S
-
-Contains the header and linux 16 bit code.
-
-This code should be entered with a bootloader at the address specified
-within the header (as _start) which will put us at 'start_of_setup'
-
-Direct loading will put us at 'start2' at the very start which will
-show an error message
-
-If everyhing goes right we will enter the 16-bit real mode C module
-with:
-
-call main ; should not return
-
-2. arch/x86/boot/main.c
-
-void main(void) will do some checks and detections (cpu,mem,..) and
-invoke: go_to_protected_mode();
-
-3. arch/x86/boot/pm.c
-
-go_to_protected_mode() - will disable interrupts and set up the initial
-idt and gdt descriptor tables before calling: protected_mode_jump() and
-passing the address of code32_start.
-
-4. arch/x86/boot/pmjump.S
-
-back in assembly-world the actual transition is made inside
-'protected_mode_jump' and we move on to 'in_pm32' where the data segment
-is set up and we jmpl to the 32-bit entry point of the kernel.
-
-5. arch/x86/kernel/head32.c (assumption!?)
-
-void i386_start_kernel(void)
-
-6. init/main.c
-
-start_kernel(void)
-
-setup_arch()!!
-
-
-Interrupts: arch/x86/include/asm/irq_vectors.h each entry is 8 bytes
+* and many more ...
diff --git a/kernel/acpi.c b/kernel/acpi.c
index da16be8..586336c 100644
--- a/kernel/acpi.c
+++ b/kernel/acpi.c
@@ -65,8 +65,10 @@ uint8_t *apci_get_next_entry(uint8_t *addr,smp_processors *procdata)
// usable
if(addr[4]&1)
{
- if(procdata->processors>=SMP_MAX_PROC)
+ if(procdata->processors>=SMP_MAX_PROC){
+
panic(FOOLOS_MODULE_NAME,"we do not support that many processors. recompile with higher SMP_MAX_PROC.");
+ }
procdata->local_apic_id[procdata->processors]=addr[3];
procdata->processors++;
@@ -139,6 +141,8 @@ bool acpi_find(smp_processors *procdata)
{
log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"Looking for RSDP Table");
char *search=0x7ffff; //will be 16 bit aligned;
+ procdata->processors=0;
+ procdata->boot=0;
while(search<=0xfffff)
{
diff --git a/kernel/kernel.c b/kernel/kernel.c
index 40c576a..6931ad1 100644
--- a/kernel/kernel.c
+++ b/kernel/kernel.c
@@ -146,32 +146,17 @@ void kernel_main(uint32_t initial_stack, int mp)
//
- // Initialize other processors (run this before entering paged mode)
+ // Gather Info about other processors.
+ // ACPI or MP
//
- // This currently uses the MP Floating Pointer Struct.
- // Should support APCI in future too.
- //
-
- smp_processors procdata1;
- smp_processors procdata2;
smp_processors procdata;
// try to find acpi tables
- bool succ_acpi=acpi_find(&procdata1);
-
- // fallback to mp tables
- bool succ_mp=mp_find(&procdata2);
-
- if(!succ_acpi&&!succ_mp)
- panic(FOOLOS_MODULE_NAME,"ACPI and MP search failed! I do not want to continue!");
-
- if(succ_acpi)procdata=procdata1;
- else procdata=procdata2;
-
- // multiprocessing!
+ if(!acpi_find(&procdata))
+ if(!mp_find(&procdata))
+ panic(FOOLOS_MODULE_NAME,"ACPI and MP search failed! I do not want to continue!");
- smp_log_procdata(&procdata1);
- smp_log_procdata(&procdata2);
+ // Start the other Processors (also before paging !)
smp_start_aps(&procdata);
@@ -195,7 +180,7 @@ void kernel_main(uint32_t initial_stack, int mp)
// Initialize Floppy Disk
//
- // floppy_init();
+ //floppy_init();
//