*/
#include "boot.h"
+#include <linux/kernel.h>
#define SMAP 0x534d4150 /* ASCII "SMAP" */
count++;
desc++;
- } while (next && count < E820MAX);
+ } while (next && count < ARRAY_SIZE(boot_params.e820_map));
return boot_params.e820_entries = count;
}
{
int x = e820.nr_map;
- if (x == E820MAX) {
+ if (x == ARRAY_SIZE(e820.map)) {
printk(KERN_ERR "Ooops! Too many entries in the memory map!\n");
return;
}
* replaces the original e820 map with a new one, removing overlaps.
*
*/
-int __init sanitize_e820_map(struct e820entry *biosmap, char *pnr_map)
+int __init sanitize_e820_map(struct e820entry *biosmap, int max_nr_map,
+ char *pnr_map)
{
struct change_member {
struct e820entry *pbios; /* pointer to original bios entry */
* no more space left for new
* bios entries ?
*/
- if (++new_bios_entry >= E820MAX)
+ if (++new_bios_entry >= max_nr_map)
break;
}
if (current_type != 0) {
u8 nr_map;
nr_map = e820.nr_map;
- if (sanitize_e820_map(e820.map, &nr_map))
+ if (sanitize_e820_map(e820.map, ARRAY_SIZE(e820.map), &nr_map))
return;
e820.nr_map = nr_map;
printk(KERN_INFO "modified physical RAM map:\n");
* Otherwise fake a memory map; one section from 0k->640k,
* the next section from 1mb->appropriate_mem_k
*/
- sanitize_e820_map(boot_params.e820_map, &boot_params.e820_entries);
+ sanitize_e820_map(boot_params.e820_map,
+ ARRAY_SIZE(boot_params.e820_map),
+ &boot_params.e820_entries);
if (copy_e820_map(boot_params.e820_map, boot_params.e820_entries) < 0)
early_panic("Cannot find a valid memory map");
printk(KERN_INFO "BIOS-provided physical RAM map:\n");
if (userdef) {
char nr = e820.nr_map;
- if (sanitize_e820_map(e820.map, &nr) < 0)
+ if (sanitize_e820_map(e820.map, ARRAY_SIZE(e820.map), &nr) < 0)
early_panic("Invalid user supplied memory map");
e820.nr_map = nr;
* Otherwise fake a memory map; one section from 0k->640k,
* the next section from 1mb->appropriate_mem_k
*/
- sanitize_e820_map(boot_params.e820_map, &boot_params.e820_entries);
+ sanitize_e820_map(boot_params.e820_map,
+ ARRAY_SIZE(boot_params.e820_map),
+ &boot_params.e820_entries);
if (copy_e820_map(boot_params.e820_map, boot_params.e820_entries)
< 0) {
unsigned long mem_size;
* Otherwise fake a memory map; one section from 0k->640k,
* the next section from 1mb->appropriate_mem_k
*/
- sanitize_e820_map(boot_params.e820_map, &boot_params.e820_entries);
+ sanitize_e820_map(boot_params.e820_map,
+ ARRAY_SIZE(boot_params.e820_map),
+ &boot_params.e820_entries);
if (copy_e820_map(boot_params.e820_map, boot_params.e820_entries)
< 0) {
unsigned long mem_size;
extern int e820_all_mapped(u64 start, u64 end, unsigned type);
extern void add_memory_region(u64 start, u64 size, int type);
extern void e820_print_map(char *who);
-extern int sanitize_e820_map(struct e820entry *biosmap, char *pnr_map);
+extern int
+sanitize_e820_map(struct e820entry *biosmap, int max_nr_map, char *pnr_map);
extern int copy_e820_map(struct e820entry *biosmap, int nr_map);
extern u64 update_memory_range(u64 start, u64 size, unsigned old_type,
unsigned new_type);
char *memory_setup(void);
int __init copy_e820_map(struct e820entry *biosmap, int nr_map);
-int __init sanitize_e820_map(struct e820entry *biosmap, char *pnr_map);
void __init add_memory_region(unsigned long long start,
unsigned long long size, int type);