diff --git a/debug.sh b/debug.sh new file mode 100755 index 0000000..bef455a --- /dev/null +++ b/debug.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +qemu-system-i386 -s -S -drive file=blankos.iso,format=raw & +sleep 1 +gdb -x gdbinit diff --git a/gdbinit b/gdbinit new file mode 100644 index 0000000..f88090d --- /dev/null +++ b/gdbinit @@ -0,0 +1,2 @@ +target remote localhost:1234 +symbol-file kernel.elf diff --git a/makefile b/makefile index 7d37811..d1580ae 100644 --- a/makefile +++ b/makefile @@ -63,7 +63,7 @@ run: iso qemu-system-i386 -drive file=blankos.iso,format=raw debug: - qemu-system-i386 -s -S -drive file=blankos.iso,format=raw + ./debug.sh clean: rm -rf $(OBJ_DIR) kernel.elf blankos.iso $(TOOLCHAIN_FILE) diff --git a/src/initrd/flower.bmp b/src/initrd/flower.bmp index 4f434c1..0d4f9c3 100644 Binary files a/src/initrd/flower.bmp and b/src/initrd/flower.bmp differ diff --git a/src/initrd/hibou.bmp b/src/initrd/hibou.bmp new file mode 100644 index 0000000..35af2b7 Binary files /dev/null and b/src/initrd/hibou.bmp differ diff --git a/src/initrd/red.bmp b/src/initrd/red.bmp new file mode 100644 index 0000000..bf748ed Binary files /dev/null and b/src/initrd/red.bmp differ diff --git a/src/initrd/smiley.bmp b/src/initrd/smiley.bmp new file mode 100644 index 0000000..6d5fc22 Binary files /dev/null and b/src/initrd/smiley.bmp differ diff --git a/src/kernel/kmain.c b/src/kernel/kmain.c index a478f71..5c52717 100644 --- a/src/kernel/kmain.c +++ b/src/kernel/kmain.c @@ -118,11 +118,6 @@ void kmain(multiboot2_info *mb_info) printf("[debug] malloc test ptr1=0x%x, ptr2=0x%x\n", ptr1, ptr2); free(ptr1); free(ptr2); - - //display_bmp(framebuffer, pitch, bpp, (uint8_t*)initrd_addr); - - //putpixel(framebuffer, pitch, bpp, i, j, yellow); - timer_install(); keyboard_install(); printf("[kernel] spawning shell...\n"); diff --git a/src/kernel/shell.c b/src/kernel/shell.c index 50af365..ec4f2f3 100644 --- a/src/kernel/shell.c +++ b/src/kernel/shell.c @@ -138,6 +138,7 @@ void shell_install() register_command("pi", program_pi); register_command("ls", program_ls); register_command("cat", program_cat); + register_command("bmp", program_bmp); for (;;) { diff --git a/src/libc/stdio.c b/src/libc/stdio.c index 3d7edb3..d583d24 100644 --- a/src/libc/stdio.c +++ b/src/libc/stdio.c @@ -15,8 +15,19 @@ extern uint32_t* framebuffer; extern uint32_t VGA_WIDTH; extern uint32_t VGA_HEIGHT; unsigned int VGA_X = 0, VGA_Y = 0; + extern int scanline; +int get_cursor_x() +{ + return VGA_X; +} + +int get_cursor_y() +{ + return VGA_Y; +} + void draw_cursor(uint32_t color) { for (int y=12; y470k + // So right now the max should be 400kb img size + char buffer[400*1000]; + int file_status = tar_file_to_buffer(initrd, filename, buffer); if (file_status != 0) { - puts("Error loading BMP\n"); + printf("Error loading file '%s'\n", filename); return; } @@ -49,7 +56,7 @@ void display_bmp(uint32_t* fb, int pitch, int bpp, uint8_t* initrd) if (bmp_header->bfType != 0x4D42) { - puts("Not a valid BMP\n"); + printf("'%s' is not a valid BMP file\n", filename); return; } @@ -57,25 +64,37 @@ void display_bmp(uint32_t* fb, int pitch, int bpp, uint8_t* initrd) int height = bmp_info->biHeight; int pixel_offset = bmp_header->bfOffBits; - if (bmp_info->biBitCount != 24) - { - puts("Not a 24-bit BMP\n"); - return; - } - + printf("%d-bit BMP, width: %d, height: %d, pixel offset: %d\n", bmp_info->biBitCount, bmp_info->biWidth, bmp_info->biHeight, bmp_header->bfOffBits); + erase_cursor(); uint8_t* pixel_data = (uint8_t*)(buffer + pixel_offset); - for (int y=0; y\n"); + return; + } + display_bmp(framebuffer, pitch, bpp, (uint8_t*)initrd_addr, argv[1]); } diff --git a/src/programs/misc.c b/src/programs/misc.c index 23a5210..fd206fa 100644 --- a/src/programs/misc.c +++ b/src/programs/misc.c @@ -73,7 +73,7 @@ void program_uptime() void program_help() { - printf("help\tpanic\twords\tprimes\trainbow\tclear\nmath\tbf\t uptime echo\t sysinfo\tconway\nrot13 morse\tcowsay time\t read\t reboot\npi\t ls\t cat\n"); + printf("help\tpanic\twords\tprimes\trainbow\tclear\nmath\tbf\t uptime echo\t sysinfo\tconway\nrot13 morse\tcowsay time\t read\t reboot\npi\t ls\t cat\t bmp\n"); } // Panic diff --git a/src/programs/programs.h b/src/programs/programs.h index 0547b68..11c799e 100644 --- a/src/programs/programs.h +++ b/src/programs/programs.h @@ -38,6 +38,6 @@ void program_reboot(); void program_ls(); void program_cat(); -void display_bmp(uint32_t* fb, int pitch, int bpp, uint8_t* initrd); +void program_bmp(); #endif