Reading sectors FDC on CPU x86 in protected 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.
User avatar
Neo92
Member
Member
Posts: 28
Joined: Tue Jun 24, 2014 9:41 am

Reading sectors FDC on CPU x86 in protected mode

Post by Neo92 »

Hi all, i post this code for reading sectors of the floppy. My question is... why the emulator Bochs show 'partial read() on floppy image returns 510/512' (usually when it does is OK) and doesn't read the next sector with 'call'? Through 'int 13h' is allowed, strange or something wrong? :?

The code
User avatar
Brendan
Member
Member
Posts: 8561
Joined: Sat Jan 15, 2005 12:00 am
Location: At his keyboard!
Contact:

Re: Reading sectors FDC on CPU x86 in protected mode

Post by Brendan »

Hi,
Neo92 wrote:Hi all, i post this code for reading sectors of the floppy. My question is... why the emulator Bochs show 'partial read() on floppy image returns 510/512' (usually when it does is OK) and doesn't read the next sector with 'call'? Through 'int 13h' is allowed, strange or something wrong? :?
How large if the floppy disk image you're using (and can I guess that the floppy image itself is 510 bytes, and not 1474560 bytes or any other multiple of 512 bytes)?


Cheers,

Brendan
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
User avatar
Neo92
Member
Member
Posts: 28
Joined: Tue Jun 24, 2014 9:41 am

Re: Reading sectors FDC on CPU x86 in protected mode

Post by Neo92 »

Hi Brendan, i must to read the second sector's floppy by first. The image is large 1024 bytes (exactly 1022 bytes) divided into 512 bytes for sector. I wouldn't want that there are the mistakes into initialization ports or DMA, i don't know... i will try of read back functions, also if is strange that with interrupt 0x13 read it. :? :(
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: Reading sectors FDC on CPU x86 in protected mode

Post by Combuster »

A floppy image must be exactly the 1.4M size of an actual floppy, anything else makes VMs trip - in different fashions depending on the emulator in question.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
User avatar
Neo92
Member
Member
Posts: 28
Joined: Tue Jun 24, 2014 9:41 am

Re: Reading sectors FDC on CPU x86 in protected mode

Post by Neo92 »

Hi Combuster, i know that the standard format floppy is 1.44 MB but my problem is reading sectors through ports in protected mode, don't work. Why?

The code
Icee
Member
Member
Posts: 100
Joined: Wed Jan 08, 2014 8:41 am
Location: Moscow, Russia

Re: Reading sectors FDC on CPU x86 in protected mode

Post by Icee »

You have already been given the answer -- not only is your image of invalid size, it's also even not sector (512 byte) granular.
User avatar
SpyderTL
Member
Member
Posts: 1074
Joined: Sun Sep 19, 2010 10:05 pm

Re: Reading sectors FDC on CPU x86 in protected mode

Post by SpyderTL »

Just add zeros to the end of your image until it is 1474560 bytes long, and see if the problem goes away. If not, let us know.
Project: OZone
Source: GitHub
Current Task: LIB/OBJ file support
"The more they overthink the plumbing, the easier it is to stop up the drain." - Montgomery Scott
User avatar
Neo92
Member
Member
Posts: 28
Joined: Tue Jun 24, 2014 9:41 am

Re: Reading sectors FDC on CPU x86 in protected mode

Post by Neo92 »

This is my code on FASM:

The code, 3rd revision
I use DMA and FDC. I don't believe that needs add the zeros, because otherwise, how does it work with interrupt 0x13?
onlyonemac
Member
Member
Posts: 1146
Joined: Sat Mar 01, 2014 2:59 pm

Re: Reading sectors FDC on CPU x86 in protected mode

Post by onlyonemac »

The BIOSes in a lot of emulators don't implement int 13 through the standard FDC subsystem; they work through a "back door" route which may or may not be able to handle incorrectly sized images.

Now can you please increase the size of your image before posting again, and repeatedly posting the same (or very similar) code is not going to fix your problem.
When you start writing an OS you do the minimum possible to get the x86 processor in a usable state, then you try to get as far away from it as possible.

Syntax checkup:
Wrong: OS's, IRQ's, zero'ing
Right: OSes, IRQs, zeroing
User avatar
Neo92
Member
Member
Posts: 28
Joined: Tue Jun 24, 2014 9:41 am

Re: Reading sectors FDC on CPU x86 in protected mode

Post by Neo92 »

I increase the size of my image (1474560 byte=1 Mbyte) but without reply.

The code, 4th revision
onlyonemac
Member
Member
Posts: 1146
Joined: Sat Mar 01, 2014 2:59 pm

Re: Reading sectors FDC on CPU x86 in protected mode

Post by onlyonemac »

Neo92 wrote:I increase the size of my image (1474560 byte=1 Mbyte) but without reply.
Then let us know so we don't all criticise you :) .
When you start writing an OS you do the minimum possible to get the x86 processor in a usable state, then you try to get as far away from it as possible.

Syntax checkup:
Wrong: OS's, IRQ's, zero'ing
Right: OSes, IRQs, zeroing
User avatar
SpyderTL
Member
Member
Posts: 1074
Joined: Sun Sep 19, 2010 10:05 pm

Re: Reading sectors FDC on CPU x86 in protected mode

Post by SpyderTL »

Neo92 wrote:I increase the size of my image (1474560 byte=1 Mbyte) but without reply.
So, to clarify, is it working now? Does Bochs give you the "Partial" error any more?

By the way, you could probably use the following code instead:

Code: Select all

times 1474560-$ db 0
Also, in your original code, the second sector should end with:

Code: Select all

times 512-($-start) db 0
since you don't have the 2 byte magic number (0xaa55) at the end of that sector. Only the first sector has that.
Project: OZone
Source: GitHub
Current Task: LIB/OBJ file support
"The more they overthink the plumbing, the easier it is to stop up the drain." - Montgomery Scott
User avatar
Neo92
Member
Member
Posts: 28
Joined: Tue Jun 24, 2014 9:41 am

Re: Reading sectors FDC on CPU x86 in protected mode

Post by Neo92 »

Aaaaaac! #-o Works in Bochs! But with delay, i don't know why... :-s
User avatar
Candy
Member
Member
Posts: 3882
Joined: Tue Oct 17, 2006 11:33 pm
Location: Eindhoven

Re: Reading sectors FDC on CPU x86 in protected mode

Post by Candy »

I moved the code out of your posts into Pastebin, so the thread is readable again. Please try to use some other code hosting site - can I suggest version control as well - when you want to paste something that's more than a few lines long?
User avatar
Neo92
Member
Member
Posts: 28
Joined: Tue Jun 24, 2014 9:41 am

Re: Reading sectors FDC on CPU x86 in protected mode

Post by Neo92 »

Thanks Candy, i don't knowed this rule, in the future i'll try don't repeat this action and i'm sorry. But i still don't understand why the floppy reading into second sector is slow. I don't want to read the second sector with interrupt 0x13 (that works) but through ports with DMA, that's all. :?:
Post Reply