[coreboot-gerrit] New patch to review for coreboot: lib/selfboot: don't open code linked list operations
Aaron Durbin (adurbin@chromium.org)
gerrit at coreboot.org
Mon Jul 11 19:30:06 CEST 2016
Aaron Durbin (adurbin at chromium.org) just uploaded a new patch set to gerrit, which you can find at https://review.coreboot.org/15601
-gerrit
commit 7f87a70a23be44f34dcf74aadbabadbf002531b8
Author: Aaron Durbin <adurbin at chromium.org>
Date: Mon Jul 11 12:16:08 2016 -0500
lib/selfboot: don't open code linked list operations
The list insertion operations were open coded at each location.
Add helper functions which provide the semantics needed by
the selfboot code in a single place.
Change-Id: Ic757255e01934b499def839131c257bde9d0cc93
Signed-off-by: Aaron Durbin <adurbin at chromium.org>
---
src/lib/selfboot.c | 32 ++++++++++++++++++++------------
1 file changed, 20 insertions(+), 12 deletions(-)
diff --git a/src/lib/selfboot.c b/src/lib/selfboot.c
index 75d6725..0c22f5a 100644
--- a/src/lib/selfboot.c
+++ b/src/lib/selfboot.c
@@ -42,6 +42,23 @@ struct segment {
int compression;
};
+
+static void segment_insert_before(struct segment *seg, struct segment *new)
+{
+ new->next = seg;
+ new->prev = seg->prev;
+ seg->prev->next = new;
+ seg->prev = new;
+}
+
+static void segment_insert_after(struct segment *seg, struct segment *new)
+{
+ new->next = seg->next;
+ new->prev = seg;
+ seg->next->prev = new;
+ seg->next = new;
+}
+
/* The problem:
* Static executables all want to share the same addresses
* in memory because only a few addresses are reliably present on
@@ -148,10 +165,7 @@ static int relocate_segment(unsigned long buffer, struct segment *seg)
}
/* Order by stream offset */
- new->next = seg;
- new->prev = seg->prev;
- seg->prev->next = new;
- seg->prev = new;
+ segment_insert_before(seg, new);
/* compute the new value of start */
start = seg->s_dstaddr;
@@ -183,10 +197,7 @@ static int relocate_segment(unsigned long buffer, struct segment *seg)
new->s_filesz = 0;
}
/* Order by stream offset */
- new->next = seg->next;
- new->prev = seg;
- seg->next->prev = new;
- seg->next = new;
+ segment_insert_after(seg, new);
printk(BIOS_SPEW, " late: [0x%016lx, 0x%016lx, 0x%016lx)\n",
new->s_dstaddr,
@@ -311,10 +322,7 @@ static int build_self_segment_list(
/* We have found another CODE, DATA or BSS segment */
/* Insert new segment at the end of the list */
- new->next = head;
- new->prev = head->prev;
- head->prev->next = new;
- head->prev = new;
+ segment_insert_before(head, new);
}
return 1;
More information about the coreboot-gerrit
mailing list