summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
authorJens Arnold <amiconn@rockbox.org>2004-08-30 19:52:45 +0000
committerJens Arnold <amiconn@rockbox.org>2004-08-30 19:52:45 +0000
commit06cb237af682fbc45a72c4e43e3f8126b2c9cac6 (patch)
treea0eb1898429941f00da446e1e8c8efdd35864ff9 /apps
parent56fd6f9316ee196bfd16a2f102469cb6b040d397 (diff)
downloadrockbox-06cb237af682fbc45a72c4e43e3f8126b2c9cac6.zip
rockbox-06cb237af682fbc45a72c4e43e3f8126b2c9cac6.tar.gz
rockbox-06cb237af682fbc45a72c4e43e3f8126b2c9cac6.tar.bz2
rockbox-06cb237af682fbc45a72c4e43e3f8126b2c9cac6.tar.xz
New debug feature: Use the SH1 user break controller to catch illegal memory accesses
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@5026 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps')
-rw-r--r--apps/debug_menu.c34
-rw-r--r--apps/plugin.c3
-rw-r--r--apps/plugin.h7
-rw-r--r--apps/plugins/firmware_flash.c4
-rw-r--r--apps/plugins/rockbox_flash.c3
5 files changed, 46 insertions, 5 deletions
diff --git a/apps/debug_menu.c b/apps/debug_menu.c
index 9fd2e33..987007c 100644
--- a/apps/debug_menu.c
+++ b/apps/debug_menu.c
@@ -122,7 +122,7 @@ bool dbg_os(void)
usage = thread_stack_usage(currval);
snprintf(buf, 32, "%d: %d%% ", currval, usage);
lcd_puts(0, 1, buf);
-
+
button = button_get_w_tmo(HZ/10);
switch(button)
@@ -130,7 +130,7 @@ bool dbg_os(void)
case BUTTON_STOP:
return false;
- case BUTTON_LEFT:
+ case BUTTON_LEFT:
currval--;
if(currval < 0)
currval = num_threads-1;
@@ -301,6 +301,7 @@ bool dbg_hw_info(void)
bool got_id; /* flag if we managed to get the flash IDs */
unsigned rom_crc = 0xFFFF; /* CRC16 of the boot ROM */
bool has_bootrom; /* flag for boot ROM present */
+ int oldmode; /* saved memory guard mode */
if(PADR & 0x400)
usb_polarity = 0; /* Negative */
@@ -312,6 +313,8 @@ bool dbg_hw_info(void)
else
pr_polarity = 1; /* Positive */
+ oldmode = system_memory_guard(MEMGUARD_NONE); /* disable memory guard */
+
/* get flash ROM type */
got_id = dbg_flash_id(&manu, &id, 0x5555, 0x2AAA); /* try SST, Atmel, NexFlash */
if (!got_id)
@@ -325,6 +328,8 @@ bool dbg_hw_info(void)
rom_crc = crc_16((unsigned char*)0x0000, 64*1024);
}
+ system_memory_guard(oldmode); /* re-enable memory guard */
+
lcd_setmargins(0, 0);
lcd_setfont(FONT_SYSFIXED);
lcd_clear_display();
@@ -389,12 +394,15 @@ bool dbg_hw_info(void)
bool got_id; /* flag if we managed to get the flash IDs */
unsigned rom_crc = 0xFFFF; /* CRC16 of the boot ROM */
bool has_bootrom; /* flag for boot ROM present */
+ int oldmode; /* saved memory guard mode */
if(PADR & 0x400)
usb_polarity = 0; /* Negative */
else
usb_polarity = 1; /* Positive */
+ oldmode = system_memory_guard(MEMGUARD_NONE); /* disable memory guard */
+
/* get flash ROM type */
got_id = dbg_flash_id(&manu, &id, 0x5555, 0x2AAA); /* try SST, Atmel, NexFlash */
if (!got_id)
@@ -407,6 +415,8 @@ bool dbg_hw_info(void)
/* calculate CRC16 checksum of boot ROM */
rom_crc = crc_16((unsigned char*)0x0000, 64*1024);
}
+
+ system_memory_guard(oldmode); /* re-enable memory guard */
lcd_clear_display();
@@ -579,7 +589,7 @@ bool dbg_ports(void)
snprintf(buf, 32, "ATA: %s, 0x%x",
ata_device?"slave":"master", ata_io_address);
lcd_puts(0, 7, buf);
-
+
lcd_update();
button = button_get_w_tmo(HZ/10);
@@ -1440,6 +1450,7 @@ static bool dbg_disk_info(void)
bool dbg_save_roms(void)
{
int fd;
+ int oldmode = system_memory_guard(MEMGUARD_NONE);
fd = creat("/internal_rom_0000-FFFF.bin", O_WRONLY);
if(fd >= 0)
@@ -1455,6 +1466,7 @@ bool dbg_save_roms(void)
close(fd);
}
+ system_memory_guard(oldmode);
return false;
}
@@ -1510,6 +1522,21 @@ bool dbg_screendump(void)
}
#endif
+bool dbg_set_memory_guard(void)
+{
+ static const struct opt_items names[MAXMEMGUARD] = {
+ { "None", -1 },
+ { "Flash ROM writes", -1 },
+ { "Zero area (all)", -1 }
+ };
+ int mode = system_memory_guard(MEMGUARD_KEEP);
+
+ set_option( "Catch mem accesses", &mode, INT, names, MAXMEMGUARD, NULL);
+ system_memory_guard(mode);
+
+ return false;
+}
+
bool debug_menu(void)
{
int m;
@@ -1524,6 +1551,7 @@ bool debug_menu(void)
#endif /* HAVE_RTC */
#endif /* HAVE_LCD_BITMAP */
{ "View OS stacks", dbg_os },
+ { "Catch mem accesses", dbg_set_memory_guard },
#ifdef HAVE_MAS3507D
{ "View MAS info", dbg_mas_info },
#endif
diff --git a/apps/plugin.c b/apps/plugin.c
index a7ae34f..6892cb9 100644
--- a/apps/plugin.c
+++ b/apps/plugin.c
@@ -259,6 +259,9 @@ static const struct plugin_api rockbox_api = {
mpeg_get_file_pos,
find_next_frame,
mpeg_get_last_header,
+#ifndef SIMULATOR
+ system_memory_guard,
+#endif
};
int plugin_load(const char* plugin, void* parameter)
diff --git a/apps/plugin.h b/apps/plugin.h
index 43f8b89..078dc12 100644
--- a/apps/plugin.h
+++ b/apps/plugin.h
@@ -51,7 +51,7 @@
#ifdef PLUGIN
#if defined(DEBUG) || defined(SIMULATOR)
-#define DEBUGF rb->debugf
+#define DEBUGF rb->debugf
#define LDEBUGF rb->debugf
#else
#define DEBUGF(...)
@@ -60,7 +60,7 @@
#endif
/* increase this every time the api struct changes */
-#define PLUGIN_API_VERSION 26
+#define PLUGIN_API_VERSION 27
/* update this to latest version if a change to the api struct breaks
backwards compatibility (and please take the opportunity to sort in any
@@ -295,6 +295,9 @@ struct plugin_api {
unsigned long (*find_next_frame)(int fd, int *offset,
int max_offset, unsigned long last_header);
unsigned long (*mpeg_get_last_header)(void);
+#ifndef SIMULATOR
+ int (*system_memory_guard)(int newmode);
+#endif
};
/* defined by the plugin loader (plugin.c) */
diff --git a/apps/plugins/firmware_flash.c b/apps/plugins/firmware_flash.c
index 8f7f187..751284a 100644
--- a/apps/plugins/firmware_flash.c
+++ b/apps/plugins/firmware_flash.c
@@ -1010,6 +1010,8 @@ void DoUserDialog(char* filename)
enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
{
+ int oldmode;
+
/* this macro should be called as the first thing you do in the plugin.
it test that the api version and model the plugin was compiled for
matches the machine it is running on */
@@ -1018,7 +1020,9 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
rb = api; /* copy to global api pointer */
/* now go ahead and have fun! */
+ oldmode = rb->system_memory_guard(MEMGUARD_NONE); /*disable memory guard */
DoUserDialog((char*) parameter);
+ rb->system_memory_guard(oldmode); /* re-enable memory guard */
return PLUGIN_OK;
}
diff --git a/apps/plugins/rockbox_flash.c b/apps/plugins/rockbox_flash.c
index 3bb8476..e393f20 100644
--- a/apps/plugins/rockbox_flash.c
+++ b/apps/plugins/rockbox_flash.c
@@ -977,6 +977,7 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
{
char* filename;
bool show_greet;
+ int oldmode;
/* this macro should be called as the first thing you do in the plugin.
it test that the api version and model the plugin was compiled for
@@ -997,7 +998,9 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
rb = api; /* copy to global api pointer */
/* now go ahead and have fun! */
+ oldmode = rb->system_memory_guard(MEMGUARD_NONE); /*disable memory guard */
DoUserDialog(filename, show_greet);
+ rb->system_memory_guard(oldmode); /* re-enable memory guard */
return PLUGIN_OK;
}