Add debug region to mapped memory

This commit is contained in:
Michael Scire 2018-03-07 04:00:19 -08:00
parent b26b8e1f5c
commit 6592744b3b
5 changed files with 20 additions and 1 deletions

View file

@ -31,6 +31,7 @@
#define _MMAPDEV15 ( 0x6000D000ull, 0x1000ull, true ) /* GPIO-1 - GPIO-8 */ #define _MMAPDEV15 ( 0x6000D000ull, 0x1000ull, true ) /* GPIO-1 - GPIO-8 */
#define _MMAPDEV16 ( 0x7000C000ull, 0x1000ull, true ) /* I2C-I2C4 */ #define _MMAPDEV16 ( 0x7000C000ull, 0x1000ull, true ) /* I2C-I2C4 */
#define _MMAPDEV17 ( 0x6000F000ull, 0x1000ull, true ) /* Exception vectors */ #define _MMAPDEV17 ( 0x6000F000ull, 0x1000ull, true ) /* Exception vectors */
#define _MMAPDEV18 ( 0x40038000ull, 0x8000ull, true ) /* DEBUG: IRAM */
/* LP0 entry ram segments (addr, size, additional attributes) */ /* LP0 entry ram segments (addr, size, additional attributes) */
#define _MMAPLP0ES0 ( 0x40020000ull, 0x10000ull, MMU_PTE_BLOCK_NS | ATTRIB_MEMTYPE_DEVICE ) /* Encrypted TZRAM */ #define _MMAPLP0ES0 ( 0x40020000ull, 0x10000ull, MMU_PTE_BLOCK_NS | ATTRIB_MEMTYPE_DEVICE ) /* Encrypted TZRAM */
@ -79,7 +80,8 @@
#define MMIO_DEVID_GPIO 15 #define MMIO_DEVID_GPIO 15
#define MMIO_DEVID_DTV_I2C234 16 #define MMIO_DEVID_DTV_I2C234 16
#define MMIO_DEVID_EXCEPTION_VECTORS 17 #define MMIO_DEVID_EXCEPTION_VECTORS 17
#define MMIO_DEVID_MAX 18 #define MMIO_DEVID_DEBUG_IRAM 18
#define MMIO_DEVID_MAX 19
#define LP0_ENTRY_RAM_SEGMENT_ID_ENCRYPTED_TZRAM 0 #define LP0_ENTRY_RAM_SEGMENT_ID_ENCRYPTED_TZRAM 0
#define LP0_ENTRY_RAM_SEGMENT_ID_LP0_ENTRY_CODE 1 #define LP0_ENTRY_RAM_SEGMENT_ID_LP0_ENTRY_CODE 1

View file

@ -18,4 +18,6 @@
#define COLOR_E 0x03000003 #define COLOR_E 0x03000003
#define COLOR_F 0xB6000003 #define COLOR_F 0xB6000003
#define PANIC_REBOOT 0x20
#endif #endif

View file

@ -150,6 +150,8 @@ void clear_priv_smc_in_progress(void) {
uint32_t (*g_smc_callback)(void *, uint64_t) = NULL; uint32_t (*g_smc_callback)(void *, uint64_t) = NULL;
uint64_t g_smc_callback_key = 0; uint64_t g_smc_callback_key = 0;
static _Atomic(int) g_num_smcs_called = 0;
uint64_t try_set_smc_callback(uint32_t (*callback)(void *, uint64_t)) { uint64_t try_set_smc_callback(uint32_t (*callback)(void *, uint64_t)) {
uint64_t key; uint64_t key;
if (g_smc_callback_key) { if (g_smc_callback_key) {
@ -199,6 +201,13 @@ void call_smc_handler(uint32_t handler_id, smc_args_t *args) {
generic_panic(); generic_panic();
} }
int num_called = atomic_fetch_add(&g_num_smcs_called, 1);
/* DEBUG: use num_called to determine panic behavior. */
if (num_called == 0x30) {
/* panic(COLOR_F); */
}
/* Call function. */ /* Call function. */
args->X[0] = smc_handler(args); args->X[0] = smc_handler(args);
(void)result; /* FIXME: result unused */ (void)result; /* FIXME: result unused */

View file

@ -36,3 +36,7 @@ __attribute__((noinline)) bool overlaps(uint64_t as, uint64_t ae, uint64_t bs, u
return true; return true;
return false; return false;
} }
uintptr_t get_iram_address_for_debug(void) {
return MMIO_GET_DEVICE_ADDRESS(MMIO_DEVID_DEBUG_IRAM);
}

View file

@ -57,6 +57,8 @@ __attribute__ ((noreturn)) void generic_panic(void);
__attribute__ ((noreturn)) void panic_predefined(uint32_t which); __attribute__ ((noreturn)) void panic_predefined(uint32_t which);
bool overlaps(uint64_t as, uint64_t ae, uint64_t bs, uint64_t be); bool overlaps(uint64_t as, uint64_t ae, uint64_t bs, uint64_t be);
uintptr_t get_iram_address_for_debug(void);
static inline uintptr_t get_physical_address(const void *vaddr) { static inline uintptr_t get_physical_address(const void *vaddr) {
uintptr_t PAR; uintptr_t PAR;
__asm__ __volatile__ ("at s1e3r, %0" :: "r"(vaddr)); __asm__ __volatile__ ("at s1e3r, %0" :: "r"(vaddr));