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

Last change on this file since 369 was 279, checked in by alain, 7 years ago

1) Introduce independant command fields for the various devices in the thread descriptor.
2) Introduce a new dev_pic_enable_ipi() function in the generic PIC device
3) Fix two bugs identified by Maxime in the scheduler initialisation, and in the sched_select().
4) fix several bugs in the TSAR hal_kentry.S.
5) Introduce a third kgiet segment (besides kdata and kcode) in the TSAR bootloader.

File size: 7.1 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#
28# The following parameters can be used to generate the optional "hard_config.h" file,
29# that is required to configurate the SystemC virtual prototype, and the "arch_info.xml"
30# file for debug.
31#  --hard=string     : path to directory to store the "hard_config.h" file
32#  --xml=string      : path to directory to store the "arch_info.xml" file
33#
34#########################################################################################
35
36import sys
37
38from arch_classes import *
39from optparse import OptionParser
40
41###################################################################################
42#   define command line arguments   
43###################################################################################
44
45parser = OptionParser()
46
47parser.add_option( '--arch', type = 'string', dest = 'arch_path',
48                   help = 'define pathname to directory containing arch_info.py file' )
49
50parser.add_option( '--bin', type = 'string', dest = 'bin_path',
51                   help = 'define pathname to directory to store arch_info.bin file' )
52
53parser.add_option( '--x_size', type = 'int', dest = 'x_size', 
54                   default = 2,
55                   help = 'define number of clusters in a row' )
56
57parser.add_option( '--y_size', type = 'int', dest = 'y_size', 
58                   default = 2,
59                   help = 'define number of clusters in a column' )
60
61parser.add_option( '--nb_cores', type = 'int', dest = 'nb_cores', 
62                   default = 2,
63                   help = 'define number of cores per cluster' )
64
65parser.add_option( '--nb_ttys', type = 'int', dest = 'nb_ttys', 
66                   default = 1,
67                   help = 'define number of TTY channels' )
68
69parser.add_option( '--nb_nics', type = 'int', dest = 'nb_nics',
70                   default = 1,
71                   help = 'define number ot NIC channels' )
72
73parser.add_option( '--fbf_size', type = 'int', dest = 'fbf_size', 
74                   default = 128,
75                   help = 'define frame buffer width and heigth' )
76
77parser.add_option( '--ioc_type', type = 'string', dest = 'ioc_type',
78                   default = 'IOC_BDV',
79                   help = 'define type of IOC: BDV / HBA / SDC / RDK / SPI' )
80
81parser.add_option( '--hard', type = 'string', dest = 'hard_path',
82                   help = 'define pathname to directory for the hard_config.h file ' )
83
84parser.add_option( '--xml', type = 'string', dest = 'xml_path', 
85                   help = 'define pathname to directory for the arch_info.xml file' )
86
87parser.add_option( '--v', action = 'store_true', dest = 'verbose',
88                   default = False,
89                   help = 'display detailed report on arch_info.bin generation' )
90
91###################################################################################
92#   Get command line arguments
93###################################################################################
94
95(options,args) = parser.parse_args()
96
97arch_path      = options.arch_path   # path to arch_info.py file
98bin_path       = options.bin_path    # path for arch_info.bin file
99
100x_size         = options.x_size      # number of clusters in a row
101y_size         = options.y_size      # number of clusters in a column
102nb_cores       = options.nb_cores    # number of cores in a cluster
103nb_ttys        = options.nb_ttys     # number of TTY channels           
104fbf_size       = options.fbf_size    # frame buffer width & heigth
105nb_nics        = options.nb_nics     # number of NIC channels           
106ioc_type       = options.ioc_type    # ioc controller type
107
108hard_path      = options.hard_path   # path for hard_config.h file
109xml_path       = options.xml_path    # path for arch_info.xml file     
110
111verbose        = options.verbose     # report on arch_info.bin generation
112
113
114###################################################################################
115#   Build the archinfo structure for the selected arch_info.py
116###################################################################################
117
118if   ( arch_path == None  ): 
119    print 'You must define a path to the arch_info.py file on command line' 
120    sys.exit(1)
121
122# dynamically append arch_path to PYTHONPATH
123sys.path.append( arch_path )
124
125# import the arch_info.py module (using file name without suffix)
126select = __import__( 'arch_info' )
127print select
128
129# build the arch_info structure by calling the arch function
130archinfo = select.arch( x_size,
131                        y_size, 
132                        nb_cores,
133                        nb_ttys, 
134                        nb_nics, 
135                        fbf_size, 
136                        ioc_type )
137
138print '[genarch] archinfo build for %s' % archinfo.name
139
140###################################################################################
141#   Generate arch_info.xml file if required.
142###################################################################################
143
144if ( xml_path != None ):
145    pathname = xml_path + '/arch_info.xml'
146    f = open ( pathname, 'w' )
147    f.write( archinfo.xml() )
148
149    print '[genarch] %s generated' % pathname
150
151###################################################################################
152#   Generate arch_info.bin file if required.
153###################################################################################
154
155if ( bin_path != None ):
156    pathname = bin_path + '/arch_info.bin'
157    f = open ( pathname, 'wb' )
158    f.write( archinfo.cbin( verbose ) )
159    print '[genarch] %s generated' % pathname
160
161###################################################################################
162#   Generate hard_config.h file if required.
163###################################################################################
164
165if ( hard_path != None ):
166
167    pathname = hard_path + '/hard_config.h'
168    f = open ( pathname, 'w' )
169    f.write( archinfo.hard_config() )
170    print '[genarch] %s generated' % pathname
171
Note: See TracBrowser for help on using the repository browser.