diff options
| -rw-r--r-- | Makefile | 11 | ||||
| -rw-r--r-- | README.md | 4 | ||||
| -rw-r--r-- | asm/gdt.s | 2 | ||||
| -rw-r--r-- | asm/int.s | 3 | ||||
| -rw-r--r-- | asm/mp.asm | 23 | ||||
| -rw-r--r-- | asm/mp.h | 3 | ||||
| -rw-r--r-- | asm/start.s | 3 | ||||
| -rw-r--r-- | asm/task.h | 1 | ||||
| -rw-r--r-- | fs/elf.h | 2 | ||||
| -rw-r--r-- | kernel/acpi.c | 1 | ||||
| -rw-r--r-- | kernel/fifo.h | 2 | ||||
| -rw-r--r-- | kernel/interrupts.c | 2 | ||||
| -rw-r--r-- | kernel/kernel.c | 3 | ||||
| -rw-r--r-- | kernel/kernel.h | 6 | ||||
| -rw-r--r-- | kernel/log.c | 4 | ||||
| -rw-r--r-- | kernel/mem.h | 2 | ||||
| -rw-r--r-- | kernel/scheduler.c | 5 | ||||
| -rw-r--r-- | kernel/scheduler.h | 10 | ||||
| -rw-r--r-- | kernel/smashing.h | 1 | ||||
| -rw-r--r-- | kernel/smp.c | 14 | ||||
| -rw-r--r-- | kernel/syscalls.c | 5 | ||||
| -rw-r--r-- | kernel/types.h | 3 | ||||
| -rw-r--r-- | kernel/usermode.c | 3 | ||||
| -rw-r--r-- | lib/string/string.h | 1 | ||||
| -rw-r--r-- | newlib/crt0.h | 1 | ||||
| -rw-r--r-- | newlib/syscalls.h | 1 |
26 files changed, 75 insertions, 41 deletions
@@ -32,12 +32,14 @@ CFLAGS+=-gstabs #CFLAGS+=-fno-zero-initialized-in-bss #CFLAGS+=-fdata-sections -ffunction-sections -CFLAGS+= -w # disable all warnings +#CFLAGS+= -w # disable all warnings #CFLAGS+= -Wimplicit-function-declaration #CFLAGS+= -Wextra #CFLAGS+= -Wall #CFLAGS+= -Werror -CFLAGS+= -Werror=implicit-function-declaration +#CFLAGS+= -Werror=implicit-function-declaration +CFLAGS+= -Wno-int-conversion +CFLAGS+= -Wno-incompatible-pointer-types ######## linker flags #################### LDFLAGS= @@ -49,7 +51,7 @@ ASFLAGS+=-gstabs ########## verbosity ##################3 V = 0 -CC = @echo "Compiling (i686-elf-gcc) $<..."; i686-elf-gcc +#CC = @echo "Compiling (i686-elf-gcc) $<..."; i686-elf-gcc AS = @echo "Assembling (i686-elf-as) $<..."; i686-elf-as #CC_1 = $(CCC) #CC = $(CC_$(V)) @@ -149,14 +151,17 @@ $(KERNEL_IMG): $(ASM_MULTIBOOT_OBJ) $(ASM_OBJECTS) $(OBJECTS) run-qemu: 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 4 -serial stdio run-qemu-debug: all # qemu -enable-kvm -s -S ~/temp/FoolOs/disk.img # qemu -enable-kvm -s -singlestep disk.img # qemu-system-i386 -enable-kvm -s -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 -s -S $(FOOLOS_ISO) -smp 4 -serial stdio #-enable-kvm -smp 1 monitor: + echo XDOTOOL HACK...&& sleep 0.2 && xdotool search --name "QEMU" windowsize 100 100 && echo XDOTOOL HACK END. & qemu-system-i386 -s -S $(FOOLOS_ISO) -smp 4 -monitor stdio # -serial stdio #-enable-kvm -smp 1 stop-qemu: @@ -98,6 +98,10 @@ Discontinued Features Todos ----- +* newlib reentrant struct!! +* Interrupts between BSP and APS ? +* Do not forget to flush TLB +* APIC / at least LAPIC? HPET timer? * Check 16bit stack alignment before ALL calls from assembler! * Ethernet driver E1000 / NS2000 & Networking stack * Porting (ncurses, gcc, binutils, vim, apache...) @@ -39,6 +39,4 @@ asm_setup_gdt: ret - - ret @@ -61,8 +61,6 @@ pop %eax // load original .endm - - .macro intx ack num func /* @@ -174,4 +172,3 @@ exc15: excx exception_handle_15 exc16: excx exception_handle_16 exc17: excx exception_handle_17 exc18: excx exception_handle_18 - @@ -1,7 +1,8 @@ -global smp_go +global smp_start +extern smp_main ; master boot record for application processors ;[org 0x7000] -smp_go: +smp_start: [bits 16] cli ;switch off interrupts! @@ -34,15 +35,19 @@ init_pm: call boot_32_pm ;continue booting in 32-bit protected mode boot_32_pm: - - mov eax, 1 ; semaphore - xchg eax, [LLOCK] - cmp eax,1 hlt - je $ - jmp $ ; loop forever here + jmp boot_32_pm + + ;mov eax, 1 ; semaphore + ;xchg eax, [LLOCK] + ;cmp eax,1 + ;hlt + ;je $ + ;jmp $ ; loop forever here + + ;call [0x8010] ;kernel_ap ;jump into our Kernel! + call smp_main - call [0x8010] ;kernel_ap ;jump into our Kernel! jmp $ ; should never be reached @@ -1 +1,2 @@ -void smp_go(); +/** Application processors */ +void smp_start(); diff --git a/asm/start.s b/asm/start.s index 1d881b4..26464a7 100644 --- a/asm/start.s +++ b/asm/start.s @@ -19,8 +19,7 @@ .section .smp .code16 _start_smp: -jmp . -//call smp_go # TODO: align later before going C +call smp_start # TODO: align later before going C # Declare a header as in the Multiboot Standard. We put this into a special # section so we can force the header to be in the start of the final program. diff --git a/asm/task.h b/asm/task.h new file mode 100644 index 0000000..40a8c17 --- /dev/null +++ b/asm/task.h @@ -0,0 +1 @@ +/* empty */ diff --git a/fs/elf.h b/fs/elf.h new file mode 100644 index 0000000..fe3e952 --- /dev/null +++ b/fs/elf.h @@ -0,0 +1,2 @@ + +uint32_t load_elf(char *name, uint32_t *alloc); diff --git a/kernel/acpi.c b/kernel/acpi.c index c41e91f..6d1fbc8 100644 --- a/kernel/acpi.c +++ b/kernel/acpi.c @@ -7,6 +7,7 @@ #include <stdint.h> #include <stdbool.h> #include "smp.h" +#include "lib/string/string.h" typedef struct acpi_rsdt_struct diff --git a/kernel/fifo.h b/kernel/fifo.h index fd9146c..92f3b75 100644 --- a/kernel/fifo.h +++ b/kernel/fifo.h @@ -8,7 +8,7 @@ typedef struct fifo_struct { - bool (*put)(struct fifo_stuct*,uint8_t); + bool (*put)(struct fifo_struct*,uint8_t); uint8_t (*get)(struct fifo_struct*); bool (*has)(struct fifo_struct*); void *data; // opaque data diff --git a/kernel/interrupts.c b/kernel/interrupts.c index 3ce33c4..1e209a9 100644 --- a/kernel/interrupts.c +++ b/kernel/interrupts.c @@ -39,7 +39,7 @@ static void int_install_ir(int irq, uint16_t flags, uint16_t sel, void *addr) } /** Installs the interrupt table */ -static void int_install() +void int_install() { idtd.size=sizeof(struct int_desc)*INT_MAX; uint32_t addr=(uint32_t)&idt[0]; diff --git a/kernel/kernel.c b/kernel/kernel.c index 4406ea0..9381091 100644 --- a/kernel/kernel.c +++ b/kernel/kernel.c @@ -14,7 +14,6 @@ #include "driver/mouse.h" #include "syscalls.h" -#include "types.h" #include "fifo.h" #include "mp.h" #include "interrupts.h" @@ -59,7 +58,7 @@ void kernel_main(uint32_t eax,uint32_t ebx) // https://wiki.osdev.org/Symmetric_Multiprocessing klog("Symmetric Multi Processing (SMP) start ... "); smp_log_procdata(&procdata); - //smp_start_aps(&procdata); + smp_start_aps(&procdata); klog("Vritual Memory / Paging init ... "); pdirectory *dir=vmem_init(kernel_blocks,(uint32_t)info->framebuffer_addr); diff --git a/kernel/kernel.h b/kernel/kernel.h index c214c4a..f73c116 100644 --- a/kernel/kernel.h +++ b/kernel/kernel.h @@ -2,20 +2,20 @@ * F00l 0S Central Configuration File * ********************************************/ +#include "log.h" + #ifndef FOOLOS_CONFIG_H #define FOOLOS_CONFIG_H #define BIN_INIT "/bin/init" - //#define FOOLOS_LOG_OFF + #define FIFO_MAX_RINGBUFFERS 20 #define MAX_FIFOS 20 #define MAX_FD 20 #define MAX_TASKS 10 #define MEM_PRINT_MEMORYMAP -//#define LOG_SYSCALLS - #define KMALLOC_MEM_SIZE 1024*1024*8 // 8MB for in kernel-memory #define NUMBER_SPINLOCKS 16 diff --git a/kernel/log.c b/kernel/log.c index 8ab2bf2..c7c1bb7 100644 --- a/kernel/log.c +++ b/kernel/log.c @@ -1,4 +1,3 @@ - #include "log.h" #include <stdarg.h> @@ -6,8 +5,11 @@ #include "kernel/kernel.h" #include "kernel/fifo.h" +#include "driver/serial.h" +#include "driver/timer.h" #include "lib/string/string.h" +#include "lib/printf/printf.h" static void log_string(char *str) { diff --git a/kernel/mem.h b/kernel/mem.h index c7e905e..42bf84d 100644 --- a/kernel/mem.h +++ b/kernel/mem.h @@ -1,5 +1,5 @@ -#include "types.h" #include "multiboot.h" +typedef uint32_t physical_address; physical_address* pmmngr_alloc_block (); void pmmngr_free_block (physical_address* p); uint32_t mem_init(multiboot_information *info); diff --git a/kernel/scheduler.c b/kernel/scheduler.c index 2373e36..cfd0fcd 100644 --- a/kernel/scheduler.c +++ b/kernel/scheduler.c @@ -1,6 +1,9 @@ +#include "scheduler.h" #include "kernel.h" + #include "mem.h" #include "asm/x86.h" +#include "kmalloc.h" #include "vmem.h" #include "syscalls.h" @@ -232,7 +235,7 @@ volatile uint32_t task_clone(uint32_t pid) } // init task (root of all other tasks / processes) // -volatile void scheduler_init(pdirectory *dir) +volatile void scheduler_init(void *dir) { for(int i=0;i<MAX_TASKS;i++) { diff --git a/kernel/scheduler.h b/kernel/scheduler.h index 7a5bea3..e89e8a3 100644 --- a/kernel/scheduler.h +++ b/kernel/scheduler.h @@ -1,2 +1,12 @@ +#include <stdint.h> // http://hosted.cjmovie.net/TutMultitask.htm void scheduler_init(void *pdirectory_dir); +volatile int task_get_current_pid(); +volatile void task_set_brk(uint32_t brk); +void task_syscall_worker(); +volatile uint32_t task_get_brk(); +volatile uint32_t task_exit(uint32_t pid); +volatile uint32_t task_fork(uint32_t pid); +volatile uint32_t task_clone(uint32_t pid); +volatile uint32_t task_wait(uint32_t pid); +volatile int task_reset(uint32_t pid, uint32_t entry, uint32_t stack); diff --git a/kernel/smashing.h b/kernel/smashing.h new file mode 100644 index 0000000..760b7c9 --- /dev/null +++ b/kernel/smashing.h @@ -0,0 +1 @@ +/*empty*/ diff --git a/kernel/smp.c b/kernel/smp.c index e2de6fe..619463a 100644 --- a/kernel/smp.c +++ b/kernel/smp.c @@ -24,23 +24,25 @@ uint32_t local_apic_addr; void smp_main() { - x86_cli(); // klog("local apic_addr:0x%08X",local_apic_addr); - while(1); //TODO!!! uint32_t *reg=local_apic_addr+FOOLOS_APIC_ID; - // klog("local apic id: 0x%08X",(*reg)); + //klog("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(); +// int_install(); + +// x86_sti(); - while(1); - switch_to_user_mode(); + + while(1)__asm__("hlt"); + +// switch_to_user_mode(); // int x=1/0; while(1); diff --git a/kernel/syscalls.c b/kernel/syscalls.c index f92ef4d..67ae48d 100644 --- a/kernel/syscalls.c +++ b/kernel/syscalls.c @@ -1,10 +1,12 @@ #include "lib/string/string.h" +#include "lib/printf/printf.h" #include "fs/fs.h" #include "fs/ext2.h" #include "kernel.h" #include "driver/vesa.h" #include "fifo.h" #include "fd.h" +#include "fs/elf.h" #include "driver/terminal.h" #include "driver/screen.h" #include <sys/stat.h> @@ -12,6 +14,7 @@ #include <stdbool.h> #include <stddef.h> #include "syscalls.h" +#include "scheduler.h" // TODO: use includes!!! uint64_t timer_get_ms(); @@ -57,9 +60,7 @@ int syscall_gettimeofday(struct timeval *tv, struct timezone *tz) int syscall_lseek(int file,int ptr,int dir) { - kpanic("unhandled syscall: lseek"); - return 0; } diff --git a/kernel/types.h b/kernel/types.h deleted file mode 100644 index 30abb43..0000000 --- a/kernel/types.h +++ /dev/null @@ -1,3 +0,0 @@ -#include <stdint.h> - -typedef uint32_t physical_address; diff --git a/kernel/usermode.c b/kernel/usermode.c index 7153e29..ee8b9db 100644 --- a/kernel/usermode.c +++ b/kernel/usermode.c @@ -4,7 +4,10 @@ #include "kmalloc.h" #include "asm/usermode.h" +#include "asm/x86.h" +#include "scheduler.h" #include "kernel.h" +#include "fs/elf.h" #include <stddef.h> diff --git a/lib/string/string.h b/lib/string/string.h index dd756a7..e5e4b94 100644 --- a/lib/string/string.h +++ b/lib/string/string.h @@ -4,5 +4,6 @@ void* memcpy(void* restrict dstptr, const void* restrict srcptr, int size); int strcmp(char *str1, char *str2); int strcmp_l(char *str1, char *str2, int length); +int strlen(const char* string); #endif diff --git a/newlib/crt0.h b/newlib/crt0.h new file mode 100644 index 0000000..40a8c17 --- /dev/null +++ b/newlib/crt0.h @@ -0,0 +1 @@ +/* empty */ diff --git a/newlib/syscalls.h b/newlib/syscalls.h new file mode 100644 index 0000000..40a8c17 --- /dev/null +++ b/newlib/syscalls.h @@ -0,0 +1 @@ +/* empty */ |
