]> oss.titaniummirror.com Git - tinyos-2.x.git/commitdiff
Update to tos-storage-* tools to support a '-t' flag to generate a VolumeMapC.nc...
authorklueska <klueska>
Fri, 23 May 2008 01:04:35 +0000 (01:04 +0000)
committerklueska <klueska>
Fri, 23 May 2008 01:04:35 +0000 (01:04 +0000)
tools/configure.ac
tools/tinyos/misc/Makefile.am
tools/tinyos/misc/tos-storage-at45db.1
tools/tinyos/misc/tos-storage-at45db.in
tools/tinyos/misc/tos-storage-pxa27xp30
tools/tinyos/misc/tos-storage-pxa27xp30.1
tools/tinyos/misc/tos-storage-pxa27xp30.in
tools/tinyos/misc/tos-storage-stm25p.1
tools/tinyos/misc/tos-storage-stm25p.in

index 37c55d3091234f3d50b8be9f27b0631a816f4321..7034cf457b85febd2a3b150c06ff40122152396f 100644 (file)
@@ -143,6 +143,7 @@ AC_OUTPUT(
        tinyos/misc/tos-write-image
        tinyos/misc/tos-storage-at45db
        tinyos/misc/tos-storage-stm25p
+       tinyos/misc/tos-storage-pxa27xp30
        tinyos/misc/Makefile
        tinyos/ncc/Makefile
        tinyos/ncc/mig
index 8dfc65b573c2e1dd13b12859d3ed97c4bef06f0a..295fad4f0db5448baefeec802dd48d2075164369 100644 (file)
@@ -11,6 +11,7 @@ dist_man_MANS = tos-check-env.1       \
                 tos-set-symbols.1      \
                 tos-storage-at45db.1   \
                 tos-storage-stm25p.1   \
+                tos-storage-pxa27xp30.1        \
                 tos-write-image.1      \
                tos-build-deluge-image.1 \
                tos-deluge.1
@@ -28,6 +29,7 @@ bin_SCRIPTS = tos-ident-flags \
              tos-check-env \
              tos-storage-stm25p \
              tos-storage-at45db \
+             tos-storage-pxa27xp30     \
              tos-build-deluge-image \
              tos-deluge
 
index 48444d905189b68646b57411461ae5aea38a6650..885eabeaa5999f065455917d39a0708cfdca395b 100644 (file)
@@ -5,25 +5,28 @@
 tos-storage-at45db - Generate storage volume description code
 .SH SYNOPSIS
 
-\fBtos-storage-at45db\fR \fIplatform-directory\fR
+\fBtos-storage-at45db\fR [\fB-t\fR] \fIplatform-directory\fR
 .SH DESCRIPTION
 
 \fBtos-storage-at45db\fR reads a user specification describing the layout
 of storage volumes on an Atmel AT45DB-family flash chip, and generates code
 describing that layout for use by the TinyOS 2.0 storage subsystem.  The
-user specification is in XML and is read from standard input. The code is
-written to standard output.
+user specification is in XML and is read from standard input. With all options,
+the code for a header file is written to standard output.  With the 
+optional \fB-t\fR flag specified, a VolumeMapC.nc file is generated that provides 
+interfaces to all the storage volume abstractions defined in the XML file.
 
-The argument should specify the platform directory for the current
-compilation target; this is necessary for the correct handling of 
-file include statements in the XML input.
+The mandatory \fIplatform-directory\fR argument should specify the platform 
+directory for the current compilation target; this is necessary for the correct 
+handling of file include statements in the XML input.
 
 This program is normally invoked automatically by the TinyOS build system
 when your application directory contains a \fBvolumes-at45db.xml\fR file.
 .SH EXAMPLES
 
-  tos-storage-at45db /opt/tinyos-2.x/tos/platforms/mica2 \\
+  tos-storage-at45db -t /opt/tinyos-2.x/tos/platforms/mica2 \\
       <volumes-at45db.xml >build/mica2/StorageVolumes.h
 .SH SEE ALSO
 
-.IR tos-storage-stm25p (1)
+.IR tos-storage-stm25p (1) 
+.IR tos-storage-pxa27xp30 (1)
index c46719a5024eab2b4addaf8a20c3774240683a92..73bb63a9617d5c5311259e288fdcab463ad5a0cc 100644 (file)
@@ -13,26 +13,46 @@ from re import match
 from sys import *
 from subprocess import Popen, PIPE
 
-# print an error message and exit
-def nfail(s):
-  stderr.write(s + "\n")
-  exit(2)
+from getopt import *
+import string
+import commands
+#New way of handling arguments........
+try:
+  opts, args = getopt(argv[1:], "t", [])
+except GetoptError, err:
+  print str(err) # will print something like "option -a not recognized"
+  stderr.write("Usage: tos-storage-at45db [-t] <platform directory>\n")
+  
+cthreads = False
+for o, a in opts:
+  if o == "-t":
+    cthreads = True
+  else:
+    assert False, "unhandled option"
 
-if len(argv) == 2:
-  platformdir = argv[1]
+if len( args ) == 1:
+  platformdir = args[0]
   # This gives the whole string when there's no / in platformdir
-  platform = platformdir[platformdir.rfind("/") + 1:]
-elif len(argv) == 1:
+  platform = platformdir[platformdir.rfind( "/" ) + 1:]
+elif len( args ) == 0:
   platformdir = ""
   platform = ""
 else:
-  nfail("Usage: tos-storage-at45db <platform directory>")
+  stderr.write("Usage: tos-storage-at45db [-t] <platform directory>\n")
+
+# print an error message and exit
+def nfail(s):
+  stderr.write(s + "\n")
+  exit(2)
 
 sector_size = 256
 flash_size = 2048 # in sectors
 
 volumes = {}
 volmap = []
+volumeNames = []
+volumeTypes = dict()
+volumeOptions = dict()
 
 def check_volume(name, base, size):
   if base == "":
@@ -130,11 +150,20 @@ def volumeparse(file, fname, depth):
     name = volume.getAttribute("name")
     size = volume.getAttribute("size")
     base = volume.getAttribute("base")
+    type = string.lower(volume.getAttribute("type"))
+    isCircular = string.upper(volume.getAttribute("circular"))
+    if isCircular == "":
+      isCircular = "FALSE"
     if name == None:
       nfail("name omitted in volume " + fname)
     if size == None:
       nfail("size omitted in volume %s %s" % (name, fname))
     check_volume(name, base, size)
+    
+    volumeNames.append( "VOLUME_" + name )
+    volumeTypes["VOLUME_" + name] = type
+    volumeOptions["VOLUME_" + name] = isCircular
+    
   for include in dom.documentElement.getElementsByTagName("include"):
     included = include.firstChild
     if included != None and included.nodeType == included.TEXT_NODE:
@@ -189,3 +218,48 @@ for (vname, vbase, vsize) in volmap:
 print "#undef VB"
 print "#endif"
 
+# output nc file for threads
+if cthreads == True:
+  outFile = open(commands.getstatusoutput("pwd")[1] + "/VolumeMapC.nc", "w")
+  outFile.write("#include \"StorageVolumes.h\" \n")
+  outFile.write("\n")
+  outFile.write("configuration VolumeMapC { \n")
+  outFile.write("  provides { \n")
+  outFile.write("    interface BlockRead[uint8_t volume_id]; \n")
+  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("  } \n")
+  outFile.write("} \n")
+  outFile.write("\n")
+  outFile.write("implementation { \n")
+  outFile.write("  components VolumeMapP; \n")
+  outFile.write("\n")
+  outFile.write("  BlockRead = VolumeMapP; \n")
+  outFile.write("  BlockWrite = VolumeMapP; \n")
+  outFile.write("  LogRead = VolumeMapP; \n")
+  outFile.write("  LogWrite = VolumeMapP; \n")
+
+  for i in range(len(volumeNames)):
+    if volumeTypes[volumeNames[i]] == "block":
+      outFile.write("\n")
+      outFile.write("  components new BlockStorageC(" + volumeNames[i] + ") as BlockStorageC_" + volumeNames[i] + "; \n")
+      outFile.write("  VolumeMapP.SubBlockRead[" + volumeNames[i] + "] -> BlockStorageC_" + volumeNames[i] + "; \n")
+      outFile.write("  VolumeMapP.SubBlockWrite[" + volumeNames[i] + "] -> BlockStorageC_" + volumeNames[i] + "; \n")
+      outFile.write("\n")
+      
+    elif volumeTypes[volumeNames[i]] == "log":
+      outFile.write("\n")      
+      outFile.write("  components new LogStorageC(" + volumeNames[i] + ", " + volumeOptions[volumeNames[i]] + ") as LogStorageC_" + volumeNames[i] + "; \n")
+      outFile.write("  VolumeMapP.SubLogRead[" + volumeNames[i] + "] -> LogStorageC_" + volumeNames[i] + "; \n")
+      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")
+  outFile.write("} \n")
+
index 120dd0b69e4c84b9c85ffc814546c843af309fd8..04c23fccb04c119e01c3e6486638852635aa4445 100755 (executable)
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/Library/Frameworks/Python.framework/Versions/Current/bin/python
 # -*- python -*-
 # Copyright (c) 2005-2006 Arch Rock Corporation
 # All rights reserved.
@@ -40,6 +40,33 @@ from re import match
 from sys import *
 from xml.dom import minidom
 
+from getopt import *
+import string
+import commands
+#New way of handling arguments........
+try:
+  opts, args = getopt(argv[1:], "t", [])
+except GetoptError, err:
+  print str(err) # will print something like "option -a not recognized"
+  stderr.write( "Usage: tos-storage-stm25p [-t] <platform directory>\n" )
+  
+if len( args ) == 1:
+  platformdir = args[0]
+  # This gives the whole string when there's no / in platformdir
+  platform = platformdir[platformdir.rfind( "/" ) + 1:]
+elif len( args ) == 0:
+  platformdir = ""
+  platform = ""
+else:
+  stderr.write( "Usage: tos-storage-stm25p [-t] <platform directory>\n" )
+  
+cthreads = False
+for o, a in opts:
+  if o == "-t":
+    cthreads = True
+  else:
+    assert False, "unhandled option"
+
 NUM_SECTORS = 16
 SECTOR_SIZE = 2097152
 
@@ -48,6 +75,8 @@ volumes = {}
 volumeNames = []
 volumeSizes = []
 volumeOffsets = []
+volumeTypes = dict()
+volumeOptions = dict()
 freeSectors = NUM_SECTORS*[ True ]
 
 def error_exit( s ):
@@ -64,6 +93,7 @@ volumes [ "PXARESERVED" ] = "blah"
 volumeNames.append( "VOLUME_PXARESERVED" )
 volumeSizes.append( 1 )
 volumeOffsets.append( 0 )
+volumeTypes[ "VOLUME_PXARESERVED" ] = ""
 freeSectors[ 0 ] = False
 
 # extract information
@@ -71,6 +101,11 @@ for volume in dom.documentElement.getElementsByTagName( "volume" ):
     name = volume.getAttribute( "name" )
     size = volume.getAttribute( "size" )
     base = volume.getAttribute( "base" )
+    type = string.lower(volume.getAttribute("type"))
+    isCircular = string.upper(volume.getAttribute("circular"))
+    if isCircular == "":
+      isCircular = "FALSE"
+          
     if name == "":
         error_exit( "volume has no name" )
     elif not match( "^[a-zA-Z0-9_]+$", name ):
@@ -101,6 +136,9 @@ for volume in dom.documentElement.getElementsByTagName( "volume" ):
 
     volumeNames.append( "VOLUME_" + name )
     volumeSizes.append( size / SECTOR_SIZE )
+    volumeTypes["VOLUME_" + name] = type
+    volumeOptions["VOLUME_" + name] = isCircular
+      
     if base == "":
         volumeOffsets.append( -1 )
     else:
@@ -150,3 +188,48 @@ print "};"
 
 print ""
 print "#endif"
+
+# output nc file for threads
+if cthreads == True:
+  outFile = open(commands.getstatusoutput("pwd")[1] + "/VolumeMapC.nc", "w")
+  outFile.write("#include \"StorageVolumes.h\" \n")
+  outFile.write("\n")
+  outFile.write("configuration VolumeMapC { \n")
+  outFile.write("  provides { \n")
+  outFile.write("    interface BlockRead[uint8_t volume_id]; \n")
+  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("  } \n")
+  outFile.write("} \n")
+  outFile.write("\n")
+  outFile.write("implementation { \n")
+  outFile.write("  components VolumeMapP; \n")
+  outFile.write("\n")
+  outFile.write("  BlockRead = VolumeMapP; \n")
+  outFile.write("  BlockWrite = VolumeMapP; \n")
+  outFile.write("  LogRead = VolumeMapP; \n")
+  outFile.write("  LogWrite = VolumeMapP; \n")
+
+  for i in range(len(volumeNames)):
+    if volumeTypes[volumeNames[i]] == "block":
+      outFile.write("\n")
+      outFile.write("  components new BlockStorageC(" + volumeNames[i] + ") as BlockStorageC_" + volumeNames[i] + "; \n")
+      outFile.write("  VolumeMapP.SubBlockRead[" + volumeNames[i] + "] -> BlockStorageC_" + volumeNames[i] + "; \n")
+      outFile.write("  VolumeMapP.SubBlockWrite[" + volumeNames[i] + "] -> BlockStorageC_" + volumeNames[i] + "; \n")
+      outFile.write("\n")
+      
+    elif volumeTypes[volumeNames[i]] == "log":
+      outFile.write("\n")      
+      outFile.write("  components new LogStorageC(" + volumeNames[i] + ", " + volumeOptions[volumeNames[i]] + ") as LogStorageC_" + volumeNames[i] + "; \n")
+      outFile.write("  VolumeMapP.SubLogRead[" + volumeNames[i] + "] -> LogStorageC_" + volumeNames[i] + "; \n")
+      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")
+  outFile.write("} \n")
index 61f065b1d20537d35d9591c6ceb8756545b66b61..47e42f3c391392a3ebdaf139b9d8efd35a4b0076 100644 (file)
@@ -8,18 +8,26 @@ tos-storage-pxa27xp30 - Generate storage volume description code
 \fBtos-storage-pxa27xp30\fR
 .SH DESCRIPTION
 
-\fBtos-storage-pxa27xp30\fR reads a user specification describing the
-layout of storage volumes on an embedded P30 flash in the Intel Xscale
-PXA27X series processor, and generates code describing that layout for
-use by the TinyOS 2.0 storage subsystem.  The user specification is in
-XML and is read from standard input. The code is written to standard
-output.
+\fBtos-storage-pxa27xp30\fR reads a user specification describing the layout of
+storage volumes on an embedded P30 flash in the Intel Xscale PXA27X series
+processor, and generates code describing that layout for use by the TinyOS 2.0
+storage subsystem.  The user specification is in XML and is read from standard
+input. With all options, the code for a header file is written to standard
+output.  With the optional \fB-t\fR flag specified, a VolumeMapC.nc file is
+generated that provides interfaces to all the storage volume abstractions
+defined in the XML file.
+
+The mandatory \fIplatform-directory\fR argument should specify the platform 
+directory for the current compilation target; this is necessary for the correct 
+handling of file include statements in the XML input.
 
 This program is normally invoked automatically by the TinyOS build system
 when your application directory contains a \fBvolumes-pxa27xp30.xml\fR file.
 .SH EXAMPLES
 
-  tos-storage-pxa27xp30 <volumes-pxa27xp30.xml >build/telosb/StorageVolumes.h
+  tos-storage-pxa27xp30 -t /opt/tinyos-2.x/tos/platforms/intelmote2 \\
+      <volumes-pxa27xp30.xml >build/telosb/StorageVolumes.h
 .SH SEE ALSO
 
-.IR tos-storage-pxa27xp30 (1)
+.IR tos-storage-stm25p (1) 
+.IR tos-storage-at45db (1) 
\ No newline at end of file
index 275b50078c39de713d227cad0b628ec45bfaa286..a82efd54f75aa90f8298ff1de6568f11727d5812 100755 (executable)
@@ -1,4 +1,4 @@
-#!@pythonpath@
+#!@pathpython@
 # -*- python -*-
 # Copyright (c) 2005-2006 Arch Rock Corporation
 # All rights reserved.
@@ -40,6 +40,33 @@ from re import match
 from sys import *
 from xml.dom import minidom
 
+from getopt import *
+import string
+import commands
+#New way of handling arguments........
+try:
+  opts, args = getopt(argv[1:], "t", [])
+except GetoptError, err:
+  print str(err) # will print something like "option -a not recognized"
+  stderr.write( "Usage: tos-storage-stm25p [-t] <platform directory>\n" )
+  
+if len( args ) == 1:
+  platformdir = args[0]
+  # This gives the whole string when there's no / in platformdir
+  platform = platformdir[platformdir.rfind( "/" ) + 1:]
+elif len( args ) == 0:
+  platformdir = ""
+  platform = ""
+else:
+  stderr.write( "Usage: tos-storage-stm25p [-t] <platform directory>\n" )
+  
+cthreads = False
+for o, a in opts:
+  if o == "-t":
+    cthreads = True
+  else:
+    assert False, "unhandled option"
+
 NUM_SECTORS = 16
 SECTOR_SIZE = 2097152
 
@@ -48,6 +75,8 @@ volumes = {}
 volumeNames = []
 volumeSizes = []
 volumeOffsets = []
+volumeTypes = dict()
+volumeOptions = dict()
 freeSectors = NUM_SECTORS*[ True ]
 
 def error_exit( s ):
@@ -64,6 +93,7 @@ volumes [ "PXARESERVED" ] = "blah"
 volumeNames.append( "VOLUME_PXARESERVED" )
 volumeSizes.append( 1 )
 volumeOffsets.append( 0 )
+volumeTypes[ "VOLUME_PXARESERVED" ] = ""
 freeSectors[ 0 ] = False
 
 # extract information
@@ -71,6 +101,11 @@ for volume in dom.documentElement.getElementsByTagName( "volume" ):
     name = volume.getAttribute( "name" )
     size = volume.getAttribute( "size" )
     base = volume.getAttribute( "base" )
+    type = string.lower(volume.getAttribute("type"))
+    isCircular = string.upper(volume.getAttribute("circular"))
+    if isCircular == "":
+      isCircular = "FALSE"
+          
     if name == "":
         error_exit( "volume has no name" )
     elif not match( "^[a-zA-Z0-9_]+$", name ):
@@ -101,6 +136,9 @@ for volume in dom.documentElement.getElementsByTagName( "volume" ):
 
     volumeNames.append( "VOLUME_" + name )
     volumeSizes.append( size / SECTOR_SIZE )
+    volumeTypes["VOLUME_" + name] = type
+    volumeOptions["VOLUME_" + name] = isCircular
+      
     if base == "":
         volumeOffsets.append( -1 )
     else:
@@ -150,3 +188,48 @@ print "};"
 
 print ""
 print "#endif"
+
+# output nc file for threads
+if cthreads == True:
+  outFile = open(commands.getstatusoutput("pwd")[1] + "/VolumeMapC.nc", "w")
+  outFile.write("#include \"StorageVolumes.h\" \n")
+  outFile.write("\n")
+  outFile.write("configuration VolumeMapC { \n")
+  outFile.write("  provides { \n")
+  outFile.write("    interface BlockRead[uint8_t volume_id]; \n")
+  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("  } \n")
+  outFile.write("} \n")
+  outFile.write("\n")
+  outFile.write("implementation { \n")
+  outFile.write("  components VolumeMapP; \n")
+  outFile.write("\n")
+  outFile.write("  BlockRead = VolumeMapP; \n")
+  outFile.write("  BlockWrite = VolumeMapP; \n")
+  outFile.write("  LogRead = VolumeMapP; \n")
+  outFile.write("  LogWrite = VolumeMapP; \n")
+
+  for i in range(len(volumeNames)):
+    if volumeTypes[volumeNames[i]] == "block":
+      outFile.write("\n")
+      outFile.write("  components new BlockStorageC(" + volumeNames[i] + ") as BlockStorageC_" + volumeNames[i] + "; \n")
+      outFile.write("  VolumeMapP.SubBlockRead[" + volumeNames[i] + "] -> BlockStorageC_" + volumeNames[i] + "; \n")
+      outFile.write("  VolumeMapP.SubBlockWrite[" + volumeNames[i] + "] -> BlockStorageC_" + volumeNames[i] + "; \n")
+      outFile.write("\n")
+      
+    elif volumeTypes[volumeNames[i]] == "log":
+      outFile.write("\n")      
+      outFile.write("  components new LogStorageC(" + volumeNames[i] + ", " + volumeOptions[volumeNames[i]] + ") as LogStorageC_" + volumeNames[i] + "; \n")
+      outFile.write("  VolumeMapP.SubLogRead[" + volumeNames[i] + "] -> LogStorageC_" + volumeNames[i] + "; \n")
+      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")
+  outFile.write("} \n")
index b558bd22cb50c545b2985ec943d043efab826b02..a7f04a0c5385e480ed52a446a3f3504ab399fc01 100644 (file)
@@ -11,19 +11,22 @@ tos-storage-stm25p - Generate storage volume description code
 \fBtos-storage-stm25p\fR reads a user specification describing the layout
 of storage volumes on an ST M25P80 flash chip, and generates code
 describing that layout for use by the TinyOS 2.0 storage subsystem.  The
-user specification is in XML and is read from standard input. The code is
-written to standard output.
+user specification is in XML and is read from standard input. With all options,
+the code for a header file is written to standard output.  With the 
+optional \fB-t\fR flag specified, a VolumeMapC.nc file is generated that provides 
+interfaces to all the storage volume abstractions defined in the XML file.
 
-The argument should specify the platform directory for the current
-compilation target; this is necessary for the correct handling of 
-file include statements in the XML input.
+The mandatory \fIplatform-directory\fR argument should specify the platform 
+directory for the current compilation target; this is necessary for the correct 
+handling of file include statements in the XML input.
 
 This program is normally invoked automatically by the TinyOS build system
 when your application directory contains a \fBvolumes-stm25p.xml\fR file.
 .SH EXAMPLES
 
-  tos-storage-stm25p /opt/tinyos-2.x/tos/platforms/telosb \\
+  tos-storage-stm25p -t /opt/tinyos-2.x/tos/platforms/telosb \\
       <volumes-stm25p.xml >build/telosb/StorageVolumes.h
 .SH SEE ALSO
 
-.IR tos-storage-stm25p (1)
+.IR tos-storage-pxa27xp30 (1)
+.IR tos-storage-at45db (1) 
index 79cb09885d976fbffd770a318a6e98ed5497290e..f1b02b785f73f46840a002827bc35070ee2aa47e 100644 (file)
@@ -39,6 +39,7 @@
 
 # @author Jonathan Hui <jhui@archedrock.com>
 # @author David Gay
+# @author Kevin Klues <klueska@cs.stanford.edu>
 #
 # $Revision$
 # $Date$
@@ -50,6 +51,33 @@ from xml.dom import *
 from xml.dom.minidom import *
 from subprocess import Popen, PIPE
 
+from getopt import *
+import string
+import commands
+#New way of handling arguments........
+try:
+  opts, args = getopt(argv[1:], "t", [])
+except GetoptError, err:
+  print str(err) # will print something like "option -a not recognized"
+  stderr.write( "Usage: tos-storage-stm25p [-t] <platform directory>\n" )
+  
+if len( args ) == 1:
+  platformdir = args[0]
+  # This gives the whole string when there's no / in platformdir
+  platform = platformdir[platformdir.rfind( "/" ) + 1:]
+elif len( args ) == 0:
+  platformdir = ""
+  platform = ""
+else:
+  stderr.write( "Usage: tos-storage-stm25p [-t] <platform directory>\n" )
+  
+cthreads = False
+for o, a in opts:
+  if o == "-t":
+    cthreads = True
+  else:
+    assert False, "unhandled option"
+
 def error_exit( s ):
     stderr.write( "ERROR: " + s + "\n" )
     exit( 2 )
@@ -92,18 +120,10 @@ volumes = {}
 volumeNames = []
 volumeSizes = []
 volumeOffsets = []
+volumeTypes = dict()
+volumeOptions = dict()
 freeSectors = NUM_SECTORS*[ True ]
 
-if len( argv ) == 2:
-  platformdir = argv[1]
-  # This gives the whole string when there's no / in platformdir
-  platform = platformdir[platformdir.rfind( "/" ) + 1:]
-elif len( argv ) == 1:
-  platformdir = ""
-  platform = ""
-else:
-  error_exit( "Usage: tos-storage-stm25p <platform directory>" )
-
 def volumeparse( file, fname, depth ):
   if depth > 10:
     error_exit( "include nesting too deep - check for cycles" )
@@ -119,6 +139,11 @@ def volumeparse( file, fname, depth ):
       name = volume.getAttribute( "name" )
       size = volume.getAttribute( "size" )
       base = volume.getAttribute( "base" )
+      type = string.lower(volume.getAttribute("type"))
+      isCircular = string.upper(volume.getAttribute("circular"))
+      if isCircular == "":
+          isCircular = "FALSE"
+      
       if name == "":
           error_exit( "volume has no name" )
       elif not match( "^[a-zA-Z0-9_]+$", name ):
@@ -148,6 +173,9 @@ def volumeparse( file, fname, depth ):
 
       volumeNames.append( "VOLUME_" + name )
       volumeSizes.append( size / SECTOR_SIZE )
+      volumeTypes["VOLUME_" + name] = type
+      volumeOptions["VOLUME_" + name] = isCircular
+      
       if base == "":
           volumeOffsets.append( -1 )
       else:
@@ -207,3 +235,48 @@ print "};"
 
 print ""
 print "#endif"
+
+# output nc file for threads
+if cthreads == True:
+  outFile = open(commands.getstatusoutput("pwd")[1] + "/VolumeMapC.nc", "w")
+  outFile.write("#include \"StorageVolumes.h\" \n")
+  outFile.write("\n")
+  outFile.write("configuration VolumeMapC { \n")
+  outFile.write("  provides { \n")
+  outFile.write("    interface BlockRead[uint8_t volume_id]; \n")
+  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("  } \n")
+  outFile.write("} \n")
+  outFile.write("\n")
+  outFile.write("implementation { \n")
+  outFile.write("  components VolumeMapP; \n")
+  outFile.write("\n")
+  outFile.write("  BlockRead = VolumeMapP; \n")
+  outFile.write("  BlockWrite = VolumeMapP; \n")
+  outFile.write("  LogRead = VolumeMapP; \n")
+  outFile.write("  LogWrite = VolumeMapP; \n")
+
+  for i in range(len(volumeNames)):
+    if volumeTypes[volumeNames[i]] == "block":
+      outFile.write("\n")
+      outFile.write("  components new BlockStorageC(" + volumeNames[i] + ") as BlockStorageC_" + volumeNames[i] + "; \n")
+      outFile.write("  VolumeMapP.SubBlockRead[" + volumeNames[i] + "] -> BlockStorageC_" + volumeNames[i] + "; \n")
+      outFile.write("  VolumeMapP.SubBlockWrite[" + volumeNames[i] + "] -> BlockStorageC_" + volumeNames[i] + "; \n")
+      outFile.write("\n")
+      
+    elif volumeTypes[volumeNames[i]] == "log":
+      outFile.write("\n")      
+      outFile.write("  components new LogStorageC(" + volumeNames[i] + ", " + volumeOptions[volumeNames[i]] + ") as LogStorageC_" + volumeNames[i] + "; \n")
+      outFile.write("  VolumeMapP.SubLogRead[" + volumeNames[i] + "] -> LogStorageC_" + volumeNames[i] + "; \n")
+      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")
+  outFile.write("} \n")