Page 1 of 1

Trying to read a 64 sector cluster

Posted: Mon Nov 28, 2016 2:41 pm
by digo_rp
Hi guys, I´m having a problem reading a 64 Sector cluster using a read function at AHCI from osdev docs,

As I can see that the most I can read is 8 sectors per cluster...

I have a 500GB harddisk on old notebook. and I format it as FAT32 using GParted.

could anyone help me please?

I don´t know how to read it that 64 sectors per cluster....

thnx so much...

Re: Trying to read a 64 sector cluster

Posted: Mon Nov 28, 2016 2:54 pm
by Octocontrabass
I'm pretty sure AHCI can handle a lot more than 64 sectors at a time.

If it can't, then you'll have to split it up into multiple shorter requests.

Re: Trying to read a 64 sector cluster

Posted: Mon Nov 28, 2016 3:49 pm
by digo_rp
could you please give some direction, how can I split it in small blocks? please

when I choose to read 64 sectors it returns nothing...

Re: Trying to read a 64 sector cluster

Posted: Mon Nov 28, 2016 4:25 pm
by digo_rp
I found it! now I can read that 64 sectors... I made a small modification.

//
// 8K bytes (16 sectors) per PRDT
//

from below
for (int i=0; i<cmdheader->prdtl-1; i++) {
cmdtbl->prdt_entry.dba = (DWORD)buf;
cmdtbl->prdt_entry.dbc = 8*1024; // 8K bytes
cmdtbl->prdt_entry.i = 1;
buf += 4*1024; // 4K words
count -= 16; // 16 sectors
}

to below

for (int i=0; i<cmdheader->prdtl-1; i++) {
cmdtbl->prdt_entry.dba = (DWORD)buf;
cmdtbl->prdt_entry.dbc = 32*1024; // 32K bytes
cmdtbl->prdt_entry.i = 1;
buf += 16*1024; // 16K words
count -= 64; // 64 sectors
}

now i can read it...

I just put here my modifications in case help somebody.

thx a lot.

Re: Trying to read a 64 sector cluster

Posted: Mon Nov 28, 2016 5:01 pm
by digo_rp
I´m so sorry I forgot to put that line too

from

cmdheader->prdtl = (WORD)((count-1)>>4) + 1; // PRDT entries count

change to

cmdheader->prdtl = (WORD)((count-1)>>6) + 1; // PRDT entries count

those modifications allows you to read a 64 sectors...

thnx a lot all