[Tinyos-commits] CVS: tinyos-1.x/tos/lib/Deluge BitVecUtils.h, 1.4, 1.5 BitVecUtils.nc, 1.4, 1.5 BitVecUtilsC.nc, 1.5, 1.6 Deluge.h, 1.23, 1.24 DelugeC.nc, 1.22, 1.23 DelugeDataRead.nc, NONE, 1.1 DelugeDataWrite.nc, NONE, 1.1 DelugeM.nc, 1.51, 1.52 DelugeMetadata.h, 1.11, 1.12 DelugeMetadata.nc, 1.10, 1.11 DelugeMetadataC.nc, 1.9, 1.10 DelugeMetadataM.nc, 1.26, 1.27 DelugeMetadataStore.nc, NONE, 1.1 DelugeMsgs.h, 1.14, 1.15 DelugePageTransfer.nc, 1.5, 1.6 DelugePageTransferC.nc, 1.10, 1.11 DelugePageTransferM.nc, 1.29, 1.30 DelugeStats.nc, NONE, 1.1 DelugeStorage.nc, NONE, 1.1 DelugeStorageC.nc, NONE, 1.1 DelugeStorageM.nc, NONE, 1.1 NetProg.h, 1.14, 1.15 NetProg.nc, 1.10, 1.11 NetProgC.nc, 1.10, 1.11 NetProgM.nc, 1.30, 1.31 NetProgMsgs.h, NONE, 1.1 SharedMsgBuf.nc, 1.4, 1.5 SharedMsgBufM.nc, 1.5, 1.6 TOSBoot.h, NONE, 1.1

Jonathan Hui jwhui at users.sourceforge.net
Fri Jul 22 10:40:14 PDT 2005


Update of /cvsroot/tinyos/tinyos-1.x/tos/lib/Deluge
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22969

Added Files:
	BitVecUtils.h BitVecUtils.nc BitVecUtilsC.nc Deluge.h 
	DelugeC.nc DelugeDataRead.nc DelugeDataWrite.nc DelugeM.nc 
	DelugeMetadata.h DelugeMetadata.nc DelugeMetadataC.nc 
	DelugeMetadataM.nc DelugeMetadataStore.nc DelugeMsgs.h 
	DelugePageTransfer.nc DelugePageTransferC.nc 
	DelugePageTransferM.nc DelugeStats.nc DelugeStorage.nc 
	DelugeStorageC.nc DelugeStorageM.nc NetProg.h NetProg.nc 
	NetProgC.nc NetProgM.nc NetProgMsgs.h SharedMsgBuf.nc 
	SharedMsgBufM.nc TOSBoot.h 
Log Message:
- Initial import of Deluge 2.0.








--- NEW FILE: DelugeDataRead.nc ---
// $Id: DelugeDataRead.nc,v 1.1 2005/07/22 17:40:06 jwhui Exp $

/*									tab:4
 *
 *
 * "Copyright (c) 2000-2004 The Regents of the University  of California.  
 * All rights reserved.
 *
 * Permission to use, copy, modify, and distribute this software and its
 * documentation for any purpose, without fee, and without written agreement is
 * hereby granted, provided that the above copyright notice, the following
 * two paragraphs and the author appear in all copies of this software.
 * 
 * IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR
 * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
 * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF
 * CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 * 
 * THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
 * AND FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
 * ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO
 * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS."
 *
 */

/**
 * @author Jonathan Hui <jwhui at cs.berkeley.edu>
 */

includes BlockStorage;
includes Deluge;

interface DelugeDataRead {

  command result_t read(imgnum_t imgNum, block_addr_t addr, void* buf, uint16_t len);
  event void readDone(storage_result_t result);

  command result_t verify(imgnum_t imgNum, pgnum_t pgNum);
  event void verifyDone(storage_result_t result, bool isValid);

}

--- NEW FILE: DelugeDataWrite.nc ---
// $Id: DelugeDataWrite.nc,v 1.1 2005/07/22 17:40:06 jwhui Exp $

/*									tab:4
 *
 *
 * "Copyright (c) 2000-2004 The Regents of the University  of California.  
 * All rights reserved.
 *
 * Permission to use, copy, modify, and distribute this software and its
 * documentation for any purpose, without fee, and without written agreement is
 * hereby granted, provided that the above copyright notice, the following
 * two paragraphs and the author appear in all copies of this software.
 * 
 * IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR
 * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
 * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF
 * CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 * 
 * THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
 * AND FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
 * ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO
 * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS."
 *
 */

/**
 * @author Jonathan Hui <jwhui at cs.berkeley.edu>
 */

interface DelugeDataWrite {

  command result_t write(imgnum_t imgNum, block_addr_t addr, void* source, uint16_t len);
  event void writeDone(storage_result_t result);

  command result_t erase(imgnum_t imgNum);
  event void eraseDone(storage_result_t result);

  command result_t commit(imgnum_t imgNum);
  event void commitDone(storage_result_t result);

}






--- NEW FILE: DelugeMetadataStore.nc ---
// $Id: DelugeMetadataStore.nc,v 1.1 2005/07/22 17:40:07 jwhui Exp $

/*									tab:4
 *
 *
 * "Copyright (c) 2000-2004 The Regents of the University  of California.  
 * All rights reserved.
 *
 * Permission to use, copy, modify, and distribute this software and its
 * documentation for any purpose, without fee, and without written agreement is
 * hereby granted, provided that the above copyright notice, the following
 * two paragraphs and the author appear in all copies of this software.
 * 
 * IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR
 * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
 * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF
 * CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 * 
 * THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
 * AND FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
 * ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO
 * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS."
 *
 */

/**
 * @author Jonathan Hui <jwhui at cs.berkeley.edu>
 */

includes Deluge;

interface DelugeMetadataStore {

  command result_t read(imgnum_t imgNum, void* buf);
  event void readDone(storage_result_t result);

  command result_t write(imgnum_t imgNum, void* buf);
  event void writeDone(storage_result_t result);

}





--- NEW FILE: DelugeStats.nc ---
// $Id: DelugeStats.nc,v 1.1 2005/07/22 17:40:08 jwhui Exp $

/*									tab:2
 *
 *
 * "Copyright (c) 2000-2004 The Regents of the University  of California.  
 * All rights reserved.
 *
 * Permission to use, copy, modify, and distribute this software and its
 * documentation for any purpose, without fee, and without written agreement is
 * hereby granted, provided that the above copyright notice, the following
 * two paragraphs and the author appear in all copies of this software.
 * 
 * IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR
 * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
 * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF
 * CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 * 
 * THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
 * AND FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
 * ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO
 * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS."
 *
 */

/**
 * @author Jonathan Hui <jwhui at cs.berkeley.edu>
 */

interface DelugeStats {

  command pgnum_t getNumPgs(imgnum_t imgNum);
  command pgnum_t getNumPgsComplete(imgnum_t imgNum);
  command imgvnum_t getVNum(imgnum_t imgNum);

}

--- NEW FILE: DelugeStorage.nc ---
// $Id: DelugeStorage.nc,v 1.1 2005/07/22 17:40:08 jwhui Exp $

/*									tab:4
 *
 *
 * "Copyright (c) 2000-2004 The Regents of the University  of California.  
 * All rights reserved.
 *
 * Permission to use, copy, modify, and distribute this software and its
 * documentation for any purpose, without fee, and without written agreement is
 * hereby granted, provided that the above copyright notice, the following
 * two paragraphs and the author appear in all copies of this software.
 * 
 * IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR
 * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
 * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF
 * CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 * 
 * THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
 * AND FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
 * ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO
 * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS."
 *
 */

/**
 * @author Jonathan Hui <jwhui at cs.berkeley.edu>
 */

includes TOSBoot;

interface DelugeStorage {
  command result_t loadImages();
  event void loadImagesDone(result_t result);
  command uint32_t imgNum2Addr(imgnum_t imgNum);
}

--- NEW FILE: DelugeStorageC.nc ---
// $Id: DelugeStorageC.nc,v 1.1 2005/07/22 17:40:08 jwhui Exp $

/*									tab:4
 *
 *
 * "Copyright (c) 2000-2004 The Regents of the University  of California.  
 * All rights reserved.
 *
 * Permission to use, copy, modify, and distribute this software and its
 * documentation for any purpose, without fee, and without written agreement is
 * hereby granted, provided that the above copyright notice, the following
 * two paragraphs and the author appear in all copies of this software.
 * 
 * IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR
 * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
 * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF
 * CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 * 
 * THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
 * AND FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
 * ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO
 * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS."
 *
 */

