Purple Text
Posted: Sat Feb 12, 2011 8:56 am
Hi! I am new to OS Development. Whenever I run my kernel, I get this:
EDIT: Just to be clearer, the problem is the purple background.
This is my entry:
And this is IO.h:
Yes, I know I used a nested function, but I didn't want to include the code twice in the same function for size reasons.
Any help would be greatly appreciated.
EDIT: Just to be clearer, the problem is the purple background.
This is my entry:
Code: Select all
#include "io/io.h"
#include "misc/ops.h"
#include "misc/startup_test.h"
void kmain(void* mbd, unsigned int magic)
{
if(magic != 0x2BADB002)
{
put_string("Invalid Magic Number. Maybe you should get a wizard next time!\n");
k_hang();
}
clear_screen();
k_startup_test();
put_string("Hello People,\n\nThis is a test.\n\nSee if you can pass it.\n\nYou failed.\n\n");
}
Code: Select all
/* io.h AOS Willow */
#define IO_IO_H
#define WHITE_ON_BLACK 0x07
#define VIDRAM_START 0xB8000
#define VIDRAM_END 0xB8FA0
unsigned char *videoram = (unsigned char *) VIDRAM_START;
const char cursor = '_';
int row = 1;
int column = 1;
void reset_cursor()
{
*videoram = 0x00; // Erase Cursor
videoram++;
*videoram = 0x00;
row = 1;
column = 1;
update_videoram();
}
void update_videoram()
{
int x = (row - 1) * 160; // Number of characters to skip for rows
int y = (column - 1); // Number of characters to skip for columns
videoram = VIDRAM_START + (x + y);
}
void move_cursor(int newrow, int newcolumn)
{
row = newrow;
column = newcolumn;
update_videoram();
*videoram = cursor; // Set cursor
}
void clear_screen()
{
reset_cursor();
for(videoram = VIDRAM_START; videoram < VIDRAM_END; videoram++)
{
*videoram = 0x0;
}
reset_cursor();
}
void put_char(char data) // Wrapper for put_coloured_char
{
put_coloured_char(WHITE_ON_BLACK, data);
}
void put_coloured_char(char colour, char data)
{
*videoram = 0x00; // Remove cursor
void write_char()
{
*videoram = data;
videoram++;
*videoram = colour;
column++;
update_videoram();
*videoram = cursor; // Set cursor
videoram++;
*videoram = colour;
videoram--;
if(column < 160) column++;
else
{
if(row < 25)
{
row++;
column = 1;
}
else clear_screen();
}
update_videoram();
}
if(videoram <= VIDRAM_END) // Is cursor in bounds?
{
if(data == '\n')
{
// Newline
if(row < 25) row++;
else
{
clear_screen();
return; // Screen has been cleared. No need to continue
}
column = 1;
update_videoram();
}
else
{
write_char();
}
}
else // Clear screen before printing
{
clear_screen();
write_char();
}
}
void put_string(const char *string) // Wrapper for put_coloured_string
{
put_coloured_string(WHITE_ON_BLACK, string);
}
void put_coloured_string(char colour, const char *string)
{
while(*string != 0)
{
put_coloured_char(colour, *string);
string++;
}
}
Any help would be greatly appreciated.