diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/kernel/boot.asm | 4 | ||||
-rw-r--r-- | src/kernel/graphics/vesa.c | 28 | ||||
-rw-r--r-- | src/kernel/graphics/vesa.h | 1 | ||||
-rw-r--r-- | src/kernel/interact.asm | 8 | ||||
-rw-r--r-- | src/kernel/io/io.c | 8 | ||||
-rw-r--r-- | src/kernel/kernel.c | 2 | ||||
-rw-r--r-- | src/kernel/paging/kheap.h | 4 |
7 files changed, 32 insertions, 23 deletions
diff --git a/src/kernel/boot.asm b/src/kernel/boot.asm index 97e68f5..de5a386 100644 --- a/src/kernel/boot.asm +++ b/src/kernel/boot.asm @@ -54,7 +54,7 @@ copy_page_physical: and edx, 0x7fffffff mov cr0, edx - mov edx, 1024 + mov edx, 0x400 %include "src/kernel/gdt/gdt.asm" @@ -68,5 +68,5 @@ copy_page_physical: ; Store the stack SECTION .bss - resb 8192 ; Reserve 8KiB + resb 0x2000 ; Reserve 8KiB _sys_stack:
\ No newline at end of file diff --git a/src/kernel/graphics/vesa.c b/src/kernel/graphics/vesa.c index 8c85d49..3c55f70 100644 --- a/src/kernel/graphics/vesa.c +++ b/src/kernel/graphics/vesa.c @@ -7,6 +7,8 @@ #include "font.h" #include "../paging/paging.h" +extern page_directory_t *kernel_directory; + void switch_to_vga() { serial_write("Force switch to VGA!\n"); vesa_available = 0; @@ -31,16 +33,20 @@ struct edid_data get_edid() { } void vbe_set_mode(unsigned short mode) { - serial_write("Setting VBE mode!\n"); + serial_write("Setting VBE mode: "); serial_write_hex(mode); + serial_write("\n"); vesa_available = 0; regs16_t regs; regs.ax = 0x4F02; - regs.bx |= 0b0100000000000000; - regs.bx &= 0b0111111111111111; + regs.bx = mode; + regs.bx = mode | (1 << 14); disable_paging(); int32(0x10, ®s); enable_paging(); + + if (regs.ax != 0x004F) switch_to_vga(); + else vesa_available = 1; } uint16_t *vbe_get_modes() { @@ -54,7 +60,7 @@ uint16_t *vbe_get_modes() { regs.es = 0; regs.di = 0x7E00; disable_paging(); - int32(0x10, ®s); // CRASH + int32(0x10, ®s); enable_paging(); struct vbe_info *info = (struct vbe_info *) info_address; @@ -93,6 +99,7 @@ struct vbe_mode_info *vbe_get_mode_info(uint16_t mode) { mode_info_final->height = mode_info->height; mode_info_final->bpp = mode_info->bpp; mode_info_final->pitch = mode_info->pitch; + mode_info_final->memory_model = mode_info->memory_model; mode_info_final->framebuffer = mode_info->framebuffer; return mode_info_final; @@ -106,9 +113,11 @@ void set_optimal_resolution() { for (uint16_t *mode = video_modes; *mode != 0xFFFF; mode++) { struct vbe_mode_info *mode_info = vbe_get_mode_info(*mode); - if (mode_info->width >= highest_width /*&& + if (mode_info->width >= highest_width && (float) mode_info->width / (float) mode_info->height < 2.0 && - (mode_info->attributes & 0x80) != 0*/) { + (mode_info->attributes & 0x1) != 0x1 && + (mode_info->attributes & 0x90) != 0x90 && + mode_info->memory_model != 6) { highest = *mode; highest_width = mode_info->width; kfree(mode_info); @@ -123,6 +132,9 @@ void set_optimal_resolution() { vbe_bpp = highest_info->bpp / 8; vbe_pitch = highest_info->pitch; fb = (char *) highest_info->framebuffer; + uint32_t fb_psize = vbe_width * vbe_height * vbe_bpp; + for (uint32_t z = 0; z < fb_psize; z += 4096) + alloc_frame(get_page((uint32_t) (fb + z), 1, kernel_directory), 1, 1); serial_write("Reached set mode!\n"); vbe_set_mode(highest); @@ -143,7 +155,7 @@ void vesa_clear() { } void vesa_set_pixel(uint16_t x, uint16_t y, uint32_t color) { - unsigned pos = x * (vbe_bpp) + y * vbe_pitch; + unsigned pos = x * vbe_bpp + y * vbe_pitch; fb[pos] = color & 255; fb[pos + 1] = (color >> 8) & 255; fb[pos + 2] = (color >> 16) & 255; @@ -179,7 +191,7 @@ void vesa_draw_rectangle(int x1, int y1, int x2, int y2, int color) { } void vesa_draw_string(char *data) { - vesa_clear(); + // vesa_clear(); // PAGE FAULT?! int i = 0; while (data[i] != '\0') { vesa_draw_char(data[i], terminal_x, terminal_y); diff --git a/src/kernel/graphics/vesa.h b/src/kernel/graphics/vesa.h index d24e2d2..4c78219 100644 --- a/src/kernel/graphics/vesa.h +++ b/src/kernel/graphics/vesa.h @@ -103,6 +103,7 @@ struct vbe_mode_info { uint16_t width; uint16_t height; uint8_t bpp; + uint8_t memory_model; uint32_t framebuffer; } __attribute__ ((packed)); diff --git a/src/kernel/interact.asm b/src/kernel/interact.asm index a625f8e..42b8a6b 100644 --- a/src/kernel/interact.asm +++ b/src/kernel/interact.asm @@ -44,7 +44,7 @@ section .text reloc: use32 ; by Napalm mov [REBASE(stack32_ptr)], esp ; save 32bit stack pointer sidt [REBASE(idt32_ptr)] ; save 32bit idt pointer - ;sgdt [REBASE(gdt32_ptr)] ; save 32bit gdt pointer + sgdt [REBASE(gdt32_ptr)] ; save 32bit gdt pointer lgdt [REBASE(gdt16_ptr)] ; load 16bit gdt pointer lea esi, [esp+0x24] ; set position of intnum on 32bit stack lodsd ; read intnum into eax @@ -144,8 +144,8 @@ section .text dd 0x00000000 ; table base address gdt32_ptr: ; GDT table pointer for 32bit access - dw 0x0018 ; table limit (size) - dd 0x00130000 ; table base address + dw 0x0000 ; table limit (size) + dd 0x00000000 ; table base address idt16_ptr: ; IDT table pointer for 16bit access dw 0x03FF ; table limit (size) @@ -192,4 +192,4 @@ section .text dw gdt16_ptr - gdt16_base - 1 ; table limit (size) dd gdt16_base ; table base address - int32_end: ; end marker (so we can copy the code)
\ No newline at end of file + int32_end: ; end marker (so we can copy the code) diff --git a/src/kernel/io/io.c b/src/kernel/io/io.c index 5da4e0e..e699ae0 100644 --- a/src/kernel/io/io.c +++ b/src/kernel/io/io.c @@ -3,19 +3,19 @@ #include "io.h" uint8_t receive_b(uint16_t port) { - unsigned char value; + uint8_t value; asm volatile ("inb %1, %0" : "=a"(value) : "Nd"(port)); return value; } uint16_t receive_w(uint16_t port) { - unsigned char value; - asm volatile("inb %1,%0" : "=a"(value) : "Nd"(port)); // TODO: Fix inw error + uint16_t value; + asm volatile("inw %1, %0" : "=a"(value) : "Nd"(port)); return value; } uint32_t receive_l(uint16_t port) { - unsigned char value; + uint32_t value; asm volatile ("inb %1, %0" : "=a"(value) : "Nd"(port)); return value; } diff --git a/src/kernel/kernel.c b/src/kernel/kernel.c index cdad8dd..35dd4fd 100644 --- a/src/kernel/kernel.c +++ b/src/kernel/kernel.c @@ -24,7 +24,7 @@ void init() { void kernel_main(void) { init(); - // vesa_draw_string("This is a testing text!"); + vesa_draw_string("This is a testing text!"); if (vesa_available) { serial_write("Loaded VESA!\n"); diff --git a/src/kernel/paging/kheap.h b/src/kernel/paging/kheap.h index a1d946c..a2254be 100644 --- a/src/kernel/paging/kheap.h +++ b/src/kernel/paging/kheap.h @@ -105,8 +105,4 @@ uint32_t kmalloc_ap(uint32_t sz, uint32_t *phys); */ uint32_t kmalloc(uint32_t sz); -/** - General deallocation function. -**/ - #endif |