aboutsummaryrefslogtreecommitdiffstats
path: root/src/rp2040/bootrom.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/rp2040/bootrom.c')
-rw-r--r--src/rp2040/bootrom.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/rp2040/bootrom.c b/src/rp2040/bootrom.c
new file mode 100644
index 00000000..da2da18e
--- /dev/null
+++ b/src/rp2040/bootrom.c
@@ -0,0 +1,25 @@
+// Hardware interface to bootrom on rp2040
+//
+// Copyright (C) 2021 Lasse Dalegaard <dalegaard@gmail.com>
+//
+// This file may be distributed under the terms of the GNU GPLv3 license.
+
+#include <stdint.h> // uint16_t, uint32_t, uintptr_t
+
+static void *
+rom_func_lookup(uint32_t code)
+{
+ // Table and lookup function are provided by the BOOTROM
+ void *(*fn)(uint16_t *, uint32_t) =
+ (void *)(uintptr_t)(*(uint16_t *)0x18);
+ uint16_t *table = (uint16_t *)(uintptr_t)(*(uint16_t *)0x14);
+ return fn(table, code);
+}
+
+void
+reset_to_usb_boot(uint32_t gpio_activity_pin_mask
+ , uint32_t disable_interface_mask)
+{
+ void (*reset_to_usb_boot)(uint32_t, uint32_t) = rom_func_lookup(0x4255);
+ reset_to_usb_boot(gpio_activity_pin_mask, disable_interface_mask);
+}