VirtualBox

Changeset 87205 in vbox


Ignore:
Timestamp:
Jan 8, 2021 4:55:19 PM (4 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
142158
Message:

IPRT: Added generic RTMpGetDescription implementation for darwin. bugref:9898

Location:
trunk/src/VBox/Runtime
Files:
2 edited
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/Makefile.kmk

    r87201 r87205  
    12891289RuntimeR3_SOURCES.darwin.x86   += common/string/memrchr.asm
    12901290RuntimeR3_SOURCES.darwin.amd64 += common/string/memrchr.asm
    1291 RuntimeR3_SOURCES.darwin.arm32 += common/string/memrchr.cpp
    1292 RuntimeR3_SOURCES.darwin.arm64 += common/string/memrchr.cpp
     1291RuntimeR3_SOURCES.darwin.arm32 += \
     1292        common/string/memrchr.cpp \
     1293        r3/darwin/RTMpGetDescription-generic.cpp
     1294RuntimeR3_SOURCES.darwin.arm64 += \
     1295        common/string/memrchr.cpp \
     1296        r3/darwin/RTMpGetDescription-generic.cpp
    12931297
    12941298## @todo Make BSD sched, implement RTMP*.
  • trunk/src/VBox/Runtime/generic/RTMpGetDescription-generic.cpp

    r82968 r87205  
    9494    }
    9595
     96#elif defined(RT_ARCH_ARM64)
     97    RTCCINTREG uFreq;
     98
    9699#else
    97100# error "PORTME or use RTMpGetDescription-generic-stub.cpp."
  • trunk/src/VBox/Runtime/r3/darwin/RTMpGetDescription-generic.cpp

    r87178 r87205  
    11/* $Id$ */
    22/** @file
    3  * IPRT - Multiprocessor, Generic RTMpGetDescription.
     3 * IPRT - Multiprocessor, RTMpGetDescription for darwin/arm.
    44 */
    55
    66/*
    7  * Copyright (C) 2009-2020 Oracle Corporation
     7 * Copyright (C) 2009-2021 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    3131#include <iprt/mp.h>
    3232#include "internal/iprt.h"
    33 #if defined(RT_ARCH_AMD64) || defined(RT_ARCH_X86)
    34 # include <iprt/asm-amd64-x86.h>
    35 #endif
    3633#include <iprt/err.h>
    3734#include <iprt/string.h>
    3835
    39 
    40 
    41 /**
    42  * Returns "Unknown" as description.
    43  *
    44  * @returns VERR_BUFFER_OVERFLOW or VINF_SUCCESS.
    45  * @param   pszBuf              Output buffer.
    46  * @param   cbBuf               Buffer size.
    47  */
    48 static int rtMpGetDescriptionUnknown(char *pszBuf, size_t cbBuf)
    49 {
    50     static const char s_szUnknown[] = "Unknown";
    51     if (cbBuf < sizeof(s_szUnknown))
    52         return VERR_BUFFER_OVERFLOW;
    53     memcpy(pszBuf, s_szUnknown, sizeof(s_szUnknown));
    54     return VINF_SUCCESS;
    55 }
     36#include <sys/sysctl.h>
    5637
    5738
     
    6748
    6849    /*
    69      * Construct the description string in a temporary buffer.
     50     * Just use the sysctl machdep.cpu.brand_string value for now.
    7051     */
    71     char        szString[4*4*3+1];
    72     RT_ZERO(szString);
    73 #if defined(RT_ARCH_AMD64) || defined(RT_ARCH_X86)
    74     if (!ASMHasCpuId())
    75         return rtMpGetDescriptionUnknown(pszBuf, cbBuf);
     52    /** @todo on arm this is very boring, so we could use the cpufamily and
     53     *        cpusubfamily instead... */
     54    char szBrand[128] = {0};
     55    size_t cb = sizeof(szBrand);
     56    int rc = sysctlbyname("machdep.cpu.brand_string", &szBrand, &cb, NULL, 0);
     57    if (rc == -1)
     58        szBrand[0] = '\0';
    7659
    77     uint32_t    uMax;
    78     uint32_t    uEBX, uECX, uEDX;
    79     ASMCpuId(0x80000000, &uMax, &uEBX, &uECX, &uEDX);
    80     if (uMax >= 0x80000002)
    81     {
    82         ASMCpuId(0x80000002,     &szString[0  + 0], &szString[0  + 4], &szString[0  + 8], &szString[0  + 12]);
    83         if (uMax >= 0x80000003)
    84             ASMCpuId(0x80000003, &szString[16 + 0], &szString[16 + 4], &szString[16 + 8], &szString[16 + 12]);
    85         if (uMax >= 0x80000004)
    86             ASMCpuId(0x80000004, &szString[32 + 0], &szString[32 + 4], &szString[32 + 8], &szString[32 + 12]);
    87     }
    88     else
    89     {
    90         ASMCpuId(0x00000000, &uMax, &uEBX, &uECX, &uEDX);
    91         ((uint32_t *)&szString[0])[0] = uEBX;
    92         ((uint32_t *)&szString[0])[1] = uEDX;
    93         ((uint32_t *)&szString[0])[2] = uECX;
    94     }
    95 
    96 #else
    97 # error "PORTME or use RTMpGetDescription-generic-stub.cpp."
    98 #endif
    99 
    100     /*
    101      * Copy it out into the buffer supplied by the caller.
    102      */
    103     char   *pszSrc = RTStrStrip(szString);
    104     size_t  cchSrc = strlen(pszSrc);
    105     if (cchSrc >= cbBuf)
    106         return VERR_BUFFER_OVERFLOW;
    107     memcpy(pszBuf, pszSrc, cchSrc + 1);
    108     return VINF_SUCCESS;
     60    char *pszStripped = RTStrStrip(szBrand);
     61    if (*pszStripped)
     62        return RTStrCopy(pszBuf, cbBuf, pszStripped);
     63    return RTStrCopy(pszBuf, cbBuf, "Unknown");
    10964}
    11065RT_EXPORT_SYMBOL(RTMpGetDescription);
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