[Tinyos-2-commits] CVS: tinyos-2.x/tos/chips/at45db BlockStorageP.nc, 1.1.2.16, 1.1.2.17 ConfigStorageP.nc, 1.1.2.8, 1.1.2.9

David Gay idgay at users.sourceforge.net
Thu Sep 21 16:03:12 PDT 2006


Update of /cvsroot/tinyos/tinyos-2.x/tos/chips/at45db
In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv10421

Modified Files:
      Tag: tinyos-2_0_devel-BRANCH
	BlockStorageP.nc ConfigStorageP.nc 
Log Message:
new block storage interfaces


Index: BlockStorageP.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/chips/at45db/BlockStorageP.nc,v
retrieving revision 1.1.2.16
retrieving revision 1.1.2.17
diff -C2 -d -r1.1.2.16 -r1.1.2.17
*** BlockStorageP.nc	15 Aug 2006 11:59:08 -0000	1.1.2.16
--- BlockStorageP.nc	21 Sep 2006 23:03:10 -0000	1.1.2.17
***************
*** 60,68 ****
       random writes are unlikely to hit in it).
  
!      The cache is only flushed on commit.
  
       The first page of a block storage volume stores the maximum address
       written in the block and a CRC of the block's contents (up to that
!      maximum address). This CRC is written at commit time and verified at
       validate time.
  
--- 60,68 ----
       random writes are unlikely to hit in it).
  
!      The cache is only flushed on sync.
  
       The first page of a block storage volume stores the maximum address
       written in the block and a CRC of the block's contents (up to that
!      maximum address). This CRC is written at sync time and verified at
       validate time.
  
***************
*** 78,94 ****
      R_WRITE,
      R_ERASE,
!     R_COMMIT,
      R_READ,
-     R_VERIFY, 
      R_CRC,
    };
  
    enum {
-     META_IDLE,
-     META_COMMIT,
-     META_VERIFY
-   };
- 
-   enum {
      N = uniqueCount(UQ_BLOCK_STORAGE) + uniqueCount(UQ_CONFIG_STORAGE),
      NO_CLIENT = 0xff
--- 78,87 ----
      R_WRITE,
      R_ERASE,
!     R_SYNC,
      R_READ,
      R_CRC,
    };
  
    enum {
      N = uniqueCount(UQ_BLOCK_STORAGE) + uniqueCount(UQ_CONFIG_STORAGE),
      NO_CLIENT = 0xff
***************
*** 96,105 ****
  
    uint8_t client = NO_CLIENT;
-   uint8_t metaState;
    storage_addr_t bytesRemaining;
-   nx_struct {
-     nx_uint16_t crc;
-     nx_uint32_t maxAddr;
-   } sig;
  
    struct {
--- 89,93 ----
***************
*** 109,115 ****
      storage_addr_t addr;
      storage_len_t len;
- 
-     /* Maximum address written in this block */
-     storage_addr_t maxAddr;
    } s[N];
  
--- 97,100 ----
***************
*** 146,150 ****
  
    void eraseStart();
!   void verifyStart();
    void multipageStart(storage_len_t len, uint16_t crc);
  
--- 131,135 ----
  
    void eraseStart();
!   void syncStart();
    void multipageStart(storage_len_t len, uint16_t crc);
  
***************
*** 155,160 ****
  	eraseStart();
  	break;
!       case R_VERIFY:
! 	verifyStart();
  	break;
        default:
--- 140,145 ----
  	eraseStart();
  	break;
!       case R_SYNC:
! 	syncStart();
  	break;
        default:
***************
*** 188,196 ****
  	signal BlockRead.computeCrcDone[c](addr, actualLength, crc, result);
  	break;
!       case R_COMMIT:
! 	signal BlockWrite.commitDone[c](result);
! 	break;
!       case R_VERIFY: 
! 	signal BlockRead.verifyDone[c](result);
  	break;
        }
--- 173,178 ----
  	signal BlockRead.computeCrcDone[c](addr, actualLength, crc, result);
  	break;
!       case R_SYNC:
! 	signal BlockWrite.syncDone[c](result);
  	break;
        }
***************
*** 221,236 ****
      client = blockId;
  
!     if (s[blockId].request == R_WRITE)
        {
! 	if (s[blockId].addr + s[blockId].len > s[blockId].maxAddr)
! 	  s[blockId].maxAddr = s[blockId].addr + s[blockId].len;
! 
! 	if (call BConfig.writeHook[blockId]())
! 	  {
! 	    /* Config write intercept. We'll get a writeContinue when it's
! 	       time to resume. */
! 	    client = NO_CLIENT;
! 	    return;
! 	  }
        }
      startRequest();
--- 203,213 ----
      client = blockId;
  
!     if (s[blockId].request == R_WRITE &&
! 	call BConfig.writeHook[blockId]())
        {
! 	/* Config write intercept. We'll get a writeContinue when it's
! 	   time to resume. */
! 	client = NO_CLIENT;
! 	return;
        }
      startRequest();
