News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

More OS problems!!

Started by thomasantony, January 24, 2005, 08:23:51 AM

Previous topic - Next topic

thomasantony

Hi,
    I tried out the scroll functions given in this forum before. I am also making a FAT driver. I am trying to read a 3k file into a 3k buffer. But read fails at sector 53(0 based). Here the problem is that my LBA to CHS routine gives out the sector num as 18 when it should never be greater than 17. I get it like this (LBA % SPT)+1 . As for the scroll function. The system is resetting after it scrolls up. It actually scrolls up about 10 lines before it resets when it should scroll only once. !! :dazzled: Plz tell me what I should do. And abt the sector num I give to the FDC, is it 0based or 1 based. In an example prog I saw, the author uses the above formula itself to get the sector num. ::)

Thomas Antony

[attachment deleted by admin]
There are 10 types of people in the world. Those who understand binary and those who don't.


Programmer's Directory. Submit for free

MichaelW

CHS sector numbers are 1 based. LBA numbers are 0 based.

Per the ATA/ATAPI 5 standard, for LBA numbers <= 16,514,064:

LBA=(((cyl_number * heads_per_cyl) + head_number) * sectors_per_track) + sector_number – 1

This can be transposed to convert from LBA to CHS, as I did for this QuickBASIC code:

SUB GetChs (cyl&, head&, sector&, logicalBlockAddress&, heads&, sectorsPerTrack&)
  ' Translates the LBA specified by <logicalBlockAddress&> to
  ' a CHS address and returns the CHS address in <cyl&>, <head&>,
  ' and <sector&>.
  '
  ' This procedure uses a transposed version of the relationship
  ' specified in the ATA standard for LBA numbers <= 16,514,064.

  cyl& = logicalBlockAddress& \ (heads& * sectorsPerTrack&)
  remainder& = logicalBlockAddress& MOD (heads& * sectorsPerTrack&)
  head& = remainder& \ sectorsPerTrack&
  sector& = remainder& MOD sectorsPerTrack& + 1
END SUB

Note that heads& is the same value as heads_per_cyl.

You can download the draft versions of the ATA/ATAPI and related standards from http://www.t13.org.
Note that the version 6 and later standards refer to the version 5 standard for the LBA/CHS translation.
eschew obfuscation

thomasantony

Hi,
    The formula I used was correct. Thaxn for the info anyway. It will be useful when I code the hdd driver. I am now rebuilding my FDC driver THE 2nd TIME :dazzled: :dazzled: . Maybe this time, it will work ok. It was working ok when it read some sectors but there seems to be some problem

Thomas Antony
There are 10 types of people in the world. Those who understand binary and those who don't.


Programmer's Directory. Submit for free

BogdanOntanu

Do not worry i have redesigned the Floppy driver many times and always in small steeps (i guess at least 4 times until now)
And I am still not satisfied ;) i will need a notification callback added to driver requests...
Ambition is a lame excuse for the ones not brave enough to be lazy.
http://www.oby.ro

thomasantony

Hi,
    Take a look at this. When I call FAT12_LoadFile the code goes into bogus memory on the second call the ReadSector. I think the memory is becoming corrupted or something. I found this using the Bochs debugger.

Thomas Antony :U

[attachment deleted by admin]
There are 10 types of people in the world. Those who understand binary and those who don't.


Programmer's Directory. Submit for free