[Tinyos-2-commits] CVS: tinyos-2.x/tos/lib/net/Deluge
DelugeManagerC.nc, NONE, 1.1 DelugeManagerP.nc, NONE,
1.1 DelugeMetadataC.nc, NONE, 1.1 DelugeMetadataClientC.nc,
NONE, 1.1 DelugeMetadataP.nc, NONE, 1.1 DelugeVolumeManager.nc,
NONE, 1.1 DelugeVolumeManagerC.nc, NONE,
1.1 DelugeVolumeManagerClientC.nc, NONE,
1.1 DelugeVolumeManagerP.nc, NONE, 1.1 Deluge.h, 1.3,
1.4 DelugeC.nc, 1.6, 1.7 DelugeMetadata.nc, 1.1,
1.2 DelugeP.nc, 1.6, 1.7 DelugePageTransfer.h, 1.4,
1.5 DelugePageTransfer.nc, 1.1, 1.2 DelugePageTransferC.nc,
1.3, 1.4 DelugePageTransferP.nc, 1.4, 1.5 ObjectTransferC.nc,
1.4, 1.5 ObjectTransferP.nc, 1.7, 1.8 DelugeMetadata.h, 1.1,
NONE DelugeStorage.nc, 1.1, NONE DelugeStorageC.nc, 1.4,
NONE DelugeStorageP.nc, 1.3, NONE
Razvan Musaloiu-E.
razvanm at users.sourceforge.net
Sun Jan 13 20:22:04 PST 2008
- Previous message: [Tinyos-2-commits]
CVS: tinyos-2.x/tos/lib/net/Deluge/BlockStorageManager
BlockReaderC.nc, NONE, 1.1 BlockStorageLockC.nc, NONE,
1.1 BlockStorageLockClientC.nc, NONE,
1.1 BlockStorageManager.h, NONE, 1.1 BlockStorageManagerC.nc,
NONE, 1.1 BlockStorageManagerP.nc, NONE, 1.1 BlockWriterC.nc,
NONE, 1.1 VolumeId.nc, NONE, 1.1 VolumeIdC.nc, NONE, 1.1
- Next message: [Tinyos-2-commits]
CVS: tinyos-2.x/tos/lib/net/Deluge/FlashVolumeManager
FlashVolumeManagerC.nc, 1.5, 1.6 FlashVolumeManagerP.nc, 1.9,
1.10 FlashVolumeManager.h, 1.4, NONE
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /cvsroot/tinyos/tinyos-2.x/tos/lib/net/Deluge
In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv20053/tos/lib/net/Deluge
Modified Files:
Deluge.h DelugeC.nc DelugeMetadata.nc DelugeP.nc
DelugePageTransfer.h DelugePageTransfer.nc
DelugePageTransferC.nc DelugePageTransferP.nc
ObjectTransferC.nc ObjectTransferP.nc
Added Files:
DelugeManagerC.nc DelugeManagerP.nc DelugeMetadataC.nc
DelugeMetadataClientC.nc DelugeMetadataP.nc
DelugeVolumeManager.nc DelugeVolumeManagerC.nc
DelugeVolumeManagerClientC.nc DelugeVolumeManagerP.nc
Removed Files:
DelugeMetadata.h DelugeStorage.nc DelugeStorageC.nc
DelugeStorageP.nc
Log Message:
Super Duper update to Deluge T2. The manual and the testing scripts are temporary out-of-date.
Some of the improvements are:
- simplified images (ident and metadata were merged)
- network-order representation of fields
- new version of tinyos.py
- improved sharing of volumes.
--- NEW FILE: DelugeManagerC.nc ---
/* Copyright (c) 2007 Johns Hopkins University.
* 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 (updated) modification history and the author appear in
* all copies of this source code.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, LOSS OF USE, DATA,
* OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
* @author Razvan Musaloiu-E. <razvanm at cs.jhu.edu>
* @author Chieh-Jan Mike Liang <cliang4 at cs.jhu.edu>
*/
#include "StorageVolumes.h"
generic configuration DelugeManagerC(am_id_t AMId)
{
uses interface DisseminationUpdate<DelugeCmd>;
}
implementation
{
components new SerialAMSenderC(AMId);
components new SerialAMReceiverC(AMId);
components new TimerMilliC() as Timer;
components NoLedsC, LedsC;
components new DelugeManagerP();
components NetProgC;
components BlockStorageManagerC;
components ObjectTransferC;
components new DelugeMetadataClientC();
components new DelugeVolumeManagerClientC();
components new BlockStorageLockClientC();
DelugeManagerP.DelayTimer -> Timer;
DelugeManagerP.SerialAMSender -> SerialAMSenderC;
DelugeManagerP.SerialAMReceiver -> SerialAMReceiverC;
DelugeManagerP.Leds -> LedsC;
DelugeManagerP.DisseminationUpdate = DisseminationUpdate;
DelugeManagerP.NetProg -> NetProgC;
DelugeManagerP.ObjectTransfer -> ObjectTransferC;
DelugeManagerP.StorageMap -> BlockStorageManagerC;
DelugeManagerP.DelugeMetadata -> DelugeMetadataClientC;
DelugeManagerP.DelugeVolumeManager -> DelugeVolumeManagerClientC;
DelugeManagerP.Resource -> BlockStorageLockClientC;
components DelugeP;
DelugeManagerP.stop -> DelugeP;
}
--- NEW FILE: DelugeManagerP.nc ---
/* Copyright (c) 2007 Johns Hopkins University.
* 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 (updated) modification history and the author appear in
* all copies of this source code.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, LOSS OF USE, DATA,
* OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
* @author Razvan Musaloiu-E. <razvanm at cs.jhu.edu>
* @author Chieh-Jan Mike Liang <cliang4 at cs.jhu.edu>
*/
generic module DelugeManagerP()
{
uses {
interface DisseminationUpdate<DelugeCmd>;
interface AMSend as SerialAMSender;
interface Receive as SerialAMReceiver;
interface Timer<TMilli> as DelayTimer;
interface NetProg;
interface Leds;
interface StorageMap[uint8_t volumeId];
interface DelugeMetadata;
interface ObjectTransfer;
interface DelugeVolumeManager;
interface Resource;
command void stop();
}
}
implementation
{
typedef nx_struct SerialReqPacket {
nx_uint8_t cmd;
nx_uint8_t imgNum;
} SerialReqPacket;
typedef nx_struct SerialReplyPacket {
nx_uint8_t error;
} SerialReplyPacket;
message_t serialMsg;
DelugeCmd delugeCmd;
void sendReply(error_t error)
{
uint8_t len = sizeof(SerialReplyPacket);
SerialReplyPacket *reply = (SerialReplyPacket *)call SerialAMSender.getPayload(&serialMsg, len);
if (reply == NULL) {
return;
}
reply->error = error;
call SerialAMSender.send(AM_BROADCAST_ADDR, &serialMsg, len);
}
event message_t* SerialAMReceiver.receive(message_t* msg, void* payload, uint8_t len)
{
SerialReqPacket *request = (SerialReqPacket *)payload;
memset(&delugeCmd, 0, sizeof(DelugeCmd));
call stop();
delugeCmd.type = request->cmd;
switch (request->cmd) {
case DELUGE_CMD_STOP:
call DisseminationUpdate.change(&delugeCmd);
case DELUGE_CMD_LOCAL_STOP:
sendReply(SUCCESS);
call Resource.release();
break;
case DELUGE_CMD_ONLY_DISSEMINATE:
case DELUGE_CMD_DISSEMINATE_AND_REPROGRAM:
if (call Resource.immediateRequest() == SUCCESS) {
call DelugeMetadata.read(request->imgNum);
} else {
sendReply(FAIL);
}
break;
case DELUGE_CMD_REPROGRAM:
case DELUGE_CMD_REBOOT:
call DelayTimer.startOneShot(1024);
sendReply(SUCCESS);
break;
}
return msg;
}
event void DelayTimer.fired()
{
switch (delugeCmd.type) {
case DELUGE_CMD_REPROGRAM:
call NetProg.programImageAndReboot(call StorageMap.getPhysicalAddress[delugeCmd.imgNum](0));
break;
case DELUGE_CMD_REBOOT:
call NetProg.reboot();
break;
}
}
event void DelugeMetadata.readDone(uint8_t imgNum, DelugeIdent* ident, error_t error)
{
delugeCmd.imgNum = imgNum;
sendReply(error);
if (error != SUCCESS) {
return;
}
switch (delugeCmd.type) {
case DELUGE_CMD_ONLY_DISSEMINATE:
case DELUGE_CMD_DISSEMINATE_AND_REPROGRAM:
delugeCmd.uidhash = ident->uidhash;
delugeCmd.size = ident->size;
call DisseminationUpdate.change(&delugeCmd);
call ObjectTransfer.publish(delugeCmd.uidhash, delugeCmd.size, delugeCmd.imgNum);
break;
}
}
event void Resource.granted() {}
event void ObjectTransfer.receiveDone(error_t error) {}
event void SerialAMSender.sendDone(message_t* msg, error_t error) {}
event void DelugeVolumeManager.eraseDone(uint8_t imgNum) {}
}
--- NEW FILE: DelugeMetadataC.nc ---
/* Copyright (c) 2007 Johns Hopkins University.
* 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 (updated) modification history and the author appear in
* all copies of this source code.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, LOSS OF USE, DATA,
* OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
* @author Razvan Musaloiu-E. <razvanm at cs.jhu.edu>
* @author Chieh-Jan Mike Liang <cliang4 at cs.jhu.edu>
*/
configuration DelugeMetadataC
{
provides interface DelugeMetadata[uint8_t client];
uses event void storageReady();
}
implementation
{
components MainC;
components DelugeMetadataP;
DelugeMetadata = DelugeMetadataP;
storageReady = DelugeMetadataP;
DelugeMetadataP.Boot -> MainC;
components new BlockReaderC(VOLUME_GOLDENIMAGE) as BlockReaderGoldenImage;
components new BlockReaderC(VOLUME_DELUGE1) as BlockReaderDeluge1;
components new BlockReaderC(VOLUME_DELUGE2) as BlockReaderDeluge2;
components new BlockReaderC(VOLUME_DELUGE3) as BlockReaderDeluge3;
DelugeMetadataP.BlockRead[VOLUME_GOLDENIMAGE] -> BlockReaderGoldenImage;
DelugeMetadataP.BlockRead[VOLUME_DELUGE1] -> BlockReaderDeluge1;
DelugeMetadataP.BlockRead[VOLUME_DELUGE2] -> BlockReaderDeluge2;
DelugeMetadataP.BlockRead[VOLUME_DELUGE3] -> BlockReaderDeluge3;
components new BlockWriterC(VOLUME_GOLDENIMAGE) as BlockWriterGoldenImage;
components new BlockWriterC(VOLUME_DELUGE1) as BlockWriterDeluge1;
components new BlockWriterC(VOLUME_DELUGE2) as BlockWriterDeluge2;
components new BlockWriterC(VOLUME_DELUGE3) as BlockWriterDeluge3;
DelugeMetadataP.BlockWrite[VOLUME_GOLDENIMAGE] -> BlockWriterGoldenImage;
DelugeMetadataP.BlockWrite[VOLUME_DELUGE1] -> BlockWriterDeluge1;
DelugeMetadataP.BlockWrite[VOLUME_DELUGE2] -> BlockWriterDeluge2;
DelugeMetadataP.BlockWrite[VOLUME_DELUGE3] -> BlockWriterDeluge3;
}
--- NEW FILE: DelugeMetadataClientC.nc ---
/* Copyright (c) 2007 Johns Hopkins University.
* 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 (updated) modification history and the author appear in
* all copies of this source code.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, LOSS OF USE, DATA,
* OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
* @author Razvan Musaloiu-E. <razvanm at cs.jhu.edu>
* @author Chieh-Jan Mike Liang <cliang4 at cs.jhu.edu>
*/
generic configuration DelugeMetadataClientC()
{
provides interface DelugeMetadata;
}
implementation
{
enum {
CLIENT_ID = unique(UQ_DELUGE_METADATA)
};
components DelugeMetadataC;
DelugeMetadata = DelugeMetadataC.DelugeMetadata[CLIENT_ID];
}
--- NEW FILE: DelugeMetadataP.nc ---
/* Copyright (c) 2007 Johns Hopkins University.
* 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 (updated) modification history and the author appear in
* all copies of this source code.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, LOSS OF USE, DATA,
* OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
* @author Razvan Musaloiu-E. <razvanm at cs.jhu.edu>
* @author Chieh-Jan Mike Liang <cliang4 at cs.jhu.edu>
*/
module DelugeMetadataP
{
provides interface DelugeMetadata[uint8_t client];
uses {
interface Boot;
interface BlockRead[uint8_t volumeId];
interface BlockWrite[uint8_t volumeId];
interface StorageMap[uint8_t volumeId];
event void storageReady();
}
}
implementation
{
enum {
S_READ_IDENT,
S_READ_CRC,
S_CRC,
S_READY,
S_BUSY
};
DelugeIdent ident;
uint8_t state;
uint8_t currentImage;
uint8_t currentPage;
nx_uint16_t currentCrc;
uint8_t currentClient;
void nextImage()
{
if (currentImage < DELUGE_NUM_VOLUMES) {
state = S_READ_IDENT;
call BlockRead.read[currentImage](0, &ident, sizeof(ident));
} else {
signal storageReady();
state = S_READY;
}
}
uint32_t calcCrcAddr()
{
return DELUGE_IDENT_SIZE + currentPage * sizeof(uint16_t);
}
uint32_t calcPageAddr()
{
return DELUGE_IDENT_SIZE + DELUGE_CRC_BLOCK_SIZE + currentPage * DELUGE_BYTES_PER_PAGE;
}
event void Boot.booted()
{
// We are going to iterate over all the images and verify their
// integrity. For each image we first read the ident to find the
// number of pages and then iterate over all of them, compute the
// CRC and check it against the corresponding value from the CRCs
// block.
state = S_READ_IDENT;
currentImage = 0;
nextImage();
}
command error_t DelugeMetadata.read[uint8_t client](uint8_t imgNum)
{
error_t error;
if (state != S_READY) {
return FAIL;
}
currentClient = client;
error = call BlockRead.read[imgNum](0, &ident, sizeof(ident));
state = error == SUCCESS ? S_BUSY : state;
return error;
}
event void BlockRead.readDone[uint8_t imgNum](storage_addr_t addr, void* buf, storage_len_t len, error_t error)
{
switch (state) {
case S_BUSY:
state = S_READY;
signal DelugeMetadata.readDone[currentClient](imgNum, buf, error);
break;
case S_READ_IDENT:
if (error == SUCCESS) {
if (ident.uidhash != DELUGE_INVALID_UID) {
currentPage = 0;
state = S_READ_CRC;
call BlockRead.read[currentImage](calcCrcAddr(), ¤tCrc, sizeof(currentCrc));
} else {
currentImage++;
nextImage();
}
}
break;
case S_READ_CRC:
state = S_CRC;
call BlockRead.computeCrc[currentImage](calcPageAddr(), DELUGE_BYTES_PER_PAGE, 0);
break;
}
}
event void BlockRead.computeCrcDone[uint8_t imgNum](storage_addr_t addr, storage_len_t len, uint16_t crc, error_t error)
{
switch (state) {
case S_CRC:
if (crc != currentCrc) {
// printf("%04x %04x\n", crc, currentCrc);
// invalidate the image by erasing it
call BlockWrite.erase[currentImage]();
} else {
currentPage++;
if (currentPage < ident.numPgs) {
state = S_READ_CRC;
call BlockRead.read[currentImage](calcCrcAddr(), ¤tCrc, sizeof(currentCrc));
} else {
currentImage++;
nextImage();
}
}
break;
}
}
default command error_t BlockRead.read[uint8_t imgNum](storage_addr_t addr, void* buf, storage_len_t len) { return FAIL; }
default command error_t BlockRead.computeCrc[uint8_t imgNum](storage_addr_t addr, storage_len_t len, uint16_t crc) { return FAIL; }
event void BlockWrite.writeDone[uint8_t imgNum](storage_addr_t addr, void* buf, storage_len_t len, error_t error) {}
event void BlockWrite.eraseDone[uint8_t imgNum](error_t error)
{
switch (state) {
case S_READY:
signal BlockWrite.eraseDone[imgNum](error);
break;
case S_CRC:
currentImage++;
nextImage();
break;
}
}
event void BlockWrite.syncDone[uint8_t imgNum](error_t error) {}
default command error_t BlockWrite.erase[uint8_t imgNum]() { return FAIL; }
default event void DelugeMetadata.readDone[uint8_t client](uint8_t imgNum, DelugeIdent* i, error_t error) {}
default event void storageReady() {}
}
--- NEW FILE: DelugeVolumeManager.nc ---
/* Copyright (c) 2007 Johns Hopkins University.
* 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 (updated) modification history and the author appear in
* all copies of this source code.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, LOSS OF USE, DATA,
* OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
* @author Razvan Musaloiu-E. <razvanm at cs.jhu.edu>
* @author Chieh-Jan Mike Liang <cliang4 at cs.jhu.edu>
*/
interface DelugeVolumeManager
{
command error_t erase(uint8_t imgNum);
event void eraseDone(uint8_t imgNum);
}
--- NEW FILE: DelugeVolumeManagerC.nc ---
/* Copyright (c) 2007 Johns Hopkins University.
* 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 (updated) modification history and the author appear in
* all copies of this source code.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, LOSS OF USE, DATA,
* OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
* @author Razvan Musaloiu-E. <razvanm at cs.jhu.edu>
* @author Chieh-Jan Mike Liang <cliang4 at cs.jhu.edu>
*/
configuration DelugeVolumeManagerC
{
provides interface DelugeVolumeManager[uint8_t client];
}
implementation
{
components DelugeVolumeManagerP;
DelugeVolumeManager = DelugeVolumeManagerP;
components new BlockWriterC(VOLUME_DELUGE1) as BlockWriterDeluge1;
components new BlockWriterC(VOLUME_DELUGE2) as BlockWriterDeluge2;
components new BlockWriterC(VOLUME_DELUGE3) as BlockWriterDeluge3;
DelugeVolumeManagerP.BlockWrite[VOLUME_DELUGE1] -> BlockWriterDeluge1;
DelugeVolumeManagerP.BlockWrite[VOLUME_DELUGE2] -> BlockWriterDeluge2;
DelugeVolumeManagerP.BlockWrite[VOLUME_DELUGE3] -> BlockWriterDeluge3;
DelugeVolumeManagerP.Resource[VOLUME_DELUGE1] -> BlockWriterDeluge1;
DelugeVolumeManagerP.Resource[VOLUME_DELUGE2] -> BlockWriterDeluge2;
DelugeVolumeManagerP.Resource[VOLUME_DELUGE3] -> BlockWriterDeluge3;
}
--- NEW FILE: DelugeVolumeManagerClientC.nc ---
/* Copyright (c) 2007 Johns Hopkins University.
* 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 (updated) modification history and the author appear in
* all copies of this source code.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, LOSS OF USE, DATA,
* OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
* @author Razvan Musaloiu-E. <razvanm at cs.jhu.edu>
* @author Chieh-Jan Mike Liang <cliang4 at cs.jhu.edu>
*/
generic configuration DelugeVolumeManagerClientC()
{
provides interface DelugeVolumeManager;
}
implementation
{
enum {
CLIENT_ID = unique(UQ_DELUGE_VOLUME_MANAGER)
};
components DelugeVolumeManagerC;
DelugeVolumeManager = DelugeVolumeManagerC.DelugeVolumeManager[CLIENT_ID];
}
--- NEW FILE: DelugeVolumeManagerP.nc ---
/* Copyright (c) 2007 Johns Hopkins University.
* 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 (updated) modification history and the author appear in
* all copies of this source code.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, LOSS OF USE, DATA,
* OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
* @author Razvan Musaloiu-E. <razvanm at cs.jhu.edu>
* @author Chieh-Jan Mike Liang <cliang4 at cs.jhu.edu>
*/
module DelugeVolumeManagerP
{
provides interface DelugeVolumeManager[uint8_t client];
uses {
interface BlockWrite[uint8_t volumeId];
interface Resource[uint8_t volumeId];
}
}
implementation
{
uint8_t currentClient;
bool busy = FALSE;
command error_t DelugeVolumeManager.erase[uint8_t client](uint8_t imgNum)
{
if (busy)
return FAIL;
busy = call Resource.request[imgNum]() == SUCCESS;
if (busy) {
currentClient = client;
return SUCCESS;
}
return FAIL;
}
event void Resource.granted[uint8_t imgNum]()
{
call BlockWrite.erase[imgNum]();
}
event void BlockWrite.eraseDone[uint8_t imgNum](error_t error)
{
busy = FALSE;
call Resource.release[imgNum]();
signal DelugeVolumeManager.eraseDone[currentClient](error);
}
event void BlockWrite.writeDone[uint8_t imgNum](storage_addr_t addr, void* buf, storage_len_t len, error_t error) {}
event void BlockWrite.syncDone[uint8_t imgNum](error_t error) {}
default command error_t BlockWrite.erase[uint8_t imgNum]() { return FAIL; }
default event void DelugeVolumeManager.eraseDone[uint8_t client](uint8_t imgNum) {}
default async command error_t Resource.request[uint8_t imgNum]() { return FAIL; }
default async command error_t Resource.release[uint8_t imgNum]() { return FAIL; }
}
Index: Deluge.h
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/lib/net/Deluge/Deluge.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** Deluge.h 20 Dec 2007 02:31:40 -0000 1.3
--- Deluge.h 14 Jan 2008 04:22:01 -0000 1.4
***************
*** 28,35 ****
#define __DELUGE_H__
! #include "DelugeMetadata.h"
!
! #define DISSMSG_DISS 0
! #define DISSMSG_REPROG 1
enum {
--- 28,44 ----
#define __DELUGE_H__
! typedef nx_struct DelugeIdent {
! nx_uint32_t uidhash; // unique id of the image
! nx_uint32_t size; // size of the whole image (ident + CRCs + binary)
! nx_uint8_t numPgs; // number of pages of complete image
! nx_uint8_t reserved;
! nx_uint16_t crc; // crc over the above 4 fields
! nx_uint8_t appname[16];
! nx_uint8_t username[16];
! nx_uint8_t hostname[16];
! nx_uint8_t platform[16];
! nx_uint32_t timestamp;
! nx_uint32_t userhash;
! } DelugeIdent;
enum {
***************
*** 38,56 ****
};
! typedef nx_struct DelugeDissemination {
! nx_uint8_t msg_type;
! nx_uint32_t uid; // unique id of image
! nx_uint16_t vNum; // version num of image
nx_uint8_t imgNum; // image number
nx_uint16_t size; // size of the image
! } DelugeDissemination;
! typedef struct DelugeNodeDesc {
! imgvnum_t vNum;
! uint32_t uid;
! imgnum_t imgNum;
! uint8_t reserved;
! uint16_t crc;
! } DelugeNodeDesc;
#endif
--- 47,75 ----
};
! enum {
! DELUGE_CMD_STOP = 1,
! DELUGE_CMD_LOCAL_STOP = 2,
! DELUGE_CMD_ONLY_DISSEMINATE = 3,
! DELUGE_CMD_DISSEMINATE_AND_REPROGRAM = 4,
! DELUGE_CMD_REPROGRAM = 5, // Reprogram the local mote
! DELUGE_CMD_REBOOT = 6, // Reboot the local mode
! };
!
! #define UQ_DELUGE_METADATA "DelugeMetadata.client"
! #define UQ_DELUGE_VOLUME_MANAGER "DelugeVolumeManager.client"
!
! typedef nx_struct DelugeCmd {
! nx_uint8_t type;
! nx_uint32_t uidhash; // unique id of image
nx_uint8_t imgNum; // image number
nx_uint16_t size; // size of the image
! } DelugeCmd;
! typedef struct BootArgs {
! uint16_t address;
! uint32_t imageAddr;
! uint8_t gestureCount;
! bool noReprogram;
! } BootArgs;
#endif
Index: DelugeC.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/lib/net/Deluge/DelugeC.nc,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** DelugeC.nc 20 Dec 2007 02:31:40 -0000 1.6
--- DelugeC.nc 14 Jan 2008 04:22:01 -0000 1.7
***************
*** 28,33 ****
#include "StorageVolumes.h"
! configuration DelugeC
! {
uses interface Leds;
}
--- 28,32 ----
#include "StorageVolumes.h"
! configuration DelugeC {
uses interface Leds;
}
***************
*** 35,88 ****
implementation
{
! components DelugeStorageC;
!
! #ifdef DELUGE_BASESTATION
! components SerialStarterC;
! components new FlashVolumeManagerC(0xAB);
! DelugeP.DissNotify -> FlashVolumeManagerC.DissNotify;
! DelugeP.ReprogNotify -> FlashVolumeManagerC.ReprogNotify;
! FlashVolumeManagerC.BlockRead[VOLUME_GOLDENIMAGE] -> DelugeStorageC.BlockRead[VOLUME_GOLDENIMAGE];
! FlashVolumeManagerC.BlockWrite[VOLUME_GOLDENIMAGE] -> DelugeStorageC.BlockWrite[VOLUME_GOLDENIMAGE];
! FlashVolumeManagerC.DelugeStorage[VOLUME_GOLDENIMAGE] -> DelugeStorageC.DelugeStorage[VOLUME_GOLDENIMAGE];
! FlashVolumeManagerC.BlockRead[VOLUME_DELUGE1] -> DelugeStorageC.BlockRead[VOLUME_DELUGE1];
! FlashVolumeManagerC.BlockWrite[VOLUME_DELUGE1] -> DelugeStorageC.BlockWrite[VOLUME_DELUGE1];
! FlashVolumeManagerC.DelugeStorage[VOLUME_DELUGE1] -> DelugeStorageC.DelugeStorage[VOLUME_DELUGE1];
! FlashVolumeManagerC.BlockRead[VOLUME_DELUGE2] -> DelugeStorageC.BlockRead[VOLUME_DELUGE2];
! FlashVolumeManagerC.BlockWrite[VOLUME_DELUGE2] -> DelugeStorageC.BlockWrite[VOLUME_DELUGE2];
! FlashVolumeManagerC.DelugeStorage[VOLUME_DELUGE2] -> DelugeStorageC.DelugeStorage[VOLUME_DELUGE2];
- FlashVolumeManagerC.BlockRead[VOLUME_DELUGE3] -> DelugeStorageC.BlockRead[VOLUME_DELUGE3];
- FlashVolumeManagerC.BlockWrite[VOLUME_DELUGE3] -> DelugeStorageC.BlockWrite[VOLUME_DELUGE3];
- FlashVolumeManagerC.DelugeStorage[VOLUME_DELUGE3] -> DelugeStorageC.DelugeStorage[VOLUME_DELUGE3];
- #endif
-
- components ObjectTransferC;
- ObjectTransferC.BlockRead[VOLUME_DELUGE1] -> DelugeStorageC.BlockRead[VOLUME_DELUGE1];
- ObjectTransferC.BlockWrite[VOLUME_DELUGE1] -> DelugeStorageC.BlockWrite[VOLUME_DELUGE1];
- ObjectTransferC.BlockRead[VOLUME_DELUGE2] -> DelugeStorageC.BlockRead[VOLUME_DELUGE2];
- ObjectTransferC.BlockWrite[VOLUME_DELUGE2] -> DelugeStorageC.BlockWrite[VOLUME_DELUGE2];
- ObjectTransferC.BlockRead[VOLUME_DELUGE3] -> DelugeStorageC.BlockRead[VOLUME_DELUGE3];
- ObjectTransferC.BlockWrite[VOLUME_DELUGE3] -> DelugeStorageC.BlockWrite[VOLUME_DELUGE3];
ObjectTransferC.Leds = Leds;
! components new DisseminatorC(DelugeDissemination, 0xDE00), DisseminationC;
components ActiveMessageC;
components NetProgC, DelugeP;
components new TimerMilliC() as Timer;
DelugeP.Leds = Leds;
DelugeP.DisseminationValue -> DisseminatorC;
! DelugeP.DisseminationUpdate -> DisseminatorC;
! DelugeP.StdControlDissemination -> DisseminationC;
DelugeP.ObjectTransfer -> ObjectTransferC;
DelugeP.NetProg -> NetProgC;
- DelugeP.StorageReadyNotify -> DelugeStorageC;
- DelugeP.DelugeMetadata -> DelugeStorageC;
DelugeP.RadioSplitControl -> ActiveMessageC;
!
! components InternalFlashC as IFlash;
! DelugeP.IFlash -> IFlash;
}
--- 34,89 ----
implementation
{
! components ObjectTransferC;
! components new BlockReaderC(VOLUME_DELUGE1) as BlockReaderDeluge1;
! components new BlockReaderC(VOLUME_DELUGE2) as BlockReaderDeluge2;
! components new BlockReaderC(VOLUME_DELUGE3) as BlockReaderDeluge3;
! components new BlockWriterC(VOLUME_DELUGE1) as BlockWriterDeluge1;
! components new BlockWriterC(VOLUME_DELUGE2) as BlockWriterDeluge2;
! components new BlockWriterC(VOLUME_DELUGE3) as BlockWriterDeluge3;
! ObjectTransferC.BlockRead[VOLUME_DELUGE1] -> BlockReaderDeluge1;
! ObjectTransferC.BlockRead[VOLUME_DELUGE2] -> BlockReaderDeluge2;
! ObjectTransferC.BlockRead[VOLUME_DELUGE3] -> BlockReaderDeluge3;
! ObjectTransferC.BlockWrite[VOLUME_DELUGE1] -> BlockWriterDeluge1;
! ObjectTransferC.BlockWrite[VOLUME_DELUGE2] -> BlockWriterDeluge2;
! ObjectTransferC.BlockWrite[VOLUME_DELUGE3] -> BlockWriterDeluge3;
ObjectTransferC.Leds = Leds;
! components new DisseminatorC(DelugeCmd, 0xDE00);
! components DisseminationC;
components ActiveMessageC;
components NetProgC, DelugeP;
components new TimerMilliC() as Timer;
+ components BlockStorageManagerC;
+ components DelugeMetadataC;
+ components new DelugeMetadataClientC();
+ components new DelugeVolumeManagerClientC();
+ components new BlockStorageLockClientC();
+ components MainC;
+
+ DelugeP.Boot -> MainC;
DelugeP.Leds = Leds;
DelugeP.DisseminationValue -> DisseminatorC;
! DelugeP.DisseminationStdControl -> DisseminationC;
DelugeP.ObjectTransfer -> ObjectTransferC;
DelugeP.NetProg -> NetProgC;
DelugeP.RadioSplitControl -> ActiveMessageC;
! DelugeP.StorageMap -> BlockStorageManagerC;
! DelugeP.DelugeMetadata -> DelugeMetadataClientC;
! DelugeP.storageReady <- DelugeMetadataC;
! DelugeP.DelugeVolumeManager -> DelugeVolumeManagerClientC;
! DelugeP.Resource -> BlockStorageLockClientC;
!
! #ifdef DELUGE_BASESTATION
! components SerialStarterC;
! components new FlashVolumeManagerC(0xAB);
! components new DelugeManagerC(0xAC);
!
! DelugeManagerC.DisseminationUpdate -> DisseminatorC;
! #endif
!
}
Index: DelugeMetadata.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/lib/net/Deluge/DelugeMetadata.nc,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** DelugeMetadata.nc 22 May 2007 20:34:22 -0000 1.1
--- DelugeMetadata.nc 14 Jan 2008 04:22:01 -0000 1.2
***************
*** 1,33 ****
- /*
- * "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."
- *
- * Copyright (c) 2007 Johns Hopkins University.
- * All rights reserved.
- */
-
/**
! * @author Jonathan Hui <jwhui at cs.berkeley.edu>
! * @author Chieh-Jan Mike Liang <cliang4 at cs.jhu.edu>
! * @author Razvan Musaloiu-E. <razvanm at cs.jhu.edu>
*/
! interface DelugeMetadata {
! command DelugeImgDesc* getImgDesc(imgnum_t imgNum);
}
--- 1,14 ----
/**
! * An interface for obtaining the identification data of an
! * image. The pointer returned by readDone will be destroyed by the
! * next read.
! *
! * @author Razvan Musaloiu-E. <razvanm at cs.jhu.edu>
! * @author Chieh-Jan Mike Liang <cliang4 at cs.jhu.edu>
*/
! interface DelugeMetadata
! {
! command error_t read(uint8_t imgNum);
! event void readDone(uint8_t imgNum, DelugeIdent* ident, error_t error);
}
Index: DelugeP.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/lib/net/Deluge/DelugeP.nc,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** DelugeP.nc 19 Jul 2007 02:19:38 -0000 1.6
--- DelugeP.nc 14 Jan 2008 04:22:01 -0000 1.7
***************
*** 21,26 ****
/**
- * @author Chieh-Jan Mike Liang <cliang4 at cs.jhu.edu>
* @author Razvan Musaloiu-E. <razvanm at cs.jhu.edu>
*/
--- 21,26 ----
/**
* @author Razvan Musaloiu-E. <razvanm at cs.jhu.edu>
+ * @author Chieh-Jan Mike Liang <cliang4 at cs.jhu.edu>
*/
***************
*** 28,46 ****
{
uses {
interface Leds;
! interface Notify<uint8_t> as StorageReadyNotify;
! interface DisseminationUpdate<DelugeDissemination>;
! interface DisseminationValue<DelugeDissemination>;
! interface StdControl as StdControlDissemination;
! interface DelugeMetadata;
interface ObjectTransfer;
- interface NetProg;
- interface InternalFlash as IFlash;
interface SplitControl as RadioSplitControl;
!
! #ifdef DELUGE_BASESTATION
! interface Notify<uint8_t> as DissNotify;
! interface Notify<uint8_t> as ReprogNotify;
! #endif
}
}
--- 28,46 ----
{
uses {
+ interface Boot;
interface Leds;
! interface DisseminationValue<DelugeCmd>;
! interface StdControl as DisseminationStdControl;
interface ObjectTransfer;
interface SplitControl as RadioSplitControl;
! interface NetProg;
! interface StorageMap[uint8_t volumeId];
! interface DelugeMetadata;
! interface DelugeVolumeManager;
! interface Resource;
! }
! provides {
! event void storageReady();
! command void stop();
}
}
***************
*** 48,141 ****
implementation
{
! uint32_t recv_uid = 0xffffffff;
! uint16_t recv_size = 0xffff;
! uint8_t recv_imgNum = 0xff;
!
! /**
! * Starts the radio
! */
! event void StorageReadyNotify.notify(uint8_t val)
{
call RadioSplitControl.start();
}
!
! #ifdef DELUGE_BASESTATION
! /**
! * Starts disseminating image information
! */
! event void DissNotify.notify(uint8_t new_img_num)
{
! DelugeImgDesc* imgDesc = call DelugeMetadata.getImgDesc(new_img_num);
! if (imgDesc->uid != DELUGE_INVALID_UID) {
! DelugeDissemination delugeDis;
!
! call ObjectTransfer.stop();
!
! delugeDis.uid = imgDesc->uid;
! delugeDis.vNum = imgDesc->vNum;
! delugeDis.imgNum = new_img_num;
! delugeDis.size = imgDesc->size;
! delugeDis.msg_type = DISSMSG_DISS;
!
! call DisseminationUpdate.change(&delugeDis); // Disseminates command
! call ObjectTransfer.publish(delugeDis.uid,
! delugeDis.size,
! delugeDis.imgNum); // Prepares to publish image data
}
}
! event void ReprogNotify.notify(uint8_t new_img_num)
{
! DelugeDissemination delugeDis;
!
! delugeDis.uid = 0;
! delugeDis.vNum = 0;
! delugeDis.imgNum = new_img_num;
! delugeDis.size = 0;
! delugeDis.msg_type = DISSMSG_REPROG;
!
! call DisseminationUpdate.change(&delugeDis); // Disseminates command
}
- #endif
- /**
- * Receives a disseminated message. If the message contains information about a
- * newer image, then we should grab this image from the network
- */
event void DisseminationValue.changed()
{
! const DelugeDissemination *delugeDis = call DisseminationValue.get();
! DelugeImgDesc *imgDesc = call DelugeMetadata.getImgDesc(delugeDis->imgNum);
!
! switch (delugeDis->msg_type) {
! case DISSMSG_DISS:
! if (imgDesc->uid == delugeDis->uid && imgDesc->uid != DELUGE_INVALID_UID) {
! if (imgDesc->vNum < delugeDis->vNum) {
! recv_uid = delugeDis->uid;
! recv_size = delugeDis->size;
! recv_imgNum = delugeDis->imgNum;
! call ObjectTransfer.receive(delugeDis->uid, delugeDis->size, delugeDis->imgNum);
! }
! } else {
! recv_uid = delugeDis->uid;
! recv_size = delugeDis->size;
! recv_imgNum = delugeDis->imgNum;
! call ObjectTransfer.receive(delugeDis->uid, delugeDis->size, delugeDis->imgNum);
! }
!
! break;
! case DISSMSG_REPROG:
! if (imgDesc->uid != DELUGE_INVALID_UID) {
! DelugeNodeDesc nodeDesc;
! call IFlash.read((uint8_t*)IFLASH_NODE_DESC_ADDR,
! &nodeDesc,
! sizeof(DelugeNodeDesc)); // Reads which image was just reprogrammed
! if (nodeDesc.uid != imgDesc->uid || nodeDesc.vNum != imgDesc->vNum) {
! call NetProg.programImgAndReboot(delugeDis->imgNum);
! }
! }
!
! break;
}
}
--- 48,133 ----
implementation
{
! enum {
! S_IDLE,
! S_PUB,
! S_RECV
! };
!
! DelugeCmd lastCmd;
! uint8_t state = S_IDLE;
!
! event void storageReady()
{
call RadioSplitControl.start();
}
!
! event void Boot.booted()
{
! lastCmd.uidhash = DELUGE_INVALID_UID;
! }
!
! event void RadioSplitControl.startDone(error_t error)
! {
! if (error == SUCCESS) {
! call DisseminationStdControl.start();
! }
! }
!
! command void stop()
! {
! call Resource.release();
! if (state == S_RECV) {
! // printf("erase %d\n", lastCmd.imgNum);
! call DelugeVolumeManager.erase(lastCmd.imgNum);
}
+ call ObjectTransfer.stop();
+ state = S_IDLE;
+ }
+
+ task void taskRequest()
+ {
+ signal Resource.granted();
}
! void request()
{
! if (call Resource.isOwner()) {
! post taskRequest();
! } else {
! call Resource.request();
! }
}
event void DisseminationValue.changed()
{
! const DelugeCmd *cmd = call DisseminationValue.get();
! // printf("cmd: %d uidhash: 0x%lx imgNum: %d size: %u\n", cmd->type, cmd->uidhash, cmd->imgNum, cmd->size);
! switch (cmd->type) {
! case DELUGE_CMD_STOP:
! call stop();
! break;
! case DELUGE_CMD_ONLY_DISSEMINATE:
! case DELUGE_CMD_DISSEMINATE_AND_REPROGRAM:
! if (state == S_RECV) {
! if (cmd->uidhash == lastCmd.uidhash) {
! if (cmd->imgNum == lastCmd.imgNum) {
! // Same uidhash, same imgNum, only cmd should be
! // different. That will be properly updated by the last
! // statement from this function.
! break;
! }
! }
! call stop();
! }
! if (cmd->uidhash != IDENT_UIDHASH) {
! call DelugeMetadata.read(cmd->imgNum);
! } else {
! state = S_PUB;
! request();
! }
! break;
}
+ lastCmd = *cmd;
+ // printf("lastCmd: %d uidhash: 0x%lx\n", lastCmd.type, lastCmd.uidhash);
}
***************
*** 143,161 ****
{
call Leds.set(LEDS_LED1 | LEDS_LED2);
! call ObjectTransfer.publish(recv_uid, recv_size, recv_imgNum);
}
! /**
! * Prepares to publish the image that was just reprogrammed
! */
! event void RadioSplitControl.startDone(error_t error)
{
! if (error == SUCCESS) {
! call StdControlDissemination.start();
}
}
!
event void RadioSplitControl.stopDone(error_t error) {}
-
default async void command Leds.set(uint8_t val) {}
}
--- 135,187 ----
{
call Leds.set(LEDS_LED1 | LEDS_LED2);
! state = S_IDLE;
!
! if (error == SUCCESS) {
! switch (lastCmd.type) {
! case DELUGE_CMD_ONLY_DISSEMINATE:
! state = S_PUB;
! request();
! break;
! case DELUGE_CMD_DISSEMINATE_AND_REPROGRAM:
! call NetProg.programImageAndReboot(call StorageMap.getPhysicalAddress[lastCmd.imgNum](0));
! break;
! }
! } else {
! call DelugeVolumeManager.erase(lastCmd.imgNum);
! }
}
! event void DelugeMetadata.readDone(uint8_t imgNum, DelugeIdent* ident, error_t error)
{
! // printf("readDone 0x%lx imgNum: %d size: %u\n", lastCmd.uidhash, lastCmd.imgNum, lastCmd.size);
! if (ident->uidhash == lastCmd.uidhash) {
! if (lastCmd.type == DELUGE_CMD_DISSEMINATE_AND_REPROGRAM) {
! call NetProg.programImageAndReboot(call StorageMap.getPhysicalAddress[imgNum](0));
! } else {
! // We already have the image so we'll go ahead and start publishing.
! state = S_PUB;
! request();
! }
! } else {
! state = S_RECV;
! request();
}
}
!
! event void Resource.granted()
! {
! switch (state) {
! case S_PUB:
! // printf("start pub 0x%lx imgNum: %d size: %u\n", lastCmd.uidhash, lastCmd.imgNum, lastCmd.size);
! call ObjectTransfer.publish(lastCmd.uidhash, lastCmd.size, lastCmd.imgNum);
! break;
! case S_RECV:
! call ObjectTransfer.receive(lastCmd.uidhash, lastCmd.size, lastCmd.imgNum);
! break;
! }
! }
!
! event void DelugeVolumeManager.eraseDone(uint8_t imgNum) {}
event void RadioSplitControl.stopDone(error_t error) {}
default async void command Leds.set(uint8_t val) {}
}
Index: DelugePageTransfer.h
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/lib/net/Deluge/DelugePageTransfer.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** DelugePageTransfer.h 22 Dec 2007 08:29:30 -0000 1.4
--- DelugePageTransfer.h 14 Jan 2008 04:22:01 -0000 1.5
***************
*** 71,77 ****
DELUGE_FAILED_SEND_DELAY = 16,
DELUGE_MIN_DELAY = 16,
! DELUGE_DATA_OFFSET = 128,
DELUGE_IDENT_SIZE = 128,
DELUGE_INVALID_ADDR = (0x7fffffffL),
DELUGE_MAX_REQ_DELAY = (0x1L << (DELUGE_MIN_ADV_PERIOD_LOG2 - 1)),
DELUGE_NACK_TIMEOUT = (DELUGE_MAX_REQ_DELAY >> 0x1),
--- 71,78 ----
DELUGE_FAILED_SEND_DELAY = 16,
DELUGE_MIN_DELAY = 16,
! // DELUGE_DATA_OFFSET = 128,
DELUGE_IDENT_SIZE = 128,
DELUGE_INVALID_ADDR = (0x7fffffffL),
+ DELUGE_MIN_ADV_PERIOD_LOG2 = 9,
DELUGE_MAX_REQ_DELAY = (0x1L << (DELUGE_MIN_ADV_PERIOD_LOG2 - 1)),
DELUGE_NACK_TIMEOUT = (DELUGE_MAX_REQ_DELAY >> 0x1),
***************
*** 84,87 ****
--- 85,89 ----
DELUGE_INVALID_PKTNUM = 0xff,
DELUGE_INVALID_PGNUM = 0xff,
+ DELUGE_QSIZE = 2
};
Index: DelugePageTransfer.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/lib/net/Deluge/DelugePageTransfer.nc,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** DelugePageTransfer.nc 22 May 2007 20:34:23 -0000 1.1
--- DelugePageTransfer.nc 14 Jan 2008 04:22:01 -0000 1.2
***************
*** 38,42 ****
event void receivedPage(object_id_t new_objid, page_num_t new_pgNum);
command void setImgNum(uint8_t new_img_num);
-
command error_t stop();
}
--- 38,41 ----
Index: DelugePageTransferC.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/lib/net/Deluge/DelugePageTransferC.nc,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** DelugePageTransferC.nc 21 Dec 2007 18:37:24 -0000 1.3
--- DelugePageTransferC.nc 14 Jan 2008 04:22:01 -0000 1.4
***************
*** 47,56 ****
DelugePageTransfer = DelugePageTransferP;
! BlockRead[VOLUME_DELUGE1] = DelugePageTransferP.BlockRead[VOLUME_DELUGE1];
! BlockWrite[VOLUME_DELUGE1] = DelugePageTransferP.BlockWrite[VOLUME_DELUGE1];
! BlockRead[VOLUME_DELUGE2] = DelugePageTransferP.BlockRead[VOLUME_DELUGE2];
! BlockWrite[VOLUME_DELUGE2] = DelugePageTransferP.BlockWrite[VOLUME_DELUGE2];
! BlockRead[VOLUME_DELUGE3] = DelugePageTransferP.BlockRead[VOLUME_DELUGE3];
! BlockWrite[VOLUME_DELUGE3] = DelugePageTransferP.BlockWrite[VOLUME_DELUGE3];
ReceiveDataMsg = DelugePageTransferP.ReceiveDataMsg;
--- 47,52 ----
DelugePageTransfer = DelugePageTransferP;
! BlockRead = DelugePageTransferP.BlockRead;
! BlockWrite = DelugePageTransferP.BlockWrite;
ReceiveDataMsg = DelugePageTransferP.ReceiveDataMsg;
Index: DelugePageTransferP.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/lib/net/Deluge/DelugePageTransferP.nc,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** DelugePageTransferP.nc 22 Dec 2007 08:29:30 -0000 1.4
--- DelugePageTransferP.nc 14 Jan 2008 04:22:01 -0000 1.5
***************
*** 149,153 ****
return (storage_addr_t)pgNum * (storage_addr_t)DELUGET2_BYTES_PER_PAGE
+ (uint16_t)pktNum * (uint16_t)DELUGET2_PKT_PAYLOAD_SIZE;
- //+ DELUGE_METADATA_SIZE;
}
--- 149,152 ----
***************
*** 176,180 ****
if (call BitVecUtils.indexOf(&nextPkt, pDataMsg->pktNum, pktsToSend, DELUGET2_PKTS_PER_PAGE) != SUCCESS) {
// no more packets to send
- //dbg(DBG_USR1, "DELUGE: SEND_DONE\n");
changeState(S_IDLE);
} else {
--- 175,178 ----
***************
*** 322,328 ****
int i;
- //dbg(DBG_USR1, "DELUGE: Received REQ_MSG(dest=%d,vNum=%d,imgNum=%d,pgNum=%d,pkts=%x)\n",
- // rxReqMsg->dest, rxReqMsg->vNum, rxReqMsg->imgNum, rxReqMsg->pgNum, rxReqMsg->requestedPkts[0]);
-
if (state == S_DISABLED) {
return msg;
--- 320,323 ----
***************
*** 387,393 ****
}
- //dbg(DBG_USR1, "DELUGE: Received DATA_MSG(vNum=%d,imgNum=%d,pgNum=%d,pktNum=%d)\n",
- // rxDataMsg->vNum, rxDataMsg->imgNum, rxDataMsg->pgNum, rxDataMsg->pktNum);
-
// check if need to suppress req or data messages
suppressMsgs(rxDataMsg->objid, rxDataMsg->pgNum);
--- 382,385 ----
***************
*** 402,413 ****
if (rxDataMsg->pktNum == 0) {
//call StatsCollector.startRecvPageTransTime(0);
- dbg("Deluge", "%.3f 115 116 116 117 115 1 %d\n", ((float)((sim_time() * 1000) / sim_ticks_per_sec())) / 1000, CC2420_DEF_CHANNEL);
}
call Leds.led1Toggle();
//call Leds.set(rxDataMsg->pktNum);
- //dbg(DBG_USR1, "DELUGE: SAVING(pgNum=%d,pktNum=%d)\n",
- // rxDataMsg->pgNum, rxDataMsg->pktNum);
-
// copy data
memcpy(&rxQueue[head^size], rxDataMsg, sizeof(DelugeDataMsg));
--- 394,401 ----
***************
*** 476,481 ****
// For collecting stats
//call StatsCollector.endRecvPageTransTime(publisher_addr);
- dbg("Deluge", "%.3f 115 116 116 117 115 2 %d\n", ((float)((sim_time() * 1000) / sim_ticks_per_sec())) / 1000, publisher_addr);
signal DelugePageTransfer.receivedPage(workingObjid, workingPgNum);
changeState(S_IDLE);
--- 464,469 ----
// For collecting stats
//call StatsCollector.endRecvPageTransTime(publisher_addr);
+ call Leds.led1Off();
signal DelugePageTransfer.receivedPage(workingObjid, workingPgNum);
changeState(S_IDLE);
***************
*** 497,499 ****
--- 485,488 ----
default command error_t BlockWrite.write[uint8_t img_num](storage_addr_t addr, void* buf, storage_len_t len) { return FAIL; }
default async command void Leds.led1Toggle() {}
+ default async command void Leds.led1Off() {}
}
Index: ObjectTransferC.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/lib/net/Deluge/ObjectTransferC.nc,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** ObjectTransferC.nc 20 Dec 2007 02:31:40 -0000 1.4
--- ObjectTransferC.nc 14 Jan 2008 04:22:01 -0000 1.5
***************
*** 41,55 ****
{
components ObjectTransferP, DelugePageTransferC;
ObjectTransfer = ObjectTransferP;
! BlockRead[VOLUME_DELUGE1] = DelugePageTransferC.BlockRead[VOLUME_DELUGE1];
! BlockWrite[VOLUME_DELUGE1] = DelugePageTransferC.BlockWrite[VOLUME_DELUGE1];
! BlockRead[VOLUME_DELUGE2] = DelugePageTransferC.BlockRead[VOLUME_DELUGE2];
! BlockWrite[VOLUME_DELUGE2] = DelugePageTransferC.BlockWrite[VOLUME_DELUGE2];
! BlockRead[VOLUME_DELUGE3] = DelugePageTransferC.BlockRead[VOLUME_DELUGE3];
! BlockWrite[VOLUME_DELUGE3] = DelugePageTransferC.BlockWrite[VOLUME_DELUGE3];
ObjectTransferP.DelugePageTransfer -> DelugePageTransferC.DelugePageTransfer;
-
- components CrcP;
ObjectTransferP.Crc -> CrcP.Crc;
--- 41,50 ----
{
components ObjectTransferP, DelugePageTransferC;
+ components CrcP;
ObjectTransfer = ObjectTransferP;
! DelugePageTransferC.BlockRead = BlockRead;
! DelugePageTransferC.BlockWrite = BlockWrite;
ObjectTransferP.DelugePageTransfer -> DelugePageTransferC.DelugePageTransfer;
ObjectTransferP.Crc -> CrcP.Crc;
***************
*** 70,76 ****
DelugePageTransferC.Leds = Leds;
! ObjectTransferP.BlockWrite[VOLUME_DELUGE1] = BlockWrite[VOLUME_DELUGE1];
! ObjectTransferP.BlockWrite[VOLUME_DELUGE2] = BlockWrite[VOLUME_DELUGE2];
! ObjectTransferP.BlockWrite[VOLUME_DELUGE3] = BlockWrite[VOLUME_DELUGE3];
components RandomC, new TimerMilliC() as Timer;
--- 65,69 ----
DelugePageTransferC.Leds = Leds;
! ObjectTransferP.BlockWrite = BlockWrite;
components RandomC, new TimerMilliC() as Timer;
Index: ObjectTransferP.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/lib/net/Deluge/ObjectTransferP.nc,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** ObjectTransferP.nc 22 Dec 2007 08:29:30 -0000 1.7
--- ObjectTransferP.nc 14 Jan 2008 04:22:01 -0000 1.8
***************
*** 64,68 ****
DelugeAdvTimer advTimers;
- //DelugeNodeDesc nodeDesc;
uint8_t state = S_STOPPED;
--- 64,67 ----
***************
*** 118,126 ****
}
- // bool isNodeDescValid(DelugeNodeDesc* tmpNodeDesc)
- // {
- // return (tmpNodeDesc->crc == crc16(tmpNodeDesc, 4 + sizeof(object_id_t) + 1));
- // }
-
bool isObjDescValid(DelugeObjDesc* tmpObjDesc)
{
--- 117,120 ----
***************
*** 138,158 ****
pMsg->sourceAddr = TOS_NODE_ID;
pMsg->version = DELUGE_VERSION;
- //pMsg->type = (imagesLoaded) ? DELUGE_ADV_NORMAL : DELUGE_ADV_ERROR;
pMsg->type = DELUGE_ADV_NORMAL;
!
! // make sure node desc is valid
! // if (!isNodeDescValid(&nodeDesc)) {
! // memset(&nodeDesc, 0xff, sizeof(nodeDesc));
! // }
! // memcpy(&pMsg->nodeDesc, &nodeDesc, sizeof(DelugeNodeDesc));
!
! // make sure obj desc is valid
! // if (!isObjDescValid(&curObjDesc)) {
! // //curObjDesc.objid = objid;
! // }
memcpy(&(pMsg->objDesc), &curObjDesc, sizeof(DelugeObjDesc));
if (call SendAdvMsg.send(addr, &pMsgBuf, sizeof(DelugeAdvMsg)) == SUCCESS) {
- //dbg(DBG_USR1, "DELUGE: Sent ADV_MSG(imgNum=%d)\n", imgDesc->imgNum);
//call StatsCollector.msg_bcastReq();
isBusy_pMsgBuf = TRUE;
--- 132,140 ----
pMsg->sourceAddr = TOS_NODE_ID;
pMsg->version = DELUGE_VERSION;
pMsg->type = DELUGE_ADV_NORMAL;
!
memcpy(&(pMsg->objDesc), &curObjDesc, sizeof(DelugeObjDesc));
if (call SendAdvMsg.send(addr, &pMsgBuf, sizeof(DelugeAdvMsg)) == SUCCESS) {
//call StatsCollector.msg_bcastReq();
isBusy_pMsgBuf = TRUE;
***************
*** 244,247 ****
--- 226,230 ----
event void DelugePageTransfer.receivedPage(object_id_t new_objid, page_num_t new_pgNum)
{
+ // printf("R: %08lx %d\n", new_objid, new_pgNum);
if (new_objid == curObjDesc.objid && new_pgNum == curObjDesc.numPgsComplete) {
curObjDesc.numPgsComplete++;
***************
*** 288,294 ****
}
! if (rxAdvMsg->version != DELUGE_VERSION
! //|| !isNodeDescValid(&rxAdvMsg->nodeDesc)
! || state != S_STARTED) {
return msg;
}
--- 271,275 ----
}
! if (rxAdvMsg->version != DELUGE_VERSION || state != S_STARTED) {
return msg;
}
--- DelugeMetadata.h DELETED ---
--- DelugeStorage.nc DELETED ---
--- DelugeStorageC.nc DELETED ---
--- DelugeStorageP.nc DELETED ---
- Previous message: [Tinyos-2-commits]
CVS: tinyos-2.x/tos/lib/net/Deluge/BlockStorageManager
BlockReaderC.nc, NONE, 1.1 BlockStorageLockC.nc, NONE,
1.1 BlockStorageLockClientC.nc, NONE,
1.1 BlockStorageManager.h, NONE, 1.1 BlockStorageManagerC.nc,
NONE, 1.1 BlockStorageManagerP.nc, NONE, 1.1 BlockWriterC.nc,
NONE, 1.1 VolumeId.nc, NONE, 1.1 VolumeIdC.nc, NONE, 1.1
- Next message: [Tinyos-2-commits]
CVS: tinyos-2.x/tos/lib/net/Deluge/FlashVolumeManager
FlashVolumeManagerC.nc, 1.5, 1.6 FlashVolumeManagerP.nc, 1.9,
1.10 FlashVolumeManager.h, 1.4, NONE
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the Tinyos-2-commits
mailing list