/**
 * @author Jonathan Hui <jwhui at cs.berkeley.edu>
 */

configuration DelugeStorageC {
  provides {
    interface DelugeDataRead as DataRead;
    interface DelugeDataWrite as DataWrite;
    interface DelugeMetadataStore as MetadataStore;
    interface DelugeStorage;
  }
}
implementation {

  components
    DelugeStorageM as Storage,
    BlockStorageC,
    LedsC as Leds;

  DataRead = Storage;
  DataWrite = Storage;
  DelugeStorage = Storage;
  MetadataStore = Storage;

  Storage.Leds -> Leds;

  Storage.BlockRead[DELUGE_VOLUME_ID_0] -> BlockStorageC.BlockRead[DELUGE_VOLUME_ID_0];
  Storage.BlockWrite[DELUGE_VOLUME_ID_0] -> BlockStorageC.BlockWrite[DELUGE_VOLUME_ID_0];
  Storage.Mount[DELUGE_VOLUME_ID_0] -> BlockStorageC.Mount[DELUGE_VOLUME_ID_0];
  Storage.StorageRemap[DELUGE_VOLUME_ID_0] -> BlockStorageC.StorageRemap[DELUGE_VOLUME_ID_0];
#if DELUGE_NUM_IMAGES >= 2
  Storage.BlockRead[DELUGE_VOLUME_ID_1] -> BlockStorageC.BlockRead[DELUGE_VOLUME_ID_1];
  Storage.BlockWrite[DELUGE_VOLUME_ID_1] -> BlockStorageC.BlockWrite[DELUGE_VOLUME_ID_1];
  Storage.Mount[DELUGE_VOLUME_ID_1] -> BlockStorageC.Mount[DELUGE_VOLUME_ID_1];
  Storage.StorageRemap[DELUGE_VOLUME_ID_1] -> BlockStorageC.StorageRemap[DELUGE_VOLUME_ID_1];
#if DELUGE_NUM_IMAGES >= 3
  Storage.BlockRead[DELUGE_VOLUME_ID_2] -> BlockStorageC.BlockRead[DELUGE_VOLUME_ID_2];
  Storage.BlockWrite[DELUGE_VOLUME_ID_2] -> BlockStorageC.BlockWrite[DELUGE_VOLUME_ID_2];
  Storage.Mount[DELUGE_VOLUME_ID_2] -> BlockStorageC.Mount[DELUGE_VOLUME_ID_2];
  Storage.StorageRemap[DELUGE_VOLUME_ID_2] -> BlockStorageC.StorageRemap[DELUGE_VOLUME_ID_2];
#if DELUGE_NUM_IMAGES >= 4
  Storage.BlockRead[DELUGE_VOLUME_ID_3] -> BlockStorageC.BlockRead[DELUGE_VOLUME_ID_3];
  Storage.BlockWrite[DELUGE_VOLUME_ID_3] -> BlockStorageC.BlockWrite[DELUGE_VOLUME_ID_3];
  Storage.Mount[DELUGE_VOLUME_ID_3] -> BlockStorageC.Mount[DELUGE_VOLUME_ID_3];
  Storage.StorageRemap[DELUGE_VOLUME_ID_3] -> BlockStorageC.StorageRemap[DELUGE_VOLUME_ID_3];
#if DELUGE_NUM_IMAGES >= 5
  Storage.BlockRead[DELUGE_VOLUME_ID_4] -> BlockStorageC.BlockRead[DELUGE_VOLUME_ID_4];
  Storage.BlockWrite[DELUGE_VOLUME_ID_4] -> BlockStorageC.BlockWrite[DELUGE_VOLUME_ID_4];
  Storage.Mount[DELUGE_VOLUME_ID_4] -> BlockStorageC.Mount[DELUGE_VOLUME_ID_4];
  Storage.StorageRemap[DELUGE_VOLUME_ID_4] -> BlockStorageC.StorageRemap[DELUGE_VOLUME_ID_4];
#if DELUGE_NUM_IMAGES >= 6
  Storage.BlockRead[DELUGE_VOLUME_ID_5] -> BlockStorageC.BlockRead[DELUGE_VOLUME_ID_5];
  Storage.BlockWrite[DELUGE_VOLUME_ID_5] -> BlockStorageC.BlockWrite[DELUGE_VOLUME_ID_5];
  Storage.Mount[DELUGE_VOLUME_ID_5] -> BlockStorageC.Mount[DELUGE_VOLUME_ID_5];
  Storage.StorageRemap[DELUGE_VOLUME_ID_5] -> BlockStorageC.StorageRemap[DELUGE_VOLUME_ID_5];
#if DELUGE_NUM_IMAGES >= 7
  Storage.BlockRead[DELUGE_VOLUME_ID_6] -> BlockStorageC.BlockRead[DELUGE_VOLUME_ID_6];
  Storage.BlockWrite[DELUGE_VOLUME_ID_6] -> BlockStorageC.BlockWrite[DELUGE_VOLUME_ID_6];
  Storage.Mount[DELUGE_VOLUME_ID_6] -> BlockStorageC.Mount[DELUGE_VOLUME_ID_6];
  Storage.StorageRemap[DELUGE_VOLUME_ID_6] -> BlockStorageC.StorageRemap[DELUGE_VOLUME_ID_6];
#if DELUGE_NUM_IMAGES >= 8
  Storage.BlockRead[DELUGE_VOLUME_ID_7] -> BlockStorageC.BlockRead[DELUGE_VOLUME_ID_7];
  Storage.BlockWrite[DELUGE_VOLUME_ID_7] -> BlockStorageC.BlockWrite[DELUGE_VOLUME_ID_7];
  Storage.Mount[DELUGE_VOLUME_ID_7] -> BlockStorageC.Mount[DELUGE_VOLUME_ID_7];
  Storage.StorageRemap[DELUGE_VOLUME_ID_7] -> BlockStorageC.StorageRemap[DELUGE_VOLUME_ID_7];
#endif
#endif
#endif
#endif
#endif
#endif
#endif

}

