summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile7
-rw-r--r--asm/asm_int.h4
-rw-r--r--asm/asm_int.s59
-rw-r--r--asm/asm_smp.asm (renamed from asm/asm_mp.asm)0
-rw-r--r--asm/asm_smp.h (renamed from asm/asm_mp.h)0
-rw-r--r--driver/serial.c1
-rw-r--r--driver/serial.h1
-rw-r--r--kernel/acpi.c19
-rw-r--r--kernel/acpi.h27
-rw-r--r--kernel/interrupts.c37
-rw-r--r--kernel/interrupts.h2
-rw-r--r--kernel/kernel.c41
-rw-r--r--kernel/kernel.h2
-rw-r--r--kernel/kmalloc.c1
-rw-r--r--kernel/mp.c3
-rw-r--r--kernel/mp.h4
-rw-r--r--kernel/multiboot.c11
-rw-r--r--kernel/multiboot.h8
-rw-r--r--kernel/smashing.c1
-rw-r--r--kernel/smp.c37
-rw-r--r--kernel/smp.h28
-rw-r--r--kernel/syscalls.c1
-rw-r--r--linker.ld2
23 files changed, 160 insertions, 136 deletions
diff --git a/Makefile b/Makefile
index 4de169d..6c84c3f 100644
--- a/Makefile
+++ b/Makefile
@@ -28,6 +28,7 @@ CFLAGS+=-I.
CFLAGS+=-I/home/miguel/temp/foolos/usr/i686-foolos/include/
CFLAGS+=-I./asm
CFLAGS+=-I./kernel
+CFLAGS+=-I./driver
CFLAGS+=-gstabs
#CFLAGS+=-fstack-protector-all
@@ -163,6 +164,12 @@ run-qemu: all
echo XDOTOOL HACK...&& sleep 0.2 && xdotool search --name "QEMU" windowsize 100 100 && echo XDOTOOL HACK END. &
qemu-system-i386 -enable-kvm $(FOOLOS_ISO) -smp 4 -serial stdio
+run-qemu-16: all
+ #qemu-system-i386 -enable-kvm disk.img -smp 4 -s
+ #qemu-system-i386 -enable-kvm -s -kernel foolos.img -smp 4 -initrd userspace/ext2.img
+ echo XDOTOOL HACK...&& sleep 0.2 && xdotool search --name "QEMU" windowsize 100 100 && echo XDOTOOL HACK END. &
+ qemu-system-i386 -enable-kvm $(FOOLOS_ISO) -smp 16 -serial stdio
+
run-qemu-debug: all
# qemu -enable-kvm -s -S ~/temp/FoolOs/disk.img
# qemu -enable-kvm -s -singlestep disk.img
diff --git a/asm/asm_int.h b/asm/asm_int.h
index 5f32777..2940ab4 100644
--- a/asm/asm_int.h
+++ b/asm/asm_int.h
@@ -25,6 +25,10 @@ void int15();
void int128(); // syscalls
void int129(); // scheduler
+void int140(); // scheduler
+void int144(); // scheduler
+void int145(); // scheduler
+void int146(); // scheduler
void int200(); // apic timer
void int170(); // smp scheduler
void int255(); // unhandled
diff --git a/asm/asm_int.s b/asm/asm_int.s
index 70993b4..ec81885 100644
--- a/asm/asm_int.s
+++ b/asm/asm_int.s
@@ -19,6 +19,10 @@
.global int128
.global int129
.global int200
+.global int140
+.global int144
+.global int145
+.global int146
.global int170
.global int255
@@ -137,31 +141,6 @@
jmp .
.endm
-int0: intx ack1 $0 interrupt_handler
-int1: intx ack1 $1 interrupt_handler
-int2: intx ack1 $2 interrupt_handler
-int3: intx ack1 $3 interrupt_handler
-int4: intx ack1 $4 interrupt_handler
-int5: intx ack1 $5 interrupt_handler
-int6: intx ack1 $6 interrupt_handler
-int7: intx ack1 $7 interrupt_handler
-
-int8: intx ack2 $8 interrupt_handler
-int9: intx ack2 $9 interrupt_handler
-int10: intx ack2 $10 interrupt_handler
-int11: intx ack2 $11 interrupt_handler
-int12: intx ack2 $12 interrupt_handler
-int13: intx ack2 $13 interrupt_handler
-int14: intx ack2 $14 interrupt_handler
-int15: intx ack2 $15 interrupt_handler
-
-int128: intx ack0 $128 interrupt_handler
-int129: intx ack0 $129 interrupt_handler
-
-int255: intx ack0 $255 interrupt_handler
-int200: intx ack0 $200 interrupt_handler
-int170: intx ack0 $170 interrupt_handler
-
exc0: excx $0 exception_handle
exc1: excx $1 exception_handle
exc2: excx $2 exception_handle
@@ -181,3 +160,33 @@ exc15: excx $15 exception_handle
exc16: excx $16 exception_handle
exc17: excx $17 exception_handle
exc18: excx $18 exception_handle
+
+int0: intx ack0 $0 interrupt_handler
+int1: intx ack0 $1 interrupt_handler
+int2: intx ack0 $2 interrupt_handler
+int3: intx ack0 $3 interrupt_handler
+int4: intx ack0 $4 interrupt_handler
+int5: intx ack0 $5 interrupt_handler
+int6: intx ack0 $6 interrupt_handler
+int7: intx ack0 $7 interrupt_handler
+int8: intx ack0 $8 interrupt_handler
+int9: intx ack0 $9 interrupt_handler
+int10: intx ack0 $10 interrupt_handler
+int11: intx ack0 $11 interrupt_handler
+int12: intx ack0 $12 interrupt_handler
+int13: intx ack0 $13 interrupt_handler
+int14: intx ack0 $14 interrupt_handler
+int15: intx ack0 $15 interrupt_handler
+
+int128: intx ack0 $128 interrupt_handler
+int129: intx ack0 $129 interrupt_handler
+
+int140: intx ack0 $140 interrupt_handler
+int144: intx ack0 $144 interrupt_handler
+int145: intx ack0 $145 interrupt_handler
+int146: intx ack0 $146 interrupt_handler
+
+int255: intx ack0 $255 interrupt_handler
+int200: intx ack0 $200 interrupt_handler
+int170: intx ack0 $170 interrupt_handler
+
diff --git a/asm/asm_mp.asm b/asm/asm_smp.asm
index 18b9d7e..18b9d7e 100644
--- a/asm/asm_mp.asm
+++ b/asm/asm_smp.asm
diff --git a/asm/asm_mp.h b/asm/asm_smp.h
index f36f4f7..f36f4f7 100644
--- a/asm/asm_mp.h
+++ b/asm/asm_smp.h
diff --git a/driver/serial.c b/driver/serial.c
index 0088868..4e43251 100644
--- a/driver/serial.c
+++ b/driver/serial.c
@@ -1,7 +1,6 @@
#include "serial.h"
#include "asm_x86.h" // provides x86_inb() and x86_outb()
-
/** COM1 Port */
static const PORT=0x3f8;
diff --git a/driver/serial.h b/driver/serial.h
index c6841f2..bf56f80 100644
--- a/driver/serial.h
+++ b/driver/serial.h
@@ -1,5 +1,6 @@
#ifndef FOOLOS_SERIAL_H
#define FOOLOS_SERIAL_H
+
/**
* @file
* MINIMALISTIC SERIAL PORT DRIVER for COM1
diff --git a/kernel/acpi.c b/kernel/acpi.c
index 8b139bf..f424312 100644
--- a/kernel/acpi.c
+++ b/kernel/acpi.c
@@ -1,9 +1,9 @@
#include "kernel.h"
+#include "acpi.h"
+
#include <stdint.h>
-#include "smp.h"
#include "lib/string/string.h"
-
typedef struct acpi_rsdt_struct
{
char sig[4];
@@ -49,14 +49,14 @@ typedef struct
}acpi_madt;
-uint8_t *apci_get_next_entry(uint8_t *addr,smp_processors *procdata)
+static uint8_t *apci_get_next_entry(uint8_t *addr,acpi_information *procdata)
{
//klog("Examining MADT Entry at 0x%08X",addr);
if(*addr==0)
{
- klog("Type 0: LocalAPIC (enabled=%d)",addr[4]&1);
+ klog("Type 0: LocalAPIC (enabled=%d) (id=0x%08X)",addr[4]&1,addr[3]);
// usable
if(addr[4]&1)
{
@@ -90,11 +90,11 @@ uint8_t *apci_get_next_entry(uint8_t *addr,smp_processors *procdata)
}
-void acpi_check_madt(uint32_t *madt,smp_processors *procdata)
+static void acpi_check_madt(uint32_t *madt,acpi_information *procdata)
{
acpi_madt *table=(acpi_madt *)*madt;
-// klog("Looking for MADT Table at %08X.",table);
+// klog("Looking for MADT Table at %08X.",table);
if(!strcmp_l("APIC",table->sig,4))
{
klog("Found MADT Table at 0x%08X",table);
@@ -106,6 +106,7 @@ void acpi_check_madt(uint32_t *madt,smp_processors *procdata)
procdata->local_apic_address=table->apic_local;
klog("Local Apic Address: 0x%08X",table->apic_local);
+
procdata->flags=table->flags;
klog("Flags (Dual 8259): %d",table->flags);
@@ -116,7 +117,7 @@ void acpi_check_madt(uint32_t *madt,smp_processors *procdata)
}
}
-void acpi_read_rsdt(acpi_rsdt *rsdt,smp_processors *procdata)
+static void acpi_read_rsdt(acpi_rsdt *rsdt,acpi_information *procdata)
{
klog("Reading RSDT Table at 0x%08X",rsdt);
@@ -142,7 +143,7 @@ void acpi_read_rsdt(acpi_rsdt *rsdt,smp_processors *procdata)
// 0x7ffff - 0x9ffff (max)
// 0xe0000 - 0xfffff
-bool acpi_find(smp_processors *procdata)
+bool acpi_fill(acpi_information *procdata)
{
klog("Looking for RSDP Table");
char *search=(char *)0x9f000; //will be 16 bit aligned;
@@ -160,7 +161,7 @@ bool acpi_find(smp_processors *procdata)
if(checksum==0)
{
- klog("RSDP Table found at 0x%08X",search);
+ klog("RSD Pointer found at 0x%08X",search);
acpi_rsdp *rsdp=(acpi_rsdp *)search;
acpi_read_rsdt(rsdp->ptr_rsdt,procdata);
return true;
diff --git a/kernel/acpi.h b/kernel/acpi.h
index ce8d710..e94766c 100644
--- a/kernel/acpi.h
+++ b/kernel/acpi.h
@@ -1,3 +1,6 @@
+#ifndef FOOLOS_ACPI_H
+#define FOOLOS_ACPI_H
+
/**
* @file
*
@@ -10,5 +13,25 @@
* https://wiki.osdev.org/MADT#Entry_Type_1_:_I.2FO_APIC
*/
-#include "smp.h"
-bool acpi_find(smp_processors *procdata);
+#include <stdint.h>
+
+typedef struct
+{
+
+ uint8_t boot; //which processor in array is bsp
+ // (boot strap processor)
+
+ uint8_t processors; // total number of usable processors
+
+ uint32_t local_apic_address;// same for every processor
+ uint32_t io_apic_address;
+
+ uint32_t local_apic_id[SMP_MAX_PROC]; // unique id for every processor
+
+ uint32_t flags;
+
+}acpi_information;
+
+bool acpi_fill(acpi_information *procdata);
+
+#endif
diff --git a/kernel/interrupts.c b/kernel/interrupts.c
index 44ab9b5..897c312 100644
--- a/kernel/interrupts.c
+++ b/kernel/interrupts.c
@@ -60,26 +60,23 @@ void interrupts_install()
uint32_t interrupt_handler(uint32_t esp, uint32_t irq)
{
-
// DO NOT WRITE INSIDE INTERRUPTS!! COZ IT ACQUIRES LOCK AND WE WILL DEADLOCK
- //klog("int: %d on 0x%x",irq,apicID());
- if(irq==0){
- asm_pit_tick();
- }
+ // klog("int: %d on 0x%x",irq,apicID());
+ if(irq==INTERRUPT_PIT_TIMER)asm_pit_tick();
// mouse and kb
- if(irq==1 || irq==12 ){
+ if(irq==INTERRUPT_KEYBOARD || irq==INTERRUPT_MOUSE){
uint32_t in=x86_inb(0x60);
- if(irq==1)keyboard_handle(in); // do this in separate thread!
+ if(irq==INTERRUPT_KEYBOARD)keyboard_handle(in); // do this in separate thread!
// TODO: mouse
// test ipi
-// apicIPI(2,170);
-// klog("0x60 in %d",in);
+ //apicIPI(15,0x81); // force cpu16 to autoschedule? just test
+ //klog("0x60 in %d",in);
}
// 0x80 - a syscall is coming in
- if(irq==128){
+ if(irq==INTERRUPT_SYSCALL){
uint32_t *stack=esp;
uint32_t eax=stack[11];
@@ -93,16 +90,14 @@ uint32_t interrupt_handler(uint32_t esp, uint32_t irq)
esp=my_scheduler(esp,2); // force scheduling of pid=2 (kernel worker)
}
- if(irq==0 || irq==129)esp=my_scheduler(esp,-1); // autoschedule
+ // schedules on APIC timer 0x8C and IPI 0x81
+ if(irq==INTERRUPT_PIT_TIMER || irq==INTERRUPT_IPI)esp=my_scheduler(esp,-1); // autoschedule
- if(irq==200){} // apic timer
- if(irq==170){
-// if(apicID()!=0)apicIPI(0,170);
- }
- if(irq==255)kpanic("Spurious Interrupt!?");
+ if(irq!=INTERRUPT_SYSCALL)apicEOI(); // ack all except software syscalls
+
+ if(irq==255)kpanic("Spurious/Unknown Interrupt!?"); // default and spurious
- if(irq!=0x81 && irq!=0x80)apicEOI();
return esp;
}
@@ -243,16 +238,16 @@ void interrupts_init(uint16_t sel)
int_install_ir(18, 0b10001110, 0x08,&exc18);
// PIT (IOAPIC)
- int_install_ir(0x90, 0b10001110, 0x08,&int0);
+ int_install_ir(0x90, 0b10001110, 0x08,&int144);
// Keyboard (IOAPIC)
- int_install_ir(0x91, 0b10001110, 0x08,&int1);
+ int_install_ir(0x91, 0b10001110, 0x08,&int145);
// Mouse (IOAPIC)
- int_install_ir(0x92, 0b10001110, 0x08,&int12);
+ int_install_ir(0x92, 0b10001110, 0x08,&int146);
// APIC Timer (LAPIC)
- int_install_ir(0x8C, 0b10001110, 0x08,&int200);
+ int_install_ir(0x8C, 0b10001110, 0x08,&int140);
// System Calls (User Software / Ring 3)
int_install_ir(0x80, 0b11101110, 0x08,&int128);
diff --git a/kernel/interrupts.h b/kernel/interrupts.h
index 80fa95e..b7f2760 100644
--- a/kernel/interrupts.h
+++ b/kernel/interrupts.h
@@ -51,7 +51,7 @@
#define INTERRUPT_APIC_TIMER 0x8C
#define INTERRUPT_SYSCALL 0x80
-#define INTERRUPT_IPI 0x81
+#define INTERRUPT_IPI 0x81 // ipi1 more might folllow
void interrupts_init(uint16_t sel);
void interrupts_install();
diff --git a/kernel/kernel.c b/kernel/kernel.c
index 12b2063..50815d1 100644
--- a/kernel/kernel.c
+++ b/kernel/kernel.c
@@ -1,13 +1,16 @@
-#include <stdint.h>
-#include "kernel/kernel.h"
+#include "kernel.h"
+
+#include "serial.h"
+#include "multiboot.h"
+#include "acpi.h"
+
+//
#include "kernel/mem.h"
#include "kernel/vmem.h"
#include "kernel/gdt.h"
#include "kernel/scheduler.h"
-#include "kernel/multiboot.h"
-#include "driver/serial.h"
#include "driver/timer.h"
#include "driver/keyboard.h"
#include "driver/mouse.h"
@@ -15,12 +18,13 @@
#include "syscalls.h"
#include "fifo.h"
#include "mp.h"
-#include "asm_mp.h"
+#include "asm_smp.h"
#include "asm_x86.h"
#include "interrupts.h"
#include "ringbuffer.h"
#include "driver/screen.h"
#include "asm_pic.h"
+#include "smp.h"
#include "fs/fs.h"
#include "kmalloc.h"
@@ -38,23 +42,22 @@ void kernel_main(uint32_t eax,uint32_t ebx)
klog("Version: git-commit: %s",GIT_REVISION);
klog("======================================");
- klog("Communication Port (COM1) init ..."); //delayed info
-
fixme("Check if kernel size does not exceed memory limits!");
- // collect some info (before we start paging)
- klog("Search / Read Multiboot Structures ... ");
+ klog("Communication Port (COM1) initialized."); //delayed info
+
+ klog("Read Multiboot Structures ...");
multiboot_information *info;
- info=get_multiboot(eax, ebx);
+ info=multiboot_read(eax, ebx);
- klog("Search / Read ACPI Structures... ");
- smp_processors procdata;
- bool acpi_found=acpi_find(&procdata);
-
- klog("Search / Read MP Structures... ");
- smp_processors procdata2;
- bool mp_found=mp_find(&procdata2);
- //
+ klog("Read Advanced Power Configuration Interface (ACPI) Structures ...");
+ acpi_information procdata;
+ bool acpi_found=acpi_fill(&procdata);
+ if(!acpi_found) kpanic("We Currently rely on ACPI Structures Sorry!");
+
+ //klog("Read Multiprocessor (MP) Structures (Legacy) ... ");
+ //smp_processors procdata2;
+ //bool mp_found=mp_find(&procdata2);
klog("Global Descriptor Table (GDT) init ...");
gdt_init();
@@ -72,6 +75,7 @@ void kernel_main(uint32_t eax,uint32_t ebx)
klog("Mouse init ...");
mouse_init();
+ klog("MEMORY MANAGEMENT");
// memory management
klog("Memory init ... ");
uint32_t kernel_blocks=mem_init(info);
@@ -80,6 +84,7 @@ void kernel_main(uint32_t eax,uint32_t ebx)
pdirectory *dir=vmem_init(kernel_blocks,(uint32_t)info->framebuffer_addr,procdata.local_apic_address,procdata.io_apic_address);
//
+
klog("Ram Filesystem init ... ");
fs_mount(info);
diff --git a/kernel/kernel.h b/kernel/kernel.h
index 3f74f4a..c7406e7 100644
--- a/kernel/kernel.h
+++ b/kernel/kernel.h
@@ -25,7 +25,7 @@
#define S1(x) #x
#define S2(x) S1(x)
-#define SMP_MAX_PROC 32
+#define SMP_MAX_PROC 16 // 16 (together with bsp) We can currently only address a maximum of 16 cpus via ipis!
// __FUNCTION__ ?
#ifndef FOOLOS_LOG_OFF
diff --git a/kernel/kmalloc.c b/kernel/kmalloc.c
index 6a5812a..239a50b 100644
--- a/kernel/kmalloc.c
+++ b/kernel/kmalloc.c
@@ -12,6 +12,7 @@ static uint8_t init=0;
// will be initialized on first call to kballoc() //
static void kmallocinit()
{
+ fixme("implement and USE! kfree");
next=&(data[0]);
first=next;
diff --git a/kernel/mp.c b/kernel/mp.c
index ba6a042..f7dcac6 100644
--- a/kernel/mp.c
+++ b/kernel/mp.c
@@ -1,3 +1,5 @@
+/* TEMPORARILY DISABLED
+ *
#include "kernel/kernel.h"
#include <stdbool.h>
@@ -173,3 +175,4 @@ bool mp_find(smp_processors *procdata)
}
+*/
diff --git a/kernel/mp.h b/kernel/mp.h
index fc7f036..e6db125 100644
--- a/kernel/mp.h
+++ b/kernel/mp.h
@@ -1,2 +1,2 @@
-#include "smp.h"
-bool mp_find(smp_processors *procdata);
+// MULTIBOOT SPEC parsing
+//bool mp_find(smp_processors *procdata);
diff --git a/kernel/multiboot.c b/kernel/multiboot.c
index a705e81..ee84180 100644
--- a/kernel/multiboot.c
+++ b/kernel/multiboot.c
@@ -1,13 +1,11 @@
-#include "kernel/kernel.h"
-//https://www.gnu.org/software/grub/manual/multiboot/multiboot.html#Boot-information-format
-
+#include "kernel.h"
#include "multiboot.h"
-#include "driver/vesa.h"
-multiboot_information* get_multiboot(uint32_t eax, uint32_t ebx)
+multiboot_information* multiboot_read(uint32_t eax, uint32_t ebx)
{
-
if(eax!=0x2badb002)kpanic("EAX was not set properly by your bootlaoder!");
+ klog("multiboot struct at addr: 0x%08X",ebx);
+
multiboot_information *info;
info=ebx;
@@ -82,5 +80,4 @@ multiboot_information* get_multiboot(uint32_t eax, uint32_t ebx)
}
return info;
-
}
diff --git a/kernel/multiboot.h b/kernel/multiboot.h
index 49f239f..09f7286 100644
--- a/kernel/multiboot.h
+++ b/kernel/multiboot.h
@@ -3,9 +3,13 @@
*
* This Structures ars defined by the multiboot specification and you will
* get them from your bootloader.
+ *
+ * Ref
+ * ---
+ * https://www.gnu.org/software/grub/manual/multiboot/multiboot.html#Boot-information-format
+ *
*/
-//# https://www.gnu.org/software/grub/manual/multiboot/multiboot.html#Boot-information-format
#ifndef MULTIBOOT_H
#define MULTIBOOT_H
@@ -64,6 +68,6 @@ typedef struct multiboot_mod_struct
}multiboot_mod;
-multiboot_information* get_multiboot(uint32_t eax, uint32_t ebx);
+multiboot_information* multiboot_read(uint32_t eax, uint32_t ebx);
#endif
diff --git a/kernel/smashing.c b/kernel/smashing.c
index dc092be..e62e317 100644
--- a/kernel/smashing.c
+++ b/kernel/smashing.c
@@ -1,5 +1,6 @@
#include "kernel/kernel.h"
#include <stdint.h>
+
// CODE FOR Stack Smashing Protector.
// Do not duplicate with userspace / sys.c
// http://wiki.osdev.org/Stack_Smashing_Protector
diff --git a/kernel/smp.c b/kernel/smp.c
index 08fe71b..9434a47 100644
--- a/kernel/smp.c
+++ b/kernel/smp.c
@@ -1,12 +1,7 @@
#include "kernel.h"
-// 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
-// https://wiki.osdev.org/Symmetric_Multiprocessing
-// https://wiki.osdev.org/APIC_timer
+#include "smp.h"
#include <stdint.h>
-#include "smp.h"
#include "gdt.h"
#include "mem.h"
#include "interrupts.h"
@@ -14,7 +9,7 @@
#include "spinlock.h"
#include "asm_x86.h"
#include "asm_pit.h"
-#include "asm_mp.h"
+#include "asm_smp.h"
#define APIC_APICID 0x20
#define APIC_APICVER 0x30
@@ -42,7 +37,7 @@
#define TMR_PERIODIC 0x20000
#define TMR_BASEDIV (1<<20)
-// some multiprocessor shit that should move away TODO
+//
uint32_t c1,c2,c3;
volatile uint8_t proc;
uint32_t cpu_counter[SMP_MAX_PROC];
@@ -106,7 +101,6 @@ void apicIPI(uint8_t dest, uint8_t number)
void apicEnable()
{
writeAPIC(APIC_SPURIOUS,readAPIC(APIC_SPURIOUS)|0x100);
-
}
/** select mode : divisor.
@@ -138,6 +132,7 @@ uint32_t probeBusSpeed(uint32_t sel)
klog("%d MHz (%d Hz) bus speed (ticks=%d)",ticksInS/(1000000/divisor),ticksInS*divisor,ticksInS/20);
return ticksInS*divisor;
}
+
void smp_main()
{
// setup stack
@@ -147,7 +142,6 @@ void smp_main()
asm volatile("jmp kernel_ap");
}
-
void kernel_ap()
{
klog("smp local apic id: 0x%08X",apicID());
@@ -186,25 +180,10 @@ void kernel_ap()
*/
}
-
-void kernel_ap_old()
-{
- proc++;
- uint8_t p=proc;
- while(1)
- {
- cpu_counter[p]++;
-
- //lock_spin(0);
- if(cpu_counter[p]%1000000==0)klog("cpu[%d] %d",p,cpu_counter[p]);
- //lock_release(0);
-
- }
-}
-
// this will start all our application processors!
-void smp_start_aps(smp_processors *pros)
+void smp_start_aps(acpi_information *pros)
{
+ fixme("how to support IPI addressing more than 16cpus?");
// TODO: check if local APIC is present via CPUID (P6 (i686) and above)
local_apic_addr=pros->local_apic_address;
io_apic_addr=pros->io_apic_address;
@@ -216,16 +195,18 @@ void smp_start_aps(smp_processors *pros)
uint32_t speed=probeBusSpeed(4); // get bus speed (divisor: 16)
// setup apic timer
- countdown=speed/16; // tick once a second
+ countdown=speed/16/10; // tick 10 times a second
writeAPIC(APIC_TMRDIV, 0x3); // divisor 16
writeAPIC(APIC_LVT_TMR, INTERRUPT_APIC_TIMER | TMR_PERIODIC); // on interrupt 200
writeAPIC(APIC_TMRINITCNT, countdown);
+ countdown*=10;
// setup IO APIC
// PIT irq 00 -> 02 flags 0 -> 0x90
// kb irq 01 -> 01 flags ? -> 0x91
// mouse irq 12 -> 12 flags ? -> 0x92
+ fixme("use acpi info to setup IOAPIC");
irqIOAPIC(2,0x90,0x0);
irqIOAPIC(1,0x91,0x0);
irqIOAPIC(12,0x92,0x0);
diff --git a/kernel/smp.h b/kernel/smp.h
index e99c77b..7e4c66a 100644
--- a/kernel/smp.h
+++ b/kernel/smp.h
@@ -1,29 +1,21 @@
+// 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
+// https://wiki.osdev.org/Symmetric_Multiprocessing
+// https://wiki.osdev.org/APIC_timer
+//
#ifndef SMP_H
#define SMP_H
#include "kernel.h"
+#include "acpi.h"
#include <stdbool.h>
-typedef struct
-{
-
- uint8_t boot; //which processor in array is bsp
- // (boot strap processor)
-
- uint8_t processors; // total number of usable processors
-
- uint32_t local_apic_address;// same for every processor
- uint32_t io_apic_address;
-
- uint32_t local_apic_id[SMP_MAX_PROC]; // unique for every processor
-
- uint32_t flags;
-
-}smp_processors;
+#include <stdint.h>
void apicEOI();
uint32_t apicID();
-bool acpi_find(smp_processors *procdata);
-void smp_start_aps(smp_processors *pros);
+void apicIPI(uint8_t dest, uint8_t number);
+void smp_start_aps(acpi_information *pros);
#endif
diff --git a/kernel/syscalls.c b/kernel/syscalls.c
index a49429d..8007b1d 100644
--- a/kernel/syscalls.c
+++ b/kernel/syscalls.c
@@ -195,6 +195,7 @@ int syscall_execve(char *name, char **argv, char **env,int pid)
uint32_t alloc;
uint32_t entry_global=load_elf(name,&alloc);
task_set_brk(alloc);
+ fixme("fix brk!");
if(!entry_global)
{
diff --git a/linker.ld b/linker.ld
index 48a413e..a650865 100644
--- a/linker.ld
+++ b/linker.ld
@@ -11,7 +11,7 @@ SECTIONS
.multiboot BLOCK(4K) : ALIGN(4K)
{
asm/asm_start.o(.smp)
- asm/asm_mp.o
+ asm/asm_smp.o
*(.multiboot)
}