Program freezes after loading OS through GRUB on bochs...
Posted: Sat Jun 12, 2010 9:21 pm
Hello, I have recently been attempting to develop some sort of an "OS". At first I had been manually writing characters to the vram, however I have just converted the example Pascal console library to C and added it. It compiled with no errors. The only problem is:
Whenever I try to boot into the OS from Bochs, it freezes after typing "boot" in grub.
In the console for bochs, it is showing these errors:
00096092378i[FDD ] read() on floppy image returns 0
00096137333i[FDD ] read() on floppy image returns 0
00096182288i[FDD ] read() on floppy image returns 0
00096227243i[FDD ] read() on floppy image returns 0
00096272198i[FDD ] read() on floppy image returns 0
00096317153i[FDD ] read() on floppy image returns 0
00096362108i[FDD ] read() on floppy image returns 0
Usually it works, but for some reason after I added this library it won't load.
Here is the source code:
kernel.c:
console.c:
console.h:
If it makes any difference, I am compiling it on a machine running Ubuntu Server 10.04, and running it in Bochs on OSX.
Thanks in advance for any help...
Whenever I try to boot into the OS from Bochs, it freezes after typing "boot" in grub.
In the console for bochs, it is showing these errors:
00096092378i[FDD ] read() on floppy image returns 0
00096137333i[FDD ] read() on floppy image returns 0
00096182288i[FDD ] read() on floppy image returns 0
00096227243i[FDD ] read() on floppy image returns 0
00096272198i[FDD ] read() on floppy image returns 0
00096317153i[FDD ] read() on floppy image returns 0
00096362108i[FDD ] read() on floppy image returns 0
Usually it works, but for some reason after I added this library it won't load.
Here is the source code:
kernel.c:
Code: Select all
#include "console.h"
/*Kernel Main*/
void kmain(void* mbd, unsigned int magic){
if(magic != 0x2BADB002){ /*Not launched using the magic number, 0x1BADB002. For some reason,
even though the kernel is launched with 0x1BADB002, it shows up in the kernel as 0x2BADB002*/
sWriteStr((unsigned char*)"Error 0");
xpos = 0;
ypos = ypos + 1;
//Error 0, kernel not launched correctly
return;
}
char * boot_loader_name =(char*) ((long*)mbd)[16];
/* Print startup message */
clrscr();
sWriteStr((unsigned char*)"Welcome to lOS!");
xpos = 0;
ypos = ypos + 1;
}
Code: Select all
#include "console.h"
unsigned char *vram = (unsigned char *) 0xb8000;
void clrscr(){
for(int i = 0; i < 3999; i = i + 1){
vram[i] = 0x00;
}
}
void sWriteChar(unsigned char val){
int offset;
if(ypos > 24){
ypos = 0;
}
if(xpos > 79){
xpos = 0;
}
offset = (xpos << 1) + (ypos * 160);
vram[offset] = val;
offset = offset + 1;
vram[offset] = 0x07;
offset = offset + 1;
xpos = (offset % 160);
ypos = (offset - xpos) / 160;
xpos = xpos >> 1;
}
void sWriteStr(unsigned char* val){
int offset, i;
if(ypos > 24){
ypos = 0;
}
if(xpos > 79){
xpos = 0;
}
offset = (xpos << 1) + (ypos * 160);
i = 0;
while(val[i] != (char)0x00){
vram[offset] = val[i];
offset = offset + 1;
vram[offset] = 0x07;
offset = offset + 1;
i = i + 1;
}
}
Code: Select all
int xpos;
int ypos;
void clrscr();
void sWriteChar(unsigned char val);
void sWriteStr(unsigned char* val);
Thanks in advance for any help...