Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 185134
b: refs/heads/master
c: 7da657d
h: refs/heads/master
v: v3
  • Loading branch information
Yinghai Lu authored and H. Peter Anvin committed Feb 12, 2010
1 parent 10ec5ee commit ad8d895
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 14 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: a678c2be75773e112f6d656a22a7f1645c4dbd6c
refs/heads/master: 7da657d1f1dd27fa9d8289d5f7e53479c7fd3a95
45 changes: 32 additions & 13 deletions trunk/arch/x86/kernel/early_res.c
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,29 @@ u64 __init find_early_area(u64 ei_start, u64 ei_last, u64 start, u64 end,
return -1ULL;
}

u64 __init find_early_area_size(u64 ei_start, u64 ei_last, u64 start,
u64 *sizep, u64 align)
{
u64 addr, last;

addr = round_up(ei_start, align);
if (addr < start)
addr = round_up(start, align);
if (addr >= ei_last)
goto out;
*sizep = ei_last - addr;
while (bad_addr_size(&addr, sizep, align) && addr + *sizep <= ei_last)
;
last = addr + *sizep;
if (last > ei_last)
goto out;

return addr;

out:
return -1ULL;
}

/*
* Find a free area with specified alignment in a specific range.
*/
Expand Down Expand Up @@ -513,24 +536,20 @@ u64 __init find_e820_area_size(u64 start, u64 *sizep, u64 align)

for (i = 0; i < e820.nr_map; i++) {
struct e820entry *ei = &e820.map[i];
u64 addr, last;
u64 ei_last;
u64 addr;
u64 ei_start, ei_last;

if (ei->type != E820_RAM)
continue;
addr = round_up(ei->addr, align);

ei_last = ei->addr + ei->size;
if (addr < start)
addr = round_up(start, align);
if (addr >= ei_last)
continue;
*sizep = ei_last - addr;
while (bad_addr_size(&addr, sizep, align) &&
addr + *sizep <= ei_last)
;
last = addr + *sizep;
if (last > ei_last)
ei_start = ei->addr;
addr = find_early_area_size(ei_start, ei_last, start,
sizep, align);

if (addr == -1ULL)
continue;

return addr;
}

Expand Down

0 comments on commit ad8d895

Please sign in to comment.