Autor Thema: Kernel funktioniert nicht  (Gelesen 9446 mal)

javadomi

  • Gast
Gespeichert
« am: 20. May 2005, 20:14 »
Ich habe ein Bootloader mit Assembler geschrieben.

boot.asm:
________________________
org 0x7C00

start:
   cli
   mov ax, 0x9000
   mov ss, ax
   mov sp, 0
   sti

   mov [bootdrv], dl
   call load

   mov ax, 0x1000
   mov es, ax
   mov ds, ax
   push ax
   mov ax, 0
   push ax
   retf

bootdrv db 0
loadmsg db "Lade Betriebssystem...",13,10,0

putstr:
   lodsb
   or al,al
   jz short putstrd
   mov ah,0x0E
   mov bx,0x0007
   int 0x10
   jmp putstr

putstrd:
   retn

load:
   push ds
   mov ax, 0
   mov dl, [bootdrv]
   int 13h
   pop ds
   jc load

load1:
   mov ax,0x1000
   mov es,ax
   mov bx, 0

   mov ah, 2
   mov al, 5
   mov cx, 2
   mov dx, 0
   int 13h
   jc load1
   mov si,loadmsg
   call putstr
   retn

times 512-($-$$)-2 db 0
dw 0AA55h
________________________

Für das starten der Kernel habe ich diese Datei angelegt.
ks.asm:
________________________
[Bits 32]

extern _main
global start

start:
   call _main

STOP:
   jmp STOP
________________________

Den Kernel selbst habe ich mit C erstellt.
kernel.c:
________________________
int main(void);

int main(void)
{
  char *str = "Hallo  Welt!", *ch;
  unsigned short *vidmem = (unsigned short*) 0xb8000;
  unsigned i;

  for (ch = str, i = 0; *ch; ch++, i++)
    vidmem = (unsigned char) *ch | 0x0700;

  for (;;)
    ;
}
________________________

Für den DJGPP Linker habe ich diese Datei erstellt.
link.ld:
________________________
OUTPUT_FORMAT("binary")
ENTRY(start)
SECTIONS
{
.text 0x00010000 : {
*(.text)
}
.data : {
*(.data)
}
.bss :
{
*(.bss)
}
}
________________________

Das alles habe ich so kompiliert.
________________________
nasm -f bin -o boot.bin boot.asm
nasm -f aout -o ks.o ks.asm
gcc -c -ffreestanding -nostdinc -I ./ -O3 -Wall -o kernel.o kernel.c
ld -T link.ld -o kernel.bin ks.o kernel.o
________________________

Dies hat auch alles geklappt. Dannach
habe ich alles per copy Befehl in
eine Datei zusammengefasst.
________________________
copy boot.bin + kernel.bin TestOS.raw
________________________

Diese Datei habe ich dann mit rawrite auf
eine Diskette geschrieben und neu gebootet.
Ich erhielt darauf die Meldung "Lade Betriebssystem...",
aber dannach ist nichts mehr passiert, obwohl
zu erwarten wäre, dass noch die Meldung
"Hallo Welt!" kommen würde. Ich habe mich
streng an verschiedene Tutorials gehalten,
aber das Ergebnis war immer das selbe. Was
habe ich falsch gemacht?

urx_

  • Beiträge: 58
    • Profil anzeigen
    • http://tange.ta.funpic.de
Gespeichert
« Antwort #1 am: 20. May 2005, 20:25 »
Das Problem ist, dass du einen Realmode Bootloader mit einem Protected-mode Kernel verwendest (glaube ich)
Hip-Hop ist vielseitige, intelligente Musik, *Metal dagegen nur stupider Lärm. <-- Von wem das wohl kommt 8)

javadomi

  • Gast
Gespeichert
« Antwort #2 am: 25. May 2005, 19:25 »
Ok, wie mache ich das jetzt? Ich habe alle C++ Kernel Tutorials ausprobiert, aber sie gehen nicht. Könnte mir vielleicht jemand ein Quellcode senden?

n3Ro

  • Beiträge: 288
    • Profil anzeigen
Gespeichert
« Antwort #3 am: 25. May 2005, 19:30 »
Am besten du schaust dir erstmal ein Paar Protected Mode Tutorials an. Und lass das mit dem eigenen Bootloader, GRUB ist 1000mal besser, einfacher, und sowieso toll :D
Agieren statt Konsumieren!

 

Einloggen