From 50c7bdbe826b5b425748a11273d14e3aed2ce851 Mon Sep 17 00:00:00 2001 From: Michal Idziorek Date: Wed, 27 Aug 2014 03:20:16 +0200 Subject: many changes and adaptions and VESA mode !! --- kernel/console.c | 6 +++ kernel/font.h | 0 kernel/kernel.c | 26 +++++++++++-- kernel/mem.c | 14 +++++-- kernel/vesa.c | 111 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ kernel/x86.h | 11 +++--- 6 files changed, 157 insertions(+), 11 deletions(-) create mode 100644 kernel/font.h create mode 100644 kernel/vesa.c (limited to 'kernel') diff --git a/kernel/console.c b/kernel/console.c index 42dc5d0..b1a9125 100644 --- a/kernel/console.c +++ b/kernel/console.c @@ -1,5 +1,7 @@ #include "console.h" +#define FOOLOS_CONSOLE + static int posx=0; static int posy=0; @@ -7,9 +9,11 @@ static int posy=0; void print_char_col(int x, int y, char c, char col) { +#ifdef FOOLOS_CONSOLE char* video_mem=(char *)SCR_VIDEOMEM+(x+y*SCR_REAL_WIDTH)*2; video_mem[0]=c; video_mem[1]=col; +#endif } void print_char(int x, int y, char c) @@ -67,6 +71,7 @@ void scr_put_string_nl(char *str) void scr_nextline() { +#ifdef FOOLOS_CONSOLE int i,x; posx=0; @@ -95,6 +100,7 @@ void scr_nextline() posy--; } +#endif } void scr_put_char(char ch,char col) diff --git a/kernel/font.h b/kernel/font.h new file mode 100644 index 0000000..e69de29 diff --git a/kernel/kernel.c b/kernel/kernel.c index 16028fd..f1ba6b7 100644 --- a/kernel/kernel.c +++ b/kernel/kernel.c @@ -42,7 +42,8 @@ void kernel_main() //timer_init(); // we know that here the bootloader placed the mamory map! - mem_init(0x7c00+0x140); + mem_init(0x7c00+0x400,*((uint16_t *)(0x7c00+0x600))); + //mem_init(0x9000); // we know that here the bootloader placed the mamory map! vmem_init(); @@ -78,8 +79,11 @@ void kernel_main() // pci pci_init(); + // vesa init + vesa_init(0x8300,0x8400); + // floppy - floppy_init(); + //floppy_init(); scr_put_string_nl(""); @@ -87,11 +91,27 @@ void kernel_main() shell_init(); // kernel main loop + uint8_t t=0; + +// while(1) + // { + //} + + while(1) { - + int i; + int j; + for(i=0;i<1024;i++) + + for(j=0;j<768;j++) + { + PutPixel(i,j,t); + } + t+=125; } + } diff --git a/kernel/mem.c b/kernel/mem.c index 28e05eb..68880be 100644 --- a/kernel/mem.c +++ b/kernel/mem.c @@ -205,20 +205,27 @@ void mem_test(int start, int end, int steps) } */ -void mem_init(uint16_t *memmap) +void mem_init(uint16_t *memmap,uint16_t entries) { + scr_put_string("mem: the memory map contains "); + scr_put_hex(entries); + scr_put_string_nl(" entries."); + + // hardcoded memory bitmap!!??! _mmngr_memory_map=0x9000; mem_free_blocks=0; pmmngr_init (); // count available memory uint32_t avail_mem=0; + int i; //print memory map and init regions! - while(1) + for(i=0;iXres); + scr_put_string(" x "); + scr_put_hex(mode->Yres); + scr_put_string_nl(""); + scr_put_string("vesa: selected mode banks: "); + scr_put_hex(mode->banks); + scr_put_string_nl(""); + scr_put_string("vesa: attribs: "); + scr_put_hex(mode->attributes); + scr_put_string_nl(""); + scr_put_string("vesa: physbase: "); + scr_put_hex32(mode->physbase); + scr_put_string_nl(""); + scr_put_string("vesa: bpp: "); + scr_put_hex(mode->bpp); + scr_put_string_nl(""); +/* +uint8_t *videomem=mode->physbase; +for(i=0;i<0xffffff;i++) +{ + videomem[i]=i; +} +*/ + + VbeModeInfoBlock=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) + if (y) y = (y*VbeModeInfoBlock->pitch); + uint8_t *cTemp=VbeModeInfoBlock->physbase; + 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/kernel/x86.h b/kernel/x86.h index 1e80405..2b7572c 100644 --- a/kernel/x86.h +++ b/kernel/x86.h @@ -3,12 +3,13 @@ #include "kernel.h" -#define X86_IRQ_BEGIN asm("cli\npusha"); -#define X86_IRQ_END asm("mov $0x20, %al\nout %al, $0x20\npopa\nsti\nleave\niret"); -//#define X86_IRQ_BEGIN asm("pusha"); -//#define X86_IRQ_END asm("mov $0x20, %al\nout %al, $0x20\npopa\nleave\niret"); -// +// todo: cli/sti?? +// http://wiki.osdev.org/Interrupt_Service_Routines +// Black Magic: Strongly Discouraged! +#define X86_IRQ_BEGIN asm("\npusha"); +#define X86_IRQ_END asm("mov $0x20, %al\nout %al, $0x20\npopa\nleave\niret"); + void x86_outb(int port, uint8_t data); uint8_t x86_inb(int port); void x86_outw(int port, uint16_t data); -- cgit v1.2.3