]> oss.titaniummirror.com Git - tinyos-2.x.git/commitdiff
Add TOSThreads C API for config storage abstraction
authorliang_mike <liang_mike>
Thu, 10 Sep 2009 19:18:09 +0000 (19:18 +0000)
committerliang_mike <liang_mike>
Thu, 10 Sep 2009 19:18:09 +0000 (19:18 +0000)
Parts of the code was contributed by Jo Agila Bitsch Link <jo.bitsch@cs.rwth-aachen.de>

tools/tinyos/misc/tos-storage-at45db.in
tools/tinyos/misc/tos-storage-pxa27xp30.in
tools/tinyos/misc/tos-storage-stm25p.in
tos/lib/tosthreads/csystem/CConfigStorageC.nc [new file with mode: 0644]
tos/lib/tosthreads/csystem/CConfigStorageP.nc [new file with mode: 0644]
tos/lib/tosthreads/csystem/TosThreadApiC.nc
tos/lib/tosthreads/csystem/VolumeMapC.nc
tos/lib/tosthreads/csystem/VolumeMapP.nc
tos/lib/tosthreads/csystem/tosthread_configstorage.h [new file with mode: 0644]

index 73bb63a9617d5c5311259e288fdcab463ad5a0cc..aa79f797bf6ed35d72e772107fd2b6c80269d1fb 100644 (file)
@@ -229,8 +229,8 @@ if cthreads == True:
   outFile.write("    interface BlockWrite[uint8_t volume_id]; \n")
   outFile.write("    interface LogRead[uint8_t volumeId]; \n")
   outFile.write("    interface LogWrite[uint8_t volumeId]; \n")
-#   outFile.write("    interface Mount[uint8_t volumeId]; \n")
-  outFile.write("    interface ConfigStorage[uint8_t volumeId]; \n")
+  outFile.write("    interface Mount as ConfigMount[uint8_t volumeId]; \n")
+  outFile.write("    interface ConfigStorage[uint8_t volumeId]; \n")
   outFile.write("  } \n")
   outFile.write("} \n")
   outFile.write("\n")
@@ -257,9 +257,9 @@ if cthreads == True:
       outFile.write("  VolumeMapP.SubLogWrite[" + volumeNames[i] + "] -> LogStorageC_" + volumeNames[i] + "; \n")
       outFile.write("\n")
 
-    elif volumeTypes[volumeNames[i]] == "config":
-      outFile.write("  components new ConfigStorageC(" + volumeNames[i] + ") as ConfigStorageC_" + volumeNames[i] + "; \n")
-#       outFile.write("  Mount[" + volumeNames[i] + "] = ConfigStorageC_" + volumeNames[i] + "; \n")
-      outFile.write("  ConfigStorage[" + volumeNames[i] + "] = ConfigStorageC_" + volumeNames[i] + "; \n")
+    elif volumeTypes[volumeNames[i]] == "config":
+      outFile.write("  components new ConfigStorageC(" + volumeNames[i] + ") as ConfigStorageC_" + volumeNames[i] + "; \n")
+      outFile.write("  ConfigMount[" + volumeNames[i] + "] = ConfigStorageC_" + volumeNames[i] + "; \n")
+      outFile.write("  ConfigStorage[" + volumeNames[i] + "] = ConfigStorageC_" + volumeNames[i] + "; \n")
   outFile.write("} \n")
 
index a82efd54f75aa90f8298ff1de6568f11727d5812..d5e205a670a9a439e29d44046e8d6de275c8149b 100755 (executable)
@@ -200,8 +200,8 @@ if cthreads == True:
   outFile.write("    interface BlockWrite[uint8_t volume_id]; \n")
   outFile.write("    interface LogRead[uint8_t volumeId]; \n")
   outFile.write("    interface LogWrite[uint8_t volumeId]; \n")
-#   outFile.write("    interface Mount[uint8_t volumeId]; \n")
-  outFile.write("    interface ConfigStorage[uint8_t volumeId]; \n")
+  outFile.write("    interface Mount as ConfigMount[uint8_t volumeId]; \n")
+  outFile.write("    interface ConfigStorage[uint8_t volumeId]; \n")
   outFile.write("  } \n")
   outFile.write("} \n")
   outFile.write("\n")
@@ -228,8 +228,8 @@ if cthreads == True:
       outFile.write("  VolumeMapP.SubLogWrite[" + volumeNames[i] + "] -> LogStorageC_" + volumeNames[i] + "; \n")
       outFile.write("\n")
 
