Commit 50eae2a7 authored by Huang, Ying's avatar Huang, Ying Committed by Ingo Molnar

x86, boot: add free_early to early reservation machanism

Add free_early to early reservation mechanism - this way early bootup
failure paths can stop wasting memory.
Signed-off-by: default avatarHuang Ying <ying.huang@intel.com>
Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
parent 4a27214d
...@@ -84,6 +84,28 @@ void __init reserve_early(unsigned long start, unsigned long end, char *name) ...@@ -84,6 +84,28 @@ void __init reserve_early(unsigned long start, unsigned long end, char *name)
strncpy(r->name, name, sizeof(r->name) - 1); strncpy(r->name, name, sizeof(r->name) - 1);
} }
void __init free_early(unsigned long start, unsigned long end)
{
struct early_res *r;
int i, j;
for (i = 0; i < MAX_EARLY_RES && early_res[i].end; i++) {
r = &early_res[i];
if (start == r->start && end == r->end)
break;
}
if (i >= MAX_EARLY_RES || !early_res[i].end)
panic("free_early on not reserved area: %lx-%lx!", start, end);
for (j = i + 1; j < MAX_EARLY_RES && early_res[j].end; j++)
;
memcpy(&early_res[i], &early_res[i + 1],
(j - 1 - i) * sizeof(struct early_res));
early_res[j - 1].end = 0;
}
void __init early_res_to_bootmem(void) void __init early_res_to_bootmem(void)
{ {
int i; int i;
......
...@@ -48,6 +48,7 @@ extern struct e820map e820; ...@@ -48,6 +48,7 @@ extern struct e820map e820;
extern void update_e820(void); extern void update_e820(void);
extern void reserve_early(unsigned long start, unsigned long end, char *name); extern void reserve_early(unsigned long start, unsigned long end, char *name);
extern void free_early(unsigned long start, unsigned long end);
extern void early_res_to_bootmem(void); extern void early_res_to_bootmem(void);
#endif/*!__ASSEMBLY__*/ #endif/*!__ASSEMBLY__*/
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment