x86/boot/e820: Rename the basic e820 data types to 'struct e820_entry' and 'struct e820_array'

The 'e820entry' and 'e820map' names have various annoyances:

 - the missing underscore departs from the usual kernel style
   and makes the code look weird,

 - in the past I kept confusing the 'map' with the 'entry', because
   a 'map' is ambiguous in that regard,

 - it's not really clear from the 'e820map' that this is a regular
   C array.

Rename them to 'struct e820_entry' and 'struct e820_array' accordingly.

( Leave the legacy UAPI header alone but do the rename in the bootparam.h
  and e820/types.h file - outside tools relying on these defines should
  either adjust their code, or should use the legacy header, or should
  create their private copies for the definitions. )

No change in functionality.

Cc: Alex Thorlton <athorlton@sgi.com>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Brian Gerst <brgerst@gmail.com>
Cc: Dan Williams <dan.j.williams@intel.com>
Cc: Denys Vlasenko <dvlasenk@redhat.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Huang, Ying <ying.huang@intel.com>
Cc: Josh Poimboeuf <jpoimboe@redhat.com>
Cc: Juergen Gross <jgross@suse.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Paul Jackson <pj@sgi.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Rafael J. Wysocki <rjw@sisk.pl>
Cc: Tejun Heo <tj@kernel.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Wei Yang <richard.weiyang@gmail.com>
Cc: Yinghai Lu <yinghai@kernel.org>
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>
This commit is contained in:
Ingo Molnar 2017-01-27 12:54:38 +01:00
parent 308bee698a
commit 8ec67d97bf
16 changed files with 66 additions and 66 deletions

View File

@ -34,5 +34,5 @@ Offset Proto Name Meaning
1EF/001 ALL sentinel Used to detect broken bootloaders
290/040 ALL edd_mbr_sig_buffer EDD MBR signatures
2D0/A00 ALL e820_map E820 memory map table
(array of struct e820entry)
(array of struct e820_entry)
D00/1EC ALL eddbuf EDD data (array of struct edd_info)

View File