-    elif volumeTypes[volumeNames[i]] == "config":
-      outFile.write("  components new ConfigStorageC(" + volumeNames[i] + ") as ConfigStorageC_" + volumeNames[i] + "; \n")
-#       outFile.write("  Mount[" + volumeNames[i] + "] = ConfigStorageC_" + volumeNames[i] + "; \n")
-      outFile.write("  ConfigStorage[" + volumeNames[i] + "] = ConfigStorageC_" + volumeNames[i] + "; \n")
+    elif volumeTypes[volumeNames[i]] == "config":
+      outFile.write("  components new ConfigStorageC(" + volumeNames[i] + ") as ConfigStorageC_" + volumeNames[i] + "; \n")
+      outFile.write("  ConfigMount[" + volumeNames[i] + "] = ConfigStorageC_" + volumeNames[i] + "; \n")
+      outFile.write("  ConfigStorage[" + volumeNames[i] + "] = ConfigStorageC_" + volumeNames[i] + "; \n")
   outFile.write("} \n")
index f1b02b785f73f46840a002827bc35070ee2aa47e..1256b8776b04d8b0c94f7e24793658121a6c0e58 100644 (file)
@@ -247,8 +247,8 @@ if cthreads == True:
   outFile.write("    interface BlockWrite[uint8_t volume_id]; \n")
   outFile.write("    interface LogRead[uint8_t volumeId]; \n")
   outFile.write("    interface LogWrite[uint8_t volumeId]; \n")
-#   outFile.write("    interface Mount[uint8_t volumeId]; \n")
-  outFile.write("    interface ConfigStorage[uint8_t volumeId]; \n")
+  outFile.write("    interface Mount as ConfigMount[uint8_t volumeId]; \n")
+  outFile.write("    interface ConfigStorage[uint8_t volumeId]; \n")
   outFile.write("  } \n")
   outFile.write("} \n")
   outFile.write("\n")
@@ -275,8 +275,8 @@ if cthreads == True:
       outFile.write("  VolumeMapP.SubLogWrite[" + volumeNames[i] + "] -> LogStorageC_" + volumeNames[i] + "; \n")
       outFile.write("\n")
 
-    elif volumeTypes[volumeNames[i]] == "config":
-      outFile.write("  components new ConfigStorageC(" + volumeNames[i] + ") as ConfigStorageC_" + volumeNames[i] + "; \n")
-#       outFile.write("  Mount[" + volumeNames[i] + "] = ConfigStorageC_" + volumeNames[i] + "; \n")
-      outFile.write("  ConfigStorage[" + volumeNames[i] + "] = ConfigStorageC_" + volumeNames[i] + "; \n")
+    elif volumeTypes[volumeNames[i]] == "config":
+      outFile.write("  components new ConfigStorageC(" + volumeNames[i] + ") as ConfigStorageC_" + volumeNames[i] + "; \n")
+      outFile.write("  ConfigMount[" + volumeNames[i] + "] = ConfigStorageC_" + volumeNames[i] + "; \n")
+      outFile.write("  ConfigStorage[" + volumeNames[i] + "] = ConfigStorageC_" + volumeNames[i] + "; \n")
   outFile.write("} \n")
