1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2010 by Thomas Martitz
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.
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
20 ****************************************************************************/
23 #ifndef __LOAD_CODE_H__
24 #define __LOAD_CODE_H__
28 #if (CONFIG_PLATFORM & PLATFORM_NATIVE)
31 extern void *lc_open(const char *filename
, unsigned char *buf
, size_t buf_size
);
32 /* header is always at the beginning of the blob, and handle actually points
33 * to the start of the blob (the header is there) */
34 static inline void *lc_open_from_mem(void* addr
, size_t blob_size
)
37 /* commit dcache and discard icache */
38 cpucache_invalidate();
41 static inline void *lc_get_header(void *handle
) { return handle
; }
42 /* no need to do anything */
43 static inline void lc_close(void *handle
) { (void)handle
; }
45 #elif (CONFIG_PLATFORM & PLATFORM_HOSTED)
47 /* don't call these directly for loading code
48 * they're to be wrapped by platform specific functions */
50 /* windows' LoadLibrary can only handle ucs2, no utf-8 */
51 #define _lc_open_char wchar_t
53 #define _lc_open_char char
55 extern void *_lc_open(const _lc_open_char
*filename
, unsigned char *buf
, size_t buf_size
);
56 extern void *_lc_get_header(void *handle
);
57 extern void _lc_close(void *handle
);
59 extern void *lc_open(const char *filename
, unsigned char *buf
, size_t buf_size
);
60 extern void *lc_open_from_mem(void *addr
, size_t blob_size
);
61 extern void *lc_get_header(void *handle
);
62 extern void lc_close(void *handle
);
63 extern const char* lc_last_error(void);
66 /* this struct needs to be the first part of other headers
67 * (lc_open() casts the other header to this one to load to the correct
72 unsigned short target_id
;
73 unsigned short api_version
;
74 unsigned char *load_addr
;
75 unsigned char *end_addr
;
78 #endif /* __LOAD_CODE_H__ */