*/
#include <stdint.h>
+#include "swab.h"
+#define ntohl(x) (host_bigendian?(x):swab32(x))
+#define htonl(x) (host_bigendian?(x):swab32(x))
+#define ntohll(x) (host_bigendian?(x):swab64(x))
+#define htonll(x) (host_bigendian?(x):swab64(x))
extern void *offset;
extern struct cbfs_header *master_header;
extern uint32_t phys_start, phys_end, align, romsize;
+extern int host_bigendian;
-static void *phys_to_virt(uint32_t addr)
+static inline void *phys_to_virt(uint32_t addr)
{
return offset + addr;
}
-static uint32_t virt_to_phys(void *addr)
+static inline uint32_t virt_to_phys(void *addr)
{
- return (long)(addr - offset) & 0xffffffff;
+ return (unsigned long)(addr - offset) & 0xffffffff;
}
#define ALIGN(val, by) (((val) + (by)-1)&~((by)-1))
+uint32_t getfilesize(const char *filename);
void *loadfile(const char *filename, uint32_t * romsize_p, void *content,
int place);
void *loadrom(const char *filename);
-void writerom(const char *filename, void *start, uint32_t size);
+int writerom(const char *filename, void *start, uint32_t size);
int iself(unsigned char *input);
int add_file_to_cbfs(void *content, uint32_t contentsize, uint32_t location);
void print_cbfs_directory(const char *filename);
+int extract_file_from_cbfs(const char *filename, const char *payloadname, const char *outpath);
+
+uint32_t cbfs_find_location(const char *romfile, uint32_t filesize,
+ const char *filename, uint32_t align);
+
+void print_supported_filetypes(void);
+
+#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))