diff --git a/arch/x86/stage1.c b/arch/x86/stage1.c index da7976b756..4f9b2b16a0 100644 --- a/arch/x86/stage1.c +++ b/arch/x86/stage1.c @@ -50,7 +50,21 @@ static void enable_rom(void) post_code(POST_STAGE1_ENABLE_ROM); } +void init_archive(struct mem_file *archive) +{ + // FIXME this should be defined in the VPD area + // but NOT IN THE CODE. + /* The len field starts behind the reset vector on x86. + * The start is not correct for all platforms. sc520 will + * need some hands on here. + */ + archive->len = *(u32 *)0xfffffff4; + archive->start =(void *)(0UL-archive->len); + + // FIXME check integrity + +} /* until we get rid of elf */ int legacy(struct mem_file *archive, char *name, void *where, struct lb_memory *mem) { @@ -121,18 +135,7 @@ void __attribute__((stdcall)) stage1_main(u32 bist) // location and size of image. - // FIXME this should be defined in the VPD area - // but NOT IN THE CODE. - - /* The len field starts behind the reset vector on x86. - * The start is not correct for all platforms. sc520 will - * need some hands on here. - */ - archive.len = *(u32 *)0xfffffff4; - archive.start =(void *)(0UL-archive.len); - - // FIXME check integrity - + init_archive(&archive); // find first initram if (check_normal_boot_flag()) { diff --git a/include/lar.h b/include/lar.h index 84f00aaf8f..f167d9036a 100644 --- a/include/lar.h +++ b/include/lar.h @@ -51,6 +51,7 @@ #define LAR_H #include +#include #define MAGIC "LARCHIVE" #define MAX_PATHLEN 1024 @@ -82,11 +83,15 @@ struct mem_file { }; /* Prototypes. */ -int find_file(const struct mem_file *archive, const char *filename, struct mem_file *result); -int copy_file(const struct mem_file *archive, const char *filename, void *where); -int run_file(const struct mem_file *archive, const char *filename, void *where); -int execute_in_place(const struct mem_file *archive, const char *filename); -int run_address(void *f); -void *load_file(const struct mem_file *archive, const char *filename); -void *load_file_segments(const struct mem_file *archive, const char *filename); +/* architecture-defined */ +SHARED(init_archive, void, struct mem_file *); +/* architecture-independent */ +SHARED(find_file, int, const struct mem_file *archive, const char *filename, struct mem_file *result); +SHARED(copy_file, int, const struct mem_file *archive, const char *filename, void *where); +SHARED(run_file, int, const struct mem_file *archive, const char *filename, void *where); +SHARED(execute_in_place, int, const struct mem_file *archive, const char *filename); +SHARED(run_address, int, void *f); +SHARED(load_file, void *, const struct mem_file *archive, const char *filename); +SHARED(load_file_segments, void *, const struct mem_file *archive, const char *filename); +SHARED(process_file, int, const struct mem_file *archive, void *where); #endif /* LAR_H */ diff --git a/lib/lar.c b/lib/lar.c index 9051f62959..8cf593bbe7 100644 --- a/lib/lar.c +++ b/lib/lar.c @@ -145,7 +145,7 @@ int find_file(const struct mem_file *archive, const char *filename, struct mem_f return 1; } -static int process_file(const struct mem_file *archive, void *where) +int process_file(const struct mem_file *archive, void *where) { printk(BIOS_SPEW, "LAR: Compression algorithm #%i used\n", archive->compression); /* no compression */ diff --git a/northbridge/amd/geodelx/vsmsetup.c b/northbridge/amd/geodelx/vsmsetup.c index 9edbbbc1f2..ac85720575 100644 --- a/northbridge/amd/geodelx/vsmsetup.c +++ b/northbridge/amd/geodelx/vsmsetup.c @@ -29,6 +29,7 @@ #include #include #include +#include #define VSA2_BUFFER 0x60000 #define VSA2_ENTRY_POINT 0x60020 @@ -169,25 +170,30 @@ u32 VSA_msrRead(u32 msrAddr) void do_vsmbios(void *bios) { - struct device *dev; - unsigned long busdevfn; - unsigned int rom = 0; unsigned char *buf; - unsigned int size = SMM_SIZE * 1024; int i; - unsigned long ilen, olen; + struct mem_file archive; + struct mem_file file; printk(BIOS_ERR, "do_vsmbios\n"); /* clear vsm bios data area */ for (i = 0x400; i < 0x500; i++) { *(volatile unsigned char *)i = 0; } + init_archive(&archive); + + if (find_file(&archive, "/blob/vsa", &file)){ + printk(BIOS_ERR, "NO VSA found!\n"); + return; + } + + if (process_file(&file, (void *)VSA2_BUFFER)) { + printk(BIOS_ERR, "Processing /blob/vsa failed\n"); + return; + } - rom = (unsigned long) bios; buf = (unsigned char *)VSA2_BUFFER; - // FIXME - //olen = unrv2b((u8 *) rom, buf, &ilen); - printk(BIOS_DEBUG, "buf ilen %d olen%d\n", ilen, olen); + printk(BIOS_DEBUG, "buf ilen %d real len %uld\n", file.len, file.reallen); printk(BIOS_DEBUG, "buf %p *buf %d buf[256k] %d\n", buf, buf[0], buf[SMM_SIZE * 1024]); printk(BIOS_DEBUG, "buf[0x20] signature is %x:%x:%x:%x\n", @@ -253,16 +259,16 @@ static int biosint(unsigned long intnumber, eax, ebx, ecx, edx); printk(BIOS_DEBUG, "biosint: ebp 0x%lx esp 0x%lx edi 0x%lx esi 0x%lx\n", ebp, esp, edi, esi); - printk(BIOS_DEBUG, "biosint: ip 0x%x cs 0x%x flags 0x%x\n", + printk(BIOS_DEBUG, "biosint: ip 0x%lx cs 0x%lx flags 0x%lx\n", ip, cs, flags); - printk(BIOS_DEBUG, "biosint: gs 0x%x fs 0x%x ds 0x%x es 0x%x\n", + printk(BIOS_DEBUG, "biosint: gs 0x%lx fs 0x%lx ds 0x%lx es 0x%lx\n", gsfs >> 16, gsfs & 0xffff, dses >> 16, dses & 0xffff); // cases in a good compiler are just as good as your own tables. switch (intnumber) { case 0 ... 15: // These are not BIOS service, but the CPU-generated exceptions - printk(BIOS_INFO, "biosint: Oops, exception %u\n", intnumber); + printk(BIOS_INFO, "biosint: Oops, exception %lu\n", intnumber); if (esp < 0x1000) { printk(BIOS_DEBUG, "Stack contents: "); while (esp < 0x1000) { @@ -290,7 +296,7 @@ static int biosint(unsigned long intnumber, &ebx, &edx, &ecx, &eax, &flags); break; default: - printk(BIOS_INFO, "BIOSINT: Unsupport int #0x%x\n", intnumber); + printk(BIOS_INFO, "BIOSINT: Unsupport int #0x%lx\n", intnumber); break; } if (ret)