summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEduardo Habkost <ehabkost@redhat.com>2020-12-10 10:26:43 -0500
committerKevin O'Connor <kevin@koconnor.net>2021-12-18 11:39:12 -0500
commit72f917ea3732b115eb411230754534812901dde5 (patch)
tree8a7debe63296941c66c4b5dd01bcfed68c7f6317 /src
parent2dd4b9b3f84019668719344b40dba79d681be41c (diff)
downloadqemu-seabios-72f917ea3732b115eb411230754534812901dde5.tar.gz
biostables: copy_fseg_table() function
Replace the common malloc_fseg() + memcpy() code pattern with a helper function. Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Diffstat (limited to 'src')
-rw-r--r--src/fw/biostables.c40
1 files changed, 16 insertions, 24 deletions
diff --git a/src/fw/biostables.c b/src/fw/biostables.c
index 794b5be..a6f316f 100644
--- a/src/fw/biostables.c
+++ b/src/fw/biostables.c
@@ -21,6 +21,19 @@
struct pir_header *PirAddr VARFSEG;
+static void *
+copy_fseg_table(const char *name, void *pos, u32 size)
+{
+ void *newpos = malloc_fseg(size);
+ if (!newpos) {
+ warn_noalloc();
+ return NULL;
+ }
+ dprintf(1, "Copying %s from %p to %p\n", name, pos, newpos);
+ memcpy(newpos, pos, size);
+ return newpos;
+}
+
void
copy_pir(void *pos)
{
@@ -33,14 +46,7 @@ copy_pir(void *pos)
return;
if (checksum(pos, p->size) != 0)
return;
- void *newpos = malloc_fseg(p->size);
- if (!newpos) {
- warn_noalloc();
- return;
- }
- dprintf(1, "Copying PIR from %p to %p\n", pos, newpos);
- memcpy(newpos, pos, p->size);
- PirAddr = newpos;
+ PirAddr = copy_fseg_table("PIR", pos, p->size);
}
void
@@ -111,14 +117,7 @@ copy_acpi_rsdp(void *pos)
int length = get_acpi_rsdp_length(pos, -1);
if (length < 0)
return;
- void *newpos = malloc_fseg(length);
- if (!newpos) {
- warn_noalloc();
- return;
- }
- dprintf(1, "Copying ACPI RSDP from %p to %p\n", pos, newpos);
- memcpy(newpos, pos, length);
- RsdpAddr = newpos;
+ RsdpAddr = copy_fseg_table("ACPI RSDP", pos, length);
}
void *find_acpi_rsdp(void)
@@ -305,14 +304,7 @@ copy_smbios(void *pos)
return;
if (checksum(pos+0x10, p->length-0x10) != 0)
return;
- struct smbios_entry_point *newpos = malloc_fseg(p->length);
- if (!newpos) {
- warn_noalloc();
- return;
- }
- dprintf(1, "Copying SMBIOS entry point from %p to %p\n", pos, newpos);
- memcpy(newpos, pos, p->length);
- SMBiosAddr = newpos;
+ SMBiosAddr = copy_fseg_table("SMBIOS", pos, p->length);
}
void