11#!/usr/bin/env python
22# -*- coding: utf-8 -*-
3- # $Id: ArmBsdSpecCodeGen.py 110676 2025年08月11日 13:45 :29Z knut.osmundsen@oracle.com $
3+ # $Id: ArmBsdSpecCodeGen.py 110677 2025年08月11日 14:48 :29Z knut.osmundsen@oracle.com $
44
55"""
66ARM BSD / OpenSource specification code generator.
3030
3131SPDX-License-Identifier: GPL-3.0-only
3232"""
33- __version__ = "$Revision: 110676 $"
33+ __version__ = "$Revision: 110677 $"
3434
3535# pylint: disable=too-many-lines
3636
@@ -1412,6 +1412,7 @@ def __init__(self, sInstr, sFuncPrefix, sParamType, sParamName, sType = 'read'):
14121412 self .sFuncPrefix = sFuncPrefix ;
14131413 self .sParamType = sParamType ;
14141414 self .sParamName = sParamName ;
1415+ self .fIs128Bit = sParamType .find ('128' ) >= 0 ; ## @todo we can do better than this...
14151416 self .sType = sType ;
14161417 self .aoInfo = [] # type: List[SysRegAccessorInfo]
14171418 self .cComplete = 0 ;
@@ -1507,11 +1508,18 @@ def generateMainFunction(self):
15071508 % (self .kdTypeToGprSuff [self .sType ], self .kdTypeToGprDesc [self .sType ],),
15081509 ' * @param %-11s %s' % (self .sParamName , self .kdTypeToParamDesc [self .sType ],),
15091510 ' */' ,
1510- 'DECLHIDDEN(VBOXSTRICTRC) %s_generic(PVMCPU pVCpu, uint32_t idSysReg, uint32_t idxGpr%s,'
1511- % (self .sFuncPrefix , self .kdTypeToGprSuff [self .sType ],),
1512- ' %s %s)' % (self .sParamType , self .sParamName ,),
1511+ 'DECLHIDDEN(VBOXSTRICTRC) %s_generic(PVMCPU pVCpu, uint32_t idSysReg, uint32_t idxGpr%s, %s %s)'
1512+ % (self .sFuncPrefix , self .kdTypeToGprSuff [self .sType ],self .sParamType , self .sParamName ,),
15131513 '{' ,
15141514 ];
1515+ 1516+ sLogFmt = '%.16Rhxs' if self .fIs128Bit else '%#RX64' ;
1517+ if self .sType == 'read' :
1518+ asLines .append (' Log(("%s(%%#x)\\ n", idSysReg));' % (self .sFuncPrefix , ));
1519+ else :
1520+ asLines .append (' Log(("%s(%%#x, %s)\\ n", idSysReg, %s));'
1521+ % (self .sFuncPrefix , sLogFmt , self .sParamName ,));
1522+ 15151523 for oInfo in self .aoInfo :
15161524 if oInfo .cInstrEssenceRefs :
15171525 asLines += [
@@ -1525,15 +1533,24 @@ def generateMainFunction(self):
15251533 ];
15261534 for oInfo in self .aoInfo :
15271535 if oInfo .sEnc [0 ] == 'A' : ## @todo better filtering out of non A64/whatever stuff.
1536+ asLines += [
1537+ ' case %s:' % (oInfo .sEnc ,),
1538+ ' {' ,
1539+ ' VBOXSTRICTRC const rcStrict = %s_%s(pVCpu, %s%s);'
1540+ % (self .sFuncPrefix , oInfo .sAsmValue , self .sParamName ,
1541+ ', uInstrEssence' if oInfo .cInstrEssenceRefs else '' ,),
1542+ ];
1543+ if self .sType == 'read' :
1544+ asLines .append (' LogFlow(("%s_%s -> %%Rrc & *%s=%s\\ n", VBOXSTRICTRC_VAL(rcStrict), *%s));'
1545+ % (self .sFuncPrefix , oInfo .sAsmValue , self .sParamName , sLogFmt , self .sParamName ,));
1546+ else :
1547+ asLines .append (' LogFlow(("%s_%s(%s) -> %%Rrc\\ n", VBOXSTRICTRC_VAL(rcStrict), %s));'
1548+ % (self .sFuncPrefix , oInfo .sAsmValue , sLogFmt , self .sParamName ,));
15281549 if oInfo .sRegName in self .kdRegsRequiringRecalcs :
1529- asLines .append (' case %s: %sreturn %s(pVCpu, %s_%s(pVCpu, %s%s));'
1530- % (oInfo .sEnc , ' ' * (45 - len (oInfo .sEnc )), self .kdRegsRequiringRecalcs [oInfo .sRegName ],
1531- self .sFuncPrefix , oInfo .sAsmValue ,
1532- self .sParamName , ', uInstrEssence' if oInfo .cInstrEssenceRefs else '' ,));
1550+ asLines .append (' return %s(pVCpu, rcStrict);' % (self .kdRegsRequiringRecalcs [oInfo .sRegName ],));
15331551 else :
1534- asLines .append (' case %s: %sreturn %s_%s(pVCpu, %s%s);'
1535- % (oInfo .sEnc , ' ' * (45 - len (oInfo .sEnc )), self .sFuncPrefix , oInfo .sAsmValue ,
1536- self .sParamName , ', uInstrEssence' if oInfo .cInstrEssenceRefs else '' ,));
1552+ asLines .append (' return rcStrict;' );
1553+ asLines .append (' }' );
15371554 asLines += [
15381555 ' }' ,
15391556 ' /* Fall back on handcoded handler. */' ,
@@ -3383,7 +3400,7 @@ def generateLicenseHeader(self, oVerInfo):
33833400 sDashYear = '' ;
33843401 return [
33853402 '/*' ,
3386- ' * Autogenerated by $Id: ArmBsdSpecCodeGen.py 110676 2025年08月11日 13:45 :29Z knut.osmundsen@oracle.com $' ,
3403+ ' * Autogenerated by $Id: ArmBsdSpecCodeGen.py 110677 2025年08月11日 14:48 :29Z knut.osmundsen@oracle.com $' ,
33873404 ' * from the open source %s specs, build %s (%s)'
33883405 % (oVerInfo ['architecture' ], oVerInfo ['build' ], oVerInfo ['ref' ],),
33893406 ' * dated %s.' % (oVerInfo ['timestamp' ],),
0 commit comments