VirtualBox

Changeset 101470 in vbox for trunk/src/VBox/Runtime/common


Ignore:
Timestamp:
Oct 17, 2023 10:33:30 AM (15 months ago)
Author:
vboxsync
Message:

Runtime/RTFdt: Add convenience method to add a property consisting of an arbitrary number of u32 cells which are given as an array, bugref:10528

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/common/misc/fdt.cpp

    r101453 r101470  
    15951595
    15961596
     1597RTDECL(int) RTFdtNodePropertyAddCellsU32AsArray(RTFDT hFdt, const char *pszProperty, uint32_t cCells, uint32_t *pau32Cells)
     1598{
     1599    PRTFDTINT pThis = hFdt;
     1600    AssertPtrReturn(pThis, VERR_INVALID_HANDLE);
     1601
     1602    /* Insert the property name into the strings block. */
     1603    uint32_t offStr;
     1604    int rc = rtFdtStringsInsertString(pThis, pszProperty, &offStr);
     1605    if (RT_FAILURE(rc))
     1606        return rc;
     1607
     1608    uint32_t cbProp = cCells * sizeof(uint32_t) + 3 * sizeof(uint32_t);
     1609
     1610    rc = rtFdtStructEnsureSpace(pThis, cbProp);
     1611    if (RT_FAILURE(rc))
     1612        return rc;
     1613
     1614    uint32_t *pu32 = (uint32_t *)(pThis->pbStruct + pThis->cbStruct);
     1615    *pu32++ = DTB_FDT_TOKEN_PROPERTY_BE;
     1616    *pu32++ = RT_H2BE_U32(cCells * sizeof(uint32_t));
     1617    *pu32++ = RT_H2BE_U32(offStr);
     1618    for (uint32_t i = 0; i < cCells; i++)
     1619        *pu32++ = RT_H2BE_U32(pau32Cells[i]);
     1620
     1621    pThis->cbStruct += cbProp;
     1622    return VINF_SUCCESS;
     1623}
     1624
     1625
    15971626RTDECL(int) RTFdtNodePropertyAddCellsU64(RTFDT hFdt, const char *pszProperty, uint32_t cCells, ...)
    15981627{
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