Page 1 of 1
How to read some sectors from CD?
Posted: Sat Oct 18, 2014 4:16 am
by donggas90
I'm trying to create a booting CD for my OS.
Already made a bootable ISO and launched my booting codes successfully.
but I don't know how to load my kernel and system files.
Code: Select all
org 0x00
bits 16
jmp Main
;=======================================================================
PrintString16:
lodsb
or al, al
jz _PrintString16Return
mov ah, 0x0E
int 0x10
jmp PrintString16
_PrintString16Return:
ret
Main:
cli
mov ax, 0x07C0
mov ds, ax
mov es, ax
mov fs, ax
mov gs, ax
xor ax, ax
mov ss, ax
not ax
mov sp, ax
sti
mov si, StartMsg
call PrintString16
cli
hlt
;=======================================================================
StartMsg db "Hello, Bootable CD!", 13, 10, 0
times 0x800 - 2 - ($ - $$ ) db 0
dw 0xAA55
I used INT 13 for previous booting disk that was floppy. but cannot sure it works for CD.
because my ISO NOT using Floppy emulation.
Is it work in my case?
or
Is there any tutorial for this problem?
Re: How to read some sectors from CD?
Posted: Sat Oct 18, 2014 8:25 am
by Combuster
Oh my.
donggas90 wrote:Is there any tutorial for this problem?
Welcome to the
Beginner Mistakes.
I used INT 13 for previous booting disk that was floppy. but cannot sure it works for CD.
Have you gone
looking for the official specification yet like we would have expected from any person asking a question? This particular question is answered on page 16, and I'm sure many of your subsequent questions will be answered somewhere else in that PDF file as well.
Re: How to read some sectors from CD?
Posted: Sat Oct 18, 2014 10:02 am
by donggas90
Oh, I did mistakes.
but my mean was just want to see some series of simple examples.
Not lectures what you thinking.
BTW I already searched many docs of this topic, but they do not told exactly so I couldn't understand how to do.
So I wrote this thread.
Yes, I'm a beginner of OS development, but NOT a beginner of programming.
Thus just you can say a keyword or showing some of codes, just link of docs or other answers, that's OK.
I don't want detailed informations like class of professor as well, just want a few clues or examples.
I'll just attempt to use INT 13 what suspected, I was too timided to try that.
If it fail, I will post again.
Thanks.
Re: How to read some sectors from CD?
Posted: Sat Oct 18, 2014 1:55 pm
by max
donggas90 wrote:BTW I already searched many docs of this topic, but they do not told exactly so I couldn't understand how to do.
Use the specification Combuster linked you to. It will tell you exactly whats necessary. If you have a specific question of what you don't understand, then come back.
Re: How to read some sectors from CD?
Posted: Sun Oct 19, 2014 1:06 am
by donggas90
Thanks max.
Finally I got a clue that INT 13 works for CD from
here.
In that thread, m99 used 0x9F as disk number. It worked for me.
but quok pointed out that assuming disk number as 0x9F can occur problem. I agree this opinion.
So I checked 0x11 sector is Boot Record Descriptor for each disk number from 0x81 to 0xFF.
because El Torito doc says, disk number of no emulation CD is 0x81-0xFF and Boot Record Descriptor always place in 0x11 sector.
but I think it's ineffecient method. because a sector of CD is 2KB size, so that occur too many overhead just to read several bytes.
I also found some extended INT 13s for CD. but they need disk number, cannot get.
So I want to know about this. Is there a way to get disk number of my CD directly?
Re: How to read some sectors from CD?
Posted: Sun Oct 19, 2014 4:16 am
by Octocontrabass
donggas90 wrote:Is there a way to get disk number of my CD directly?
When you boot from a floppy disk, hard disk, USB flash disk, or CD, the disk number is in DL.
Re: How to read some sectors from CD?
Posted: Sun Oct 19, 2014 4:42 am
by donggas90
Octocontrabass wrote:the disk number is in DL.
Wow, thanks.
Re: How to read some sectors from CD?
Posted: Sun Oct 19, 2014 12:55 pm
by donggas90
I've been returned at ZERO.
INT 13 function 02 wasn't work as predicted.
I expected that loads 0x800bytes per sector but 512bytes.
and Sector 1 is not offset 0 of ISO file. but 0xA000 that is start of Terminate Descriptor + 0x800.
I tried INT 13 function 00 to reset the offset of Sector 1 to zero. but didn't work.
Thus I cannont read Primary Descriptor so cannot read Root Directory Record to search my kernel file.
My ISO is not emulated. and my current testing machine is VMware.
Here is my codes.
Code: Select all
mov byte[DiskNumber], dl
xor ah, ah
int 0x13
mov al, 1
xor ch, ch
mov cl, ISO_PRIMARY_VOLUME_DESCRIPTOR_SECTOR ;0x11
xor dh, dh
push es
push ROOT_DIRECTORY_RECORD_SEGMENT ;0x02E0
pop es
xor bx, bx
call ReadSector
jc Fail
I traced bytes from es:bx and tested some different cases.
Then I recognized that loaded ISO offset is 0xC000 and sector size is 512, Sector 1 offset is 0xA000.
0xC000 = 0xA000 + 512 * 0x10
What can I do for this problem?
Re: How to read some sectors from CD?
Posted: Sun Oct 19, 2014 1:11 pm
by Combuster
I wrote:I'm sure many of your subsequent questions will be answered somewhere else in that PDF file as well.
The specification wrote:After the boot process has been initiated the INT 13 Extensions (functions 41-48) will access the CD
you wrote:INT 13 function 02
Being able to read might be a lost art, but it's certainly an important one
Re: How to read some sectors from CD?
Posted: Sun Oct 19, 2014 11:41 pm
by donggas90
Thanks Combuster.
OMG, that was the point!
I didn't mind that line bacause my manual of BIOS(General Software, Inc.) is not listed that functions.
Finally I got the data of ISO successfully!