Making stuff work again
This commit is contained in:
parent
086eba4ea4
commit
e472492ee3
2 changed files with 57 additions and 56 deletions
7
Makefile
7
Makefile
|
@ -6,12 +6,13 @@ build/start32.o: build/ src/start32.asm
|
|||
fasm src/start32.asm build/start32.o
|
||||
build/kernel-i386.elf: build/start32.o
|
||||
tcc -m32 -nostdlib -Wl,-Ttext,0x100000 -o build/kernel-i386.elf src/*.c build/start32.o
|
||||
image: build/kernel-i386.elf mount
|
||||
cp build/kernel-i386.elf mnt/
|
||||
sync
|
||||
|
||||
qemu-multiboot: build/kernel-i386.elf
|
||||
qemu-system-i386 -kernel build/kernel-i386.elf -serial stdio
|
||||
qemu-image: build/kernel-i386.elf mount
|
||||
cp build/kernel-i386.elf mnt/
|
||||
sync
|
||||
qemu-image: image
|
||||
qemu-system-i386 koalemos.img -serial stdio
|
||||
|
||||
mount: koalemos.img mnt/
|
||||
|
|
106
src/kernel.c
106
src/kernel.c
|
@ -4,72 +4,72 @@
|
|||
#include "xtoa.h"
|
||||
|
||||
static inline void outb(unsigned short port, unsigned char val) {
|
||||
asm volatile ("outb %0, %1" : : "a"(val), "Nd"(port) : "memory");
|
||||
asm volatile ("outb %0, %1" : : "a"(val), "Nd"(port) : "memory");
|
||||
}
|
||||
static inline unsigned char inb(unsigned short port) {
|
||||
unsigned char ret;
|
||||
asm volatile("inb %1, %0" : "=a"(ret) : "Nd"(port) : "memory");
|
||||
return ret;
|
||||
unsigned char ret;
|
||||
asm volatile("inb %1, %0" : "=a"(ret) : "Nd"(port) : "memory");
|
||||
return ret;
|
||||
}
|
||||
|
||||
void kmain (unsigned int mbootmagick, multiboot_info_t* mbootinfo) {
|
||||
|
||||
// Cursor disabling
|
||||
outb(0x3D4, 0x0A);
|
||||
outb(0x3D5, 0x20);
|
||||
// Cursor disabling
|
||||
outb(0x3D4, 0x0A);
|
||||
outb(0x3D5, 0x20);
|
||||
|
||||
int serial_initialized = serial_init();
|
||||
serial_write_string("\n=== KoalemOS ===\n");
|
||||
int serial_initialized = serial_init();
|
||||
serial_write_string("\n=== KoalemOS ===\n");
|
||||
|
||||
// Check multiboot header
|
||||
if (mbootmagick != MULTIBOOT_BOOTLOADER_MAGIC) {
|
||||
return;
|
||||
}
|
||||
// Check multiboot header
|
||||
if (mbootmagick != MULTIBOOT_BOOTLOADER_MAGIC) {
|
||||
return;
|
||||
}
|
||||
|
||||
serial_write_string("\nMultiboot flags: ");
|
||||
serial_write_string(itoa(mbootinfo->flags, 2));
|
||||
serial_write_string("\nMultiboot flags: ");
|
||||
serial_write_string(itoa(mbootinfo->flags, 2));
|
||||
|
||||
serial_write_string("\nMultiboot flags: ");
|
||||
serial_write_string(itoa(mbootinfo->flags, 2));
|
||||
// Check videomode
|
||||
if (mbootinfo->flags & MULTIBOOT_INFO_VBE_INFO) {
|
||||
serial_write_string("\nVBE Mode: 0x");
|
||||
serial_write_string(itoa(mbootinfo->vbe_mode, 16));
|
||||
}
|
||||
|
||||
// Check videomode
|
||||
if (mbootinfo->flags & MULTIBOOT_INFO_VBE_INFO) {
|
||||
serial_write_string("\nVBE Mode: 0x");
|
||||
serial_write_string(itoa(mbootinfo->vbe_mode, 16));
|
||||
}
|
||||
if (!(mbootinfo->flags & MULTIBOOT_INFO_FRAMEBUFFER_INFO)) {
|
||||
serial_write_string("\nVideo info not available");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(mbootinfo->flags & MULTIBOOT_INFO_FRAMEBUFFER_INFO)) {
|
||||
serial_write_string("\nVideo info not available");
|
||||
return;
|
||||
}
|
||||
serial_write_string("\nFramebuffer: ");
|
||||
serial_write_string("\n Address: 0x");
|
||||
serial_write_string(ultoa(mbootinfo->framebuffer_addr, 16));
|
||||
|
||||
serial_write_string("\nFramebuffer: ");
|
||||
serial_write_string("\n Address: 0x");
|
||||
serial_write_string(ultoa(mbootinfo->framebuffer_addr, 16));
|
||||
serial_write_string("\n Dimensions: ");
|
||||
serial_write_string(itoa(mbootinfo->framebuffer_width, 10));
|
||||
serial_write_string("X");
|
||||
serial_write_string(itoa(mbootinfo->framebuffer_height, 10));
|
||||
serial_write_string("x");
|
||||
serial_write_string(itoa(mbootinfo->framebuffer_bpp, 10));
|
||||
serial_write_string("\n Pitch: ");
|
||||
serial_write_string(itoa(mbootinfo->framebuffer_pitch, 10));
|
||||
serial_write_string("\n RPos:");
|
||||
serial_write_string(itoa(mbootinfo->framebuffer_red_field_position, 10));
|
||||
serial_write_string("\n GPos:");
|
||||
serial_write_string(itoa(mbootinfo->framebuffer_green_field_position, 10));
|
||||
serial_write_string("\n BPos:");
|
||||
serial_write_string(itoa(mbootinfo->framebuffer_blue_field_position, 10));
|
||||
|
||||
serial_write_string("\n Dimensions: ");
|
||||
serial_write_string(itoa(mbootinfo->framebuffer_width, 10));
|
||||
serial_write_string("X");
|
||||
serial_write_string(itoa(mbootinfo->framebuffer_height, 10));
|
||||
serial_write_string("x");
|
||||
serial_write_string(itoa(mbootinfo->framebuffer_bpp, 10));
|
||||
serial_write_string("\n Pitch: ");
|
||||
serial_write_string(itoa(mbootinfo->framebuffer_pitch, 10));
|
||||
serial_write_string("\n RPos:");
|
||||
serial_write_string(itoa(mbootinfo->framebuffer_red_field_position, 10));
|
||||
serial_write_string("\n GPos:");
|
||||
serial_write_string(itoa(mbootinfo->framebuffer_green_field_position, 10));
|
||||
serial_write_string("\n BPos:");
|
||||
serial_write_string(itoa(mbootinfo->framebuffer_blue_field_position, 10));
|
||||
initfb(mbootinfo->framebuffer_addr, mbootinfo->framebuffer_width, mbootinfo->framebuffer_height, mbootinfo->framebuffer_bpp, mbootinfo->framebuffer_pitch, mbootinfo->framebuffer_red_field_position, mbootinfo->framebuffer_green_field_position, mbootinfo->framebuffer_blue_field_position);
|
||||
int x, y, i;
|
||||
unsigned char c = 0;
|
||||
for(;;) {
|
||||
for(y=0;y<768;y++) {
|
||||
for(x=0;x<1024;x++) {
|
||||
putpixel(x, y, c, c, c, 0xff);
|
||||
}
|
||||
}
|
||||
c+=4;
|
||||
}
|
||||
|
||||
initfb(mbootinfo->framebuffer_addr, mbootinfo->framebuffer_width, mbootinfo->framebuffer_height, mbootinfo->framebuffer_bpp, mbootinfo->framebuffer_pitch, mbootinfo->framebuffer_red_field_position, mbootinfo->framebuffer_green_field_position, mbootinfo->framebuffer_blue_field_position);
|
||||
|
||||
int x, y;
|
||||
for (y=0; y<mbootinfo->framebuffer_height;y++) {
|
||||
for (x=0; x<mbootinfo->framebuffer_width;x++) {
|
||||
putpixel(x, y, 0, 255*x/mbootinfo->framebuffer_width, 255*y/mbootinfo->framebuffer_height, 0xff);
|
||||
}
|
||||
}
|
||||
|
||||
serial_write_string("\nExecution finished, halting...");
|
||||
serial_write_string("\nExecution finished, halting...");
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue