summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorPatrick Georgi <patrick.georgi@coresystems.de>2009-08-20 14:48:03 +0000
committerPatrick Georgi <patrick.georgi@coresystems.de>2009-08-20 14:48:03 +0000
commitb203c2f95e8174bff1170a47d06186a315de4997 (patch)
treecb6acc1a5907a55c1411f19c52b83a3b786213b6 /src/lib
parentce9d8640b1cf14419783d839afc0c53184c70bbf (diff)
downloadcoreboot-b203c2f95e8174bff1170a47d06186a315de4997.tar.xz
20090819-2-trim-down-cbfs:
CBFS uses sprintf, which requires vtxprintf, which requires (in the current design) a nested function. That works on x86, but on PPC this requires a trampoline. In the ROM stage, this is not available, so remove the single use of sprintf and replace it with a direct string handler - it's only used to fill in fixed-length hex values. 20090819-3-more-noreturns-in-romcc: Mark two more functions in romcc as noreturn. Helps clang's scan-build a bit 20090819-4-cbfsify-ppc: Make PPC use CBFS. Support big endian ELF in cbfs-mkstage. Untested and not complete yet. 20090819-5-fix-ppc-build: The CBFS build system requires ROM_IMAGE_SIZE to have a somewhat plausible value. With fixes to tohex* functions as discussed on the list, and correct function names. Signed-off-by: Patrick Georgi <patrick.georgi@coresystems.de> Acked-by: Myles Watson <mylesgw@gmail.com> Acked-by: Stefan Reinauer <stepan@coresystems.de> git-svn-id: svn://svn.coreboot.org/coreboot/trunk@4558 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/cbfs.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/src/lib/cbfs.c b/src/lib/cbfs.c
index 5a8b5f7762..ad45ece95a 100644
--- a/src/lib/cbfs.c
+++ b/src/lib/cbfs.c
@@ -124,13 +124,27 @@ struct cbfs_stage *cbfs_find_file(const char *name, int type)
return (void *) CBFS_SUBHEADER(file);
}
+static int tohex4(unsigned int c)
+{
+ return (c<=9)?(c+'0'):(c-10+'a');
+}
+
+static void tohex16(unsigned int val, char* dest)
+{
+ dest[0]=tohex4(val>>12);
+ dest[1]=tohex4((val>>8) & 0xf);
+ dest[2]=tohex4((val>>4) & 0xf);
+ dest[3]=tohex4(val & 0xf);
+}
+
void *cbfs_load_optionrom(u16 vendor, u16 device, void * dest)
{
- char name[17];
+ char name[17]="pciXXXX,XXXX.rom";
struct cbfs_optionrom *orom;
u8 *src;
- sprintf(name,"pci%04x,%04x.rom", vendor, device);
+ tohex16(vendor, name+3);
+ tohex16(device, name+8);
orom = (struct cbfs_optionrom *)
cbfs_find_file(name, CBFS_TYPE_OPTIONROM);