diff options
Diffstat (limited to 'apps/plugins/rockboy.c')
-rw-r--r-- | apps/plugins/rockboy.c | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/apps/plugins/rockboy.c b/apps/plugins/rockboy.c new file mode 100644 index 0000000000..4778fa8ee6 --- /dev/null +++ b/apps/plugins/rockboy.c | |||
@@ -0,0 +1,81 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2005 Jens Arnold | ||
11 | * | ||
12 | * Overlay loader for rockboy on Archos | ||
13 | * | ||
14 | * All files in this archive are subject to the GNU General Public License. | ||
15 | * See the file COPYING in the source tree root for full license agreement. | ||
16 | * | ||
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
18 | * KIND, either express or implied. | ||
19 | * | ||
20 | ****************************************************************************/ | ||
21 | #include "plugin.h" | ||
22 | |||
23 | #if MEM <= 8 && !defined(SIMULATOR) | ||
24 | |||
25 | #define OVL_NAME "/.rockbox/viewers/rockboy.ovl" | ||
26 | #define OVL_DISPLAYNAME "RockBoy" | ||
27 | |||
28 | struct plugin_api* rb; | ||
29 | unsigned char *mp3buf; | ||
30 | int mp3buf_size; | ||
31 | |||
32 | /* this is the plugin entry point */ | ||
33 | enum plugin_status plugin_start(struct plugin_api* api, void* parameter) | ||
34 | { | ||
35 | int fh, readsize; | ||
36 | struct { | ||
37 | unsigned long magic; | ||
38 | unsigned char *start_addr; | ||
39 | unsigned char *end_addr; | ||
40 | enum plugin_status(*entry_point)(struct plugin_api*, void*); | ||
41 | } header; | ||
42 | |||
43 | /* this macro should be called as the first thing you do in the plugin. | ||
44 | it test that the api version and model the plugin was compiled for | ||
45 | matches the machine it is running on */ | ||
46 | TEST_PLUGIN_API(api); | ||
47 | rb = api; | ||
48 | |||
49 | fh = rb->open(OVL_NAME, O_RDONLY); | ||
50 | if (fh < 0) | ||
51 | { | ||
52 | rb->splash(2*HZ, true, "Couldn't open " OVL_DISPLAYNAME " overlay."); | ||
53 | return PLUGIN_ERROR; | ||
54 | } | ||
55 | readsize = rb->read(fh, &header, sizeof(header)); | ||
56 | if (readsize != sizeof(header) || header.magic != 0x524f564c) | ||
57 | { | ||
58 | rb->close(fh); | ||
59 | rb->splash(2*HZ, true, OVL_NAME " is not a valid Rockbox overlay."); | ||
60 | return PLUGIN_ERROR; | ||
61 | } | ||
62 | |||
63 | mp3buf = rb->plugin_get_mp3_buffer(&mp3buf_size); | ||
64 | if (header.start_addr < mp3buf || header.end_addr > mp3buf + mp3buf_size) | ||
65 | { | ||
66 | rb->close(fh); | ||
67 | rb->splash(2*HZ, true, OVL_DISPLAYNAME | ||
68 | " overlay doesn't fit into memory."); | ||
69 | return PLUGIN_ERROR; | ||
70 | } | ||
71 | rb->lseek(fh, 0, SEEK_SET); | ||
72 | readsize = rb->read(fh, header.start_addr, header.end_addr - header.start_addr); | ||
73 | rb->close(fh); | ||
74 | if (readsize != header.end_addr - header.start_addr) | ||
75 | { | ||
76 | rb->splash(2*HZ, true, "Error loading " OVL_DISPLAYNAME " overlay."); | ||
77 | return PLUGIN_ERROR; | ||
78 | } | ||
79 | return header.entry_point(api, parameter); | ||
80 | } | ||
81 | #endif | ||