KixOS
Posted: Wed Nov 03, 2004 12:00 am
I just started developing my New OS, I am going to call it KixOS (yeah I copied Linus Torvalds Linus - Linux, Kim - Kix, but it doesnt sounds to bad ). Any tips/ideas are wellcome!!
Code: Select all
[BITS 32]
[global start]
[extern main] ; The main kernel function
start:
call main ; call int main(void) from the C++ code
cli
hlt
Well, I can tell you in one quick and easy line what is wrong with your bootloader:Kimm wrote:well I am writing it in C++ and some 32 bit assembly, I dont acctually know much assembly and only the loader is written in it. But since it contains so very little maby you could help me anyway, it doesnt seem to load the OS properly, acctually when I boot from the Kernel file I am only met by a black screen (it is supose to be a black screen, but it should also say "Hello World")
this is the loader code:
I didnt acctually write it myselfe (I know extremely little asm) but got it from a tutorial therefore I dont know exactly might what be wrong with itCode: Select all
[BITS 32] [global start] [extern main] ; The main kernel function start: call main ; call int main(void) from the C++ code cli hlt
he said that this is his loader not bootloader...Well, I can tell you in one quick and easy line what is wrong with your bootloader:
I understand tha you are attempting to load ur kernel with LILO ????I have another question.
When I added my Kernel the the boot loader (LILO, I'm running linux), I noticed that linux boots from the file "vmlinuz" and not directly from the .bin file in the same directory. What is "vmlinuz" what does it do, do I need one to boot and display text? and in that case... how do I make one?
That's true, but it doesn't change anything. His code is not a loader of any sort, and it doesn't really do anything except halt after the main function runs.AlAdDiN wrote:he said that this is his loader not bootloader...
LILO is designed to boot Linux by whatever means works.Kimm wrote:what cant I use LILO?? is there a differance?
thats pretty much what its supose to doThat's true, but it doesn't change anything. His code is not a loader of any sort, and it doesn't really do anything except halt after the main function runs.
Thank you [AlAdDiN], sounds interesting. if I can just get some simple instructions in how to use itif u want I can give you my bootloader it can load one or two files (useful for tow stage kernel loading) from a FAT12 floppy then it launch the first loaded file. (the bootloader code is commented in french)
Code: Select all
;**********************************************************************
;* GNU X-OS Boot loader *
;**********************************************************************
;* @Auteur : Alaa-eddine KADDOURI *
;* *
;* @Projet : X Operating System (X-OS) *
;* @version : XOS LOADER v3.0 *
;* *
;* @Description : ce code permet de charger deux fichiers, un setup *
;* et un noyeau, puis lance le setup qui doit passer en mode *
;* prot?g? d?placer le noyeau au dela du premier Mo puis le lancer *
;* *
;* @Site web : http://xos.freezee.org (rubrique "Projets") *
;**********************************************************************
[ORG 0x7C00]
[BITS 16]
jmp start ;jmp to executable code 3bytes
;**********************************************************************
;* boot record : NE PAS MODIFIER *
;**********************************************************************
_OEM_NAME__________ db 'XoLo3',10,13,0
_bytes_per_sector__ dw 512
_sect_per_cluster__ db 1
_reserved_sectors__ dw 1
_number_of_FATs____ db 2
_number_of_entries_ dw 224
_nb_total_sectors__ dw 2880
_media_descriptor__ db 0xF0
_sectors_per_FAT___ dw 9
_sector_per_track__ dw 18
_number_of_heads___ dw 2
_nb_hidden_sectors_ dw 0
_nb_part_sectors___ dd 0
_drive_number______ db 0
_reserved1_________ db 0
_signature_________ db 29h
_serial_number_____ dd 0
;_volume_label______ db 'XOS-LOADER ' ;11bytes
;_reserved2_________ db 0, 0, 0, 0, 0, 0, 0, 0 ;8bytes
;**********************************************************************
;**********************************************************************
;les outils pour la fat12 et l'affichage
%include "boot.inc"
setup db 'XOSKER32'
kername db 'SETUP XSS',0 ;le format du nom ici est en 8x3
;exemple: 'NOMFIC00EXT'
%define MSG_init _OEM_NAME__________
; db 'By AlAdDiN',10,13
;***CONST et var
%define bootdrive 0
;***quelques adesses memoires utiles
LOAD_ADDR DW 9020h
%define buffer 0x7e00
%define file 0x8000
;***MESSAGES
MSG_pix db '.',0
MSG_ok db 'OK',10,13,0
MSG_notfound db 'E',0
;MSG_reboot db 'Hit key',10,13,0
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
start:
cli
mov AX,9000h
mov SS,AX
mov SP,0h
sti
mov es, ax
push ax
xor ax, ax
mov ds, ax
mov ax, 7c00h
mov si, ax
mov di, ax
mov cx, 0100h
rep movsw
mov ax, go
push ax
retf
go:
mov ax, cs
mov ds, ax
mov es, ax
mov si, _OEM_NAME__________
call P_print
load:
mov si, kername
call P_print
mov ax, 19 ;premier secteur de la fat
lo1:
push ax ;on sauveguarde ax (compteur de boucle principalle)
mov bx, buffer ;le buffer dans lequel on va lire les secteur de la fat
Call P_readsector ;lecture d'un secteur
mov cx, 16 ;16 entr?es dans chaque buffer de 512 octets
mov dl, 1 ;1ere entr?e de la fat
lo2:
push cx ;on sauvegare cx (car il servira de compteur de boucle)
mov di, file ;buffer qui contiendra une entr?e de la fat (32 octets) (chaque entr?e contient le nom du fichier, les attribut, la taille ...etc)
mov bx, buffer ;le buffer qui contien l'entr? ? lire
call P_buf2file ;on lit l'entr?e
mov bx, file ;
call P_decompfile ;extractions des donn?es de cet entr?e (nom du fichier, attributs, dates, taille...)
mov si, filename ;filename est une chaine qui contien le nom du dernier ficher extrait de la fat (voir boot.inc)
mov di, kername ;le nom de notre kernel
mov cx, 11 ;8 char pour le nom 3 pour l'extention = 11
repe cmpsb ;comparaison des deux chaines
jz Found ;Youpiii ............... On a trouv? le kernel !!!
next1: ;pas encore ??
inc dl ;entr? suivante de la fat
pop cx ;on recup?re la valeur de notre compteur
loop lo2 ;puis on relance la recherche du kernel
pop ax ;on recup?re la valeur de notre compteur principal
cmp ax, 32 ;toute la fat ? ?tait lu ??
jge NotFound ;oui ===> le kernel n'est pas la d'dans :-(
inc ax ;ya encore des entr?es dans la fat ?
jmp lo1 ;oui , on passe ? la suivante
Found: ;le kernel est trouv?
pop cx ;d'abord on lib?re la pile
pop ax
mov ax, 1 ;
call P_sl2p ;secteur logique en physique
mov bx, buffer
mov ah, 02
mov al, 9
mov dl, bootdrive
int 13h
mov bx, 0
push bx
mov ax, [LOAD_ADDR]
mov es, ax
lo: ;chargement du kernel
mov si, MSG_pix
Call P_print
mov ax, [cluster]
pop bx
add ax, 31
call P_readsector
add bx, 512
push bx
mov bx, buffer
mov ax, [cluster]
call P_getnextcluster
mov [cluster], ax
cmp ax, 0x0FF8 ;fin du fichier
jb lo
mov si, MSG_ok ;le kernel est charg?
Call P_print
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
cmp word [LOAD_ADDR], 9020h
jne finish
mov ax, ds
mov es, ax
mov si, setup
mov di, kername
mov cx, 8
rep movsb
mov [LOAD_ADDR], word 100h
jmp load
finish:
;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
mov ax, word 0x9020 ;on sauveguarde l'addresse de chargement du kernel
jmp 0x9020:0 ;lancement du kernel...
NotFound:
mov si, MSG_notfound
call P_print
mov ah, 0 ;attente d'une touche
int 16h ;
int 19h
jmp $
times 510 - ($-$$) DB 0
MAGIC_NUMBER dw 0AA55h
[SEGMENT .bss]
;file resb 32
;buffer resb 512*9
filename resb 8
ext resb 3
Yet, I followed the compilation steps in a tutorial completely but it still doesnt work.Booting 'KixOS'
kernel (hdo,4)/home/kim/Documents/KixOS/Kernel.bin - root=/dev/hda5
Error 13: Invalid or unsupported executable format