]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - glsdk/host-tools.git/blobdiff - respart/RM-autogen-data.py
RM-autogen-data.py: Use sysfw documentation to generate the data
[glsdk/host-tools.git] / respart / RM-autogen-data.py
index 12caca4856c8eea97b67e70350b87226107c1573..2654a1f091f055bdebbd15922592666d9886ced0 100755 (executable)
@@ -7,13 +7,12 @@ from xlwt.Utils import rowcol_to_cell
 COL_COMMENT = 0
 COL_RES_TYPE = 1
 COL_SUB_TYPE = 2
 COL_COMMENT = 0
 COL_RES_TYPE = 1
 COL_SUB_TYPE = 2
-COL_RES_FIELD = 3
-COL_RES_COUNT = 5
-COL_RES_START = 6
-COL_HOST_START = 7
+COL_RES_COUNT = 3
+COL_RES_START = 4
+COL_HOST_START = 5
 
 ROW_HOST_ID = 0
 
 ROW_HOST_ID = 0
-ROW_RES_START = 2
+ROW_RES_START = 1
 
 dict_dev = {}
 dict_subtype = {}
 
 dict_dev = {}
 dict_subtype = {}
@@ -36,16 +35,29 @@ const_values  = {
 %s}'''
        header = "# %s.py - Auto generated SoC data\n" % soc
        devs = ""
 %s}'''
        header = "# %s.py - Auto generated SoC data\n" % soc
        devs = ""
-       for i in dict_dev:
-               devs += '"%s" : %d,\n' % (i, dict_dev[i])
+       for i in sorted(dict_dev.items(), key=lambda x: x[1]):
+               (dev, dev_id) = i
+               devs += '"%s" : %d,\n' % (dev, dev_id)
+
        subtypes = ""
        subtypes = ""
-       for i in dict_subtype:
-               subtypes += '"%s" : %d,\n' % (i, dict_subtype[i])
+       for i in sorted(dict_subtype.items(), key=lambda x: x[1]):
+               (subtype, subtype_id) = i
+               subtypes += '"%s" : %d,\n' % (subtype, subtype_id)
+
        hosts = ""
        hosts = ""
-       for i in dict_host:
-               hosts += '"%s" : %d,\n' % (i, dict_host[i])
+       for i in sorted(dict_host.items(), key=lambda x: x[1]):
+               (host, host_id) = i
+               hosts += '"%s" : %d,\n' % (host, host_id)
+
        return output % (header, devs, subtypes, hosts)
 
        return output % (header, devs, subtypes, hosts)
 
+def gen_rm_resasg_csv():
+       output = ""
+       for entry in utypes:
+               (dev, subtype, count, start) = entry
+               output += "%s,%s,%d,%d\n" % (dev, subtype, start, count)
+       return output
+
 def gen_rm_resasg_sheet(sheet):
 
        fmt_header = xlwt.easyxf('font: color-index blue, bold on')
 def gen_rm_resasg_sheet(sheet):
 
        fmt_header = xlwt.easyxf('font: color-index blue, bold on')
@@ -101,7 +113,7 @@ args = parser.parse_args()
 print(args)
 
 # Parse docuemntation and extract host_id defines
 print(args)
 
 # Parse docuemntation and extract host_id defines
-output = evalcmd('cat %s/output/%s/sec_proxy/hosts.h | grep "#define HOST_ID" | awk -F"[ ()]*" \'{print $2" " $3}\'' % (args.prefix, args.soc))
+output = evalcmd('cat %s/include/soc/%s/hosts.h | grep "#define HOST_ID" | awk -F"[ ()]*" \'{print $2" " $3}\'' % (args.prefix, args.soc))
 for line in output.split('\n'):
        if (line == ''):
                continue
 for line in output.split('\n'):
        if (line == ''):
                continue
@@ -110,26 +122,28 @@ for line in output.split('\n'):
        dict_host[host] = host_id
 
 # Parse docuemntation and extract dev_id and subtype defines
        dict_host[host] = host_id
 
 # Parse docuemntation and extract dev_id and subtype defines
