@@ -35,6 +35,7 @@ def __init__(self, folder='', soc_yaml=None):
3535 self ._socs = []
3636 self ._series = []
3737 self ._families = []
38+ self ._extended_socs = []
3839
3940 if soc_yaml is None :
4041 return
@@ -76,17 +77,16 @@ def __init__(self, folder='', soc_yaml=None):
7677 found_match = True
7778 break
7879
79-
8080 if found_match is False :
8181 sys .exit (f'ERROR: SoC qualifier match unresolved: { qualifiers } ' )
8282
8383 for f in data .get ('family' , []):
84- family = Family (f ['name' ], folder , [], [])
84+ family = Family (f ['name' ], [ folder ] , [], [])
8585 for s in f .get ('series' , []):
86- series = Series (s ['name' ], folder , f ['name' ], [])
86+ series = Series (s ['name' ], [ folder ] , f ['name' ], [])
8787 socs = [(Soc (soc ['name' ],
8888 [c ['name' ] for c in soc .get ('cpuclusters' , [])],
89- folder , s ['name' ], f ['name' ]))
89+ [ folder ] , s ['name' ], f ['name' ]))
9090 for soc in s .get ('socs' , [])]
9191 series .socs .extend (socs )
9292 self ._series .append (series )
@@ -95,26 +95,36 @@ def __init__(self, folder='', soc_yaml=None):
9595 family .socs .extend (socs )
9696 socs = [(Soc (soc ['name' ],
9797 [c ['name' ] for c in soc .get ('cpuclusters' , [])],
98- folder , None , f ['name' ]))
98+ [ folder ] , None , f ['name' ]))
9999 for soc in f .get ('socs' , [])]
100100 self ._socs .extend (socs )
101101 self ._families .append (family )
102102
103103 for s in data .get ('series' , []):
104- series = Series (s ['name' ], folder , '' , [])
104+ series = Series (s ['name' ], [ folder ] , '' , [])
105105 socs = [(Soc (soc ['name' ],
106106 [c ['name' ] for c in soc .get ('cpuclusters' , [])],
107- folder , s ['name' ], '' ))
107+ [ folder ] , s ['name' ], '' ))
108108 for soc in s .get ('socs' , [])]
109109 series .socs .extend (socs )
110110 self ._series .append (series )
111111 self ._socs .extend (socs )
112112
113- socs = [(Soc (soc ['name' ],
114- [c ['name' ] for c in soc .get ('cpuclusters' , [])],
115- folder , '' , '' ))
116- for soc in data .get ('socs' , [])]
117- self ._socs .extend (socs )
113+ for soc in data .get ('socs' , []):
114+ mutual_exclusive = {'name' , 'extend' }
115+ if len (mutual_exclusive - soc .keys ()) < 1 :
116+ sys .exit (f'ERROR: Malformed content in SoC file: { soc_yaml } \n '
117+ f'{ mutual_exclusive } are mutual exclusive at this level.' )
118+ if soc .get ('name' ) is not None :
119+ self ._socs .append (Soc (soc ['name' ], [c ['name' ] for c in soc .get ('cpuclusters' , [])],
120+ [folder ], '' , '' ))
121+ elif soc .get ('extend' ) is not None :
122+ self ._extended_socs .append (Soc (soc ['extend' ],
123+ [c ['name' ] for c in soc .get ('cpuclusters' , [])],
124+ [folder ], '' , '' ))
125+ else :
126+ sys .exit (f'ERROR: Malformed "socs" section in SoC file: { soc_yaml } \n '
127+ f'Cannot find one of required keys { mutual_exclusive } .' )
118128
119129 @staticmethod
120130 def from_file (socs_file ):
@@ -137,8 +147,23 @@ def from_yaml(socs_yaml):
137147 def extend (self , systems ):
138148 self ._families .extend (systems .get_families ())
139149 self ._series .extend (systems .get_series ())
150+
151+ for es in self ._extended_socs [:]:
152+ for s in systems .get_socs ():
153+ if s .name == es .name :
154+ s .extend (es )
155+ self ._extended_socs .remove (es )
156+ break
140157 self ._socs .extend (systems .get_socs ())
141158
159+ for es in systems .get_extended_socs ():
160+ for s in self ._socs :
161+ if s .name == es .name :
162+ s .extend (es )
163+ break
164+ else :
165+ self ._extended_socs .append (es )
166+
142167 def get_families (self ):
143168 return self ._families
144169
@@ -148,6 +173,9 @@ def get_series(self):
148173 def get_socs (self ):
149174 return self ._socs
150175
176+ def get_extended_socs (self ):
177+ return self ._extended_socs
178+
151179 def get_soc (self , name ):
152180 try :
153181 return next (s for s in self ._socs if s .name == name )
@@ -160,23 +188,28 @@ def get_soc(self, name):
160188class Soc :
161189 name : str
162190 cpuclusters : List [str ]
163- folder : str
191+ folder : List [ str ]
164192 series : str = ''
165193 family : str = ''
166194
195+ def extend (self , soc ):
196+ if self .name == soc .name :
197+ self .cpuclusters .extend (soc .cpuclusters )
198+ self .folder .extend (soc .folder )
199+
167200
168201@dataclass
169202class Series :
170203 name : str
171- folder : str
204+ folder : List [ str ]
172205 family : str
173206 socs : List [Soc ]
174207
175208
176209@dataclass
177210class Family :
178211 name : str
179- folder : str
212+ folder : List [ str ]
180213 series : List [Series ]
181214 socs : List [Soc ]
182215
@@ -293,7 +326,7 @@ def dump_v2_system(args, type, system):
293326 info = args .cmakeformat .format (
294327 TYPE = 'TYPE;' + type ,
295328 NAME = 'NAME;' + system .name ,
296- DIR = 'DIR;' + Path (system . folder ).as_posix (),
329+ DIR = 'DIR;' + ';' . join ([ Path (x ).as_posix () for x in system . folder ] ),
297330 HWM = 'HWM;' + 'v2'
298331 )
299332 else :
0 commit comments