Mailing List Archive

cbios disk read problems
Hey folks,

I am seeing this issue with machines on which I do I/O ops thru cbios
mode. I noticed some of the reads at high sectors seem to be returning
the wrong data even though the op itself succeds. The output of the
int 13 call returns EFLAGS: 0x246 (CF is 0) and EAX is 0x1, which
indicates success according to ralph brown's int13/02h page.

The I/O code is exactly the same as the one in chain.c, but moved into
io.c (I sent some patches recently so com32 modules can read data from
other disks and partitions).

I put a snippet of the read code here:
http://pastebin.ca/468529

My test involved reading sector 70686, for which the CHS calculated
was: 138, 0, 31. Also count is 1. The target disk is a 256MB USB
flashdrive, which i formated with

mkdiskimage -4 /dev/sdd 4 64 32

(I only wanted a 4MB boot partition, which ended up as sda4).

The target sector was supposed to have data for a file, but the data
it reads in cbios mode is coming out blank. ebios mode however does
get the right data for the same sector location.

My test had some other read cases where they seem to have succeeded:
sector 8450 and 8192. I also looked at what disk info was being
collected for the flash drive. disk info had sectors = 32 and heads =
16.

The only code change I have made is to accept a count varialbe to read
multiple sectors at a time. But I tried reverting to original chain.c
code with:

inreg.eax.w[0] = 0x0201; (on line 60 in pastebin link)

without any luck. Still the same blank data output.

Does anyone have experience with cbios intricacies or why this might
be happening? Thanks for any help.

--
Ram

_______________________________________________
SYSLINUX mailing list
Submissions to SYSLINUX@zytor.com
Unsubscribe or set options at:
http://www.zytor.com/mailman/listinfo/syslinux
Please do not send private replies to mailing list traffic.
Re: cbios disk read problems [ In reply to ]
Ram Yalamanchili wrote:
> Does anyone have experience with cbios intricacies or why this might
> be happening? Thanks for any help.
>
> --
> Ram

I'm a bit rusty on this sort of thing but you have to be very careful
with CHS translations. If the algorithm used at format/write time is not
the same as the algorithm used at read time then you will get issues
such as this. eg you can get problems formatting and filling a disk on a
machine with AMI BIOS and then trying to boot it on a machine with a
Phoenix BIOS.

Andrew

_______________________________________________
SYSLINUX mailing list
Submissions to SYSLINUX@zytor.com
Unsubscribe or set options at:
http://www.zytor.com/mailman/listinfo/syslinux
Please do not send private replies to mailing list traffic.
Re: cbios disk read problems [ In reply to ]
On 5/3/07, Andrew Goodbody <agoodbody@itronix.co.uk> wrote:
> Ram Yalamanchili wrote:
> > Does anyone have experience with cbios intricacies or why this might
> > be happening? Thanks for any help.
> >
> > --
> > Ram
>
> I'm a bit rusty on this sort of thing but you have to be very careful
> with CHS translations. If the algorithm used at format/write time is not
> the same as the algorithm used at read time then you will get issues
> such as this. eg you can get problems formatting and filling a disk on a
> machine with AMI BIOS and then trying to boot it on a machine with a
> Phoenix BIOS.
>
> Andrew
>
> _______________________________________________
> SYSLINUX mailing list
> Submissions to SYSLINUX@zytor.com
> Unsubscribe or set options at:
> http://www.zytor.com/mailman/listinfo/syslinux
> Please do not send private replies to mailing list traffic.
>
>

Hmm, I actually see this issue on both the machines I have here (Dell
laptop D410 and an AMI bios box). I think, in general there is
something wrong in the code. The algorithm to calculate CHS for reads
is the same one Peter wrote for chain.c32, and I confirmed from
wikipedia.

The disk was made entirely with mkdiskimage and mtools/mkfs.vfat. I
think this is unlikely, but is it possible that the cbios reads dont
support reading after certain disk region? Reading the 70k'ish sector
is around offset 34MB.. hmm..

thanks.

