Page 1 of 3

Extended read

Posted: Sat Feb 19, 2005 4:43 pm
by Ribas_pt
I'm sorry if this is already in the forum, i did no found it.

I've googled and searched about extended read, but i've found very diferent disk address packet format, and i'm confused...

i have this code ......

.....
mov ah,0x42 ; function to read from CDROM
mov dl,[btdrv] ; cdrom drive number
mov si,read_dap ; point to parameter block
int 0x13

......

read_dap:
db 0x10 ; 00: size of parameter block
db 0
db 0x1 ; 02: number of blocks to read (max 0xFF)
db 0
dw 0x0010,0x8000 ; 04: where to read it (offset,segment)
dd 0,0 ; 08: starting block number (quadword)

i want to load something at 1 megabyte and jump to it in protected mode .... help please! thanks (sorry for my english)

Re:Extended read

Posted: Sun Feb 20, 2005 9:34 pm
by Brendan
Hi,
Ribas_pt wrote:I've googled and searched about extended read, but i've found very diferent disk address packet format, and i'm confused...

i have this code ......

.....
mov ah,0x42 ; function to read from CDROM
mov dl,[btdrv] ; cdrom drive number
mov si,read_dap ; point to parameter block
int 0x13
If you haven't already done it, try adding "jc .error" after the "int 0x13".

Ralph Brown's Interrupt List (http://www.ctyme.com/intr/rb-0708.htm) lists this function as "Disk I/O Enhancements". This may mean that it's something added to the BIOS's disk IO functions by DOS and/or Windows, and the function itself may not be supported by the BIOS/ROM itself. Even if it is supported on some computers I doubt it's supported by all.

Further, I'm assuming that "mov dl,[btdrv]" refers to an emulated floppy disk on a CD-ROM, rather than the CD-ROM itself - not sure if that matters (you didn't say what you where trying to load, and where exactly you want to load it from.
Ribas_pt wrote:i want to load something at 1 megabyte and jump to it in protected mode .... help please! thanks (sorry for my english)
IMHO you'd be better to use "normal" BIOS disk IO functions. For example, my own floppy disk boot sector code sets up "unreal mode" (and enables the A20 gate) to get access to memory above 1 MB, uses the normal floppy "read sectors" BIOS function to load data below 1 MB, and then transfers the data to memory above 1 MB after (ie. without the BIOS). If you're loading data from an emulated floppy on a boot CD (or a real floppy) this works fine (works on every computer I've been able to test it on).


Cheers,

Brendan

Re:Extended read

Posted: Mon Feb 21, 2005 5:29 pm
by ribas
thanks Bredan i'll try your advice, i was trying to load a kernel that i manualy put in the imediate sector (2048 bytes) after my boot code using no emulation i'm able too boot and dectect int 13 extensions ... a20 etc... and load the kernel (all this works fine) under 1 mb... i'll try unreal mode to load'it and move it above 1 mb. I really want to do this without emulation ... if i faill i'll try de floppy emulation thing.. if you have some code ...it would be helpfull. Thanks for your reply!

Re:Extended read

Posted: Mon Feb 21, 2005 6:34 pm
by ribas
if anyone can help ....

Re:Extended read

Posted: Tue Feb 22, 2005 2:01 am
by bubach
Just wondering what you are doing here:

Code: Select all

org   0x7c00
use16

   ; Entry point for initial bootstap code
boot:
   jmp   start
   nop
Trying to make a bootsector or a second stage loader?

Re:Extended read

Posted: Tue Feb 22, 2005 2:45 am
by ribas
trying to make a bootsector that jumps to the kernel at 1 mb ...
i thing i'll try de floppy emulation thing.. i'm new to this .... i've looked a lot of code (including your own ... ) ... i figured that cd-roms don?t have the 512 byte limit and so i tried to make a bootsector that does everything (check cpu,a20,memory) and load a kernel at 1 mb. I'm able to load it below .... i just want to load it at 1 mb. the kernel must reside in the imediate sector after the bootloader. i get the lba of the kernel through the bootsector lba + bootsector size ... bootsector is aligned in 2048 bytes sectors. thanks for the reply

Re:Extended read

Posted: Tue Feb 22, 2005 3:16 am
by Pype.Clicker
afaik, the "extended read" is not able to go beyond 1MB, not more than legacy "read" is. So you're back to the two good-old options:
- load everything below 1MB, switch to pmode then move data to their final location
- switch to unreal mode, and repeat "read chunk, move chunk above 1MB" for each "chunk" of data you need to read (esp. useful when you have more than 640KB of kernel to load)

Re:Extended read

Posted: Tue Feb 22, 2005 3:47 am
by ribas
can you give some links ... where i can see how to move the code ....

assuming i've loaded at 0x80000 linear how can i move it to 0x100000 ?????

Re:Extended read

Posted: Tue Feb 22, 2005 3:55 am
by Pype.Clicker
http://www.osdev.org/osfaq2/index.php/UnrealMode

then simply

Code: Select all

   ;; assume ds == es == flat, unreal segment
   mov esi, 0x  80000  ; this is, 128Kb before A000 vga area
   mov edi, 0x100000 ; and this is 1MB
   mov ecx, 0x8000    ; 0x8000 * 4 = 128KB
   rep movsd               

Re:Extended read

Posted: Tue Feb 22, 2005 4:14 am
by ribas
thanks! i'll try it

Re:Extended read

Posted: Tue Feb 22, 2005 4:29 am
by ribas
;; assume ds == es == flat, unreal segment
mov esi, 0x 80000 ; this is, 128Kb before A000 vga area

i think this is my real mode buffer ...

mov edi, 0x100000 ; and this is 1MB

destination ....
mov ecx, 0x8000 ; 0x8000 * 4 = 128KB

??? size??
rep movsd

thanks

Re:Extended read

Posted: Tue Feb 22, 2005 4:51 am
by Pype.Clicker
ribas wrote: mov ecx, 0x8000 ; 0x8000 * 4 = 128KB
??? size??
Yup, in a rep xxxsx thing, ecx contains the number of item to be moved/stored/loaded/scanned ...

Here, I was using "movsd" so the count should be given in number of dwords (0x80 for a 512-bytes sector).

Re:Extended read

Posted: Tue Feb 22, 2005 6:28 am
by bubach
Hmm.. All that code wont fit in the bootsector and you don't have any bootsignature.
I saw that you used my old code, which imho sucks.. ;)
I can't remember how much of that I actually wrote, and how much is "borrowed", plus that I didn't know much Assembly when I did that. If you want to look at my newest bootsector which loads a file (up to ~576kb big) into mem at 64kb, enables pmode and a20, download BOS 0.03 from my website: http://bos.asmhackers.net/

You should be able to modify it by changing the drivenumber (and some other stuff) to fit a cdrom-drive.

Re:Extended read

Posted: Tue Feb 22, 2005 7:22 am
by ribas
thank you all .. i'll try the floppy emulation, seems more compatible, i think that it is possible to end that emulation after loading the kernel. Is it possible to set a resolution 800x600 32bpp im pm mode or it's best to do'it iin the loader? fasm or nasm ? ... i reallly like fasm..

Re:Extended read

Posted: Tue Feb 22, 2005 8:06 am
by Pype.Clicker
it is theorically possible to setup a video mode like 800x600 after pm switch, but it is *way* easier to set it up *before* ;)