KixOS
Re: KixOS
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 it
this is the loader code:
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
Re: KixOS
I want to notice you that developping a kernel using C++ is not too easy, since you can't allocate objects (you must write a malloc/realloc/free functions to be able to do it)
I think C is suffisent, and makes kernel developpement easier
It's only my opinion
I think C is suffisent, and makes kernel developpement easier
It's only my opinion
-----------------------
There are 10 types of people in this world... those that understand binary, and those that don't.
There are 10 types of people in this world... those that understand binary, and those that don't.
Re: KixOS
thank you [AlAdDiN], I'll see if I can learn C a little better then. But my current kernel is basicaly C now anyway
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?
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?
Last edited by Kimm on Wed Nov 03, 2004 12:00 am, edited 1 time in total.
Re: KixOS
Perhaps you have some sort of barrier when using C++ (runtime support), but who knows how it will scale up later, once you have that support
*post*
-
- Member
- Posts: 134
- Joined: Sun Oct 24, 2004 11:00 pm
- Location: North Dakota, where the buffalo roam
Re: KixOS
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
This is not a bootloader.
In fact all this code does is create an assembly routine which calls the main function. It doesn't load anything, and it doesn't do anything. You should do some research on what a bootloader is and does. Or, you could use a premade bootloader like GRUB. Try here: <a href="http://www.gnu.org/software/grub/">http://www.gnu.org/software/grub/</a>
Re: KixOS
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?
I think if you don't want to write ur own bootloader use GRUB instead
and if u know assembler u can write ure own bootloader it's not too hard.
if 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)
-----------------------
There are 10 types of people in this world... those that understand binary, and those that don't.
There are 10 types of people in this world... those that understand binary, and those that don't.
-
- Member
- Posts: 134
- Joined: Sun Oct 24, 2004 11:00 pm
- Location: North Dakota, where the buffalo roam
Re: KixOS
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?
Grub is designed to boot any OS through a well-documented consistent interface.
Many Linux distros are moving toward Grub rather than LILO because it is just better in so many ways. You should be able to boot your Linux install with Grub, as well as your own OS, Windows, FreeBSD, whatever you can think of. The documentation will tell you how to do all of this. One major advantage of Grub is that since it doesn't store a pointer to the file which stores your kernel, it doesn't have to be fixed every time you get a new kernel.
Last edited by rexlunae on Thu Nov 04, 2004 12:00 am, edited 2 times in total.
Re: KixOS
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)
Re: KixOS
if you want the bootloader to load tow file just use this code
it will load files defined in variables setup and kername to addresses LOAD_ADDR and 100h respectivelly
in this example the file called SETUP.XSS is loaded to address 9020h and XOSKER32.XSS will be loaded to 100h (0x1000 linear)
then SETUP.XSS is called (it will do some configs before loading kernel)
so if you want to use such loading methode just redefine setup and kername variables, normally you have not to modify any loading addresse since you will launch setup first witch can move the kernel to another place before launching it (this is very useful when u want to load ur kernel at upper memory @0x100000 for example )
file names must have this format "FILENAMEEXT"
no dot betweent filename and extention
if the file name is shorter than 8 chars complete with spaces (same think for file extention)
now if you want to load only one file then you must define it in setup variable
then you must comment all lines between
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
and
;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
you may also modify the variable LOAD_ADDR to chose anotther place where u want to load kernel (NOTE that memory between 0x9000 and 0x9020 is used by boot sector
note that this code is compatible with fat12, he will NOT destroy any data in your floppy if it is formatted with FAT12, all you have to do is to setup the bootsector in the floppy bootsector then copy your file/files to the root directory in the floppy
you will also need the boot.inc (define some fat12 functions)
you'll find it at this address http://xos.freezee.org/beta
it will load files defined in variables setup and kername to addresses LOAD_ADDR and 100h respectivelly
in this example the file called SETUP.XSS is loaded to address 9020h and XOSKER32.XSS will be loaded to 100h (0x1000 linear)
then SETUP.XSS is called (it will do some configs before loading kernel)
so if you want to use such loading methode just redefine setup and kername variables, normally you have not to modify any loading addresse since you will launch setup first witch can move the kernel to another place before launching it (this is very useful when u want to load ur kernel at upper memory @0x100000 for example )
file names must have this format "FILENAMEEXT"
no dot betweent filename and extention
if the file name is shorter than 8 chars complete with spaces (same think for file extention)
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
now if you want to load only one file then you must define it in setup variable
then you must comment all lines between
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
and
;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
you may also modify the variable LOAD_ADDR to chose anotther place where u want to load kernel (NOTE that memory between 0x9000 and 0x9020 is used by boot sector
note that this code is compatible with fat12, he will NOT destroy any data in your floppy if it is formatted with FAT12, all you have to do is to setup the bootsector in the floppy bootsector then copy your file/files to the root directory in the floppy
you will also need the boot.inc (define some fat12 functions)
you'll find it at this address http://xos.freezee.org/beta
-----------------------
There are 10 types of people in this world... those that understand binary, and those that don't.
There are 10 types of people in this world... those that understand binary, and those that don't.
Re: KixOS
Well, I am having some cind of problem with my OS! I used Grub to boot it (sorry [AlAdDiN] just dont know how to use your bootloader). And I got the following errormessage:
I was woundering if maby someone could take a look at the code and see if I did something wrong, or perhaps I configured the bootlader in a wrong way. Its not much to the world, but atleast it should be able to print text in two different colors.
http://www.area51central.com/Temp/KixOS.tar.gz
I dont know how to write a Makefile so I wrote a simple C++ program (Make.out) that calls system() to make gcc and nasm compile the kernel, then ld to link it.
If you arnt using Linux you can use some other compiler and compile Loader.asm and Kernel.c to two .o files, then link them using link.ld.
I also included the code for Make.out
Thank you in advance!
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
I was woundering if maby someone could take a look at the code and see if I did something wrong, or perhaps I configured the bootlader in a wrong way. Its not much to the world, but atleast it should be able to print text in two different colors.
http://www.area51central.com/Temp/KixOS.tar.gz
I dont know how to write a Makefile so I wrote a simple C++ program (Make.out) that calls system() to make gcc and nasm compile the kernel, then ld to link it.
If you arnt using Linux you can use some other compiler and compile Loader.asm and Kernel.c to two .o files, then link them using link.ld.
I also included the code for Make.out
Thank you in advance!
Last edited by Kimm on Sun Nov 07, 2004 12:00 am, edited 1 time in total.
Re: KixOS
is your kernel in ELF format (hexedit it and see if u have ELF in first 3 bytes)
if not maybe this is the problem
I think it's because you are compilling ur kernel under cygwin
another think I dont' find any multiboot signature in ur kernel, this is needed to boot with grub
if not maybe this is the problem
I think it's because you are compilling ur kernel under cygwin
another think I dont' find any multiboot signature in ur kernel, this is needed to boot with grub
-----------------------
There are 10 types of people in this world... those that understand binary, and those that don't.
There are 10 types of people in this world... those that understand binary, and those that don't.