summaryrefslogtreecommitdiffstats
path: root/utils/apeconsole/main.cpp
diff options
context:
space:
mode:
authorEvan Lojewski <github@meklort.com>2020-02-17 20:47:13 -0700
committerGitHub <noreply@github.com>2020-02-17 20:47:13 -0700
commit23b478f335cd622049ad17f1f7ca4f0641200705 (patch)
tree2243e00ad65259233171f3fbc97eb898c806af3e /utils/apeconsole/main.cpp
parentd2419a287fc52929c351fb7fed54bae323fedc54 (diff)
downloadbcm5719-ortega-23b478f335cd622049ad17f1f7ca4f0641200705.tar.gz
bcm5719-ortega-23b478f335cd622049ad17f1f7ca4f0641200705.zip
printf: Remove nvm access from the ape as it triggers a race condition when the rx cpu is restarted. (#35)
Rather than print directly, the APE now using the host debug console only for printf. The RX cpu (function 0 only) uses the debug console and forwards it over SPI when new data is available.
Diffstat (limited to 'utils/apeconsole/main.cpp')
-rw-r--r--utils/apeconsole/main.cpp36
1 files changed, 23 insertions, 13 deletions
diff --git a/utils/apeconsole/main.cpp b/utils/apeconsole/main.cpp
index 9cfd048..0614bc7 100644
--- a/utils/apeconsole/main.cpp
+++ b/utils/apeconsole/main.cpp
@@ -101,29 +101,39 @@ int main(int argc, char const *argv[])
exit(-1);
}
- uint32_t* DEBUG = (uint32_t*)&gAPEBase[0x4000];
- volatile uint32_t* write_pointer = &DEBUG[0];
- volatile uint32_t* read_pointer = &DEBUG[1];
- uint32_t buffer_size = 0x1000 - 8;
- volatile uint32_t* buffer = &DEBUG[2];
+ uint32_t buffer_size = sizeof(SHM.RcpuPrintfBuffer)/sizeof(SHM.RcpuPrintfBuffer[0]) * sizeof(uint32_t);
+
+ if (SHM.RcpuWritePointer.r32 > buffer_size ||
+ SHM.RcpuReadPointer.r32 > buffer_size ||
+ SHM.RcpuHostReadPointer.r32 > buffer_size)
+ {
+ // Print buffer has not been initialized or we are not function 0. Exit out.
+ cerr << "Unexpected value in SHM. exiting." << endl;
+ cerr << "Write Pointer: " << SHM.RcpuWritePointer.r32 << endl;
+ cerr << "Read Pointer: " << SHM.RcpuReadPointer.r32 << endl;
+ cerr << "Host Read Pointer: " << SHM.RcpuHostReadPointer.r32 << endl;
+ cerr << "Max Pointer: " << buffer_size << endl;
+ exit(-1);
+ }
for(;;)
{
BARRIER();
- uint32_t cached_pointer = *read_pointer;
- if(cached_pointer != *write_pointer)
+ uint32_t cached_pointer = SHM.RcpuHostReadPointer.r32;
+ if(cached_pointer != SHM.RcpuWritePointer.r32)
{
+ if(cached_pointer >= buffer_size)
+ {
+ cached_pointer = 0;
+ }
+
uint32_t word_pointer = cached_pointer / 4;
uint32_t byte_index = cached_pointer % 4;
- char character = (uint8_t)(buffer[word_pointer] >> (byte_index * 8));
+ char character = (uint8_t)(SHM.RcpuPrintfBuffer[word_pointer].r32 >> (byte_index * 8));
// printf("Buffer[%d] = %c\n", cached_pointer, character);
putchar(character);
- if(cached_pointer++ >= buffer_size)
- {
- cached_pointer = 0;
- }
- *read_pointer = cached_pointer;
+ SHM.RcpuHostReadPointer.r32 = ++cached_pointer;
}
}
OpenPOWER on IntegriCloud