diff options
Diffstat (limited to 'firmware/export')
-rw-r--r-- | firmware/export/load_code.h | 27 |
1 files changed, 22 insertions, 5 deletions
diff --git a/firmware/export/load_code.h b/firmware/export/load_code.h index 6f5e5d0842..55ce601ee5 100644 --- a/firmware/export/load_code.h +++ b/firmware/export/load_code.h | |||
@@ -20,17 +20,21 @@ | |||
20 | ****************************************************************************/ | 20 | ****************************************************************************/ |
21 | 21 | ||
22 | 22 | ||
23 | #ifndef __LOAD_CODE_H__ | ||
24 | #define __LOAD_CODE_H__ | ||
25 | |||
23 | #include "config.h" | 26 | #include "config.h" |
24 | 27 | ||
25 | #if (CONFIG_PLATFORM & PLATFORM_NATIVE) | 28 | #if (CONFIG_PLATFORM & PLATFORM_NATIVE) |
26 | #include "system.h" | 29 | #include "system.h" |
27 | 30 | ||
28 | extern void *lc_open(const char *filename, char *buf, size_t buf_size); | 31 | extern void *lc_open(const char *filename, unsigned char *buf, size_t buf_size); |
29 | /* header is always at the beginning of the blob, and handle actually points | 32 | /* header is always at the beginning of the blob, and handle actually points |
30 | * to the start of the blob */ | 33 | * to the start of the blob (the header is there) */ |
31 | static inline void *lc_open_from_mem(void* addr, size_t blob_size) | 34 | static inline void *lc_open_from_mem(void* addr, size_t blob_size) |
32 | { | 35 | { |
33 | (void)blob_size; | 36 | (void)blob_size; |
37 | /* commit dcache and discard icache */ | ||
34 | cpucache_invalidate(); | 38 | cpucache_invalidate(); |
35 | return addr; | 39 | return addr; |
36 | } | 40 | } |
@@ -48,14 +52,27 @@ static inline void lc_close(void *handle) { (void)handle; } | |||
48 | #else | 52 | #else |
49 | #define _lc_open_char char | 53 | #define _lc_open_char char |
50 | #endif | 54 | #endif |
51 | extern void *_lc_open(const _lc_open_char *filename, char *buf, size_t buf_size); | 55 | extern void *_lc_open(const _lc_open_char *filename, unsigned char *buf, size_t buf_size); |
52 | extern void *_lc_get_header(void *handle); | 56 | extern void *_lc_get_header(void *handle); |
53 | extern void _lc_close(void *handle); | 57 | extern void _lc_close(void *handle); |
54 | 58 | ||
55 | extern void *lc_open(const char *filename, char *buf, size_t buf_size); | 59 | extern void *lc_open(const char *filename, unsigned char *buf, size_t buf_size); |
56 | /* not possiible on hosted platforms */ | ||
57 | extern void *lc_open_from_mem(void *addr, size_t blob_size); | 60 | extern void *lc_open_from_mem(void *addr, size_t blob_size); |
58 | extern void *lc_get_header(void *handle); | 61 | extern void *lc_get_header(void *handle); |
59 | extern void lc_close(void *handle); | 62 | extern void lc_close(void *handle); |
60 | extern const char* lc_last_error(void); | 63 | extern const char* lc_last_error(void); |
61 | #endif | 64 | #endif |
65 | |||
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 | ||
68 | * address) | ||
69 | */ | ||
70 | struct lc_header { | ||
71 | unsigned long magic; | ||
72 | unsigned short target_id; | ||
73 | unsigned short api_version; | ||
74 | unsigned char *load_addr; | ||
75 | unsigned char *end_addr; | ||
76 | }; | ||
77 | |||
78 | #endif /* __LOAD_CODE_H__ */ | ||