summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEvan Lojewski <github@meklort.com>2019-05-02 19:59:19 -0600
committerEvan Lojewski <github@meklort.com>2019-05-02 19:59:19 -0600
commit86106d98887a390f3a0dd54edf167cb5da1c2436 (patch)
tree95ef7dfb0615a611e6ee8a3b37b8bdb5195a86d2
parentd34ace3709b06d55510c7b4481f9e055ff6610e3 (diff)
downloadbcm5719-ortega-86106d98887a390f3a0dd54edf167cb5da1c2436.tar.gz
bcm5719-ortega-86106d98887a390f3a0dd54edf167cb5da1c2436.zip
Begin moving APE tx code from the host to the APE.
-rw-r--r--ape/ape.h1
-rw-r--r--cmake/arm.cmake2
-rw-r--r--include/APE_APE.h64
-rw-r--r--include/bcm5719_APE.h64
-rw-r--r--ipxact/APE_component.xml8
-rw-r--r--libs/CMakeLists.txt1
-rw-r--r--libs/Network/CMakeLists.txt60
-rw-r--r--libs/Network/include/Network.h61
-rw-r--r--libs/Network/init.c (renamed from ape/rx_from_network.c)44
-rw-r--r--libs/Network/tx.c296
-rw-r--r--simulator/CMakeLists.txt4
-rw-r--r--simulator/HAL.cpp4
-rw-r--r--simulator/include/CXXRegister.h7
13 files changed, 535 insertions, 81 deletions
diff --git a/ape/ape.h b/ape/ape.h
index b8de36f..4d7eeba 100644
--- a/ape/ape.h
+++ b/ape/ape.h
@@ -45,7 +45,6 @@
#ifndef APE_H
#define APE_H
-void initRxFromNetwork(void);
void initRMU(void);
diff --git a/cmake/arm.cmake b/cmake/arm.cmake
index b27e1cf..8e360bc 100644
--- a/cmake/arm.cmake
+++ b/cmake/arm.cmake
@@ -42,7 +42,7 @@
### @endcond
################################################################################
-SET(ARM_COMPILE_OPTIONS -nostdlib -nodefaultlibs -fomit-frame-pointer -target thumbv7-none-eabi -mcpu=cortex-m3 -mfloat-abi=soft )
+SET(ARM_COMPILE_OPTIONS -nostdlib -nodefaultlibs -fomit-frame-pointer -target thumbv7-none-eabi -mcpu=cortex-m3 -mfloat-abi=soft -fno-builtin)
SET(ARM_LINK_OPTIONS --gc-sections)
# SET(CMAKE_EXE_LINKER_FLAGS -static)
diff --git a/include/APE_APE.h b/include/APE_APE.h
index 25a853e..4a4d266 100644
--- a/include/APE_APE.h
+++ b/include/APE_APE.h
@@ -118,14 +118,14 @@ typedef uint32_t APE_APE_H_uint32_t;
#define APE_MODE_SWAP_ARB_DWORD_MASK 0x800u
#define GET_APE_MODE_SWAP_ARB_DWORD(__reg__) (((__reg__) & 0x800) >> 11u)
#define SET_APE_MODE_SWAP_ARB_DWORD(__val__) (((__val__) << 11u) & 0x800u)
-#define APE_MODE_CHANNEL_0_STATUS_SHIFT 14u
-#define APE_MODE_CHANNEL_0_STATUS_MASK 0x4000u
-#define GET_APE_MODE_CHANNEL_0_STATUS(__reg__) (((__reg__) & 0x4000) >> 14u)
-#define SET_APE_MODE_CHANNEL_0_STATUS(__val__) (((__val__) << 14u) & 0x4000u)
-#define APE_MODE_CHANNEL_2_STATUS_SHIFT 15u
-#define APE_MODE_CHANNEL_2_STATUS_MASK 0x8000u
-#define GET_APE_MODE_CHANNEL_2_STATUS(__reg__) (((__reg__) & 0x8000) >> 15u)
-#define SET_APE_MODE_CHANNEL_2_STATUS(__val__) (((__val__) << 15u) & 0x8000u)
+#define APE_MODE_CHANNEL_0_ENABLE_SHIFT 14u
+#define APE_MODE_CHANNEL_0_ENABLE_MASK 0x4000u
+#define GET_APE_MODE_CHANNEL_0_ENABLE(__reg__) (((__reg__) & 0x4000) >> 14u)
+#define SET_APE_MODE_CHANNEL_0_ENABLE(__val__) (((__val__) << 14u) & 0x4000u)
+#define APE_MODE_CHANNEL_2_ENABLE_SHIFT 15u
+#define APE_MODE_CHANNEL_2_ENABLE_MASK 0x8000u
+#define GET_APE_MODE_CHANNEL_2_ENABLE(__reg__) (((__reg__) & 0x8000) >> 15u)
+#define SET_APE_MODE_CHANNEL_2_ENABLE(__val__) (((__val__) << 15u) & 0x8000u)
#define APE_MODE_MEMORY_ECC_SHIFT 18u
#define APE_MODE_MEMORY_ECC_MASK 0x40000u
#define GET_APE_MODE_MEMORY_ECC(__reg__) (((__reg__) & 0x40000) >> 18u)
@@ -134,14 +134,14 @@ typedef uint32_t APE_APE_H_uint32_t;
#define APE_MODE_ICODE_PIP_RD_DISABLE_MASK 0x80000u
#define GET_APE_MODE_ICODE_PIP_RD_DISABLE(__reg__) (((__reg__) & 0x80000) >> 19u)
#define SET_APE_MODE_ICODE_PIP_RD_DISABLE(__val__) (((__val__) << 19u) & 0x80000u)
-#define APE_MODE_CHANNEL_1_STATUS_SHIFT 30u
-#define APE_MODE_CHANNEL_1_STATUS_MASK 0x40000000u
-#define GET_APE_MODE_CHANNEL_1_STATUS(__reg__) (((__reg__) & 0x40000000) >> 30u)
-#define SET_APE_MODE_CHANNEL_1_STATUS(__val__) (((__val__) << 30u) & 0x40000000u)
-#define APE_MODE_CHANNEL_3_STATUS_SHIFT 31u
-#define APE_MODE_CHANNEL_3_STATUS_MASK 0x80000000u
-#define GET_APE_MODE_CHANNEL_3_STATUS(__reg__) (((__reg__) & 0x80000000) >> 31u)
-#define SET_APE_MODE_CHANNEL_3_STATUS(__val__) (((__val__) << 31u) & 0x80000000u)
+#define APE_MODE_CHANNEL_1_ENABLE_SHIFT 30u
+#define APE_MODE_CHANNEL_1_ENABLE_MASK 0x40000000u
+#define GET_APE_MODE_CHANNEL_1_ENABLE(__reg__) (((__reg__) & 0x40000000) >> 30u)
+#define SET_APE_MODE_CHANNEL_1_ENABLE(__val__) (((__val__) << 30u) & 0x40000000u)
+#define APE_MODE_CHANNEL_3_ENABLE_SHIFT 31u
+#define APE_MODE_CHANNEL_3_ENABLE_MASK 0x80000000u
+#define GET_APE_MODE_CHANNEL_3_ENABLE(__reg__) (((__reg__) & 0x80000000) >> 31u)
+#define SET_APE_MODE_CHANNEL_3_ENABLE(__val__) (((__val__) << 31u) & 0x80000000u)
/** @brief Register definition for @ref APE_t.Mode. */
typedef register_container RegAPEMode_t {
@@ -177,9 +177,9 @@ typedef register_container RegAPEMode_t {
/** @brief Padding */
BITFIELD_MEMBER(APE_APE_H_uint32_t, reserved_13_12, 12, 2)
/** @brief */
- BITFIELD_MEMBER(APE_APE_H_uint32_t, Channel0Status, 14, 1)
+ BITFIELD_MEMBER(APE_APE_H_uint32_t, Channel0Enable, 14, 1)
/** @brief */
- BITFIELD_MEMBER(APE_APE_H_uint32_t, Channel2Status, 15, 1)
+ BITFIELD_MEMBER(APE_APE_H_uint32_t, Channel2Enable, 15, 1)
/** @brief Padding */
BITFIELD_MEMBER(APE_APE_H_uint32_t, reserved_17_16, 16, 2)
/** @brief */
@@ -189,14 +189,14 @@ typedef register_container RegAPEMode_t {
/** @brief Padding */
BITFIELD_MEMBER(APE_APE_H_uint32_t, reserved_29_20, 20, 10)
/** @brief */
- BITFIELD_MEMBER(APE_APE_H_uint32_t, Channel1Status, 30, 1)
+ BITFIELD_MEMBER(APE_APE_H_uint32_t, Channel1Enable, 30, 1)
/** @brief */
- BITFIELD_MEMBER(APE_APE_H_uint32_t, Channel3Status, 31, 1)
+ BITFIELD_MEMBER(APE_APE_H_uint32_t, Channel3Enable, 31, 1)
#elif defined(__BIG_ENDIAN__)
/** @brief */
- BITFIELD_MEMBER(APE_APE_H_uint32_t, Channel3Status, 31, 1)
+ BITFIELD_MEMBER(APE_APE_H_uint32_t, Channel3Enable, 31, 1)
/** @brief */
- BITFIELD_MEMBER(APE_APE_H_uint32_t, Channel1Status, 30, 1)
+ BITFIELD_MEMBER(APE_APE_H_uint32_t, Channel1Enable, 30, 1)
/** @brief Padding */
BITFIELD_MEMBER(APE_APE_H_uint32_t, reserved_29_20, 20, 10)
/** @brief */
@@ -206,9 +206,9 @@ typedef register_container RegAPEMode_t {
/** @brief Padding */
BITFIELD_MEMBER(APE_APE_H_uint32_t, reserved_17_16, 16, 2)
/** @brief */
- BITFIELD_MEMBER(APE_APE_H_uint32_t, Channel2Status, 15, 1)
+ BITFIELD_MEMBER(APE_APE_H_uint32_t, Channel2Enable, 15, 1)
/** @brief */
- BITFIELD_MEMBER(APE_APE_H_uint32_t, Channel0Status, 14, 1)
+ BITFIELD_MEMBER(APE_APE_H_uint32_t, Channel0Enable, 14, 1)
/** @brief Padding */
BITFIELD_MEMBER(APE_APE_H_uint32_t, reserved_13_12, 12, 2)
/** @brief */
@@ -268,18 +268,18 @@ typedef register_container RegAPEMode_t {
bits.SwapATBdword.setName("SwapATBdword");
bits.SwapARBdword.setBaseRegister(&r32);
bits.SwapARBdword.setName("SwapARBdword");
- bits.Channel0Status.setBaseRegister(&r32);
- bits.Channel0Status.setName("Channel0Status");
- bits.Channel2Status.setBaseRegister(&r32);
- bits.Channel2Status.setName("Channel2Status");
+ bits.Channel0Enable.setBaseRegister(&r32);
+ bits.Channel0Enable.setName("Channel0Enable");
+ bits.Channel2Enable.setBaseRegister(&r32);
+ bits.Channel2Enable.setName("Channel2Enable");
bits.MemoryECC.setBaseRegister(&r32);
bits.MemoryECC.setName("MemoryECC");
bits.ICodePIPRdDisable.setBaseRegister(&r32);
bits.ICodePIPRdDisable.setName("ICodePIPRdDisable");
- bits.Channel1Status.setBaseRegister(&r32);
- bits.Channel1Status.setName("Channel1Status");
- bits.Channel3Status.setBaseRegister(&r32);
- bits.Channel3Status.setName("Channel3Status");
+ bits.Channel1Enable.setBaseRegister(&r32);
+ bits.Channel1Enable.setName("Channel1Enable");
+ bits.Channel3Enable.setBaseRegister(&r32);
+ bits.Channel3Enable.setName("Channel3Enable");
}
RegAPEMode_t& operator=(const RegAPEMode_t& other)
{
diff --git a/include/bcm5719_APE.h b/include/bcm5719_APE.h
index 1c0144b..bfaddcf 100644
--- a/include/bcm5719_APE.h
+++ b/include/bcm5719_APE.h
@@ -118,14 +118,14 @@ typedef uint32_t BCM5719_APE_H_uint32_t;
#define APE_MODE_SWAP_ARB_DWORD_MASK 0x800u
#define GET_APE_MODE_SWAP_ARB_DWORD(__reg__) (((__reg__) & 0x800) >> 11u)
#define SET_APE_MODE_SWAP_ARB_DWORD(__val__) (((__val__) << 11u) & 0x800u)
-#define APE_MODE_CHANNEL_0_STATUS_SHIFT 14u
-#define APE_MODE_CHANNEL_0_STATUS_MASK 0x4000u
-#define GET_APE_MODE_CHANNEL_0_STATUS(__reg__) (((__reg__) & 0x4000) >> 14u)
-#define SET_APE_MODE_CHANNEL_0_STATUS(__val__) (((__val__) << 14u) & 0x4000u)
-#define APE_MODE_CHANNEL_2_STATUS_SHIFT 15u
-#define APE_MODE_CHANNEL_2_STATUS_MASK 0x8000u
-#define GET_APE_MODE_CHANNEL_2_STATUS(__reg__) (((__reg__) & 0x8000) >> 15u)
-#define SET_APE_MODE_CHANNEL_2_STATUS(__val__) (((__val__) << 15u) & 0x8000u)
+#define APE_MODE_CHANNEL_0_ENABLE_SHIFT 14u
+#define APE_MODE_CHANNEL_0_ENABLE_MASK 0x4000u
+#define GET_APE_MODE_CHANNEL_0_ENABLE(__reg__) (((__reg__) & 0x4000) >> 14u)
+#define SET_APE_MODE_CHANNEL_0_ENABLE(__val__) (((__val__) << 14u) & 0x4000u)
+#define APE_MODE_CHANNEL_2_ENABLE_SHIFT 15u
+#define APE_MODE_CHANNEL_2_ENABLE_MASK 0x8000u
+#define GET_APE_MODE_CHANNEL_2_ENABLE(__reg__) (((__reg__) & 0x8000) >> 15u)
+#define SET_APE_MODE_CHANNEL_2_ENABLE(__val__) (((__val__) << 15u) & 0x8000u)
#define APE_MODE_MEMORY_ECC_SHIFT 18u
#define APE_MODE_MEMORY_ECC_MASK 0x40000u
#define GET_APE_MODE_MEMORY_ECC(__reg__) (((__reg__) & 0x40000) >> 18u)
@@ -134,14 +134,14 @@ typedef uint32_t BCM5719_APE_H_uint32_t;
#define APE_MODE_ICODE_PIP_RD_DISABLE_MASK 0x80000u
#define GET_APE_MODE_ICODE_PIP_RD_DISABLE(__reg__) (((__reg__) & 0x80000) >> 19u)
#define SET_APE_MODE_ICODE_PIP_RD_DISABLE(__val__) (((__val__) << 19u) & 0x80000u)
-#define APE_MODE_CHANNEL_1_STATUS_SHIFT 30u
-#define APE_MODE_CHANNEL_1_STATUS_MASK 0x40000000u
-#define GET_APE_MODE_CHANNEL_1_STATUS(__reg__) (((__reg__) & 0x40000000) >> 30u)
-#define SET_APE_MODE_CHANNEL_1_STATUS(__val__) (((__val__) << 30u) & 0x40000000u)
-#define APE_MODE_CHANNEL_3_STATUS_SHIFT 31u
-#define APE_MODE_CHANNEL_3_STATUS_MASK 0x80000000u
-#define GET_APE_MODE_CHANNEL_3_STATUS(__reg__) (((__reg__) & 0x80000000) >> 31u)
-#define SET_APE_MODE_CHANNEL_3_STATUS(__val__) (((__val__) << 31u) & 0x80000000u)
+#define APE_MODE_CHANNEL_1_ENABLE_SHIFT 30u
+#define APE_MODE_CHANNEL_1_ENABLE_MASK 0x40000000u
+#define GET_APE_MODE_CHANNEL_1_ENABLE(__reg__) (((__reg__) & 0x40000000) >> 30u)
+#define SET_APE_MODE_CHANNEL_1_ENABLE(__val__) (((__val__) << 30u) & 0x40000000u)
+#define APE_MODE_CHANNEL_3_ENABLE_SHIFT 31u
+#define APE_MODE_CHANNEL_3_ENABLE_MASK 0x80000000u
+#define GET_APE_MODE_CHANNEL_3_ENABLE(__reg__) (((__reg__) & 0x80000000) >> 31u)
+#define SET_APE_MODE_CHANNEL_3_ENABLE(__val__) (((__val__) << 31u) & 0x80000000u)
/** @brief Register definition for @ref APE_t.Mode. */
typedef register_container RegAPEMode_t {
@@ -177,9 +177,9 @@ typedef register_container RegAPEMode_t {
/** @brief Padding */
BITFIELD_MEMBER(BCM5719_APE_H_uint32_t, reserved_13_12, 12, 2)
/** @brief */
- BITFIELD_MEMBER(BCM5719_APE_H_uint32_t, Channel0Status, 14, 1)
+ BITFIELD_MEMBER(BCM5719_APE_H_uint32_t, Channel0Enable, 14, 1)
/** @brief */
- BITFIELD_MEMBER(BCM5719_APE_H_uint32_t, Channel2Status, 15, 1)
+ BITFIELD_MEMBER(BCM5719_APE_H_uint32_t, Channel2Enable, 15, 1)
/** @brief Padding */
BITFIELD_MEMBER(BCM5719_APE_H_uint32_t, reserved_17_16, 16, 2)
/** @brief */
@@ -189,14 +189,14 @@ typedef register_container RegAPEMode_t {
/** @brief Padding */
BITFIELD_MEMBER(BCM5719_APE_H_uint32_t, reserved_29_20, 20, 10)
/** @brief */
- BITFIELD_MEMBER(BCM5719_APE_H_uint32_t, Channel1Status, 30, 1)
+ BITFIELD_MEMBER(BCM5719_APE_H_uint32_t, Channel1Enable, 30, 1)
/** @brief */
- BITFIELD_MEMBER(BCM5719_APE_H_uint32_t, Channel3Status, 31, 1)
+ BITFIELD_MEMBER(BCM5719_APE_H_uint32_t, Channel3Enable, 31, 1)
#elif defined(__BIG_ENDIAN__)
/** @brief */
- BITFIELD_MEMBER(BCM5719_APE_H_uint32_t, Channel3Status, 31, 1)
+ BITFIELD_MEMBER(BCM5719_APE_H_uint32_t, Channel3Enable, 31, 1)
/** @brief */
- BITFIELD_MEMBER(BCM5719_APE_H_uint32_t, Channel1Status, 30, 1)
+ BITFIELD_MEMBER(BCM5719_APE_H_uint32_t, Channel1Enable, 30, 1)
/** @brief Padding */
BITFIELD_MEMBER(BCM5719_APE_H_uint32_t, reserved_29_20, 20, 10)
/** @brief */
@@ -206,9 +206,9 @@ typedef register_container RegAPEMode_t {
/** @brief Padding */
BITFIELD_MEMBER(BCM5719_APE_H_uint32_t, reserved_17_16, 16, 2)
/** @brief */
- BITFIELD_MEMBER(BCM5719_APE_H_uint32_t, Channel2Status, 15, 1)
+ BITFIELD_MEMBER(BCM5719_APE_H_uint32_t, Channel2Enable, 15, 1)
/** @brief */
- BITFIELD_MEMBER(BCM5719_APE_H_uint32_t, Channel0Status, 14, 1)
+ BITFIELD_MEMBER(BCM5719_APE_H_uint32_t, Channel0Enable, 14, 1)
/** @brief Padding */
BITFIELD_MEMBER(BCM5719_APE_H_uint32_t, reserved_13_12, 12, 2)
/** @brief */
@@ -268,18 +268,18 @@ typedef register_container RegAPEMode_t {
bits.SwapATBdword.setName("SwapATBdword");
bits.SwapARBdword.setBaseRegister(&r32);
bits.SwapARBdword.setName("SwapARBdword");
- bits.Channel0Status.setBaseRegister(&r32);
- bits.Channel0Status.setName("Channel0Status");
- bits.Channel2Status.setBaseRegister(&r32);
- bits.Channel2Status.setName("Channel2Status");
+ bits.Channel0Enable.setBaseRegister(&r32);
+ bits.Channel0Enable.setName("Channel0Enable");
+ bits.Channel2Enable.setBaseRegister(&r32);
+ bits.Channel2Enable.setName("Channel2Enable");
bits.MemoryECC.setBaseRegister(&r32);
bits.MemoryECC.setName("MemoryECC");
bits.ICodePIPRdDisable.setBaseRegister(&r32);
bits.ICodePIPRdDisable.setName("ICodePIPRdDisable");
- bits.Channel1Status.setBaseRegister(&r32);
- bits.Channel1Status.setName("Channel1Status");
- bits.Channel3Status.setBaseRegister(&r32);
- bits.Channel3Status.setName("Channel3Status");
+ bits.Channel1Enable.setBaseRegister(&r32);
+ bits.Channel1Enable.setName("Channel1Enable");
+ bits.Channel3Enable.setBaseRegister(&r32);
+ bits.Channel3Enable.setName("Channel3Enable");
}
RegAPEMode_t& operator=(const RegAPEMode_t& other)
{
diff --git a/ipxact/APE_component.xml b/ipxact/APE_component.xml
index 3200034..38886ce 100644
--- a/ipxact/APE_component.xml
+++ b/ipxact/APE_component.xml
@@ -89,14 +89,14 @@
<ipxact:access>read-write</ipxact:access>
</ipxact:field>
<ipxact:field>
- <ipxact:name>Channel 0 Status</ipxact:name>
+ <ipxact:name>Channel 0 Enable</ipxact:name>
<ipxact:description></ipxact:description>
<ipxact:bitOffset>14</ipxact:bitOffset>
<ipxact:bitWidth>1</ipxact:bitWidth>
<ipxact:access>read-write</ipxact:access>
</ipxact:field>
<ipxact:field>
- <ipxact:name>Channel 2 Status</ipxact:name>
+ <ipxact:name>Channel 2 Enable</ipxact:name>
<ipxact:description></ipxact:description>
<ipxact:bitOffset>15</ipxact:bitOffset>
<ipxact:bitWidth>1</ipxact:bitWidth>
@@ -117,14 +117,14 @@
<ipxact:access>read-write</ipxact:access>
</ipxact:field>
<ipxact:field>
- <ipxact:name>Channel 1 Status</ipxact:name>
+ <ipxact:name>Channel 1 Enable</ipxact:name>
<ipxact:description></ipxact:description>
<ipxact:bitOffset>30</ipxact:bitOffset>
<ipxact:bitWidth>1</ipxact:bitWidth>
<ipxact:access>read-write</ipxact:access>
</ipxact:field>
<ipxact:field>
- <ipxact:name>Channel 3 Status</ipxact:name>
+ <ipxact:name>Channel 3 Enable</ipxact:name>
<ipxact:description></ipxact:description>
<ipxact:bitOffset>31</ipxact:bitOffset>
<ipxact:bitWidth>1</ipxact:bitWidth>
diff --git a/libs/CMakeLists.txt b/libs/CMakeLists.txt
index b3fe23b..f3ef1e1 100644
--- a/libs/CMakeLists.txt
+++ b/libs/CMakeLists.txt
@@ -49,6 +49,7 @@ add_subdirectory(MII)
add_subdirectory(VPD)
add_subdirectory(NCSI)
+add_subdirectory(Network)
add_subdirectory(OptParse)
diff --git a/libs/Network/CMakeLists.txt b/libs/Network/CMakeLists.txt
new file mode 100644
index 0000000..e5dd1a5
--- /dev/null
+++ b/libs/Network/CMakeLists.txt
@@ -0,0 +1,60 @@
+################################################################################
+###
+### @file libs/Network/CMakeLists.txt
+###
+### @project
+###
+### @brief Network CMake file
+###
+################################################################################
+###
+################################################################################
+###
+### @copyright Copyright (c) 2019, 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
+################################################################################
+
+project(Network)
+
+
+# Host Simulation library
+simulator_add_library(${PROJECT_NAME} STATIC tx.c)
+target_link_libraries(${PROJECT_NAME} PRIVATE simulator NCSI)
+target_include_directories(${PROJECT_NAME} PUBLIC ../../include)
+target_include_directories(${PROJECT_NAME} PUBLIC include)
+
+# ARM Library
+arm_add_library(${PROJECT_NAME}-arm STATIC init.c tx.c)
+target_link_libraries(${PROJECT_NAME}-arm PRIVATE NCSI-arm)
+target_include_directories(${PROJECT_NAME}-arm PUBLIC ../../include)
+target_include_directories(${PROJECT_NAME}-arm PUBLIC include)
+
+# add_subdirectory(tests) \ No newline at end of file
diff --git a/libs/Network/include/Network.h b/libs/Network/include/Network.h
new file mode 100644
index 0000000..8bfadcf
--- /dev/null
+++ b/libs/Network/include/Network.h
@@ -0,0 +1,61 @@
+////////////////////////////////////////////////////////////////////////////////
+///
+/// @file Network.h
+///
+/// @project
+///
+/// @brief Network TX/RX Support Routines
+///
+////////////////////////////////////////////////////////////////////////////////
+///
+////////////////////////////////////////////////////////////////////////////////
+///
+/// @copyright Copyright (c) 2019, 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
+////////////////////////////////////////////////////////////////////////////////
+
+#ifndef NETWORK_H
+#define NETWORK_H
+
+#include <stdint.h>
+
+void Network_InitTxRx(void);
+
+uint32_t Network_TX_numBlocksNeeded(uint32_t frame_size);
+int32_t Network_TX_allocateBlock(void);
+
+void Network_TX_transmitBePacket(uint8_t* packet, uint32_t length);
+
+
+
+
+
+#endif /* NETWORK_H */ \ No newline at end of file
diff --git a/ape/rx_from_network.c b/libs/Network/init.c
index 430409c..45be102 100644
--- a/ape/rx_from_network.c
+++ b/libs/Network/init.c
@@ -1,10 +1,10 @@
////////////////////////////////////////////////////////////////////////////////
///
-/// @file rx_from_network.c
+/// @file init.c
///
/// @project
///
-/// @brief Initialization code for RX from network.
+/// @brief Initialization code for TX to network / RX from network.
///
////////////////////////////////////////////////////////////////////////////////
///
@@ -42,8 +42,6 @@
/// @endcond
////////////////////////////////////////////////////////////////////////////////
-#include "ape.h"
-
#include <APE_FILTERS.h>
#include <APE_APE.h>
#include <APE_DEVICE.h>
@@ -641,7 +639,7 @@ static const FilterRuleInit_t gRuleInit[32] = {
},
};
-void initRxFromNetwork(void)
+void Network_InitTxRx(void)
{
for(int i = 0; i < 32; i++)
{
@@ -674,17 +672,41 @@ void initRxFromNetwork(void)
// I recommend also setting APE_PROMISCUOUS_MODE and PROMISCUOUS_MODE,
// as these will cause you less headaches during development.
DEVICE.ReceiveMacMode.bits.Enable = 1;
- // DEVICE.ReceiveMacMode.bits.PromiscuousMode = 1;
- // DEVICE.ReceiveMacMode.bits.APEPromiscuousMode = 1;
+ DEVICE.ReceiveMacMode.bits.PromiscuousMode = 1;
+ DEVICE.ReceiveMacMode.bits.APEPromiscuousMode = 1;
// Ensure REG_EMAC_MODE__ENABLE_APE_{TX,RX}_PATH are set.
// *** NOTE: Both bits are set in rmu.c ***/
+ // Enable APE channel 0/0
+ RegAPEMode_t mode;
+ mode = APE.Mode;
+ mode.bits.Event1 = 1;
+ mode.bits.Channel0Enable = 1;
+ mode.bits.Channel2Enable = 1;
+ APE.Mode = mode;
+
+
// Enable RX for funciton 0
- RegAPERxPoolModeStatus0_t poolMode;
- poolMode.r32 = 0;
- poolMode.bits.Enable = 1;
- APE.RxPoolModeStatus0 = poolMode;
+ RegAPERxPoolModeStatus0_t rxMode;
+ rxMode.r32 = 0;
+ rxMode.bits.Reset = 1;
+ APE.RxPoolModeStatus0 = rxMode;
+
+ rxMode.bits.Reset = 0;
+ rxMode.bits.Enable = 1;
+ APE.RxPoolModeStatus0 = rxMode;
+
+ // Enable TX for function 0
+ RegAPETxToNetPoolModeStatus0_t txMode;
+ txMode.r32 = 0;
+ txMode.bits.Reset = 1;
+ APE.TxToNetPoolModeStatus0 = txMode;
+
+ txMode.bits.Reset = 0;
+ txMode.bits.Enable = 1;
+ APE.TxToNetPoolModeStatus0 = txMode;
+
}
diff --git a/libs/Network/tx.c b/libs/Network/tx.c
new file mode 100644
index 0000000..730afb6
--- /dev/null
+++ b/libs/Network/tx.c
@@ -0,0 +1,296 @@
+////////////////////////////////////////////////////////////////////////////////
+///
+/// @file tx.c
+///
+/// @project
+///
+/// @brief Network transmission routines
+///
+////////////////////////////////////////////////////////////////////////////////
+///
+////////////////////////////////////////////////////////////////////////////////
+///
+/// @copyright Copyright (c) 2019, 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 <Network.h>
+#include <Ethernet.h>
+#include <APE_APE.h>
+#include <APE_TX_PORT.h>
+
+#ifdef CXX_SIMULATOR
+#include <stdio.h>
+#include <endian.h>
+#else
+/* ARM */
+static inline uint32_t be32toh(uint32_t be32)
+{
+ uint32_t le32 = (be32 & 0xFF000000 >> 24) |
+ (be32 & 0x00FF0000 >> 8) |
+ (be32 & 0x0000FF00 << 8) |
+ (be32 & 0x000000FF << 24);
+
+ return le32;
+}
+#endif
+
+uint32_t Network_TX_numBlocksNeeded(uint32_t frame_size)
+{
+ static const uint32_t first_size = 20 * sizeof(uint32_t);
+ static const uint32_t remaining_size = 30 * sizeof(uint32_t);
+ uint32_t blocks = 1;
+ // Block size is 128 bytes, first one has 12 words used, so 20 words available.
+ if(frame_size > first_size)
+ {
+ frame_size -= 20 * sizeof(uint32_t);
+
+ // Remaining blocks can hold 30 words;
+ blocks += ((frame_size + remaining_size - 1) / remaining_size);
+ }
+
+#ifdef CXX_SIMULATOR
+ printf("%d blocks needed for packet\n", blocks);
+#endif
+ return blocks;
+}
+
+
+
+int32_t __attribute__((noinline)) Network_TX_allocateBlock(void)
+{
+ int32_t block = -1;
+
+ // Wait for allocator state machine to finish.
+ // while(APE_TX_TO_NET_BUFFER_ALLOCATOR_0_STATE_PROCESSING == APE.TxToNetBufferAllocator0.bits.State);
+
+ // Set the alloc bit.
+ RegAPETxToNetBufferAllocator0_t alloc;
+ alloc.r32 = 0;
+ alloc.bits.RequestAllocation = 1;
+ APE.TxToNetBufferAllocator0 = alloc;
+
+ // Wait for state machine to finish
+ RegAPETxToNetBufferAllocator0_t status;
+ do {
+ status = APE.TxToNetBufferAllocator0;
+ } while(APE_TX_TO_NET_BUFFER_ALLOCATOR_0_STATE_PROCESSING == status.bits.State);
+
+ if(APE_TX_TO_NET_BUFFER_ALLOCATOR_0_STATE_ALLOCATION_OK != status.bits.State)
+ {
+ block = -1;
+#if CXX_SIMULATOR
+ printf("Error: Failed to allocate TX block.\n");
+#endif
+ }
+ else
+ {
+ block = status.bits.Index;
+#if CXX_SIMULATOR
+ printf("Allocated TX block %d\n", block);
+#endif
+ }
+
+ return block;
+}
+
+uint32_t __attribute__((noinline)) Network_TX_initFirstBlockBe(RegTX_PORTOut_t* block, uint32_t length, int32_t blocks, int32_t next_block, uint32_t* packet)
+{
+ int copy_length;
+ int i;
+ union {
+ uint32_t r32;
+ struct {
+ uint32_t payload_length:7;
+ uint32_t next_block:23;
+ uint32_t first:1;
+ uint32_t not_last:1;
+ } bits;
+ } control;
+
+ control.r32 = 0;
+ control.bits.next_block = next_block >= 0 ? next_block : 0;
+ control.bits.first = 1;
+
+ if(length > ((TX_PORT_OUT_ALL_BLOCK_WORDS - TX_PORT_OUT_ALL_FIRST_PAYLOAD_WORD)*4))
+ {
+ copy_length = (TX_PORT_OUT_ALL_BLOCK_WORDS - TX_PORT_OUT_ALL_FIRST_PAYLOAD_WORD)*4;
+ control.bits.not_last = 1;
+ }
+ else
+ {
+ // Last.
+ copy_length = length;
+ control.bits.not_last = 0;
+ }
+
+ // block[1] = uninitialized;
+ block[2].r32 = 0;
+ block[3].r32 = 0;
+ block[4].r32 = 0;
+ block[5].r32 = 0;
+ block[6].r32 = 0;
+ block[7].r32 = 0;
+ block[8].r32 = 0;
+ block[9].r32 = 0;
+ // block[10] = uninitialized;
+ // block[11] = uninitialized;
+ block[TX_PORT_OUT_ALL_FRAME_LEN_WORD].r32 = length;
+ block[TX_PORT_OUT_ALL_NUM_BLOCKS_WORD].r32 = blocks;
+
+ // Copy Payload Data.
+ int num_words = (copy_length + sizeof(uint32_t) - 1)/sizeof(uint32_t);
+ for(i = 0; i < num_words; i++)
+ {
+ block[TX_PORT_OUT_ALL_FIRST_PAYLOAD_WORD + i].r32 = be32toh(packet[i]);
+ }
+
+ // Pad if too small.
+ if(copy_length < ETHERNET_FRAME_MIN)
+ {
+ copy_length = ETHERNET_FRAME_MIN;
+ length = ETHERNET_FRAME_MIN;
+ }
+ num_words = (copy_length + sizeof(uint32_t) - 1)/sizeof(uint32_t);
+ for(; i < num_words; i++)
+ {
+ // Pad remaining with 0's
+ block[TX_PORT_OUT_ALL_FIRST_PAYLOAD_WORD + i].r32 = 0;
+ }
+
+ control.bits.payload_length = copy_length;
+
+ block[TX_PORT_OUT_ALL_CONTROL_WORD].r32 = control.r32;
+
+ length -= control.bits.payload_length;
+
+ return copy_length;
+}
+
+
+uint32_t __attribute__((noinline)) Network_TX_initAdditionalBlockBe(RegTX_PORTOut_t* block, int32_t next_block, uint32_t length, uint32_t* packet)
+{
+ int i;
+ union {
+ uint32_t r32;
+ struct {
+ uint32_t payload_length:7;
+ uint32_t next_block:23;
+ uint32_t first:1;
+ uint32_t not_last:1;
+ } bits;
+ } control;
+
+ control.r32 = 0;
+ control.bits.first = 0;
+ control.bits.next_block = next_block;
+
+ if(length > ((TX_PORT_OUT_ALL_BLOCK_WORDS - TX_PORT_OUT_ALL_ADDITIONAL_PAYLOAD_WORD)*4))
+ {
+ control.bits.payload_length = (TX_PORT_OUT_ALL_BLOCK_WORDS - TX_PORT_OUT_ALL_ADDITIONAL_PAYLOAD_WORD)*4;
+ control.bits.not_last = 1;
+ }
+ else
+ {
+ // Last
+ control.bits.payload_length = length;
+ control.bits.not_last = 0;
+ }
+
+ // block[1] = uninitialized;
+
+ // Copy payload data.
+ int num_words = (length + sizeof(uint32_t) - 1)/sizeof(uint32_t);
+ for(i = 0; i < num_words; i++)
+ {
+ block[TX_PORT_OUT_ALL_ADDITIONAL_PAYLOAD_WORD + i].r32 = be32toh(packet[i]);
+
+ }
+
+ block[TX_PORT_OUT_ALL_CONTROL_WORD].r32 = control.r32;
+
+ length -= control.bits.payload_length;
+
+ return length;
+}
+
+void Network_TX_transmitBePacket(uint8_t* packet, uint32_t length)
+{
+ uint32_t* packet_32 = (uint32_t*)packet;
+ uint32_t consumed = 0;
+ uint32_t blocks = Network_TX_numBlocksNeeded(length);
+ int total_blocks = blocks;;
+
+ // First block
+ int32_t first = Network_TX_allocateBlock();
+ int32_t next_block = -1;
+ if(blocks > 1)
+ {
+ next_block = Network_TX_allocateBlock();
+ }
+ RegTX_PORTOut_t* block = (RegTX_PORTOut_t*)&TX_PORT.Out[TX_PORT_OUT_ALL_BLOCK_WORDS * first];
+
+ consumed += Network_TX_initFirstBlockBe(block, length, blocks, next_block, &packet_32[consumed/4]);
+ blocks -= 1;
+ while(blocks)
+ {
+
+ block = (RegTX_PORTOut_t*)&TX_PORT.Out[TX_PORT_OUT_ALL_BLOCK_WORDS * next_block];
+ blocks--;
+ if(blocks)
+ {
+ next_block = Network_TX_allocateBlock();
+ consumed += Network_TX_initAdditionalBlockBe(block, next_block, length-consumed, &packet_32[consumed/4]);
+ }
+ else
+ {
+ Network_TX_initAdditionalBlockBe(block, 0, length - consumed, &packet_32[consumed/4]);
+ }
+ }
+
+ int tail = next_block;
+ if(next_block == -1)
+ {
+ tail = first;
+ }
+
+ RegAPETxToNetDoorbellFunc0_t doorbell;
+ doorbell.r32 = 0;
+ doorbell.bits.Head = first;
+ doorbell.bits.Tail = tail;
+ doorbell.bits.Length = total_blocks;
+ // doorbell.print();
+
+ APE.TxToNetDoorbellFunc0 = doorbell;
+ // APE.TxToNetDoorbellFunc0.print();
+ // APE.TxToNetBufferReturn0.print();
+}
diff --git a/simulator/CMakeLists.txt b/simulator/CMakeLists.txt
index 5795cde..21c0698 100644
--- a/simulator/CMakeLists.txt
+++ b/simulator/CMakeLists.txt
@@ -31,6 +31,10 @@ simulator_add_library(${PROJECT_NAME} STATIC
APE_FILTERS_sim.cpp
APE_NVIC.cpp
APE_NVIC_sim.cpp
+
+ APE_TX_PORT.cpp
+ APE_TX_PORT_sim.cpp
+
)
include_directories(../libs/NVRam)
diff --git a/simulator/HAL.cpp b/simulator/HAL.cpp
index 364f33f..46b0705 100644
--- a/simulator/HAL.cpp
+++ b/simulator/HAL.cpp
@@ -12,6 +12,7 @@
#include <bcm5719_GEN.h>
#include <APE_NVIC.h>
#include <APE_FILTERS.h>
+#include <APE_TX_PORT.h>
#include <dirent.h>
#include <endian.h>
@@ -284,5 +285,8 @@ bool initHAL(const char *pci_path, int wanted_function)
init_APE_NVIC();
init_APE_NVIC_sim(NULL);
+ init_APE_TX_PORT();
+ init_APE_TX_PORT_sim(NULL);
+
return true;
}
diff --git a/simulator/include/CXXRegister.h b/simulator/include/CXXRegister.h
index d565d4d..3e40e3e 100644
--- a/simulator/include/CXXRegister.h
+++ b/simulator/include/CXXRegister.h
@@ -148,6 +148,13 @@ protected:
void doRelatedWritesBase(CXXRegisterBase* source)
{
+ if(source->mMask != this->mMask)
+ {
+ // read latest value as we are only modifying some bits.
+ doReadCallbacks();
+ setRawValue(getTempValue());
+ }
+
// Update base temp value with latest write.
unsigned int base = getRawValue();
base &= ~(source->mMask);
OpenPOWER on IntegriCloud