diff --git a/tos/lib/tosthreads/csystem/CConfigStorageC.nc b/tos/lib/tosthreads/csystem/CConfigStorageC.nc
new file mode 100644 (file)
index 0000000..995065b
--- /dev/null
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2009 RWTH Aachen 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 J\97 çgila Bitsch Link <jo.bitsch@cs.rwth-aachen.de>
+ */
+
+configuration CConfigStorageC {}
+
+implementation {
+  components CConfigStorageP,
+             BlockingConfigStorageP,
+             VolumeMapC;
+
+  CConfigStorageP.BlockingConfig -> BlockingConfigStorageP;
+  CConfigStorageP.BlockingMount -> BlockingConfigStorageP;
+
+  BlockingConfigStorageP.ConfigMount -> VolumeMapC.ConfigMount;
+  BlockingConfigStorageP.ConfigStorage -> VolumeMapC.ConfigStorage;
+}
diff --git a/tos/lib/tosthreads/csystem/CConfigStorageP.nc b/tos/lib/tosthreads/csystem/CConfigStorageP.nc
new file mode 100644 (file)
index 0000000..bb67f9c
--- /dev/null
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 2009 RWTH Aachen 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 J\97 çgila Bitsch Link <jo.bitsch@cs.rwth-aachen.de>
+ * @author Chieh-Jan Mike Liang <cliang4@cs.jhu.edu>
+ */
+
+module CConfigStorageP {
+  uses {
+    interface BlockingConfig[uint8_t volume_id];
+    interface BlockingMount[uint8_t volume_id];
+  }
+}
+
+implementation {
+  error_t volumeConfigMount(uint8_t volumeId) @C() AT_SPONTANEOUS {
+    return call BlockingMount.mount[volumeId]();
+  }
+  
+  error_t volumeConfigRead(uint8_t volumeId, storage_addr_t addr, void* buf, storage_len_t* len) @C() AT_SPONTANEOUS {
+    return call BlockingConfig.read[volumeId](addr, buf, len);
+  }
+  
+  error_t volumeConfigWrite(uint8_t volumeId, storage_addr_t addr, void* buf, storage_len_t* len) @C() AT_SPONTANEOUS {
+    return call BlockingConfig.write[volumeId](addr, buf, len);
+  }
+  
+  error_t volumeConfigCommit(uint8_t volumeId) @C() AT_SPONTANEOUS {
+    return call BlockingConfig.commit[volumeId]();
+  }
+  
+  storage_len_t volumeConfigGetSize(uint8_t volumeId) @C() AT_SPONTANEOUS {
+    return call BlockingConfig.getSize[volumeId]();
+  }
+  
+  bool volumeConfigValid(uint8_t volumeId) @C() AT_SPONTANEOUS {
+    return call BlockingConfig.valid[volumeId]();
+  }
+}
index 17803b991fb259260e88fab706196e93d9103267..da04a860bb1ddf6c8e87fe10fb0009a9d15bd26e 100644 (file)
@@ -31,6 +31,7 @@
  
 /**
  * @author Kevin Klues <klueska@cs.stanford.edu>
+ * @author Chieh-Jan Mike Liang <cliang4@cs.jhu.edu>
  */
  
 #include "tosthread.h"
