source: trunk/tools/arch_info/genarch.py @ 156

Last change on this file since 156 was 6, checked in by alain, 5 years ago

Modify the boot_info_t struct to describe external peripherals in all clusters.

File size: 8.0 KB
Line 
1#!/usr/bin/env python
2
3##########################################################################################
4#  File   : genarch.py
5#  Date   : 2016
6#  Author : Alain Greiner
7#  Copyright (c)  UPMC Sorbonne Universites
8#########################################################################################
9# This python script generates the "arch_info.bin" file required by the ALMOS-MK
10# operating system bootloader and describing the target hardware architecture.
11# It uses an architecture specific, python script that must be called "arch_info.py".
12#
13# The source directory containing the "arch_info.py" file and the destination directory
14# to store the "arch_info.bin" file are defined by parameters on the command line:
15#  --arch=string     : path to directory containing the "arch_info.py" file
16#  --bin=string      : path to directory store the "arch_info.bin" file
17#
18# As the target architecture is generic, the following hardware parameters can be
19# defined on the command line:
20#  --x_size=int      : number of clusters in a row
21#  --y_size=int      : number of clusters in a column
22#  --nb_cores=int    : number of cores per cluster
23#  --nb_ttys=int     : number of TTY channels
24#  --nb_nics=int     : number of NIC channels
25#  --fbf_size=int    : frame buffer width & heigth
26#  --ioc_type=string : can be IOC_BDV , IOC_HBA , IOC_SDC , IOC_SPI
27#  --io_cxy=int      : IO cluster identifier
28#  --boot_cxy=int    : boot cluster identifier
29#  --cache_line=int  : number of bytes in a cache line
30#
31# The following parameters can be used to generate the optional "hard_config.h" file,
32# that is required to configurate the SystemC virtual prototype, and the "arch_info.xml"
33# file for debug.
34#  --hard=string     : path to directory to store the "hard_config.h" file
35#  --xml=string      : path to directory to store the "arch_info.xml" file
36#
37#########################################################################################
38
39import sys
40
41from arch_classes import *
42from optparse import OptionParser
43
44###################################################################################
45#   define command line arguments   
46###################################################################################
47
48parser = OptionParser()
49
50parser.add_option( '--arch', type = 'string', dest = 'arch_path',
51                   help = 'define pathname to directory containing arch_info.py file' )
52
53parser.add_option( '--bin', type = 'string', dest = 'bin_path',
54                   help = 'define pathname to directory to store arch_info.bin file' )
55
56parser.add_option( '--x_size', type = 'int', dest = 'x_size', 
57                   default = 2,
58                   help = 'define number of clusters in a row' )
59
60parser.add_option( '--y_size', type = 'int', dest = 'y_size', 
61                   default = 2,
62                   help = 'define number of clusters in a column' )
63
64parser.add_option( '--nb_cores', type = 'int', dest = 'nb_cores', 
65                   default = 2,
66                   help = 'define number of cores per cluster' )
67
68parser.add_option( '--nb_ttys', type = 'int', dest = 'nb_ttys', 
69                   default = 1,
70                   help = 'define number of TTY channels' )
71
72parser.add_option( '--nb_nics', type = 'int', dest = 'nb_nics',
73                   default = 1,
74                   help = 'define number ot NIC channels' )
75
76parser.add_option( '--fbf_size', type = 'int', dest = 'fbf_size', 
77                   default = 128,
78                   help = 'define frame buffer width and heigth' )
79
80parser.add_option( '--ioc_type', type = 'string', dest = 'ioc_type',
81                   default = 'IOC_BDV',
82                   help = 'define type of IOC: BDV / HBA / SDC / RDK / SPI' )
83
84parser.add_option( '--io_cxy', type = 'int', dest = 'io_cxy',
85                   default = 0,
86                   help = 'define IO cluster identifier' )
87
88parser.add_option( '--boot_cxy', type = 'int', dest = 'boot_cxy',
89                   default = 0,
90                   help = 'define boot cluster identifier' )
91
92parser.add_option( '--cache_line', type = 'int', dest = 'cache_line',
93                   default = 64,
94                   help = 'define number of bytes in a cache line' )
95
96parser.add_option( '--hard', type = 'string', dest = 'hard_path',
97                   help = 'define pathname to directory for the hard_config.h file ' )
98
99parser.add_option( '--xml', type = 'string', dest = 'xml_path', 
100                   help = 'define pathname to directory for the arch_info.xml file' )
101
102parser.add_option( '--v', action = 'store_true', dest = 'verbose',
103                   default = False,
104                   help = 'display detailed report on arch_info.bin generation' )
105
106###################################################################################
107#   Get command line arguments
108###################################################################################
109
110(options,args) = parser.parse_args()
111
112arch_path      = options.arch_path   # path to arch_info.py file
113bin_path       = options.bin_path    # path for arch_info.bin file
114
115x_size         = options.x_size      # number of clusters in a row
116y_size         = options.y_size      # number of clusters in a column
117nb_cores       = options.nb_cores    # number of cores in a cluster
118nb_ttys        = options.nb_ttys     # number of TTY channels           
119fbf_size       = options.fbf_size    # frame buffer width & heigth
120nb_nics        = options.nb_nics     # number of NIC channels           
121ioc_type       = options.ioc_type    # ioc controller type
122io_cxy         = options.io_cxy      # IO cluster identifier
123boot_cxy       = options.boot_cxy    # boot cluster identifier
124cache_line     = options.cache_line  # number of bytes in a cache line
125
126hard_path      = options.hard_path   # path for hard_config.h file
127xml_path       = options.xml_path    # path for arch_info.xml file     
128
129verbose        = options.verbose     # report on arch_info.bin generation
130
131
132###################################################################################
133#   Build the archinfo structure for the selected arch_info.py
134###################################################################################
135
136if   ( arch_path == None  ): 
137    print 'You must define a path to the arch_info.py file on command line' 
138    sys.exit(1)
139
140# dynamically append arch_path to PYTHONPATH
141sys.path.append( arch_path )
142
143# import the arch_info.py module (using file name without suffix)
144select = __import__( 'arch_info' )
145print select
146
147# build the arch_info structure by calling the arch function
148archinfo = select.arch( x_size,
149                        y_size, 
150                        nb_cores,
151                        nb_ttys, 
152                        nb_nics, 
153                        fbf_size, 
154                        ioc_type, 
155                        io_cxy,
156                        boot_cxy,
157                        cache_line )
158
159print '[genarch] archinfo build for %s' % archinfo.name
160
161###################################################################################
162#   Generate arch_info.xml file if required.
163###################################################################################
164
165if ( xml_path != None ):
166    pathname = xml_path + '/arch_info.xml'
167    f = open ( pathname, 'w' )
168    f.write( archinfo.xml() )
169
170    print '[genarch] %s generated' % pathname
171
172###################################################################################
173#   Generate arch_info.bin file if required.
174###################################################################################
175
176if ( bin_path != None ):
177    pathname = bin_path + '/arch_info.bin'
178    f = open ( pathname, 'wb' )
179    f.write( archinfo.cbin( verbose ) )
180    print '[genarch] %s generated' % pathname
181
182###################################################################################
183#   Generate hard_config.h file if required.
184###################################################################################
185
186if ( hard_path != None ):
187
188    pathname = hard_path + '/hard_config.h'
189    f = open ( pathname, 'w' )
190    f.write( archinfo.hard_config() )
191    print '[genarch] %s generated' % pathname
192
Note: See TracBrowser for help on using the repository browser.