[Tinyos-2-commits]
CVS: tinyos-2.x/tos/lib/net/Deluge/FlashVolumeManager
FlashVolumeManager.h, NONE, 1.1 FlashVolumeManagerC.nc, NONE,
1.1 FlashVolumeManagerP.nc, NONE, 1.1
Razvan Musaloiu-E.
razvanm at users.sourceforge.net
Tue May 22 13:34:26 PDT 2007
- Previous message: [Tinyos-2-commits] CVS: tinyos-2.x/tos/lib/net/Deluge
AutoStarterC.nc, NONE, 1.1 AutoStarterP.nc, NONE,
1.1 BitVecUtils.h, NONE, 1.1 BitVecUtils.nc, NONE,
1.1 BitVecUtilsC.nc, NONE, 1.1 Crc.nc, NONE, 1.1 CrcP.nc, NONE,
1.1 Deluge.h, NONE, 1.1 DelugeC.nc, NONE, 1.1 DelugeMetadata.h,
NONE, 1.1 DelugeMetadata.nc, NONE, 1.1 DelugeMsgs.h, NONE,
1.1 DelugeP.nc, NONE, 1.1 DelugePageTransfer.h, NONE,
1.1 DelugePageTransfer.nc, NONE, 1.1 DelugePageTransferC.nc,
NONE, 1.1 DelugePageTransferP.nc, NONE, 1.1 DelugeStorageC.nc,
NONE, 1.1 DelugeStorageP.nc, NONE, 1.1 FakeBlockReaderC.nc,
NONE, 1.1 FakeBlockWriterC.nc, NONE, 1.1 FakeBlockWriterP.nc,
NONE, 1.1 Globals.nc, NONE, 1.1 GlobalsC.nc, NONE,
1.1 ObjectTransfer.nc, NONE, 1.1 ObjectTransferC.nc, NONE,
1.1 ObjectTransferP.nc, NONE, 1.1 SerialStarterC.nc, NONE,
1.1 StatsCollector.nc, NONE, 1.1 StatsCollectorC.nc, NONE,
1.1 StatsCollectorP.nc, NONE, 1.1
- Next message: [Tinyos-2-commits] CVS: tinyos-2.x/tos/lib/net/Deluge/extra
NetProg.h, NONE, 1.1 NetProg.nc, NONE, 1.1 NetProgC.nc, NONE,
1.1 NetProgM.nc, NONE, 1.1 TOSBoot.h, NONE, 1.1
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /cvsroot/tinyos/tinyos-2.x/tos/lib/net/Deluge/FlashVolumeManager
In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv24715/tos/lib/net/Deluge/FlashVolumeManager
Added Files:
FlashVolumeManager.h FlashVolumeManagerC.nc
FlashVolumeManagerP.nc
Log Message:
Initial commit of the Deluge T2. Some notes:
- TOSBoot includes some code to allow the MicaZ version to compile but it's not support for it it's not done yet.
- tools/tinyos/misc/Makefile.am is not updated yet so the new tools will not be installed by default.
--- NEW FILE: FlashVolumeManager.h ---
/* Copyright (c) 2007 Johns Hopkins University.
* All rights reserved.
*
* Permission to use, copy, modify, and distribute this software and its
* documentation for any purpose, without fee, and without written
* agreement is hereby granted, provided that the above copyright
* notice, the (updated) modification history and the author appear in
* all copies of this source code.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, LOSS OF USE, DATA,
* OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
* @author Chieh-Jan Mike Liang <cliang4 at cs.jhu.edu>
* @author Razvan Musaloiu-E. <razvanm at cs.jhu.edu>
*/
#ifndef FLASHVOLUMEMANAGER_H
#define FLASHVOLUMEMANAGER_H
#define SERIALMSG_ERASE 0
#define SERIALMSG_WRITE 1
#define SERIALMSG_READ 2
#define SERIALMSG_CRC 3
#define SERIALMSG_ADDR 4
#define SERIALMSG_REPROG 5
#define SERIALMSG_DISS 6
typedef nx_struct SerialReqPacket {
nx_uint8_t msg_type;
nx_uint8_t img_num;
nx_uint16_t offset;
nx_uint16_t len;
nx_uint8_t data[0];
} SerialReqPacket;
#define SERIALMSG_SUCCESS 0
#define SERIALMSG_FAIL 1
typedef nx_struct SerialReplyPacket {
nx_uint8_t error;
nx_uint8_t data[0];
} SerialReplyPacket;
#endif
--- NEW FILE: FlashVolumeManagerC.nc ---
/* Copyright (c) 2007 Johns Hopkins University.
* All rights reserved.
*
* Permission to use, copy, modify, and distribute this software and its
* documentation for any purpose, without fee, and without written
* agreement is hereby granted, provided that the above copyright
* notice, the (updated) modification history and the author appear in
* all copies of this source code.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, LOSS OF USE, DATA,
* OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
* @author Chieh-Jan Mike Liang <cliang4 at cs.jhu.edu>
* @author Razvan Musaloiu-E. <razvanm at cs.jhu.edu>
*/
#include "AM.h"
generic configuration FlashVolumeManagerC(am_id_t AMId)
{
#ifdef DELUGE
provides interface Notify<uint8_t>;
#endif
uses {
interface BlockRead[uint8_t img_num];
interface BlockWrite[uint8_t img_num];
interface StorageMap[uint8_t img_num];
}
}
implementation
{
components new SerialAMSenderC(AMId),
new SerialAMReceiverC(AMId),
new FlashVolumeManagerP(),
NoLedsC, LedsC;
FlashVolumeManagerP.BlockRead[0] = BlockRead[0];
FlashVolumeManagerP.BlockWrite[0] = BlockWrite[0];
FlashVolumeManagerP.StorageMap[0] = StorageMap[0];
FlashVolumeManagerP.BlockRead[1] = BlockRead[1];
FlashVolumeManagerP.BlockWrite[1] = BlockWrite[1];
FlashVolumeManagerP.StorageMap[1] = StorageMap[1];
FlashVolumeManagerP.SerialAMSender -> SerialAMSenderC;
FlashVolumeManagerP.SerialAMReceiver -> SerialAMReceiverC;
FlashVolumeManagerP.Leds -> NoLedsC;
#ifdef DELUGE
components NetProgC, new TimerMilliC();
FlashVolumeManagerP.NetProg -> NetProgC;
FlashVolumeManagerP.Timer -> TimerMilliC;
Notify = FlashVolumeManagerP.Notify;
#endif
}
--- NEW FILE: FlashVolumeManagerP.nc ---
/* Copyright (c) 2007 Johns Hopkins University.
* All rights reserved.
*
* Permission to use, copy, modify, and distribute this software and its
* documentation for any purpose, without fee, and without written
* agreement is hereby granted, provided that the above copyright
* notice, the (updated) modification history and the author appear in
* all copies of this source code.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS'
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, LOSS OF USE, DATA,
* OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
* @author Chieh-Jan Mike Liang <cliang4 at cs.jhu.edu>
* @author Razvan Musaloiu-E. <razvanm at cs.jhu.edu>
*/
#include "FlashVolumeManager.h"
generic module FlashVolumeManagerP()
{
#ifdef DELUGE
provides interface Notify<uint8_t>;
#endif
uses {
interface BlockRead[uint8_t img_num];
interface BlockWrite[uint8_t img_num];
interface StorageMap[uint8_t img_num];
interface AMSend as SerialAMSender;
interface Receive as SerialAMReceiver;
interface Leds;
#ifdef DELUGE
interface NetProg;
interface Timer<TMilli> as Timer;
#endif
}
}
implementation
{
// States for keeping track of split-phase events
enum {
S_IDLE,
S_ERASE,
S_WRITE,
S_READ,
S_CRC,
S_REPROG,
};
message_t serialMsg;
uint8_t buffer[TOSH_DATA_LENGTH]; // Temporary buffer for "write" operation
uint8_t img_num_reboot = 0xFF; // Image number to reprogram
uint8_t state = S_IDLE; // Manager state for multiplexing "done" events
/**
* Replies to the PC request with operation results
*/
void sendReply(error_t error, storage_len_t len)
{
SerialReplyPacket *srpkt = (SerialReplyPacket *)call SerialAMSender.getPayload(&serialMsg);
if (error == SUCCESS) {
srpkt->error = SERIALMSG_SUCCESS;
} else {
srpkt->error = SERIALMSG_FAIL;
}
call SerialAMSender.send(AM_BROADCAST_ADDR, &serialMsg, len);
}
event void BlockRead.readDone[uint8_t img_num](storage_addr_t addr,
void* buf,
storage_len_t len,
error_t error)
{
if (state == S_READ) {
SerialReplyPacket *serialMsg_payload = (SerialReplyPacket *)call SerialAMSender.getPayload(&serialMsg);
if (buf == serialMsg_payload->data) {
state = S_IDLE;
sendReply(error, len + sizeof(SerialReplyPacket));
}
}
}
event void BlockRead.computeCrcDone[uint8_t img_num](storage_addr_t addr,
storage_len_t len,
uint16_t crc,
error_t error)
{
if (state == S_CRC) {
state = S_IDLE;
if (error == SUCCESS) {
SerialReplyPacket *srpkt = (SerialReplyPacket *)call SerialAMSender.getPayload(&serialMsg);
srpkt->data[1] = crc & 0xFF;
srpkt->data[0] = (crc >> 8) & 0xFF;
}
sendReply(error, 2 + sizeof(SerialReplyPacket));
}
}
event void BlockWrite.writeDone[uint8_t img_num](storage_addr_t addr,
void* buf,
storage_len_t len,
error_t error)
{
if (state == S_WRITE && buf == buffer) {
state = S_IDLE;
sendReply(error, sizeof(SerialReplyPacket));
}
}
event void BlockWrite.eraseDone[uint8_t img_num](error_t error)
{
if (state == S_ERASE) {
state = S_IDLE;
sendReply(error, sizeof(SerialReplyPacket));
}
}
event void BlockWrite.syncDone[uint8_t img_num](error_t error) {}
event void SerialAMSender.sendDone(message_t* msg, error_t error) {}
event message_t* SerialAMReceiver.receive(message_t* msg, void* payload, uint8_t len)
{
error_t error = SUCCESS;
SerialReqPacket *srpkt = (SerialReqPacket *)payload;
SerialReplyPacket *serialMsg_payload =
(SerialReplyPacket *)call SerialAMSender.getPayload(&serialMsg);
switch (srpkt->msg_type) {
case SERIALMSG_ERASE: // === Erases a volume ===
state = S_ERASE;
error = call BlockWrite.erase[srpkt->img_num]();
break;
case SERIALMSG_WRITE: // === Writes to a volume ===
state = S_WRITE;
memcpy(buffer, srpkt->data, srpkt->len);
error = call BlockWrite.write[srpkt->img_num](srpkt->offset,
buffer,
srpkt->len);
break;
case SERIALMSG_READ: // === Reads a portion of a volume ===
state = S_READ;
error = call BlockRead.read[srpkt->img_num](srpkt->offset,
serialMsg_payload->data,
srpkt->len);
break;
case SERIALMSG_CRC: // === Computes CRC over a portion of a volume ===
state = S_CRC;
error = call BlockRead.computeCrc[srpkt->img_num](srpkt->offset,
srpkt->len, 0);
break;
case SERIALMSG_ADDR: // === Gets the physical starting address of a volume ===
*(nx_uint32_t*)(&serialMsg_payload->data) =
(uint32_t)call StorageMap.getPhysicalAddress[srpkt->img_num](0);
sendReply(SUCCESS, sizeof(SerialReplyPacket) + 4);
break;
#ifdef DELUGE
case SERIALMSG_REPROG: // === Reboots and reprograms ===
state = S_REPROG;
sendReply(SUCCESS, sizeof(SerialReplyPacket));
img_num_reboot = srpkt->img_num;
call Timer.startOneShot(1024);
break;
case SERIALMSG_DISS: // === Starts disseminating a volume ===
signal Notify.notify(srpkt->img_num); // Notifies Deluge to start disseminate
sendReply(SUCCESS, sizeof(SerialReplyPacket));
break;
#endif
}
// If a split-phase operation fails when being requested, signals the failure now
if (error != SUCCESS) {
state = S_IDLE;
sendReply(error, sizeof(SerialReplyPacket));
}
return msg;
}
#ifdef DELUGE
event void Timer.fired()
{
// Reboots and reprograms
call NetProg.programImgAndReboot(img_num_reboot);
}
command error_t Notify.enable() { return SUCCESS; }
command error_t Notify.disable() { return SUCCESS; }
#endif
default command error_t BlockWrite.write[uint8_t img_num](storage_addr_t addr, void* buf, storage_len_t len) { return FAIL; }
default command error_t BlockWrite.erase[uint8_t img_num]() { return FAIL; }
default command error_t BlockWrite.sync[uint8_t img_num]() { return FAIL; }
default command error_t BlockRead.read[uint8_t img_num](storage_addr_t addr, void* buf, storage_len_t len) { return FAIL; }
default command error_t BlockRead.computeCrc[uint8_t img_num](storage_addr_t addr, storage_len_t len, uint16_t crc) { return FAIL; }
default command storage_addr_t StorageMap.getPhysicalAddress[uint8_t img_num](storage_addr_t addr) { return 0; }
}
- Previous message: [Tinyos-2-commits] CVS: tinyos-2.x/tos/lib/net/Deluge
AutoStarterC.nc, NONE, 1.1 AutoStarterP.nc, NONE,
1.1 BitVecUtils.h, NONE, 1.1 BitVecUtils.nc, NONE,
1.1 BitVecUtilsC.nc, NONE, 1.1 Crc.nc, NONE, 1.1 CrcP.nc, NONE,
1.1 Deluge.h, NONE, 1.1 DelugeC.nc, NONE, 1.1 DelugeMetadata.h,
NONE, 1.1 DelugeMetadata.nc, NONE, 1.1 DelugeMsgs.h, NONE,
1.1 DelugeP.nc, NONE, 1.1 DelugePageTransfer.h, NONE,
1.1 DelugePageTransfer.nc, NONE, 1.1 DelugePageTransferC.nc,
NONE, 1.1 DelugePageTransferP.nc, NONE, 1.1 DelugeStorageC.nc,
NONE, 1.1 DelugeStorageP.nc, NONE, 1.1 FakeBlockReaderC.nc,
NONE, 1.1 FakeBlockWriterC.nc, NONE, 1.1 FakeBlockWriterP.nc,
NONE, 1.1 Globals.nc, NONE, 1.1 GlobalsC.nc, NONE,
1.1 ObjectTransfer.nc, NONE, 1.1 ObjectTransferC.nc, NONE,
1.1 ObjectTransferP.nc, NONE, 1.1 SerialStarterC.nc, NONE,
1.1 StatsCollector.nc, NONE, 1.1 StatsCollectorC.nc, NONE,
1.1 StatsCollectorP.nc, NONE, 1.1
- Next message: [Tinyos-2-commits] CVS: tinyos-2.x/tos/lib/net/Deluge/extra
NetProg.h, NONE, 1.1 NetProg.nc, NONE, 1.1 NetProgC.nc, NONE,
1.1 NetProgM.nc, NONE, 1.1 TOSBoot.h, NONE, 1.1
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the Tinyos-2-commits
mailing list