[Tinyos-2-commits] CVS: tinyos-2.x/tos/chips/at45db
At45dbBlockConfig.nc, 1.1.2.2, 1.1.2.3 At45dbVolume.nc,
1.1.2.3, 1.1.2.4 BlockStorageP.nc, 1.1.2.10,
1.1.2.11 ConfigStorageC.nc, 1.1.2.3, 1.1.2.4 ConfigStorageP.nc,
1.1.2.3, 1.1.2.4 StorageManagerP.nc, 1.1.2.3, 1.1.2.4
David Gay
idgay at users.sourceforge.net
Tue May 30 14:36:30 PDT 2006
- Previous message: [Tinyos-2-commits]
CVS: tinyos-2.x/tos/interfaces Mount.nc, 1.1.2.3,
1.1.2.4 BlockRead.nc, 1.1.2.9, 1.1.2.10 ConfigStorage.nc,
1.1.2.1, 1.1.2.2 LogRead.nc, 1.1.2.3, 1.1.2.4
- Next message: [Tinyos-2-commits] CVS: tinyos-2.x/apps/tests/storage/Config
RandRWAppC.nc, 1.1.2.1, 1.1.2.2 RandRWC.nc, 1.1.2.1, 1.1.2.2
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /cvsroot/tinyos/tinyos-2.x/tos/chips/at45db
In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv21546
Modified Files:
Tag: tinyos-2_0_devel-BRANCH
At45dbBlockConfig.nc At45dbVolume.nc BlockStorageP.nc
ConfigStorageC.nc ConfigStorageP.nc StorageManagerP.nc
Log Message:
config storage cleanup
volume size in At45dbVolume is now in pages
Index: At45dbBlockConfig.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/chips/at45db/Attic/At45dbBlockConfig.nc,v
retrieving revision 1.1.2.2
retrieving revision 1.1.2.3
diff -C2 -d -r1.1.2.2 -r1.1.2.3
*** At45dbBlockConfig.nc 25 May 2006 22:57:19 -0000 1.1.2.2
--- At45dbBlockConfig.nc 30 May 2006 21:36:27 -0000 1.1.2.3
***************
*** 25,33 ****
/**
- * Set which half of the block is used by the current config state
- * @param flip TRUE for 2nd half, FALSE for 1st half
- */
- command void setFlip(bool flip);
- /**
* Query which half of the block is used by the current config state
* @return TRUE for 2nd half, FALSE for 1st half
--- 25,28 ----
Index: At45dbVolume.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/chips/at45db/Attic/At45dbVolume.nc,v
retrieving revision 1.1.2.3
retrieving revision 1.1.2.4
diff -C2 -d -r1.1.2.3 -r1.1.2.4
*** At45dbVolume.nc 26 Jan 2006 21:11:40 -0000 1.1.2.3
--- At45dbVolume.nc 30 May 2006 21:36:27 -0000 1.1.2.4
***************
*** 26,31 ****
/**
* Find the flash volume size
! * @return Flash volume size in bytes
*/
! command storage_len_t volumeSize();
}
--- 26,31 ----
/**
* Find the flash volume size
! * @return Flash volume size in pages
*/
! command at45page_t volumeSize();
}
Index: BlockStorageP.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/chips/at45db/Attic/BlockStorageP.nc,v
retrieving revision 1.1.2.10
retrieving revision 1.1.2.11
diff -C2 -d -r1.1.2.10 -r1.1.2.11
*** BlockStorageP.nc 25 May 2006 22:57:19 -0000 1.1.2.10
--- BlockStorageP.nc 30 May 2006 21:36:27 -0000 1.1.2.11
***************
*** 91,95 ****
event at45page_t BConfig.npages[blockstorage_t id]() {
! return call At45dbVolume.volumeSize[id]() >> (AT45_PAGE_SIZE_LOG2 + 1);
}
--- 91,95 ----
event at45page_t BConfig.npages[blockstorage_t id]() {
! return call At45dbVolume.volumeSize[id]() >> 1;
}
***************
*** 123,128 ****
error_t newRequest(uint8_t newState, blockstorage_t id,
storage_addr_t addr, uint8_t* buf, storage_len_t len) {
if (state[id] != S_IDLE)
! return FAIL;
setupRequest(newState, id, addr, buf, len);
--- 123,134 ----
error_t newRequest(uint8_t newState, blockstorage_t id,
storage_addr_t addr, uint8_t* buf, storage_len_t len) {
+ storage_len_t vsize;
+
if (state[id] != S_IDLE)
! return EBUSY;
!
! vsize = call BlockRead.getSize[id]();
! if (addr > vsize || len >= vsize - addr)
! return EINVAL;
setupRequest(newState, id, addr, buf, len);
***************
*** 301,305 ****
command storage_len_t BlockRead.getSize[blockstorage_t blockId]() {
! return call At45dbVolume.volumeSize[blockId]();
}
--- 307,318 ----
command storage_len_t BlockRead.getSize[blockstorage_t blockId]() {
! storage_len_t vsize;
!
! if (call BConfig.isConfig[blockId]())
! vsize = signal BConfig.npages[blockId]();
! else
! vsize = call At45dbVolume.volumeSize[blockId]();
!
! return vsize << AT45_PAGE_SIZE_LOG2;
}
***************
*** 318,330 ****
uint32_t max = sig[2] | (uint32_t)sig[3] << 8 |
(uint32_t)sig[4] << 16 | (uint32_t)sig[5] << 24;
- storage_len_t vsize;
-
- if (call BConfig.isConfig[client]())
- vsize = signal BConfig.npages[client]() << AT45_PAGE_SIZE_LOG2;
- else
- vsize = call At45dbVolume.volumeSize[client]();
/* Ignore maxAddress values that are too large */
! if (max <= vsize)
{
maxAddr[client] = max;
--- 331,337 ----
uint32_t max = sig[2] | (uint32_t)sig[3] << 8 |
(uint32_t)sig[4] << 16 | (uint32_t)sig[5] << 24;
/* Ignore maxAddress values that are too large */
! if (max <= call BlockRead.getSize[client]())
{
maxAddr[client] = max;
***************
*** 384,388 ****
default command at45page_t At45dbVolume.remap[blockstorage_t id](at45page_t volumePage) { return 0; }
! default command storage_addr_t At45dbVolume.volumeSize[blockstorage_t id]() { return 0; }
default async command error_t Resource.request[blockstorage_t id]() { return FAIL; }
default async command void Resource.release[blockstorage_t id]() { }
--- 391,395 ----
default command at45page_t At45dbVolume.remap[blockstorage_t id](at45page_t volumePage) { return 0; }
! default command at45page_t At45dbVolume.volumeSize[blockstorage_t id]() { return 0; }
default async command error_t Resource.request[blockstorage_t id]() { return FAIL; }
default async command void Resource.release[blockstorage_t id]() { }
Index: ConfigStorageC.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/chips/at45db/Attic/ConfigStorageC.nc,v
retrieving revision 1.1.2.3
retrieving revision 1.1.2.4
diff -C2 -d -r1.1.2.3 -r1.1.2.4
*** ConfigStorageC.nc 25 May 2006 22:57:19 -0000 1.1.2.3
--- ConfigStorageC.nc 30 May 2006 21:36:27 -0000 1.1.2.4
***************
*** 21,25 ****
generic configuration ConfigStorageC(volume_id_t volid) {
provides {
! interface SplitControl;
interface ConfigStorage;
}
--- 21,25 ----
generic configuration ConfigStorageC(volume_id_t volid) {
provides {
! interface Mount;
interface ConfigStorage;
}
***************
*** 34,38 ****
components BlockStorageP, WireBlockStorageP;
! SplitControl = ConfigStorageP.SplitControl[CONFIG_ID];
ConfigStorage = ConfigStorageP.ConfigStorage[CONFIG_ID];
--- 34,38 ----
components BlockStorageP, WireBlockStorageP;
! Mount = ConfigStorageP.Mount[CONFIG_ID];
ConfigStorage = ConfigStorageP.ConfigStorage[CONFIG_ID];
Index: ConfigStorageP.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/chips/at45db/Attic/ConfigStorageP.nc,v
retrieving revision 1.1.2.3
retrieving revision 1.1.2.4
diff -C2 -d -r1.1.2.3 -r1.1.2.4
*** ConfigStorageP.nc 25 May 2006 22:57:19 -0000 1.1.2.3
--- ConfigStorageP.nc 30 May 2006 21:36:27 -0000 1.1.2.4
***************
*** 22,26 ****
module ConfigStorageP {
provides {
! interface SplitControl[configstorage_t id];
interface ConfigStorage[configstorage_t id];
interface At45dbBlockConfig as BConfig[blockstorage_t id];
--- 22,26 ----
module ConfigStorageP {
provides {
! interface Mount[configstorage_t id];
interface ConfigStorage[configstorage_t id];
interface At45dbBlockConfig as BConfig[blockstorage_t id];
***************
*** 53,57 ****
enum {
S_STOPPED,
- S_STOP,
S_MOUNT,
S_CLEAN,
--- 53,56 ----
***************
*** 64,89 ****
};
uint8_t state[N];
uint32_t lowVersion[N], highVersion[N];
! uint8_t flipped[(N + 7) / 8];
uint8_t client = NO_CLIENT;
at45page_t nextPage;
! command int BConfig.isConfig[blockstorage_t id]() {
! return id < N;
! }
!
! command void BConfig.setFlip[blockstorage_t id](bool flip) {if (flip)
! flipped[id >> 3] |= 1 << (id & 7);
! else
! flipped[id >> 3] &= ~(1 << (id & 7));
! }
! inline command int BConfig.flipped[blockstorage_t id]() {
! return (flipped[id >> 3] & (1 << (id & 7))) != 0;
! }
! command error_t SplitControl.start[uint8_t id]() {
/* Read version on both halves. Validate higher. Validate lower if
higher invalid. Use lower if both invalid. */
--- 63,85 ----
};
+ /* Per-client state */
uint8_t state[N];
+
+ /* Version numbers for lower and upper half */
uint32_t lowVersion[N], highVersion[N];
!
! /* Bit n is true if client n is using upper block */
! uint8_t flipped[(N + 7) / 8];
uint8_t client = NO_CLIENT;
at45page_t nextPage;
! void setFlip(blockstorage_t id, bool flip);
! /* ------------------------------------------------------------------ */
! /* Mounting */
! /* ------------------------------------------------------------------ */
! command error_t Mount.mount[uint8_t id]() {
/* Read version on both halves. Validate higher. Validate lower if
higher invalid. Use lower if both invalid. */
***************
*** 92,96 ****
state[id] = S_MOUNT;
! call BConfig.setFlip[id](FALSE);
call BlockRead.read[id](0, &lowVersion[id], sizeof lowVersion[id]);
--- 88,92 ----
state[id] = S_MOUNT;
! setFlip(id, FALSE);
call BlockRead.read[id](0, &lowVersion[id], sizeof lowVersion[id]);
***************
*** 102,115 ****
{
state[id] = S_STOPPED;
! signal SplitControl.startDone[id](FAIL);
}
else if (!call BConfig.flipped[id]())
{
! call BConfig.setFlip[id](TRUE);
call BlockRead.read[id](0, &highVersion[id], sizeof highVersion[id]);
}
else
{
! call BConfig.setFlip[id](highVersion[id] > lowVersion[id]);
call BlockRead.verify[id]();
}
--- 98,113 ----
{
state[id] = S_STOPPED;
! signal Mount.mountDone[id](FAIL);
}
else if (!call BConfig.flipped[id]())
{
! /* Just read low-half version. Read high-half version */
! setFlip(id, TRUE);
call BlockRead.read[id](0, &highVersion[id], sizeof highVersion[id]);
}
else
{
! /* Verify the half with the largest version */
! setFlip(id, highVersion[id] > lowVersion[id]);
call BlockRead.verify[id]();
}
***************
*** 123,127 ****
if ((highVersion[id] > lowVersion[id]) == isflipped)
{
! call BConfig.setFlip[id](!isflipped);
call BlockRead.verify[id]();
return;
--- 121,127 ----
if ((highVersion[id] > lowVersion[id]) == isflipped)
{
! /* Verification of the half with the highest version failed. Try
! the other half. */
! setFlip(id, !isflipped);
call BlockRead.verify[id]();
return;
***************
*** 131,148 ****
}
state[id] = S_CLEAN;
! signal SplitControl.startDone[id](SUCCESS);
}
! command error_t SplitControl.stop[uint8_t id]() {
! return FAIL;
! }
command error_t ConfigStorage.read[configstorage_t id](storage_addr_t addr, void* buf, storage_len_t len) {
/* Read from current half using BlockRead */
if (!(state[id] == S_CLEAN || state[id] == S_DIRTY))
! return FAIL;
return call BlockRead.read[id](addr + sizeof(uint32_t), buf, len);
}
command error_t ConfigStorage.write[configstorage_t id](storage_addr_t addr, void* buf, storage_len_t len) {
/* 1: If first write:
--- 131,157 ----
}
state[id] = S_CLEAN;
! signal Mount.mountDone[id](SUCCESS);
}
! /* ------------------------------------------------------------------ */
! /* Read */
! /* ------------------------------------------------------------------ */
command error_t ConfigStorage.read[configstorage_t id](storage_addr_t addr, void* buf, storage_len_t len) {
/* Read from current half using BlockRead */
if (!(state[id] == S_CLEAN || state[id] == S_DIRTY))
! return EOFF;
!
return call BlockRead.read[id](addr + sizeof(uint32_t), buf, len);
}
+ void readReadDone(configstorage_t id, storage_addr_t addr, void* buf, storage_len_t len, error_t error) {
+ signal ConfigStorage.readDone[id](addr - sizeof(uint32_t), buf, len, error);
+ }
+
+ /* ------------------------------------------------------------------ */
+ /* Write */
+ /* ------------------------------------------------------------------ */
+
command error_t ConfigStorage.write[configstorage_t id](storage_addr_t addr, void* buf, storage_len_t len) {
/* 1: If first write:
***************
*** 151,155 ****
if (!(state[id] == S_CLEAN || state[id] == S_DIRTY))
! return FAIL;
return call BlockWrite.write[id](addr + sizeof(uint32_t), buf, len);
}
--- 160,164 ----
if (!(state[id] == S_CLEAN || state[id] == S_DIRTY))
! return EOFF;
return call BlockWrite.write[id](addr + sizeof(uint32_t), buf, len);
}
***************
*** 193,196 ****
--- 202,206 ----
else
{
+ // copy next page
at45page_t from, to, npages = signal BConfig.npages[client]();
***************
*** 208,212 ****
if (error == SUCCESS)
{
! call BConfig.setFlip[client](!call BConfig.flipped[client]());
state[client] = S_DIRTY;
}
--- 218,222 ----
if (error == SUCCESS)
{
! setFlip(client, !call BConfig.flipped[client]());
state[client] = S_DIRTY;
}
***************
*** 221,227 ****
--- 231,247 ----
}
+ void writeWriteDone(configstorage_t id, storage_addr_t addr, void* buf, storage_len_t len, error_t error) {
+ signal ConfigStorage.writeDone[id](addr - sizeof(uint32_t), buf, len, error);
+ }
+
+ /* ------------------------------------------------------------------ */
+ /* Commit */
+ /* ------------------------------------------------------------------ */
+
command error_t ConfigStorage.commit[configstorage_t id]() {
/* Call BlockWrite.commit */
/* Could special-case attempt to commit clean block */
+ if (!(state[id] == S_CLEAN || state[id] == S_DIRTY))
+ return EOFF;
return call BlockWrite.commit[id]();
}
***************
*** 233,236 ****
--- 253,286 ----
}
+ /* ------------------------------------------------------------------ */
+ /* Get Size */
+ /* ------------------------------------------------------------------ */
+
+ command storage_len_t ConfigStorage.getSize[configstorage_t id]() {
+ return call BlockRead.getSize[id]();
+ }
+
+ /* ------------------------------------------------------------------ */
+ /* Interface with BlockStorageP */
+ /* ------------------------------------------------------------------ */
+
+ /* The config volumes use the low block volume numbers. So a volume is a
+ config volume iff its its id is less than N */
+
+ command int BConfig.isConfig[blockstorage_t id]() {
+ return id < N;
+ }
+
+ void setFlip(blockstorage_t id, bool flip) {
+ if (flip)
+ flipped[id >> 3] |= 1 << (id & 7);
+ else
+ flipped[id >> 3] &= ~(1 << (id & 7));
+ }
+
+ inline command int BConfig.flipped[blockstorage_t id]() {
+ return (flipped[id >> 3] & (1 << (id & 7))) != 0;
+ }
+
event void BlockRead.readDone[configstorage_t id](storage_addr_t addr, void* buf, storage_len_t len, error_t error) {
if (id < N)
***************
*** 238,242 ****
mountReadDone(id, error);
else
! signal ConfigStorage.readDone[id](addr - sizeof(uint32_t), buf, len, error);
}
--- 288,292 ----
mountReadDone(id, error);
else
! readReadDone(id, addr, buf, len, error);
}
***************
*** 248,252 ****
event void BlockWrite.writeDone[configstorage_t id]( storage_addr_t addr, void* buf, storage_len_t len, error_t error ) {
if (id < N)
! signal ConfigStorage.writeDone[id](addr - sizeof(uint32_t), buf, len, error);
}
--- 298,302 ----
event void BlockWrite.writeDone[configstorage_t id]( storage_addr_t addr, void* buf, storage_len_t len, error_t error ) {
if (id < N)
! writeWriteDone(id, addr, buf, len, error);
}
***************
*** 274,278 ****
event void At45db.computeCrcDone(error_t error, uint16_t crc) {}
! default event void SplitControl.startDone[configstorage_t id](error_t error) { }
default event void ConfigStorage.readDone[configstorage_t id](storage_addr_t addr, void* buf, storage_len_t len, error_t error) {}
default event void ConfigStorage.writeDone[configstorage_t id](storage_addr_t addr, void* buf, storage_len_t len, error_t error) {}
--- 324,328 ----
event void At45db.computeCrcDone(error_t error, uint16_t crc) {}
! default event void Mount.mountDone[configstorage_t id](error_t error) { }
default event void ConfigStorage.readDone[configstorage_t id](storage_addr_t addr, void* buf, storage_len_t len, error_t error) {}
default event void ConfigStorage.writeDone[configstorage_t id](storage_addr_t addr, void* buf, storage_len_t len, error_t error) {}
Index: StorageManagerP.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/chips/at45db/Attic/StorageManagerP.nc,v
retrieving revision 1.1.2.3
retrieving revision 1.1.2.4
diff -C2 -d -r1.1.2.3 -r1.1.2.4
*** StorageManagerP.nc 27 Jan 2006 00:57:20 -0000 1.1.2.3
--- StorageManagerP.nc 30 May 2006 21:36:27 -0000 1.1.2.4
***************
*** 28,35 ****
}
! command storage_len_t At45dbVolume.volumeSize[volume_id_t volid]() {
switch (volid)
{
! #define VS(id, size) case id: return (storage_addr_t)size << AT45_PAGE_SIZE_LOG2;
#include "StorageVolumes.h"
default: return 0;
--- 28,35 ----
}
! command at45page_t At45dbVolume.volumeSize[volume_id_t volid]() {
switch (volid)
{
! #define VS(id, size) case id: return size;
#include "StorageVolumes.h"
default: return 0;
- Previous message: [Tinyos-2-commits]
CVS: tinyos-2.x/tos/interfaces Mount.nc, 1.1.2.3,
1.1.2.4 BlockRead.nc, 1.1.2.9, 1.1.2.10 ConfigStorage.nc,
1.1.2.1, 1.1.2.2 LogRead.nc, 1.1.2.3, 1.1.2.4
- Next message: [Tinyos-2-commits] CVS: tinyos-2.x/apps/tests/storage/Config
RandRWAppC.nc, 1.1.2.1, 1.1.2.2 RandRWC.nc, 1.1.2.1, 1.1.2.2
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the Tinyos-2-commits
mailing list