***************
*** 254,269 ****
    /* ------------------------------------------------------------------ */
  
-   void commitCrcDone(uint16_t crc);
-   void verifyCrcDone(uint16_t crc);
- 
-   void multipageDone(uint16_t crc) {
-     switch (s[client].request)
-       {
-       default: endRequest(SUCCESS, crc); break;
-       case R_COMMIT: commitCrcDone(crc); break;
-       case R_VERIFY: verifyCrcDone(crc); break;
-       }
-   }
- 
    void calcRequest(storage_addr_t addr, at45page_t *page,
  		   at45pageoffset_t *offset, at45pageoffset_t *count) {
--- 231,234 ----
***************
*** 284,288 ****
      if (bytesRemaining == 0)
        {
! 	multipageDone(crc);
  	return;
        }
--- 249,253 ----
      if (bytesRemaining == 0)
        {
! 	endRequest(SUCCESS, crc);
  	return;
        }
***************
*** 301,305 ****
  	call At45db.read(page, offset, buf, count);
  	break;
!       default:
  	call At45db.computeCrc(page, offset, count, crc);
  	break;
--- 266,270 ----
  	call At45db.read(page, offset, buf, count);
  	break;
!       case R_CRC:
  	call At45db.computeCrc(page, offset, count, crc);
  	break;
***************
*** 308,312 ****
  
    void multipageStart(storage_len_t len, uint16_t crc) {
-     metaState = META_IDLE;
      bytesRemaining = len;
      multipageContinue(crc);
--- 273,276 ----
***************
*** 345,416 ****
  
    /* ------------------------------------------------------------------ */
!   /* Commit								*/
    /* ------------------------------------------------------------------ */
  
!   command error_t BlockWrite.commit[uint8_t id]() {
!     return newRequest(R_COMMIT, id, 0, NULL, s[id].maxAddr);
!   }
! 
!   /* Called once crc computed. Write crc + signature in block 0. */
!   void commitCrcDone(uint16_t crc) {
!     sig.crc = crc;
!     sig.maxAddr = s[client].maxAddr;
!     metaState = META_COMMIT;
!     call At45db.write(pageRemap(0), 1 << AT45_PAGE_SIZE_LOG2, &sig, sizeof sig);
    }
  
!   void commitWriteDone(error_t error) {
!     if (error == SUCCESS)
!       call At45db.syncAll();
!     else
!       endRequest(error, 0);
    }
  
!   void commitSyncDone(error_t error) {
      endRequest(error, 0);
    }
  
    /* ------------------------------------------------------------------ */
-   /* Verify								*/
-   /* ------------------------------------------------------------------ */
- 
-   command error_t BlockRead.verify[uint8_t id]() {
-     return newRequest(R_VERIFY, id, 0, NULL, 0);
-   }
- 
-   void verifyStart() {
-     metaState = META_VERIFY;
-     call At45db.read(pageRemap(0), 1 << AT45_PAGE_SIZE_LOG2, &sig, sizeof sig);
-   }
- 
-   /* See signature written in commit */
-   void verifyReadDone(error_t error) {
-     if (error == SUCCESS)
-       {
- 	storage_addr_t max = sig.maxAddr;
- 
- 	/* Ignore maxAddress values that are too large */
- 	if (max <= call BlockRead.getSize[client]())
- 	  {
- 	    s[client].addr = 0;
- 	    s[client].maxAddr = max;
- 	    multipageStart(max, 0);
- 	    return;
- 	  }
-       }
-     endRequest(FAIL, 0);
-   }
- 
-   void verifyCrcDone(uint16_t crc) {
-     if (crc == sig.crc)
-       endRequest(SUCCESS, 0);
-     else
-       {
- 	s[client].maxAddr = 0;
- 	endRequest(FAIL, 0);
-       }
-   }
- 
-   /* ------------------------------------------------------------------ */
    /* Read								*/
    /* ------------------------------------------------------------------ */
--- 309,328 ----
  
    /* ------------------------------------------------------------------ */
!   /* Sync								*/
    /* ------------------------------------------------------------------ */
  
!   command error_t BlockWrite.sync[uint8_t id]() {
!     return newRequest(R_SYNC, id, 0, NULL, 0);
    }
  
!   void syncStart() {
!     call At45db.syncAll();
    }
  
!   void syncSyncDone(error_t error) {
      endRequest(error, 0);
    }
  
    /* ------------------------------------------------------------------ */
    /* Read								*/
    /* ------------------------------------------------------------------ */
***************
*** 449,464 ****
    event void At45db.writeDone(error_t result) {
      if (client != NO_CLIENT)
!       if (metaState == META_IDLE)
! 	multipageOpDone(result, 0);
!       else
! 	commitWriteDone(result);
    }
  
    event void At45db.readDone(error_t result) {
      if (client != NO_CLIENT)
!       if (metaState == META_IDLE)
! 	multipageOpDone(result, 0);
!       else
! 	verifyReadDone(result);
    }
  
--- 361,370 ----
    event void At45db.writeDone(error_t result) {
      if (client != NO_CLIENT)
!       multipageOpDone(result, 0);
    }
  
    event void At45db.readDone(error_t result) {
      if (client != NO_CLIENT)
!       multipageOpDone(result, 0);
    }
  
***************
*** 475,479 ****
    event void At45db.syncDone(error_t result) {
      if (client != NO_CLIENT)
!       commitSyncDone(result);
    }
  
--- 381,385 ----
    event void At45db.syncDone(error_t result) {
      if (client != NO_CLIENT)
!       syncSyncDone(result);
    }
  
***************
*** 482,488 ****
    default event void BlockWrite.writeDone[uint8_t id](storage_addr_t addr, void* buf, storage_len_t len, error_t result) { }
    default event void BlockWrite.eraseDone[uint8_t id](error_t result) { }
!   default event void BlockWrite.commitDone[uint8_t id](error_t result) { }
    default event void BlockRead.readDone[uint8_t id](storage_addr_t addr, void* buf, storage_len_t len, error_t result) { }
-   default event void BlockRead.verifyDone[uint8_t id](error_t result) { }
    default event void BlockRead.computeCrcDone[uint8_t id](storage_addr_t addr, storage_len_t len, uint16_t x, error_t result) { }
    
--- 388,393 ----
    default event void BlockWrite.writeDone[uint8_t id](storage_addr_t addr, void* buf, storage_len_t len, error_t result) { }
    default event void BlockWrite.eraseDone[uint8_t id](error_t result) { }
!   default event void BlockWrite.syncDone[uint8_t id](error_t result) { }
    default event void BlockRead.readDone[uint8_t id](storage_addr_t addr, void* buf, storage_len_t len, error_t result) { }
    default event void BlockRead.computeCrcDone[uint8_t id](storage_addr_t addr, storage_len_t len, uint16_t x, error_t result) { }
    

Index: ConfigStorageP.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/chips/at45db/ConfigStorageP.nc,v
retrieving revision 1.1.2.8
retrieving revision 1.1.2.9
diff -C2 -d -r1.1.2.8 -r1.1.2.9
*** ConfigStorageP.nc	21 Sep 2006 22:51:39 -0000	1.1.2.8
--- ConfigStorageP.nc	21 Sep 2006 23:03:10 -0000	1.1.2.9
***************
*** 267,274 ****
    /* ------------------------------------------------------------------ */
  
!   void commitDone(uint8_t id, error_t error);
  
    command error_t ConfigStorage.commit[uint8_t id]() {
-     /* Call BlockWrite.commit */
      error_t ok;
      uint16_t crc;
--- 267,273 ----
    /* ------------------------------------------------------------------ */
  
!   void commitSyncDone(uint8_t id, error_t error);
  
    command error_t ConfigStorage.commit[uint8_t id]() {
      error_t ok;
      uint16_t crc;
***************
*** 305,309 ****
        signal ConfigStorage.commitDone[id](error);
      else if (error != SUCCESS)
!       commitDone(id, error);
      else
        {
--- 304,308 ----
        signal ConfigStorage.commitDone[id](error);
      else if (error != SUCCESS)
!       commitSyncDone(id, error);
      else
        {
***************
*** 315,324 ****
    void commitWriteDone(uint8_t id, error_t error) {
      if (error != SUCCESS)
!       commitDone(id, error);
      else
!       call BlockWrite.commit[id]();
    }
  
!   void commitDone(uint8_t id, error_t error) {
      s[id].committing = FALSE;
      if (error == SUCCESS)
--- 314,323 ----
    void commitWriteDone(uint8_t id, error_t error) {
      if (error != SUCCESS)
!       commitSyncDone(id, error);
      else
!       call BlockWrite.sync[id]();
    }
  
!   void commitSyncDone(uint8_t id, error_t error) {
      s[id].committing = FALSE;
      if (error == SUCCESS)
***************
*** 376,382 ****
    }
  
!   event void BlockWrite.commitDone[uint8_t id]( error_t error ) {
      if (id < N)
!       commitDone(id, error);
    }
  
--- 375,381 ----
    }
  
!   event void BlockWrite.syncDone[uint8_t id]( error_t error ) {
      if (id < N)
!       commitSyncDone(id, error);
    }
  
***************
*** 394,398 ****
    }
  
-   event void BlockRead.verifyDone[uint8_t id](error_t error) {}
    event void BlockWrite.eraseDone[uint8_t id](error_t error) {}
    event void At45db.eraseDone(error_t error) {}
--- 393,396 ----



More information about the Tinyos-2-commits mailing list