summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEvan Lojewski <github@meklort.com>2020-11-08 12:44:06 -0700
committerGitHub <noreply@github.com>2020-11-08 12:44:06 -0700
commitdcf18c68966a622cac8bdfd3cdb4cb4675847433 (patch)
tree3f890c9a5f9d413b745ec5c0018f7362617e3733
parent9e45d2fe541e46576585cae950dc1e3ef62fef4e (diff)
downloadbcm5719-ortega-dcf18c68966a622cac8bdfd3cdb4cb4675847433.tar.gz
bcm5719-ortega-dcf18c68966a622cac8bdfd3cdb4cb4675847433.zip
stage1: Cleanup trivial linting warnings. (#166)
-rw-r--r--.clang.lnt.in4
-rw-r--r--stage1/CMakeLists.txt3
-rw-r--r--stage1/init_hw.c64
-rw-r--r--stage1/main.c25
-rw-r--r--stage1/stage1.h6
5 files changed, 44 insertions, 58 deletions
diff --git a/.clang.lnt.in b/.clang.lnt.in
index 4d24612..27ac4a4 100644
--- a/.clang.lnt.in
+++ b/.clang.lnt.in
@@ -120,8 +120,6 @@
// statement. For example:
-d"__asm__(p...)=/*lint -e{19}*/ __asm__(p)"
- -d"_Static_assert(p...)=/*lint -e{19}*/"
-
// ...causes Lint to be quiet about the semicolon that follows an
// __asm__() declaration. Note, the -e{N} form of suppression takes
// effect only for the forward-declaration, definition or
@@ -136,6 +134,8 @@
//
-esym(123,__asm__)
+++d"_Static_assert(...)=/*lint -e{19}*/"
+
-rw_asgn(__alignof__,__alignof)
// "__extension__" is GCC's way of allowing the use of non-standard
diff --git a/stage1/CMakeLists.txt b/stage1/CMakeLists.txt
index 9c100fd..fcaf8e6 100644
--- a/stage1/CMakeLists.txt
+++ b/stage1/CMakeLists.txt
@@ -60,7 +60,7 @@ target_link_libraries(${PROJECT_NAME}
target_link_libraries(${PROJECT_NAME} NVRam-mips MII-mips APE-mips printf-mips)
target_link_libraries(${PROJECT_NAME} bcm5719)
target_compile_options(${PROJECT_NAME} PRIVATE -nodefaultlibs)
-target_include_directories(${PROJECT_NAME} PUBLIC ../libs/VPD/include)
+target_include_directories(${PROJECT_NAME} PUBLIC ../libs/VPD/include .)
# Simulator add_executable
@@ -70,6 +70,7 @@ simulator_add_executable(sim-${PROJECT_NAME}
target_link_libraries(sim-${PROJECT_NAME} simulator)
target_link_libraries(sim-${PROJECT_NAME} NVRam MII VPD APE printf)
+target_include_directories(sim-${PROJECT_NAME} PUBLIC .)
install(TARGETS ${PROJECT_NAME} DESTINATION fw RESOURCE)
diff --git a/stage1/init_hw.c b/stage1/init_hw.c
index a40bc27..85c8616 100644
--- a/stage1/init_hw.c
+++ b/stage1/init_hw.c
@@ -42,33 +42,25 @@
/// @endcond
////////////////////////////////////////////////////////////////////////////////
-#include "stage1.h"
-
#include <APE.h>
#include <MII.h>
-#if CXX_SIMULATOR
-#include <APE_DEVICE.h>
-#else
-#include <bcm5719_DEVICE.h>
-#endif
-#include <bcm5719_GEN.h>
#include <bcm5719_RXMBUF.h>
#include <bcm5719_SDBCACHE.h>
#include <bcm5719_TXMBUF.h>
-#include <types.h>
+#include <stage1.h>
-#if CXX_SIMULATOR
+#ifdef CXX_SIMULATOR
#define volatile
#endif
void *memset(void *s, int c, size_t n)
{
-#if CXX_SIMULATOR
+#ifdef CXX_SIMULATOR
// TODO: Use the memory window to set everything.
#else
// We assume things are aligned here...
- uint32_t *buffer = s;
- for (int i = 0; i < n / 4; i++)
+ int32_t *buffer = s;
+ for (size_t i = 0; i < n / 4; i++)
{
buffer[i] = c;
}
@@ -147,12 +139,12 @@ void init_mii(volatile DEVICE_t *device)
void __attribute__((noinline)) zero_bss(void)
{
-#if !CXX_SIMULATOR
+#ifndef CXX_SIMULATOR
// Zero BSS information, will always be word aligned.
extern uint32_t _fbss[];
extern uint32_t _ebss[];
- memset(_fbss, 0, (_ebss - _fbss) * 4);
+ memset(_fbss, 0, (size_t)(_ebss - _fbss) * 4u);
#endif
}
@@ -160,7 +152,7 @@ void early_init_hw(void)
{
zero_bss();
-#if !CXX_SIMULATOR
+#ifndef CXX_SIMULATOR
// Zero out ram - gencom, db cache, tx/rx mbuf, others in mem map
memset((void *)&GEN, 0, REG_GEN_SIZE);
memset((void *)&RXMBUF, 0, REG_RXMBUF_SIZE);
@@ -169,15 +161,15 @@ void early_init_hw(void)
#endif
}
-void init_mac(NVRAMContents_t *nvram)
+void init_mac(const NVRAMContents_t *nvram)
{
int function = DEVICE.Status.bits.FunctionNumber;
- uint32_t *mac0 = nvram->info.macAddr0;
- uint32_t *my_mac = mac0; // default.
+ const uint32_t *mac0 = nvram->info.macAddr0;
+ const uint32_t *my_mac = mac0; // default.
DEVICE.EmacMacAddresses0High.r32 = mac0[0];
DEVICE.EmacMacAddresses0Low.r32 = mac0[1];
- uint32_t *mac1 = nvram->info.macAddr1;
+ const uint32_t *mac1 = nvram->info.macAddr1;
if (1 == function)
{
my_mac = mac1;
@@ -185,7 +177,7 @@ void init_mac(NVRAMContents_t *nvram)
DEVICE.EmacMacAddresses1High.r32 = mac1[0];
DEVICE.EmacMacAddresses1Low.r32 = mac1[1];
- uint32_t *mac2 = nvram->info2.macAddr2;
+ const uint32_t *mac2 = nvram->info2.macAddr2;
if (2 == function)
{
my_mac = mac2;
@@ -193,7 +185,7 @@ void init_mac(NVRAMContents_t *nvram)
DEVICE.EmacMacAddresses2High.r32 = mac2[0];
DEVICE.EmacMacAddresses2Low.r32 = mac2[1];
- uint32_t *mac3 = nvram->info2.macAddr3;
+ const uint32_t *mac3 = nvram->info2.macAddr3;
if (3 == function)
{
my_mac = mac3;
@@ -225,21 +217,21 @@ uint32_t translate_power_budget(uint16_t raw)
return translator.r32;
}
-void init_power(NVRAMContents_t *nvram)
+void init_power(const NVRAMContents_t *nvram)
{
// PCI power dissipated / consumed
DEVICE.PciPowerConsumptionInfo.r32 = nvram->info.powerConsumed;
DEVICE.PciPowerDissipatedInfo.r32 = nvram->info.powerDissipated;
// Power Budget
- uint32_t pb_raw0 = (nvram->info.powerBudget0) & 0xffff;
- uint32_t pb_raw1 = (nvram->info.powerBudget0) >> 16;
- uint32_t pb_raw2 = (nvram->info.powerBudget1) & 0xffff;
- uint32_t pb_raw3 = (nvram->info.powerBudget1) >> 16;
- uint32_t pb_raw4 = (nvram->info.powerBudget2) & 0xffff;
- uint32_t pb_raw5 = (nvram->info.powerBudget2) >> 16;
- uint32_t pb_raw6 = (nvram->info.powerBudget3) & 0xffff;
- uint32_t pb_raw7 = (nvram->info.powerBudget3) >> 16;
+ uint16_t pb_raw0 = (nvram->info.powerBudget0) & 0xffff;
+ uint16_t pb_raw1 = (nvram->info.powerBudget0) >> 16;
+ uint16_t pb_raw2 = (nvram->info.powerBudget1) & 0xffff;
+ uint16_t pb_raw3 = (nvram->info.powerBudget1) >> 16;
+ uint16_t pb_raw4 = (nvram->info.powerBudget2) & 0xffff;
+ uint16_t pb_raw5 = (nvram->info.powerBudget2) >> 16;
+ uint16_t pb_raw6 = (nvram->info.powerBudget3) & 0xffff;
+ uint16_t pb_raw7 = (nvram->info.powerBudget3) >> 16;
DEVICE.PciPowerBudget0.r32 = translate_power_budget(pb_raw0);
DEVICE.PciPowerBudget1.r32 = translate_power_budget(pb_raw1);
@@ -251,7 +243,7 @@ void init_power(NVRAMContents_t *nvram)
DEVICE.PciPowerBudget7.r32 = translate_power_budget(pb_raw7);
}
-uint16_t nvm_get_subsystem_device(volatile DEVICE_t *device, NVRAMContents_t *nvram)
+uint16_t nvm_get_subsystem_device(volatile DEVICE_t *device, const NVRAMContents_t *nvram)
{
switch (MII_getPhy(device))
{
@@ -281,7 +273,7 @@ uint16_t nvm_get_subsystem_device(volatile DEVICE_t *device, NVRAMContents_t *nv
}
}
-void init_pci(volatile DEVICE_t *device, NVRAMContents_t *nvram)
+void init_pci(volatile DEVICE_t *device, const NVRAMContents_t *nvram)
{
// PCI Device / Vendor ID.
RegDEVICEPciVendorDeviceId_t vendor_device;
@@ -300,7 +292,7 @@ void init_pci(volatile DEVICE_t *device, NVRAMContents_t *nvram)
// RegDEVICEPciClassCodeRevision_t partially from REG_CHIP_ID
}
-void init_gen(NVRAMContents_t *nvram)
+void init_gen(const NVRAMContents_t *nvram)
{
int function = DEVICE.Status.bits.FunctionNumber;
uint32_t cfg_feature;
@@ -342,7 +334,7 @@ void init_gen(NVRAMContents_t *nvram)
GEN.GenCfg5.r32 = nvram->info2.cfg5;
}
-void load_nvm_config(volatile DEVICE_t *device, NVRAMContents_t *nvram)
+void load_nvm_config(volatile DEVICE_t *device, const NVRAMContents_t *nvram)
{
// Load information from NVM, set various registers + mem
@@ -361,7 +353,7 @@ void load_nvm_config(volatile DEVICE_t *device, NVRAMContents_t *nvram)
init_gen(nvram);
}
-void init_hw(volatile DEVICE_t *device, NVRAMContents_t *nvram)
+void init_hw(volatile DEVICE_t *device)
{
reportStatus(STATUS_INIT_HW, 0);
// Misc regs init
diff --git a/stage1/main.c b/stage1/main.c
index d3e4046..df1bf4a 100644
--- a/stage1/main.c
+++ b/stage1/main.c
@@ -42,11 +42,11 @@
/// @endcond
////////////////////////////////////////////////////////////////////////////////
-#include "stage1.h"
+#include <stage1.h>
#define MAX_VPD_SUPPORTED (512u) /* Buffer size for caching VPD data. */
-#if CXX_SIMULATOR
+#ifdef CXX_SIMULATOR
#include <HAL.hpp>
#define crc_swap(__x__) (__x__) /* No swapping needed on the host */
#define vpd_swap(__x__) (__x__) /* No swapping needed on the host */
@@ -55,23 +55,16 @@
#define crc_swap(__x__) ((((__x__)&0x000000FF) << 24) | (((__x__)&0x0000FF00) << 8) | (((__x__)&0x00FF0000) >> 8) | (((__x__)&0xFF000000) >> 24))
#define vpd_swap(__x__) ((((__x__)&0x000000FF) << 24) | (((__x__)&0x0000FF00) << 8) | (((__x__)&0x00FF0000) >> 8) | (((__x__)&0xFF000000) >> 24))
#endif
-#include <APE.h>
#include <NVRam.h>
#include <bcm5719_APE.h>
#include <bcm5719_BOOTCODE.h>
-#if CXX_SIMULATOR
-#include <APE_DEVICE.h>
-#else
-#include <bcm5719_DEVICE.h>
-#endif
-#include <bcm5719_GEN.h>
#include <bcm5719_SHM.h>
const char gStage1Version[] = "stage1-" STRINGIFY(VERSION_MAJOR) "." STRINGIFY(VERSION_MINOR) "." STRINGIFY(VERSION_PATCH);
NVRAMContents_t gNVMContents;
uint32_t gVPDLength = 0;
-uint32_t *gVPD = NULL;
+const uint32_t *gVPD = NULL;
uint32_t gVPDCd[MAX_VPD_SUPPORTED / 4];
void __attribute__((noinline)) reportStatus(uint32_t code, uint8_t step)
@@ -82,7 +75,7 @@ void __attribute__((noinline)) reportStatus(uint32_t code, uint8_t step)
void init_once(void)
{
SHM.RcpuInitCount.r32 = 0;
- SHM.RcpuFwVersion.r32 = (VERSION_MAJOR << 24) | (VERSION_MINOR << 16) | VERSION_PATCH;
+ SHM.RcpuFwVersion.r32 = (VERSION_MAJOR << 24) | (VERSION_MINOR << 16) | VERSION_PATCH; //lint !e835
SHM.RcpuApeResetCount.r32 = 0;
SHM.RcpuLastApeStatus.r32 = 0;
@@ -93,7 +86,7 @@ void init_once(void)
void handle_printf()
{
- uint32_t buffer_size = sizeof(SHM.RcpuPrintfBuffer) / sizeof(SHM.RcpuPrintfBuffer[0]) * sizeof(uint32_t);
+ uint32_t buffer_size = ARRAY_ELEMENTS(SHM.RcpuPrintfBuffer) * sizeof(uint32_t);
if (SHM.RcpuWritePointer.r32 > buffer_size || SHM.RcpuReadPointer.r32 > buffer_size || SHM.RcpuHostReadPointer.r32 > buffer_size)
{
@@ -111,7 +104,7 @@ void handle_printf()
uint32_t word_pointer = cached_pointer / 4;
uint32_t byte_index = cached_pointer % 4;
- char character = (uint8_t)(SHM.RcpuPrintfBuffer[word_pointer].r32 >> (byte_index * 8));
+ char character = (char)(SHM.RcpuPrintfBuffer[word_pointer].r32 >> (byte_index * 8));
em100_putchar(character);
@@ -141,7 +134,7 @@ void find_vpd(void)
gVPD = (uint32_t *)gNVMContents.vpd.bytes;
gVPDLength = sizeof(gNVMContents.vpd.bytes);
- for (int i = 0; i < ARRAY_ELEMENTS(gNVMContents.directory); i++)
+ for (size_t i = 0; i < ARRAY_ELEMENTS(gNVMContents.directory); i++)
{
NVRAMCodeDirectory_t *cd = &gNVMContents.directory[i];
@@ -173,7 +166,7 @@ void find_vpd(void)
int main()
{
-#if CXX_SIMULATOR
+#ifdef CXX_SIMULATOR
initHAL(NULL);
#endif
@@ -208,7 +201,7 @@ int main()
reportStatus(STATUS_MAIN, 2);
// Read in the NVM header.
-#if !CXX_SIMULATOR
+#ifndef CXX_SIMULATOR
load_nvm_config(&DEVICE, &gNVMContents);
// Initialize the hardware.
diff --git a/stage1/stage1.h b/stage1/stage1.h
index bb4f2ef..ffc39cc 100644
--- a/stage1/stage1.h
+++ b/stage1/stage1.h
@@ -54,7 +54,7 @@
#include <bcm5719_GEN.h>
#include <bcm5719_eeprom.h>
-#if CXX_SIMULATOR
+#ifdef CXX_SIMULATOR
#include <APE_DEVICE.h>
#define volatile
#else
@@ -62,8 +62,8 @@
#endif
void early_init_hw(void);
-void load_nvm_config(volatile DEVICE_t* device, NVRAMContents_t *nvram);
-void init_hw(volatile DEVICE_t* device, NVRAMContents_t *nvram);
+void load_nvm_config(volatile DEVICE_t* device, const NVRAMContents_t *nvram);
+void init_hw(volatile DEVICE_t* device);
#define STATUS_MAIN (0x8234700u)
#define STATUS_EARLY_INIT (0x8234800u)
OpenPOWER on IntegriCloud