diff options
| author | Evan Lojewski <github@meklort.com> | 2020-11-07 17:57:34 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-11-07 17:57:34 -0700 |
| commit | e86f52c7073e3ce983c5e7e93286eb9a73fd8ba8 (patch) | |
| tree | e450aa708affb411a908ee84272984539fe19d17 /utils | |
| parent | 86e905d8e482562b78bff17e68f5cf0e1537cf2f (diff) | |
| download | bcm5719-ortega-e86f52c7073e3ce983c5e7e93286eb9a73fd8ba8.tar.gz bcm5719-ortega-e86f52c7073e3ce983c5e7e93286eb9a73fd8ba8.zip | |
build: Enable builds under FreeBSD (#164)
This fixes build related issues when attempting to compile firmware and tools under FreeBSD.
Note: Host tools have not been ported for raw register access.
Note: The Linux specific ethtool APIs are not available under FreeBSD, and so -t eth is not supported under FreeBSD.
Diffstat (limited to 'utils')
| -rwxr-xr-x | utils/bcmflash/CMakeLists.txt | 10 | ||||
| -rw-r--r-- | utils/bcmflash/create_header.c | 2 | ||||
| -rw-r--r-- | utils/bcmflash/main.cpp | 6 | ||||
| -rw-r--r-- | utils/bcmflash/nvm_blackbird.c | 119 | ||||
| -rw-r--r-- | utils/bcmflash/nvm_kh08p.c | 121 | ||||
| -rw-r--r-- | utils/bcmflash/nvm_talos2.c | 119 | ||||
| -rw-r--r-- | utils/bcmregtool/CMakeLists.txt | 2 | ||||
| -rw-r--r-- | utils/bcmregtool/main.cpp | 2 |
8 files changed, 184 insertions, 197 deletions
diff --git a/utils/bcmflash/CMakeLists.txt b/utils/bcmflash/CMakeLists.txt index 1839968..fd41194 100755 --- a/utils/bcmflash/CMakeLists.txt +++ b/utils/bcmflash/CMakeLists.txt @@ -7,7 +7,6 @@ set(SOURCES fileio.cpp bcmflash.h - ethtool.c ethtool.h # Support files for initializing the firmware header create_header.c create_header.h @@ -16,9 +15,18 @@ set(SOURCES nvm_kh08p.c ) +IF(CONFIG_HAVE_LINUX_ETHTOOL_H) + LIST(APPEND SOURCES + ethtool.c ethtool.h + ) +ENDIF() + simulator_add_executable(${PROJECT_NAME} ${SOURCES}) target_link_libraries(${PROJECT_NAME} PRIVATE NVRam VPD simulator OptParse) format_target_sources(${PROJECT_NAME}) INSTALL(TARGETS ${PROJECT_NAME} DESTINATION bin) + +ADD_ENDIANNESS_DEFINES(${PROJECT_NAME}) +ADD_ETHTOOL_DEFINES(${PROJECT_NAME}) diff --git a/utils/bcmflash/create_header.c b/utils/bcmflash/create_header.c index 5983370..133c351 100644 --- a/utils/bcmflash/create_header.c +++ b/utils/bcmflash/create_header.c @@ -45,8 +45,8 @@ #include "create_header.h" #include <NVRam.h> +#include <bcm5719-endian.h> #include <bcm5719_eeprom.h> -#include <endian.h> #include <string.h> static struct diff --git a/utils/bcmflash/main.cpp b/utils/bcmflash/main.cpp index 32c5916..cacf81e 100644 --- a/utils/bcmflash/main.cpp +++ b/utils/bcmflash/main.cpp @@ -44,14 +44,16 @@ #include "bcmflash.h" #include "create_header.h" +#ifdef CONFIG_HAVE_LINUX_ETHTOOL_H #include "ethtool.h" +#endif #include <../bcm5719_NVM.h> #include <NVRam.h> #include <OptionParser.h> +#include <bcm5719-endian.h> #include <bcm5719_DEVICE.h> #include <bcm5719_eeprom.h> -#include <endian.h> #include <stdbool.h> #include <stdint.h> #include <stdio.h> @@ -94,6 +96,7 @@ storage_t gStorage[] = { .write = bcmflash_nvram_write, .size = bcmflash_nvram_size, }, +#ifdef ENDIANNESS_CONFIG_HAVE_LINUX_ETHTOOL_H { .type = "eth", .type_help = "Use the specified network interface (tg3 driver must be loaded).", @@ -102,6 +105,7 @@ storage_t gStorage[] = { .write = bcmflash_ethtool_write, .size = bcmflash_ethtool_size, }, +#endif { .type = "file", .type_help = "Use the file specified.", diff --git a/utils/bcmflash/nvm_blackbird.c b/utils/bcmflash/nvm_blackbird.c index dcec68a..49befcb 100644 --- a/utils/bcmflash/nvm_blackbird.c +++ b/utils/bcmflash/nvm_blackbird.c @@ -44,24 +44,15 @@ #include "create_header.h" +#include <bcm5719-endian.h> #include <bcm5719_eeprom.h> -#ifdef __LITTLE_ENDIAN__ -#define htobe32(__x__) ((((__x__)&0x000000FF) << 24) | (((__x__)&0x0000FF00) << 8) | (((__x__)&0x00FF0000) >> 8) | (((__x__)&0xFF000000) >> 24)) -#define htobe16(__x__) ((((__x__)&0x00FF) << 8) | (((__x__)&0xFF00) >> 8)) -#elif __BIG_ENDIAN__ -#define htobe32(__x__) (__x__) -#define htobe16(__x__) (__x__) -#else -#error Unknown endianness -#endif - NVRAMInfo2_t gBlackbirdNVRAMInfo2 = { - .mfr2Unk = 0, // [200] 00 00 -- Unknown, probably unused. - .mfr2Len = htobe16(sizeof(NVRAMInfo2_t)), // [202] 00 8C -- Length of manufacturing section 2. - .UNKNOWN0 = 0, // [204] 00 00 00 00 -- Could be reserved. + .mfr2Unk = 0, // [200] 00 00 -- Unknown, probably unused. + .mfr2Len = swap16(sizeof(NVRAMInfo2_t)), // [202] 00 8C -- Length of manufacturing section 2. + .UNKNOWN0 = 0, // [204] 00 00 00 00 -- Could be reserved. - .macAddr2 = { htobe32(0x1022), htobe32(0x33445562) }, + .macAddr2 = { swap32(0x1022), swap32(0x33445562) }, .UNKNOWN1 = 0, // [210] 0 .UNKNOWN2 = 0, // [214] 0 @@ -70,55 +61,55 @@ NVRAMInfo2_t gBlackbirdNVRAMInfo2 = { .UNKNOWN4 = 0, // [220] 0 .UNKNOWN5 = 0, // [224] 0 - .func3PXEVLAN = htobe16(0), - .func2PXEVLAN = htobe16(0), - - .pciSubsystemF1GPHY = htobe16(0x1981), - .pciSubsystemF0GPHY = htobe16(0x1981), - .pciSubsystemF3GPHY = htobe16(0x1981), - .pciSubsystemF2GPHY = htobe16(0x1981), - .pciSubsystemF1SERDES = htobe16(0x1657), - .pciSubsystemF0SERDES = htobe16(0x1657), - .pciSubsystemF3SERDES = htobe16(0x1657), - .pciSubsystemF2SERDES = htobe16(0x1657), - - .UNKNOWN7 = 0, // [23C] 0 - .UNKNOWN8 = 0, // [240] 0 - .UNKNOWN9 = 0, // [244] 0 - .UNKNOWN10 = 0, // [248] 0 - .UNKNOWN11 = 0, // [24C] 0 - .func2CfgFeature = htobe32(0xC5C00000), // 1 [250] C5 C0 00 00 - Function 2 GEN_CFG_1E4. - .func2CfgHW = htobe32(0x00004014), // 1 [254] 00 00 40 14 - Function 2 GEN_CFG_2. - - .macAddr3 = { htobe32(0x1022), htobe32(0x33445563) }, - - .func3CfgFeature = htobe32(0xC5C00000), // 1 [260] C5 C0 00 00 - Function 3 GEN_CFG_1E4. - .func3CfgHW = htobe32(0x00004014), // 1 [264] 00 00 40 14 - Function 3 GEN_CFG_2. - .UNKNOWN12 = 0, // [268] 0a - .UNKNOWN13 = 0, // [26C] 0a - .UNKNOWN14 = 0, // [270] 0a - .UNKNOWN15 = 0, // [274] 0a - .func0CfgHW2 = htobe32(0x00000040), // 1 [278] 00 00 00 40 - Function 0 GEN_CFG_2A8.a - .func1CfgHW2 = htobe32(0x00000040), // 1 [27C] 00 00 00 40 - Function 1 GEN_CFG_2A8.a - .func2CfgHW2 = htobe32(0x00000040), // 1 [280] 00 00 00 40 - Function 2 GEN_CFG_2A8.a - .func3CfgHW2 = htobe32(0x00000040), // 1 [284] 00 00 00 40 - Function 3 GEN_CFG_2A8.a - .mfr2CRC = 0, // [288] 1A AC 41 A6 // could be CRC + .func3PXEVLAN = swap16(0), + .func2PXEVLAN = swap16(0), + + .pciSubsystemF1GPHY = swap16(0x1981), + .pciSubsystemF0GPHY = swap16(0x1981), + .pciSubsystemF3GPHY = swap16(0x1981), + .pciSubsystemF2GPHY = swap16(0x1981), + .pciSubsystemF1SERDES = swap16(0x1657), + .pciSubsystemF0SERDES = swap16(0x1657), + .pciSubsystemF3SERDES = swap16(0x1657), + .pciSubsystemF2SERDES = swap16(0x1657), + + .UNKNOWN7 = 0, // [23C] 0 + .UNKNOWN8 = 0, // [240] 0 + .UNKNOWN9 = 0, // [244] 0 + .UNKNOWN10 = 0, // [248] 0 + .UNKNOWN11 = 0, // [24C] 0 + .func2CfgFeature = swap32(0xC5C00000), // 1 [250] C5 C0 00 00 - Function 2 GEN_CFG_1E4. + .func2CfgHW = swap32(0x00004014), // 1 [254] 00 00 40 14 - Function 2 GEN_CFG_2. + + .macAddr3 = { swap32(0x1022), swap32(0x33445563) }, + + .func3CfgFeature = swap32(0xC5C00000), // 1 [260] C5 C0 00 00 - Function 3 GEN_CFG_1E4. + .func3CfgHW = swap32(0x00004014), // 1 [264] 00 00 40 14 - Function 3 GEN_CFG_2. + .UNKNOWN12 = 0, // [268] 0a + .UNKNOWN13 = 0, // [26C] 0a + .UNKNOWN14 = 0, // [270] 0a + .UNKNOWN15 = 0, // [274] 0a + .func0CfgHW2 = swap32(0x00000040), // 1 [278] 00 00 00 40 - Function 0 GEN_CFG_2A8.a + .func1CfgHW2 = swap32(0x00000040), // 1 [27C] 00 00 00 40 - Function 1 GEN_CFG_2A8.a + .func2CfgHW2 = swap32(0x00000040), // 1 [280] 00 00 00 40 - Function 2 GEN_CFG_2A8.a + .func3CfgHW2 = swap32(0x00000040), // 1 [284] 00 00 00 40 - Function 3 GEN_CFG_2A8.a + .mfr2CRC = 0, // [288] 1A AC 41 A6 // could be CRC }; NVRAMInfo_t gBlackbirdNVRAMInfo = { - .macAddr0 = { htobe32(0x1022), htobe32(0x33445560) }, + .macAddr0 = { swap32(0x1022), swap32(0x33445560) }, .partNumber = "BCM95719", .partRevision = { 'A', '0' }, .firmwareRevision = 0, /* Placeholder*/ .mfrData = { 0 }, .func1PXEVLAN = 0, .func0PXEVLAN = 0, - .deviceID = htobe16(0x1657), /*< PCI Device ID. */ - .vendorID = htobe16(0x14E4), /*< PCI Vendor ID. */ - .subsystemDeviceID = htobe16(0x1657), /*< PCI Subsystem Device ID. */ - .subsystemVendorID = htobe16(0x14E4), /*< PCI Subsystem Vendor ID. */ + .deviceID = swap16(0x1657), /*< PCI Device ID. */ + .vendorID = swap16(0x14E4), /*< PCI Vendor ID. */ + .subsystemDeviceID = swap16(0x1657), /*< PCI Subsystem Device ID. */ + .subsystemVendorID = swap16(0x14E4), /*< PCI Subsystem Vendor ID. */ - .cpuClock = htobe16(66), /*< 66MHz, Legacy */ + .cpuClock = swap16(66), /*< 66MHz, Legacy */ .SMBusAddr = 0, .SMBusAddrBMC = 0, @@ -136,23 +127,23 @@ NVRAMInfo_t gBlackbirdNVRAMInfo = { .powerConsumedD2 = 0x00, /*< Power consumed in the D2 state. The NetXtreme II family does not support the D2 state. */ .powerConsumedD3 = 0x0A, /*< Power consumed in the D3 state. Note: The data scale is hard coded at 0.1. */ - .func0CfgFeature = htobe32(0xC5C00080), - .func0CfgHW = htobe32(0x00004014), + .func0CfgFeature = swap32(0xC5C00080), + .func0CfgHW = swap32(0x00004014), - .macAddr1 = { htobe32(0x1022), htobe32(0x33445561) }, - .func1CfgFeature = htobe32(0xC5C00000), - .func1CfgHW = htobe32(0x00004014), + .macAddr1 = { swap32(0x1022), swap32(0x33445561) }, + .func1CfgFeature = swap32(0xC5C00000), + .func1CfgHW = swap32(0x00004014), - .cfgShared = htobe32(0x00C2AA38), - .powerBudget0 = htobe32(0x2C163C2C), - .powerBudget1 = htobe32(0x0000230A), + .cfgShared = swap32(0x00C2AA38), + .powerBudget0 = swap32(0x2C163C2C), + .powerBudget1 = swap32(0x0000230A), .serworksUse = 0, .func1SERDESOverride = 0, .func0SERDESOverride = 0, .tpmNVMSize = 0, - .macNVMSize = htobe16(4), - .powerBudget2 = htobe32(0x00000000), - .powerBudget3 = htobe32(0x00000000), + .macNVMSize = swap16(4), + .powerBudget2 = swap32(0x00000000), + .powerBudget3 = swap32(0x00000000), .mfrCRC = 0, }; diff --git a/utils/bcmflash/nvm_kh08p.c b/utils/bcmflash/nvm_kh08p.c index 3deb019..3ce4e7d 100644 --- a/utils/bcmflash/nvm_kh08p.c +++ b/utils/bcmflash/nvm_kh08p.c @@ -44,24 +44,15 @@ #include "create_header.h" +#include <bcm5719-endian.h> #include <bcm5719_eeprom.h> -#ifdef __LITTLE_ENDIAN__ -#define htobe32(__x__) ((((__x__)&0x000000FF) << 24) | (((__x__)&0x0000FF00) << 8) | (((__x__)&0x00FF0000) >> 8) | (((__x__)&0xFF000000) >> 24)) -#define htobe16(__x__) ((((__x__)&0x00FF) << 8) | (((__x__)&0xFF00) >> 8)) -#elif __BIG_ENDIAN__ -#define htobe32(__x__) (__x__) -#define htobe16(__x__) (__x__) -#else -#error Unknown endianness -#endif - NVRAMInfo2_t gKH08PNVRAMInfo2 = { - .mfr2Unk = 0, // [200] 00 00 -- Unknown, probably unused. - .mfr2Len = htobe16(sizeof(NVRAMInfo2_t)), // [202] 00 8C -- Length of manufacturing section 2. - .UNKNOWN0 = 0, // [204] 00 00 00 00 -- Could be reserved. + .mfr2Unk = 0, // [200] 00 00 -- Unknown, probably unused. + .mfr2Len = swap16(sizeof(NVRAMInfo2_t)), // [202] 00 8C -- Length of manufacturing section 2. + .UNKNOWN0 = 0, // [204] 00 00 00 00 -- Could be reserved. - .macAddr2 = { htobe32(0x1022), htobe32(0x33445568) }, + .macAddr2 = { swap32(0x1022), swap32(0x33445568) }, .UNKNOWN1 = 0, // [210] 0 .UNKNOWN2 = 0, // [214] 0 @@ -70,55 +61,55 @@ NVRAMInfo2_t gKH08PNVRAMInfo2 = { .UNKNOWN4 = 0, // [220] 0 .UNKNOWN5 = 0, // [224] 0 - .func3PXEVLAN = htobe16(1), - .func2PXEVLAN = htobe16(1), - - .pciSubsystemF1GPHY = htobe16(0x1904), - .pciSubsystemF0GPHY = htobe16(0x1904), - .pciSubsystemF3GPHY = htobe16(0x1904), - .pciSubsystemF2GPHY = htobe16(0x1904), - .pciSubsystemF1SERDES = htobe16(0x1657), - .pciSubsystemF0SERDES = htobe16(0x1657), - .pciSubsystemF3SERDES = htobe16(0x1657), - .pciSubsystemF2SERDES = htobe16(0x1657), - - .UNKNOWN7 = 0, // [23C] 0 - .UNKNOWN8 = 0, // [240] 0 - .UNKNOWN9 = 0, // [244] 0 - .UNKNOWN10 = 0, // [248] 0 - .UNKNOWN11 = 0, // [24C] 0 - .func2CfgFeature = htobe32(0xCDB50202), // 1 [250] C5 C0 00 00 - Function 2 GEN_CFG_1E4. - .func2CfgHW = htobe32(0x00006014), // 1 [254] 00 00 40 14 - Function 2 GEN_CFG_2. - - .macAddr3 = { htobe32(0x1022), htobe32(0x33445569) }, - - .func3CfgFeature = htobe32(0xCDB50202), // 1 [260] C5 C0 00 00 - Function 3 GEN_CFG_1E4. - .func3CfgHW = htobe32(0x00006014), // 1 [264] 00 00 40 14 - Function 3 GEN_CFG_2. - .UNKNOWN12 = 0, // [268] 0a - .UNKNOWN13 = 0, // [26C] 0a - .UNKNOWN14 = 0, // [270] 0a - .UNKNOWN15 = 0, // [274] 0a - .func0CfgHW2 = htobe32(0x00000042), - .func1CfgHW2 = htobe32(0x00000042), - .func2CfgHW2 = htobe32(0x00000042), - .func3CfgHW2 = htobe32(0x00000042), + .func3PXEVLAN = swap16(1), + .func2PXEVLAN = swap16(1), + + .pciSubsystemF1GPHY = swap16(0x1904), + .pciSubsystemF0GPHY = swap16(0x1904), + .pciSubsystemF3GPHY = swap16(0x1904), + .pciSubsystemF2GPHY = swap16(0x1904), + .pciSubsystemF1SERDES = swap16(0x1657), + .pciSubsystemF0SERDES = swap16(0x1657), + .pciSubsystemF3SERDES = swap16(0x1657), + .pciSubsystemF2SERDES = swap16(0x1657), + + .UNKNOWN7 = 0, // [23C] 0 + .UNKNOWN8 = 0, // [240] 0 + .UNKNOWN9 = 0, // [244] 0 + .UNKNOWN10 = 0, // [248] 0 + .UNKNOWN11 = 0, // [24C] 0 + .func2CfgFeature = swap32(0xCDB50202), // 1 [250] C5 C0 00 00 - Function 2 GEN_CFG_1E4. + .func2CfgHW = swap32(0x00006014), // 1 [254] 00 00 40 14 - Function 2 GEN_CFG_2. + + .macAddr3 = { swap32(0x1022), swap32(0x33445569) }, + + .func3CfgFeature = swap32(0xCDB50202), // 1 [260] C5 C0 00 00 - Function 3 GEN_CFG_1E4. + .func3CfgHW = swap32(0x00006014), // 1 [264] 00 00 40 14 - Function 3 GEN_CFG_2. + .UNKNOWN12 = 0, // [268] 0a + .UNKNOWN13 = 0, // [26C] 0a + .UNKNOWN14 = 0, // [270] 0a + .UNKNOWN15 = 0, // [274] 0a + .func0CfgHW2 = swap32(0x00000042), + .func1CfgHW2 = swap32(0x00000042), + .func2CfgHW2 = swap32(0x00000042), + .func3CfgHW2 = swap32(0x00000042), .mfr2CRC = 0, // [288] 1A AC 41 A6 // could be CRC }; NVRAMInfo_t gKH08PNVRAMInfo = { - .macAddr0 = { htobe32(0x1022), htobe32(0x33445566) }, + .macAddr0 = { swap32(0x1022), swap32(0x33445566) }, .partNumber = "BCM95719", .partRevision = { 'A', '0' }, .firmwareRevision = 0, /* Placeholder*/ .mfrData = { 0 }, - .func1PXEVLAN = htobe16(1), - .func0PXEVLAN = htobe16(1), - .deviceID = htobe16(0x1657), /*< PCI Device ID. */ - .vendorID = htobe16(0x14E4), /*< PCI Vendor ID. */ - .subsystemDeviceID = htobe16(0x1657), /*< PCI Subsystem Device ID. */ - .subsystemVendorID = htobe16(0x14E4), /*< PCI Subsystem Vendor ID. */ + .func1PXEVLAN = swap16(1), + .func0PXEVLAN = swap16(1), + .deviceID = swap16(0x1657), /*< PCI Device ID. */ + .vendorID = swap16(0x14E4), /*< PCI Vendor ID. */ + .subsystemDeviceID = swap16(0x1657), /*< PCI Subsystem Device ID. */ + .subsystemVendorID = swap16(0x14E4), /*< PCI Subsystem Vendor ID. */ - .cpuClock = htobe16(66), /*< 66MHz, Legacy */ + .cpuClock = swap16(66), /*< 66MHz, Legacy */ .SMBusAddr = 0x64, .SMBusAddrBMC = 0, @@ -136,23 +127,23 @@ NVRAMInfo_t gKH08PNVRAMInfo = { .powerConsumedD2 = 0x00, /*< Power consumed in the D2 state. The NetXtreme II family does not support the D2 state. */ .powerConsumedD3 = 0x0A, /*< Power consumed in the D3 state. Note: The data scale is hard coded at 0.1. */ - .func0CfgFeature = htobe32(0xCDB50282), - .func0CfgHW = htobe32(0x00006014), + .func0CfgFeature = swap32(0xCDB50282), + .func0CfgHW = swap32(0x00006014), - .macAddr1 = { htobe32(0x1022), htobe32(0x33445567) }, - .func1CfgFeature = htobe32(0xCDB50202), - .func1CfgHW = htobe32(0x00006014), + .macAddr1 = { swap32(0x1022), swap32(0x33445567) }, + .func1CfgFeature = swap32(0xCDB50202), + .func1CfgHW = swap32(0x00006014), - .cfgShared = htobe32(0x0012AA38), - .powerBudget0 = htobe32(0x2C163C2C), - .powerBudget1 = htobe32(0x0000230A), + .cfgShared = swap32(0x0012AA38), + .powerBudget0 = swap32(0x2C163C2C), + .powerBudget1 = swap32(0x0000230A), .serworksUse = 0, .func1SERDESOverride = 0, .func0SERDESOverride = 0, .tpmNVMSize = 0, - .macNVMSize = htobe16(2), - .powerBudget2 = htobe32(0x00000000), - .powerBudget3 = htobe32(0x00000000), + .macNVMSize = swap16(2), + .powerBudget2 = swap32(0x00000000), + .powerBudget3 = swap32(0x00000000), .mfrCRC = 0, }; diff --git a/utils/bcmflash/nvm_talos2.c b/utils/bcmflash/nvm_talos2.c index c47e391..8158df4 100644 --- a/utils/bcmflash/nvm_talos2.c +++ b/utils/bcmflash/nvm_talos2.c @@ -44,24 +44,15 @@ #include "create_header.h" +#include <bcm5719-endian.h> #include <bcm5719_eeprom.h> -#ifdef __LITTLE_ENDIAN__ -#define htobe32(__x__) ((((__x__)&0x000000FF) << 24) | (((__x__)&0x0000FF00) << 8) | (((__x__)&0x00FF0000) >> 8) | (((__x__)&0xFF000000) >> 24)) -#define htobe16(__x__) ((((__x__)&0x00FF) << 8) | (((__x__)&0xFF00) >> 8)) -#elif __BIG_ENDIAN__ -#define htobe32(__x__) (__x__) -#define htobe16(__x__) (__x__) -#else -#error Unknown endianness -#endif - NVRAMInfo2_t gTalosIINVRAMInfo2 = { - .mfr2Unk = 0, // [200] 00 00 -- Unknown, probably unused. - .mfr2Len = htobe16(sizeof(NVRAMInfo2_t)), // [202] 00 8C -- Length of manufacturing section 2. - .UNKNOWN0 = 0, // [204] 00 00 00 00 -- Could be reserved. + .mfr2Unk = 0, // [200] 00 00 -- Unknown, probably unused. + .mfr2Len = swap16(sizeof(NVRAMInfo2_t)), // [202] 00 8C -- Length of manufacturing section 2. + .UNKNOWN0 = 0, // [204] 00 00 00 00 -- Could be reserved. - .macAddr2 = { htobe32(0x1022), htobe32(0x33445572) }, + .macAddr2 = { swap32(0x1022), swap32(0x33445572) }, .UNKNOWN1 = 0, // [210] 0 .UNKNOWN2 = 0, // [214] 0 @@ -70,55 +61,55 @@ NVRAMInfo2_t gTalosIINVRAMInfo2 = { .UNKNOWN4 = 0, // [220] 0 .UNKNOWN5 = 0, // [224] 0 - .func3PXEVLAN = htobe16(0), - .func2PXEVLAN = htobe16(0), - - .pciSubsystemF1GPHY = htobe16(0x1981), - .pciSubsystemF0GPHY = htobe16(0x1981), - .pciSubsystemF3GPHY = htobe16(0x1981), - .pciSubsystemF2GPHY = htobe16(0x1981), - .pciSubsystemF1SERDES = htobe16(0x1657), - .pciSubsystemF0SERDES = htobe16(0x1657), - .pciSubsystemF3SERDES = htobe16(0x1657), - .pciSubsystemF2SERDES = htobe16(0x1657), - - .UNKNOWN7 = 0, // [23C] 0 - .UNKNOWN8 = 0, // [240] 0 - .UNKNOWN9 = 0, // [244] 0 - .UNKNOWN10 = 0, // [248] 0 - .UNKNOWN11 = 0, // [24C] 0 - .func2CfgFeature = htobe32(0xC5C00000), // 1 [250] C5 C0 00 00 - Function 2 GEN_CFG_1E4. - .func2CfgHW = htobe32(0x00004014), // 1 [254] 00 00 40 14 - Function 2 GEN_CFG_2. - - .macAddr3 = { htobe32(0x1022), htobe32(0x33445573) }, - - .func3CfgFeature = htobe32(0xC5C00000), // 1 [260] C5 C0 00 00 - Function 3 GEN_CFG_1E4. - .func3CfgHW = htobe32(0x00004014), // 1 [264] 00 00 40 14 - Function 3 GEN_CFG_2. - .UNKNOWN12 = 0, // [268] 0a - .UNKNOWN13 = 0, // [26C] 0a - .UNKNOWN14 = 0, // [270] 0a - .UNKNOWN15 = 0, // [274] 0a - .func0CfgHW2 = htobe32(0x00000040), // 1 [278] 00 00 00 40 - Function 0 GEN_CFG_2A8.a - .func1CfgHW2 = htobe32(0x00000040), // 1 [27C] 00 00 00 40 - Function 1 GEN_CFG_2A8.a - .func2CfgHW2 = htobe32(0x00000040), // 1 [280] 00 00 00 40 - Function 2 GEN_CFG_2A8.a - .func3CfgHW2 = htobe32(0x00000040), // 1 [284] 00 00 00 40 - Function 3 GEN_CFG_2A8.a - .mfr2CRC = 0, // [288] 1A AC 41 A6 // could be CRC + .func3PXEVLAN = swap16(0), + .func2PXEVLAN = swap16(0), + + .pciSubsystemF1GPHY = swap16(0x1981), + .pciSubsystemF0GPHY = swap16(0x1981), + .pciSubsystemF3GPHY = swap16(0x1981), + .pciSubsystemF2GPHY = swap16(0x1981), + .pciSubsystemF1SERDES = swap16(0x1657), + .pciSubsystemF0SERDES = swap16(0x1657), + .pciSubsystemF3SERDES = swap16(0x1657), + .pciSubsystemF2SERDES = swap16(0x1657), + + .UNKNOWN7 = 0, // [23C] 0 + .UNKNOWN8 = 0, // [240] 0 + .UNKNOWN9 = 0, // [244] 0 + .UNKNOWN10 = 0, // [248] 0 + .UNKNOWN11 = 0, // [24C] 0 + .func2CfgFeature = swap32(0xC5C00000), // 1 [250] C5 C0 00 00 - Function 2 GEN_CFG_1E4. + .func2CfgHW = swap32(0x00004014), // 1 [254] 00 00 40 14 - Function 2 GEN_CFG_2. + + .macAddr3 = { swap32(0x1022), swap32(0x33445573) }, + + .func3CfgFeature = swap32(0xC5C00000), // 1 [260] C5 C0 00 00 - Function 3 GEN_CFG_1E4. + .func3CfgHW = swap32(0x00004014), // 1 [264] 00 00 40 14 - Function 3 GEN_CFG_2. + .UNKNOWN12 = 0, // [268] 0a + .UNKNOWN13 = 0, // [26C] 0a + .UNKNOWN14 = 0, // [270] 0a + .UNKNOWN15 = 0, // [274] 0a + .func0CfgHW2 = swap32(0x00000040), // 1 [278] 00 00 00 40 - Function 0 GEN_CFG_2A8.a + .func1CfgHW2 = swap32(0x00000040), // 1 [27C] 00 00 00 40 - Function 1 GEN_CFG_2A8.a + .func2CfgHW2 = swap32(0x00000040), // 1 [280] 00 00 00 40 - Function 2 GEN_CFG_2A8.a + .func3CfgHW2 = swap32(0x00000040), // 1 [284] 00 00 00 40 - Function 3 GEN_CFG_2A8.a + .mfr2CRC = 0, // [288] 1A AC 41 A6 // could be CRC }; NVRAMInfo_t gTalosIINVRAMInfo = { - .macAddr0 = { htobe32(0x1022), htobe32(0x33445570) }, + .macAddr0 = { swap32(0x1022), swap32(0x33445570) }, .partNumber = "BCM95719", .partRevision = { 'A', '0' }, .firmwareRevision = 0, /* Placeholder*/ .mfrData = { 0 }, .func1PXEVLAN = 0, .func0PXEVLAN = 0, - .deviceID = htobe16(0x1657), /*< PCI Device ID. */ - .vendorID = htobe16(0x14E4), /*< PCI Vendor ID. */ - .subsystemDeviceID = htobe16(0x1657), /*< PCI Subsystem Device ID. */ - .subsystemVendorID = htobe16(0x14E4), /*< PCI Subsystem Vendor ID. */ + .deviceID = swap16(0x1657), /*< PCI Device ID. */ + .vendorID = swap16(0x14E4), /*< PCI Vendor ID. */ + .subsystemDeviceID = swap16(0x1657), /*< PCI Subsystem Device ID. */ + .subsystemVendorID = swap16(0x14E4), /*< PCI Subsystem Vendor ID. */ - .cpuClock = htobe16(66), /*< 66MHz, Legacy */ + .cpuClock = swap16(66), /*< 66MHz, Legacy */ .SMBusAddr = 0, .SMBusAddrBMC = 0, @@ -136,23 +127,23 @@ NVRAMInfo_t gTalosIINVRAMInfo = { .powerConsumedD2 = 0x00, /*< Power consumed in the D2 state. The NetXtreme II family does not support the D2 state. */ .powerConsumedD3 = 0x0A, /*< Power consumed in the D3 state. Note: The data scale is hard coded at 0.1. */ - .func0CfgFeature = htobe32(0xC5C00080), - .func0CfgHW = htobe32(0x00004014), + .func0CfgFeature = swap32(0xC5C00080), + .func0CfgHW = swap32(0x00004014), - .macAddr1 = { htobe32(0x1022), htobe32(0x33445571) }, - .func1CfgFeature = htobe32(0xC5C00000), - .func1CfgHW = htobe32(0x00004014), + .macAddr1 = { swap32(0x1022), swap32(0x33445571) }, + .func1CfgFeature = swap32(0xC5C00000), + .func1CfgHW = swap32(0x00004014), - .cfgShared = htobe32(0x00C2AA38), - .powerBudget0 = htobe32(0x2C163C2C), - .powerBudget1 = htobe32(0x0000230A), + .cfgShared = swap32(0x00C2AA38), + .powerBudget0 = swap32(0x2C163C2C), + .powerBudget1 = swap32(0x0000230A), .serworksUse = 0, .func1SERDESOverride = 0, .func0SERDESOverride = 0, .tpmNVMSize = 0, - .macNVMSize = htobe16(4), - .powerBudget2 = htobe32(0x00000000), - .powerBudget3 = htobe32(0x00000000), + .macNVMSize = swap16(4), + .powerBudget2 = swap32(0x00000000), + .powerBudget3 = swap32(0x00000000), .mfrCRC = 0, }; diff --git a/utils/bcmregtool/CMakeLists.txt b/utils/bcmregtool/CMakeLists.txt index 4cc2376..862eb12 100644 --- a/utils/bcmregtool/CMakeLists.txt +++ b/utils/bcmregtool/CMakeLists.txt @@ -15,3 +15,5 @@ target_link_libraries(${PROJECT_NAME} PRIVATE simulator OptParse elfio) format_target_sources(${PROJECT_NAME}) INSTALL(TARGETS ${PROJECT_NAME} DESTINATION bin) + +ADD_ENDIANNESS_DEFINES(${PROJECT_NAME}) diff --git a/utils/bcmregtool/main.cpp b/utils/bcmregtool/main.cpp index cb273fb..a0dcb47 100644 --- a/utils/bcmregtool/main.cpp +++ b/utils/bcmregtool/main.cpp @@ -51,6 +51,7 @@ #include <MII.h> #include <NVRam.h> #include <OptionParser.h> +#include <bcm5719-endian.h> #include <bcm5719_APE.h> #include <bcm5719_GEN.h> #include <bcm5719_SHM.h> @@ -58,7 +59,6 @@ #include <bcm5719_SHM_CHANNEL1.h> #include <bcm5719_eeprom.h> #include <elfio/elfio.hpp> -#include <endian.h> #include <iostream> #include <stdbool.h> #include <stdint.h> |

