summaryrefslogtreecommitdiff
path: root/board/zinger/board.c
diff options
context:
space:
mode:
Diffstat (limited to 'board/zinger/board.c')
-rw-r--r--board/zinger/board.c40
1 files changed, 7 insertions, 33 deletions
diff --git a/board/zinger/board.c b/board/zinger/board.c
index 5dcbef04fb..3ea9850015 100644
--- a/board/zinger/board.c
+++ b/board/zinger/board.c
@@ -9,6 +9,7 @@
#include "registers.h"
#include "rsa.h"
#include "sha256.h"
+#include "system.h"
#include "task.h"
#include "usb_pd.h"
#include "util.h"
@@ -23,10 +24,6 @@ static const void *rw_sig = (void *)CONFIG_FLASH_BASE + CONFIG_FW_RW_OFF
/* Large 768-Byte buffer for RSA computation : could be re-use afterwards... */
static uint32_t rsa_workbuf[3 * RSANUMWORDS];
-static uint8_t *rw_hash;
-static uint8_t rw_flash_changed;
-static uint32_t info_data[6];
-
extern void pd_rx_handler(void);
/* RW firmware reset vector */
@@ -60,12 +57,16 @@ int is_ro_mode(void)
static int check_rw_valid(void)
{
int good;
+ void *rw_hash;
/* Check if we have a RW firmware flashed */
if (*rw_rst == 0xffffffff)
return 0;
- good = rsa_verify(&pkey, (void *)rw_sig, (void *)rw_hash, rsa_workbuf);
+ /* calculate hash of RW */
+ rw_hash = flash_hash_rw();
+
+ good = rsa_verify(&pkey, (void *)rw_sig, rw_hash, rsa_workbuf);
if (!good) {
debug_printf("RSA verify FAILED\n");
return 0;
@@ -74,30 +75,6 @@ static int check_rw_valid(void)
return 1;
}
-uint32_t *board_get_info(void)
-{
- if (rw_flash_changed) {
- /* re-calculate RW hash */
- rw_hash = flash_hash_rw();
- rw_flash_changed = 0;
- }
-
- /* copy first 20 bytes of RW hash */
- memcpy(info_data, rw_hash, 5 * sizeof(uint32_t));
-
- /* copy other info into data msg */
- info_data[5] = VDO_INFO(CONFIG_USB_PD_HW_DEV_ID_BOARD_MAJOR,
- CONFIG_USB_PD_HW_DEV_ID_BOARD_MINOR,
- ver_get_numcommits(), !is_ro_mode());
-
- return info_data;
-}
-
-void board_rw_contents_change(void)
-{
- rw_flash_changed = 1;
-}
-
extern void pd_task(void);
int main(void)
@@ -106,9 +83,6 @@ int main(void)
debug_printf("Power supply started ... %s\n",
is_ro_mode() ? "RO" : "RW");
- /* calculate hash of RW */
- rw_hash = flash_hash_rw();
-
/* Verify RW firmware and use it if valid */
if (is_ro_mode() && check_rw_valid())
jump_to_rw();
@@ -118,6 +92,6 @@ int main(void)
debug_printf("background loop exited !\n");
/* we should never reach that point */
- cpu_reset();
+ system_reset(0);
return 0;
}