-output = evalcmd('cat %s/output/%s/rm/resasg_types.rst | grep SUBTYPE | awk -F" " \'{ print $2" "$4" "$6" "$8" "$10 }\'' % (args.prefix, args.soc))
+output = evalcmd('cat %s/docs/public/5_soc_doc/%s/resasg_types.rst | grep  -v "\------" | grep -A100000 "+======" | tail -n +2' % (args.prefix, args.soc))
 dev = dev_id = None
 for line in output.split('\n'):
 dev = dev_id = None
 for line in output.split('\n'):
-       if (line == ''):
+       array = line.replace(' ', '').split('|')
+       if(len(array) == 1):
                continue
                continue
-       array = line.split(' ')
-       #print(array)
-       if (array[0] != '|'):
-               (dev, dev_id, subtype, subtype_id, utype_id) = array
+
+       if (array[1] != ''):
+               (x, dev, dev_id, subtype, subtype_id, utype_id, start, count, x) = array
+       elif (array[3] != ''):
+               (x, x, x, subtype, subtype_id, utype_id, start, count, x) = array
        else:
        else:
-               (dummy, subtype, subtype_id, utype_id, dummy) = array
+               (x, x, x, x, x, x, start, count, x) = array
+       start=int(start, 0)
+       count=int(count, 0)
 
 
-       #print (dev, dev_id, subtype, subtype_id, utype_id)
+       #print (dev, dev_id, subtype, subtype_id, utype_id, start, count)
        dict_dev[dev] = int(dev_id, 0)
        dict_subtype[subtype] = int(subtype_id, 0)
        dict_dev[dev] = int(dev_id, 0)
        dict_subtype[subtype] = int(subtype_id, 0)
-       # TODO Add raneg parsing when documentation supports
-       '''
-       utypes.append((dev, subtype))
-       '''
+       utypes.append((dev, subtype, start, count))
 
 
+'''
 #Parse bordconfig to extract the dev, subtype and range of resources
 output = evalcmd('cat %s/output/%s/rm/boardcfg_rm_data.c | grep -A100000 "resasg_entries" | awk \'BEGIN { FS="\\n"; RS="{" } { print $2 " " $3 " " $4 }\' | awk -F" " \'{print $3 " " $4 " " $7 " " $10}\'' % (args.prefix, args.soc))
 for line in output.split('\n'):
 #Parse bordconfig to extract the dev, subtype and range of resources
 output = evalcmd('cat %s/output/%s/rm/boardcfg_rm_data.c | grep -A100000 "resasg_entries" | awk \'BEGIN { FS="\\n"; RS="{" } { print $2 " " $3 " " $4 }\' | awk -F" " \'{print $3 " " $4 " " $7 " " $10}\'' % (args.prefix, args.soc))
 for line in output.split('\n'):
@@ -143,6 +157,7 @@ for line in output.split('\n'):
        count = int(count)
        #print((dev, subtype, start, count))
        utypes.append((dev, subtype, start, count))
        count = int(count)
        #print((dev, subtype, start, count))
        utypes.append((dev, subtype, start, count))
+'''
 
 #print(dict_dev)
 #print(dict_subtype)
 
 #print(dict_dev)
 #print(dict_subtype)
@@ -154,6 +169,12 @@ ofile = open("%s.py" % args.soc, "w")
 ofile.write(data)
 ofile.close()
 
 ofile.write(data)
 ofile.close()
 
+#Generate the csv file with default values
+data = gen_rm_resasg_csv()
+ofile = open("%s.csv" % args.soc, "w")
+ofile.write(data)
+ofile.close()
+
 #Generate the excel sheet with default values
 workbook = xlwt.Workbook()
 sheet = workbook.add_sheet(args.soc)
 #Generate the excel sheet with default values
 workbook = xlwt.Workbook()
 sheet = workbook.add_sheet(args.soc)