[Tinyos-contrib-commits]
CVS: tinyos-1.x/contrib/rincon/apps/Blackbook5/core
NodeMapC.nc, 1.1, 1.2 BCleanC.nc, 1.1, 1.2 SectorMapM.nc, 1.1,
1.2 BFileDeleteM.nc, 1.1, 1.2 WriteAllocM.nc, 1.1,
1.2 BFileDirC.nc, 1.1, 1.2 FileioC.nc, 1.1, 1.2 Blackbook.h,
1.1, 1.2 WriteAllocC.nc, 1.1, 1.2 NodeMapM.nc, 1.1,
1.2 FileioM.nc, 1.1, 1.2
dmm
rincon at users.sourceforge.net
Tue Jun 6 09:51:03 PDT 2006
- Previous message: [Tinyos-contrib-commits]
CVS: tinyos-1.x/contrib/rincon/tools/java/com/rincon/blackbook/messages
BlackbookFileMsg.java, 1.1, 1.2 BlackbookSectorMsg.class, 1.1,
1.2 BlackbookFileMsg.class, 1.1, 1.2 BlackbookNodeMsg.class,
1.1, 1.2 BlackbookSectorMsg.java, 1.1,
1.2 BlackbookNodeMsg.java, 1.1, 1.2
- Next message: [Tinyos-contrib-commits]
CVS: tinyos-1.x/contrib/rincon/apps/Blackbook5
Blackbook5_API.pdf, NONE, 1.1
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /cvsroot/tinyos/tinyos-1.x/contrib/rincon/apps/Blackbook5/core
In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv28804/contrib/rincon/apps/Blackbook5/core
Modified Files:
NodeMapC.nc BCleanC.nc SectorMapM.nc BFileDeleteM.nc
WriteAllocM.nc BFileDirC.nc FileioC.nc Blackbook.h
WriteAllocC.nc NodeMapM.nc FileioM.nc
Log Message:
Updated Blackbook to v.5.1, fixed many bugs and increased reliability
Index: NodeMapC.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/contrib/rincon/apps/Blackbook5/core/NodeMapC.nc,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** NodeMapC.nc 18 May 2006 22:34:20 -0000 1.1
--- NodeMapC.nc 6 Jun 2006 16:50:29 -0000 1.2
***************
*** 45,49 ****
implementation {
components NodeMapM, StateC, SectorMapC, UtilC;
!
NodeMap = NodeMapM;
NodeBooter = NodeMapM;
--- 45,49 ----
implementation {
components NodeMapM, StateC, SectorMapC, UtilC;
!
NodeMap = NodeMapM;
NodeBooter = NodeMapM;
Index: BCleanC.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/contrib/rincon/apps/Blackbook5/core/BCleanC.nc,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** BCleanC.nc 18 May 2006 22:34:20 -0000 1.1
--- BCleanC.nc 6 Jun 2006 16:50:29 -0000 1.2
***************
*** 38,47 ****
implementation {
components BCleanM, FlashBridgeC, SectorMapC;
!
BClean = BCleanM;
BCleanM.FlashBridge -> FlashBridgeC.FlashBridge[unique("FlashBridge")];
BCleanM.SectorMap -> SectorMapC;
-
}
--- 38,46 ----
implementation {
components BCleanM, FlashBridgeC, SectorMapC;
!
BClean = BCleanM;
BCleanM.FlashBridge -> FlashBridgeC.FlashBridge[unique("FlashBridge")];
BCleanM.SectorMap -> SectorMapC;
}
Index: SectorMapM.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/contrib/rincon/apps/Blackbook5/core/SectorMapM.nc,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** SectorMapM.nc 18 May 2006 22:34:20 -0000 1.1
--- SectorMapM.nc 6 Jun 2006 16:50:29 -0000 1.2
***************
*** 239,243 ****
// This performs a size estimate of the biggest single file we can create on flash.
! for(sectorIndex = 0; sectorIndex < FLASH_TOTAL_SECTORS; sectorIndex++) {
if(!flashSectors[sectorIndex].inUse && flashSectors[sectorIndex].writePage < FLASH_PAGES_PER_SECTOR) {
totalSpace += call SectorMap.bytesRemaining(&flashSectors[sectorIndex]);
--- 239,243 ----
// This performs a size estimate of the biggest single file we can create on flash.
! for(sectorIndex = FLASH_FIRST_BLACKBOOK_SECTOR; sectorIndex <= FLASH_LAST_BLACKBOOK_SECTOR; sectorIndex++) {
if(!flashSectors[sectorIndex].inUse && flashSectors[sectorIndex].writePage < FLASH_PAGES_PER_SECTOR) {
totalSpace += call SectorMap.bytesRemaining(&flashSectors[sectorIndex]);
Index: BFileDeleteM.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/contrib/rincon/apps/Blackbook5/core/BFileDeleteM.nc,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** BFileDeleteM.nc 18 May 2006 22:34:20 -0000 1.1
--- BFileDeleteM.nc 6 Jun 2006 16:50:29 -0000 1.2
***************
*** 108,112 ****
event void NodeShop.metaDeleted(node *focusedNode, result_t result) {
if(call BlackbookState.getState() == S_DELETE_BUSY) {
! if(!call Checkpoint.update(currentNode)) {
post finalize();
}
--- 108,123 ----
event void NodeShop.metaDeleted(node *focusedNode, result_t result) {
if(call BlackbookState.getState() == S_DELETE_BUSY) {
! currentNode->state = NODE_EMPTY;
! previousNode->nextNode = NULL;
!
! if(currentFile->firstNode->state == NODE_EMPTY) {
! currentFile->firstNode = NULL;
! currentFile->state = FILE_EMPTY;
! call BlackbookState.toIdle();
! signal BFileDelete.deleted[currentClient](SUCCESS);
!
! } else {
! currentNode = currentFile->firstNode;
! previousNode = currentFile->firstNode;
post finalize();
}
***************
*** 149,166 ****
event void Checkpoint.updated(node *focusedNode, result_t result) {
if(call BlackbookState.getState() == S_DELETE_BUSY) {
! currentNode->state = NODE_EMPTY;
! previousNode->nextNode = NULL;
! currentNode = currentFile->firstNode;
! previousNode = currentNode;
!
! if(focusedNode == currentNode) {
! currentFile->firstNode = NULL;
! currentFile->state = FILE_EMPTY;
! call BlackbookState.toIdle();
! signal BFileDelete.deleted[currentClient](SUCCESS);
!
! } else {
! post finalize();
! }
}
}
--- 160,164 ----
event void Checkpoint.updated(node *focusedNode, result_t result) {
if(call BlackbookState.getState() == S_DELETE_BUSY) {
! call NodeShop.deleteNode(currentNode);
}
}
***************
*** 186,192 ****
*/
task void finalize() {
! if(currentNode->nextNode == NULL) {
! // Delete the last valid node of the file
! call NodeShop.deleteNode(currentNode);
} else {
--- 184,195 ----
*/
task void finalize() {
! if((currentNode->nextNode == NULL) || currentNode->nextNode->state == NODE_DELETED) {
! // Working from the last node in the file to the first node:
! // 1. Remove the checkpoint. This way, if we reboot in the middle,
! // the node will get erased anyway.
! // 2. Invalidate the nodemeta through NodeShop.
!
! currentNode->state = NODE_DELETED;
! call Checkpoint.update(currentNode);
} else {
Index: WriteAllocM.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/contrib/rincon/apps/Blackbook5/core/WriteAllocM.nc,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** WriteAllocM.nc 18 May 2006 22:34:20 -0000 1.1
--- WriteAllocM.nc 6 Jun 2006 16:50:29 -0000 1.2
***************
*** 86,89 ****
--- 86,92 ----
uint8_t nextElement;
+ /** TRUE if BClean was called during the current allocation attempt */
+ bool cleaned;
+
enum {
S_IDLE = 0,
***************
*** 124,127 ****
--- 127,131 ----
}
+ cleaned = FALSE;
minSize = minimumSize;
totalSize = 0;
***************
*** 254,264 ****
/**
* Garbage Collection is complete
* @return SUCCESS if any sectors were erased.
*/
event void BClean.gcDone(result_t result) {
if(call State.getState() == S_OPEN) {
! if(!allocateOneSector()) {
fail();
}
}
}
--- 258,325 ----
/**
* Garbage Collection is complete
+ * TODO This works fine, but notice how the code is
+ * similar to other areas of code in this file.
+ * To polish it off, maybe think about combining all this
+ * code into one function.
* @return SUCCESS if any sectors were erased.
*/
event void BClean.gcDone(result_t result) {
+ node *lastGoodNode;
if(call State.getState() == S_OPEN) {
! if(!result) {
! fail();
! return;
! }
!
! cleaned = TRUE;
!
! // 1. Erase all the current temporary nodes
! // and find the last non-temporary node of the file
! currentNode = currentFile->firstNode;
! lastGoodNode = NULL;
! totalSize = 0;
! nextElement = 0;
!
! do {
! if(currentNode->state == NODE_TEMPORARY) {
! call SectorMap.freeSector(call SectorMap.getSectorAtAddress(currentNode->flashAddress));
! currentNode->state = NODE_EMPTY;
!
! } else {
! if(onlyOneNode) {
! // This is a dictionary file, add up its reserveLength
! // because the dataLength isn't set when Checkpoint opens this up
! // during boot
! totalSize += currentNode->reserveLength;
!
! } else {
! totalSize += currentNode->dataLength;
! minSize -= currentNode->dataLength;
! }
!
! nextElement++;
! lastGoodNode = currentNode;
! }
! } while((currentNode = currentNode->nextNode) != NULL);
!
!
! // 2. Allocate a node to the file
! if((currentNode = call NodeBooter.requestAddNode()) == NULL) {
fail();
+ return;
+ }
+
+ // 3. Sew it into our linked list
+ if(lastGoodNode == NULL) {
+ currentFile->firstNode = currentNode;
+ } else {
+ lastGoodNode->nextNode = currentNode;
}
+
+ // 4. Setup parameters and re-attempt allocation
+ currentNode->filenameCrc = currentFile->filenameCrc;
+ currentNode->state = NODE_TEMPORARY;
+
+ post allocate();
}
}
***************
*** 274,278 ****
task void allocate() {
if(!allocateOneSector()) {
! call BClean.gc();
}
}
--- 335,343 ----
task void allocate() {
if(!allocateOneSector()) {
! if(!cleaned) {
! call BClean.gc();
! } else {
! fail();
! }
}
}
***************
*** 290,294 ****
totalSize += currentNode->reserveLength;
!
// The totalSize here is actually the append address in the file,
// if we're finishing successfully.
--- 355,359 ----
totalSize += currentNode->reserveLength;
!
// The totalSize here is actually the append address in the file,
// if we're finishing successfully.
***************
*** 322,331 ****
currentNode->fileElement = nextElement;
nextElement++;
!
if(currentFile->firstNode == currentNode) {
metaSize += sizeof(filemeta);
}
! currentNode->reserveLength = call SectorMap.bytesRemaining(currentSector);
if(call Util.convertBytesToPages(currentNode->reserveLength) > call Util.convertBytesToPages(minSize + metaSize - totalSize)) {
--- 387,396 ----
currentNode->fileElement = nextElement;
nextElement++;
!
if(currentFile->firstNode == currentNode) {
metaSize += sizeof(filemeta);
}
! currentNode->reserveLength = call SectorMap.bytesRemaining(currentSector);
if(call Util.convertBytesToPages(currentNode->reserveLength) > call Util.convertBytesToPages(minSize + metaSize - totalSize)) {
***************
*** 424,428 ****
} else if(currentFile->state == FILE_WRITING) {
currentFile->state = FILE_IDLE;
-
}
--- 489,492 ----
Index: BFileDirC.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/contrib/rincon/apps/Blackbook5/core/BFileDirC.nc,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** BFileDirC.nc 18 May 2006 22:34:20 -0000 1.1
--- BFileDirC.nc 6 Jun 2006 16:50:29 -0000 1.2
***************
*** 51,55 ****
BFileDirM.InternalDictionary -> BDictionaryC.InternalDictionary[INTERNAL_DICTIONARY];
BFileDirM.Util -> UtilC;
-
}
--- 51,54 ----
Index: FileioC.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/contrib/rincon/apps/Blackbook5/core/FileioC.nc,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** FileioC.nc 18 May 2006 22:34:20 -0000 1.1
--- FileioC.nc 6 Jun 2006 16:50:29 -0000 1.2
***************
*** 41,45 ****
implementation {
components FileioM, FlashBridgeC, NodeShopC, NodeMapC, StateC, GenericCrcC;
!
Fileio = FileioM;
StdControl = FlashBridgeC;
--- 41,45 ----
implementation {
components FileioM, FlashBridgeC, NodeShopC, NodeMapC, StateC, GenericCrcC;
!
Fileio = FileioM;
StdControl = FlashBridgeC;
Index: Blackbook.h
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/contrib/rincon/apps/Blackbook5/core/Blackbook.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** Blackbook.h 18 May 2006 22:34:20 -0000 1.1
--- Blackbook.h 6 Jun 2006 16:50:29 -0000 1.2
***************
*** 60,64 ****
/** The element of the file this node represents, 0 for the first node */
! uint8_t fileElement;
} nodemeta;
--- 60,64 ----
/** The element of the file this node represents, 0 for the first node */
! uint16_t fileElement;
} nodemeta;
Index: WriteAllocC.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/contrib/rincon/apps/Blackbook5/core/WriteAllocC.nc,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** WriteAllocC.nc 18 May 2006 22:34:20 -0000 1.1
--- WriteAllocC.nc 6 Jun 2006 16:50:29 -0000 1.2
***************
*** 37,41 ****
implementation {
components WriteAllocM, SectorMapC, NodeMapC, NodeShopC, StateC, UtilC, BCleanC;
!
WriteAlloc = WriteAllocM;
--- 37,41 ----
implementation {
components WriteAllocM, SectorMapC, NodeMapC, NodeShopC, StateC, UtilC, BCleanC;
!
WriteAlloc = WriteAllocM;
Index: NodeMapM.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/contrib/rincon/apps/Blackbook5/core/NodeMapM.nc,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** NodeMapM.nc 18 May 2006 22:34:20 -0000 1.1
--- NodeMapM.nc 6 Jun 2006 16:50:29 -0000 1.2
***************
*** 164,168 ****
if(nodes[nodeIndex].fileElement == currentElement) {
// in fact it's the next node we're looking for
-
if(currentElement == 0) {
// This is the first node of the file
--- 164,167 ----
***************
*** 173,179 ****
--- 172,180 ----
}
+ nodes[nodeIndex].fileElement = 0xFF;
nodes[nodeIndex].nextNode = NULL;
lastLinkedNode = &nodes[nodeIndex];
currentElement++;
+ nodeIndex = -1; // -1 because the for loop immediately adds 1
}
}
***************
*** 183,192 ****
}
! // Remove all the dangling nodes.
for(nodeIndex = 0; nodeIndex < call NodeMap.getMaxNodes(); nodeIndex++) {
! if(nodes[nodeIndex].state == NODE_BOOTING) {
! nodes[nodeIndex].state = NODE_DELETED;
! call SectorMap.documentNode(&nodes[nodeIndex]);
! nodes[nodeIndex].state = NODE_EMPTY;
}
}
--- 184,200 ----
}
! // Remove all the dangling nodes - although this should never happen,
! // we take some precautions. One issue is this will not erase
! // the node's checkpoint, so the checkpoint for this node will
! // be around forever, until another node is written to its location
! // I'd rather have a lingering 18 byte checkpoint hanging around
! // than a sector-long undeletable node
for(nodeIndex = 0; nodeIndex < call NodeMap.getMaxNodes(); nodeIndex++) {
! if(nodes[nodeIndex].state != NODE_EMPTY && nodes[nodeIndex].state != NODE_VALID) {
! if(nodes[nodeIndex].fileElement != 0xFF) {
! nodes[nodeIndex].state = NODE_DELETED;
! call SectorMap.removeNode(&nodes[nodeIndex]);
! nodes[nodeIndex].state = NODE_EMPTY;
! }
}
}
Index: FileioM.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/contrib/rincon/apps/Blackbook5/core/FileioM.nc,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** FileioM.nc 18 May 2006 22:34:20 -0000 1.1
--- FileioM.nc 6 Jun 2006 16:50:29 -0000 1.2
***************
*** 173,177 ****
*/
event void FlashBridge.writeDone(uint32_t addr, void *buf, uint32_t len, result_t result) {
- currentNode->dataCrc = call GenericCrc.crc16(currentNode->dataCrc, buf + totalComplete, len);
currentNode->dataLength += len;
totalComplete += len;
--- 173,176 ----
***************
*** 367,370 ****
--- 366,370 ----
*/
task void write() {
+ currentNode->dataCrc = call GenericCrc.crc16(currentNode->dataCrc, currentBuffer + totalComplete, currentAmount);
if(!call FlashBridge.write(actualAddress, currentBuffer + totalComplete, currentAmount)) {
post write();
- Previous message: [Tinyos-contrib-commits]
CVS: tinyos-1.x/contrib/rincon/tools/java/com/rincon/blackbook/messages
BlackbookFileMsg.java, 1.1, 1.2 BlackbookSectorMsg.class, 1.1,
1.2 BlackbookFileMsg.class, 1.1, 1.2 BlackbookNodeMsg.class,
1.1, 1.2 BlackbookSectorMsg.java, 1.1,
1.2 BlackbookNodeMsg.java, 1.1, 1.2
- Next message: [Tinyos-contrib-commits]
CVS: tinyos-1.x/contrib/rincon/apps/Blackbook5
Blackbook5_API.pdf, NONE, 1.1
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the Tinyos-contrib-commits
mailing list