[SeaBIOS] [PATCH 1/8] Add "romfile" code to assist with extract integer config settings.
Wayne Xia
xiawenc at linux.vnet.ibm.com
Wed Jul 6 04:40:59 CEST 2011
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);
--
Best Regards
Wayne Xia
mail:xiawenc at linux.vnet.ibm.com
tel:86-010-82450803
More information about the SeaBIOS
mailing list