@@ -67,6 +68,9 @@ implementation {
   #if defined(TOSTHREAD_LOGSTORAGE_H) || defined(TOSTHREAD_DYNAMIC_LOADER)
     components CLogStorageC;
   #endif 
+  #if defined(TOSTHREAD_CONFIGSTORAGE_H) || defined(TOSTHREAD_DYNAMIC_LOADER)
+    components CConfigStorageC;
+  #endif
   #if defined(TOSTHREAD_COLLECTION_H) || defined(TOSTHREAD_DYNAMIC_LOADER)
     components CCollectionC;
   #endif 
index 2821a08c31e847662496d09fec1f5d10f3304fd9..ee2126fdffbabec327b12b39be9e9043f3416e4f 100644 (file)
@@ -22,6 +22,7 @@
 
 /**
  * @author Chieh-Jan Mike Liang <cliang4@cs.jhu.edu>
+ * @author J\97 çgila Bitsch Link <jo.bitsch@cs.rwth-aachen.de>
  */
 
 configuration VolumeMapC { 
@@ -30,6 +31,8 @@ configuration VolumeMapC {
     interface BlockWrite[uint8_t volume_id];
     interface LogRead[uint8_t volume_id];
     interface LogWrite[uint8_t volume_id];
+    interface ConfigStorage[uint8_t volume_id];
+    interface Mount[uint8_t volume_id];
   }
 } 
 
@@ -40,4 +43,7 @@ implementation {
   BlockWrite = VolumeMapP;
   LogRead = VolumeMapP;
   LogWrite = VolumeMapP;
+  
+  ConfigStorage = VolumeMapP;
+  Mount = VolumeMapP;
 } 
index 5c810ddab21c5bf5e124c6394db0572b48174f91..2896fa19d5dc109f5da43e67b0f13aefa6871cb8 100644 (file)
@@ -22,6 +22,7 @@
 
 /**
  * @author Chieh-Jan Mike Liang <cliang4@cs.jhu.edu>
+ * @author J\97 çgila Bitsch Link <jo.bitsch@cs.rwth-aachen.de>
  */
 
 module VolumeMapP {
@@ -30,6 +31,8 @@ module VolumeMapP {
     interface BlockWrite[uint8_t volume_id];
     interface LogRead[uint8_t volume_id];
     interface LogWrite[uint8_t volume_id];
+    interface ConfigStorage[uint8_t volume_id];
+    interface Mount[uint8_t volume_id];
   }
   
   uses { 
@@ -37,6 +40,8 @@ module VolumeMapP {
     interface BlockWrite as SubBlockWrite[uint8_t volume_id]; 
     interface LogRead as SubLogRead[uint8_t volume_id];
     interface LogWrite as SubLogWrite[uint8_t volume_id];
+    interface ConfigStorage as SubConfigStorage[uint8_t volume_id];
+    interface Mount as SubMount[uint8_t volume_id];
   }
 }
 
@@ -204,4 +209,73 @@ implementation {
   default event void LogWrite.appendDone[uint8_t volume_id](void* buf, storage_len_t len, bool recordsLost, error_t error) {}
   default event void LogWrite.eraseDone[uint8_t volume_id](error_t error) {}
   default event void LogWrite.syncDone[uint8_t volume_id](error_t error) {}
+  
+  command error_t ConfigStorage.read[uint8_t volume_id](storage_addr_t addr, void* buf, storage_len_t len) {
+    return call SubConfigStorage.read[volume_id](addr, buf, len);
+  }
+  
+  event void SubConfigStorage.readDone[uint8_t volume_id](storage_addr_t addr, void* buf, storage_len_t len, error_t error) {
+    signal ConfigStorage.readDone[volume_id](addr, buf, len, error);
+  }
+  
+  command error_t ConfigStorage.write[uint8_t volume_id](storage_addr_t addr, void* buf, storage_len_t len) {
+    return call SubConfigStorage.write[volume_id](addr, buf, len);
+  }
+  
+  event void SubConfigStorage.writeDone[uint8_t volume_id](storage_addr_t addr, void* buf, storage_len_t len, error_t error) {
+    signal ConfigStorage.writeDone[volume_id](addr, buf, len, error);
+  }
+  
+  command error_t ConfigStorage.commit[uint8_t volume_id]() {
+    return call SubConfigStorage.commit[volume_id]();
+  }
+  
+  event void SubConfigStorage.commitDone[uint8_t volume_id](error_t error) {
+    signal ConfigStorage.commitDone[volume_id](error);
+  }
+
+  command storage_len_t ConfigStorage.getSize[uint8_t volume_id]() {
+    return call SubConfigStorage.getSize[volume_id]();
+  }
+  
+  command bool ConfigStorage.valid[uint8_t volume_id]() {
+    return call SubConfigStorage.valid[volume_id]();
+  }
+  
+  command error_t Mount.mount[uint8_t volume_id]() {
+    return call SubMount.mount[volume_id]();
+  }
+  
+  event void SubMount.mountDone[uint8_t volume_id](error_t error) {
+    signal Mount.mountDone[volume_id](error);
+  }
+  
+  default command error_t SubConfigStorage.read[uint8_t volume_id](storage_addr_t addr, void* buf, storage_len_t len) {
+    return FAIL;
+  }
+
+  default command error_t SubConfigStorage.write[uint8_t volume_id](storage_addr_t addr, void* buf, storage_len_t len) {
+    return FAIL;
+  }
+  
+  default command error_t SubConfigStorage.commit[uint8_t volume_id]() {
+    return FAIL;
+  }
+
+  default command storage_len_t SubConfigStorage.getSize[uint8_t volume_id]() {
+    return FAIL;
+  }
+  
+  default command bool SubConfigStorage.valid[uint8_t volume_id]() {
+    return FAIL;
+  }
+  
+  default command error_t SubMount.mount[uint8_t volume_id]() {
+    return FAIL;
+  }
+
+  default event void ConfigStorage.commitDone[uint8_t volume_id](error_t error) {}
+  default event void ConfigStorage.writeDone[uint8_t volume_id](storage_addr_t addr, void* buf, storage_len_t len, error_t error) {}  
+  default event void ConfigStorage.readDone[uint8_t volume_id](storage_addr_t addr, void* buf, storage_len_t len, error_t error) {}
+  default event void Mount.mountDone[uint8_t volume_id](error_t error) {}
 }
diff --git a/tos/lib/tosthreads/csystem/tosthread_configstorage.h b/tos/lib/tosthreads/csystem/tosthread_configstorage.h
new file mode 100644 (file)
index 0000000..51d5d30
--- /dev/null
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2009 RWTH Aachen 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 J\97 çgila Bitsch Link <jo.bitsch@cs.rwth-aachen.de>
+ */
+
+#ifndef TOSTHREAD_CONFIGSTORAGE_H
+#define TOSTHREAD_CONFIGSTORAGE_H
+
+#include "Storage.h"
+
+extern error_t volumeConfigMount(uint8_t volumeId);
+extern error_t volumeConfigRead(uint8_t volumeId, storage_addr_t addr, void* buf, storage_len_t* len);
+extern error_t volumeConfigWrite(uint8_t volumeId, storage_addr_t addr, void* buf, storage_len_t* len);
+extern error_t volumeConfigCommit(uint8_t volumeId);
+extern storage_len_t volumeConfigGetSize(uint8_t volumeId);
+extern bool volumeConfigValid(uint8_t volumeId);
+
+#endif   // TOSTHREAD_CONFIGSTORAGE_H