From 02d35ad07f70822e9e74a2f909dfa648f3e3b6d5 Mon Sep 17 00:00:00 2001 From: klueska Date: Fri, 23 May 2008 01:04:35 +0000 Subject: [PATCH] Update to tos-storage-* tools to support a '-t' flag to generate a VolumeMapC.nc file that exports interfaces from all the volumes described in the XML file for a particular storage chip. Also fixed the make system to create and install the tos-storage-pxa27xp30 script --- tools/configure.ac | 1 + tools/tinyos/misc/Makefile.am | 2 + tools/tinyos/misc/tos-storage-at45db.1 | 19 +++-- tools/tinyos/misc/tos-storage-at45db.in | 92 ++++++++++++++++++--- tools/tinyos/misc/tos-storage-pxa27xp30 | 85 +++++++++++++++++++- tools/tinyos/misc/tos-storage-pxa27xp30.1 | 24 ++++-- tools/tinyos/misc/tos-storage-pxa27xp30.in | 85 +++++++++++++++++++- tools/tinyos/misc/tos-storage-stm25p.1 | 17 ++-- tools/tinyos/misc/tos-storage-stm25p.in | 93 +++++++++++++++++++--- 9 files changed, 374 insertions(+), 44 deletions(-) diff --git a/tools/configure.ac b/tools/configure.ac index 37c55d30..7034cf45 100644 --- a/tools/configure.ac +++ b/tools/configure.ac @@ -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 diff --git a/tools/tinyos/misc/Makefile.am b/tools/tinyos/misc/Makefile.am index 8dfc65b5..295fad4f 100644 --- a/tools/tinyos/misc/Makefile.am +++ b/tools/tinyos/misc/Makefile.am @@ -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 diff --git a/tools/tinyos/misc/tos-storage-at45db.1 b/tools/tinyos/misc/tos-storage-at45db.1 index 48444d90..885eabea 100644 --- a/tools/tinyos/misc/tos-storage-at45db.1 +++ b/tools/tinyos/misc/tos-storage-at45db.1 @@ -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 \\ build/mica2/StorageVolumes.h .SH SEE ALSO -.IR tos-storage-stm25p (1) +.IR tos-storage-stm25p (1) +.IR tos-storage-pxa27xp30 (1) diff --git a/tools/tinyos/misc/tos-storage-at45db.in b/tools/tinyos/misc/tos-storage-at45db.in index c46719a5..73bb63a9 100644 --- a/tools/tinyos/misc/tos-storage-at45db.in +++ b/tools/tinyos/misc/tos-storage-at45db.in @@ -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] \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 ") + stderr.write("Usage: tos-storage-at45db [-t] \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") + diff --git a/tools/tinyos/misc/tos-storage-pxa27xp30 b/tools/tinyos/misc/tos-storage-pxa27xp30 index 120dd0b6..04c23fcc 100755 --- a/tools/tinyos/misc/tos-storage-pxa27xp30 +++ b/tools/tinyos/misc/tos-storage-pxa27xp30 @@ -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] \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] \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") diff --git a/tools/tinyos/misc/tos-storage-pxa27xp30.1 b/tools/tinyos/misc/tos-storage-pxa27xp30.1 index 61f065b1..47e42f3c 100644 --- a/tools/tinyos/misc/tos-storage-pxa27xp30.1 +++ b/tools/tinyos/misc/tos-storage-pxa27xp30.1 @@ -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 build/telosb/StorageVolumes.h + tos-storage-pxa27xp30 -t /opt/tinyos-2.x/tos/platforms/intelmote2 \\ + 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 diff --git a/tools/tinyos/misc/tos-storage-pxa27xp30.in b/tools/tinyos/misc/tos-storage-pxa27xp30.in index 275b5007..a82efd54 100755 --- a/tools/tinyos/misc/tos-storage-pxa27xp30.in +++ b/tools/tinyos/misc/tos-storage-pxa27xp30.in @@ -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] \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] \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") diff --git a/tools/tinyos/misc/tos-storage-stm25p.1 b/tools/tinyos/misc/tos-storage-stm25p.1 index b558bd22..a7f04a0c 100644 --- a/tools/tinyos/misc/tos-storage-stm25p.1 +++ b/tools/tinyos/misc/tos-storage-stm25p.1 @@ -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 \\ build/telosb/StorageVolumes.h .SH SEE ALSO -.IR tos-storage-stm25p (1) +.IR tos-storage-pxa27xp30 (1) +.IR tos-storage-at45db (1) diff --git a/tools/tinyos/misc/tos-storage-stm25p.in b/tools/tinyos/misc/tos-storage-stm25p.in index 79cb0988..f1b02b78 100644 --- a/tools/tinyos/misc/tos-storage-stm25p.in +++ b/tools/tinyos/misc/tos-storage-stm25p.in @@ -39,6 +39,7 @@ # @author Jonathan Hui # @author David Gay +# @author Kevin Klues # # $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] \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] \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 " ) - 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") -- 2.39.2