X-Git-Url: https://oss.titaniummirror.com/gitweb/?a=blobdiff_plain;f=tools%2Ftinyos%2Fmisc%2Ftos-storage-pxa27xp30.in;h=a82efd54f75aa90f8298ff1de6568f11727d5812;hb=02d35ad07f70822e9e74a2f909dfa648f3e3b6d5;hp=275b50078c39de713d227cad0b628ec45bfaa286;hpb=409a3bb13dabe16fbe0600a8127358e7e6b1b7a3;p=tinyos-2.x.git 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")