summaryrefslogtreecommitdiff
path: root/apps/plugins/rockboy.c
diff options
context:
space:
mode:
authorJens Arnold <amiconn@rockbox.org>2006-01-16 18:51:12 +0000
committerJens Arnold <amiconn@rockbox.org>2006-01-16 18:51:12 +0000
commitffb0cdc4263c5c5f4b13fd7514533f4d17fa2a3b (patch)
tree26ded3a09271a2c2df73889e2761cf80c77f5237 /apps/plugins/rockboy.c
parentb1a17a624645522d751e6d313a5ceebc0649d49d (diff)
downloadrockbox-ffb0cdc4263c5c5f4b13fd7514533f4d17fa2a3b.zip
rockbox-ffb0cdc4263c5c5f4b13fd7514533f4d17fa2a3b.tar.gz
rockbox-ffb0cdc4263c5c5f4b13fd7514533f4d17fa2a3b.tar.bz2
rockbox-ffb0cdc4263c5c5f4b13fd7514533f4d17fa2a3b.tar.xz
Archos recorders: The Rockboy overlay loader now uses the same header as the plugin loader.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@8354 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/plugins/rockboy.c')
-rw-r--r--apps/plugins/rockboy.c63
1 files changed, 39 insertions, 24 deletions
diff --git a/apps/plugins/rockboy.c b/apps/plugins/rockboy.c
index d350457..f571894 100644
--- a/apps/plugins/rockboy.c
+++ b/apps/plugins/rockboy.c
@@ -34,47 +34,62 @@ int audiobuf_size;
/* this is the plugin entry point */
enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
{
- int fh, readsize;
- struct {
- unsigned long magic;
- unsigned char *start_addr;
- unsigned char *end_addr;
- enum plugin_status(*entry_point)(struct plugin_api*, void*);
- } header;
+ int fd, readsize;
+ struct plugin_header header;
rb = api;
- fh = rb->open(OVL_NAME, O_RDONLY);
- if (fh < 0)
+ fd = rb->open(OVL_NAME, O_RDONLY);
+ if (fd < 0)
{
- rb->splash(2*HZ, true, "Couldn't open " OVL_DISPLAYNAME " overlay.");
+ rb->splash(2*HZ, true, "Can't open " OVL_NAME);
return PLUGIN_ERROR;
}
- readsize = rb->read(fh, &header, sizeof(header));
- if (readsize != sizeof(header) || header.magic != 0x524f564c)
+ readsize = rb->read(fd, &header, sizeof(header));
+ rb->close(fd);
+ /* Close for now. Less code than doing it in all error checks.
+ * Would need to seek back anyway. */
+
+ if (readsize != sizeof(header))
{
- rb->close(fh);
- rb->splash(2*HZ, true, OVL_NAME " is not a valid Rockbox overlay.");
+ rb->splash(2*HZ, true, "Reading" OVL_DISPLAYNAME " overlay failed.");
return PLUGIN_ERROR;
}
-
+ if (header.magic != PLUGIN_MAGIC || header.target_id != TARGET_ID)
+ {
+ rb->splash(2*HZ, true, OVL_DISPLAYNAME
+ " overlay: Incompatible model.");
+ return PLUGIN_ERROR;
+ }
+ if (header.api_version != PLUGIN_API_VERSION)
+ {
+ rb->splash(2*HZ, true, OVL_DISPLAYNAME
+ " overlay: Incompatible version.");
+ return PLUGIN_ERROR;
+ }
+
audiobuf = rb->plugin_get_audio_buffer(&audiobuf_size);
- if (header.start_addr < audiobuf ||
+ if (header.load_addr < audiobuf ||
header.end_addr > audiobuf + audiobuf_size)
{
- rb->close(fh);
rb->splash(2*HZ, true, OVL_DISPLAYNAME
- " overlay doesn't fit into memory.");
+ " overlay doesn't fit into memory.");
+ return PLUGIN_ERROR;
+ }
+ rb->memset(header.load_addr, 0, header.end_addr - header.load_addr);
+
+ fd = rb->open(OVL_NAME, O_RDONLY);
+ if (fd < 0)
+ {
+ rb->splash(2*HZ, true, "Can't open " OVL_NAME);
return PLUGIN_ERROR;
}
- rb->memset(header.start_addr, 0, header.end_addr - header.start_addr);
+ readsize = rb->read(fd, header.load_addr, header.end_addr - header.load_addr);
+ rb->close(fd);
- rb->lseek(fh, 0, SEEK_SET);
- readsize = rb->read(fh, header.start_addr, header.end_addr - header.start_addr);
- rb->close(fh);
- if (readsize <= (int)sizeof(header))
+ if (readsize < 0)
{
- rb->splash(2*HZ, true, "Error loading " OVL_DISPLAYNAME " overlay.");
+ rb->splash(2*HZ, true, "Reading" OVL_DISPLAYNAME " overlay failed.");
return PLUGIN_ERROR;
}
return header.entry_point(api, parameter);