* @author Razvan Musaloiu-E. <razvanm@cs.jhu.edu>
*/
+#include "imgNum2volumeId.h"
+
generic module FlashVolumeManagerP()
{
uses {
typedef nx_struct SerialReqPacket {
nx_uint8_t cmd;
nx_uint8_t imgNum;
- nx_uint16_t offset;
+ nx_uint32_t offset;
nx_uint16_t len;
nx_uint8_t data[0];
} SerialReqPacket;
nx_uint16_t nodeid;
};
- uint8_t imgNum2volumeId[] = {
- VOLUME_GOLDENIMAGE,
- VOLUME_DELUGE1,
- VOLUME_DELUGE2,
- VOLUME_DELUGE3
- };
-
void sendReply(error_t error, storage_len_t len)
{
SerialReplyPacket *reply = (SerialReplyPacket *)call SerialAMSender.getPayload(&serialMsg, sizeof(SerialReplyPacket));
}
// Converts the image number that the user wants to the real image number
- imgNum = request->imgNum < DELUGE_NUM_VOLUMES ? imgNum2volumeId[request->imgNum] : 0xFF;
+ imgNum = imgNum2volumeId(request->imgNum);
- if (imgNum != 0xFF) {
+ if (imgNum != NON_DELUGE_VOLUME) {
error = SUCCESS;
// We ask for a reservation only for erase and write.
switch (request->cmd) {
switch (request->cmd) {
case CMD_ERASE: // === Erases a volume ===
state = S_ERASE;
+#if defined(PLATFORM_MICAZ) || defined(PLATFORM_IRIS) || defined(PLATFORM_EPIC)
+ error = FAIL;
+#else
error = call BlockWrite.erase[imgNum]();
+#endif
break;
case CMD_WRITE: // === Writes to a volume ===
state = S_WRITE;
{
// Release the resource.
if (state == S_IDLE && call Resource.isOwner()) {
- call Leds.led1Off();
call Resource.release();
}
- if (state == S_IDLE && !call ArbiterInfo.inUse()) {
+ if (state == S_IDLE) {
call Leds.led1Off();
}
}