@ -900,7 +900,7 @@ static void add_e820ext(struct boot_params *params,
unsigned long size;
e820ext->type = SETUP_E820_EXT;
e820ext->len = nr_entries * sizeof(struct e820entry);
e820ext->len = nr_entries * sizeof(struct e820_entry);
e820ext->next = 0;
data = (struct setup_data *)(unsigned long)params->hdr.setup_data;
@ -917,9 +917,9 @@ static void add_e820ext(struct boot_params *params,
static efi_status_t setup_e820(struct boot_params *params,
struct setup_data *e820ext, u32 e820ext_size)
{
struct e820entry *e820_map = &params->e820_map[0];
struct e820_entry *e820_map = &params->e820_map[0];
struct efi_info *efi = &params->efi_info;
struct e820entry *prev = NULL;
struct e820_entry *prev = NULL;
u32 nr_entries;
u32 nr_desc;
int i;
@ -983,14 +983,14 @@ static efi_status_t setup_e820(struct boot_params *params,
}
if (nr_entries == ARRAY_SIZE(params->e820_map)) {
u32 need = (nr_desc - i) * sizeof(struct e820entry) +
u32 need = (nr_desc - i) * sizeof(struct e820_entry) +
sizeof(struct setup_data);
if (!e820ext || e820ext_size < need)
return EFI_BUFFER_TOO_SMALL;
/* boot_params map full, switch to e820 extended */
e820_map = (struct e820entry *)e820ext->data;
e820_map = (struct e820_entry *)e820ext->data;
}
e820_map->addr = d->phys_addr;
@ -1019,7 +1019,7 @@ static efi_status_t alloc_e820ext(u32 nr_desc, struct setup_data **e820ext,
unsigned long size;
size = sizeof(struct setup_data) +
sizeof(struct e820entry) * nr_desc;
sizeof(struct e820_entry) * nr_desc;
if (*e820ext) {
efi_call_early(free_pool, *e820ext);

View File

@ -426,7 +426,7 @@ static unsigned long slots_fetch_random(void)
return 0;
}
static void process_e820_entry(struct e820entry *entry,
static void process_e820_entry(struct e820_entry *entry,
unsigned long minimum,
unsigned long image_size)
{

View File

@ -21,8 +21,8 @@ static int detect_memory_e820(void)
{
int count = 0;
struct biosregs ireg, oreg;
struct e820entry *desc = boot_params.e820_map;
static struct e820entry buf; /* static so it is zeroed */
struct e820_entry *desc = boot_params.e820_map;
static struct e820_entry buf; /* static so it is zeroed */
initregs(&ireg);
ireg.ax = 0xe820;

View File

@ -4,8 +4,8 @@
#include <asm/e820/types.h>
/* see comment in arch/x86/kernel/e820.c */
extern struct e820map *e820;
extern struct e820map *e820_saved;
extern struct e820_array *e820;
extern struct e820_array *e820_saved;
extern unsigned long pci_mem_start;
@ -13,7 +13,7 @@ extern int e820_any_mapped(u64 start, u64 end, unsigned type);
extern int e820_all_mapped(u64 start, u64 end, unsigned type);
extern void e820_add_region(u64 start, u64 size, int type);
extern void e820_print_map(char *who);
extern int sanitize_e820_map(struct e820entry *biosmap, int max_nr_map, u32 *pnr_map);
extern int sanitize_e820_map(struct e820_entry *biosmap, int max_nr_map, u32 *pnr_map);
extern u64 e820_update_range(u64 start, u64 size, unsigned old_type, unsigned new_type);
extern u64 e820_remove_range(u64 start, u64 size, unsigned old_type, int checktype);
extern void update_e820(void);

View File

@ -68,9 +68,9 @@
/*
* The whole array of E820 entries:
*/
struct e820map {
struct e820_array {
__u32 nr_map;
struct e820entry map[E820_X_MAX];
struct e820_entry map[E820_X_MAX];
};
/*

View File

@ -152,7 +152,7 @@ struct boot_params {
struct setup_header hdr; /* setup header */ /* 0x1f1 */
__u8 _pad7[0x290-0x1f1-sizeof(struct setup_header)];
__u32 edd_mbr_sig_buffer[EDD_MBR_SIG_MAX]; /* 0x290 */
struct e820entry e820_map[E820MAX]; /* 0x2d0 */
struct e820_entry e820_map[E820MAX]; /* 0x2d0 */
__u8 _pad8[48]; /* 0xcd0 */
struct edd_info eddbuf[EDDMAXNR]; /* 0xd00 */
__u8 _pad9[276]; /* 0xeec */

View File

@ -10,7 +10,7 @@
* A single E820 map entry, describing a memory range of [addr...addr+size-1],
* of 'type' memory type:
*/
struct e820entry {
struct e820_entry {
__u64 addr;
__u64 size;
__u32 type;

View File

@ -504,7 +504,7 @@ static int prepare_elf_headers(struct kimage *image, void **addr,
return ret;
}
static int add_e820_entry(struct boot_params *params, struct e820entry *entry)
static int add_e820_entry(struct boot_params *params, struct e820_entry *entry)
{
unsigned int nr_e820_entries;
@ -513,7 +513,7 @@ static int add_e820_entry(struct boot_params *params, struct e820entry *entry)
return 1;
memcpy(&params->e820_map[nr_e820_entries], entry,
sizeof(struct e820entry));
sizeof(struct e820_entry));
params->e820_entries++;
return 0;
}
@ -522,7 +522,7 @@ static int memmap_entry_callback(u64 start, u64 end, void *arg)
{
struct crash_memmap_data *cmd = arg;
struct boot_params *params = cmd->params;
struct e820entry ei;
struct e820_entry ei;
ei.addr = start;
ei.size = end - start + 1;
@ -561,7 +561,7 @@ int crash_setup_memmap_entries(struct kimage *image, struct boot_params *params)
{
int i, ret = 0;
unsigned long flags;
struct e820entry ei;
struct e820_entry ei;
struct crash_memmap_data cmd;
struct crash_mem *cmem;

View File

@ -40,10 +40,10 @@
* user can e.g. boot the original kernel with mem=1G while still booting the
* next kernel with full memory.
*/
static struct e820map initial_e820 __initdata;
static struct e820map initial_e820_saved __initdata;
struct e820map *e820 __refdata = &initial_e820;
struct e820map *e820_saved __refdata = &initial_e820_saved;
static struct e820_array initial_e820 __initdata;
static struct e820_array initial_e820_saved __initdata;
struct e820_array *e820 __refdata = &initial_e820;
struct e820_array *e820_saved __refdata = &initial_e820_saved;
/* For PCI or other memory-mapped resources */
unsigned long pci_mem_start = 0xaeedbabe;
@ -61,7 +61,7 @@ e820_any_mapped(u64 start, u64 end, unsigned type)
int i;
for (i = 0; i < e820->nr_map; i++) {
struct e820entry *ei = &e820->map[i];
struct e820_entry *ei = &e820->map[i];
if (type && ei->type != type)
continue;
@ -84,7 +84,7 @@ int __init e820_all_mapped(u64 start, u64 end, unsigned type)
int i;
for (i = 0; i < e820->nr_map; i++) {
struct e820entry *ei = &e820->map[i];
struct e820_entry *ei = &e820->map[i];
if (type && ei->type != type)
continue;
@ -110,7 +110,7 @@ int __init e820_all_mapped(u64 start, u64 end, unsigned type)
/*
* Add a memory region to the kernel e820 map.
*/
static void __init __e820_add_region(struct e820map *e820x, u64 start, u64 size,
static void __init __e820_add_region(struct e820_array *e820x, u64 start, u64 size,
int type)
{
int x = e820x->nr_map;
@ -185,7 +185,7 @@ void __init e820_print_map(char *who)
* numbered type.
*
* The input parameter biosmap points to an array of 'struct
* e820entry' which on entry has elements in the range [0, *pnr_map)
* e820_entry' which on entry has elements in the range [0, *pnr_map)
* valid, and which has space for up to max_nr_map entries.
* On return, the resulting sanitized e820 map entries will be in
* overwritten in the same location, starting at biosmap.
@ -238,7 +238,7 @@ void __init e820_print_map(char *who)
* ______________________4_
*/
struct change_member {
struct e820entry *pbios; /* pointer to original bios entry */
struct e820_entry *pbios; /* pointer to original bios entry */
unsigned long long addr; /* address for this change point */
};
@ -259,13 +259,13 @@ static int __init cpcompare(const void *a, const void *b)
return (ap->addr != ap->pbios->addr) - (bp->addr != bp->pbios->addr);
}
int __init sanitize_e820_map(struct e820entry *biosmap, int max_nr_map,
int __init sanitize_e820_map(struct e820_entry *biosmap, int max_nr_map,
u32 *pnr_map)
{
static struct change_member change_point_list[2*E820_X_MAX] __initdata;
static struct change_member *change_point[2*E820_X_MAX] __initdata;
static struct e820entry *overlap_list[E820_X_MAX] __initdata;
static struct e820entry new_bios[E820_X_MAX] __initdata;
static struct e820_entry *overlap_list[E820_X_MAX] __initdata;
static struct e820_entry new_bios[E820_X_MAX] __initdata;
unsigned long current_type, last_type;
unsigned long long last_addr;
int chgidx;
@ -379,13 +379,13 @@ int __init sanitize_e820_map(struct e820entry *biosmap, int max_nr_map,
new_nr = new_bios_entry;
/* copy new bios mapping into original location */
memcpy(biosmap, new_bios, new_nr * sizeof(struct e820entry));
memcpy(biosmap, new_bios, new_nr * sizeof(struct e820_entry));
*pnr_map = new_nr;
return 0;
}
static int __init __append_e820_map(struct e820entry *biosmap, int nr_map)
static int __init __append_e820_map(struct e820_entry *biosmap, int nr_map)
{
while (nr_map) {
u64 start = biosmap->addr;
@ -414,7 +414,7 @@ static int __init __append_e820_map(struct e820entry *biosmap, int nr_map)
* will have given us a memory map that we can use to properly
* set up memory. If we aren't, we'll fake a memory map.
*/
static int __init append_e820_map(struct e820entry *biosmap, int nr_map)
static int __init append_e820_map(struct e820_entry *biosmap, int nr_map)
{
/* Only one memory region (or negative)? Ignore it */
if (nr_map < 2)
@ -423,7 +423,7 @@ static int __init append_e820_map(struct e820entry *biosmap, int nr_map)
return __append_e820_map(biosmap, nr_map);
}
static u64 __init __e820_update_range(struct e820map *e820x, u64 start,
static u64 __init __e820_update_range(struct e820_array *e820x, u64 start,
u64 size, unsigned old_type,
unsigned new_type)
{
@ -445,7 +445,7 @@ static u64 __init __e820_update_range(struct e820map *e820x, u64 start,
printk(KERN_CONT "\n");
for (i = 0; i < e820x->nr_map; i++) {
struct e820entry *ei = &e820x->map[i];
struct e820_entry *ei = &e820x->map[i];
u64 final_start, final_end;
u64 ei_end;
@ -524,7 +524,7 @@ u64 __init e820_remove_range(u64 start, u64 size, unsigned old_type,
printk(KERN_CONT "\n");
for (i = 0; i < e820->nr_map; i++) {
struct e820entry *ei = &e820->map[i];
struct e820_entry *ei = &e820->map[i];
u64 final_start, final_end;
u64 ei_end;
@ -535,7 +535,7 @@ u64 __init e820_remove_range(u64 start, u64 size, unsigned old_type,
/* totally covered? */
if (ei->addr >= start && ei_end <= end) {
real_removed_size += ei->size;
memset(ei, 0, sizeof(struct e820entry));
memset(ei, 0, sizeof(struct e820_entry));
continue;
}
@ -658,16 +658,16 @@ __init void e820_setup_gap(void)
*/
__init void e820_reallocate_tables(void)
{
struct e820map *n;
struct e820_array *n;
int size;
size = offsetof(struct e820map, map) + sizeof(struct e820entry) * e820->nr_map;
size = offsetof(struct e820_array, map) + sizeof(struct e820_entry) * e820->nr_map;
n = kmalloc(size, GFP_KERNEL);
BUG_ON(!n);
memcpy(n, e820, size);
e820 = n;
size = offsetof(struct e820map, map) + sizeof(struct e820entry) * e820_saved->nr_map;
size = offsetof(struct e820_array, map) + sizeof(struct e820_entry) * e820_saved->nr_map;
n = kmalloc(size, GFP_KERNEL);
BUG_ON(!n);
memcpy(n, e820_saved, size);
@ -683,12 +683,12 @@ __init void e820_reallocate_tables(void)
void __init parse_e820_ext(u64 phys_addr, u32 data_len)
{
int entries;
struct e820entry *extmap;
struct e820_entry *extmap;
struct setup_data *sdata;
sdata = early_memremap(phys_addr, data_len);
entries = sdata->len / sizeof(struct e820entry);
extmap = (struct e820entry *)(sdata->data);
entries = sdata->len / sizeof(struct e820_entry);
extmap = (struct e820_entry *)(sdata->data);
__append_e820_map(extmap, entries);
sanitize_e820_map(e820->map, ARRAY_SIZE(e820->map), &e820->nr_map);
early_memunmap(sdata, data_len);
@ -712,7 +712,7 @@ void __init e820_mark_nosave_regions(unsigned long limit_pfn)
unsigned long pfn = 0;
for (i = 0; i < e820->nr_map; i++) {
struct e820entry *ei = &e820->map[i];
struct e820_entry *ei = &e820->map[i];
if (pfn < PFN_UP(ei->addr))
register_nosave_region(pfn, PFN_UP(ei->addr));
@ -738,7 +738,7 @@ static int __init e820_mark_nvs_memory(void)
int i;
for (i = 0; i < e820->nr_map; i++) {
struct e820entry *ei = &e820->map[i];
struct e820_entry *ei = &e820->map[i];
if (ei->type == E820_NVS)
acpi_nvs_register(ei->addr, ei->size);
@ -786,7 +786,7 @@ static unsigned long __init e820_end_pfn(unsigned long limit_pfn, unsigned type)
unsigned long max_arch_pfn = MAX_ARCH_PFN;
for (i = 0; i < e820->nr_map; i++) {
struct e820entry *ei = &e820->map[i];
struct e820_entry *ei = &e820->map[i];
unsigned long start_pfn;
unsigned long end_pfn;
@ -1040,7 +1040,7 @@ void __init e820_reserve_resources(void)
}
for (i = 0; i < e820_saved->nr_map; i++) {
struct e820entry *entry = &e820_saved->map[i];
struct e820_entry *entry = &e820_saved->map[i];
firmware_map_add_early(entry->addr,
entry->addr + entry->size,
e820_type_to_string(entry->type));
@ -1083,7 +1083,7 @@ void __init e820_reserve_resources_late(void)
* avoid stolen RAM:
*/
for (i = 0; i < e820->nr_map; i++) {
struct e820entry *entry = &e820->map[i];
struct e820_entry *entry = &e820->map[i];
u64 start, end;
if (entry->type != E820_RAM)
@ -1145,7 +1145,7 @@ void __init setup_memory_map(void)
char *who;
who = x86_init.resources.memory_setup();
memcpy(e820_saved, e820, sizeof(struct e820map));
memcpy(e820_saved, e820, sizeof(struct e820_array));
printk(KERN_INFO "e820: BIOS-provided physical RAM map:\n");
e820_print_map(who);
}
@ -1163,7 +1163,7 @@ void __init memblock_x86_fill(void)
memblock_allow_resize();
for (i = 0; i < e820->nr_map; i++) {
struct e820entry *ei = &e820->map[i];
struct e820_entry *ei = &e820->map[i];
end = ei->addr + ei->size;
if (end != (resource_size_t)end)

View File

@ -108,7 +108,7 @@ static int setup_e820_entries(struct boot_params *params)
params->e820_entries = nr_e820_entries;
memcpy(&params->e820_map, &e820_saved->map,
nr_e820_entries * sizeof(struct e820entry));
nr_e820_entries * sizeof(struct e820_entry));
return 0;
}

View File

@ -25,7 +25,7 @@ static void resource_clip(struct resource *res, resource_size_t start,
static void remove_e820_regions(struct resource *avail)
{
int i;
struct e820entry *entry;
struct e820_entry *entry;
for (i = 0; i < e820->nr_map; i++) {
entry = &e820->map[i];

View File

@ -459,7 +459,7 @@ static void __init e820_reserve_setup_data(void)
}
sanitize_e820_map(e820->map, ARRAY_SIZE(e820->map), &e820->nr_map);
memcpy(e820_saved, e820, sizeof(struct e820map));
memcpy(e820_saved, e820, sizeof(struct e820_array));
printk(KERN_INFO "extended physical RAM map:\n");
e820_print_map("reserve setup_data");
}

View File

@ -201,7 +201,7 @@ struct restore_data_record {
* @map: the e820 map to be calculated
* @buf: the md5 result to be stored to
*/
static int get_e820_md5(struct e820map *map, void *buf)
static int get_e820_md5(struct e820_array *map, void *buf)
{
struct scatterlist sg;
struct crypto_ahash *tfm;
@ -214,8 +214,8 @@ static int get_e820_md5(struct e820map *map, void *buf)
{
AHASH_REQUEST_ON_STACK(req, tfm);
size = offsetof(struct e820map, map)
+ sizeof(struct e820entry) * map->nr_map;
size = offsetof(struct e820_array, map)
+ sizeof(struct e820_entry) * map->nr_map;
ahash_request_set_tfm(req, tfm);
sg_init_one(&sg, (u8 *)map, size);
ahash_request_set_callback(req, 0, NULL, NULL);

View File

@ -41,7 +41,7 @@ struct xen_memory_region xen_extra_mem[XEN_EXTRA_MEM_MAX_REGIONS] __initdata;
unsigned long xen_released_pages;
/* E820 map used during setting up memory. */
static struct e820entry xen_e820_map[E820_X_MAX] __initdata;
static struct e820_entry xen_e820_map[E820_X_MAX] __initdata;
static u32 xen_e820_map_entries __initdata;
/*
@ -198,7 +198,7 @@ void __init xen_inv_extra_mem(void)
*/
static unsigned long __init xen_find_pfn_range(unsigned long *min_pfn)
{
const struct e820entry *entry = xen_e820_map;
const struct e820_entry *entry = xen_e820_map;
unsigned int i;
unsigned long done = 0;
@ -457,7 +457,7 @@ static unsigned long __init xen_foreach_remap_area(unsigned long nr_pages,
{
phys_addr_t start = 0;
unsigned long ret_val = 0;
const struct e820entry *entry = xen_e820_map;
const struct e820_entry *entry = xen_e820_map;
int i;
/*
@ -601,7 +601,7 @@ static void __init xen_align_and_add_e820_region(phys_addr_t start,
static void __init xen_ignore_unusable(void)
{
struct e820entry *entry = xen_e820_map;
struct e820_entry *entry = xen_e820_map;
unsigned int i;
for (i = 0; i < xen_e820_map_entries; i++, entry++) {
@ -612,7 +612,7 @@ static void __init xen_ignore_unusable(void)
bool __init xen_is_e820_reserved(phys_addr_t start, phys_addr_t size)
{
struct e820entry *entry;
struct e820_entry *entry;
unsigned mapcnt;
phys_addr_t end;
@ -645,7 +645,7 @@ phys_addr_t __init xen_find_free_area(phys_addr_t size)
{
unsigned mapcnt;
phys_addr_t addr, start;
struct e820entry *entry = xen_e820_map;
struct e820_entry *entry = xen_e820_map;
for (mapcnt = 0; mapcnt < xen_e820_map_entries; mapcnt++, entry++) {
if (entry->type != E820_RAM || entry->size < size)

View File

@ -3339,7 +3339,7 @@ int main(int argc, char *argv[])
* simple, single region.
*/
boot->e820_entries = 1;
boot->e820_map[0] = ((struct e820entry) { 0, mem, E820_RAM });
boot->e820_map[0] = ((struct e820_entry) { 0, mem, E820_RAM });
/*
* The boot header contains a command line pointer: we put the command
* line after the boot header.