From 4e9143d8ab7fe77339946b7bc37eec0820b00f2e Mon Sep 17 00:00:00 2001 From: Evan Lojewski Date: Sat, 29 Jun 2019 11:34:55 -0600 Subject: SPlit the MIPS hal from the APE hal in the simulation code. --- simulator/APE_HAL.cpp | 113 ++++++++++++++++++++++++++++++++++++++++++++++ simulator/CMakeLists.txt | 1 + simulator/HAL.cpp | 92 ++++++++++++++++++------------------- simulator/include/HAL.hpp | 11 +++-- utils/apeconsole/main.cpp | 1 + utils/bcmflash/main.cpp | 5 ++ 6 files changed, 169 insertions(+), 54 deletions(-) create mode 100644 simulator/APE_HAL.cpp diff --git a/simulator/APE_HAL.cpp b/simulator/APE_HAL.cpp new file mode 100644 index 0000000..5f968e2 --- /dev/null +++ b/simulator/APE_HAL.cpp @@ -0,0 +1,113 @@ +//////////////////////////////////////////////////////////////////////////////// +/// +/// @file APE_HAL.cpp +/// +/// @project +/// +/// @brief C++ Register wrapper code for the APE +/// +//////////////////////////////////////////////////////////////////////////////// +/// +//////////////////////////////////////////////////////////////////////////////// +/// +/// @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 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +void initAPEHAL(void) +{ + // init_APE_DEVICE0(); + // init_APE_DEVICE0_sim(NULL); + init_APE_DEVICE1(); + init_APE_DEVICE1_sim(NULL); + init_APE_DEVICE2(); + init_APE_DEVICE2_sim(NULL); + init_APE_DEVICE3(); + init_APE_DEVICE3_sim(NULL); + + init_APE_FILTERS0(); + init_APE_FILTERS0_sim(NULL); + + init_APE_FILTERS1(); + init_APE_FILTERS1_sim(NULL); + + init_APE_FILTERS2(); + init_APE_FILTERS2_sim(NULL); + + init_APE_FILTERS3(); + init_APE_FILTERS3_sim(NULL); + + init_APE_NVIC(); + init_APE_NVIC_sim(NULL); + + init_APE_TX_PORT0(); + init_APE_TX_PORT0_sim(NULL); + + init_APE_RX_PORT0(); + init_APE_RX_PORT0_sim(NULL); + + init_APE_TX_PORT1(); + init_APE_TX_PORT1_sim(NULL); + + init_APE_RX_PORT1(); + init_APE_RX_PORT1_sim(NULL); + + init_APE_TX_PORT2(); + init_APE_TX_PORT2_sim(NULL); + + init_APE_RX_PORT2(); + init_APE_RX_PORT2_sim(NULL); + + init_APE_TX_PORT3(); + init_APE_TX_PORT3_sim(NULL); + + init_APE_RX_PORT3(); + init_APE_RX_PORT3_sim(NULL); +} \ No newline at end of file diff --git a/simulator/CMakeLists.txt b/simulator/CMakeLists.txt index d8061ab..20302a3 100644 --- a/simulator/CMakeLists.txt +++ b/simulator/CMakeLists.txt @@ -27,6 +27,7 @@ simulator_add_library(${PROJECT_NAME} STATIC bcm5719_SHM_CHANNEL3_sim.cpp # APE indirect registers + APE_HAL.cpp APE_FILTERS0.cpp APE_FILTERS0_sim.cpp APE_NVIC.cpp diff --git a/simulator/HAL.cpp b/simulator/HAL.cpp index 90ca052..2342840 100644 --- a/simulator/HAL.cpp +++ b/simulator/HAL.cpp @@ -1,3 +1,46 @@ +//////////////////////////////////////////////////////////////////////////////// +/// +/// @file HAL.cpp +/// +/// @project +/// +/// @brief C++ Register wrapper code +/// +//////////////////////////////////////////////////////////////////////////////// +/// +//////////////////////////////////////////////////////////////////////////////// +/// +/// @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 "../libs/NVRam/bcm5719_NVM.h" #include "pci_config.h" @@ -10,19 +53,6 @@ #include #include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -// #include -// #include -// #include #include #include @@ -302,41 +332,5 @@ bool initHAL(const char *pci_path, int wanted_function) init_bcm5719_SHM_CHANNEL3(); init_bcm5719_SHM_CHANNEL3_sim(&APEBase[0x4c00]); - init_APE_FILTERS0(); - init_APE_FILTERS0_sim(NULL); - - init_APE_NVIC(); - init_APE_NVIC_sim(NULL); - - init_APE_TX_PORT0(); - init_APE_TX_PORT0_sim(NULL); - - init_APE_RX_PORT0(); - init_APE_RX_PORT0_sim(NULL); - - init_APE_TX_PORT1(); - init_APE_TX_PORT1_sim(NULL); - - init_APE_RX_PORT1(); - init_APE_RX_PORT1_sim(NULL); - - init_APE_TX_PORT2(); - init_APE_TX_PORT2_sim(NULL); - - init_APE_RX_PORT2(); - init_APE_RX_PORT2_sim(NULL); - - init_APE_TX_PORT3(); - init_APE_TX_PORT3_sim(NULL); - - init_APE_RX_PORT3(); - init_APE_RX_PORT3_sim(NULL); - - // init_APE_DEVICE1(); - // init_APE_DEVICE1_sim(NULL); - // init_APE_DEVICE2(); - // init_APE_DEVICE2_sim(NULL); - // init_APE_DEVICE3(); - // init_APE_DEVICE3_sim(NULL); return true; } diff --git a/simulator/include/HAL.hpp b/simulator/include/HAL.hpp index 198b782..4898f2c 100644 --- a/simulator/include/HAL.hpp +++ b/simulator/include/HAL.hpp @@ -2,15 +2,15 @@ /// /// @file HAL.h /// -/// @project +/// @project /// -/// @brief C++ REgister wrapper code +/// @brief C++ Register wrapper code /// //////////////////////////////////////////////////////////////////////////////// /// //////////////////////////////////////////////////////////////////////////////// /// -/// @copyright Copyright (c) 2018, Evan Lojewski +/// @copyright Copyright (c) 2019, Evan Lojewski /// @cond /// /// All rights reserved. @@ -45,11 +45,12 @@ #ifndef HAL_H #define HAL_H -#include -#include +#include +#include bool is_supported(uint16_t vendor_id, uint16_t device_id); bool initHAL(const char* pci_path, int wanted_function = 0); +void initAPEHAL(void); extern uint8_t *gDEVICEBase; extern uint8_t *gAPEBase; diff --git a/utils/apeconsole/main.cpp b/utils/apeconsole/main.cpp index 3010d6d..38569c4 100644 --- a/utils/apeconsole/main.cpp +++ b/utils/apeconsole/main.cpp @@ -64,6 +64,7 @@ #include #include +#include #include #include diff --git a/utils/bcmflash/main.cpp b/utils/bcmflash/main.cpp index 903b26a..c8db619 100644 --- a/utils/bcmflash/main.cpp +++ b/utils/bcmflash/main.cpp @@ -64,6 +64,8 @@ #include #include +#include + #include "../NVRam/bcm5719_NVM.h" using namespace std; @@ -484,12 +486,15 @@ int main(int argc, char const *argv[]) infile.read((char*)ape, new_ape_length); infile.close(); +#if 0 + // Erase the previous APE image while(new_ape_length < ape_length) { // erase remaining bytes. ape[new_ape_length] = 0xFF; new_ape_length++; } +#endif } printf("New Length (bytes): 0x%08X\n", new_ape_length); -- cgit v1.2.1