News:

Printed Amstrad Addict magazine announced, check it out here!

Main Menu

X-MASS, a mass-storage expansion for all CPC.

Started by TotO, 18:32, 14 December 14

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

arnoldemu

Quote from: gerald on 14:07, 26 February 16
Did you wait for the data ready flag ?
After sending a command, you have to poll the status register. As long as bit 7 of this register is high, the command is still in progress and other bit are not valid. Reading data register during this time will return garbage.
@Ast: Sorry I didn't add that to my example code.
My games. My Games
My website with coding examples: Unofficial Amstrad WWW Resource

Ast

Yes I do this to wait for data request :


wait    ld bc,#Fd0f
waitda in a,(c)
          and #08
          jr z,waitda
...

just before my read routine...

my proggy is like that :


          ...
          ld bc,#Fd0e
          ld a,0+%01000000 ; set bit 6 to 1 to enter LBA Mode
          out(c),a
;
          ld bc,#fd0a
          ld a,1 ; sector count
          out (c),a
          inc c
;
          ld a,0 ; sector number - bits (7:0)
          out (c),a
          inc c
;   
          ld a,0 ; cylinder low - bits (15:8)
          out (c),a
          inc c
;
          ld a,0 ; cylinder high - bits (23:16)
          out (c),a
          inc c
;
          ld a,#20 ; Read function
          out (c),a
;
          call wait ; wait request
          ld bc,#fd08 ; ide data
          ld hl,#1000 ; buffer
          ld de,512
read    in a,(c)
          ld (hl),a
          inc hl
          dec de
          ld a,d
          or e
          jr nz,read
          ret

Here you could find the entire routine i wrote to read x-Mass Lba data...
Give me your opinion and where i made mistakes to read Lba0 ????

_____________________

Ast/iMP4CT. "By the power of Grayskull, i've the power"

http://amstradplus.forumforever.com/index.php
http://impdos.wikidot.com/
http://impdraw.wikidot.com/

All friends are welcome !

arnoldemu

@Ast: code looks good to me.

Does your code get to the reading of the data register? Maybe your code is stuck waiting for data ready but device has return an error?
My games. My Games
My website with coding examples: Unofficial Amstrad WWW Resource

Ast

Yes my code read data and put the result in #1000 up to #11FF.
I made some tests modifing sector number and many #ff byte are written in the zone (#1000-#11FF)
I don't find LBA0 and I don't know how to find it... pfff... What a pity !
_____________________

Ast/iMP4CT. "By the power of Grayskull, i've the power"

http://amstradplus.forumforever.com/index.php
http://impdos.wikidot.com/
http://impdraw.wikidot.com/

All friends are welcome !

Ast

When I put sector num to 70, I have the follwing result... Is it good ????
_____________________

Ast/iMP4CT. "By the power of Grayskull, i've the power"

http://amstradplus.forumforever.com/index.php
http://impdos.wikidot.com/
http://impdraw.wikidot.com/

All friends are welcome !

Fessor

For a boot Sector it looks good,  comparing with this
MS-DOS 5.0 Floppy Disk Boot Record


*edit*
Overseen "Sector 70"

Ast

So with all these informations who could tell me which value i'd have  to put to access root directory ?
_____________________

Ast/iMP4CT. "By the power of Grayskull, i've the power"

http://amstradplus.forumforever.com/index.php
http://impdos.wikidot.com/
http://impdraw.wikidot.com/

All friends are welcome !

gerald

Quote from: Ast on 15:35, 26 February 16
So with all these informations who could tell me which value i'd have  to put to access root directory ?
To know where the root directory is located, you 1st need to determine which FAT you are looking at.
For FAT12/FAT16 this is a reserved area, and its location is expressed in LBA on the FAT boot sector.
For FAT32 this is a regular folder and its location is expressed in cluster on the FAT boot sector.
All this is well explain in the FAT32 specification (Chapter 3.5, P14).

Fessor

From the Values of the Screenshot
Byte B+C = 00 02 = 0x200 = 512 Bytes per Sector
Byte D = 2 = 2 Sectors per Cluster
Byte E + F = 21 00 = 0x21 = 21 reserved Sectors (starting with Sector 0) ; Fat begins at logical Sector nr 21.
Byte 10 = 2 = 2 FATs on disc
Byte 11+12 = Value for possible Root directory Entrys (dunno why set to 0)
Byte 13+14 = Total Sectors on Disc (dunno why set to 0)


