summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEvan Lojewski <github@meklort.com>2020-02-16 22:48:32 -0700
committerGitHub <noreply@github.com>2020-02-16 22:48:32 -0700
commitf2dea3a2f10ca19344f9246e1df1a8a9f2c3d1ed (patch)
treefdae4b5234af9cfb911f4cf0d35b1f0ab46e4dec
parent3d8734da2d4786088a9c9d3d6aac552ae38a1f53 (diff)
downloadbcm5719-ortega-f2dea3a2f10ca19344f9246e1df1a8a9f2c3d1ed.tar.gz
bcm5719-ortega-f2dea3a2f10ca19344f9246e1df1a8a9f2c3d1ed.zip
Update the bcmregtool and apeloader to work on pci functions 1, 2, and 3. (#33)
-rw-r--r--utils/bcmregtool/apeloader/main.c97
-rw-r--r--utils/bcmregtool/main.cpp3
2 files changed, 61 insertions, 39 deletions
diff --git a/utils/bcmregtool/apeloader/main.c b/utils/bcmregtool/apeloader/main.c
index f1e886b..54c4642 100644
--- a/utils/bcmregtool/apeloader/main.c
+++ b/utils/bcmregtool/apeloader/main.c
@@ -43,53 +43,74 @@
////////////////////////////////////////////////////////////////////////////////
#include <APE_SHM.h>
+#include <APE_SHM1.h>
+#include <APE_SHM2.h>
+#include <APE_SHM3.h>
-int __start()
+void init_shm(volatile SHM_t* shm)
{
- // Update SHM.Sig to signal ready.
- SHM.SegSig.bits.Sig = SHM_SEG_SIG_SIG_LOADER;
- SHM.FwStatus.bits.Ready = 1;
+ // Update shm->Sig to signal ready.
+ shm->SegSig.bits.Sig = SHM_SEG_SIG_SIG_LOADER;
+ shm->FwStatus.bits.Ready = 1;
- for (;;)
+}
+
+void handle_command(volatile SHM_t* shm)
+{
+ uint32_t command = shm->LoaderCommand.bits.Command;
+ if (!command)
+ {
+ return;
+ }
+
+ uint32_t arg0 = shm->LoaderArg0.r32;
+ uint32_t arg1 = shm->LoaderArg1.r32;
+
+ switch (command)
{
- uint32_t command = SHM.LoaderCommand.bits.Command;
- if (!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:
{
- continue;
+ // call address specified in arg0.
+ void (*function)(uint32_t) = ((void *)arg0);
+ function(arg1);
+ break;
}
+ }
- uint32_t arg0 = SHM.LoaderArg0.r32;
- uint32_t arg1 = SHM.LoaderArg1.r32;
+ // Mark command as handled.
+ shm->LoaderCommand.bits.Command = 0;
+}
- 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;
- }
- }
+int __start()
+{
+ init_shm(&SHM);
+ init_shm(&SHM1);
+ init_shm(&SHM2);
+ init_shm(&SHM3);
- // Mark command as handled.
- SHM.LoaderCommand.bits.Command = 0;
+ for (;;)
+ {
+ handle_command(&SHM);
+ handle_command(&SHM1);
+ handle_command(&SHM2);
+ handle_command(&SHM3);
}
} \ No newline at end of file
diff --git a/utils/bcmregtool/main.cpp b/utils/bcmregtool/main.cpp
index faeacde..0d9181e 100644
--- a/utils/bcmregtool/main.cpp
+++ b/utils/bcmregtool/main.cpp
@@ -103,6 +103,7 @@ void boot_ape_loader()
extern unsigned char apeloader_bin[];
extern unsigned int apeloader_bin_len;
+ int function = DEVICE.Status.bits.FunctionNumber;
int numWords = apeloader_bin_len/4;
RegAPEMode_t mode;
@@ -124,7 +125,7 @@ void boot_ape_loader()
// Mark fw as not read.
SHM.FwStatus.bits.Ready = 0;
// Start the file
- APE.GpioMessage.r32 = 0x60220B00|2;
+ APE.GpioMessage.r32 = 0x60220B00|2 + (0x1000 * function);
mode.bits.Halt = 0;
mode.bits.FastBoot = 1;
OpenPOWER on IntegriCloud