--- NEW FILE: DelugeStorageM.nc ---
// $Id: DelugeStorageM.nc,v 1.1 2005/07/22 17:40:08 jwhui Exp $

/*									tab:2
 *
 *
 * "Copyright (c) 2000-2005 The Regents of the University  of California.  
 * All rights reserved.
 *
 * Permission to use, copy, modify, and distribute this software and its
 * documentation for any purpose, without fee, and without written agreement is
 * hereby granted, provided that the above copyright notice, the following
 * two paragraphs and the author appear in all copies of this software.
 * 
 * IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR
 * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
 * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF
 * CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 * 
 * THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
 * AND FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
 * ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO
 * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS."
 *
 */

/**
 * @author Jonathan Hui <jwhui at cs.berkeley.edu>
 */

module DelugeStorageM {
  provides {
    interface DelugeMetadataStore as MetadataStore;
    interface DelugeDataRead as DataRead;
    interface DelugeDataWrite as DataWrite;
    interface DelugeStorage;
  }
  uses {
    interface BlockRead[blockstorage_t blockId];
    interface BlockWrite[blockstorage_t blockId];
    interface Mount[blockstorage_t blockId];
    interface StorageRemap[blockstorage_t blockId];
    interface Leds;
  }
}

implementation {

  enum {
    S_NEVER_USED,
    S_MOUNTING,
    S_IDLE,
    S_METADATA_READ,
    S_METADATA_WRITE,
    S_READ,
    S_WRITE,
    S_ERASE,
    S_VERIFY,
    S_COMMIT,
  };

  uint8_t state = S_NEVER_USED;
  uint8_t client;
  uint16_t crcScratch;
  uint8_t pgNum;

  void signalDone(result_t result) {
    uint8_t tmpState = state;
    state = S_IDLE;
    switch(tmpState) {
    case S_METADATA_READ: signal MetadataStore.readDone(result); break;
    case S_READ: signal DataRead.readDone(result); break;
    case S_METADATA_WRITE: signal MetadataStore.writeDone(result); break;
    case S_WRITE: signal DataWrite.writeDone(result); break;
    case S_ERASE: signal DataWrite.eraseDone(result); break;
    case S_VERIFY: signal DataRead.verifyDone(result, crcScratch); break;
    case S_COMMIT: signal DataWrite.commitDone(result); break;
    case S_MOUNTING:
      if (result == FAIL)
	state = S_NEVER_USED;
      signal DelugeStorage.loadImagesDone(result);
      break;
    }
  }

  command result_t DelugeStorage.loadImages() {

    result_t result;

    if (state != S_NEVER_USED)
      return FAIL;
    
    client = 0;

    result = call Mount.mount[DELUGE_IMAGES[client].imageNum](DELUGE_IMAGES[client].volumeId);

    if (result == SUCCESS)
      state = S_MOUNTING;

    return result;

  }

  event void Mount.mountDone[volume_t volume](storage_result_t result, volume_id_t id) { 

    if (result != STORAGE_OK) {
      signalDone(FAIL);
      return;
    }
    
    // mount next image
    if ( ++client < DELUGE_NUM_IMAGES ) {
      if (call Mount.mount[DELUGE_IMAGES[client].imageNum](DELUGE_IMAGES[client].volumeId) == FAIL)
	signalDone(FAIL);
      return;
    }

    // mounted all images
    signalDone(SUCCESS);

  }

  command uint32_t DelugeStorage.imgNum2Addr(imgnum_t imgNum) {
    if (imgNum == DELUGE_GOLDEN_IMAGE_NUM)
      return TOSBOOT_GOLDEN_IMG_ADDR;
    return call StorageRemap.physicalAddr[DELUGE_IMAGES[imgNum].imageNum](0);
  }

  result_t newRequest(uint8_t newState, imgnum_t imgNum, 
		      block_addr_t addr, void* buf, uint16_t len) {
    
    result_t result = FAIL;
    uint8_t image = DELUGE_IMAGES[imgNum].imageNum;

    if (state != S_IDLE)
      return FAIL;
    
    switch(newState) {
    case S_VERIFY:
      pgNum = addr;
      addr = DELUGE_METADATA_SIZE + sizeof(uint16_t) * pgNum;
      buf = &crcScratch;
      len = sizeof(crcScratch);
      // no break
    case S_METADATA_READ: case S_READ:
      result = call BlockRead.read[image](addr, buf, len);
      break;
    case S_METADATA_WRITE: case S_WRITE:
      result = call BlockWrite.write[image](addr, buf, len);
      break;
    case S_ERASE:
      result = call BlockWrite.erase[image]();
      break;
    case S_COMMIT:
      result = call BlockWrite.commit[image]();
      break;
    }

    if (result == SUCCESS)
      state = newState;

    return result;

  }

  command result_t MetadataStore.read(imgnum_t imgNum, void* buf) {
    return newRequest(S_METADATA_READ, imgNum, 0, buf, sizeof(DelugeImgDesc));
  }

  command result_t MetadataStore.write(imgnum_t imgNum, void* buf) {
    return newRequest(S_METADATA_WRITE, imgNum, 0, buf, sizeof(DelugeImgDesc));
  }
  
  command result_t DataRead.read(imgnum_t imgNum, block_addr_t addr,
				 void* buf, uint16_t length) {
    return newRequest(S_READ, imgNum, addr, buf, length);
  }
  
  command result_t DataRead.verify(imgnum_t imgNum, pgnum_t tmpPgNum) {
    return newRequest(S_VERIFY, imgNum, tmpPgNum, NULL, 0);
  }

  command result_t DataWrite.write(imgnum_t imgNum, block_addr_t addr, 
				   void* buf, uint16_t length) {
    return newRequest(S_WRITE, imgNum, addr, buf, length);
  }
  
  command result_t DataWrite.erase(imgnum_t imgNum) {
    return newRequest(S_ERASE, imgNum, 0, 0, 0);
  }

  command result_t DataWrite.commit(imgnum_t imgNum) {
    return newRequest(S_COMMIT, imgNum, 0, 0, 0);
  }
  
  event void BlockRead.readDone[uint8_t volume](storage_result_t result, block_addr_t addr, void* buf, block_addr_t len) {

    uint16_t tmpLen;

    if ( pgNum == 0 ) {
      addr = DELUGE_CRC_BLOCK_SIZE;
      tmpLen = DELUGE_BYTES_PER_PAGE-DELUGE_CRC_BLOCK_SIZE;
    }
    else {
      addr = (block_addr_t)pgNum*DELUGE_BYTES_PER_PAGE;
      tmpLen = DELUGE_BYTES_PER_PAGE;
    }

    if ( result != STORAGE_OK 
	 || state == S_READ
	 || call BlockRead.computeCrc[volume]( addr + DELUGE_METADATA_SIZE, tmpLen ) == FAIL )
      signalDone(result);

  }
  
  event void BlockRead.computeCrcDone[uint8_t volume](storage_result_t result, uint16_t crc, block_addr_t addr, block_addr_t len) {
    crcScratch = ( crc == crcScratch );
    signalDone(result);
  }

  event void BlockWrite.writeDone[uint8_t volume](storage_result_t result, block_addr_t addr, void* buf, block_addr_t len) {
    signalDone(result);
  }

  event void BlockWrite.eraseDone[uint8_t volume](storage_result_t result) { 
    signalDone(result);
  } 

  event void BlockWrite.commitDone[uint8_t volume](storage_result_t result) {
    signalDone(result);
  }

  event void BlockRead.verifyDone[uint8_t volume](storage_result_t result) {}

  default command result_t BlockRead.read[blockstorage_t blockId](block_addr_t addr, void* buf, block_addr_t len) { return FAIL; }
  default command result_t BlockRead.verify[blockstorage_t blockId]() { return FAIL; }
  default command result_t BlockRead.computeCrc[blockstorage_t blockId](block_addr_t addr, block_addr_t len) { return FAIL; }
  default command result_t BlockWrite.write[blockstorage_t blockId](block_addr_t addr, void* buf, block_addr_t len) { return FAIL; }
  default command result_t BlockWrite.erase[blockstorage_t blockId]() { return FAIL; }
  default command result_t BlockWrite.commit[blockstorage_t blockId]() { return FAIL; }
  default command result_t Mount.mount[blockstorage_t blockId](volume_id_t id) { return FAIL; }
  default command uint32_t StorageRemap.physicalAddr[blockstorage_t blockId](uint32_t id) { return STORAGE_INVALID_ADDR; }

}





