diff options
| -rw-r--r-- | asm/multiboot.s | 9 | ||||
| -rw-r--r-- | driver/mouse.c | 3 | ||||
| -rw-r--r-- | driver/vesa.c (renamed from xxx/video/vesa.c) | 14 | ||||
| -rw-r--r-- | driver/vesa.h (renamed from xxx/video/vesa.h) | 2 | ||||
| -rw-r--r-- | kernel/kernel.c | 7 | ||||
| -rw-r--r-- | kernel/multiboot.c | 68 | ||||
| -rw-r--r-- | kernel/multiboot.h | 10 | ||||
| -rw-r--r-- | kernel/syscalls.h | 10 | ||||
| -rw-r--r-- | kernel/vmem.c | 55 | ||||
| -rw-r--r-- | kernel/vmem.h | 2 | ||||
| -rw-r--r-- | userspace/fonts/Makefile (renamed from xxx/font/Makefile) | 0 | ||||
| -rw-r--r-- | userspace/fonts/binarize.py (renamed from xxx/font/binarize.py) | 0 | ||||
| -rw-r--r-- | userspace/fonts/binfont.src (renamed from xxx/font/binfont.src) | 0 | ||||
| -rw-r--r-- | userspace/foolshell.c | 24 |
14 files changed, 165 insertions, 39 deletions
diff --git a/asm/multiboot.s b/asm/multiboot.s index 22be3d1..1d808a3 100644 --- a/asm/multiboot.s +++ b/asm/multiboot.s @@ -27,10 +27,10 @@ .long 0 .long 0 -.long 1 #gfx_stuff -.long 800 -.long 600 -.long 24 +.long 0 #gfx_stuff 0=enable! +.long 1280 +.long 1024 +.long 32 # Currently the stack pointer register (esp) points at anything and using it may # cause massive harm. Instead, we'll provide our own stack. We will allocate @@ -58,7 +58,6 @@ _start: push %ebx #pass address of the multiboot information data structure push %eax #pass eax, so kernel can check for magic number - call kernel_main diff --git a/driver/mouse.c b/driver/mouse.c index d676f45..d4dbb56 100644 --- a/driver/mouse.c +++ b/driver/mouse.c @@ -100,6 +100,7 @@ void mouse_init() void mouse_log() { //log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"%02x / %02x / %02x ",mouse_byte[0], mouse_byte[1],mouse_byte[2]); + //TODO: ignore last packet for 4packets mouse and resync if you get out of sync if(mouse_byte[0]&0x80||mouse_byte[0]&0x40)return; //skip packet on overflow if(!(mouse_byte[0]&0x8))panic(FOOLOS_MODULE_NAME,"mouse packets out of sync!?"); // this bit is always 1, otherwise panic! @@ -128,6 +129,8 @@ void mouse_log() if(mouse_y>600)mouse_y=600; log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"%d / %d / %02x ",mouse_x, mouse_y,mouse_byte[2]); + if (mouse_byte[0] & 1)vesa_put_rect(mouse_x,600-mouse_y,10,10,0x00ffff); + else vesa_put_rect(mouse_x,600-mouse_y,10,10,0x0000ff); //PutFont('X', mouse_x,600-mouse_y, 0xffffff); } diff --git a/xxx/video/vesa.c b/driver/vesa.c index b43ca50..9b0dd55 100644 --- a/xxx/video/vesa.c +++ b/driver/vesa.c @@ -8,7 +8,7 @@ #include "lib/printf/printf.h" #define FOOLOS_MODULE_NAME "vesa" -#define FOOLSOS_SHOW_VESAMODES +//#define FOOLSOS_SHOW_VESAMODES static foolfont *deffont; static vbemodeinfo *VbeModeInfoBlock; @@ -28,7 +28,6 @@ void PutPixel(int x,int y, int color); void vesa_switch_buffers() { for(int i=0;i<800*600*2;i++)physbase[i]=buffer[i]; - } void vesa_put_rect(int x, int y, int w , int h, int color) @@ -43,7 +42,6 @@ void vesa_clear_screen() vesa_put_rect(0,0,VbeModeInfoBlock->Xres, VbeModeInfoBlock->Yres, 0xffffff); } - void vesa_set_physbase(uint32_t addr) { VbeModeInfoBlock->physbase=addr; @@ -111,11 +109,12 @@ uint32_t vesa_init(vbeinfo *info,vbemodeinfo *mode,foolfont *rawfont) return VbeModeInfoBlock->physbase; - } -void PutPixel(int x,int y, int color){ +// TODO: what will happen in 24bit mode? +void PutPixel(int x,int y, int color) +{ //do not write memory outside the screen buffer, check parameters against the VBE mode info if (x<0 || x>VbeModeInfoBlock->Xres|| y<0 || y>VbeModeInfoBlock->Yres) return; if (x) x = (x*(VbeModeInfoBlock->bpp>>3)); // get bytes (divide by 8) @@ -124,9 +123,8 @@ 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); - - } + cTemp[x+y+2] = (uint8_t)((color>>16) & 0xff); +} void PutFont(char c, int x,int y, int color) diff --git a/xxx/video/vesa.h b/driver/vesa.h index 371e944..f6e3eaf 100644 --- a/xxx/video/vesa.h +++ b/driver/vesa.h @@ -15,7 +15,6 @@ typedef struct vbeinfo_struct{ uint16_t TotalMemory; // as # of 64KB blocks }vbeinfo; - typedef struct ModeInfoBlock { uint16_t attributes; uint8_t winA,winB; @@ -43,5 +42,6 @@ typedef struct ModeInfoBlock { }vbemodeinfo; uint32_t vesa_init(vbeinfo *info,vbemodeinfo *mode,foolfont *rawfont); + void PutConsoleChar(char c, int color); void PutConsole(char *str, int color); diff --git a/kernel/kernel.c b/kernel/kernel.c index fcfb8d7..4ba76fa 100644 --- a/kernel/kernel.c +++ b/kernel/kernel.c @@ -53,6 +53,9 @@ void kernel_main(uint32_t eax,uint32_t ebx) // MULTIBOOT HEADER multiboot_information *info=get_multiboot(eax, ebx); + + // INIT VESA + vesa_init(info->vbe_control_info,info->vbe_mode_info,0); // Gather Info about other processors. (APs = application processors) // ACPI or MP smp_processors procdata; @@ -71,9 +74,9 @@ void kernel_main(uint32_t eax,uint32_t ebx) //TODO: !!! Check commented out sleep ()!!! smp_log_procdata(&procdata); smp_start_aps(&procdata,"/boot/mp.bin"); //will be copied over mbr - + // VIRTUAL MEMORY (paging) - pdirectory *dir=vmem_init(kernel_blocks); + pdirectory *dir=vmem_init(kernel_blocks,(uint32_t)info->framebuffer_addr); // PCI Bus pci_init(); diff --git a/kernel/multiboot.c b/kernel/multiboot.c index 3132717..0440b8e 100644 --- a/kernel/multiboot.c +++ b/kernel/multiboot.c @@ -1,5 +1,7 @@ +//https://www.gnu.org/software/grub/manual/multiboot/multiboot.html#Boot-information-format #define FOOLOS_MODULE_NAME "multiboot" #include "multiboot.h" +#include "driver/vesa.h" #include "lib/logger/log.h" multiboot_information* get_multiboot(uint32_t eax, uint32_t ebx) @@ -9,22 +11,74 @@ multiboot_information* get_multiboot(uint32_t eax, uint32_t ebx) multiboot_information *info; info=ebx; + log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"multiboot flags: 0x%08X",info->flags); + + if(info->flags&&1<<0) + { + log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"[0] mem_lower: %d KB",info->mem_lower); + log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"[0] mem_upper: %d KB",info->mem_upper); + } + + if(info->flags&&1<<1) + { + log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"[1] boot-device 0x%08X",info->boot_device); + } + + if(info->flags&&1<<2) + { + log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"[2] cmdline: \"%s\"",info->cmdline); + } + + if(info->flags&&1<<3) + { + log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"[3] loaded modules count: %d",info->mods_count); + } + + if(info->flags&&1<<4) + { + log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"[4/5] a.out kernel image symbols found"); + } + + if(info->flags&&1<<5) + { + log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"[4/5] ELF table: %d entries (sized %d) at 0x%08X",info->syms[0],info->syms[1],info->syms[2]); + } + + if(info->flags&&1<<6) + { + log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"[6] Found memory map"); + } + + if(info->flags&&1<<7) + { + log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"[7] Found Drives map"); + } + + if(info->flags&&1<<8) + { + log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"[8] ROM Configuration Table at: 0x%08X",info->config_table); + } + if(info->flags&&1<<9) { - log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"Loaded by: \"%s\"",info->boot_loader_name); + log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"[9] Loaded by: \"%s\"",info->boot_loader_name); } - log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"multiboot flags: 0x%08X",info->flags); + if(info->flags&&1<<10) + { + log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"[10] APM Table present."); + } - if(info->flags&&1<<0) + if(info->flags&&1<<11) { - log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"mem_lower: %d KB",info->mem_lower); - log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"mem_upper: %d KB",info->mem_upper); + log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"[11] VBE control info: 0x%08X",info->vbe_control_info); + log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"[11] VBE mode info: 0x%08X",info->vbe_mode_info); + log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"[11] VBE current mode (spec V3.0): 0x%08X",info->vbe_mode); } - if(info->flags&&1<<2) + if(info->flags&&1<<12) { - log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"cmdline: \"%s\"",info->cmdline); + log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"[12] Framebuffer (w:%d h:%d bpp:%d) at addr=0x%08X",info->framebuffer_width,info->framebuffer_height,info->framebuffer_bpp,info->framebuffer_addr); } return info; diff --git a/kernel/multiboot.h b/kernel/multiboot.h index bb31a2e..560bae4 100644 --- a/kernel/multiboot.h +++ b/kernel/multiboot.h @@ -16,7 +16,7 @@ typedef struct multiboot_information_struct uint32_t cmdline; uint32_t mods_count; uint32_t mods_addr; - uint32_t mods_syms[4]; + uint32_t syms[4]; uint32_t mmap_length; uint32_t mmap_addr; uint32_t drives_length; @@ -30,7 +30,13 @@ typedef struct multiboot_information_struct uint16_t vbe_interface_seg; uint16_t vbe_interface_off; uint16_t vbe_interface_len; - + uint64_t framebuffer_addr; + uint32_t framebuffer_pitch; + uint32_t framebuffer_width; + uint32_t framebuffer_height; + uint8_t framebuffer_bpp; + uint8_t framebuffer_type; + //color_info; }multiboot_information; diff --git a/kernel/syscalls.h b/kernel/syscalls.h index c8bc807..e88d8c3 100644 --- a/kernel/syscalls.h +++ b/kernel/syscalls.h @@ -20,3 +20,13 @@ #define SYSCALL_READDIR 63 #define SYSCALL_KILL 73 #define SYSCALL_POLL 80 + + +// new planned syscalls for graphx +// TODO: split ncurses and our syscalls?? + +// int syscall_create_win("title"); +// int syscall_kill_win(int descriptor); +// int syscall_update_win(int descriptor, *mem, *rect); +// int syscall_callback(*func, ON_MOUSE); +// int syscall_sleep(); diff --git a/kernel/vmem.c b/kernel/vmem.c index f49689f..3d3456b 100644 --- a/kernel/vmem.c +++ b/kernel/vmem.c @@ -10,6 +10,7 @@ #define FOOLOS_MODULE_NAME "vmem" static uint32_t kernel_pages; +static uint32_t fb_addr; // TODO : why is the frame not 0xfffff?? enum PAGE_PTE_FLAGS @@ -305,6 +306,57 @@ pdirectory* vmem_new_space_dir(pdirectory *copy_dir) virt_addr+=1024*4096; } + // FRAMEBUFFER IDENTITY MAP (4pages enought? ) + phys_addr=fb_addr; + virt_addr=fb_addr; + + for(int j=0;j<4;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*) kballoc(1); + 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_add_attrib (&page, I86_PTE_USER); + 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); + pt_entry_add_attrib (entry, I86_PTE_USER); + 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; + } // programm space virt_addr=0x8000000; @@ -442,8 +494,9 @@ void vmem_set_dir(pdirectory *dir) x86_set_pdbr(dir); } -pdirectory* vmem_init(uint32_t kernel_blocks) +pdirectory* vmem_init(uint32_t kernel_blocks, uint32_t frameb_addr) { + fb_addr=frameb_addr; kernel_pages=kernel_blocks/1024+1; return vmem_new_space_dir(NULL); } diff --git a/kernel/vmem.h b/kernel/vmem.h index d30c7cf..104e5ab 100644 --- a/kernel/vmem.h +++ b/kernel/vmem.h @@ -34,4 +34,4 @@ typedef struct pdirectory_struct { pd_entry m_entries[PAGES_PER_DIR]; }pdirectory; -pdirectory* vmem_init(uint32_t kernel_blocks); +pdirectory* vmem_init(uint32_t kernel_blocks,uint32_t fb_addr); diff --git a/xxx/font/Makefile b/userspace/fonts/Makefile index 2eeaf37..2eeaf37 100644 --- a/xxx/font/Makefile +++ b/userspace/fonts/Makefile diff --git a/xxx/font/binarize.py b/userspace/fonts/binarize.py index 1abb9d6..1abb9d6 100644 --- a/xxx/font/binarize.py +++ b/userspace/fonts/binarize.py diff --git a/xxx/font/binfont.src b/userspace/fonts/binfont.src index c1d9ccc..c1d9ccc 100644 --- a/xxx/font/binfont.src +++ b/userspace/fonts/binfont.src diff --git a/userspace/foolshell.c b/userspace/foolshell.c index 7247871..47d1e92 100644 --- a/userspace/foolshell.c +++ b/userspace/foolshell.c @@ -14,8 +14,6 @@ uint8_t buf_test[1024*300]; void hello() { // ascci art: http://patorjk.com/software/taag/#p=testall&f=Cards&t=Fool%20OS - // - puts( "\033c" @@ -73,6 +71,13 @@ int main(int argc, char **argv) printf("setvbuf returned %i\n",setvbuf(stdin,NULL,_IONBF,0)); + // TODO: remove test (Tryint to write directyly to frameubuff) + uint32_t *vmem=0xfd000000; + for(int i=0;i<2000;i++) + { + *vmem=0xff0000; + vmem++; + } while(1) { prompt(); @@ -88,6 +93,11 @@ int main(int argc, char **argv) buf[bl]=c; buf[bl+1]='\0'; bl++; + for(int i=0;i<20000;i++) + { + *vmem=0xff0000; + vmem++; + } } //fgets(buf,255,stdin); @@ -100,7 +110,6 @@ int main(int argc, char **argv) char **tokenize(char *buf) { - char **token; token=malloc(10*sizeof(char*)); @@ -134,9 +143,7 @@ char **tokenize(char *buf) token[c]=NULL; } - return token; - } int process(char *buf) @@ -194,9 +201,7 @@ int process(char *buf) token[t-1]=0; // printf("path token: '%s'\n",token); - - if(!strcmp(token,"..")) { left--; @@ -275,8 +280,3 @@ int process(char *buf) return 0; } - - - - - |
