Autor Thema: Gelöst: Problem mit Kernel, direkter Reboot  (Gelesen 2006 mal)

Drako

  • Beiträge: 4
    • Profil anzeigen
Gespeichert
« am: 21. October 2008, 11:55 »
hallo Leute,

bin noch recht neu in der OSDev-Szene.
ich habe also mit dem Tutorial von Cheebi angefangen (Kernel in C)
und hab einfach alles kopiert, kompiliert und auf ne Diskette kopiert.
dann hab ich das gestartet.

und alles funktioniert.

Erfreut über diesen Erfolg hab ich dann auch gleich angefangen einen eigenen Kernel auf Basis dessen aus dem Tutorial geschrieben.
kompiliert und gemerkt, dass der jetzt größer als ein Sektor ist.
also hab ich noch im (fast original belassenen) Bootloader aus der 1 eine 3 gemacht.

als ich mein neues Gebilde nun testen wollte, ging dann nichts mehr.
Rechner an -> Diskettenlaufwerk rattert -> Bildschirm wird schwarz -> Rechner startet neu.

deshalb wollte ich mal fragen, was ich falsch gemacht habe^^

hier die Quellen:

kernel.c
#include "screen.h"

int main(void)
{
clrscr();
set_color(0xA);
printstr("DrakOS Version 1.0\n");
printstr("Copyright (C) 2008, Felix Bytow\n\n");
set_color(0x7);
printstr("\t\tSie können den Rechner nun ausschalten.");
}

inout.c
#include "inout.h"

void outb(uint_16 port, uint_8 value)
{
asm("outb %1, %0" : : "d" (port), "a" (value));
}

uint_8 inb(uint_16 port)
{
uint_8 result;
asm("inb %1, %0" : "=a" (result) : "d" (port));
return result;
}

screen.c
#include "screen.h"
#include "inout.h"
#include "string.h"

static uint_8 iXPos = 0, iYPos = 0, bColor = 0x7;
static char* pScreen = (char*)0xB8000;
#define CHAR_SPACE (char)' '

void clrscr(void)
{
uint_32 x, y;
for (y = 0; y < 25; ++y)
{
for (x = 0; x < 80; ++x)
{
pScreen[y * 160 + x * 2] = CHAR_SPACE;
pScreen[y * 160 + x * 2 + 1] = 0x0;
}
}
gotoxy(0, 0);
}

void gotoxy(uint_8 x, uint_8 y)
{
uint_16 tmp;
if (x >= 80 || y >= 25)
return;
tmp = y * 80 + x;
outb(0x3D4, 14);
outb(0x3D5, tmp >> 8);
outb(0x3D4, 15);
outb(0x3D5, tmp);
iXPos = x;
iYPos = y;
}

void printch(char c)
{
uint_32 x, y;
x = iXPos;
y = iYPos;
switch (c)
{
case '\t':
{
int n;
for (n = 0; n < 4; ++n)
printch(' ');
} break;
case '\n':
{
x = 0;
++y;
if (y == 25)
{
--y;
scroll();
return;
}
gotoxy((uint_8)x, (uint_8)y);
} break;
default:
{
pScreen[y * 160 + x * 2] = c;
pScreen[y * 160 + x * 2 + 1] = bColor;
++x;
if (x == 80)
{
x = 0;
++y;
if (y == 25)
{
--y;
scroll();
return;
}
}
gotoxy((uint_8)x, (uint_8)y);
}
}
}

void printstr(const char* pStr)
{
int iLen, i;
iLen = stringlen(pStr);
for (i = 0; i < iLen; ++i)
printch(pStr[i]);
}

void scroll(void)
{
uint_32 x, y;
for (y = 0; y < 24; ++y)
{
for (x = 0; x < 80; ++x)
{
pScreen[y * 160 + x * 2] = pScreen[(y + 1) * 160 + x * 2];
pScreen[y * 160 + x * 2 + 1] = pScreen[(y + 1) * 160 + x * 2 + 1];
}
}
for (x = 0; x < 80; ++x)
{
pScreen[24 * 160 + x * 2] = CHAR_SPACE;
pScreen[24 * 160 + x * 2 + 1] = 0x0;
}
gotoxy(0, 24);
}

void set_color(uint_8 color)
{
if (color > 0xF)
return;
bColor = color;
}

string.c
#include "string.h"

int stringlen(const char* pStr)
{
int iLen;
iLen = 0;
if (!pStr)
return -1;
while (pStr[iLen] != '\0')
++iLen;
return iLen;
}

types.h
#if !defined (TYPES_H)
#define TYPES_H

typedef unsigned char byte;
typedef unsigned short word;
typedef unsigned long dword;
typedef unsigned long long qword;

typedef unsigned char uint_8;
typedef unsigned short uint_16;
typedef unsigned long uint_32;
typedef unsigned long long uint_64;

typedef signed char int_8;
typedef signed short int_16;
typedef signed long int_32;
typedef signed long long int_64;

typedef float real_32;
typedef double real_64;

typedef void* ptr;

#endif

In den restlichen *.h-Dateien befinden sich lediglich die Deklarationen/Prototypen der Funktionen in den dazugehörenden *.c-Dateien.

Der Bootloader ist bis auf die Änderung der 1 in eine 3 original geblieben.

Würde mich sehr über Hilfe freuen.

MfG Drako
« Letzte Änderung: 21. October 2008, 16:50 von Drako »

Drako

  • Beiträge: 4
    • Profil anzeigen
Gespeichert
« Antwort #1 am: 21. October 2008, 16:50 »
ok, hat sich erledigt.

Ich verwende jetzt GRUB als Bootloader und da funktionierts.

 

Einloggen