Merged to master at e68a8934c7fd..ac67a8b3dfc0 (from, to]

You can see the entire diff with 'git diff' or at
https://github.com/brho/akaros/compare/e68a8934c7fd...ac67a8b3dfc0


good times with sign extension!
(http://stackoverflow.com/questions/7554560/sign-extension-with-unsigned-long-long)


On 2016-10-20 at 12:00 "Ronald G. Minnich" <[email protected]> wrote:
> From: Fergus Simpson <[email protected]>
> 
> Drive reads were not working past the 1 TiB mark because the resulting
> address was negative. This was determined to be an issue with an
> unsigned char getting sign extended when bit shifted into an int64_t.
> It is now cast to a uint32_t after the shift to prevent sign
> extension. The container was also changed from int64_t to uint64_t.
> 
> Change-Id: I590b0da4fd0c02b0e2542a0b65bde510bba89525
> Signed-off-by: Fergus Simpson <[email protected]>
> ---
>  kern/drivers/dev/sdiahci.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/kern/drivers/dev/sdiahci.c b/kern/drivers/dev/sdiahci.c
> index 172b854..811fc05 100644
> --- a/kern/drivers/dev/sdiahci.c
> +++ b/kern/drivers/dev/sdiahci.c
> @@ -1943,7 +1943,7 @@ static int iario(struct sdreq *r)
>  {
>       ERRSTACK(2);
>       int i, n, count, try, max, flag, task;
> -     int64_t lba;
> +     uint64_t lba;
>       char *name;
>       unsigned char *cmd, *data;
>       void *port;
> @@ -1978,7 +1978,9 @@ static int iario(struct sdreq *r)
>               return SDcheck;
>       }
>  
> -     lba = cmd[2] << 24 | cmd[3] << 16 | cmd[4] << 8 | cmd[5];
> +     // TODO: make cmd bigger to support drives with >= 2 TiB
> capacity,
> +     // with 32 bits and 512 B blocks only 2^(9+32) = 2 TiB
> addressable
> +     lba = (uint32_t)(cmd[2] << 24) | cmd[3] << 16 | cmd[4] << 8
> | cmd[5]; count = cmd[7] << 8 | cmd[8];
>       if (r->data == NULL)
>               return SDok;

-- 
You received this message because you are subscribed to the Google Groups 
"Akaros" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to