Changeset 108215 in vbox for trunk/src/VBox/Runtime/common/acpi/acpi-ns.cpp
- Timestamp:
- Feb 13, 2025 6:24:31 PM (3 months ago)
- svn:sync-xref-src-repo-rev:
- 167535
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/common/acpi/acpi-ns.cpp
r108184 r108215 231 231 int rc = rtAcpiNsAddEntryWorker(pNsRoot, pszNameString, fSwitchTo, &pNsEntry); 232 232 if (RT_SUCCESS(rc)) 233 { 234 pNsEntry->fAstNd = true; 233 235 pNsEntry->pAstNd = pAstNd; 236 } 234 237 235 238 return rc; … … 243 246 if (RT_SUCCESS(rc)) 244 247 { 248 pNsEntry->fAstNd = false; 245 249 pNsEntry->pAstNd = NULL; 246 250 pNsEntry->offBits = offBits; … … 252 256 253 257 258 DECLHIDDEN(int) rtAcpiNsAddEntryExternal(PRTACPINSROOT pNsRoot, const char *pszNameString, PCRTACPIASLEXTERNAL pExternal) 259 { 260 PRTACPINSENTRY pNsEntry = NULL; 261 int rc = rtAcpiNsAddEntryWorker(pNsRoot, pszNameString, false /*fSwitchTo*/, &pNsEntry); 262 if (RT_SUCCESS(rc)) 263 { 264 pNsEntry->fAstNd = false; 265 pNsEntry->pExternal = pExternal; 266 } 267 268 return rc; 269 } 270 271 272 DECLHIDDEN(int) rtAcpiNsQueryNamePathForNameString(PRTACPINSROOT pNsRoot, const char *pszNameString, char *pachNamePath, size_t *pcchNamePath) 273 { 274 AssertReturn(!pachNamePath || *pcchNamePath >= 6, VERR_INVALID_PARAMETER); /* Needs to support at least \XXXX and the zero terminator. */ 275 276 const char *pszNameSegLast = NULL; 277 PCRTACPINSENTRY pNsEntry = rtAcpiNsLookupWorker(pNsRoot, pszNameString, true /*fExcludeLast*/, &pszNameSegLast); 278 if (pNsEntry) 279 { 280 int rc = VERR_BUFFER_OVERFLOW; 281 size_t cchNamePath = 1; /* For the root prefix. */ 282 283 if (!pachNamePath) 284 { 285 /* Calculate the name path size based on the number of segments. */ 286 uint32_t cEntries = 0; 287 do 288 { 289 cEntries++; 290 pNsEntry = pNsEntry->pParent; 291 } while (pNsEntry); 292 293 cchNamePath += cEntries * (4 + 1) - 1; /* XXXX., except for the last one. */ 294 } 295 else 296 { 297 uint32_t idxEntry = 0; 298 PCRTACPINSENTRY aNsEntries[255]; /* Maximum amount of name segments possible. */ 299 do 300 { 301 aNsEntries[idxEntry++] = pNsEntry; 302 pNsEntry = pNsEntry->pParent; 303 } while (pNsEntry); 304 305 char *pch = pachNamePath; 306 *pch++ = '\\'; 307 *pch = '\0'; 308 309 /* The last entry must be the root entry. */ 310 idxEntry--; 311 Assert(!aNsEntries[idxEntry]->pParent); 312 313 while (idxEntry) 314 { 315 pNsEntry = aNsEntries[--idxEntry]; 316 if (cchNamePath + 5 < *pcchNamePath) 317 { 318 pch[0] = pNsEntry->achNameSeg[0]; 319 pch[1] = pNsEntry->achNameSeg[1]; 320 pch[2] = pNsEntry->achNameSeg[2]; 321 pch[3] = pNsEntry->achNameSeg[3]; 322 pch[4] = '.'; 323 pch += 5; 324 } 325 cchNamePath += 5; 326 } 327 328 /* Append the last name segment. */ 329 if (cchNamePath + 5 < *pcchNamePath) 330 { 331 pch[0] = pszNameSegLast[0]; 332 pch[1] = pszNameSegLast[1]; 333 pch[2] = pszNameSegLast[2]; 334 pch[3] = pszNameSegLast[3]; 335 pch[4] = '\0'; 336 cchNamePath += 4; 337 } 338 339 if (cchNamePath <= *pcchNamePath) 340 rc = VINF_SUCCESS; 341 } 342 343 *pcchNamePath = cchNamePath; 344 return rc; 345 } 346 347 *pcchNamePath = 0; 348 return VERR_NOT_FOUND; 349 } 350 351 254 352 DECLHIDDEN(int) rtAcpiNsPop(PRTACPINSROOT pNsRoot) 255 353 {
Note:
See TracChangeset
for help on using the changeset viewer.