Compare commits

..

No commits in common. "086eba4ea4a3ad5d14b6b73457a5b1b140ae3092" and "1a9201b529dd2f5d650817aa91e4e3e7aab627b3" have entirely different histories.

5 changed files with 69 additions and 93 deletions

View file

@ -1,24 +0,0 @@
#include "framebuffer.h"
static unsigned long fb_address;
static unsigned long fb_pitch;
static unsigned short fb_width, fb_height;
static unsigned char fb_bpp, fb_bytespp;
static unsigned char fb_rpos, fb_bpos, fb_gpos;
void initfb(unsigned long addr, unsigned short w, unsigned short h, unsigned char bpp, unsigned long pitch, unsigned char rpos, unsigned char gpos, unsigned char bpos) {
fb_address = addr;
fb_pitch = pitch;
fb_width = w;
fb_height = h;
fb_bpp = bpp;
fb_bytespp = bpp/8;
fb_rpos = rpos;
fb_gpos = gpos;
fb_bpos = bpos;
}
void putpixel(unsigned short x, unsigned short y, unsigned char r, unsigned char g, unsigned char b, unsigned char a) {
if (x>fb_width || y> fb_height) return;
*((unsigned long *)(fb_address + y*fb_pitch + x*fb_bytespp)) = r<<fb_rpos | g<<fb_gpos | b<<fb_bpos;
}

View file

@ -1,7 +0,0 @@
#ifndef _FRAMEBUFFER_H
#define _FRAMEBUFFER_H 1
void initfb(unsigned long addr, unsigned short w, unsigned short h, unsigned char bpp, unsigned long pitch, unsigned char rpos, unsigned char gpos, unsigned char bpos);
void putpixel(unsigned short x, unsigned short y, unsigned char r, unsigned char g, unsigned char b, unsigned char a);
#endif

View file