_______________________________________________
SYSLINUX mailing list
Submissions to SYSLINUX@zytor.com
Unsubscribe or set options at:
http://www.zytor.com/mailman/listinfo/syslinux
Please do not send private replies to mailing list traffic.
Re: cbios disk read problems [ In reply to ]
Ram Yalamanchili wrote:
>
> Hmm, I actually see this issue on both the machines I have here (Dell
> laptop D410 and an AMI bios box). I think, in general there is
> something wrong in the code. The algorithm to calculate CHS for reads
> is the same one Peter wrote for chain.c32, and I confirmed from
> wikipedia.
>
> The disk was made entirely with mkdiskimage and mtools/mkfs.vfat. I
> think this is unlikely, but is it possible that the cbios reads dont
> support reading after certain disk region? Reading the 70k'ish sector
> is around offset 34MB.. hmm..
>

Well, there is the cylinder < 1024 limitation of CBIOS; of course
individual BIOSes can have additional bugs.

-hpa

_______________________________________________
SYSLINUX mailing list
Submissions to SYSLINUX@zytor.com
Unsubscribe or set options at:
http://www.zytor.com/mailman/listinfo/syslinux
Please do not send private replies to mailing list traffic.
Re: cbios disk read problems [ In reply to ]
Ram Yalamanchili wrote:
>
> Hmm, I actually see this issue on both the machines I have here (Dell
> laptop D410 and an AMI bios box). I think, in general there is
> something wrong in the code. The algorithm to calculate CHS for reads
> is the same one Peter wrote for chain.c32, and I confirmed from
> wikipedia.
>
> The disk was made entirely with mkdiskimage and mtools/mkfs.vfat. I
> think this is unlikely, but is it possible that the cbios reads dont
> support reading after certain disk region? Reading the 70k'ish sector
> is around offset 34MB.. hmm..
>

34 MB sounds suspicious, since it's just above the 32 MB mark for 16-bit
linear sector numbers, by the way.

-hpa

_______________________________________________
SYSLINUX mailing list
Submissions to SYSLINUX@zytor.com
Unsubscribe or set options at:
http://www.zytor.com/mailman/listinfo/syslinux
Please do not send private replies to mailing list traffic.
Re: cbios disk read problems [ In reply to ]
On 5/3/07, H. Peter Anvin <hpa@zytor.com> wrote:
>
> Well, there is the cylinder < 1024 limitation of CBIOS; of course
> individual BIOSes can have additional bugs.

The CHS calculated was: 138, 0, 31 respectively.

So, i guess thats not the issue. Does the geometry gotten from the
disk info seem right? While doing the mkdiskimage, the parameters
were:

mkdiskimage -4 /dev/sdd 4 64 32

disk_info->sect is 32, but head is 16 from what i get from the bios.
Isn't it supposed to be 64 or am I missing something?

> 34 MB sounds suspicious, since it's just above the 32 MB mark for 16-bit
> linear sector numbers, by the way.
>
> -hpa
>
>
hmm ic.. i'll do some tests to see if reads go ok for files located
under the 32MB mark. This probably will show in chain.c32 too if the
partition is located above the 32MB mark. There is a possibility the C
version of this code is broken somehow compared to the CBIOS routine
in ldlinux.asm, etc. Will report back... :)

--
Ram

_______________________________________________
SYSLINUX mailing list
Submissions to SYSLINUX@zytor.com
Unsubscribe or set options at:
http://www.zytor.com/mailman/listinfo/syslinux
Please do not send private replies to mailing list traffic.
Re: cbios disk read problems [ In reply to ]
Ram Yalamanchili wrote:
> On 5/3/07, H. Peter Anvin <hpa@zytor.com> wrote:
>> Well, there is the cylinder < 1024 limitation of CBIOS; of course
>> individual BIOSes can have additional bugs.
>
> The CHS calculated was: 138, 0, 31 respectively.
>
> So, i guess thats not the issue. Does the geometry gotten from the
> disk info seem right? While doing the mkdiskimage, the parameters
> were:
>
> mkdiskimage -4 /dev/sdd 4 64 32
>
> disk_info->sect is 32, but head is 16 from what i get from the bios.
> Isn't it supposed to be 64 or am I missing something?

Not necessarily. The BIOS is free to pick its own geometry; that's why
SYSLINUX queries the BIOS geometry at runtime.

-hpa

_______________________________________________
SYSLINUX mailing list
Submissions to SYSLINUX@zytor.com
Unsubscribe or set options at:
http://www.zytor.com/mailman/listinfo/syslinux
Please do not send private replies to mailing list traffic.