[Tinyos-beta-commits] CVS: tinyos-1.x/beta/Deluge/Deluge Deluge.h,
1.10, 1.11 DelugeC.nc, 1.5, 1.6 DelugeDataRead.nc, 1.5,
1.6 DelugeDataWrite.nc, 1.4, 1.5 DelugeM.nc, 1.25,
1.26 DelugeMetadata.nc, 1.8, 1.9 DelugeMetadataC.nc, 1.8,
1.9 DelugeMetadataM.nc, 1.21, 1.22 DelugeMsgs.h, 1.8,
1.9 DelugePageTransfer.nc, 1.4, 1.5 DelugePageTransferC.nc,
1.7, 1.8 DelugePageTransferM.nc, 1.11, 1.12 DelugeStorageC.nc,
1.10, 1.11 DelugeStorageM.nc, 1.10, 1.11 NetProg.h, 1.4,
1.5 NetProgC.nc, 1.5, 1.6 NetProgM.nc, 1.11,
1.12 SharedMsgBuf.nc, 1.2, 1.3 SharedMsgBufM.nc, 1.3, 1.4
Jonathan Hui
jwhui at users.sourceforge.net
Sun Jul 17 14:09:43 PDT 2005
- Previous message: [Tinyos-beta-commits] CVS: tinyos-1.x/beta/platform/tsb
MicDriverC.nc, 1.1, 1.2 MicDriverM.nc, 1.1, 1.2
- Next message: [Tinyos-beta-commits] CVS: tinyos-1.x/beta/Deluge/delugetools
Eraser.java, 1.9, 1.10 ImageInjector.java, 1.10,
1.11 Rebooter.java, 1.8, 1.9
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /cvsroot/tinyos/tinyos-1.x/beta/Deluge/Deluge
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23525
Modified Files:
Deluge.h DelugeC.nc DelugeDataRead.nc DelugeDataWrite.nc
DelugeM.nc DelugeMetadata.nc DelugeMetadataC.nc
DelugeMetadataM.nc DelugeMsgs.h DelugePageTransfer.nc
DelugePageTransferC.nc DelugePageTransferM.nc
DelugeStorageC.nc DelugeStorageM.nc NetProg.h NetProgC.nc
NetProgM.nc SharedMsgBuf.nc SharedMsgBufM.nc
Log Message:
- Call BlockWrite.commit() when image is done to fully support flash
chips with the new storage stack abstraction (e.g. at45db).
- Removed parameterization of interfaces to reduce code size.
- Updated reboot logic to help ensure that a node will eventually
reboot to an image even if the reboot command was received before the
image itself.
Index: Deluge.h
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/beta/Deluge/Deluge/Deluge.h,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -d -r1.10 -r1.11
*** Deluge.h 23 Jun 2005 19:30:20 -0000 1.10
--- Deluge.h 17 Jul 2005 21:09:28 -0000 1.11
***************
*** 84,89 ****
typedef struct DelugeNodeDesc {
imgvnum_t vNum;
imgnum_t imgNum;
! uint8_t dummy;
uint16_t crc;
} DelugeNodeDesc;
--- 84,90 ----
typedef struct DelugeNodeDesc {
imgvnum_t vNum;
+ uint32_t uid;
imgnum_t imgNum;
! uint8_t reserved;
uint16_t crc;
} DelugeNodeDesc;
Index: DelugeC.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/beta/Deluge/Deluge/DelugeC.nc,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** DelugeC.nc 17 May 2005 20:55:47 -0000 1.5
--- DelugeC.nc 17 Jul 2005 21:09:29 -0000 1.6
***************
*** 77,81 ****
DelugeM.Crc -> CrcC;
DelugeM.Leds -> Leds;
! DelugeM.Metadata -> Metadata.Metadata[unique("DelugeMetadata")];
DelugeM.NetProg -> NetProgC;
DelugeM.PageTransfer -> PageTransfer;
--- 77,81 ----
DelugeM.Crc -> CrcC;
DelugeM.Leds -> Leds;
! DelugeM.Metadata -> Metadata;
DelugeM.NetProg -> NetProgC;
DelugeM.PageTransfer -> PageTransfer;
***************
*** 83,87 ****
DelugeM.ReceiveAdvMsg -> Comm.ReceiveMsg[AM_DELUGEADVMSG];
DelugeM.SendAdvMsg-> Comm.SendMsg[AM_DELUGEADVMSG];
! DelugeM.SharedMsgBuf -> SharedMsgBufM.SharedMsgBuf[DELUGE_SHARED_MSG_BUF];
DelugeM.Timer -> TimerC.Timer[unique("Timer")];
--- 83,87 ----
DelugeM.ReceiveAdvMsg -> Comm.ReceiveMsg[AM_DELUGEADVMSG];
DelugeM.SendAdvMsg-> Comm.SendMsg[AM_DELUGEADVMSG];
! DelugeM.SharedMsgBuf -> SharedMsgBufM;
DelugeM.Timer -> TimerC.Timer[unique("Timer")];
***************
*** 91,95 ****
PageTransfer.SendDataMsg -> Comm.SendMsg[AM_DELUGEDATAMSG];
PageTransfer.SendReqMsg -> Comm.SendMsg[AM_DELUGEREQMSG];
! PageTransfer.SharedMsgBuf -> SharedMsgBufM.SharedMsgBuf[DELUGE_SHARED_MSG_BUF];
}
--- 91,95 ----
PageTransfer.SendDataMsg -> Comm.SendMsg[AM_DELUGEDATAMSG];
PageTransfer.SendReqMsg -> Comm.SendMsg[AM_DELUGEREQMSG];
! PageTransfer.SharedMsgBuf -> SharedMsgBufM;
}
Index: DelugeDataRead.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/beta/Deluge/Deluge/DelugeDataRead.nc,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** DelugeDataRead.nc 17 May 2005 20:55:47 -0000 1.5
--- DelugeDataRead.nc 17 Jul 2005 21:09:29 -0000 1.6
***************
*** 34,42 ****
interface DelugeDataRead {
! command result_t read(imgnum_t imgNum, block_addr_t addr, void* buf, block_addr_t len);
event void readDone(storage_result_t result);
! command result_t computeCrc(imgnum_t imgNum, block_addr_t addr, block_addr_t len);
! event void computeCrcDone(storage_result_t result, uint16_t crc);
}
--- 34,42 ----
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);
}
Index: DelugeDataWrite.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/beta/Deluge/Deluge/DelugeDataWrite.nc,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** DelugeDataWrite.nc 17 May 2005 20:55:47 -0000 1.4
--- DelugeDataWrite.nc 17 Jul 2005 21:09:36 -0000 1.5
***************
*** 31,35 ****
interface DelugeDataWrite {
! command result_t write(imgnum_t imgNum, block_addr_t addr, void* source, block_addr_t len);
event void writeDone(storage_result_t result);
--- 31,35 ----
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);
***************
*** 37,39 ****
--- 37,42 ----
event void eraseDone(storage_result_t result);
+ command result_t commit(imgnum_t imgNum);
+ event void commitDone(storage_result_t result);
+
}
Index: DelugeM.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/beta/Deluge/Deluge/DelugeM.nc,v
retrieving revision 1.25
retrieving revision 1.26
diff -C2 -d -r1.25 -r1.26
*** DelugeM.nc 12 Jul 2005 18:03:15 -0000 1.25
--- DelugeM.nc 17 Jul 2005 21:09:36 -0000 1.26
***************
*** 57,63 ****
enum {
- S_ENABLED,
- S_DISABLED,
S_INITIALIZING,
};
--- 57,63 ----
enum {
S_INITIALIZING,
+ S_STARTED,
+ S_STOPPED,
};
***************
*** 107,111 ****
void resetTimer(int i) {
! if (advTimers[i].periodLog2 != DELUGE_MIN_ADV_PERIOD_LOG2) {
advTimers[i].periodLog2 = DELUGE_MIN_ADV_PERIOD_LOG2;
setupAdvTimer(i);
--- 107,112 ----
void resetTimer(int i) {
! if ( i < DELUGE_NUM_IMAGES &&
! advTimers[i].periodLog2 != DELUGE_MIN_ADV_PERIOD_LOG2 ) {
advTimers[i].periodLog2 = DELUGE_MIN_ADV_PERIOD_LOG2;
setupAdvTimer(i);
***************
*** 136,180 ****
command result_t StdControl.init() {
! result_t result;
!
! state = S_DISABLED;
#ifndef PLATFORM_PC
call IFlash.read((uint16_t*)IFLASH_NODE_DESC_ADDR, &nodeDesc, sizeof(nodeDesc));
#endif
! result = call Leds.init();
! result = rcombine(call PageTransferControl.init(), result);
! result = rcombine(call MetadataControl.init(), result);
! return result;
}
! command result_t StdControl.start() {
! result_t result;
int i;
!
! result = call PageTransferControl.start();
!
! state = S_INITIALIZING;
! if (!call Metadata.started())
! call MetadataControl.start();
! else {
! state = S_ENABLED;
! setNextPage();
! }
!
for ( i = 0; i < DELUGE_NUM_TIMERS; i++ )
resetTimer(i);
!
! return result;
!
}
command result_t StdControl.stop() {
! if (state == S_ENABLED)
! state = S_DISABLED;
call Timer.stop();
! return call PageTransferControl.stop();
}
--- 137,171 ----
command result_t StdControl.init() {
! state = S_INITIALIZING;
#ifndef PLATFORM_PC
call IFlash.read((uint16_t*)IFLASH_NODE_DESC_ADDR, &nodeDesc, sizeof(nodeDesc));
#endif
! call Leds.init();
! call PageTransferControl.init();
! return SUCCESS;
}
! void realStart() {
! setNextPage();
! call PageTransferControl.start();
! }
! command result_t StdControl.start() {
int i;
! if ( state == S_STOPPED )
! realStart();
! state = S_STARTED;
for ( i = 0; i < DELUGE_NUM_TIMERS; i++ )
resetTimer(i);
! return SUCCESS;
}
command result_t StdControl.stop() {
! state = S_STOPPED;
call Timer.stop();
! call PageTransferControl.stop();
! return SUCCESS;
}
***************
*** 184,189 ****
event result_t MetadataControl.startDone() {
! state = S_ENABLED;
! setNextPage();
return SUCCESS;
}
--- 175,180 ----
event result_t MetadataControl.startDone() {
! if ( state == S_STARTED )
! realStart();
return SUCCESS;
}
***************
*** 199,206 ****
DelugeImgDesc *imgDesc = call Metadata.getImgDesc(imgNum);
if (!call SharedMsgBuf.isLocked()) {
pMsg->sourceAddr = TOS_LOCAL_ADDRESS;
pMsg->version = DELUGE_VERSION;
! pMsg->type = (state == S_ENABLED) ? DELUGE_ADV_NORMAL : DELUGE_ADV_ERROR;
memcpy(&pMsg->nodeDesc, &nodeDesc, sizeof(DelugeNodeDesc));
memcpy(&pMsg->imgDesc, imgDesc, sizeof(DelugeImgDesc));
--- 190,203 ----
DelugeImgDesc *imgDesc = call Metadata.getImgDesc(imgNum);
+ if ( nodeDesc.uid != DELUGE_IMAGE_UID
+ && nodeDesc.uid == imgDesc->uid
+ && call Metadata.isComplete(nodeDesc.imgNum)
+ && !rebootDelay )
+ rebootDelay = DELUGE_REBOOT_DELAY;
+
if (!call SharedMsgBuf.isLocked()) {
pMsg->sourceAddr = TOS_LOCAL_ADDRESS;
pMsg->version = DELUGE_VERSION;
! pMsg->type = (state == S_STARTED) ? DELUGE_ADV_NORMAL : DELUGE_ADV_ERROR;
memcpy(&pMsg->nodeDesc, &nodeDesc, sizeof(DelugeNodeDesc));
memcpy(&pMsg->imgDesc, imgDesc, sizeof(DelugeImgDesc));
***************
*** 230,237 ****
if (rebootDelay > 0) {
if (!(--rebootDelay)) {
- #ifndef PLATFORM_PC
- call IFlash.write((uint16_t*)IFLASH_NODE_DESC_ADDR, &nodeDesc, sizeof(nodeDesc));
- #endif
// will not return on SUCCESS
call NetProg.programImgAndReboot(nodeDesc.imgNum);
--- 227,232 ----
if (rebootDelay > 0) {
+ call Leds.yellowOn();
if (!(--rebootDelay)) {
// will not return on SUCCESS
call NetProg.programImgAndReboot(nodeDesc.imgNum);
***************
*** 253,258 ****
bool isNodeDescValid(DelugeNodeDesc* tmpNodeDesc) {
! return (tmpNodeDesc->crc == call Crc.crc16(tmpNodeDesc, 4)
! || tmpNodeDesc->vNum == DELUGE_INVALID_VNUM);
}
--- 248,253 ----
bool isNodeDescValid(DelugeNodeDesc* tmpNodeDesc) {
! return ( tmpNodeDesc->crc == call Crc.crc16(tmpNodeDesc, 8)
! || tmpNodeDesc->vNum == DELUGE_INVALID_VNUM );
}
***************
*** 266,270 ****
bool isEqual = FALSE;
! if ( rxAdvMsg->version != DELUGE_VERSION
|| !isNodeDescValid(&rxAdvMsg->nodeDesc) )
return pMsg;
--- 261,265 ----
bool isEqual = FALSE;
! if ( rxAdvMsg->version != DELUGE_VERSION
|| !isNodeDescValid(&rxAdvMsg->nodeDesc) )
return pMsg;
***************
*** 278,282 ****
&& cmpImgDesc->numPgsComplete == curImgDesc->numPgsComplete)) {
sendAdvMsg(imgNum, rxAdvMsg->sourceAddr);
! return pMsg;
}
else if ( rxAdvMsg->type == DELUGE_ADV_RESET ) {
--- 273,278 ----
&& cmpImgDesc->numPgsComplete == curImgDesc->numPgsComplete)) {
sendAdvMsg(imgNum, rxAdvMsg->sourceAddr);
! if ( rxAdvMsg->nodeDesc.vNum == nodeDesc.vNum )
! return pMsg;
}
else if ( rxAdvMsg->type == DELUGE_ADV_RESET ) {
***************
*** 285,293 ****
}
}
// don't do anything with the image descriptor if it is corrupt
// or if the images have not been mounted
if ( call Metadata.isImgDescValid(&(rxAdvMsg->imgDesc))
! && state == S_ENABLED ) {
// don't listen to advertisements about the golden image
--- 281,304 ----
}
}
+
+ if ( rxAdvMsg->nodeDesc.vNum != nodeDesc.vNum
+ && rxAdvMsg->nodeDesc.vNum != DELUGE_INVALID_VNUM ) {
+ resetTimer( rxAdvMsg->nodeDesc.imgNum );
+ if ( ( rxAdvMsg->nodeDesc.vNum - nodeDesc.vNum) > 0 ) {
+ memcpy(&nodeDesc, &rxAdvMsg->nodeDesc, sizeof(DelugeNodeDesc));
+ #ifndef PLATFORM_PC
+ call IFlash.write((uint8_t*)IFLASH_NODE_DESC_ADDR, &nodeDesc, sizeof(nodeDesc));
+ #endif
+ if ( nodeDesc.imgNum == DELUGE_GOLDEN_IMAGE_NUM )
+ rebootDelay = DELUGE_REBOOT_DELAY;
+ if (rxAdvMsg->type == DELUGE_ADV_PC)
+ sendAdvMsg(imgNum, rxAdvMsg->sourceAddr);
+ }
+ }
// don't do anything with the image descriptor if it is corrupt
// or if the images have not been mounted
if ( call Metadata.isImgDescValid(&(rxAdvMsg->imgDesc))
! && state == S_STARTED ) {
// don't listen to advertisements about the golden image
***************
*** 300,305 ****
if (curImgDesc->vNum == DELUGE_INVALID_VNUM
|| (cmpImgDesc->vNum != DELUGE_INVALID_VNUM
! && (cmpImgDesc->vNum - curImgDesc->vNum) > 0))
call Metadata.setupNewImage(&(rxAdvMsg->imgDesc));
}
// image is larger
--- 311,318 ----
if (curImgDesc->vNum == DELUGE_INVALID_VNUM
|| (cmpImgDesc->vNum != DELUGE_INVALID_VNUM
! && (cmpImgDesc->vNum - curImgDesc->vNum) > 0)) {
call Metadata.setupNewImage(&(rxAdvMsg->imgDesc));
+ call PageTransfer.setWorkingPage(DELUGE_INVALID_IMGNUM, DELUGE_INVALID_PGNUM);
+ }
}
// image is larger
***************
*** 320,342 ****
if ( !isEqual )
resetTimer(imgNum);
-
- }
- }
! if ((rxAdvMsg->nodeDesc.vNum - nodeDesc.vNum) > 0
! && rxAdvMsg->nodeDesc.vNum != DELUGE_INVALID_VNUM
! && call Metadata.isComplete(rxAdvMsg->nodeDesc.imgNum)) {
! call Leds.yellowOn();
! nodeDesc = rxAdvMsg->nodeDesc;
! rebootDelay = DELUGE_REBOOT_DELAY;
! resetTimer(imgNum);
! if (rxAdvMsg->sourceAddr == TOS_UART_ADDR
! || rxAdvMsg->type == DELUGE_ADV_PC)
! sendAdvMsg(imgNum, rxAdvMsg->sourceAddr);
}
!
! if ( rxAdvMsg->nodeDesc.vNum != nodeDesc.vNum )
! resetTimer(imgNum);
!
return pMsg;
--- 333,340 ----
if ( !isEqual )
resetTimer(imgNum);
! }
}
!
return pMsg;
Index: DelugeMetadata.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/beta/Deluge/Deluge/DelugeMetadata.nc,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** DelugeMetadata.nc 17 May 2005 20:55:47 -0000 1.8
--- DelugeMetadata.nc 17 Jul 2005 21:09:37 -0000 1.9
***************
*** 31,35 ****
interface DelugeMetadata {
- command bool started();
command bool isComplete(imgnum_t imgNum);
command bool isImgDescValid(DelugeImgDesc* tmpImgDesc);
--- 31,34 ----
Index: DelugeMetadataC.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/beta/Deluge/Deluge/DelugeMetadataC.nc,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** DelugeMetadataC.nc 21 Jun 2005 23:34:31 -0000 1.8
--- DelugeMetadataC.nc 17 Jul 2005 21:09:37 -0000 1.9
***************
*** 35,39 ****
provides {
interface DelugeStats;
! interface DelugeMetadata as Metadata[uint8_t id];
interface SplitControl;
}
--- 35,39 ----
provides {
interface DelugeStats;
! interface DelugeMetadata as Metadata;
interface SplitControl;
}
***************
*** 56,67 ****
Main.StdControl -> FlashWPC;
- Main.StdControl -> TimerC;
DelugeMetadataM.Crc -> CrcC;
! DelugeMetadataM.DataRead -> Storage.DataRead[unique("DelugeDataRead")];
! DelugeMetadataM.DataWrite -> Storage.DataWrite[unique("DelugeDataWrite")];
DelugeMetadataM.DelugeStorage -> Storage;
DelugeMetadataM.FlashWP -> FlashWPC;
DelugeMetadataM.Leds -> Leds;
DelugeMetadataM.Timer -> TimerC.Timer[unique("Timer")];
--- 56,67 ----
Main.StdControl -> FlashWPC;
DelugeMetadataM.Crc -> CrcC;
! DelugeMetadataM.DataRead -> Storage;
! DelugeMetadataM.DataWrite -> Storage;
DelugeMetadataM.DelugeStorage -> Storage;
DelugeMetadataM.FlashWP -> FlashWPC;
DelugeMetadataM.Leds -> Leds;
+ DelugeMetadataM.MetadataStore -> Storage;
DelugeMetadataM.Timer -> TimerC.Timer[unique("Timer")];
Index: DelugeMetadataM.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/beta/Deluge/Deluge/DelugeMetadataM.nc,v
retrieving revision 1.21
retrieving revision 1.22
diff -C2 -d -r1.21 -r1.22
*** DelugeMetadataM.nc 12 Jul 2005 18:16:09 -0000 1.21
--- DelugeMetadataM.nc 17 Jul 2005 21:09:37 -0000 1.22
***************
*** 32,40 ****
provides {
interface SplitControl;
! interface DelugeMetadata as Metadata[uint8_t id];
interface DelugeStats;
}
uses {
interface Crc;
interface DelugeDataRead as DataRead;
interface DelugeDataWrite as DataWrite;
--- 32,41 ----
provides {
interface SplitControl;
! interface DelugeMetadata as Metadata;
interface DelugeStats;
}
uses {
interface Crc;
+ interface DelugeMetadataStore as MetadataStore;
interface DelugeDataRead as DataRead;
interface DelugeDataWrite as DataWrite;
***************
*** 50,54 ****
DelugeImgDesc imgDesc[DELUGE_NUM_IMAGES];
- uint8_t client;
uint8_t curImage;
uint8_t state;
--- 51,54 ----
***************
*** 58,62 ****
S_INIT,
S_SCAN_METADATA,
- S_SCAN_DATA,
S_IDLE,
S_CLEAR_WP,
--- 58,61 ----
***************
*** 83,93 ****
}
! void signalDone(result_t result) {
! uint8_t tmpState = state;
state = S_IDLE;
! switch(tmpState) {
! case S_SCAN_METADATA: signal SplitControl.startDone(); break;
! default: signal Metadata.updateDone[client](SUCCESS); break;
! }
}
--- 82,88 ----
}
! void signalDone() {
state = S_IDLE;
! signal Metadata.updateDone(SUCCESS);
}
***************
*** 100,109 ****
result = call DelugeStorage.loadImages();
break;
- case S_SCAN_DATA:
- state = S_SCAN_METADATA;
- // no break
case S_SCAN_METADATA:
! result = call DataRead.read(curImage, 0, &imgDesc[curImage],
! sizeof(DelugeImgDesc));
break;
case S_CLEAR_WP:
--- 95,100 ----
result = call DelugeStorage.loadImages();
break;
case S_SCAN_METADATA:
! result = call MetadataStore.read(curImage, &imgDesc[curImage]);
break;
case S_CLEAR_WP:
***************
*** 122,125 ****
--- 113,119 ----
}
+ if ( result == FAIL )
+ call Timer.start(TIMER_ONE_SHOT, 512);
+
return result;
***************
*** 127,132 ****
event result_t Timer.fired() {
! if (execute() == FAIL)
! call Timer.start(TIMER_ONE_SHOT, 512);
return SUCCESS;
}
--- 121,125 ----
event result_t Timer.fired() {
! execute();
return SUCCESS;
}
***************
*** 138,142 ****
state = S_SCAN_METADATA;
}
! call Timer.start(TIMER_ONE_SHOT, 512);
}
--- 131,135 ----
state = S_SCAN_METADATA;
}
! execute();
}
***************
*** 145,209 ****
state = S_SCAN_METADATA;
curImage++;
! if (curImage < DELUGE_NUM_IMAGES)
! call Timer.start(TIMER_ONE_SHOT, 512);
else {
// all done, signal that metadata is ready
! signalDone(SUCCESS);
}
}
void verifyNextPage() {
!
! if (call DataRead.read(curImage,
! DELUGE_METADATA_SIZE + sizeof(crc)*imgDesc[curImage].numPgsComplete,
! &crc, sizeof(crc)) == FAIL)
call Timer.start(TIMER_ONE_SHOT, 512);
-
}
! event void DataRead.readDone(storage_result_t result) {
!
! block_addr_t addr, len;
! if (result != STORAGE_OK) {
call Timer.start(TIMER_ONE_SHOT, 512);
return;
}
! if (state == S_SCAN_METADATA) {
!
! // check if metadata is corrupt
! if ( !call Metadata.isImgDescValid[client](&imgDesc[curImage])
! || imgDesc[curImage].imgNum != curImage ) {
! imgDesc[curImage].vNum = DELUGE_INVALID_VNUM;
! imgDesc[curImage].imgNum = curImage;
! imgDesc[curImage].numPgs = 0;
! imgDesc[curImage].numPgsComplete = 0;
! imgDesc[curImage].crc = call Crc.crc16(&imgDesc[curImage], 8);
! scanNextImage();
! return;
! }
!
! state = S_SCAN_DATA;
! verifyNextPage();
!
}
- else {
- if (imgDesc[curImage].numPgsComplete == 0) {
- addr = DELUGE_CRC_BLOCK_SIZE;
- len = DELUGE_BYTES_PER_PAGE-DELUGE_CRC_BLOCK_SIZE;
- }
- else {
- addr = (block_addr_t)imgDesc[curImage].numPgsComplete*DELUGE_BYTES_PER_PAGE;
- len = DELUGE_BYTES_PER_PAGE;
- }
! if (call DataRead.computeCrc(curImage, addr + DELUGE_METADATA_SIZE, len) == FAIL)
! call Timer.start(TIMER_ONE_SHOT, 512);
! }
}
! event void DataRead.computeCrcDone(storage_result_t result, uint16_t crcResult) {
if (result != STORAGE_OK) {
--- 138,179 ----
state = S_SCAN_METADATA;
curImage++;
! if (curImage < DELUGE_NUM_IMAGES) {
! execute();
! }
else {
// all done, signal that metadata is ready
! state = S_IDLE;
! signal SplitControl.startDone();
}
}
void verifyNextPage() {
! if ( call DataRead.verify(curImage, imgDesc[curImage].numPgsComplete) == FAIL)
call Timer.start(TIMER_ONE_SHOT, 512);
}
! event void MetadataStore.readDone(storage_result_t result) {
! if ( result != STORAGE_OK ) {
call Timer.start(TIMER_ONE_SHOT, 512);
return;
}
! // check if metadata is corrupt
! if ( !call Metadata.isImgDescValid(&imgDesc[curImage])
! || imgDesc[curImage].imgNum != curImage ) {
! imgDesc[curImage].vNum = DELUGE_INVALID_VNUM;
! imgDesc[curImage].imgNum = curImage;
! imgDesc[curImage].numPgs = 0;
! imgDesc[curImage].numPgsComplete = 0;
! scanNextImage();
! return;
}
! verifyNextPage();
}
! event void DataRead.verifyDone(storage_result_t result, bool isValid) {
if (result != STORAGE_OK) {
***************
*** 213,219 ****
// SCAN state
! if (state == S_SCAN_DATA) {
! if (crc == crcResult) {
imgDesc[curImage].numPgsComplete++;
if (imgDesc[curImage].numPgsComplete < imgDesc[curImage].numPgs) {
--- 183,189 ----
// SCAN state
! if (state == S_SCAN_METADATA) {
! if ( isValid ) {
imgDesc[curImage].numPgsComplete++;
if (imgDesc[curImage].numPgsComplete < imgDesc[curImage].numPgs) {
***************
*** 224,228 ****
scanNextImage();
!
}
--- 194,198 ----
scanNextImage();
!
}
***************
*** 230,270 ****
else {
! if (crc != crcResult) {
imgDesc[curImage].numPgsComplete = 0;
! if (call DataWrite.erase(curImage) == FAIL)
! call Timer.start(TIMER_ONE_SHOT, 512);
return;
}
! imgDesc[curImage].numPgsComplete++;
!
! if (imgDesc[curImage].imgNum == DELUGE_GOLDEN_IMAGE_NUM
! && imgDesc[curImage].numPgs == imgDesc[curImage].numPgsComplete) {
! state = S_SET_WP;
! if (call FlashWP.setWP() == FAIL)
call Timer.start(TIMER_ONE_SHOT, 512);
}
! else {
! signalDone(SUCCESS);
! }
!
}
}
- command bool Metadata.started[uint8_t id]() {
- return (state >= S_IDLE);
}
! command bool Metadata.isImgDescValid[uint8_t id](DelugeImgDesc* tmpImgDesc) {
return ( tmpImgDesc->crc == call Crc.crc16(tmpImgDesc, 8)
&& tmpImgDesc->crc != 0 );
}
! command bool Metadata.isComplete[uint8_t id](imgnum_t imgNum) {
! return ( (imgDesc[imgNum].numPgs == imgDesc[imgNum].numPgsComplete
! && imgDesc[imgNum].numPgs != DELUGE_INVALID_PGNUM
! && imgDesc[imgNum].numPgs )
! || imgNum == DELUGE_GOLDEN_IMAGE_NUM );
}
--- 200,249 ----
else {
! if ( !isValid ) {
imgDesc[curImage].numPgsComplete = 0;
! state = S_SETUP;
! execute();
return;
}
! if ( imgDesc[curImage].numPgsComplete + 1 >= imgDesc[curImage].numPgs ) {
! if (call DataWrite.commit(curImage) == FAIL)
call Timer.start(TIMER_ONE_SHOT, 512);
+ return;
}
!
! imgDesc[curImage].numPgsComplete++;
! signalDone();
!
}
}
+
+ event void DataWrite.commitDone(storage_result_t result) {
+
+ if (result != STORAGE_OK) {
+ call Timer.start(TIMER_ONE_SHOT, 512);
+ return;
+ }
+
+ imgDesc[curImage].numPgsComplete = imgDesc[curImage].numPgs;
+ if (curImage == DELUGE_GOLDEN_IMAGE_NUM) {
+ state = S_SET_WP;
+ execute();
+ return;
+ }
+
+ signalDone();
}
! command bool Metadata.isImgDescValid(DelugeImgDesc* tmpImgDesc) {
return ( tmpImgDesc->crc == call Crc.crc16(tmpImgDesc, 8)
&& tmpImgDesc->crc != 0 );
}
! command bool Metadata.isComplete(imgnum_t imgNum) {
! return ( imgDesc[imgNum].numPgs == imgDesc[imgNum].numPgsComplete
! && imgDesc[imgNum].numPgs );
}
***************
*** 280,307 ****
return imgDesc[imgNum].numPgsComplete;
}
!
! command result_t Metadata.receivedPage[uint8_t id](imgnum_t imgNum, pgnum_t pgNum) {
! if (state != S_IDLE
! || imgDesc[imgNum].numPgsComplete >= imgDesc[imgNum].numPgs
! || imgDesc[imgNum].numPgsComplete != pgNum)
return FAIL;
state = S_VERIFY;
- client = id;
curImage = imgNum;
!
! verifyNextPage();
return SUCCESS;
!
}
!
! command result_t Metadata.setupNewImage[uint8_t id](DelugeImgDesc* newImgDesc) {
!
if (state != S_IDLE)
return FAIL;
!
! client = id;
curImage = newImgDesc->imgNum;
state = (curImage == DELUGE_GOLDEN_IMAGE_NUM) ? S_CLEAR_WP : S_SETUP;
--- 259,282 ----
return imgDesc[imgNum].numPgsComplete;
}
!
! command result_t Metadata.receivedPage(imgnum_t imgNum, pgnum_t pgNum) {
! if ( state != S_IDLE )
return FAIL;
state = S_VERIFY;
curImage = imgNum;
!
! execute();
return SUCCESS;
!
}
!
! command result_t Metadata.setupNewImage(DelugeImgDesc* newImgDesc) {
!
if (state != S_IDLE)
return FAIL;
!
curImage = newImgDesc->imgNum;
state = (curImage == DELUGE_GOLDEN_IMAGE_NUM) ? S_CLEAR_WP : S_SETUP;
***************
*** 309,320 ****
memcpy(&(imgDesc[curImage]), newImgDesc, sizeof(DelugeImgDesc));
imgDesc[curImage].numPgsComplete = 0;
!
! call Timer.start(TIMER_ONE_SHOT, 1);
!
return SUCCESS;
!
}
! command DelugeImgDesc* Metadata.getImgDesc[uint8_t id](uint8_t imgNum) {
return &imgDesc[imgNum];
}
--- 284,295 ----
memcpy(&(imgDesc[curImage]), newImgDesc, sizeof(DelugeImgDesc));
imgDesc[curImage].numPgsComplete = 0;
!
! execute();
!
return SUCCESS;
!
}
! command DelugeImgDesc* Metadata.getImgDesc(uint8_t imgNum) {
return &imgDesc[imgNum];
}
***************
*** 322,351 ****
event void FlashWP.clrWPDone() {
state = S_SETUP;
! call Timer.start(TIMER_ONE_SHOT, 1);
}
event void FlashWP.setWPDone() {
! state = S_VERIFY;
! signalDone(SUCCESS);
}
event void DataWrite.eraseDone(storage_result_t result) {
! if (result != STORAGE_OK) {
! call Timer.start(TIMER_ONE_SHOT, 512);
! return;
! }
!
! if (call DataWrite.write(curImage, 0, &imgDesc[curImage],
! sizeof(DelugeImgDesc)) == FAIL)
call Timer.start(TIMER_ONE_SHOT, 512);
}
! event void DataWrite.writeDone(storage_result_t result) {
! signalDone(result);
}
! default event void Metadata.updateDone[uint8_t id](result_t result) {}
}
--- 297,322 ----
event void FlashWP.clrWPDone() {
state = S_SETUP;
! execute();
}
event void FlashWP.setWPDone() {
! signalDone();
}
event void DataWrite.eraseDone(storage_result_t result) {
! if ( result != STORAGE_OK
! || call MetadataStore.write(curImage, &imgDesc[curImage]) == FAIL )
call Timer.start(TIMER_ONE_SHOT, 512);
}
! event void MetadataStore.writeDone(storage_result_t result) {
! signalDone();
}
! event void DataRead.readDone(storage_result_t result) {}
! event void DataWrite.writeDone(storage_result_t result) {}
! default event void Metadata.updateDone(result_t result) {}
}
Index: DelugeMsgs.h
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/beta/Deluge/Deluge/DelugeMsgs.h,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** DelugeMsgs.h 12 Jul 2005 18:03:16 -0000 1.8
--- DelugeMsgs.h 17 Jul 2005 21:09:37 -0000 1.9
***************
*** 57,61 ****
uint8_t version; // 1
uint8_t type; // 1
! DelugeNodeDesc nodeDesc; // 6
DelugeImgDesc imgDesc; // 12
uint8_t numImages; // 1
--- 57,61 ----
uint8_t version; // 1
uint8_t type; // 1
! DelugeNodeDesc nodeDesc; // 10
DelugeImgDesc imgDesc; // 12
uint8_t numImages; // 1
Index: DelugePageTransfer.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/beta/Deluge/Deluge/DelugePageTransfer.nc,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** DelugePageTransfer.nc 17 May 2005 20:55:48 -0000 1.4
--- DelugePageTransfer.nc 17 Jul 2005 21:09:37 -0000 1.5
***************
*** 31,36 ****
interface DelugePageTransfer {
command result_t setWorkingPage(imgnum_t imgNum, pgnum_t pgNum);
- command imgnum_t getWorkingImage();
- command pgnum_t getWorkingPage();
command bool isTransferring();
command result_t dataAvailable(uint16_t sourceAddr, imgnum_t imgNum);
--- 31,34 ----
Index: DelugePageTransferC.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/beta/Deluge/Deluge/DelugePageTransferC.nc,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** DelugePageTransferC.nc 17 May 2005 20:55:48 -0000 1.7
--- DelugePageTransferC.nc 17 Jul 2005 21:09:37 -0000 1.8
***************
*** 47,51 ****
components
- Main,
DelugePageTransferM,
BitVecUtilsC,
--- 47,50 ----
***************
*** 61,68 ****
DelugePageTransferM.BitVecUtils -> BitVecUtilsC;
! DelugePageTransferM.DataRead -> Storage.DataRead[unique("DelugeDataRead")];
! DelugePageTransferM.DataWrite -> Storage.DataWrite[unique("DelugeDataWrite")];
DelugePageTransferM.DelugeStats -> Metadata;
- DelugePageTransferM.Metadata -> Metadata.Metadata[unique("DelugeMetadata")];
DelugePageTransferM.Random -> RandomLFSR;
DelugePageTransferM.ReceiveDataMsg = ReceiveDataMsg;
--- 60,66 ----
DelugePageTransferM.BitVecUtils -> BitVecUtilsC;
! DelugePageTransferM.DataRead -> Storage;
! DelugePageTransferM.DataWrite -> Storage;
DelugePageTransferM.DelugeStats -> Metadata;
DelugePageTransferM.Random -> RandomLFSR;
DelugePageTransferM.ReceiveDataMsg = ReceiveDataMsg;
Index: DelugePageTransferM.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/beta/Deluge/Deluge/DelugePageTransferM.nc,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -d -r1.11 -r1.12
*** DelugePageTransferM.nc 17 May 2005 20:55:48 -0000 1.11
--- DelugePageTransferM.nc 17 Jul 2005 21:09:37 -0000 1.12
***************
*** 1,8 ****
// $Id$
! /* tab:4
*
*
! * "Copyright (c) 2000-2004 The Regents of the University of California.
* All rights reserved.
*
--- 1,8 ----
// $Id$
! /* tab:2
*
*
! * "Copyright (c) 2000-2005 The Regents of the University of California.
* All rights reserved.
*
***************
*** 36,40 ****
uses {
interface BitVecUtils;
- interface DelugeMetadata as Metadata;
interface DelugeDataRead as DataRead;
interface DelugeDataWrite as DataWrite;
--- 36,39 ----
***************
*** 53,89 ****
implementation {
- struct {
- union {
- struct {
- uint16_t source;
- uint8_t remainingAttempts;
- bool suppressReq;
- } rx;
- struct {
- uint16_t dest;
- uint8_t imgToSend;
- uint8_t pageToSend;
- } tx;
- };
- } vars;
-
// send/receive page buffers, and state variables for buffers
uint8_t pktsToSend[DELUGE_PKT_BITVEC_SIZE]; // bit vec of packets to send
uint8_t pktsToReceive[DELUGE_PKT_BITVEC_SIZE]; // bit vec of packets to receive
! struct {
! uint8_t pktNum;
! uint8_t data[DELUGE_PKT_PAYLOAD_SIZE];
! } dataBuf;
! bool isWriting;
!
! TOS_MsgPtr pMsgBuf;
! DelugeReqMsg *pReqMsg;
! DelugeDataMsg *pDataMsg;
// state variables
! uint8_t state;
! imgnum_t workingImgNum;
! pgnum_t workingPgNum;
enum {
--- 52,71 ----
implementation {
// send/receive page buffers, and state variables for buffers
uint8_t pktsToSend[DELUGE_PKT_BITVEC_SIZE]; // bit vec of packets to send
uint8_t pktsToReceive[DELUGE_PKT_BITVEC_SIZE]; // bit vec of packets to receive
! DelugeDataMsg rxQueue[DELUGE_QSIZE];
! uint8_t head, size;
// state variables
! uint8_t state;
! imgnum_t workingImgNum;
! pgnum_t workingPgNum;
! uint16_t nodeAddr;
! uint8_t remainingAttempts;
! bool suppressReq;
! uint8_t imgToSend;
! uint8_t pageToSend;
enum {
***************
*** 103,107 ****
state = newState;
!
}
--- 85,89 ----
state = newState;
!
}
***************
*** 110,114 ****
workingImgNum = DELUGE_INVALID_IMGNUM;
workingPgNum = DELUGE_INVALID_PGNUM;
- isWriting = FALSE;
return SUCCESS;
}
--- 92,95 ----
***************
*** 116,122 ****
command result_t StdControl.start() {
changeState(S_IDLE);
- pMsgBuf = call SharedMsgBuf.getMsgBuf();
- pReqMsg = (DelugeReqMsg*)(pMsgBuf->data);
- pDataMsg = (DelugeDataMsg*)(pMsgBuf->data);
return SUCCESS;
}
--- 97,100 ----
***************
*** 134,145 ****
}
- command imgnum_t PageTransfer.getWorkingImage() {
- return workingImgNum;
- }
-
- command pgnum_t PageTransfer.getWorkingPage() {
- return workingPgNum;
- }
-
command bool PageTransfer.isTransferring() {
return (state != S_IDLE && state != S_DISABLED);
--- 112,115 ----
***************
*** 157,166 ****
command result_t PageTransfer.dataAvailable(uint16_t sourceAddr, imgnum_t imgNum) {
! if (state == S_IDLE && workingImgNum == imgNum) {
// currently idle, so request data from source
changeState(S_RX_LOCKING);
! vars.rx.source = sourceAddr;
! vars.rx.remainingAttempts = DELUGE_MAX_NUM_REQ_TRIES;
! vars.rx.suppressReq = FALSE;
// randomize request to prevent collision
--- 127,136 ----
command result_t PageTransfer.dataAvailable(uint16_t sourceAddr, imgnum_t imgNum) {
! if ( state == S_IDLE && workingImgNum == imgNum ) {
// currently idle, so request data from source
changeState(S_RX_LOCKING);
! nodeAddr = sourceAddr;
! remainingAttempts = DELUGE_MAX_NUM_REQ_TRIES;
! suppressReq = FALSE;
// randomize request to prevent collision
***************
*** 174,178 ****
block_addr_t calcOffset(pgnum_t pgNum, uint8_t pktNum) {
return (block_addr_t)pgNum*(block_addr_t)DELUGE_BYTES_PER_PAGE
! + (block_addr_t)pktNum*(block_addr_t)DELUGE_PKT_PAYLOAD_SIZE
+ DELUGE_METADATA_SIZE;
}
--- 144,148 ----
block_addr_t calcOffset(pgnum_t pgNum, uint8_t pktNum) {
return (block_addr_t)pgNum*(block_addr_t)DELUGE_BYTES_PER_PAGE
! + (uint16_t)pktNum*(uint16_t)DELUGE_PKT_PAYLOAD_SIZE
+ DELUGE_METADATA_SIZE;
}
***************
*** 180,189 ****
void setupReqMsg() {
if ( state == S_RX_LOCKING ) {
! if ( call SharedMsgBuf.lock() == FAIL )
return;
changeState(S_RECEIVING);
! pReqMsg->dest = (vars.rx.source != TOS_UART_ADDR) ?
! vars.rx.source : TOS_UART_ADDR;
pReqMsg->sourceAddr = TOS_LOCAL_ADDRESS;
pReqMsg->imgNum = workingImgNum;
--- 150,162 ----
void setupReqMsg() {
+ TOS_MsgPtr pMsgBuf = call SharedMsgBuf.getMsgBuf();
+ DelugeReqMsg* pReqMsg = (DelugeReqMsg*)(pMsgBuf->data);
+
if ( state == S_RX_LOCKING ) {
! if ( call SharedMsgBuf.isLocked() )
return;
+ call SharedMsgBuf.lock();
changeState(S_RECEIVING);
! pReqMsg->dest = (nodeAddr != TOS_UART_ADDR) ? nodeAddr : TOS_UART_ADDR;
pReqMsg->sourceAddr = TOS_LOCAL_ADDRESS;
pReqMsg->imgNum = workingImgNum;
***************
*** 194,206 ****
if (state != S_RECEIVING)
return;
!
// suppress request
! if ( vars.rx.suppressReq ) {
startReqTimer(FALSE);
! vars.rx.suppressReq = FALSE;
}
// tried too many times, give up
! else if (vars.rx.remainingAttempts == 0) {
changeState(S_IDLE);
}
--- 167,179 ----
if (state != S_RECEIVING)
return;
!
// suppress request
! if ( suppressReq ) {
startReqTimer(FALSE);
! suppressReq = FALSE;
}
// tried too many times, give up
! else if ( remainingAttempts == 0 ) {
changeState(S_IDLE);
}
***************
*** 215,229 ****
}
! task void writeDataTask() {
! if (call DataWrite.write(workingImgNum, calcOffset(workingPgNum, dataBuf.pktNum),
! dataBuf.data, DELUGE_PKT_PAYLOAD_SIZE) == FAIL)
! isWriting = FALSE;
}
void suppressMsgs(imgnum_t imgNum, pgnum_t pgNum) {
if (state == S_SENDING || state == S_TX_LOCKING) {
! if (imgNum < vars.tx.imgToSend
! || (imgNum == vars.tx.imgToSend
! && pgNum < vars.tx.pageToSend)) {
changeState(S_IDLE);
memset(pktsToSend, 0x0, DELUGE_PKT_BITVEC_SIZE);
--- 188,202 ----
}
! void writeData() {
! if( call DataWrite.write(workingImgNum, calcOffset(rxQueue[head].pgNum, rxQueue[head].pktNum),
! rxQueue[head].data, DELUGE_PKT_PAYLOAD_SIZE) == FAIL )
! size = 0;
}
void suppressMsgs(imgnum_t imgNum, pgnum_t pgNum) {
if (state == S_SENDING || state == S_TX_LOCKING) {
! if (imgNum < imgToSend
! || (imgNum == imgToSend
! && pgNum < pageToSend)) {
changeState(S_IDLE);
memset(pktsToSend, 0x0, DELUGE_PKT_BITVEC_SIZE);
***************
*** 235,239 ****
&& pgNum <= workingPgNum)) {
// suppress next request since similar request has been overheard
! vars.rx.suppressReq = TRUE;
}
}
--- 208,212 ----
&& pgNum <= workingPgNum)) {
// suppress next request since similar request has been overheard
! suppressReq = TRUE;
}
}
***************
*** 252,272 ****
// check if need to suppress req or data messages
suppressMsgs(rxDataMsg->imgNum, rxDataMsg->pgNum);
!
! if (rxDataMsg->vNum == call DelugeStats.getVNum(workingImgNum)
! && rxDataMsg->imgNum == workingImgNum
! && rxDataMsg->pgNum == workingPgNum
! && BITVEC_GET(pktsToReceive, rxDataMsg->pktNum)
! && !isWriting) {
// got a packet we need
call Leds.set(rxDataMsg->pktNum);
dbg(DBG_USR1, "DELUGE: SAVING(pgNum=%d,pktNum=%d)\n",
! rxDataMsg->pgNum,rxDataMsg->pktNum);
// copy data
! dataBuf.pktNum = rxDataMsg->pktNum;
! memcpy(dataBuf.data, rxDataMsg->data, DELUGE_PKT_PAYLOAD_SIZE);
! if (post writeDataTask())
! isWriting = TRUE;
}
--- 225,244 ----
// check if need to suppress req or data messages
suppressMsgs(rxDataMsg->imgNum, rxDataMsg->pgNum);
!
! if ( rxDataMsg->vNum == call DelugeStats.getVNum(rxDataMsg->imgNum)
! && rxDataMsg->imgNum == workingImgNum
! && rxDataMsg->pgNum == workingPgNum
! && BITVEC_GET(pktsToReceive, rxDataMsg->pktNum)
! && size < DELUGE_QSIZE ) {
// got a packet we need
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));
! if ( ++size == 1 )
! writeData();
}
***************
*** 277,294 ****
void setupDataMsg() {
uint16_t nextPkt;
if (state != S_SENDING && state != S_TX_LOCKING)
return;
!
! signal PageTransfer.suppressMsgs(vars.tx.imgToSend);
if ( state == S_TX_LOCKING ) {
! if ( call SharedMsgBuf.lock() == FAIL )
return;
changeState(S_SENDING);
! pDataMsg->vNum = call DelugeStats.getVNum(vars.tx.imgToSend);
! pDataMsg->imgNum = vars.tx.imgToSend;
! pDataMsg->pgNum = vars.tx.pageToSend;
pDataMsg->pktNum = 0;
}
--- 249,270 ----
void setupDataMsg() {
+ TOS_MsgPtr pMsgBuf = call SharedMsgBuf.getMsgBuf();
+ DelugeDataMsg* pDataMsg = (DelugeDataMsg*)(pMsgBuf->data);
+
uint16_t nextPkt;
if (state != S_SENDING && state != S_TX_LOCKING)
return;
!
! signal PageTransfer.suppressMsgs(imgToSend);
if ( state == S_TX_LOCKING ) {
! if ( call SharedMsgBuf.isLocked() )
return;
+ call SharedMsgBuf.lock();
changeState(S_SENDING);
! pDataMsg->vNum = call DelugeStats.getVNum(imgToSend);
! pDataMsg->imgNum = imgToSend;
! pDataMsg->pgNum = pageToSend;
pDataMsg->pktNum = 0;
}
***************
*** 302,306 ****
else {
pDataMsg->pktNum = nextPkt;
! if (call DataRead.read(vars.tx.imgToSend, calcOffset(pDataMsg->pgNum, pDataMsg->pktNum),
pDataMsg->data, DELUGE_PKT_PAYLOAD_SIZE) == FAIL)
call Timer.start(TIMER_ONE_SHOT, DELUGE_FAILED_SEND_DELAY);
--- 278,282 ----
else {
pDataMsg->pktNum = nextPkt;
! if (call DataRead.read(imgToSend, calcOffset(pageToSend, nextPkt),
pDataMsg->data, DELUGE_PKT_PAYLOAD_SIZE) == FAIL)
call Timer.start(TIMER_ONE_SHOT, DELUGE_FAILED_SEND_DELAY);
***************
*** 310,321 ****
event result_t Timer.fired() {
! switch(state) {
! case S_RX_LOCKING: case S_RECEIVING:
! setupReqMsg();
! break;
! case S_TX_LOCKING: case S_SENDING:
! setupDataMsg();
! break;
! }
return SUCCESS;
}
--- 286,291 ----
event result_t Timer.fired() {
! setupReqMsg();
! setupDataMsg();
return SUCCESS;
}
***************
*** 324,327 ****
--- 294,299 ----
DelugeReqMsg *rxReqMsg = (DelugeReqMsg*)(pMsg->data);
+ imgnum_t imgNum;
+ pgnum_t pgNum;
int i;
***************
*** 331,350 ****
if (state == S_DISABLED)
return pMsg;
// check if need to suppress req or data msgs
! suppressMsgs(rxReqMsg->imgNum, rxReqMsg->pgNum);
! if (rxReqMsg->pgNum >= call DelugeStats.getNumPgsComplete(rxReqMsg->imgNum)
! || rxReqMsg->vNum != call DelugeStats.getVNum(rxReqMsg->imgNum)
! || rxReqMsg->dest != TOS_LOCAL_ADDRESS) {
! // don't have this page, ignore request
return pMsg;
- }
! if (state == S_IDLE
! || ((state == S_SENDING || state == S_TX_LOCKING)
! && rxReqMsg->imgNum == vars.tx.imgToSend
! && rxReqMsg->vNum == call DelugeStats.getVNum(vars.tx.imgToSend)
! && rxReqMsg->pgNum == vars.tx.pageToSend)) {
// take union of packet bit vectors
for ( i = 0; i < DELUGE_PKT_BITVEC_SIZE; i++ )
--- 303,323 ----
if (state == S_DISABLED)
return pMsg;
+
+ imgNum = rxReqMsg->imgNum;
+ pgNum = rxReqMsg->pgNum;
// check if need to suppress req or data msgs
! suppressMsgs(imgNum, pgNum);
! // if not for me, ignore request
! if ( rxReqMsg->dest != TOS_LOCAL_ADDRESS
! || rxReqMsg->vNum != call DelugeStats.getVNum(imgNum)
! || pgNum >= call DelugeStats.getNumPgsComplete(imgNum) )
return pMsg;
! if ( state == S_IDLE
! || ( (state == S_SENDING || state == S_TX_LOCKING)
! && imgNum == imgToSend
! && pgNum == pageToSend ) ) {
// take union of packet bit vectors
for ( i = 0; i < DELUGE_PKT_BITVEC_SIZE; i++ )
***************
*** 352,361 ****
}
! if (state == S_IDLE) {
// not currently sending, so start sending data
changeState(S_TX_LOCKING);
! vars.tx.imgToSend = rxReqMsg->imgNum;
! vars.tx.pageToSend = rxReqMsg->pgNum;
! vars.tx.dest = (rxReqMsg->sourceAddr != TOS_UART_ADDR) ? TOS_BCAST_ADDR : TOS_UART_ADDR;
setupDataMsg();
}
--- 325,334 ----
}
! if ( state == S_IDLE ) {
// not currently sending, so start sending data
changeState(S_TX_LOCKING);
! imgToSend = imgNum;
! pageToSend = pgNum;
! nodeAddr = (rxReqMsg->sourceAddr != TOS_UART_ADDR) ? TOS_BCAST_ADDR : TOS_UART_ADDR;
setupDataMsg();
}
***************
*** 367,370 ****
--- 340,345 ----
event void DataRead.readDone(storage_result_t result) {
+ TOS_MsgPtr pMsgBuf = call SharedMsgBuf.getMsgBuf();
+
if (state != S_SENDING)
return;
***************
*** 375,379 ****
}
! if (call SendDataMsg.send(vars.tx.dest, sizeof(DelugeDataMsg), pMsgBuf) == FAIL)
call Timer.start(TIMER_ONE_SHOT, DELUGE_FAILED_SEND_DELAY);
--- 350,354 ----
}
! if (call SendDataMsg.send(nodeAddr, sizeof(DelugeDataMsg), pMsgBuf) == FAIL)
call Timer.start(TIMER_ONE_SHOT, DELUGE_FAILED_SEND_DELAY);
***************
*** 384,395 ****
uint16_t tmp;
- isWriting = FALSE;
-
// mark packet as received
! BITVEC_CLEAR(pktsToReceive, dataBuf.pktNum);
!
if (!call BitVecUtils.indexOf(&tmp, 0, pktsToReceive, DELUGE_PKTS_PER_PAGE)) {
signal PageTransfer.receivedPage(workingImgNum, workingPgNum);
changeState(S_IDLE);
}
--- 359,374 ----
uint16_t tmp;
// mark packet as received
! BITVEC_CLEAR(pktsToReceive, rxQueue[head].pktNum);
! head = (head+1)%DELUGE_QSIZE;
! size--;
!
if (!call BitVecUtils.indexOf(&tmp, 0, pktsToReceive, DELUGE_PKTS_PER_PAGE)) {
signal PageTransfer.receivedPage(workingImgNum, workingPgNum);
changeState(S_IDLE);
+ size = 0;
+ }
+ else if ( size ) {
+ writeData();
}
***************
*** 401,405 ****
return SUCCESS;
! vars.rx.remainingAttempts--;
// start timeout timer in case request is not serviced
--- 380,384 ----
return SUCCESS;
! remainingAttempts--;
// start timeout timer in case request is not serviced
***************
*** 410,413 ****
--- 389,394 ----
event result_t SendDataMsg.sendDone(TOS_MsgPtr pMsg, result_t success) {
+ TOS_MsgPtr pMsgBuf = call SharedMsgBuf.getMsgBuf();
+ DelugeDataMsg* pDataMsg = (DelugeDataMsg*)(pMsgBuf->data);
BITVEC_CLEAR(pktsToSend, pDataMsg->pktNum);
call Timer.start(TIMER_ONE_SHOT, 2);
***************
*** 422,428 ****
}
! event void DataRead.computeCrcDone(storage_result_t result, uint16_t crcResult) {}
event void DataWrite.eraseDone(storage_result_t result) {}
! event void Metadata.updateDone(result_t result) {}
}
--- 403,409 ----
}
! event void DataRead.verifyDone(storage_result_t result, bool isValid) {}
event void DataWrite.eraseDone(storage_result_t result) {}
! event void DataWrite.commitDone(storage_result_t result) {}
}
Index: DelugeStorageC.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/beta/Deluge/Deluge/DelugeStorageC.nc,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -d -r1.10 -r1.11
*** DelugeStorageC.nc 23 Jun 2005 19:30:20 -0000 1.10
--- DelugeStorageC.nc 17 Jul 2005 21:09:37 -0000 1.11
***************
*** 31,36 ****
configuration DelugeStorageC {
provides {
! interface DelugeDataRead as DataRead[uint8_t id];
! interface DelugeDataWrite as DataWrite[uint8_t id];
interface DelugeStorage;
}
--- 31,37 ----
configuration DelugeStorageC {
provides {
! interface DelugeDataRead as DataRead;
! interface DelugeDataWrite as DataWrite;
! interface DelugeMetadataStore as MetadataStore;
interface DelugeStorage;
}
***************
*** 39,43 ****
components
- Main,
DelugeStorageM as Storage,
BlockStorageC,
--- 40,43 ----
***************
*** 47,52 ****
DataWrite = Storage;
DelugeStorage = Storage;
!
! Main.StdControl -> Storage;
Storage.Leds -> Leds;
--- 47,51 ----
DataWrite = Storage;
DelugeStorage = Storage;
! MetadataStore = Storage;
Storage.Leds -> Leds;
Index: DelugeStorageM.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/beta/Deluge/Deluge/DelugeStorageM.nc,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -d -r1.10 -r1.11
*** DelugeStorageM.nc 29 Jun 2005 21:08:15 -0000 1.10
--- DelugeStorageM.nc 17 Jul 2005 21:09:37 -0000 1.11
***************
*** 1,8 ****
// $Id$
! /* tab:4
*
*
! * "Copyright (c) 2000-2004 The Regents of the University of California.
* All rights reserved.
*
--- 1,8 ----
// $Id$
! /* tab:2
*
*
! * "Copyright (c) 2000-2005 The Regents of the University of California.
* All rights reserved.
*
***************
*** 31,38 ****
module DelugeStorageM {
provides {
! interface DelugeDataRead as DataRead[uint8_t id];
! interface DelugeDataWrite as DataWrite[uint8_t id];
interface DelugeStorage;
- interface StdControl;
}
uses {
--- 31,38 ----
module DelugeStorageM {
provides {
! interface DelugeMetadataStore as MetadataStore;
! interface DelugeDataRead as DataRead;
! interface DelugeDataWrite as DataWrite;
interface DelugeStorage;
}
uses {
***************
*** 51,71 ****
S_MOUNTING,
S_IDLE,
S_READ,
S_WRITE,
S_ERASE,
! S_COMPUTE_CRC,
};
! uint8_t state;
uint8_t client;
! void signalDone(result_t result, uint16_t crc) {
uint8_t tmpState = state;
state = S_IDLE;
switch(tmpState) {
! case S_READ: signal DataRead.readDone[client](result); break;
! case S_WRITE: signal DataWrite.writeDone[client](result); break;
! case S_ERASE: signal DataWrite.eraseDone[client](result); break;
! case S_COMPUTE_CRC: signal DataRead.computeCrcDone[client](result, crc); break;
case S_MOUNTING:
if (result == FAIL)
--- 51,79 ----
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)
***************
*** 76,92 ****
}
- command result_t StdControl.init() {
- state = S_NEVER_USED;
- return SUCCESS;
- }
-
- command result_t StdControl.start() {
- return SUCCESS;
- }
-
- command result_t StdControl.stop() {
- return SUCCESS;
- }
-
command result_t DelugeStorage.loadImages() {
--- 84,87 ----
***************
*** 110,114 ****
if (result != STORAGE_OK) {
! signalDone(FAIL, 0);
return;
}
--- 105,109 ----
if (result != STORAGE_OK) {
! signalDone(FAIL);
return;
}
***************
*** 117,126 ****
if ( ++client < DELUGE_NUM_IMAGES ) {
if (call Mount.mount[DELUGE_IMAGES[client].imageNum](DELUGE_IMAGES[client].volumeId) == FAIL)
! signalDone(FAIL, 0);
return;
}
// mounted all images
! signalDone(SUCCESS, 0);
}
--- 112,121 ----
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);
}
***************
*** 132,137 ****
}
! result_t newRequest(uint8_t newState, uint8_t id, imgnum_t imgNum,
! block_addr_t addr, void* buf, block_addr_t len) {
result_t result = FAIL;
--- 127,132 ----
}
! result_t newRequest(uint8_t newState, imgnum_t imgNum,
! block_addr_t addr, void* buf, uint16_t len) {
result_t result = FAIL;
***************
*** 141,151 ****
return FAIL;
- client = id;
-
switch(newState) {
! case S_READ:
result = call BlockRead.read[image](addr, buf, len);
break;
! case S_WRITE:
result = call BlockWrite.write[image](addr, buf, len);
break;
--- 136,150 ----
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;
***************
*** 153,158 ****
result = call BlockWrite.erase[image]();
break;
! case S_COMPUTE_CRC:
! result = call BlockRead.computeCrc[image](addr, len);
break;
}
--- 152,157 ----
result = call BlockWrite.erase[image]();
break;
! case S_COMMIT:
! result = call BlockWrite.commit[image]();
break;
}
***************
*** 165,203 ****
}
! command result_t DataRead.read[uint8_t id](imgnum_t imgNum, block_addr_t addr,
! void* buf, block_addr_t length) {
! return newRequest(S_READ, id, imgNum, addr, buf, length);
}
! command result_t DataRead.computeCrc[uint8_t id](imgnum_t imgNum, block_addr_t addr, block_addr_t length) {
! return newRequest(S_COMPUTE_CRC, id, imgNum, addr, NULL, length);
}
! command result_t DataWrite.write[uint8_t id](imgnum_t imgNum, block_addr_t addr,
! void* buf, block_addr_t length) {
! return newRequest(S_WRITE, id, imgNum, addr, buf, length);
}
! command result_t DataWrite.erase[uint8_t id](imgnum_t imgNum) {
! return newRequest(S_ERASE, id, 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) {
! signalDone(result, 0);
}
event void BlockRead.computeCrcDone[uint8_t volume](storage_result_t result, uint16_t crc, block_addr_t addr, block_addr_t len) {
! signalDone(result, crc);
}
event void BlockWrite.writeDone[uint8_t volume](storage_result_t result, block_addr_t addr, void* buf, block_addr_t len) {
! signalDone(result, 0);
}
event void BlockWrite.eraseDone[uint8_t volume](storage_result_t result) {
! signalDone(result, 0);
}
! event void BlockWrite.commitDone[uint8_t volume](storage_result_t result) {}
event void BlockRead.verifyDone[uint8_t volume](storage_result_t result) {}
--- 164,234 ----
}
! 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) {}
***************
*** 211,218 ****
default command uint32_t StorageRemap.physicalAddr[blockstorage_t blockId](uint32_t id) { return STORAGE_INVALID_ADDR; }
- default event void DataRead.readDone[uint8_t id](storage_result_t result) {}
- default event void DataRead.computeCrcDone[uint8_t id](storage_result_t result, uint16_t crcResult) {}
- default event void DataWrite.writeDone[uint8_t id](storage_result_t result) {}
- default event void DataWrite.eraseDone[uint8_t id](storage_result_t result) {}
-
}
--- 242,244 ----
Index: NetProg.h
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/beta/Deluge/Deluge/NetProg.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** NetProg.h 3 Jul 2005 06:55:17 -0000 1.4
--- NetProg.h 17 Jul 2005 21:09:37 -0000 1.5
***************
*** 34,40 ****
#define __NETPROG_H__
enum {
IFLASH_TOS_INFO_ADDR = 0x60, // 6 bytes
! IFLASH_NODE_DESC_ADDR = 0x66, // 6 bytes
};
--- 34,46 ----
#define __NETPROG_H__
+ #ifndef IDENT_UID_HASH
+ #define IDENT_UID_HASH 0
+ #endif
+
+ static const uint32_t DELUGE_IMAGE_UID = IDENT_UID_HASH;
+
enum {
IFLASH_TOS_INFO_ADDR = 0x60, // 6 bytes
! IFLASH_NODE_DESC_ADDR = 0x66, // 10 bytes
};
Index: NetProgC.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/beta/Deluge/Deluge/NetProgC.nc,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** NetProgC.nc 17 May 2005 20:55:48 -0000 1.5
--- NetProgC.nc 17 Jul 2005 21:09:37 -0000 1.6
***************
*** 60,71 ****
Main.StdControl -> Comm;
- Main.StdControl -> SharedMsgBufM;
NetProgM.Crc -> CrcC;
- NetProgM.Metadata -> Metadata.Metadata[unique("DelugeMetadata")];
NetProgM.MetadataControl -> Metadata;
NetProgM.ReceiveMsg -> Comm.ReceiveMsg[AM_NETPROGMSG];
NetProgM.SendMsg -> Comm.SendMsg[AM_NETPROGMSG];
! NetProgM.SharedMsgBuf -> SharedMsgBufM.SharedMsgBuf[DELUGE_SHARED_MSG_BUF];
NetProgM.Storage -> Storage;
--- 60,69 ----
Main.StdControl -> Comm;
NetProgM.Crc -> CrcC;
NetProgM.MetadataControl -> Metadata;
NetProgM.ReceiveMsg -> Comm.ReceiveMsg[AM_NETPROGMSG];
NetProgM.SendMsg -> Comm.SendMsg[AM_NETPROGMSG];
! NetProgM.SharedMsgBuf -> SharedMsgBufM;
NetProgM.Storage -> Storage;
Index: NetProgM.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/beta/Deluge/Deluge/NetProgM.nc,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -d -r1.11 -r1.12
*** NetProgM.nc 12 Jul 2005 20:09:06 -0000 1.11
--- NetProgM.nc 17 Jul 2005 21:09:37 -0000 1.12
***************
*** 36,40 ****
uses {
interface Crc;
- interface DelugeMetadata as Metadata;
interface DelugeStorage as Storage;
interface InternalFlash as IFlash;
--- 36,39 ----
***************
*** 67,72 ****
command result_t StdControl.init() {
!
! result_t result = call MetadataControl.init();
#ifndef PLATFORM_PC
NetProg_TOSInfo tosInfo;
--- 66,70 ----
command result_t StdControl.init() {
!
#ifndef PLATFORM_PC
NetProg_TOSInfo tosInfo;
***************
*** 83,92 ****
#endif
! return result;
}
command result_t StdControl.start() {
! return call MetadataControl.start();
}
--- 81,93 ----
#endif
! call MetadataControl.init();
!
! return SUCCESS;
}
command result_t StdControl.start() {
! call MetadataControl.start();
! return SUCCESS;
}
***************
*** 107,111 ****
return FAIL;
}
!
command result_t NetProg.programImgAndReboot(imgnum_t newImgNum) {
--- 108,112 ----
return FAIL;
}
!
command result_t NetProg.programImgAndReboot(imgnum_t newImgNum) {
***************
*** 157,161 ****
}
- event void Metadata.updateDone(result_t result) {}
event void Storage.loadImagesDone(result_t result) {}
event void SharedMsgBuf.bufFree() {}
--- 158,161 ----
Index: SharedMsgBuf.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/beta/Deluge/Deluge/SharedMsgBuf.nc,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** SharedMsgBuf.nc 15 Mar 2005 06:24:32 -0000 1.2
--- SharedMsgBuf.nc 17 Jul 2005 21:09:37 -0000 1.3
***************
*** 42,58 ****
/**
! * Request a lock on the shared message buf.
! *
! * @return <code>SUCCESS</code> if the lock was acquired successfully;
! * <code>FAIL</code> otherwise.
*/
! command result_t lock();
/**
* Release lock on shared message buf.
- *
- * @return <code>SUCCESS</code> if the lock was released successfully;
*/
! command result_t unlock();
/**
--- 42,53 ----
/**
! * Acquire lock on shared message buf.
*/
! command void lock();
/**
* Release lock on shared message buf.
*/
! command void unlock();
/**
Index: SharedMsgBufM.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/beta/Deluge/Deluge/SharedMsgBufM.nc,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** SharedMsgBufM.nc 17 May 2005 20:55:48 -0000 1.3
--- SharedMsgBufM.nc 17 Jul 2005 21:09:37 -0000 1.4
***************
*** 1,8 ****
// $Id$
! /* tab:4
*
*
! * "Copyright (c) 2000-2004 The Regents of the University of California.
* All rights reserved.
*
--- 1,8 ----
// $Id$
! /* tab:2
*
*
! * "Copyright (c) 2000-2005 The Regents of the University of California.
* All rights reserved.
*
***************
*** 34,89 ****
module SharedMsgBufM {
provides {
! interface SharedMsgBuf[uint8_t id];
! interface StdControl;
}
- uses interface BitVecUtils;
}
implementation {
! #include <BitVecUtils.h>
!
! enum {
! SMB_NUM_BUFS = uniqueCount("SharedMsgBuf"),
! SMB_LOCK_BITVEC_SIZE = (((SMB_NUM_BUFS-1)/8)+1),
! };
!
! TOS_Msg msgBufs[SMB_NUM_BUFS];
! uint8_t lockedMsgBufs[SMB_LOCK_BITVEC_SIZE];
! command result_t StdControl.init() {
! memset(lockedMsgBufs, 0x0, SMB_LOCK_BITVEC_SIZE);
! return SUCCESS;
}
! command result_t StdControl.start() { return SUCCESS; }
! command result_t StdControl.stop() { return SUCCESS; }
!
! command TOS_MsgPtr SharedMsgBuf.getMsgBuf[uint8_t id]() {
! if (id >= SMB_NUM_BUFS)
! return NULL;
! return &(msgBufs[id]);
! }
!
! command result_t SharedMsgBuf.lock[uint8_t id]() {
! if (id >= SMB_NUM_BUFS || BITVEC_GET(lockedMsgBufs, id))
! return FAIL;
! BITVEC_SET(lockedMsgBufs, id);
! return SUCCESS;
}
! command result_t SharedMsgBuf.unlock[uint8_t id]() {
! if (id >= SMB_NUM_BUFS)
! return FAIL;
! BITVEC_CLEAR(lockedMsgBufs, id);
! signal SharedMsgBuf.bufFree[id]();
! return SUCCESS;
}
! command bool SharedMsgBuf.isLocked[uint8_t id]() {
! return !!BITVEC_GET(lockedMsgBufs, id);
}
- default event void SharedMsgBuf.bufFree[uint8_t id]() {}
-
}
--- 34,62 ----
module SharedMsgBufM {
provides {
! interface SharedMsgBuf;
}
}
implementation {
! TOS_Msg msgBuf;
! bool isLocked = FALSE;
! command TOS_MsgPtr SharedMsgBuf.getMsgBuf() {
! return &msgBuf;
}
! command void SharedMsgBuf.lock() {
! isLocked = TRUE;
}
! command void SharedMsgBuf.unlock() {
! isLocked = FALSE;
! signal SharedMsgBuf.bufFree();
}
! command bool SharedMsgBuf.isLocked() {
! return isLocked;
}
}
- Previous message: [Tinyos-beta-commits] CVS: tinyos-1.x/beta/platform/tsb
MicDriverC.nc, 1.1, 1.2 MicDriverM.nc, 1.1, 1.2
- Next message: [Tinyos-beta-commits] CVS: tinyos-1.x/beta/Deluge/delugetools
Eraser.java, 1.9, 1.10 ImageInjector.java, 1.10,
1.11 Rebooter.java, 1.8, 1.9
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the Tinyos-beta-commits
mailing list