ia64/xen-unstable

changeset 10127:49bb240a05ee

Re-order code in preparation for future patches.

There is no change to the functions which have moved.

Signed-off-by: Ian Campbell <ian.campbell@xensource.com>
author Ian.Campbell@xensource.com
date Mon May 22 09:21:01 2006 +0100 (2006-05-22)
parents 14717dedba02
children ebfa1046a81f
files linux-2.6-xen-sparse/arch/i386/kernel/setup-xen.c linux-2.6-xen-sparse/arch/x86_64/kernel/e820-xen.c
line diff
     1.1 --- a/linux-2.6-xen-sparse/arch/i386/kernel/setup-xen.c	Sun May 21 20:15:58 2006 +0100
     1.2 +++ b/linux-2.6-xen-sparse/arch/i386/kernel/setup-xen.c	Mon May 22 09:21:01 2006 +0100
     1.3 @@ -399,6 +399,26 @@ EXPORT_SYMBOL(phys_to_machine_mapping);
     1.4  start_info_t *xen_start_info;
     1.5  EXPORT_SYMBOL(xen_start_info);
     1.6  
     1.7 +static void __init add_memory_region(unsigned long long start,
     1.8 +                                  unsigned long long size, int type)
     1.9 +{
    1.10 +	int x;
    1.11 +
    1.12 +	if (!efi_enabled) {
    1.13 +       		x = e820.nr_map;
    1.14 +
    1.15 +		if (x == E820MAX) {
    1.16 +		    printk(KERN_ERR "Ooops! Too many entries in the memory map!\n");
    1.17 +		    return;
    1.18 +		}
    1.19 +
    1.20 +		e820.map[x].addr = start;
    1.21 +		e820.map[x].size = size;
    1.22 +		e820.map[x].type = type;
    1.23 +		e820.nr_map++;
    1.24 +	}
    1.25 +} /* add_memory_region */
    1.26 +
    1.27  static void __init limit_regions(unsigned long long size)
    1.28  {
    1.29  	unsigned long long current_addr = 0;
    1.30 @@ -444,26 +464,6 @@ static void __init limit_regions(unsigne
    1.31  	}
    1.32  }
    1.33  
    1.34 -static void __init add_memory_region(unsigned long long start,
    1.35 -                                  unsigned long long size, int type)
    1.36 -{
    1.37 -	int x;
    1.38 -
    1.39 -	if (!efi_enabled) {
    1.40 -       		x = e820.nr_map;
    1.41 -
    1.42 -		if (x == E820MAX) {
    1.43 -		    printk(KERN_ERR "Ooops! Too many entries in the memory map!\n");
    1.44 -		    return;
    1.45 -		}
    1.46 -
    1.47 -		e820.map[x].addr = start;
    1.48 -		e820.map[x].size = size;
    1.49 -		e820.map[x].type = type;
    1.50 -		e820.nr_map++;
    1.51 -	}
    1.52 -} /* add_memory_region */
    1.53 -
    1.54  #define E820_DEBUG	1
    1.55  
    1.56  static void __init print_memory_map(char *who)
     2.1 --- a/linux-2.6-xen-sparse/arch/x86_64/kernel/e820-xen.c	Sun May 21 20:15:58 2006 +0100
     2.2 +++ b/linux-2.6-xen-sparse/arch/x86_64/kernel/e820-xen.c	Mon May 22 09:21:01 2006 +0100
     2.3 @@ -33,38 +33,21 @@ unsigned long pci_mem_start = 0xaeedbabe
     2.4   */
     2.5  unsigned long end_pfn; 
     2.6  EXPORT_SYMBOL(end_pfn);
     2.7 -unsigned long end_user_pfn = MAXMEM>>PAGE_SHIFT;  
     2.8 -unsigned long end_pfn_map; 
     2.9 -
    2.10 -/* 
    2.11 - * Add a memory region to the kernel e820 map.
    2.12 - */ 
    2.13 -void __init add_memory_region(unsigned long start, unsigned long size, int type)
    2.14 -{
    2.15 -	int x = e820.nr_map;
    2.16 -
    2.17 -	if (x == E820MAX) {
    2.18 -		printk(KERN_ERR "Ooops! Too many entries in the memory map!\n");
    2.19 -		return;
    2.20 -	}
    2.21 -
    2.22 -	e820.map[x].addr = start;
    2.23 -	e820.map[x].size = size;
    2.24 -	e820.map[x].type = type;
    2.25 -	e820.nr_map++;
    2.26 -}
    2.27 -
    2.28 -#ifndef CONFIG_XEN
    2.29  
    2.30  /* 
    2.31   * end_pfn only includes RAM, while end_pfn_map includes all e820 entries.
    2.32   * The direct mapping extends to end_pfn_map, so that we can directly access
    2.33   * apertures, ACPI and other tables without having to play with fixmaps.
    2.34   */ 
    2.35 +unsigned long end_pfn_map; 
    2.36  
    2.37  /* 
    2.38   * Last pfn which the user wants to use.
    2.39   */
    2.40 +unsigned long end_user_pfn = MAXMEM>>PAGE_SHIFT;  
    2.41 +
    2.42 +#ifndef CONFIG_XEN
    2.43 +
    2.44  
    2.45  extern struct resource code_resource, data_resource;
    2.46  
    2.47 @@ -276,8 +259,91 @@ void __init e820_reserve_resources(void)
    2.48  		}
    2.49  	}
    2.50  }
    2.51 +#else
    2.52 +void __init e820_reserve_resources(void) 
    2.53 +{
    2.54 +	dom0_op_t op;
    2.55 +	struct dom0_memory_map_entry *map;
    2.56 +	unsigned long gapstart, gapsize, round, last;
    2.57 +	int i, found = 0;
    2.58 +
    2.59 +	if (!(xen_start_info->flags & SIF_INITDOMAIN))
    2.60 +		return;
    2.61 +
    2.62 +	map = alloc_bootmem_low_pages(PAGE_SIZE);
    2.63 +	op.cmd = DOM0_PHYSICAL_MEMORY_MAP;
    2.64 +	set_xen_guest_handle(op.u.physical_memory_map.memory_map, map);
    2.65 +	op.u.physical_memory_map.max_map_entries =
    2.66 +		PAGE_SIZE / sizeof(struct dom0_memory_map_entry);
    2.67 +	BUG_ON(HYPERVISOR_dom0_op(&op));
    2.68 +
    2.69 +	last = 0x100000000ULL;
    2.70 +	gapstart = 0x10000000;
    2.71 +	gapsize = 0x400000;
    2.72 +
    2.73 +	for (i = op.u.physical_memory_map.nr_map_entries - 1; i >= 0; i--) {
    2.74 +		struct resource *res;
    2.75 +
    2.76 +		if ((last > map[i].end) && ((last - map[i].end) > gapsize)) {
    2.77 +			gapsize = last - map[i].end;
    2.78 +			gapstart = map[i].end;
    2.79 +			found = 1;
    2.80 +		}
    2.81 +		if (map[i].start < last)
    2.82 +			last = map[i].start;
    2.83 +
    2.84 +		if (map[i].end > 0x100000000ULL)
    2.85 +			continue;
    2.86 +		res = alloc_bootmem_low(sizeof(struct resource));
    2.87 +		res->name = map[i].is_ram ? "System RAM" : "reserved";
    2.88 +		res->start = map[i].start;
    2.89 +		res->end = map[i].end - 1;
    2.90 +		res->flags = IORESOURCE_MEM | IORESOURCE_BUSY;
    2.91 +		request_resource(&iomem_resource, res);
    2.92 +	}
    2.93 +
    2.94 +	free_bootmem(__pa(map), PAGE_SIZE);
    2.95 +
    2.96 +	if (!found) {
    2.97 +		gapstart = HYPERVISOR_memory_op(XENMEM_maximum_ram_page, NULL);
    2.98 +		gapstart = (gapstart << PAGE_SHIFT) + 1024*1024;
    2.99 +		printk(KERN_ERR "PCI: Warning: Cannot find a gap in the 32bit address range\n"
   2.100 +		       KERN_ERR "PCI: Unassigned devices with 32bit resource registers may break!\n");
   2.101 +	}
   2.102 +
   2.103 +	/*
   2.104 +	 * See how much we want to round up: start off with
   2.105 +	 * rounding to the next 1MB area.
   2.106 +	 */
   2.107 +	round = 0x100000;
   2.108 +	while ((gapsize >> 4) > round)
   2.109 +		round += round;
   2.110 +	/* Fun with two's complement */
   2.111 +	pci_mem_start = (gapstart + round) & -round;
   2.112 +
   2.113 +	printk(KERN_INFO "Allocating PCI resources starting at %lx (gap: %lx:%lx)\n",
   2.114 +		pci_mem_start, gapstart, gapsize);
   2.115 +}
   2.116  #endif /* CONFIG_XEN */
   2.117  
   2.118 +/* 
   2.119 + * Add a memory region to the kernel e820 map.
   2.120 + */ 
   2.121 +void __init add_memory_region(unsigned long start, unsigned long size, int type)
   2.122 +{
   2.123 +	int x = e820.nr_map;
   2.124 +
   2.125 +	if (x == E820MAX) {
   2.126 +		printk(KERN_ERR "Ooops! Too many entries in the memory map!\n");
   2.127 +		return;
   2.128 +	}
   2.129 +
   2.130 +	e820.map[x].addr = start;
   2.131 +	e820.map[x].size = size;
   2.132 +	e820.map[x].type = type;
   2.133 +	e820.nr_map++;
   2.134 +}
   2.135 +
   2.136  void __init e820_print_map(char *who)
   2.137  {
   2.138  	int i;
   2.139 @@ -588,71 +654,6 @@ e820_hole_size(unsigned long start_pfn, 
   2.140  	return 0;
   2.141  }
   2.142  
   2.143 -void __init e820_reserve_resources(void) 
   2.144 -{
   2.145 -	dom0_op_t op;
   2.146 -	struct dom0_memory_map_entry *map;
   2.147 -	unsigned long gapstart, gapsize, round, last;
   2.148 -	int i, found = 0;
   2.149 -
   2.150 -	if (!(xen_start_info->flags & SIF_INITDOMAIN))
   2.151 -		return;
   2.152 -
   2.153 -	map = alloc_bootmem_low_pages(PAGE_SIZE);
   2.154 -	op.cmd = DOM0_PHYSICAL_MEMORY_MAP;
   2.155 -	set_xen_guest_handle(op.u.physical_memory_map.memory_map, map);
   2.156 -	op.u.physical_memory_map.max_map_entries =
   2.157 -		PAGE_SIZE / sizeof(struct dom0_memory_map_entry);
   2.158 -	BUG_ON(HYPERVISOR_dom0_op(&op));
   2.159 -
   2.160 -	last = 0x100000000ULL;
   2.161 -	gapstart = 0x10000000;
   2.162 -	gapsize = 0x400000;
   2.163 -
   2.164 -	for (i = op.u.physical_memory_map.nr_map_entries - 1; i >= 0; i--) {
   2.165 -		struct resource *res;
   2.166 -
   2.167 -		if ((last > map[i].end) && ((last - map[i].end) > gapsize)) {
   2.168 -			gapsize = last - map[i].end;
   2.169 -			gapstart = map[i].end;
   2.170 -			found = 1;
   2.171 -		}
   2.172 -		if (map[i].start < last)
   2.173 -			last = map[i].start;
   2.174 -
   2.175 -		if (map[i].end > 0x100000000ULL)
   2.176 -			continue;
   2.177 -		res = alloc_bootmem_low(sizeof(struct resource));
   2.178 -		res->name = map[i].is_ram ? "System RAM" : "reserved";
   2.179 -		res->start = map[i].start;
   2.180 -		res->end = map[i].end - 1;
   2.181 -		res->flags = IORESOURCE_MEM | IORESOURCE_BUSY;
   2.182 -		request_resource(&iomem_resource, res);
   2.183 -	}
   2.184 -
   2.185 -	free_bootmem(__pa(map), PAGE_SIZE);
   2.186 -
   2.187 -	if (!found) {
   2.188 -		gapstart = HYPERVISOR_memory_op(XENMEM_maximum_ram_page, NULL);
   2.189 -		gapstart = (gapstart << PAGE_SHIFT) + 1024*1024;
   2.190 -		printk(KERN_ERR "PCI: Warning: Cannot find a gap in the 32bit address range\n"
   2.191 -		       KERN_ERR "PCI: Unassigned devices with 32bit resource registers may break!\n");
   2.192 -	}
   2.193 -
   2.194 -	/*
   2.195 -	 * See how much we want to round up: start off with
   2.196 -	 * rounding to the next 1MB area.
   2.197 -	 */
   2.198 -	round = 0x100000;
   2.199 -	while ((gapsize >> 4) > round)
   2.200 -		round += round;
   2.201 -	/* Fun with two's complement */
   2.202 -	pci_mem_start = (gapstart + round) & -round;
   2.203 -
   2.204 -	printk(KERN_INFO "Allocating PCI resources starting at %lx (gap: %lx:%lx)\n",
   2.205 -		pci_mem_start, gapstart, gapsize);
   2.206 -}
   2.207 -
   2.208  #endif
   2.209  
   2.210  void __init parse_memopt(char *p, char **from)