libpayload: Add larfptr function
[coreboot.git] / payloads / libpayload / include / libpayload.h
index d557eeff697a65d8de7bf37435c2d83a658bac65..8535bd04fa74abfe7564da39abdded9c0439f5e2 100644 (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))
 #define NVRAM_RTC_DAY            7
 #define NVRAM_RTC_MONTH          8
 #define NVRAM_RTC_YEAR           9
+#define NVRAM_RTC_FREQ_SELECT    10
+#define  NVRAM_RTC_UIP           0x80
+
+struct tm {
+       int tm_sec;
+       int tm_min;
+       int tm_hour;
+       int tm_mday;
+       int tm_mon;
+       int tm_year;
+       int tm_wday;
+       int tm_yday;
+       int tm_isdst;
+};
 
 /* drivers/nvram.c */
 u8 nvram_read(u8 addr);
 void nvram_write(u8 val, u8 addr);
+int nvram_updating(void);
+void rtc_read_clock(struct tm *tm);
 
 /* drivers/keyboard.c */
 void keyboard_init(void);
@@ -182,6 +199,65 @@ char *strchr(const char *s, int c);
 char *strdup(const char *s);
 char *strstr(const char *h, const char *n);
 
+/* libc/time.c */
+
+struct timeval {
+       time_t tv_sec;
+       suseconds_t tv_usec;
+};
+
+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);
+void *larfptr(struct LAR *lar, const char *filename);
+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);