VirtualBox

Changeset 94093 in vbox for trunk/src/VBox/Runtime/r3/darwin


Ignore:
Timestamp:
Mar 4, 2022 10:50:45 PM (3 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
150339
Message:

IPRT: Use same approach in RTMpGetMaxFrequency for getting at the a CPU in the I/O registry as we use in RTMpGetDescription. If intel is anything to go by, the cpu number in the name is hex not decimal. bugref:9898

Location:
trunk/src/VBox/Runtime/r3/darwin
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/r3/darwin/RTMpGetDescription-generic.cpp

    r94091 r94093  
    6060#if defined(RT_ARCH_ARM64)
    6161    char szArmCpuPath[64];
    62     RTStrPrintf(szArmCpuPath, sizeof(szArmCpuPath), "IODeviceTree:/cpus/cpu%u", idCpu);
     62    RTStrPrintf(szArmCpuPath, sizeof(szArmCpuPath), "IODeviceTree:/cpus/cpu%x", idCpu); /** @todo Hex? M1 Max only has 10 cores... */
    6363    io_registry_entry_t hIoRegEntry = IORegistryEntryFromPath(kIOMasterPortDefault, szArmCpuPath);
    6464    if (hIoRegEntry != MACH_PORT_NULL)
  • trunk/src/VBox/Runtime/r3/darwin/mp-darwin.cpp

    r94087 r94093  
    351351     */
    352352
     353#if 1 /* simpler way to get at it inspired by powermetrics, this is also used
     354         in the arm version of RTMpGetDescription. */
     355    /* Assume names on the form "cpu<N>" are only for CPUs. */
     356    char szCpuPath[64];
     357# if defined(RT_ARCH_AMD64) || defined(RT_ARCH_X86)
     358    RTStrPrintf(szCpuPath, sizeof(szCpuPath), "IODeviceTree:/cpus/CPU%X", idCpu);
     359# else
     360    RTStrPrintf(szCpuPath, sizeof(szCpuPath), "IODeviceTree:/cpus/cpu%x", idCpu); /** @todo Hex? M1 Max only has 10 cores... */
     361# endif
     362    io_registry_entry_t hIoRegEntry = IORegistryEntryFromPath(kIOMasterPortDefault, szCpuPath);
     363    if (hIoRegEntry != MACH_PORT_NULL)
     364    {
     365        uint32_t uCpuFrequency = rtMpDarwinGetMaxFrequencyFromIOService(hIoRegEntry);
     366        IOObjectRelease(hIoRegEntry);
     367        if (uCpuFrequency)
     368            return uCpuFrequency;
     369    }
     370
     371#else
    353372    /* Assume names on the form "cpu<N>" are only for CPUs. */
    354373    char szCpuName[32];
     
    367386    }
    368387
    369 #if 1 /* Just in case... */
     388# if 1 /* Just in case... */
    370389    /* Create a matching dictionary for searching for CPU services in the IOKit. */
    371 # if defined(RT_ARCH_ARM64) || defined(RT_ARCH_ARM32)
     390#  if defined(RT_ARCH_ARM64) || defined(RT_ARCH_ARM32)
    372391    hMatchingDict = IOServiceMatching("AppleARMCPU");
    373 # elif defined(RT_ARCH_AMD64) || defined(RT_ARCH_X86)
     392#  elif defined(RT_ARCH_AMD64) || defined(RT_ARCH_X86)
    374393    hMatchingDict = IOServiceMatching("AppleACPICPU");
    375 # else
    376 error "Port me!"
    377 # endif
     394#  else
     395 error "Port me!"
     396#  endif
    378397    AssertReturn(hMatchingDict, 0);
    379398
     
    399418    }
    400419    IOObjectRelease(hCpuServices);
     420# endif
    401421#endif
    402 
    403422    AssertFailed();
    404423    return 0;
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