|
78 | 78 | /* reserved for 32-bit pointer: 0x0008 */ |
79 | 79 | #define RT_FLAG_FUNC_ARM_NONSEC 0x0010 |
80 | 80 |
|
81 | | -#define BOOTROM_FUNC_TABLE_OFFSET 0x14 |
82 | | - |
83 | | -#define BOOTROM_IS_A2() ((*(volatile uint8_t *)0x13) == 2) |
84 | | -#define BOOTROM_WELL_KNOWN_PTR_SIZE (BOOTROM_IS_A2() ? 2 : 4) |
85 | | - |
86 | | -#if defined(__riscv) |
| 81 | +#define BOOTROM_WELL_KNOWN_PTR_SIZE 2 |
87 | 82 | #define BOOTROM_ENTRY_OFFSET 0x7dfc |
88 | 83 | #define BOOTROM_TABLE_LOOKUP_ENTRY_OFFSET (BOOTROM_ENTRY_OFFSET - BOOTROM_WELL_KNOWN_PTR_SIZE) |
89 | 84 | #define BOOTROM_TABLE_LOOKUP_OFFSET (BOOTROM_ENTRY_OFFSET - BOOTROM_WELL_KNOWN_PTR_SIZE*2) |
90 | | -#else |
91 | | -#define BOOTROM_VTABLE_OFFSET 0x00 |
92 | | -#define BOOTROM_TABLE_LOOKUP_OFFSET (BOOTROM_FUNC_TABLE_OFFSET + BOOTROM_WELL_KNOWN_PTR_SIZE) |
93 | | -#endif |
94 | 85 |
|
95 | 86 | #define ROM_TABLE_CODE(c1, c2) ((c1) | ((c2) << 8)) |
96 | 87 |
|
| 88 | +#define REBOOT2_TYPE_MASK 0x0f |
| 89 | + |
| 90 | +/* note these match REBOOT_TYPE */ |
| 91 | + |
| 92 | +/* values 0-7 are secure/non-secure */ |
| 93 | +#define REBOOT2_FLAG_REBOOT_TYPE_NORMAL 0x0 /* param0 = diagnostic partition */ |
| 94 | +#define REBOOT2_FLAG_REBOOT_TYPE_BOOTSEL 0x2 /* param0 = gpio_pin_number, param1 = flags */ |
| 95 | +#define REBOOT2_FLAG_REBOOT_TYPE_RAM_IMAGE 0x3 /* param0 = image_region_base, param1 = image_region_size */ |
| 96 | +#define REBOOT2_FLAG_REBOOT_TYPE_FLASH_UPDATE 0x4 /* param0 = update_base */ |
| 97 | + |
| 98 | +/* values 8-15 are secure only */ |
| 99 | +#define REBOOT2_FLAG_REBOOT_TYPE_PC_SP 0xd |
| 100 | + |
| 101 | +#define REBOOT2_FLAG_REBOOT_TO_ARM 0x10 |
| 102 | +#define REBOOT2_FLAG_REBOOT_TO_RISCV 0x20 |
| 103 | + |
| 104 | +#define REBOOT2_FLAG_NO_RETURN_ON_SUCCESS 0x100 |
| 105 | + |
| 106 | +#define BOOTSEL_FLAG_DISABLE_MSD_INTERFACE 0x01 |
| 107 | +#define BOOTSEL_FLAG_DISABLE_PICOBOOT_INTERFACE 0x02 |
| 108 | +#define BOOTSEL_FLAG_GPIO_PIN_ACTIVE_LOW 0x10 |
| 109 | +#define BOOTSEL_FLAG_GPIO_PIN_SPECIFIED 0x20 |
| 110 | + |
| 111 | +#define PICOBOOT_GET_INFO_SYS 1 |
| 112 | +#define PICOBOOT_GET_INFO_PARTTION_TABLE 2 |
| 113 | +#define PICOBOOT_GET_INFO_UF2_TARGET_PARTITION 3 |
| 114 | +#define PICOBOOT_GET_INFO_UF2_STATUS 4 |
| 115 | + |
| 116 | +#define UF2_STATUS_IGNORED_FAMILY 0x01 |
| 117 | +#define UF2_STATUS_ABORT_EXCLUSIVELY_LOCKED 0x10 |
| 118 | +#define UF2_STATUS_ABORT_BAD_ADDRESS 0x20 |
| 119 | +#define UF2_STATUS_ABORT_WRITE_ERROR 0x40 |
| 120 | +#define UF2_STATUS_ABORT_REBOOT_FAILED 0x80 |
| 121 | + |
97 | 122 | /**************************************************************************** |
98 | 123 | * Public Type Definitions |
99 | 124 | ****************************************************************************/ |
100 | 125 |
|
101 | 126 | typedef void *(*rom_table_lookup_fn)(uint32_t code, uint32_t mask); |
102 | 127 |
|
103 | | -static __inline void *rom_func_lookup(uint32_t code) |
104 | | -{ |
105 | | -#ifdef __riscv |
106 | | - uint32_t rom_offset_adjust = rom_size_is_64k() ? 32 * 1024 : 0; |
107 | | - |
108 | | - /* on RISC-V the code (a jmp) is actually embedded in the table */ |
| 128 | +typedef int (*rom_reboot_fn)(uint32_t flags, uint32_t delay_ms, |
| 129 | + uint32_t p0, uint32_t p1); |
109 | 130 |
|
110 | | - rom_table_lookup_fn rom_table_lookup = (rom_table_lookup_fn) (uintptr_t) |
111 | | - *(uint16_t *)(BOOTROM_TABLE_LOOKUP_ENTRY_OFFSET + rom_offset_adjust); |
| 131 | +static void *rom_func_lookup(uint32_t code) |
| 132 | +{ |
| 133 | + rom_table_lookup_fn rom_table_lookup = (rom_table_lookup_fn)(uintptr_t) |
| 134 | + *(uint16_t *)(BOOTROM_TABLE_LOOKUP_ENTRY_OFFSET); |
112 | 135 |
|
113 | 136 | return rom_table_lookup(code, RT_FLAG_FUNC_RISCV); |
114 | | -#else |
115 | | - /* on ARM the function pointer is stored in the table, so we dereference |
116 | | - * it via lookup() rather than lookup_entry() |
117 | | - */ |
118 | | - |
119 | | - rom_table_lookup_fn rom_table_lookup = (rom_table_lookup_fn) (uintptr_t) |
120 | | - *(uint16_t *)(BOOTROM_TABLE_LOOKUP_OFFSET); |
121 | | - if (pico_processor_state_is_nonsecure()) |
122 | | - { |
123 | | - return rom_table_lookup(code, RT_FLAG_FUNC_ARM_NONSEC); |
124 | | - } |
125 | | - else |
126 | | - { |
127 | | - return rom_table_lookup(code, RT_FLAG_FUNC_ARM_SEC); |
128 | | - } |
129 | | -#endif |
130 | 137 | } |
0 commit comments