A modern Music Player Daemon based on Rockbox open source high quality audio player
libadwaita
audio
rust
zig
deno
mpris
rockbox
mpd
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2010 by Thomas Martitz
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21
22
23#ifndef __LOAD_CODE_H__
24#define __LOAD_CODE_H__
25
26#include "config.h"
27
28extern void *lc_open(const char *filename, unsigned char *buf, size_t buf_size);
29
30#if (CONFIG_PLATFORM & PLATFORM_NATIVE)
31#include "system.h"
32
33/* header is always at the beginning of the blob, and handle actually points
34 * to the start of the blob (the header is there) */
35static inline void *lc_open_from_mem(void* addr, size_t blob_size)
36{
37 (void)blob_size;
38 /* commit dcache and discard icache */
39 commit_discard_idcache();
40 return addr;
41}
42static inline void *lc_get_header(void *handle) { return handle; }
43/* no need to do anything */
44static inline void lc_close(void *handle) { (void)handle; }
45
46#elif (CONFIG_PLATFORM & PLATFORM_HOSTED)
47
48#ifdef APPLICATION
49/* App doesn't simulate code loading from a buffer */
50static inline void * lc_open_from_mem(void *addr, size_t blob_size)
51{
52 return NULL;
53 (void)addr; (void)blob_size;
54}
55#else
56extern void *lc_open_from_mem(void* addr, size_t blob_size);
57#endif
58
59extern void *lc_get_header(void *handle);
60extern void lc_close(void *handle);
61
62#endif
63
64/* this struct needs to be the first part of other headers
65 * (lc_open() casts the other header to this one to load to the correct
66 * address)
67 */
68struct lc_header {
69 unsigned long magic;
70 unsigned short target_id;
71 unsigned short api_version;
72 unsigned char *load_addr;
73 unsigned char *end_addr;
74};
75
76#endif /* __LOAD_CODE_H__ */