Page 1 of 1
Bootloader
Posted: Wed Apr 27, 2011 10:13 am
by seingh
Hello everyone, I'm new in this forum and in the development of operating systems ^ ^ (XD)
I wanted to ask how to create a custom bootloader ... or better to say how to recognize it from qemu xD.
In short, the boot loader code is this:
Boot.asm:
Code: Select all
global loader
[BITS 32]
extern _kmain
section .text
LEA SI,[msg]
MOV AH,0Eh
print: MOV AL,[SI]
CMP AL,0
JZ done
INT 10h
INC SI
JMP print
; wait for 'any key':
done: ;MOV AH,0
;INT 16h
call _kmain
MOV AX,0040h
MOV DS,AX
MOV word[0072h],0000h.
JMP 0FFFFh:0000h
msg DB 'Benvenuto in patronum OS.',13,10
; end boot1
qemu in windows but does not recognize it ... in ubuntu I need to use "qemu-kernel kernel.bin" instead in windows if I type the same command (with qemu installed) nothing happens ...
Sorry for my **** English, I'm Italian ^ ^
Re: Bootloader
Posted: Wed Apr 27, 2011 12:09 pm
by seingh
berkus wrote:You seem to lack the boot loader signature at the end.
I did not understand what you are saying, please write in another way, I'm sorry.
Re: Bootloader
Posted: Wed Apr 27, 2011 12:22 pm
by seingh
berkus wrote:I assume you have read the Bootloader wiki article, so you know about the BIOS boot signature. There's even an example how to define one.
oh, i haven't read it....
EDIT: After reading the article, I see that do not there is a big difference between that article and "my" ( excepted that the code in the article is in 16 bit and my is in 32 bit, there is also the difference that he does not call any C code, which I will be obliged to do (because I do not know very well asm) )
Re: Bootloader
Posted: Wed Apr 27, 2011 3:20 pm
by b.zaar
seingh wrote:berkus wrote:I assume you have read the Bootloader wiki article, so you know about the BIOS boot signature. There's even an example how to define one.
oh, i haven't read it....
EDIT: After reading the article, I see that do not there is a big difference between that article and "my" ( excepted that the code in the article is in 16 bit and my is in 32 bit, there is also the difference that he does not call any C code, which I will be obliged to do (because I do not know very well asm) )
You can't use 32 bit code in a boot sector, the cpu is running in 16 bit mode until you enter protected mode.
Re: Bootloader
Posted: Fri Apr 29, 2011 4:08 am
by seingh
b.zaar wrote:seingh wrote:berkus wrote:I assume you have read the Bootloader wiki article, so you know about the BIOS boot signature. There's even an example how to define one.
oh, i haven't read it....
EDIT: After reading the article, I see that do not there is a big difference between that article and "my" ( excepted that the code in the article is in 16 bit and my is in 32 bit, there is also the difference that he does not call any C code, which I will be obliged to do (because I do not know very well asm) )
You can't use 32 bit code in a boot sector, the cpu is running in 16 bit mode until you enter protected mode.
I solved it this way:
Code: Select all
global loader
extern kmain
MODULEALIGN equ 1<<0
MEMINFO equ 1<<1
FLAGS equ MODULEALIGN | MEMINFO
MAGIC equ 0x1BADB002
CHECKSUM equ -(MAGIC + FLAGS)
section .text
align 4
MultiBootHeader:
dd MAGIC
dd FLAGS
dd CHECKSUM
STACKSIZE equ 0x4000
loader:
mov esp, stack+STACKSIZE
push eax
push ebx
call kmain
cli
hang:
hlt
jmp hang
section .bss
align 4
stack:
resb STACKSIZE
thank you anyway ^ ^
Re: Bootloader
Posted: Fri Apr 29, 2011 5:50 pm
by Gigasoft
That isn't a bootloader. It is the entry point and multiboot header for a multiboot executable.
Re: Bootloader
Posted: Sat Apr 30, 2011 2:04 am
by seingh
Gigasoft wrote:That isn't a bootloader. It is the entry point and multiboot header for a multiboot executable.
What? I tried this code in QEMU with the string "qemu -kernel kernel.bin" (after compiling a "kernel.bin" file ) and it works...
It do what I want: it calls a C function from Assembler in the computer boot. And with this I think it's a bootloader.
Re: Bootloader
Posted: Sat Apr 30, 2011 3:18 am
by shikhin
/me shakes his head - this is what happens to people who just aimlessly copy code from some website, without even understanding what it does.
Re: Bootloader
Posted: Sat Apr 30, 2011 4:56 am
by Chandra
What? I tried this code in QEMU with the string "qemu -kernel kernel.bin" (after compiling a "kernel.bin" file ) and it works...
It do what I want: it calls a C function from Assembler in the computer boot. And with this I think it's a bootloader.
Do you have any idea what
-kernel option does? It's a good practice to examine the water level before diving into this huge sea. Do care to search before complaining.
Re: Bootloader
Posted: Sat Apr 30, 2011 8:04 am
by seingh
Shikhin wrote:/me shakes his head - this is what happens to people who just aimlessly copy code from some website, without even understanding what it does.
I already said that I do not know well the assembly, or rather not know anything about assembler.
It is true that I copied that code from a site ... but this does not mean anything.
Chandra wrote:What? I tried this code in QEMU with the string "qemu -kernel kernel.bin" (after compiling a "kernel.bin" file ) and it works...
It do what I want: it calls a C function from Assembler in the computer boot. And with this I think it's a bootloader.
Do you have any idea what
-kernel option does? It's a good practice to examine the water level before diving into this huge sea. Do care to search before complaining.
Yes, it is obvious that I know what are the functions that I say.
It's needless to say ****.
berkus wrote:This isn't a bootloader, it's just a multiboot entry point which can be loaded by multiboot-compatible bootloader.
Sorry, but it works without another bootloader ( such as grub ).
Re: Bootloader
Posted: Sat Apr 30, 2011 11:05 am
by neon
I wanted to ask how to create a custom bootloader
You asked about creating a bootloader. This isnt a bootloader, stop calling it one.
Re: Bootloader
Posted: Sat Apr 30, 2011 11:12 am
by seingh
neon wrote:I wanted to ask how to create a custom bootloader
You asked about creating a bootloader. This isnt a bootloader, stop calling it one.
ok XD
Re: Bootloader
Posted: Tue May 03, 2011 6:33 am
by seingh
berkus wrote:seingh wrote:Sorry, but it works without another bootloader ( such as grub ).
Well, you're wrong here. Try to boot it on a real hardware, then we'll talk.
Or you can try booting it in bochs. All the same.
I tried it on my pc and it do not work...
That means that I must use grub -.-
Re: Bootloader
Posted: Tue May 03, 2011 6:37 am
by shikhin
Accepting that you are wrong is the first step to start learning. And stating that everyone except you is wrong is the first step to damage your reputation.
I warned you.
Re: Bootloader
Posted: Tue May 03, 2011 7:45 am
by seingh
Shikhin wrote:Accepting that you are wrong is the first step to start learning. And stating that everyone except you is wrong is the first step to damage your reputation.
I warned you.
OK, sorry