Fixed a couple of little bugs

This commit is contained in:
Andrew Pamment 2016-01-30 16:50:14 +10:00
parent e15beac2d7
commit 1334b3e7f0
5 changed files with 43 additions and 26 deletions

View File

@ -768,10 +768,12 @@ void do_printf(char *fmt, va_list args) {
} }
void kprintf(char *fmt, ...) { void kprintf(char *fmt, ...) {
va_list args; if (initialized == 1) {
va_start(args, fmt); va_list args;
do_printf(fmt, args); va_start(args, fmt);
va_end(args); do_printf(fmt, args);
va_end(args);
}
} }
void update_cursor(void) { void update_cursor(void) {

39
gui.c
View File

@ -80,25 +80,41 @@ void init_gui(multiboot_info_t *mbinfo) {
serialnos = 0; serialnos = 0;
vidmode = 1; vidmode = 1;
modeinfo = (struct ModeInfoBlock *)mbinfo->vbe_mode_info; modeinfo = (struct ModeInfoBlock *)mbinfo->vbe_mode_info;
framebuffer = (char *)modeinfo->physbase; framebuffer = (unsigned char *)modeinfo->physbase;
bytesPerLine = modeinfo->pitch; bytesPerLine = modeinfo->pitch;
width = modeinfo->Xres; width = modeinfo->Xres;
height = modeinfo->Yres; height = modeinfo->Yres;
depth = modeinfo->bpp / 8; depth = modeinfo->bpp / 8;
gui_pagemap(); gui_pagemap();
backbuffer = (unsigned char *)malloc(bytesPerLine * height); backbuffer = (unsigned char *)malloc(width * height * depth);
memset(backbuffer, 0, bytesPerLine * height);
memset(backbuffer, 0, width * height * depth);
windows = (void *)0; windows = (void *)0;
//closebtn = (char *)malloc(16 * 16 * 3);
//memset(closebtn, 0, 16 * 16 * 3);
gui_convert_xpm(close_xpm, &closebtn); gui_convert_xpm(close_xpm, &closebtn);
gui_convert_xpm(pointer_xpm, &mouseptr); gui_convert_xpm(pointer_xpm, &mouseptr);
//mouseptr = (char *)malloc(32 * 32 * 3);
//memset(mouseptr, 0, 32 * 32 * 3);
gui_convert_xpm(minimize_xpm, &minimizebtn); gui_convert_xpm(minimize_xpm, &minimizebtn);
//minimizebtn = (char *)malloc(16 * 16 * 3);
//memset(minimizebtn, 0, 16 * 16 * 3);
gui_convert_xpm(defaulticon_xpm, &defaulticon); gui_convert_xpm(defaulticon_xpm, &defaulticon);
//defaulticon = (char *)malloc(64 * 64 * 3);
//memset(defaulticon, 0, 64 * 64 * 3);
wallpaper = (void *)0; wallpaper = (void *)0;
wallpaper_lock = 0; wallpaper_lock = 0;
//gui_convert_xpm(wallpaper_xpm, &wallpaper); } else {
//BochsBreak(); vidmode = 0;
} }
} }
@ -230,7 +246,6 @@ void gui_convert_xpm(char **xpm, unsigned char **buffer) {
*buffer = ptr; *buffer = ptr;
memset(ptr, 0, bwidth * bheight * 3); memset(ptr, 0, bwidth * bheight * 3);
int boffset = 0; int boffset = 0;
int match; int match;
for (i=0;i<bheight;i++) { for (i=0;i<bheight;i++) {
@ -261,22 +276,20 @@ void gui_convert_xpm(char **xpm, unsigned char **buffer) {
free(theColours); free(theColours);
for (i=0;i<charsperpixel;i++) {
for (i=0;i<colours;i++) {
free(theKeys[i]); free(theKeys[i]);
} }
free(theKeys); free(theKeys);
} }
void gui_display_pointer() { void gui_display_pointer() {
int x;
int y;
render(backbuffer, mouseptr, 32, 32, mouse_pos_x, mouse_pos_y, width, height, 3); render(backbuffer, mouseptr, 32, 32, mouse_pos_x, mouse_pos_y, width, height, 3);
//flip();
} }
void gui_draw_char(unsigned char *buffer, unsigned int dest_width, unsigned int dest_height, unsigned int x, unsigned int y, char c, unsigned int colour) { void gui_draw_char(unsigned char *buffer, unsigned int dest_width, unsigned int dest_height, unsigned int x, unsigned int y, char c, unsigned int colour) {
int i; int i;
int l;
for (i=0;i<font.Chars;i++) { for (i=0;i<font.Chars;i++) {
if (font.Index[i] == c) break; if (font.Index[i] == c) break;
} }
@ -420,9 +433,7 @@ void gui_drawtitlebar(unsigned char *buffer, unsigned int dest_width, unsigned i
} }
void gui_pagemap() { void gui_pagemap() {
if (vidmode == 1) { framebuffer = mem_map_framebuffer((unsigned int)framebuffer, bytesPerLine * height);
framebuffer = mem_map_framebuffer((unsigned int)framebuffer, bytesPerLine * height);
}
} }
void gui_find_icon_space(struct window_t *window) { void gui_find_icon_space(struct window_t *window) {

View File

@ -27,7 +27,7 @@ align 4
dd 0 dd 0
dd 1024 dd 1024
dd 768 dd 768
dd 24 dd 32
; reserve initial kernel stack space ; reserve initial kernel stack space
STACKSIZE equ 0x4000 ; that's 16k. STACKSIZE equ 0x4000 ; that's 16k.

View File

@ -91,7 +91,9 @@ void init_mem(multiboot_info_t *mbd) {
mem_end = mod->mod_end; mem_end = mod->mod_end;
} }
pages_above_kernel -= (round_up_to_page(mem_end) / PAGE_SIZE); mem_end = round_up_to_page(mem_end);
pages_above_kernel -= (mem_end / PAGE_SIZE);
#ifdef MEM_DEBUG #ifdef MEM_DEBUG
pageframes = (struct mem_frame_t *)mem_end; pageframes = (struct mem_frame_t *)mem_end;
@ -123,6 +125,8 @@ void init_mem(multiboot_info_t *mbd) {
} }
#endif #endif
mem_reserve(0x00f00000, 256); // ISA HOLE
kernel_ds_at = (unsigned char *)0; kernel_ds_at = (unsigned char *)0;
pci_mem_at = (unsigned char *)0x20000000; pci_mem_at = (unsigned char *)0x20000000;
} }
@ -523,15 +527,12 @@ unsigned char *mem_map_page(unsigned int phys, unsigned int virt, int flags) {
unsigned char *mem_map_framebuffer(unsigned int phys, unsigned int fb_length) { unsigned char *mem_map_framebuffer(unsigned int phys, unsigned int fb_length) {
unsigned int virt = 0xe0000000; unsigned int virt = 0xe0000000;
fb_length += 0x1000; int i, j;
fb_length &= 0xFFFFF000;
int i;
unsigned int start = phys & 0xFFFFF000; unsigned int start = phys & 0xFFFFF000;
framebuffer_start = start; framebuffer_start = start;
framebuffer_len = fb_length; framebuffer_len = round_up_to_page(fb_length);
for (i=start;i<start+fb_length;i+= 0x1000) { for (i=start;i<start+fb_length;i+= 0x1000) {
@ -546,6 +547,9 @@ unsigned char *mem_map_framebuffer(unsigned int phys, unsigned int fb_length) {
// table doesnt exist, create it. // table doesnt exist, create it.
pd_map[dir_entry] = (unsigned int)mem_alloc() | 3; pd_map[dir_entry] = (unsigned int)mem_alloc() | 3;
ivld_tlb(virt); ivld_tlb(virt);
for (j=0;j<1023;j++) {
pt_map[j] = 0x2;
}
} }
pt_map[table_entry] = i | 3; pt_map[table_entry] = i | 3;
ivld_tlb(virt); ivld_tlb(virt);

View File

@ -118,7 +118,7 @@ void convert_xpm(char **xpm, unsigned char **buffer) {
} }
} }
free(theColours); free(theColours);
for (i=0;i<charsperpixel;i++) { for (i=0;i<colours;i++) {
free(theKeys[i]); free(theKeys[i]);
} }
free(theKeys); free(theKeys);