Prodatron

Quote from: Fessor on 16:13, 26 February 16Byte 11+12 = Value for possible Root directory Entrys (dunno why set to 0)
Byte 13+14 = Total Sectors on Disc (dunno why set to 0)
Because it's a FAT32 partition, which leaves 0 here and uses 32bit values at another place (see the Microsoft documentation).

GRAPHICAL Z80 MULTITASKING OPERATING SYSTEM

Ast

#460
Quote from: gerald on 16:06, 26 February 16
To know where the root directory is located, you 1st need to determine which FAT you are looking at.
For FAT12/FAT16 this is a reserved area, and its location is expressed in LBA on the FAT boot sector.
For FAT32 this is a regular folder and its location is expressed in cluster on the FAT boot sector.
All this is well explain in the FAT32 specification (Chapter 3.5, P14).
In my case, my x-Mass is Fat32 format. So what are the value to access directory ? explanations will be welcomed.

(of course, i see the following formula : RootDirSectors = ((BPB_RootEntCnt * 32) + (BPB_BytsPerSec – 1)) / BPB_BytsPerSec)

the calcul would be :

((2*32)+(512-1))/512 -> 64,99.....
_____________________

Ast/iMP4CT. "By the power of Grayskull, i've the power"

http://amstradplus.forumforever.com/index.php
http://impdos.wikidot.com/
http://impdraw.wikidot.com/

All friends are welcome !

gerald

Quote from: Ast on 17:10, 26 February 16
In my case, my x-Mass is Fat32 format. So what are the value to access directory ? explanations will be welcomed.

(of course, i see the following formula : RootDirSectors = ((BPB_RootEntCnt * 32) + (BPB_BytsPerSec – 1)) / BPB_BytsPerSec)

the calcul would be :

((2*32)+(512-1))/512 -> 64,99.....
((2*32)+(512-1))/512 = 64, you're doing integer calculation.
Are you sure you have a FAT32 ? Your BPB_RootEntCnt sould be 0, and RootDirSectors= 0
Note that RootDirSectors tells you the size (in sectors) of the root directory, not where it is located.

Ast

@Gerald : see pictures in reply #454, you could see FAT32... (address #1050)
_____________________

Ast/iMP4CT. "By the power of Grayskull, i've the power"

http://amstradplus.forumforever.com/index.php
http://impdos.wikidot.com/
http://impdraw.wikidot.com/

All friends are welcome !

Prodatron

Please have a look at the document.
It says (page 13):
QuoteRootDirSectors = ((BPB_RootEntCnt * 32) + (BPB_BytsPerSec – 1)) / BPB_BytsPerSec;
Note that on a FAT32 volume the BPB_RootEntCnt value is always 0, so on a FAT32 volume RootDirSectors is always 0.

RootDirSectors is not the start position of the root directory but its size for FAT12 and FAT16 partitions.

The root directory of a FAT32 partition starts at this cluster (page 22):
QuoteFor FAT32, the root directory can be of variable size and is a cluster chain, just like any other
directory is. The first cluster of the root directory on a FAT32 volume is stored in BPB_RootClus.

GRAPHICAL Z80 MULTITASKING OPERATING SYSTEM

Ast

The value (4 bytes) is 0x00000002, so the result is the same as previous... 64
and now ?
_____________________

Ast/iMP4CT. "By the power of Grayskull, i've the power"

http://amstradplus.forumforever.com/index.php
http://impdos.wikidot.com/
http://impdraw.wikidot.com/

All friends are welcome !

gerald

Quote from: Ast on 17:47, 26 February 16
The value (4 bytes) is 0x00000002, so the result is the same as previous... 64
and now ?
RootEntCnt is 2 byte, at offset 17 (0x11) : 0x0000 on the picture you posted  ;)

Ast

