summaryrefslogtreecommitdiffstats
path: root/ape
diff options
context:
space:
mode:
authorEvan Lojewski <github@meklort.com>2019-04-06 19:38:58 -0600
committerEvan Lojewski <github@meklort.com>2019-04-06 19:38:58 -0600
commit12ee00e9421862e96aabb4ff17a0435d3fab7909 (patch)
treed517d464b2d93264b7eb4e59dbf317ffccb70a7a /ape
parente8d119a925d8837a9a8d59750392223f96b28c1c (diff)
downloadbcm5719-ortega-12ee00e9421862e96aabb4ff17a0435d3fab7909.tar.gz
bcm5719-ortega-12ee00e9421862e96aabb4ff17a0435d3fab7909.zip
Add initial rx-from-network initialization code.
Diffstat (limited to 'ape')
-rw-r--r--ape/CMakeLists.txt1
-rw-r--r--ape/ape.h19
-rw-r--r--ape/main.c54
-rw-r--r--ape/rx_from_network.c345
4 files changed, 394 insertions, 25 deletions
diff --git a/ape/CMakeLists.txt b/ape/CMakeLists.txt
index ce94cbf..6d9a324 100644
--- a/ape/CMakeLists.txt
+++ b/ape/CMakeLists.txt
@@ -50,6 +50,7 @@ set(LINKER_SCRIPT "${CMAKE_CURRENT_SOURCE_DIR}/ape.ld")
arm_add_executable(${PROJECT_NAME}
main.c
vectors.c
+ rx_from_network.c
)
arm_linker_script(${PROJECT_NAME} ${LINKER_SCRIPT})
diff --git a/ape/ape.h b/ape/ape.h
index d4c9ae6..c073cfb 100644
--- a/ape/ape.h
+++ b/ape/ape.h
@@ -1,4 +1,4 @@
-////////////////////////////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////////////////////////////
///
/// @file stage1.h
///
@@ -45,22 +45,7 @@
#ifndef APE_H
#define APE_H
-// #include <bcm5719_eeprom.h>
-// #include <bcm5719_GEN.h>
-
-// void early_init_hw(void);
-// void load_nvm_config(NVRAMContents_t *nvram);
-// void init_hw(NVRAMContents_t *nvram);
-
-#define STATUS_MAIN (0x8234700u)
-#define STATUS_EARLY_INIT (0x8234800u)
-#define STATUS_NVM_CONFIG (0x8234900u)
-#define STATUS_INIT_HW (0x8234A00u)
-
-// static inline void reportStatus(uint32_t code, uint8_t step)
-// {
-// GEN.GenDataSig.r32 = (code | step);
-// }
+void initRxFromNetwork(void);
#endif /* APE_H */
diff --git a/ape/main.c b/ape/main.c
index 420c4fc..aee4bf7 100644
--- a/ape/main.c
+++ b/ape/main.c
@@ -46,17 +46,55 @@
#include <APE_SHM.h>
-int main()
+void __attribute__((noreturn)) loaderLoop(void)
{
- int i = 0;
- while(1)
+ // Update SHM.Sig to signal ready.
+ SHM.SegSig.bits.Sig = SHM_SEG_SIG_SIG_LOADER;
+ SHM.FwStatus.bits.Ready = 1;
+
+ for(;;)
{
- SHM.SegSig.r32 = i++;
- }
+ uint32_t command = SHM.LoaderCommand.bits.Command;
+ if(!command) continue;
+
+ uint32_t arg0 = SHM.LoaderArg0.r32;
+ uint32_t arg1 = SHM.LoaderArg1.r32;
+
+ switch(command)
+ {
+ default:
+ break;
+ case SHM_LOADER_COMMAND_COMMAND_READ_MEM:
+ {
+ // Read word address specified in arg0
+ uint32_t* addr = ((void*)arg0);
+ SHM.LoaderArg0.r32 = *addr;
+ break;
+ }
+ case SHM_LOADER_COMMAND_COMMAND_WRITE_MEM:
+ {
+ // Write word address specified in arg0 with arg1
+ uint32_t* addr = ((void*)arg0);
+ *addr = arg1;
+ break;
+ }
+ case SHM_LOADER_COMMAND_COMMAND_CALL:
+ {
+ // call address specified in arg0.
+ void (*function)(uint32_t) = ((void*)arg0);
+ function(arg1);
+ break;
+ }
+ }
+
+ // Mark command as handled.
+ SHM.LoaderCommand.bits.Command = 0;
+ }
}
-void __start()
+void __attribute__((noreturn)) __start()
{
- (void)main();
-}
+ initRxFromNetwork();
+ loaderLoop();
+} \ No newline at end of file
diff --git a/ape/rx_from_network.c b/ape/rx_from_network.c
new file mode 100644
index 0000000..a0e913c
--- /dev/null
+++ b/ape/rx_from_network.c
@@ -0,0 +1,345 @@
+////////////////////////////////////////////////////////////////////////////////
+///
+/// @file rx_from_network.c
+///
+/// @project
+///
+/// @brief Initialization code for RX from network.
+///
+////////////////////////////////////////////////////////////////////////////////
+///
+////////////////////////////////////////////////////////////////////////////////
+///
+/// @copyright Copyright (c) 2018, Evan Lojewski
+/// @cond
+///
+/// All rights reserved.
+///
+/// Redistribution and use in source and binary forms, with or without
+/// modification, are permitted provided that the following conditions are met:
+/// 1. Redistributions of source code must retain the above copyright notice,
+/// this list of conditions and the following disclaimer.
+/// 2. Redistributions in binary form must reproduce the above copyright notice,
+/// this list of conditions and the following disclaimer in the documentation
+/// and/or other materials provided with the distribution.
+/// 3. Neither the name of the copyright holder nor the
+/// names of its contributors may be used to endorse or promote products
+/// derived from this software without specific prior written permission.
+///
+////////////////////////////////////////////////////////////////////////////////
+///
+/// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+/// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+/// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+/// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+/// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+/// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+/// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+/// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+/// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+/// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+/// POSSIBILITY OF SUCH DAMAGE.
+/// @endcond
+////////////////////////////////////////////////////////////////////////////////
+
+#include "ape.h"
+
+#include <APE_FILTERS.h>
+
+typedef struct {
+ RegFILTERSElementConfig_t cfg;
+ RegFILTERSElementPattern_t pat;
+} FilterElementInit_t;
+static const FilterElementInit_t gElementInit[32] = {
+ [0] = {{0}},
+ [1] = {{0}},
+ [2] = {{0}},
+ [3] = {{0}},
+ [4] = {{0}},
+ [5] = {{0}},
+ [6] = {{0}},
+ [7] = {{0}},
+ [8] = {{0}},
+ [9] = {{0}},
+ [10] = {{0}},
+ [11] = {{0}},
+ [12] = {{0}},
+ [13] = {{0}},
+ [14] = {{0}},
+ [15] = {{0}},
+
+ // 16: Check MAC address multicast bit not set.
+ [16] = {
+ .cfg = { .bits = {
+ .RuleOffset = 0,
+ .RuleClass = 0,
+ .RuleHeader = FILTERS_ELEMENT_CONFIG_RULE_HEADER_SOF,
+ .RuleOp = FILTERS_ELEMENT_CONFIG_RULE_OP_NE,
+ .reserved_23_18 = 0,
+ .RuleMap = 0,
+ .RuleDiscard = 0,
+ .RuleMask = 1,
+ .RuleP3 = 0,
+ .RuleP2 = 0,
+ .RuleP1 = 0,
+ .RuleAnd = 0,
+ .RuleEnable = 1,
+ }},
+ .pat = {.r32 = 0x01000100},
+ },
+
+ [17] = {{0}},
+ [18] = {{0}},
+
+ // 19: Special VLAN match.
+ [19] = {
+ .cfg = { .bits = {
+ .RuleOffset = 0,
+ .RuleClass = 0,
+ .RuleHeader = FILTERS_ELEMENT_CONFIG_RULE_HEADER_VLAN,
+ .RuleOp = FILTERS_ELEMENT_CONFIG_RULE_OP_EQ,
+ .reserved_23_18 = 0,
+ .RuleMap = 0,
+ .RuleDiscard = 0,
+ .RuleMask = 1,
+ .RuleP3 = 0,
+ .RuleP2 = 0,
+ .RuleP1 = 0,
+ .RuleAnd = 0,
+ .RuleEnable = 1,
+ }},
+ .pat = {.r32 = 0},
+ },
+
+ // 20: IPv6 Neighbor Advertisement.
+ [20] = {
+ .cfg = { .bits = {
+ .RuleOffset = 0,
+ .RuleClass = 0,
+ .RuleHeader = FILTERS_ELEMENT_CONFIG_RULE_HEADER_ICMPV6,
+ .RuleOp = FILTERS_ELEMENT_CONFIG_RULE_OP_EQ,
+ .reserved_23_18 = 0,
+ .RuleMap = 0,
+ .RuleDiscard = 0,
+ .RuleMask = 1,
+ .RuleP3 = 0,
+ .RuleP2 = 0,
+ .RuleP1 = 0,
+ .RuleAnd = 0,
+ .RuleEnable = 0, // Disabled
+ }},
+ .pat = {.r32 = 0x8800FF00},
+ },
+
+ // 21: IPv6 Router Advertisement.
+ [21] = {
+ .cfg = { .bits = {
+ .RuleOffset = 0,
+ .RuleClass = 0,
+ .RuleHeader = FILTERS_ELEMENT_CONFIG_RULE_HEADER_ICMPV6,
+ .RuleOp = FILTERS_ELEMENT_CONFIG_RULE_OP_EQ,
+ .reserved_23_18 = 0,
+ .RuleMap = 0,
+ .RuleDiscard = 0,
+ .RuleMask = 1,
+ .RuleP3 = 0,
+ .RuleP2 = 0,
+ .RuleP1 = 0,
+ .RuleAnd = 0,
+ .RuleEnable = 0, // Disabled
+ }},
+ .pat = {.r32 = 0x8600FF00},
+ },
+
+ // 22: DHCPv6 Server.
+ [22] = {
+ .cfg = { .bits = {
+ .RuleOffset = 2,
+ .RuleClass = 0,
+ .RuleHeader = FILTERS_ELEMENT_CONFIG_RULE_HEADER_UDP,
+ .RuleOp = FILTERS_ELEMENT_CONFIG_RULE_OP_EQ,
+ .reserved_23_18 = 0,
+ .RuleMap = 0,
+ .RuleDiscard = 0,
+ .RuleMask = 1,
+ .RuleP3 = 0,
+ .RuleP2 = 0,
+ .RuleP1 = 0,
+ .RuleAnd = 0,
+ .RuleEnable = 0, // Disabled
+ }},
+ .pat = {.r32 = 0x0223FFFF},
+ },
+
+ [23] = {{0}},
+
+ // 24: ARP match.
+ [24] = {
+ .cfg = { .bits = {
+ .RuleOffset = 12,
+ .RuleClass = 0,
+ .RuleHeader = FILTERS_ELEMENT_CONFIG_RULE_HEADER_SOF,
+ .RuleOp = FILTERS_ELEMENT_CONFIG_RULE_OP_EQ,
+ .reserved_23_18 = 0,
+ .RuleMap = 0,
+ .RuleDiscard = 0,
+ .RuleMask = 1,
+ .RuleP3 = 0,
+ .RuleP2 = 0,
+ .RuleP1 = 0,
+ .RuleAnd = 0,
+ .RuleEnable = 1,
+ }},
+ .pat = {.r32 = 0x0806FFFF},
+ },
+
+ // 25: DHCPv4.
+ [25] = {
+ .cfg = { .bits = {
+ .RuleOffset = 2,
+ .RuleClass = 0,
+ .RuleHeader = FILTERS_ELEMENT_CONFIG_RULE_HEADER_UDP,
+ .RuleOp = FILTERS_ELEMENT_CONFIG_RULE_OP_EQ,
+ .reserved_23_18 = 0,
+ .RuleMap = 0,
+ .RuleDiscard = 0,
+ .RuleMask = 1,
+ .RuleP3 = 0,
+ .RuleP2 = 0,
+ .RuleP1 = 0,
+ .RuleAnd = 0,
+ .RuleEnable = 1,
+ }},
+ .pat = {.r32 = 0x0044FFFF},
+ },
+
+ // 26: DHCPv4.
+ [26] = {
+ .cfg = { .bits = {
+ .RuleOffset = 2,
+ .RuleClass = 0,
+ .RuleHeader = FILTERS_ELEMENT_CONFIG_RULE_HEADER_UDP,
+ .RuleOp = FILTERS_ELEMENT_CONFIG_RULE_OP_EQ,
+ .reserved_23_18 = 0,
+ .RuleMap = 0,
+ .RuleDiscard = 0,
+ .RuleMask = 1,
+ .RuleP3 = 0,
+ .RuleP2 = 0,
+ .RuleP1 = 0,
+ .RuleAnd = 0,
+ .RuleEnable = 1,
+ }},
+ .pat = {.r32 = 0x0043FFFF},
+ },
+
+ // 27: NetBIOS
+ [27] = {
+ .cfg = { .bits = {
+ .RuleOffset = 2,
+ .RuleClass = 0,
+ .RuleHeader = FILTERS_ELEMENT_CONFIG_RULE_HEADER_UDP,
+ .RuleOp = FILTERS_ELEMENT_CONFIG_RULE_OP_EQ,
+ .reserved_23_18 = 0,
+ .RuleMap = 0,
+ .RuleDiscard = 0,
+ .RuleMask = 1,
+ .RuleP3 = 0,
+ .RuleP2 = 0,
+ .RuleP1 = 0,
+ .RuleAnd = 0,
+ .RuleEnable = 1,
+ }},
+ .pat = {.r32 = 0x0088FFFC},
+ },
+
+ // 28: Broadcast address match.
+ [28] = {
+ .cfg = { .bits = {
+ .RuleOffset = 0,
+ .RuleClass = 0,
+ .RuleHeader = FILTERS_ELEMENT_CONFIG_RULE_HEADER_SOF,
+ .RuleOp = FILTERS_ELEMENT_CONFIG_RULE_OP_EQ,
+ .reserved_23_18 = 0,
+ .RuleMap = 0,
+ .RuleDiscard = 0,
+ .RuleMask = 0,
+ .RuleP3 = 0,
+ .RuleP2 = 0,
+ .RuleP1 = 0,
+ .RuleAnd = 0,
+ .RuleEnable = 1,
+ }},
+ .pat = {.r32 = 0xFFFFFFFF},
+ },
+
+ // 29: Broadcast address match.
+ [29] = {
+ .cfg = { .bits = {
+ .RuleOffset = 4,
+ .RuleClass = 0,
+ .RuleHeader = FILTERS_ELEMENT_CONFIG_RULE_HEADER_SOF,
+ .RuleOp = FILTERS_ELEMENT_CONFIG_RULE_OP_EQ,
+ .reserved_23_18 = 0,
+ .RuleMap = 0,
+ .RuleDiscard = 0,
+ .RuleMask = 1,
+ .RuleP3 = 0,
+ .RuleP2 = 0,
+ .RuleP1 = 0,
+ .RuleAnd = 0,
+ .RuleEnable = 1,
+ }},
+ .pat = {.r32 = 0xFFFFFFFF},
+ },
+
+ // 30: IPv6 multicast.
+ [30] = {
+ .cfg = { .bits = {
+ .RuleOffset = 0,
+ .RuleClass = 0,
+ .RuleHeader = FILTERS_ELEMENT_CONFIG_RULE_HEADER_SOF,
+ .RuleOp = FILTERS_ELEMENT_CONFIG_RULE_OP_EQ,
+ .reserved_23_18 = 0,
+ .RuleMap = 0,
+ .RuleDiscard = 0,
+ .RuleMask = 1,
+ .RuleP3 = 0,
+ .RuleP2 = 0,
+ .RuleP1 = 0,
+ .RuleAnd = 0,
+ .RuleEnable = 1,
+ }},
+ .pat = {.r32 = 0x3333FFFF},
+ },
+ // 31: Check MAC address multicast bit is set.
+ [31] = {
+ .cfg = { .bits = {
+ .RuleOffset = 0,
+ .RuleClass = 0,
+ .RuleHeader = FILTERS_ELEMENT_CONFIG_RULE_HEADER_SOF,
+ .RuleOp = FILTERS_ELEMENT_CONFIG_RULE_OP_EQ,
+ .reserved_23_18 = 0,
+ .RuleMap = 0,
+ .RuleDiscard = 0,
+ .RuleMask = 1,
+ .RuleP3 = 0,
+ .RuleP2 = 0,
+ .RuleP1 = 0,
+ .RuleAnd = 0,
+ .RuleEnable = 1,
+ }},
+ .pat = {.r32 = 0x01000100},
+ },
+
+};
+
+void initRxFromNetwork(void)
+{
+ for(int i = 0; i < 32; i++)
+ {
+ FILTERS.ElementConfig[i] = gElementInit[i].cfg;
+ FILTERS.ElementPattern[i] = gElementInit[i].pat;
+ }
+
+}
OpenPOWER on IntegriCloud