read sector bios call in v86 mode

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
Prabu

read sector bios call in v86 mode

Post by Prabu »

I had setup'd my v86 mode right.

I tested it by calling bios int 0x10 (with ax = 0x12) to switch to video mode 0x12. This works fine.

But I can't read a sector from my diskette using bios call
int 0x13
(with ax = 0x201, bx = 0, es = 0x1000, cx = 1, dx = 0)


bochs exits with this error :

FATAL : floppy recal : f07: ctrl not ready
>> : out dx, ax

BIOS panic at rombios.c line 1558

note:
I hadn't mapped the floppy interrupt to call bios. Does this causing the problem for me.

Advanced thanks! for your help!
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:read sector bios call in v86 mode

Post by Pype.Clicker »

honestly, i don't recommend you use V86 for floppy accesses. The main reason is that floppy programming relies too much on timer handler, floppy IRQ handler and DMA programming, which will all be 'weirdly' behaving (at best) in a V86 environment (e.g. DMA especially will be somehow tricky to handle)
ASHLEY4

Re:read sector bios call in v86 mode

Post by ASHLEY4 »

I agree with Clicker, i switch back to realmode from pmode for graphic mode switching, works fine, but if i try use int 13h for floppy access, i get big problems.

But i also have problems with a pmode floppy driver i made, works fine on at lest 30 pc that its been tested on, but does not work on any emulator, including bochs ?.

\\\\||////
(@@)
ASHLEY4.

Batteries not included, Some assembly required.
Prabu

Re:read sector bios call in v86 mode

Post by Prabu »

ok. guys I will write my own protected mode floppy driver.


Can I atleast use int 0x13 to access hard disk.
Chris Giese

Re:read sector bios call in v86 mode

Post by Chris Giese »

>floppy IRQ handler

This could be the main problem. Hardware interrupts must be up and running to use INT 13h for floppy access. In my own code, I "reflect" the hardware interrupts into V86 mode.

Because you have interrupts nested inside other interrupts, the V86 mode monitor must be re-entrant. Apart from initializing the V86 mode session, try to avoid accessing global or static local variables in the V86 mode monitor code.

>and DMA programming, which will all be 'weirdly' behaving (at best) in a V86 environment

Not really, unless you have paging enabled.

>(e.g. DMA especially will be somehow tricky to handle)

Things to check:
  • the buffer is below 1 megabyte (a restriction of INT 13h)
  • the buffer memory is physically contiguous
  • the DMA operation does not cross a physical 64K boundary (easy: make the buffer 2^N bytes long, and align it to a 2^N-byte boundary)
  • if you use address translation (paging or segmentation), make sure the conversion to physical address is done correctly
This code is not well-tested, but it seems to work:
http://my.execpc.com/~geezer/osd/pmode/v86mm.zip
Prabu

Re:read sector bios call in v86 mode

Post by Prabu »

Yes, u are right, it depends on floppy irq handler.

I checked it out in real mode. In real mode I masked all other irq's except floppy irq and tested int 0x13, it works fine.

In v86 mode i tried the same.

But the hell, No interrupt is raised.
ASHLEY4

Re:read sector bios call in v86 mode

Post by ASHLEY4 »

Do you remap the pic ?, in your OS.

\\\\||////
(@@)
ASHLEY4.

Batteries not included, Some assembly required.
Prabu

Re:read sector bios call in v86 mode

Post by Prabu »

Yes! I had remapped the pic, so that pic master interrupts are from 0x28 and slave's interrupts are from 0x70
Prabu

Re:I got it!!!

Post by Prabu »

hi friends,

<happy>I can read a floppy or hdd sector using int 0x13 in v86 mode</happy>

i solved the problem that i asked you before some days.

let me say u what I did to solve the problem,
it is very simple.

before entering into v86 mode to call int 0x13
i wrote this command.

mov dx, FLOPPY_MAIN_STATUS_REGS
mov al, 0
out dx, al ; selects no drive and resets the
; controller

call wait
mov al, SELECT_DRIVEA ; selects the current drive
out dx, al


not just this much,
I also mapped the floppy irq to call real mode int service routine.

before calling the irq I had called the mrqloop function
and the loop iterates until the floppy is ready to expect
the command from cpu.

This works fine in BOCHS!

In real machine int 0x13 returns with success but there is
no data in the buffer.

Later I changed my code to retry 3 times. Then! " I got it! "

so ! I can use int 0x13 using v86 mode to read floppy sectors

I tried the same to read hard disk!
I had mapped the hard disk irq's to respective real mode isr's.
It works fine ! I read the first sector (where the partition table reside) of my hard disk using these commands.

In my OS I have a function in protected mode to call bios functions like this

struct regs *callbios16(struct regs *, ulong es, ushort interrupt_number);

so to read a floppy sector
I just say

struct regs r; /* this struct also includes flags */

r.ax = 0x201
r.bx = 0x0
r.cx = sector
r.dx = 0x0
r = *(callbios16(&r, 0x700, 0x13);

and to read a hdd sector
I just say

r.ax = 0x201
r.bx = 0x0
r.cx = sector
r.dx = 0x80
r = *(callbios16(&r, 0x700, 0x13);


comming back to solving problems, Most problems in OS seems a big head ache at first! but later they will be solved using a simple solution!

I know the function callbios16 will help me to proceed developing my Filesystem.

After fininshing my file system i will come back to floppy and ide to write my own protected mode device drivers for them.


Hi friends, If you can't understand my explanations about how I solved and if you are interested in using int 0x13 to read floopy sector and stuck up, ask me I can post my OS code in my website!

so every one can use it and go fast in developing an OS!
Post Reply