1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
* $Id$
*
* Copyright (C) 2005 Jens Arnold
*
* Overlay loader for rockboy on Archos
*
* All files in this archive are subject to the GNU General Public License.
* See the file COPYING in the source tree root for full license agreement.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
****************************************************************************/
#include "plugin.h"
#if MEM <= 8 && !defined(SIMULATOR)
#define OVL_NAME "/.rockbox/viewers/rockboy.ovl"
#define OVL_DISPLAYNAME "RockBoy"
struct plugin_api* rb;
unsigned char *audiobuf;
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;
/* 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 */
TEST_PLUGIN_API(api);
rb = api;
fh = rb->open(OVL_NAME, O_RDONLY);
if (fh < 0)
{
rb->splash(2*HZ, true, "Couldn't open " OVL_DISPLAYNAME " overlay.");
return PLUGIN_ERROR;
}
readsize = rb->read(fh, &header, sizeof(header));
if (readsize != sizeof(header) || header.magic != 0x524f564c)
{
rb->close(fh);
rb->splash(2*HZ, true, OVL_NAME " is not a valid Rockbox overlay.");
return PLUGIN_ERROR;
}
audiobuf = rb->plugin_get_audio_buffer(&audiobuf_size);
if (header.start_addr < audiobuf ||
header.end_addr > audiobuf + audiobuf_size)
{
rb->close(fh);
rb->splash(2*HZ, true, OVL_DISPLAYNAME
" overlay doesn't fit into memory.");
return PLUGIN_ERROR;
}
rb->lseek(fh, 0, SEEK_SET);
readsize = rb->read(fh, header.start_addr, header.end_addr - header.start_addr);
rb->close(fh);
if (readsize != header.end_addr - header.start_addr)
{
rb->splash(2*HZ, true, "Error loading " OVL_DISPLAYNAME " overlay.");
return PLUGIN_ERROR;
}
return header.entry_point(api, parameter);
}
#endif
|