Rockbox mail archive
Subject: Re: Digrom2/ATA2
From: alankorr (alankorr_at_subdimension.com)
> > I noticed Alan's code still has a signed 'cluster_hi' on
> line 348. What
> > happens if you make it unsigned?
Nothing because "(short_word)<<16" discards the high 16 bits
so unsigned or signed case don't matter.
> Just 1 question : I've started learning ATA manipulation,
> structures and LFN;
> The thing I can't figure is :
> To search for the content of a given file, the method :
> Byte 0 : MBR => Byte 0x7E00 (sector 63) : PBR / Boot
> sector => Byte 0xBE00
> (start + 32 * res_sector ) : FAT table / root dir
> Here we get every file's cluster list, right ??
> But how can we make link between those cluster list with
> the file names ???
MBR (Master Boot Record) contains partition table, because
i'm lazy, i just lookup the first partition and find its
start sector (start_sector_of_part0).
This sector is also the BPB (Boot Parameter Block) for this
- check partition is a FAT32 filesystem
- get the cluster number which contains the first cluster of
our root directory
- get the reserved sectors to figure out from where FAT
- get the number of FAT
- get the total sectors for one FAT
The start sector of the first FAT begins at :
start_sector_for_partition + reserved_sectors.
The first data sector begins just after the last FAT, i.e :
start_sector_for_partition + reserved_sectors +
number_of_FAT * total_sectors_for_one_FAT.
The first two entries in FAT are reserved (FFFFFFF8
The next entry is the first root cluster but not necessarily
(why you must get it from BPB).
Getting the first root cluster, you can read its sectors and
find out our files.
However, if files are not in the cluster, its modulo 128
gives us its entry on FAT sector number (cluster / 128),
reading the long word give you the next cluster for root
directory if exists. So we loop to continue finding out our
One file is found, we get its entry which gives us where the
file is located : its first cluster.
Juste read this cluster. And if you need to write several
cluster, the next cluster is got the same way we did for
Sorry for trouble with ATA.C, it worked for me because my
hardisk just contains very few files (don't want to waste my
files during development).
It will take me a long time before I find the trouble
because i'm still ill.
In fact, this ATA.C is just for DIGROM, not for a more
general distribution and should not prevent you from doing
your own ATA or FAT32 codings.
// free anonymous email || forums \\ subZINE || anonymous browsing
subDIMENSION -- http://www.subdimension.com
Page was last modified "Jan 10 2012" The Rockbox Crew