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@chromium.org> Reviewed-on: https://review.coreboot.org/15601 Tested-by: build bot (Jenkins) Reviewed-by: Furquan Shaikh <furquan@google.com> Reviewed-by: Paul Menzel <paulepanter@users.sourceforge.net> Reviewed-by: Patrick Georgi <pgeorgi@google.com>
This commit is contained in:
parent
4934818118
commit
edfcce80b2
|
@ -42,6 +42,22 @@ struct segment {
|
||||||
int compression;
|
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:
|
/* The problem:
|
||||||
* Static executables all want to share the same addresses
|
* Static executables all want to share the same addresses
|
||||||
* in memory because only a few addresses are reliably present on
|
* in memory because only a few addresses are reliably present on
|
||||||
|
@ -148,10 +164,7 @@ static int relocate_segment(unsigned long buffer, struct segment *seg)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Order by stream offset */
|
/* Order by stream offset */
|
||||||
new->next = seg;
|
segment_insert_before(seg, new);
|
||||||
new->prev = seg->prev;
|
|
||||||
seg->prev->next = new;
|
|
||||||
seg->prev = new;
|
|
||||||
|
|
||||||
/* compute the new value of start */
|
/* compute the new value of start */
|
||||||
start = seg->s_dstaddr;
|
start = seg->s_dstaddr;
|
||||||
|
@ -183,10 +196,7 @@ static int relocate_segment(unsigned long buffer, struct segment *seg)
|
||||||
new->s_filesz = 0;
|
new->s_filesz = 0;
|
||||||
}
|
}
|
||||||
/* Order by stream offset */
|
/* Order by stream offset */
|
||||||
new->next = seg->next;
|
segment_insert_after(seg, new);
|
||||||
new->prev = seg;
|
|
||||||
seg->next->prev = new;
|
|
||||||
seg->next = new;
|
|
||||||
|
|
||||||
printk(BIOS_SPEW, " late: [0x%016lx, 0x%016lx, 0x%016lx)\n",
|
printk(BIOS_SPEW, " late: [0x%016lx, 0x%016lx, 0x%016lx)\n",
|
||||||
new->s_dstaddr,
|
new->s_dstaddr,
|
||||||
|
@ -311,10 +321,7 @@ static int build_self_segment_list(
|
||||||
|
|
||||||
/* We have found another CODE, DATA or BSS segment */
|
/* We have found another CODE, DATA or BSS segment */
|
||||||
/* Insert new segment at the end of the list */
|
/* Insert new segment at the end of the list */
|
||||||
new->next = head;
|
segment_insert_before(head, new);
|
||||||
new->prev = head->prev;
|
|
||||||
head->prev->next = new;
|
|
||||||
head->prev = new;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
|
|
Loading…
Reference in New Issue