--- NEW FILE: NetProgMsgs.h ---
// $Id: NetProgMsgs.h,v 1.1 2005/07/22 17:40:08 jwhui Exp $

/*									tab:2
 *
 *
 * "Copyright (c) 2000-2005 The Regents of the University  of California.  
 * All rights reserved.
 *
 * Permission to use, copy, modify, and distribute this software and its
 * documentation for any purpose, without fee, and without written agreement is
 * hereby granted, provided that the above copyright notice, the following
 * two paragraphs and the author appear in all copies of this software.
 * 
 * IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR
 * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
 * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF
 * CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 * 
 * THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
 * AND FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
 * ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO
 * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS."
 *
 */

/**
 * @author Jonathan Hui <jwhui at cs.berkeley.edu>
 */

#ifndef __NETPROG_MSGS_H__
#define __NETPROG_MSGS_H__

enum {
  AM_NETPROGMSG = 164,
};

typedef struct NetProgMsg {
  Ident_t ident;
  uint16_t sourceAddr;
} NetProgMsg;

#endif



--- NEW FILE: TOSBoot.h ---
// $Id: TOSBoot.h,v 1.1 2005/07/22 17:40:08 jwhui Exp $

/*									tab:2
 * "Copyright (c) 2000-2005 The Regents of the University  of California.  
 * All rights reserved.
 *
 * Permission to use, copy, modify, and distribute this software and its
 * documentation for any purpose, without fee, and without written agreement is
 * hereby granted, provided that the above copyright notice, the following
 * two paragraphs and the author appear in all copies of this software.
 * 
 * IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR
 * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
 * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF
 * CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 * 
 * THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
 * AND FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
 * ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO
 * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS."
 */

/**
 * @author  Jonathan Hui <jwhui at cs.berkeley.edu>
 */

#ifndef __TOSBOOT_H__
#define __TOSBOOT_H__

#include "TOSBoot_platform.h"

typedef struct tosboot_args_t {
  uint32_t imageAddr;
  uint8_t  gestureCount;
  bool     noReprogram;
} tosboot_args_t;

#endif



More information about the Tinyos-commits mailing list