diff options
| -rw-r--r-- | boot2/stage2.asm | 2 | ||||
| -rw-r--r-- | boot2/vesa_setup_16.asm | 1 | ||||
| -rw-r--r-- | kernel/config.h | 3 | ||||
| -rw-r--r-- | kernel/console.c | 28 | ||||
| -rw-r--r-- | kernel/kernel.c | 1 | ||||
| -rw-r--r-- | kernel/mem.c | 3 | ||||
| -rw-r--r-- | kernel/vmem.c | 50 | ||||
| -rw-r--r-- | lib/logger/log.c | 8 | ||||
| -rw-r--r-- | userspace/Makefile | 1 | ||||
| -rw-r--r-- | video/vesa.c | 8 | ||||
| -rw-r--r-- | video/vesa.h | 2 |
11 files changed, 93 insertions, 14 deletions
diff --git a/boot2/stage2.asm b/boot2/stage2.asm index 44a4faf..160d75c 100644 --- a/boot2/stage2.asm +++ b/boot2/stage2.asm @@ -44,7 +44,7 @@ VESA_MODES equ 0xb000 ; do NOT overwrite yourself! be careful! VESA_MODE_INFO equ 0xc000 VESA_MODE_SELECT equ 0x4114 -CHUNKS_TO_LOAD equ 0x0f ;number of 0x8000 * 512 byte chunks to load into ram +CHUNKS_TO_LOAD equ 0x20 ;number of 0x8000 * 512 byte chunks to load into ram ; jmp boot_16 ;start boot process diff --git a/boot2/vesa_setup_16.asm b/boot2/vesa_setup_16.asm index d4c6ca2..5bee57c 100644 --- a/boot2/vesa_setup_16.asm +++ b/boot2/vesa_setup_16.asm @@ -79,6 +79,7 @@ VesaSetup: ;VESA: finally switch to the mode of choice! mov ax,0x4f02 ;vesa function: Set Mode mov bx,VESA_MODE_SELECT + int 0x10 cmp ax,0x004f je vesa_ok3 diff --git a/kernel/config.h b/kernel/config.h index a741c4a..867c693 100644 --- a/kernel/config.h +++ b/kernel/config.h @@ -9,7 +9,8 @@ #define FOOLOS_CONSOLE_AUTOBREAK // add newline automatically at end of line #define FOOLOS_LOG_OFF // do not log anything -#define FOOLOS_CONSOLE // otherwise VESA will be used! +//#define FOOLOS_CONSOLE // otherwise VESA will be used! +#define FOOLSOS_SHOW_VESAMODES #define MEM_PRINT_MEMORYMAP #define LOG_BUF_SIZE 4069 #define LOG_SYSCALLS diff --git a/kernel/console.c b/kernel/console.c index cdd2fc1..e0e70a3 100644 --- a/kernel/console.c +++ b/kernel/console.c @@ -4,12 +4,21 @@ #include "kernel/config.h" +#include "lib/logger/log.h" +#include "fs/ext2.h" + +#define FOOLOS_MODULE_NAME "console" #ifdef FOOLOS_CONSOLE #include "video/console.h" -void console_init(){scr_clear();} +void console_init(){ + scr_clear(); + log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"init console"); + int inode_nr=ext2_filename_to_inode(EXT2_RAM_ADDRESS,"/binfont.bin"); + if(inode_nr!=-1)ext2_inode_content(EXT2_RAM_ADDRESS,inode_nr,0x8000000,0xffff); // load font; +} void console_del_char(){scr_backspace();} void console_put_char_gray(char c){scr_put_char(c,SCR_GRAY2);} void console_put_char_white(char c){scr_put_char(c,SCR_WHITE);} @@ -24,8 +33,23 @@ void console_put_str_red(char *s){scr_put_string(s,SCR_RED);} #include "video/vesa.h" -void console_init(){uint32_t vesa_physbase=vesa_init(0x9300,0x9400,0x168000+512);} +void console_init(){ + + int inode_nr=ext2_filename_to_inode(EXT2_RAM_ADDRESS,"/binfont.bin"); + if(inode_nr!=-1)ext2_inode_content(EXT2_RAM_ADDRESS,inode_nr,0x1300000,0xffff); // load font; + uint32_t vesa_physbase=vesa_init(0xb000,0xc000,0x1300000); +} + +void console_del_char(char c){PutConsoleChar('*',0xffffff);} void console_put_char(char c){PutConsoleChar(c,0xffffff);} +void console_put_char_gray(char c){PutConsoleChar(c,0xffffff);} +void console_put_char_white(char c){PutConsoleChar(c,0xffffff);} +void console_put_char_green(char c){PutConsoleChar(c,0xffffff);} +void console_put_char_red(char c){PutConsoleChar(c,0xffffff);} void console_put_str(char *s){PutConsole(s,0xffffff);} +void console_put_str_gray(char *s){PutConsole(s,0xffffff);} +void console_put_str_white(char *s){PutConsole(s,0xffffff);} +void console_put_str_green(char *s){PutConsole(s,0xffffff);} +void console_put_str_red(char *s){PutConsole(s,0xffffff);} #endif diff --git a/kernel/kernel.c b/kernel/kernel.c index 82136c0..3bf238e 100644 --- a/kernel/kernel.c +++ b/kernel/kernel.c @@ -91,7 +91,6 @@ void kernel_main(uint32_t initial_stack, int mp) // // Initialize Multitasking // - task_init(dir); //; this will never return! } diff --git a/kernel/mem.c b/kernel/mem.c index 62851c9..4e7d392 100644 --- a/kernel/mem.c +++ b/kernel/mem.c @@ -239,7 +239,8 @@ void mem_init(uint16_t *memmap,uint16_t entries) // here is somewhere our kernel stuff. // reserve 4Mb (0x100000-0x500000) for kernel and ext2 img - pmmngr_deinit_region(0x0,0x500000); + // even more! + pmmngr_deinit_region(0x0,0x1400000); // and here is the memory map that we JUST created! pmmngr_deinit_region(0x500000,mem_array_size*4+PMMNGR_BLOCK_SIZE); diff --git a/kernel/vmem.c b/kernel/vmem.c index a909b1a..24a2f92 100644 --- a/kernel/vmem.c +++ b/kernel/vmem.c @@ -248,7 +248,55 @@ pdirectory* vmem_new_space_dir(pdirectory *copy_dir) uint32_t virt_addr=0; // first pages are identity mapped - for(int j=0;j<3;j++) + for(int j=0;j<5;j++) + { + + // this is the table for our page directory. It maps 1024*4096 bytes + ptable* table; + + // create new tables on init + if(copy_dir==NULL) + { + // alloc space for our new table + table = (ptable*) pmmngr_alloc_block (); + if (!table)panic(FOOLOS_MODULE_NAME,"unable to alloc table"); + + //! idenitity mapping + for (int i=0, frame=phys_addr, virt=virt_addr; i<1024; i++, frame+=4096, virt+=4096) + { + //! 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 + table->m_entries [PAGE_TABLE_INDEX (virt) ] = page; + } + + pd_entry* entry = &dir->m_entries [PAGE_DIRECTORY_INDEX (virt_addr) ]; + *entry=0; + pd_entry_add_attrib (entry, I86_PDE_PRESENT); + pd_entry_add_attrib (entry, I86_PDE_WRITABLE); + pd_entry_set_frame (entry, (physical_addr)table); + + } + // otherwise simply take existing stuff from pdir 0 + else + { + dir->m_entries[PAGE_DIRECTORY_INDEX(virt_addr)]= + copy_dir->m_entries[PAGE_DIRECTORY_INDEX(virt_addr)]; + + } + + phys_addr+=1024*4096; + virt_addr+=1024*4096; + } + + phys_addr=0xFc000000; + virt_addr=0xFc000000; + // vesa + for(int j=0;j<5;j++) { // this is the table for our page directory. It maps 1024*4096 bytes diff --git a/lib/logger/log.c b/lib/logger/log.c index 8d69fc3..7d7bc58 100644 --- a/lib/logger/log.c +++ b/lib/logger/log.c @@ -1,19 +1,20 @@ #define FOOLOS_MODULE_NAME "log" #include <stdarg.h> +#include <stdbool.h> #include "log.h" #include "kernel/config.h" #include "kernel/console.h" #include "lib/printf/printf.h" #include "lib/int/stdint.h" -#include "lib/bool/bool.h" #include "kernel/timer.h" static char buffer[LOG_BUF_SIZE]; static int first=0; static int last=0; +static bool init=false; void log(char *module_name, int log_level, char *format_string, ...) { @@ -40,7 +41,8 @@ void log(char *module_name, int log_level, char *format_string, ...) va_end(va); tfp_sprintf(buf_log,"%s %s: %s\n",buf_time,module_name,buf_info); - console_put_str_gray(buf_log); + + if(init)console_put_str_gray(buf_log); for(int i=0;buf_log[i]!=0;i++) { @@ -76,5 +78,7 @@ void log_log() console_put_char_gray(buffer[i]); } + + init=true; } diff --git a/userspace/Makefile b/userspace/Makefile index d3f47bc..f112e67 100644 --- a/userspace/Makefile +++ b/userspace/Makefile @@ -23,6 +23,7 @@ ext2.img: $(PROGS) cp $^ mnt/bin echo "++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>---.+++++++..+++.>>.<-.<.+++.------.--------.>>+.>++." > mnt/home/miguel/hello.brain # cp ~/temp/fool-os-stuff/binutils-build-host-foolos/binutils/readelf mnt/bin + cp ../font/binfont.bin mnt/ cp ~/temp/fool-os-stuff/ncurses-5.9/progs/tput mnt/bin mkdir -p mnt/etc echo "127.0.0.1 localhost" > mnt/etc/hosts diff --git a/video/vesa.c b/video/vesa.c index 416a893..8952f81 100644 --- a/video/vesa.c +++ b/video/vesa.c @@ -97,7 +97,7 @@ uint32_t vesa_init(vbeinfo *info,vbemodeinfo *mode,foolfont *rawfont) mode->Xres, mode->Yres, mode->banks, mode->attributes); log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"bpp: %d / physbase: 0x%x", mode->bpp,mode->physbase); -/* + // vesa modes // todo: take segment from vbeinfo! #ifdef FOOLSOS_SHOW_VESAMODES @@ -105,12 +105,11 @@ uint32_t vesa_init(vbeinfo *info,vbemodeinfo *mode,foolfont *rawfont) while(*modeptr!=0xffff&&*modeptr!=0) { - log(FOOLOS_MODULE_NAME,FOOLOS_LOG_DEBUG,"mode supported : 0x%x", (*modeptr)); - scr_put_hex(*modeptr); + log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"mode supported : 0x%X", (*modeptr)); modeptr++; } #endif -*/ + return VbeModeInfoBlock->physbase; @@ -127,6 +126,7 @@ void PutPixel(int x,int y, int color){ cTemp[x+y] = (uint8_t)(color & 0xff); cTemp[x+y+1] = (uint8_t)((color>>8) & 0xff); //cTemp[x+y+2] = (uint8_t)((color>>16) & 0xff); + } diff --git a/video/vesa.h b/video/vesa.h index 1f6c12e..371e944 100644 --- a/video/vesa.h +++ b/video/vesa.h @@ -1,4 +1,4 @@ -#include "lib/int/stdint.h" +#include <stdint.h> typedef struct foolfont_struct { |
