VirtualBox

Changeset 97518 in vbox


Ignore:
Timestamp:
Nov 11, 2022 11:23:43 PM (2 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
154542
Message:

ValKit/bs3-cpu-basic-2: Some assembly cleanups. bugref:9898

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/ValidationKit/bootsectors/bs3-cpu-basic-2-template.mac

    r97516 r97518  
    4545;*  Defined Constants And Macros                                                                                                 *
    4646;*********************************************************************************************************************************
    47 %ifndef BS3_CPUBAS2_UD_OFF_DEFINED
    48 %define BS3_CPUBAS2_UD_OFF_DEFINED
     47%ifnmacro BS3_CPUBAS2_UD_OFF
    4948%macro BS3_CPUBAS2_UD_OFF 1
    5049BS3_GLOBAL_NAME_EX BS3_CMN_NM(%1) %+ _offUD, , 1
     
    5655%if TMPL_BITS == 16
    5756 %define BS3_CPUBAS2_REF_LABEL_VIA_CS(a_Label)     cs:a_Label
    58  %define BS3_CPUBAS2_JMP_FAR_MEM_LABEL(a_Label)    jmp far [BS3_CPUBAS2_REF_LABEL_VIA_CS(a_Label)]
    5957%elif TMPL_BITS == 32
    6058 %define BS3_CPUBAS2_REF_LABEL_VIA_CS(a_Label)     cs:a_Label wrt FLAT
    61  %define BS3_CPUBAS2_JMP_FAR_MEM_LABEL(a_Label)    jmp far [BS3_CPUBAS2_REF_LABEL_VIA_CS(a_Label)]
    6259%elif TMPL_BITS == 64
    6360 %define BS3_CPUBAS2_REF_LABEL_VIA_CS(a_Label)     a_Label wrt FLAT
    64  %define BS3_CPUBAS2_JMP_FAR_MEM_LABEL(a_Label)    jmp far [BS3_CPUBAS2_REF_LABEL_VIA_CS(a_Label)]
    6561%else
    6662 %error TMPL_BITS
     
    7167;
    7268; @param 1      The label of the memory pointer.
    73 ; @param 2      Set to 0 for no prefix, 1 for REX.W prefix.
    74 %ifndef BS3_CPUBAS2_JMP_FAR_MEM_LABEL_DEFINED
    75 %define BS3_CPUBAS2_JMP_FAR_MEM_LABEL_DEFINED
     69; @param 2      Prefix: 0: none, 1: 066h, 2: REX.W, 3: 066h REX.W
     70%ifnmacro BS3_CPUBAS2_JMP_FAR_MEM_LABEL
    7671%macro BS3_CPUBAS2_JMP_FAR_MEM_LABEL 2
     72 %if (%2) == 1 || (%2) == 3
     73        db      066h                        ; o16/o32
     74 %endif
    7775 %if TMPL_BITS != 64
    7876        jmp far [BS3_CPUBAS2_REF_LABEL_VIA_CS(%1)]
    7977 %elif TMPL_BITS == 64
    8078        ;  48FF2C25[040C0000]  <3>  jmp far [BS3_CPUBAS2_REF_LABLE_VIA_CS(.fpfn)]
    81   %if %2 != 0
     79  %if (%2) == 2 || (%2) == 3
    8280        db      048h                        ; REX.W
    8381  %endif
     
    8886 %endif
    8987%endmacro
    90 %endif ; BS3_CPUBAS2_JMP_FAR_MEM_LABEL_DEFINED
     88%endif
    9189
    9290;;
     
    9492;
    9593; @param 1      The label of the memory pointer.
    96 ; @param 2      Set to 0 for no prefix, 1 for REX.W prefix.
    97 %ifndef BS3_CPUBAS2_CALL_FAR_MEM_LABEL_DEFINED
    98 %define BS3_CPUBAS2_CALL_FAR_MEM_LABEL_DEFINED
     94; @param 2      Prefix: 0: none, 1: 066h, 2: REX.W, 3: 066h REX.W
     95%ifnmacro BS3_CPUBAS2_CALL_FAR_MEM_LABEL
    9996%macro BS3_CPUBAS2_CALL_FAR_MEM_LABEL 2
     97 %if (%2) == 1 || (%2) == 3
     98        db      066h                        ; o16/o32
     99 %endif
    100100 %if TMPL_BITS != 64
    101101        call far [BS3_CPUBAS2_REF_LABEL_VIA_CS(%1)]
    102102 %elif TMPL_BITS == 64
    103   %if %2 != 0
     103  %if (%2) == 2 || (%2) == 3
    104104        db      048h                        ; REX.W
    105105  %endif
     
    110110 %endif
    111111%endmacro
    112 %endif ; BS3_CPUBAS2_CALL_FAR_MEM_LABEL_DEFINED
     112%endif
    113113
    114114
     
    12961296; Since AMD and Intel treat REX.W differently, we need two versions of the
    12971297; test functions here and use a macro to accomplish that.
    1298 %ifndef jmpf_macro_defined
    1299 %define jmpf_macro_defined
     1298;
     1299; @param 1      Symbol suffix
     1300; @param 2      0 for AMD, 1 for Intel.
     1301;
     1302%ifnmacro jmpf_macro
    13001303%macro jmpf_macro 2
    13011304
    13021305BS3_CPUBAS2_UD_OFF bs3CpuBasic2_jmpf_mem_same_r0__ud2 %+ %1
    13031306BS3_PROC_BEGIN_CMN bs3CpuBasic2_jmpf_mem_same_r0__ud2 %+ %1, BS3_PBC_NEAR
    1304         jmp     far [BS3_CPUBAS2_REF_LABEL_VIA_CS(.fpfn)]
     1307        BS3_CPUBAS2_JMP_FAR_MEM_LABEL   .fpfn, 2
    13051308.fpfn:
    13061309 %if TMPL_BITS == 16
     
    13261329BS3_CPUBAS2_UD_OFF bs3CpuBasic2_jmpf_mem_same_r1__ud2 %+ %1
    13271330BS3_PROC_BEGIN_CMN bs3CpuBasic2_jmpf_mem_same_r1__ud2 %+ %1, BS3_PBC_NEAR
    1328         jmp     far [BS3_CPUBAS2_REF_LABEL_VIA_CS(.fpfn)]
     1331        BS3_CPUBAS2_JMP_FAR_MEM_LABEL   .fpfn, 2
    13291332.fpfn:
    13301333 %if TMPL_BITS == 16
     
    13651368BS3_CPUBAS2_UD_OFF bs3CpuBasic2_jmpf_mem_same_r3__ud2 %+ %1
    13661369BS3_PROC_BEGIN_CMN bs3CpuBasic2_jmpf_mem_same_r3__ud2 %+ %1, BS3_PBC_NEAR
    1367         BS3_CPUBAS2_JMP_FAR_MEM_LABEL   .fpfn, 1
     1370        BS3_CPUBAS2_JMP_FAR_MEM_LABEL   .fpfn, 2
    13681371.fpfn:
    13691372 %if TMPL_BITS == 16
     
    13861389BS3_CPUBAS2_UD_OFF bs3CpuBasic2_jmpf_mem_r0_cs16__ud2 %+ %1
    13871390BS3_PROC_BEGIN_CMN bs3CpuBasic2_jmpf_mem_r0_cs16__ud2 %+ %1, BS3_PBC_NEAR
    1388   %if TMPL_BITS != 16
    1389         db      66h
    1390   %endif
    1391         BS3_CPUBAS2_JMP_FAR_MEM_LABEL   .fpfn, 0
     1391        BS3_CPUBAS2_JMP_FAR_MEM_LABEL   .fpfn, (TMPL_BITS != 16) ; TMPL_BITS != 16 ? 1 : 0
    13921392.fpfn:
    13931393        dw      .again wrt CGROUP16
     
    14001400BS3_CPUBAS2_UD_OFF bs3CpuBasic2_jmpf_mem_r0_cs32__ud2 %+ %1
    14011401BS3_PROC_BEGIN_CMN bs3CpuBasic2_jmpf_mem_r0_cs32__ud2 %+ %1, BS3_PBC_NEAR
    1402   %if TMPL_BITS == 16
    1403         db      66h
    1404   %endif
    1405         BS3_CPUBAS2_JMP_FAR_MEM_LABEL   .fpfn, 0
     1402        BS3_CPUBAS2_JMP_FAR_MEM_LABEL   .fpfn, (TMPL_BITS == 16) ; TMPL_BITS == 16 ? 1 : 0
    14061403.fpfn:
    14071404        dd      .again wrt FLAT
     
    14161413BS3_CPUBAS2_UD_OFF bs3CpuBasic2_jmpf_mem_r0_cs64__ud2 %+ %1
    14171414BS3_PROC_BEGIN_CMN bs3CpuBasic2_jmpf_mem_r0_cs64__ud2 %+ %1, BS3_PBC_NEAR
    1418  %if TMPL_BITS == 16
    1419         db      066h
    1420  %endif
    1421         jmp     far [BS3_CPUBAS2_REF_LABEL_VIA_CS(.fpfn)]
     1415        BS3_CPUBAS2_JMP_FAR_MEM_LABEL   .fpfn, (2 - (TMPL_BITS == 16)) ; TMPL_BITS == 16 ? 1 : 2
    14221416.fpfn:
    14231417        dd      .jmp_target wrt FLAT
     
    14411435BS3_CPUBAS2_UD_OFF bs3CpuBasic2_jmpf_mem_r0_cs16l__ud2 %+ %1
    14421436BS3_PROC_BEGIN_CMN bs3CpuBasic2_jmpf_mem_r0_cs16l__ud2 %+ %1, BS3_PBC_NEAR
    1443  %if TMPL_BITS == 32
    1444         db      066h
    1445  %endif
    1446         BS3_CPUBAS2_JMP_FAR_MEM_LABEL   .fpfn, 0
     1437        BS3_CPUBAS2_JMP_FAR_MEM_LABEL   .fpfn, (TMPL_BITS == 32) ; TMPL_BITS == 32 ? 1 : 0
    14471438.fpfn:
    14481439 %if TMPL_BITS != 64
     
    14951486; Since AMD and Intel treat REX.W differently, we need two versions of the
    14961487; test functions here and use a macro to accomplish that.
    1497 %ifndef callf_macro_defined
    1498 %define callf_macro_defined
     1488;
     1489; @param 1      Symbol suffix
     1490; @param 2      0 for AMD, 1 for Intel.
     1491;
     1492%ifnmacro callf_macro
    14991493%macro callf_macro 2
    15001494
    15011495BS3_CPUBAS2_UD_OFF bs3CpuBasic2_callf_mem_same_r0__ud2 %+ %1
    15021496BS3_PROC_BEGIN_CMN bs3CpuBasic2_callf_mem_same_r0__ud2 %+ %1, BS3_PBC_NEAR
    1503         call    far [BS3_CPUBAS2_REF_LABEL_VIA_CS(.fpfn)]
     1497        BS3_CPUBAS2_CALL_FAR_MEM_LABEL .fpfn, 2
    15041498.fpfn:
    15051499 %if TMPL_BITS == 16
     
    15251519BS3_CPUBAS2_UD_OFF bs3CpuBasic2_callf_mem_same_r1__ud2 %+ %1
    15261520BS3_PROC_BEGIN_CMN bs3CpuBasic2_callf_mem_same_r1__ud2 %+ %1, BS3_PBC_NEAR
    1527         call    far [BS3_CPUBAS2_REF_LABEL_VIA_CS(.fpfn)]
     1521        BS3_CPUBAS2_CALL_FAR_MEM_LABEL .fpfn, 2
    15281522.fpfn:
    15291523 %if TMPL_BITS == 16
     
    15641558BS3_CPUBAS2_UD_OFF bs3CpuBasic2_callf_mem_same_r3__ud2 %+ %1
    15651559BS3_PROC_BEGIN_CMN bs3CpuBasic2_callf_mem_same_r3__ud2 %+ %1, BS3_PBC_NEAR
    1566         BS3_CPUBAS2_CALL_FAR_MEM_LABEL .fpfn, 1
     1560        BS3_CPUBAS2_CALL_FAR_MEM_LABEL .fpfn, 2
    15671561.fpfn:
    15681562 %if TMPL_BITS == 16
     
    15851579BS3_CPUBAS2_UD_OFF bs3CpuBasic2_callf_mem_r0_cs16__ud2 %+ %1
    15861580BS3_PROC_BEGIN_CMN bs3CpuBasic2_callf_mem_r0_cs16__ud2 %+ %1, BS3_PBC_NEAR
    1587   %if TMPL_BITS != 16
    1588         db      66h
    1589   %endif
    1590         BS3_CPUBAS2_CALL_FAR_MEM_LABEL .fpfn, 0
     1581        BS3_CPUBAS2_CALL_FAR_MEM_LABEL .fpfn, (TMPL_BITS != 16) ; (TMPL_BITS == 16 ? 0 : 1)
    15911582.fpfn:
    15921583        dw      .again wrt CGROUP16
     
    15991590BS3_CPUBAS2_UD_OFF bs3CpuBasic2_callf_mem_r0_cs32__ud2 %+ %1
    16001591BS3_PROC_BEGIN_CMN bs3CpuBasic2_callf_mem_r0_cs32__ud2 %+ %1, BS3_PBC_NEAR
    1601   %if TMPL_BITS == 16
    1602         db      66h
    1603   %endif
    1604         BS3_CPUBAS2_CALL_FAR_MEM_LABEL .fpfn, 0
     1592        BS3_CPUBAS2_CALL_FAR_MEM_LABEL .fpfn, (TMPL_BITS == 16) ; (TMPL_BITS == 16 ? 1 : 0)
    16051593.fpfn:
    16061594        dd      .again wrt FLAT
     
    16151603BS3_CPUBAS2_UD_OFF bs3CpuBasic2_callf_mem_r0_cs64__ud2 %+ %1
    16161604BS3_PROC_BEGIN_CMN bs3CpuBasic2_callf_mem_r0_cs64__ud2 %+ %1, BS3_PBC_NEAR
    1617  %if TMPL_BITS == 16
    1618         db      066h
    1619  %endif
    1620         call    far [BS3_CPUBAS2_REF_LABEL_VIA_CS(.fpfn)]
     1605        BS3_CPUBAS2_CALL_FAR_MEM_LABEL .fpfn, (2 - (TMPL_BITS == 16)) ; (TMPL_BITS == 16 ? 1 : 2)
    16211606.fpfn:
    16221607        dd      .call_target wrt FLAT
     
    16401625BS3_CPUBAS2_UD_OFF bs3CpuBasic2_callf_mem_r0_cs16l__ud2 %+ %1
    16411626BS3_PROC_BEGIN_CMN bs3CpuBasic2_callf_mem_r0_cs16l__ud2 %+ %1, BS3_PBC_NEAR
    1642  %if TMPL_BITS == 32
    1643         db      066h
    1644  %endif
    1645         BS3_CPUBAS2_CALL_FAR_MEM_LABEL .fpfn, 0
     1627        BS3_CPUBAS2_CALL_FAR_MEM_LABEL .fpfn, (TMPL_BITS == 32) ; (TMPL_BITS == 32 ? 1 : 0)
    16461628.fpfn:
    16471629 %if TMPL_BITS != 64
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette