VirtualBox

Changeset 100193 in vbox for trunk/include


Ignore:
Timestamp:
Jun 16, 2023 8:13:55 AM (18 months ago)
Author:
vboxsync
Message:

include/iprt/asm-arm.h: Some ASM*() helpers for arm64, bugref:10457

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/iprt/asm-arm.h

    r99978 r100193  
    4949 * @{
    5050 */
    51 
    52 
    53 #if 0 /* figure out arm64 */
    54 
    55 /**
    56  * Get the CPSR (Current Program Status) register.
    57  * @returns CPSR.
    58  */
    59 #if RT_INLINE_ASM_EXTERNAL
    60 DECLASM(RTCCUINTREG) ASMGetFlags(void);
    61 #else
    62 DECLINLINE(RTCCUINTREG) ASMGetFlags(void)
    63 {
    64     RTCCUINTREG uFlags;
    65 # if RT_INLINE_ASM_GNU_STYLE
    66 #  ifdef RT_ARCH_ARM64
    67     __asm__ __volatile__("mrs %0, nzcv\n\t"  : "=r" (uFlags));
    68 #  else
    69     __asm__ __volatile__("mrs %0, cpsr\n\t"  : "=r" (uFlags));
    70 #  endif
    71 # else
    72 #  error "Unsupported compiler"
    73 # endif
    74     return uFlags;
    75 }
    76 #endif
    77 
    78 
    79 /**
    80  * Set the CPSR register.
    81  * @param   uFlags      The new CPSR value.
    82  */
    83 #if RT_INLINE_ASM_EXTERNAL
    84 DECLASM(void) ASMSetFlags(RTCCUINTREG uFlags);
    85 #else
    86 DECLINLINE(void) ASMSetFlags(RTCCUINTREG uFlags)
    87 {
    88 # if RT_INLINE_ASM_GNU_STYLE
    89     __asm__ __volatile__("msr cpsr_c, %0\n\t"
    90                          : : "r" (uFlags));
    91 # else
    92 #  error "Unsupported compiler"
    93 # endif
    94 }
    95 #endif
    96 
    97 #endif
    98 
    9951
    10052/**
     
    169121
    170122
    171 #if 0 /* port to arm64, armv7 and check */
    172 
    173123/**
    174124 * Enables interrupts (IRQ and FIQ).
     
    179129DECLINLINE(void) ASMIntEnable(void)
    180130{
     131# if RT_INLINE_ASM_GNU_STYLE
     132#  ifdef RT_ARCH_ARM64
     133    __asm__ __volatile__("msr daifclr, #0xf\n\t");
     134#  else
    181135    RTCCUINTREG uFlags;
    182 # if RT_INLINE_ASM_GNU_STYLE
    183136    __asm__ __volatile__("mrs %0, cpsr\n\t"
    184137                         "bic %0, %0, #0xc0\n\t"
    185138                         "msr cpsr_c, %0\n\t"
    186139                         : "=r" (uFlags));
     140#  endif
    187141# else
    188142#  error "Unsupported compiler"
     
    200154DECLINLINE(void) ASMIntDisable(void)
    201155{
     156# if RT_INLINE_ASM_GNU_STYLE
     157#  ifdef RT_ARCH_ARM64
     158    __asm__ __volatile__("msr daifset, #0xf\n\t");
     159#  else
    202160    RTCCUINTREG uFlags;
    203 # if RT_INLINE_ASM_GNU_STYLE
    204161    __asm__ __volatile__("mrs %0, cpsr\n\t"
    205162                         "orr %0, %0, #0xc0\n\t"
    206163                         "msr cpsr_c, %0\n\t"
    207164                         : "=r" (uFlags));
     165#  endif
    208166# else
    209167#  error "Unsupported compiler"
     
    223181    RTCCUINTREG uFlags;
    224182# if RT_INLINE_ASM_GNU_STYLE
     183#  ifdef RT_ARCH_ARM64
     184    __asm__ __volatile__("mrs %[uRet], daif\n\t"
     185                         "msr daifset, #0xf\n\t"
     186                         : [uRet] "=r" (uFlags));
     187#  else
    225188    RTCCUINTREG uNewFlags;
    226189    __asm__ __volatile__("mrs %0, cpsr\n\t"
     
    229192                         : "=r" (uFlags)
    230193                         , "=r" (uNewFlags));
     194#  endif
    231195# else
    232196#  error "Unsupported compiler"
     
    234198    return uFlags;
    235199}
     200
     201
     202/**
     203 * Get the CPSR/PSTATE register.
     204 * @returns CPSR/PSTATE.
     205 */
     206#if RT_INLINE_ASM_EXTERNAL
     207DECLASM(RTCCUINTREG) ASMGetFlags(void);
     208#else
     209DECLINLINE(RTCCUINTREG) ASMGetFlags(void)
     210{
     211    RTCCUINTREG uFlags;
     212# if RT_INLINE_ASM_GNU_STYLE
     213#  ifdef RT_ARCH_ARM64
     214    __asm__ __volatile__("isb\n\t"
     215                         "mrs %0, daif\n\t"
     216                         : "=r" (uFlags));
     217#  else
     218#   error "Implementation required for arm32"
     219#  endif
     220# else
     221#  error "Unsupported compiler"
     222# endif
     223    return uFlags;
     224}
     225#endif
     226
     227
     228/**
     229 * Get the CPSR/PSTATE register.
     230 * @returns CPSR/PSTATE.
     231 */
     232#if RT_INLINE_ASM_EXTERNAL
     233DECLASM(void) ASMSetFlags(RTCCUINTREG uFlags);
     234#else
     235DECLINLINE(void) ASMSetFlags(RTCCUINTREG uFlags)
     236{
     237# if RT_INLINE_ASM_GNU_STYLE
     238#  ifdef RT_ARCH_ARM64
     239    __asm__ __volatile__("isb\n\t"
     240                         "msr daif, %[uFlags]\n\t"
     241                         : : [uFlags] "r" (uFlags));
     242#  else
     243#   error "Implementation required for arm32"
     244#  endif
     245# else
     246#  error "Unsupported compiler"
     247# endif
     248}
    236249#endif
    237250
     
    244257DECLINLINE(bool) ASMIntAreEnabled(void)
    245258{
    246 /** @todo r=bird: reversed, but does both need to be enabled? */
    247259    return ASMGetFlags() & 0xc0 /* IRQ and FIQ bits */ ? true : false;
    248260}
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