#include "mptable.h" // MPTABLE_SIGNATURE
#include "biosvar.h" // GET_EBDA
#include "lzmadecode.h" // LzmaDecode
+#include "smbios.h" // smbios_init
/****************************************************************
// Populate max ram and e820 map info by scanning for a coreboot table.
static void
-coreboot_fill_map()
+coreboot_fill_map(void)
{
dprintf(3, "Attempting to find coreboot table\n");
}
void
-coreboot_copy_biostable()
+coreboot_copy_biostable(void)
{
struct cb_memory *cbm = CBMemTable;
if (! CONFIG_COREBOOT || !cbm)
* Coreboot flash format
****************************************************************/
-// XXX - optimize
-#define ntohl(x) ((((x)&0xff)<<24) | (((x)&0xff00)<<8) | \
- (((x)&0xff0000) >> 8) | (((x)&0xff000000) >> 24))
-#define htonl(x) ntohl(x)
-
#define CBFS_HEADER_MAGIC 0x4F524243
#define CBFS_HEADPTR_ADDR 0xFFFFFFFc
#define CBFS_VERSION1 0x31313131
static struct cbfs_header *CBHDR;
static void
-cbfs_setup()
+cbfs_setup(void)
{
if (! CONFIG_COREBOOT_FLASH)
return;
// Return the first file in the CBFS archive
static struct cbfs_file *
-cbfs_getfirst()
+cbfs_getfirst(void)
{
if (! CBHDR)
return NULL;
return NULL;
}
+// Find next file with the given filename prefix.
struct cbfs_file *
cbfs_findprefix(const char *prefix, struct cbfs_file *last)
{
u32 size = ntohl(file->len);
void *src = (void*)file + ntohl(file->offset);
- if (cbfs_iscomp(file))
- // Compressed.
- return ulzma(dst, maxlen, src, size);
+ if (cbfs_iscomp(file)) {
+ // Compressed - copy to temp ram and uncompress it.
+ u32 asize = ALIGN(size, 4);
+ void *temp = malloc_tmphigh(asize);
+ if (!temp)
+ return -1;
+ iomemcpy(temp, src, asize);
+ int ret = ulzma(dst, maxlen, temp, size);
+ yield();
+ free(temp);
+ return ret;
+ }
// Not compressed.
dprintf(3, "Copying data %d@%p to %d@%p\n", size, src, maxlen, dst);
dprintf(1, "File too big to copy\n");
return -1;
}
- memcpy(dst, src, size);
+ iomemcpy(dst, src, size);
return size;
}
-static char
-getHex(u8 x)
-{
- if (x <= 9)
- return '0' + x;
- return 'a' + x - 10;
-}
-
-static u32
-hexify4(u16 x)
-{
- return ((getHex(x&0xf) << 24)
- | (getHex((x>>4)&0xf) << 16)
- | (getHex((x>>8)&0xf) << 8)
- | (getHex(x>>12)));
-}
-
// Find and copy the optionrom for the given vendor/device id.
int
cbfs_copy_optionrom(void *dst, u32 maxlen, u32 vendev)
return -1;
char fname[17];
- // Ughh - poor man's sprintf of "pci%04x,%04x.rom"
- *(u32*)fname = 0x20696370; // "pci "
- *(u32*)&fname[3] = hexify4(vendev);
- fname[7] = ',';
- *(u32*)&fname[8] = hexify4(vendev >> 16);
- *(u32*)&fname[12] = 0x6d6f722e; // ".rom"
- fname[16] = '\0';
-
+ snprintf(fname, sizeof(fname), "pci%04x,%04x.rom"
+ , (u16)vendev, vendev >> 16);
return cbfs_copyfile(cbfs_finddatafile(fname), dst, maxlen);
}