Changeset 87205 in vbox
- Timestamp:
- Jan 8, 2021 4:55:19 PM (4 years ago)
- svn:sync-xref-src-repo-rev:
- 142158
- Location:
- trunk/src/VBox/Runtime
- Files:
-
- 2 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/Makefile.kmk
r87201 r87205 1289 1289 RuntimeR3_SOURCES.darwin.x86 += common/string/memrchr.asm 1290 1290 RuntimeR3_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 1291 RuntimeR3_SOURCES.darwin.arm32 += \ 1292 common/string/memrchr.cpp \ 1293 r3/darwin/RTMpGetDescription-generic.cpp 1294 RuntimeR3_SOURCES.darwin.arm64 += \ 1295 common/string/memrchr.cpp \ 1296 r3/darwin/RTMpGetDescription-generic.cpp 1293 1297 1294 1298 ## @todo Make BSD sched, implement RTMP*. -
trunk/src/VBox/Runtime/generic/RTMpGetDescription-generic.cpp
r82968 r87205 94 94 } 95 95 96 #elif defined(RT_ARCH_ARM64) 97 RTCCINTREG uFreq; 98 96 99 #else 97 100 # error "PORTME or use RTMpGetDescription-generic-stub.cpp." -
trunk/src/VBox/Runtime/r3/darwin/RTMpGetDescription-generic.cpp
r87178 r87205 1 1 /* $Id$ */ 2 2 /** @file 3 * IPRT - Multiprocessor, Generic RTMpGetDescription.3 * IPRT - Multiprocessor, RTMpGetDescription for darwin/arm. 4 4 */ 5 5 6 6 /* 7 * Copyright (C) 2009-202 0Oracle Corporation7 * Copyright (C) 2009-2021 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 31 31 #include <iprt/mp.h> 32 32 #include "internal/iprt.h" 33 #if defined(RT_ARCH_AMD64) || defined(RT_ARCH_X86)34 # include <iprt/asm-amd64-x86.h>35 #endif36 33 #include <iprt/err.h> 37 34 #include <iprt/string.h> 38 35 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> 56 37 57 38 … … 67 48 68 49 /* 69 * Construct the description string in a temporary buffer.50 * Just use the sysctl machdep.cpu.brand_string value for now. 70 51 */ 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'; 76 59 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"); 109 64 } 110 65 RT_EXPORT_SYMBOL(RTMpGetDescription);
Note:
See TracChangeset
for help on using the changeset viewer.