From 681ec27e2c64763bba02ef816d41b6b366559f03 Mon Sep 17 00:00:00 2001 From: Jordan Crouse Date: Wed, 7 May 2008 20:34:02 +0000 Subject: libpayload: Add LAR walking support Add suport for walking LARs. These try to emulate the f* functions from POSIX, though they are obviously different in their behavior. Signed-off-by: Jordan Crouse Acked-by: Myles Watson git-svn-id: svn://svn.coreboot.org/coreboot/trunk@3288 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1 --- payloads/libpayload/include/libpayload.h | 50 ++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) (limited to 'payloads/libpayload/include/libpayload.h') diff --git a/payloads/libpayload/include/libpayload.h b/payloads/libpayload/include/libpayload.h index 5bafb305ef..be4d2a7ba3 100644 --- a/payloads/libpayload/include/libpayload.h +++ b/payloads/libpayload/include/libpayload.h @@ -36,6 +36,7 @@ #include #include #include +#include #define MIN(a,b) ((a) < (b) ? (a) : (b)) #define MAX(a,b) ((a) > (b) ? (a) : (b)) @@ -207,6 +208,55 @@ struct timeval { int gettimeofday(struct timeval *tv, void *tz); +/* libc/lar.c */ + +struct LAR { + void * start; + int cindex; + int count; + int alloc; + int eof; + void **headers; +}; + +struct larent { + u8 name[LAR_MAX_PATHLEN]; +}; + +struct larstat { + u32 len; + u32 reallen; + u32 checksum; + u32 compchecksum; + u32 offset; + u32 compression; + u64 entry; + u64 loadaddress; +}; + +struct LFILE { + struct LAR *lar; + struct lar_header *header; + u32 size; + void *start; + u32 offset; +}; + +struct LAR *openlar(void *addr); +int closelar(struct LAR *lar); +struct larent *readlar(struct LAR *lar); +void rewindlar(struct LAR *lar); +int larstat(struct LAR *lar, const char *path, struct larstat *buf); +struct LFILE * lfopen(struct LAR *lar, const char *filename); +int lfread(void *ptr, size_t size, size_t nmemb, struct LFILE *stream); + +#define SEEK_SET 0 +#define SEEK_CUR 1 +#define SEEK_END 2 + +int lfseek(struct LFILE *stream, long offset, int whence); +int lfclose(struct LFILE *file); + /* i386/coreboot.c */ int get_coreboot_info(struct sysinfo_t *info); -- cgit v1.2.3