Hi, I tried the patch 1 and 2, and tested it with qemu passing data, it seems good. thanks.
δΊ 2011-7-6 9:08, Kevin O'Connor ει:
Add romfile_loadint() function which can be used to extract a little-endian binary encoded integer from rom.
src/paravirt.c | 19 +++++++++++++++++++ src/paravirt.h | 1 + 2 files changed, 20 insertions(+), 0 deletions(-)
diff --git a/src/paravirt.c b/src/paravirt.c index 09e3d23..9cf77de 100644 --- a/src/paravirt.c +++ b/src/paravirt.c @@ -409,3 +409,22 @@ romfile_loadfile(const char *name, int *psize) data[filesize] = '\0'; return data; }
+// Attempt to load an integer from the given file - return 'defval' +// if unsuccesful. +u64 +romfile_loadint(const char *name, u64 defval) +{
- u32 file = romfile_find(name);
- if (!file)
return defval;
- int filesize = romfile_size(file);
- if (!filesize || filesize> sizeof(u64) || (filesize& (filesize-1)))
// Doesn't look like a valid integer.
return defval;
- u64 val = 0;
- romfile_copy(file,&val, sizeof(val));
- return val;
+} diff --git a/src/paravirt.h b/src/paravirt.h index 7bf34b1..83166f4 100644 --- a/src/paravirt.h +++ b/src/paravirt.h @@ -101,6 +101,7 @@ static inline const char* romfile_name(u32 fileid) { return qemu_cfg_name_file(fileid); } void *romfile_loadfile(const char *name, int *psize); +u64 romfile_loadint(const char *name, u64 defval);
u32 qemu_cfg_e820_entries(void); void* qemu_cfg_e820_load_next(void *addr);