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 <jordan.crouse@amd.com>
Acked-by: Myles Watson <mylesgw@gmail.com>


git-svn-id: svn://svn.coreboot.org/coreboot/trunk@3288 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1
This commit is contained in:
Jordan Crouse
2008-05-07 20:34:02 +00:00
parent 35993a231e
commit 681ec27e2c
5 changed files with 492 additions and 1 deletions

View File

@ -36,6 +36,7 @@
#include <arch/io.h>
#include <sysinfo.h>
#include <stdarg.h>
#include <lar.h>
#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);