[coreboot] Embedding VSA in a LAR

Carl-Daniel Hailfinger c-d.hailfinger.devel.2006 at gmx.net
Wed Jan 23 02:33:02 CET 2008


Besides the obvious stuff (storing the VSA as a file in the LAR) there
are two points to solve which are rather interesting:
- Entry point specification
- Load address specification
Both are not trivial because we get both specifications above from an
ELF header. The VSA is not an ELF file, so we have to specify entry
point and load address by hand.

The following patch allows us to specify LAR entries like
"entry=33:blobs/vsa" which then have entry point addr 33.
This can be extended to a loadaddr= parameter.

Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006 at gmx.net>

Index: LinuxBIOSv3-laroptions/util/lar/lib.c
===================================================================
--- LinuxBIOSv3-laroptions/util/lar/lib.c	(Revision 559)
+++ LinuxBIOSv3-laroptions/util/lar/lib.c	(Arbeitskopie)
@@ -207,8 +207,10 @@
 	char *realname;
 	char *c;
 
-	if (strstr(name, "nocompress:") == name) {
-		realname = strdup(name + 11);
+	printf("add_files called for %s\n", name);
+	/* search backwards to find the last option delimiter */
+	if (strrchr(name, ':')) {
+		realname = strdup(strrchr(name, ':') + 1);
 	} else {
 		realname = strdup(name);
 	}
Index: LinuxBIOSv3-laroptions/util/lar/lib.h
===================================================================
--- LinuxBIOSv3-laroptions/util/lar/lib.h	(Revision 559)
+++ LinuxBIOSv3-laroptions/util/lar/lib.h	(Arbeitskopie)
@@ -56,7 +56,7 @@
 
 /* Prototypes for in-memory LAR operations */
 int lar_process_name(char *name, char **pfilename, char **ppathname, 
-		enum compalgo *thisalgo);
+		enum compalgo *thisalgo, u32 *entry);
 u32 lar_compress(char *ptr, ssize_t size, char *temp, enum compalgo *thisalgo);
 int lar_add_entry(struct lar *lar, char *pathname, void *data, 
 	u32 complen, u32 reallen, u32 loadaddress, u32 entry, 
Index: LinuxBIOSv3-laroptions/util/lar/stream.c
===================================================================
--- LinuxBIOSv3-laroptions/util/lar/stream.c	(Revision 559)
+++ LinuxBIOSv3-laroptions/util/lar/stream.c	(Arbeitskopie)
@@ -671,20 +671,25 @@
  * @return 0 success, or -1 on failure (i.e. a bad name)
  */
 int lar_process_name(char *name, char **pfilename, char **ppathname, 
-		     enum compalgo *thisalgo)
+		     enum compalgo *thisalgo, u32 *entry)
 {
 	char *filename = name, *pathname = name;
 
-	if (!strncmp(name, "nocompress:",11)) {
-		filename += 11;
+	if (strstr(name, "nocompress:")) {
 		*thisalgo = none;
 	}
+	if (strstr(name, "entry=")) {
+		*entry = strtoul(strstr(name, "entry=") + 6, NULL, 0);
+	}
+	if (strrchr(name, ':'))
+		filename = strrchr(name, ':') + 1;
 
 	/* this is dangerous */
 	if (filename[0] == '.' && filename[1] == '/')
 		filename += 2;
 
-	pathname = strchr(filename, ':');
+	/* New pathname syntax: path=file */
+	pathname = strchr(filename, '=');
 
 	if (pathname != NULL) {
 		*pathname = '\0';
@@ -783,6 +788,7 @@
 	u32 *walk,  csum;
 	u32 offset;
 
+	printf("lar_add_entry called for %s, entry is %p\n", pathname, (void *)entry);
 	/* Find the beginning of the available space in the LAR */
 	offset = lar_empty_offset(lar);
 
@@ -848,13 +854,18 @@
 	u32 complen;
 	int pathlen;
 	u32 size;
+	u32 entry = 0;
 
+	printf("lar_add_file: name is %s\n", name);
+
 	thisalgo = algo;
-	lar_process_name(name, &filename, &pathname, &thisalgo);
+	lar_process_name(name, &filename, &pathname, &thisalgo, &entry);
+	printf("lar_add_file: after processing: filename=%s, pathname=%s\n", filename, pathname);
 
 	ptr = mapfile(filename, &size);
 
 	if (elfparse() && iself(ptr)) {
+		printf("lar_add_file: handle elf\n");
 		output_elf_segments(lar, pathname, ptr, size, thisalgo);
 		return 0;
 	}
@@ -878,7 +889,7 @@
 
 	munmap(ptr, size);
 
-	ret = lar_add_entry(lar, pathname, temp, complen, size, 0, 0, thisalgo);
+	ret = lar_add_entry(lar, pathname, temp, complen, size, 0, entry, thisalgo);
 
 	free(temp);
 	return ret;






More information about the coreboot mailing list