[Booting] HDD emulated CD
Posted: Sun Apr 15, 2012 6:16 am
Hello everyone,
Story:
I'm a beginning OS developer.
I just made it such far my own bootloader (on sector 1 of floppy) can load the kernel (on sector 2 of floppy).
Now I want to get rid of the floppy usage and step over to hard disk.
But to write the 2 sectors to a harddisk every time is much work, so I should like to emulate a HDD on a CD with El Torito.
I use Nero Burning ROM 10 to write my bootloader and kernel to the CD.
Emulated as 2.88 MB Floppy it works, it can load it from drive 0x0, which is the emulated floppy.
Problem:
Now the problem is when I make an emulated HDD from it and read the kernel from drive 0x80 (which is the emulated HDD) it won't work.
I think I don't know how to read from a HDD. (the emulated CD)
I hope someone could give me more explanation about this.
Thanks in advance,
Dennis
This is all code:
bootloader.asm:
kernel.asm:
How to assemble and combine (under Windows):
This creates "x.img" which I burn to the CD (emulated as HDD) with Nero Buring ROM.
Story:
I'm a beginning OS developer.
I just made it such far my own bootloader (on sector 1 of floppy) can load the kernel (on sector 2 of floppy).
Now I want to get rid of the floppy usage and step over to hard disk.
But to write the 2 sectors to a harddisk every time is much work, so I should like to emulate a HDD on a CD with El Torito.
I use Nero Burning ROM 10 to write my bootloader and kernel to the CD.
Emulated as 2.88 MB Floppy it works, it can load it from drive 0x0, which is the emulated floppy.
Problem:
Now the problem is when I make an emulated HDD from it and read the kernel from drive 0x80 (which is the emulated HDD) it won't work.
I think I don't know how to read from a HDD. (the emulated CD)
I hope someone could give me more explanation about this.
Thanks in advance,
Dennis
This is all code:
bootloader.asm:
Code: Select all
[BITS 16]
[ORG 0x7C00]
MOV DL, 0x80 ;0x80 = HDD 1 (emulated CD)
MOV DH, 0x0 ;head (0=base)
MOV CH, 0x0 ;track/cylinder
MOV CL, 0x02 ;sector (1=bootloader, apparently sectors starts counting at 1 instead of 0)
MOV BX, 0x1000 ;place in RAM for kernel - I suppose randomly chosen on examples
MOV ES, BX ;place BX in pointer ES
MOV BX, 0x0 ;back to zero - also has something to do with RAM position
ReadFloppy:
MOV AH, 0x02
MOV AL, 0x01
INT 0x13
JC ReadFloppy ;if it went wrong, try again
;pointers to RAM position (0x1000)
MOV AX, 0x1000
MOV DS, AX
MOV ES, AX
MOV FS, AX
MOV GS, AX
MOV SS, AX
JMP 0x1000:0x0
;assuming we get never back here again, so no further coding needed (kernel handles everything now)
TIMES 510 - ($ - $$) db 0 ;fill resting bytes with zero
DW 0xAA55 ;end of bootloader (2 bytes)
Code: Select all
;set print-registers
MOV AH, 0x0E ;function nr
MOV BH, 0x00 ;page
MOV BL, 0x07 ;color
MOV SI, msg ;move msg to SI-pointer
CALL PrintString ;call function to print SI (msg)
JMP $ ;hang
PrintString:
.next_char:
MOV AL, [SI] ;current character
OR AL, AL
JZ .exit_char ;if current char is zero, go to end
INT 0x10 ;print character
INC SI ;increase pointer to msg (next character)
JMP .next_char
.exit_char:
RET
msg db 'Hello world from the kernel!', 13, 10, 0
TIMES 512 - ($ - $$) db 0 ;fill the rest
Code: Select all
nasm bootloader.asm -o boot.bin
nasm kernel.asm -o kernel.bin
copy boot.bin x.img
type kernel.bin >> x.img