diff options
| author | Michal Idziorek <m.i@gmx.at> | 2014-10-24 13:59:06 +0200 |
|---|---|---|
| committer | Michal Idziorek <m.i@gmx.at> | 2014-10-24 13:59:06 +0200 |
| commit | 55b3af4989e7908472d1dbfb3fe1bdd6e43262e1 (patch) | |
| tree | 98bc925761d5b75380b0f5e0d87f286d964d720f | |
| parent | 831df8bcb2717442a41464533bacf0a58a4af0ce (diff) | |
moved kernel and ramimage to 0x100000 successfully
chs is broken however and only the first chunk seems to get loaded
properly :(
| -rw-r--r-- | Makefile | 6 | ||||
| -rw-r--r-- | boot/disk_load_16.asm | 6 | ||||
| -rw-r--r-- | boot/kernel_entry.asm | 1 | ||||
| -rw-r--r-- | boot/stage2.asm | 63 | ||||
| -rw-r--r-- | fs/fs.c | 2 | ||||
| -rw-r--r-- | fs/fs.h | 2 | ||||
| -rw-r--r-- | kernel/config.h | 2 | ||||
| -rw-r--r-- | kernel/kernel.c | 10 | ||||
| -rw-r--r-- | kernel/syscalls.c | 2 |
9 files changed, 59 insertions, 35 deletions
@@ -16,7 +16,7 @@ USB_STICK=/dev/sdf #take care! #here our kernel will be loaded by the bootloader. -KERNEL_START=0x18000 +KERNEL_START=0x100000 #use our cross compiler CC=i686-elf-gcc @@ -102,8 +102,8 @@ FoolOS.img: $(MBR) $(STAGE2) kernel.bin $(FILLUP) FoolData.img cp $(FILLUP) $@ dd if=$(MBR) of=$@ bs=512 seek=0 conv=notrunc dd if=$(STAGE2) of=$@ bs=512 seek=1 conv=notrunc - dd if=kernel.bin of=$@ bs=512 seek=10 conv=notrunc #will end up at 0x18000 in ram (this is what the booloader starts loading secotr: 10) - dd if=FoolData.img of=$@ bs=512 seek=842 conv=notrunc + dd if=kernel.bin of=$@ bs=512 seek=10 conv=notrunc #will end up at 0x100000 in ram (this is what the booloader starts loading secotr: 10) + dd if=FoolData.img of=$@ bs=512 seek=842 conv=notrunc #data starts at 0x168000 binfont.img: binfont.bin cat $^ > $@ diff --git a/boot/disk_load_16.asm b/boot/disk_load_16.asm index 78aa22b..5eb43a9 100644 --- a/boot/disk_load_16.asm +++ b/boot/disk_load_16.asm @@ -15,6 +15,8 @@ STR_SPACE: STR_OK: db "Kernel Loaded",0 +STR_PROGRESS: + db ".",0 bpbSectorsPerTrack: dw 18 @@ -189,9 +191,9 @@ disk_read_error: disk_load_finish: - mov bx, STR_OK + mov bx, STR_PROGRESS call print_string - call print_nextline +; call print_nextline popa ret diff --git a/boot/kernel_entry.asm b/boot/kernel_entry.asm index 3b1fb26..53f63ad 100644 --- a/boot/kernel_entry.asm +++ b/boot/kernel_entry.asm @@ -9,7 +9,6 @@ [bits 32] [extern kernel_main] - push 0x1 cmp eax,1 diff --git a/boot/stage2.asm b/boot/stage2.asm index 3fde5c1..9dd00bc 100644 --- a/boot/stage2.asm +++ b/boot/stage2.asm @@ -47,8 +47,15 @@ VESA_MODE_SELECT equ 0x4114 jmp boot_16 ;start boot process ;;SOME Global Data, mainly info/error strings +FILL: + times 32 db 0x66 + BOOT_DRIVE: db 0xff + +LOADER_TARGET: + dd 0x100000 ;here we will put our image + KERNEL_CHUNK: dw 0x1 STR_VERSION: @@ -124,13 +131,21 @@ boot_16: call BiosGetMemoryMap ; this will also put the number of entries ; of the memory map at MEMMAP_SIZE_OFFSET -kernel_load: ; Load the KERNEL Image mov bx, STR_LOAD call print_string call print_nextline + +kernel_load: + call disk_load_16 + ; init vesa on last iteration! + mov ax,[KERNEL_CHUNK] + cmp ax,0x5 + jne skip_vesa_init + call VesaSetup + skip_vesa_init: call switch_to_pm ; @@ -140,53 +155,61 @@ boot_32_pm: ;Fast A20 Gate: ;http://wiki.osdev.org/A20_Line - in al, 0x92 or al, 2 out 0x92, al - ; tell the world we are protected - mov ebx,STR_PM - mov ecx,2*23*80 - call print_string_pm + ;mov ebx,STR_PM + ;mov ecx,2*23*80 + ;call print_string_pm + + ;increment chunk number + mov ax,[KERNEL_CHUNK] + add ax,1 + mov [KERNEL_CHUNK],ax - push edx ; persist edx for some reason!? + ;check if all chunkgs loaded (hardcoded to 0x6 for a start) + cmp ax,0x6 + je finish_load + ; show KERNEL CHUNK value + push edx ; persist edx for some reason!? mov edx,0 mov dx,[KERNEL_CHUNK] mov ecx,2*24*80 call print_hex_pm + pop edx + ; here we actually do copy the chunk into ext mem! + mov eax,[LOADER_TARGET] + mov ebx,0x18000 - ; here we should move the chunk away or stop the loop if everything loaded. - mov ax,[KERNEL_CHUNK] - add ax,1 - mov [KERNEL_CHUNK],ax + copy_next_byte: - ; here we should copy the chunk into ext mem! + mov ecx,[ebx] + mov [eax],ecx + inc eax + inc ebx + cmp ebx, 0x90000 + jne copy_next_byte + mov [LOADER_TARGET],eax ;persist next target address ; and now go back to real! (first 16bit protected!) - cmp edx,0x20 - je finish_load - pop edx - - - jmp CODE16_SEG:reinit_16 + finish_load: ; - call VesaSetup ; call kernel! mov eax,0 ;tell the kernel ; we are the booting processor - call 0x18000 ;jump into our Kernel! + call 0x100000 ;jump into our Kernel! [bits 16] @@ -7,7 +7,7 @@ int fs_readdir(const char *name,fs_dirent *dirs,int max) { - return ext2_read_dir(0x80800, name,dirs,max); // TODO: hardcoded, fix this + return ext2_read_dir(EXT2_RAM_ADDRESS, name,dirs,max); // TODO: hardcoded, fix this } @@ -1,6 +1,6 @@ #ifndef FOOLOS_FS #define FOOLOS_FS - +#define EXT2_RAM_ADDRESS 0x168800 enum FS_FILE_TYPE{ FS_FILE_TYPE_DIR = 1, diff --git a/kernel/config.h b/kernel/config.h index 019ef34..bbe0672 100644 --- a/kernel/config.h +++ b/kernel/config.h @@ -1,4 +1,4 @@ //#define FOOLOS_COMPILE_FLOPPY #define FOOLOS_CONSOLE_AUTOBREAK //add newline automatically at end of line -#define FOOLOS_LOG_OFF // do not log anythong +//#define FOOLOS_LOG_OFF // do not log anythong diff --git a/kernel/kernel.c b/kernel/kernel.c index 208d1cd..4452e3e 100644 --- a/kernel/kernel.c +++ b/kernel/kernel.c @@ -8,6 +8,8 @@ #include "smp.h" #include "time.h" +#include "fs/fs.h" + #ifdef FOOLOS_COMPILE_FLOPPY #include "floppy.h" #endif @@ -46,8 +48,6 @@ volatile int16_t mouse_y; void kernel_main(uint32_t initial_stack, int mp) { - - /// TODO /////// SYMMETRIC MULTIPROCESSING, APS get caought here, move it away /// // catch the APs (Application Processors) @@ -94,7 +94,7 @@ void kernel_main(uint32_t initial_stack, int mp) // this function returns the physical base address of // our video memory // - uint32_t vesa_physbase=vesa_init(0x8300,0x8400,0x80000+0x200); + uint32_t vesa_physbase=vesa_init(0x8300,0x8400,0x168000+512);//0x80000+0x200); // self-log message of logger :P log_log(); @@ -196,8 +196,8 @@ void kernel_main(uint32_t initial_stack, int mp) // //vesa_init_doublebuff(); - ext2_check(0x80800); - syscall_execve(15,0,0); + ext2_check(EXT2_RAM_ADDRESS); + //syscall_execve(15,0,0); // Just hang around here, if its reached. // we do our tasks anyway. on the next clock tick. diff --git a/kernel/syscalls.c b/kernel/syscalls.c index 564a604..b151627 100644 --- a/kernel/syscalls.c +++ b/kernel/syscalls.c @@ -47,7 +47,7 @@ int syscall_readdir(const char *name,fs_dirent *dirs,int max) int syscall_execve(char *name, char **argv, char **env) { - ext2_inode_content(0x80800,name,0x100000,0x100000); + ext2_inode_content(EXT2_RAM_ADDRESS,name,0x800000,0x100000); // autorun "user-space" prog asm("push $0x100000"); |
