Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 25324
b: refs/heads/master
c: 9522236
h: refs/heads/master
v: v3
  • Loading branch information
Arjan van de Ven authored and Linus Torvalds committed Apr 9, 2006
1 parent a6ee9db commit 70f01d4
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: eee5a9fa63c97366cdea6ab3aa2ed9e3601812d0
refs/heads/master: 952223683ec989e86328c24808fdb962c4dbeb0a
30 changes: 30 additions & 0 deletions trunk/arch/i386/kernel/setup.c
Original file line number Diff line number Diff line change
Expand Up @@ -963,6 +963,36 @@ efi_memory_present_wrapper(unsigned long start, unsigned long end, void *arg)
return 0;
}

/*
* This function checks if the entire range <start,end> is mapped with type.
*
* Note: this function only works correct if the e820 table is sorted and
* not-overlapping, which is the case
*/
int __init
e820_all_mapped(unsigned long start, unsigned long end, unsigned type)
{
int i;
for (i = 0; i < e820.nr_map; i++) {
struct e820entry *ei = &e820.map[i];
if (type && ei->type != type)
continue;
/* is the region (part) in overlap with the current region ?*/
if (ei->addr >= end || ei->addr + ei->size <= start)
continue;
/* if the region is at the beginning of <start,end> we move
* start to the end of the region since it's ok until there
*/
if (ei->addr <= start)
start = ei->addr + ei->size;
/* if start is now at or beyond end, we're done, full
* coverage */
if (start >= end)
return 1; /* we're done */
}
return 0;
}

/*
* Find the highest page frame number we have available
*/
Expand Down
33 changes: 33 additions & 0 deletions trunk/arch/x86_64/kernel/e820.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ static inline int bad_addr(unsigned long *addrp, unsigned long size)
return 0;
}

/*
* This function checks if any part of the range <start,end> is mapped
* with type.
*/
int __meminit
e820_any_mapped(unsigned long start, unsigned long end, unsigned type)
{
Expand All @@ -95,6 +99,35 @@ e820_any_mapped(unsigned long start, unsigned long end, unsigned type)
return 0;
}

/*
* This function checks if the entire range <start,end> is mapped with type.
*
* Note: this function only works correct if the e820 table is sorted and
* not-overlapping, which is the case
*/
int __init e820_all_mapped(unsigned long start, unsigned long end, unsigned type)
{
int i;
for (i = 0; i < e820.nr_map; i++) {
struct e820entry *ei = &e820.map[i];
if (type && ei->type != type)
continue;
/* is the region (part) in overlap with the current region ?*/
if (ei->addr >= end || ei->addr + ei->size <= start)
continue;

/* if the region is at the beginning of <start,end> we move
* start to the end of the region since it's ok until there
*/
if (ei->addr <= start)
start = ei->addr + ei->size;
/* if start is now at or beyond end, we're done, full coverage */
if (start >= end)
return 1; /* we're done */
}
return 0;
}

/*
* Find a free area in a specific range.
*/
Expand Down
4 changes: 4 additions & 0 deletions trunk/include/asm-i386/e820.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ struct e820map {
};

extern struct e820map e820;

extern int e820_all_mapped(unsigned long start, unsigned long end,
unsigned type);

#endif/*!__ASSEMBLY__*/

#endif/*__E820_HEADER*/
1 change: 1 addition & 0 deletions trunk/include/asm-x86_64/e820.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ extern unsigned long e820_end_of_ram(void);
extern void e820_reserve_resources(void);
extern void e820_print_map(char *who);
extern int e820_any_mapped(unsigned long start, unsigned long end, unsigned type);
extern int e820_all_mapped(unsigned long start, unsigned long end, unsigned type);

extern void e820_bootmem_free(pg_data_t *pgdat, unsigned long start,unsigned long end);
extern void e820_setup_gap(void);
Expand Down

0 comments on commit 70f01d4

Please sign in to comment.