]> oss.titaniummirror.com Git - tinyos-2.x.git/commit
stm25p: fix seek error master
authorR. Steve McKown <rsmckown@gmail.com>
Fri, 2 Jan 2015 21:06:50 +0000 (14:06 -0700)
committerR. Steve McKown <rsmckown@gmail.com>
Fri, 2 Jan 2015 21:22:43 +0000 (14:22 -0700)
commitf821ba09d2c769ef7ffe75103ed399c72b7f3c08
tree10d74497c55bd93056e54580ecd61bc856f141bd
parentb4cefea4fe265ce3bead428c13f1435227016cee
stm25p: fix seek error

Ensure correct computation of m_log_info[ id ].read_addr when client code
requests seek() to a cookie whose value is below the current virtual
address range by a distance, in address value, greater than 255 sectors.

The sector component of a virtual address is 16 bits, given
STM25P_SECTOR_SIZE_LOG2 is 16 and sizeof(storage_cookie_t) is 32.
However, in ClientResource.granted[]() in the S_SEEK case, the client's
read_addr value can have its upper bits silently discarded because
sector value are handled in uint8_t variables.

The symptom of upper bit discards is that client code receives the
contents of a full log many times until the client read_addr value
finally increments to the point that allows satisfaction of the end of
log condition,

    read_addr >= m_log_info[ client ].write_addr

Example case exhibiting this behavior:

read_addr = 0x59f0000
write_addr = 5a6dbf8
LogRead.seek(0x2a71400)

The resulting address handling in ClientResource.granted[]() in the
S_SEEK request case, around Stm25pLogP.nc:229:

readSector = 0xa7; // from incoming cookie value, should be 0x2a7
writeSector = 0xa7; // should be 0x5a7
if (writeSector - readSector > numSectors): FALSE, should be TRUE
  Had the if expression above been TRUE, the read address would
  still be computed incorrectly due to 8-bit match in the if's
  'then' clause.
m_log_state[ id  ].read_addr = 0x2a7000; // should be 0x59f000
tos/chips/stm25p/Stm25pLogP.nc