@ -1,5 +1,5 @@
#include "multiboot.h" #include "multiboot.h"
#include "framebuffer.h" #include "vga.h"
#include "serial.h" #include "serial.h"
#include "xtoa.h" #include "xtoa.h"
@ -18,58 +18,90 @@ void kmain (unsigned int mbootmagick, multiboot_info_t* mbootinfo) {
outb(0x3D4, 0x0A); outb(0x3D4, 0x0A);
outb(0x3D5, 0x20); outb(0x3D5, 0x20);
int serial_initialized = serial_init(); //cls();
serial_write_string("\n=== KoalemOS ===\n"); vga_init(VGA_COLOR_BLACK, VGA_COLOR_GRAY);
vga_write_line("=== KoalemOS ===");
if (serial_init() > 0) {
vga_write_line_color("Serial initialization failed", VGA_COLOR_BLACK,
VGA_COLOR_ORANGE);
} else {
vga_write_line("\nInitialized serial.");
serial_write_string("\n=== KoalemOS ===\n");
}
vga_write("Checking multiboot loader: ");
// Check multiboot header // Check multiboot header
if (mbootmagick != MULTIBOOT_BOOTLOADER_MAGIC) { if (mbootmagick != MULTIBOOT_BOOTLOADER_MAGIC) {
vga_write_color("INVALID MAGIC", VGA_COLOR_BLACK, VGA_COLOR_RED);
return; return;
} }
if (mbootinfo->flags & MULTIBOOT_INFO_BOOT_LOADER_NAME)
vga_write((char *)mbootinfo->boot_loader_name);
else
vga_write_color("Unknown", VGA_COLOR_BLACK, VGA_COLOR_ORANGE);
serial_write_string("\nMultiboot flags: "); vga_write("\nMultiboot flags: ");
serial_write_string(itoa(mbootinfo->flags, 2)); vga_write(itoa(mbootinfo->flags, 2));
serial_write_string("\nMultiboot flags: "); serial_write_string("\nMultiboot flags: ");
serial_write_string(itoa(mbootinfo->flags, 2)); serial_write_string(itoa(mbootinfo->flags, 2));
// Check videomode // Check videomode
if (mbootinfo->flags & MULTIBOOT_INFO_VBE_INFO) { if (mbootinfo->flags & MULTIBOOT_INFO_VBE_INFO) {
serial_write_string("\nVBE Mode: 0x"); vga_write("\nVBE Mode: 0x");
serial_write_string(itoa(mbootinfo->vbe_mode, 16)); vga_write(itoa(mbootinfo->vbe_mode, 16));
serial_write_string("\nVBE Mode: 0x");
serial_write_string(itoa(mbootinfo->vbe_mode, 16));
} }
if (mbootinfo->flags & MULTIBOOT_INFO_FRAMEBUFFER_INFO) {
vga_write("\nFramebuffer: ");
serial_write_string("\nFramebuffer: ");
vga_write("address: 0x");
serial_write_string("\n Address: 0x");
vga_write(ultoa(mbootinfo->framebuffer_addr, 16));
serial_write_string(ultoa(mbootinfo->framebuffer_addr, 16));
if (!(mbootinfo->flags & MULTIBOOT_INFO_FRAMEBUFFER_INFO)) { serial_write_string("\n Dimensions: ");
serial_write_string("\nVideo info not available"); serial_write_string(itoa(mbootinfo->framebuffer_width, 10));
return; 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("\nFramebuffer: "); unsigned long *vmem;
serial_write_string("\n Address: 0x"); int i;
serial_write_string(ultoa(mbootinfo->framebuffer_addr, 16)); for (i = 0; i < mbootinfo->framebuffer_height; i++) {
vmem = mbootinfo->framebuffer_addr + i*mbootinfo->framebuffer_pitch + i*(mbootinfo->framebuffer_bpp/8);
serial_write_string("\n Dimensions: "); *vmem = 0xff<<mbootinfo->framebuffer_red_field_position;((char *)vmem)+=mbootinfo->framebuffer_bpp/8;
serial_write_string(itoa(mbootinfo->framebuffer_width, 10)); *vmem = 0xff<<mbootinfo->framebuffer_red_field_position;((char *)vmem)+=mbootinfo->framebuffer_bpp/8;
serial_write_string("X"); *vmem = 0xff<<mbootinfo->framebuffer_red_field_position;((char *)vmem)+=mbootinfo->framebuffer_bpp/8;
serial_write_string(itoa(mbootinfo->framebuffer_height, 10)); *vmem = 0xff<<mbootinfo->framebuffer_red_field_position;((char *)vmem)+=mbootinfo->framebuffer_bpp/8;
serial_write_string("x"); *vmem = 0xff<<mbootinfo->framebuffer_green_field_position;((char *)vmem)+=mbootinfo->framebuffer_bpp/8;
serial_write_string(itoa(mbootinfo->framebuffer_bpp, 10)); *vmem = 0xff<<mbootinfo->framebuffer_green_field_position;((char *)vmem)+=mbootinfo->framebuffer_bpp/8;
serial_write_string("\n Pitch: "); *vmem = 0xff<<mbootinfo->framebuffer_green_field_position;((char *)vmem)+=mbootinfo->framebuffer_bpp/8;
serial_write_string(itoa(mbootinfo->framebuffer_pitch, 10)); *vmem = 0xff<<mbootinfo->framebuffer_green_field_position;((char *)vmem)+=mbootinfo->framebuffer_bpp/8;
serial_write_string("\n RPos:"); *vmem = 0xff<<mbootinfo->framebuffer_blue_field_position;((char *)vmem)+=mbootinfo->framebuffer_bpp/8;
serial_write_string(itoa(mbootinfo->framebuffer_red_field_position, 10)); *vmem = 0xff<<mbootinfo->framebuffer_blue_field_position;((char *)vmem)+=mbootinfo->framebuffer_bpp/8;
serial_write_string("\n GPos:"); *vmem = 0xff<<mbootinfo->framebuffer_blue_field_position;((char *)vmem)+=mbootinfo->framebuffer_bpp/8;
serial_write_string(itoa(mbootinfo->framebuffer_green_field_position, 10)); *vmem = 0xff<<mbootinfo->framebuffer_blue_field_position;((char *)vmem)+=mbootinfo->framebuffer_bpp/8;
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;
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);
} }
}
} else {
vga_write_color("\nVideo info not available", VGA_COLOR_BLACK, VGA_COLOR_RED);
serial_write_string("\nVideo info not available");
return;
}
vga_write_line("\nExecution finished, halting...");
serial_write_string("\nExecution finished, halting..."); serial_write_string("\nExecution finished, halting...");
} }

View file

@ -24,30 +24,6 @@ char* itoa(int value, int base) {
} }
return result; return result;
} }
char* uitoa(unsigned int value, int base) {
char* result;
// check that the base if valid
if (base < 2 || base > 36) { *result = '\0'; return result; }
char* ptr = result, *ptr1 = result, tmp_char;
int tmp_value;
do {
tmp_value = value;
value /= base;
*ptr++ = "zyxwvutsrqponmlkjihgfedcba9876543210123456789abcdefghijklmnopqrstuvwxyz" [35 + (tmp_value - value * base)];
} while ( value );
*ptr-- = '\0';
while(ptr1 < ptr) {
tmp_char = *ptr;
*ptr--= *ptr1;
*ptr1++ = tmp_char;
}
return result;
}
char* ltoa(long value, int base) { char* ltoa(long value, int base) {
char* result; char* result;

View file

@ -2,7 +2,6 @@
#define HEADER_XTOA #define HEADER_XTOA
char* itoa(int value, int base); char* itoa(int value, int base);
char* uitoa(unsigned int value, int base);
char* ltoa(long value, int base); char* ltoa(long value, int base);
char* ultoa(unsigned long value, int base); char* ultoa(unsigned long value, int base);