X-Git-Url: https://oss.titaniummirror.com/gitweb/?p=tinyos-2.x.git;a=blobdiff_plain;f=tos%2Flib%2Fnet%2FDeluge%2FFlashVolumeManager%2FFlashVolumeManagerP.nc;h=b91f194bee9f4ded4544df14a5b030819dd0ba19;hp=138c6b02ec361cc5316a3fe3fec833d5f11c4515;hb=809036bc77a8366b0f9aa2d78cdcacdcc4dc1379;hpb=e014c5d251e1706ee383c01597ed49173c00c8f3 diff --git a/tos/lib/net/Deluge/FlashVolumeManager/FlashVolumeManagerP.nc b/tos/lib/net/Deluge/FlashVolumeManager/FlashVolumeManagerP.nc index 138c6b02..b91f194b 100644 --- a/tos/lib/net/Deluge/FlashVolumeManager/FlashVolumeManagerP.nc +++ b/tos/lib/net/Deluge/FlashVolumeManager/FlashVolumeManagerP.nc @@ -24,12 +24,14 @@ * @author Razvan Musaloiu-E. */ +#include "imgNum2volumeId.h" + generic module FlashVolumeManagerP() { uses { interface BlockRead[uint8_t imgNum]; interface BlockWrite[uint8_t imgNum]; - interface Resource[uint8_t imgNum]; + interface Resource; interface ArbiterInfo; interface AMSend as SerialAMSender; interface Receive as SerialAMReceiver; @@ -43,7 +45,7 @@ implementation 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; @@ -87,7 +89,7 @@ implementation nx_uint32_t uidhash; nx_uint16_t nodeid; }; - + void sendReply(error_t error, storage_len_t len) { SerialReplyPacket *reply = (SerialReplyPacket *)call SerialAMSender.getPayload(&serialMsg, sizeof(SerialReplyPacket)); @@ -179,29 +181,16 @@ implementation } // Converts the image number that the user wants to the real image number - switch (request->imgNum) { - case 0: - imgNum = VOLUME_GOLDENIMAGE; - break; - case 1: - imgNum = VOLUME_DELUGE1; - break; - case 2: - imgNum = VOLUME_DELUGE2; - break; - case 3: - imgNum = VOLUME_DELUGE3; - break; - } + 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) { case CMD_ERASE: case CMD_WRITE: - if (!call Resource.isOwner[imgNum]()) { - error = call Resource.immediateRequest[imgNum](); + if (!call Resource.isOwner()) { + error = call Resource.immediateRequest(); } } if (error == SUCCESS) { @@ -211,7 +200,11 @@ implementation 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; @@ -264,17 +257,16 @@ implementation event void TimeoutTimer.fired() { // Release the resource. - if (state == S_IDLE && call Resource.isOwner[currentImgNum]()) { - call Leds.led1Off(); - call Resource.release[currentImgNum](); + if (state == S_IDLE && call Resource.isOwner()) { + call Resource.release(); } - if (state == S_IDLE && !call ArbiterInfo.inUse()) { + if (state == S_IDLE) { call Leds.led1Off(); } } event void SerialAMSender.sendDone(message_t* msg, error_t error) {} - event void Resource.granted[uint8_t imgNum]() {} + event void Resource.granted() {} default command error_t BlockWrite.write[uint8_t imgNum](storage_addr_t addr, void* buf, storage_len_t len) { return FAIL; } default command error_t BlockWrite.erase[uint8_t imgNum]() { return FAIL; } @@ -282,7 +274,7 @@ implementation default command error_t BlockRead.read[uint8_t imgNum](storage_addr_t addr, void* buf, storage_len_t len) { return FAIL; } default command error_t BlockRead.computeCrc[uint8_t imgNum](storage_addr_t addr, storage_len_t len, uint16_t crc) { return FAIL; } - default async command error_t Resource.immediateRequest[uint8_t imgNum]() { return FAIL; } - default async command error_t Resource.release[uint8_t imgNum]() { return FAIL; } - default async command bool Resource.isOwner[uint8_t imgNum]() { return FAIL; } + default async command error_t Resource.immediateRequest() { return FAIL; } + default async command error_t Resource.release() { return FAIL; } + default async command bool Resource.isOwner() { return FAIL; } }