1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19#include <stdint.h>
20
21extern void *offset;
22extern struct cbfs_header *master_header;
23extern uint32_t phys_start, phys_end, align, romsize;
24
25static void *phys_to_virt(uint32_t addr)
26{
27 return offset + addr;
28}
29
30static uint32_t virt_to_phys(void *addr)
31{
32 return (unsigned long)(addr - offset) & 0xffffffff;
33}
34
35#define ALIGN(val, by) (((val) + (by)-1)&~((by)-1))
36
37void *loadfile(const char *filename, uint32_t * romsize_p, void *content,
38 int place);
39void *loadrom(const char *filename);
40void writerom(const char *filename, void *start, uint32_t size);
41
42int iself(unsigned char *input);
43
44typedef void (*comp_func_ptr) (char *, int, char *, int *);
45typedef enum { CBFS_COMPRESS_NONE = 0, CBFS_COMPRESS_LZMA = 1 } comp_algo;
46
47comp_func_ptr compression_function(comp_algo algo);
48
49uint64_t intfiletype(const char *name);
50
51int parse_elf_to_payload(unsigned char *input, unsigned char **output,
52 comp_algo algo);
53int parse_elf_to_stage(unsigned char *input, unsigned char **output,
54 comp_algo algo, uint32_t * location);
55
56void *create_cbfs_file(const char *filename, void *data, uint32_t * datasize,
57 uint32_t type, uint32_t * location);
58
59int create_cbfs_image(const char *romfile, uint32_t romsize,
60 const char *bootblock, uint32_t align);
61
62int add_file_to_cbfs(void *content, uint32_t contentsize, uint32_t location);
63void print_cbfs_directory(const char *filename);
64
65#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
66