So, when you take the 2 bytes (#3F,#00)...
the result is 1,121.... so... the winner is ?????
_____________________

Ast/iMP4CT. "By the power of Grayskull, i've the power"

http://amstradplus.forumforever.com/index.php
http://impdos.wikidot.com/
http://impdraw.wikidot.com/

All friends are welcome !

gerald

Quote from: Ast on 18:07, 26 February 16
So, when you take the 2 bytes (#3F,#00)...
the result is 1,121.... so... the winner is ??? ??
0x00 0x00, where do you see 3F 00 at offset 0x11 ?
[attachimg=1]

Ast

J'étais parti sur #17 (juste en dessous :-p). Désolé je parlais en Hexa.
J'ai confondu 17 avec #17...

Donc je ne vois pas ce que ça peut donner et où trouver ce ?#** de directory...
_____________________

Ast/iMP4CT. "By the power of Grayskull, i've the power"

http://amstradplus.forumforever.com/index.php
http://impdos.wikidot.com/
http://impdraw.wikidot.com/

All friends are welcome !

Ast

That's normal to have 00 because the doc says : **

For FAT32 volumes, this field must be set to 0.
_____________________

Ast/iMP4CT. "By the power of Grayskull, i've the power"

http://amstradplus.forumforever.com/index.php
http://impdos.wikidot.com/
http://impdraw.wikidot.com/

All friends are welcome !

gerald

Quote from: Ast on 18:16, 26 February 16
Donc je ne vois pas ce que ça peut donner et où trouver ce ?#** de directory...
Si tu t'arrete a ca, t'es pas pret de le trouver  :laugh:


You need to follow the procedure :
Get the partition type. To do this you have to know the total number of cluster available for data storage :
DataSec = TotSec – (BPB_ResvdSecCnt + (BPB_NumFATs * FATSz) + RootDirSectors);
CountofClusters = DataSec / BPB_SecPerClus


Now you know which fat type you have with this test :
If(CountofClusters < 4085) {
/* Volume is FAT12 */
} else if(CountofClusters < 65525) {
/* Volume is FAT16 */
} else {
/* Volume is FAT32 */
}


Once you know you fat type, you know where to get your root directory sector/cluster
For FAT32 it's at offset 44 (0x2C), and it' a cluster number, not a sector.

To translate the cluster number to LBA, you have some additional calculation:
The 1st usable data sector is after the reserved sector, FAT(s),  and root dir sectors. And you have to remember that sectors are relative to the partition.
Something like

sector = PartitionOffset                + // sectors a relative to start of partition
              cluster - 2                       +  // cluster start at 2
              BPB_RsvdSecCnt            +  // 
              FATSize * BPB_NumFATs + // FATSize location is function of fat type, number of fat can be 1 or more
              RootDirSectors


Ast

So, I must calculate to see the result :)
_____________________

Ast/iMP4CT. "By the power of Grayskull, i've the power"

http://amstradplus.forumforever.com/index.php
http://impdos.wikidot.com/
http://impdraw.wikidot.com/

All friends are welcome !

Ast

To Gerald :

if BPB_FATSz16 (Offset 22, 2 bytes) field is fill of zero (00 00), you have a FAT32 volume....
_____________________

Ast/iMP4CT. "By the power of Grayskull, i've the power"

http://amstradplus.forumforever.com/index.php
http://impdos.wikidot.com/
http://impdraw.wikidot.com/

All friends are welcome !

Prodatron

#473
The document describes it very clearly:

Quote
If(CountofClusters < 4085) {
/* Volume is FAT12 */
} else if(CountofClusters < 65525) {
/* Volume is FAT16 */
} else {
/* Volume is FAT32 */
}
This is the one and only way that FAT type is determined. There is no such thing as a FAT12 volume
that has more than 4084 clusters. There is no such thing as a FAT16 volume that has less than 4085
clusters or more than 65,524 clusters. There is no such thing as a FAT32 volume that has less than
65,525 clusters.
[...]
NOTE: As is noted numerous times earlier, the world is full of FAT code that is wrong.

;)

PS: And yes, we already had problems on the MSX: Someone tried to extend FAT16 partitions in an illegal way, as he didn't follow this rule, and SymbOS was thinking that it's FAT32.

GRAPHICAL Z80 MULTITASKING OPERATING SYSTEM

Ast

#474
You're right Prodatron but what i have written is also written in the ide Microsoft's documentation... Just see Page 9.
_____________________

Ast/iMP4CT. "By the power of Grayskull, i've the power"

http://amstradplus.forumforever.com/index.php
http://impdos.wikidot.com/
http://impdraw.wikidot.com/

All friends are welcome !

Powered by SMFPacks Menu Editor Mod