]> oss.titaniummirror.com Git - tinyos-2.x.git/blobdiff - tos/lib/net/Deluge/FlashVolumeManager/FlashVolumeManagerP.nc
This commit from Chieh-Jan (Mike) Liang contains the following:
[tinyos-2.x.git] / tos / lib / net / Deluge / FlashVolumeManager / FlashVolumeManagerP.nc
index 78cda769888c97aca3f55b72ba0abd8c036b6bee..2021f2e0a6ca549b01b1fa6e4b7d796b183677b3 100644 (file)
 generic module FlashVolumeManagerP()
 {
 #ifdef DELUGE
-  provides interface Notify<uint8_t>;
+  provides {
+    interface Notify<uint8_t> as DissNotify;
+    interface Notify<uint8_t> as ReprogNotify;
+  }
 #endif
   uses {
     interface BlockRead[uint8_t img_num];
@@ -55,6 +58,7 @@ implementation
     S_READ,
     S_CRC,
     S_REPROG,
+    S_SYNC,
   };
   
   message_t serialMsg;
@@ -127,7 +131,7 @@ implementation
   
   event void BlockWrite.syncDone[uint8_t img_num](error_t error)
   {
-    if (state == S_ERASE) {
+    if (state == S_ERASE || state == S_SYNC) {
       state = S_IDLE;
       sendReply(error, sizeof(SerialReplyPacket));
     }
@@ -177,20 +181,27 @@ implementation
           error = call BlockRead.computeCrc[img_num](srpkt->offset,
                                                             srpkt->len, 0);
           break;
+        case SERIALMSG_SYNC:     // === Sync the flash ===
+          state = S_SYNC;
+          error = call BlockWrite.sync[img_num]();
   #ifdef DELUGE
         case SERIALMSG_ADDR:     // === Gets the physical starting address of a volume ===
           *(nx_uint32_t*)(&serialMsg_payload->data) =
                                   (uint32_t)call DelugeStorage.getPhysicalAddress[img_num](0);
           sendReply(SUCCESS, sizeof(SerialReplyPacket) + 4);
           break;
-        case SERIALMSG_REPROG:   // === Reboots and reprograms ===
+        case SERIALMSG_REPROG_BS:   // === Reprograms only the base station ===
           state = S_REPROG;
           sendReply(SUCCESS, sizeof(SerialReplyPacket));
           img_num_reboot = img_num;
           call Timer.startOneShot(1024);
           break;
         case SERIALMSG_DISS:     // === Starts disseminating a volume ===
-          signal Notify.notify(img_num);   // Notifies Deluge to start disseminate
+          signal DissNotify.notify(img_num);   // Notifies Deluge to start disseminate
+          sendReply(SUCCESS, sizeof(SerialReplyPacket));
+          break;
+        case SERIALMSG_REPROG:   // === Reprograms the network (except the base station) ===
+          signal ReprogNotify.notify(img_num);
           sendReply(SUCCESS, sizeof(SerialReplyPacket));
           break;
   #endif
@@ -215,8 +226,10 @@ implementation
     call NetProg.programImgAndReboot(img_num_reboot);
   }
   
-  command error_t Notify.enable() { return SUCCESS; }
-  command error_t Notify.disable() { return SUCCESS; }
+  command error_t DissNotify.enable() { return SUCCESS; }
+  command error_t DissNotify.disable() { return SUCCESS; }
+  command error_t ReprogNotify.enable() { return SUCCESS; }
+  command error_t ReprogNotify.disable() { return SUCCESS; }
   
   default command storage_addr_t DelugeStorage.getPhysicalAddress[uint8_t img_num](storage_addr_t addr) { return 0; }
 #endif