Commit c9cce83dd1d59f52e2c8f8c7d265ba4854c40785

Authored by Bernhard Walle
Committed by Ingo Molnar
1 parent 9773db2a30

x86: remove extern declarations for code, data, bss resources

This patch removes the extern struct resource declarations for
data_resource, code_resource and bss_resource on x86 and declares that
three structures as static as done on other architectures like IA64.

On i386, these structures are moved to setup_32.c (from e820_32.c) because
that's code that is not specific to e820 and also required on EFI systems.
That makes the "extern" reference superfluous.

On x86_64, data_resource, code_resource and bss_resource are passed to
e820_reserve_resources() as arguments just as done on i386 and IA64.  That
also avoids the "extern" reference and it's possible to make it static.

Signed-off-by: Bernhard Walle <bwalle@suse.de>
Cc: "Luck, Tony" <tony.luck@intel.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>

Showing 7 changed files with 127 additions and 121 deletions Side-by-side Diff

arch/x86/kernel/e820_32.c
... ... @@ -37,27 +37,7 @@
37 37 EXPORT_SYMBOL(pci_mem_start);
38 38 #endif
39 39 extern int user_defined_memmap;
40   -struct resource data_resource = {
41   - .name = "Kernel data",
42   - .start = 0,
43   - .end = 0,
44   - .flags = IORESOURCE_BUSY | IORESOURCE_MEM
45   -};
46 40  
47   -struct resource code_resource = {
48   - .name = "Kernel code",
49   - .start = 0,
50   - .end = 0,
51   - .flags = IORESOURCE_BUSY | IORESOURCE_MEM
52   -};
53   -
54   -struct resource bss_resource = {
55   - .name = "Kernel bss",
56   - .start = 0,
57   - .end = 0,
58   - .flags = IORESOURCE_BUSY | IORESOURCE_MEM
59   -};
60   -
61 41 static struct resource system_rom_resource = {
62 42 .name = "System ROM",
63 43 .start = 0xf0000,
... ... @@ -111,60 +91,6 @@
111 91 .flags = IORESOURCE_BUSY | IORESOURCE_READONLY | IORESOURCE_MEM
112 92 };
113 93  
114   -static struct resource video_ram_resource = {
115   - .name = "Video RAM area",
116   - .start = 0xa0000,
117   - .end = 0xbffff,
118   - .flags = IORESOURCE_BUSY | IORESOURCE_MEM
119   -};
120   -
121   -static struct resource standard_io_resources[] = { {
122   - .name = "dma1",
123   - .start = 0x0000,
124   - .end = 0x001f,
125   - .flags = IORESOURCE_BUSY | IORESOURCE_IO
126   -}, {
127   - .name = "pic1",
128   - .start = 0x0020,
129   - .end = 0x0021,
130   - .flags = IORESOURCE_BUSY | IORESOURCE_IO
131   -}, {
132   - .name = "timer0",
133   - .start = 0x0040,
134   - .end = 0x0043,
135   - .flags = IORESOURCE_BUSY | IORESOURCE_IO
136   -}, {
137   - .name = "timer1",
138   - .start = 0x0050,
139   - .end = 0x0053,
140   - .flags = IORESOURCE_BUSY | IORESOURCE_IO
141   -}, {
142   - .name = "keyboard",
143   - .start = 0x0060,
144   - .end = 0x006f,
145   - .flags = IORESOURCE_BUSY | IORESOURCE_IO
146   -}, {
147   - .name = "dma page reg",
148   - .start = 0x0080,
149   - .end = 0x008f,
150   - .flags = IORESOURCE_BUSY | IORESOURCE_IO
151   -}, {
152   - .name = "pic2",
153   - .start = 0x00a0,
154   - .end = 0x00a1,
155   - .flags = IORESOURCE_BUSY | IORESOURCE_IO
156   -}, {
157   - .name = "dma2",
158   - .start = 0x00c0,
159   - .end = 0x00df,
160   - .flags = IORESOURCE_BUSY | IORESOURCE_IO
161   -}, {
162   - .name = "fpu",
163   - .start = 0x00f0,
164   - .end = 0x00ff,
165   - .flags = IORESOURCE_BUSY | IORESOURCE_IO
166   -} };
167   -
168 94 #define ROMSIGNATURE 0xaa55
169 95  
170 96 static int __init romsignature(const unsigned char *rom)
... ... @@ -260,10 +186,9 @@
260 186 * Request address space for all standard RAM and ROM resources
261 187 * and also for regions reported as reserved by the e820.
262 188 */
263   -static void __init
264   -legacy_init_iomem_resources(struct resource *code_resource,
265   - struct resource *data_resource,
266   - struct resource *bss_resource)
  189 +void __init legacy_init_iomem_resources(struct resource *code_resource,
  190 + struct resource *data_resource,
  191 + struct resource *bss_resource)
267 192 {
268 193 int i;
269 194  
... ... @@ -304,35 +229,6 @@
304 229 }
305 230 }
306 231 }
307   -
308   -/*
309   - * Request address space for all standard resources
310   - *
311   - * This is called just before pcibios_init(), which is also a
312   - * subsys_initcall, but is linked in later (in arch/i386/pci/common.c).
313   - */
314   -static int __init request_standard_resources(void)
315   -{
316   - int i;
317   -
318   - printk("Setting up standard PCI resources\n");
319   - if (efi_enabled)
320   - efi_initialize_iomem_resources(&code_resource,
321   - &data_resource, &bss_resource);
322   - else
323   - legacy_init_iomem_resources(&code_resource,
324   - &data_resource, &bss_resource);
325   -
326   - /* EFI systems may still have VGA */
327   - request_resource(&iomem_resource, &video_ram_resource);
328   -
329   - /* request I/O space for devices used on all i[345]86 PCs */
330   - for (i = 0; i < ARRAY_SIZE(standard_io_resources); i++)
331   - request_resource(&ioport_resource, &standard_io_resources[i]);
332   - return 0;
333   -}
334   -
335   -subsys_initcall(request_standard_resources);
336 232  
337 233 #if defined(CONFIG_PM) && defined(CONFIG_HIBERNATION)
338 234 /**
arch/x86/kernel/e820_64.c
... ... @@ -47,8 +47,6 @@
47 47 */
48 48 static unsigned long __initdata end_user_pfn = MAXMEM>>PAGE_SHIFT;
49 49  
50   -extern struct resource code_resource, data_resource, bss_resource;
51   -
52 50 /* Check for some hardcoded bad areas that early boot is not allowed to touch */
53 51 static inline int bad_addr(unsigned long *addrp, unsigned long size)
54 52 {
... ... @@ -213,7 +211,8 @@
213 211 /*
214 212 * Mark e820 reserved areas as busy for the resource manager.
215 213 */
216   -void __init e820_reserve_resources(void)
  214 +void __init e820_reserve_resources(struct resource *code_resource,
  215 + struct resource *data_resource, struct resource *bss_resource)
217 216 {
218 217 int i;
219 218 for (i = 0; i < e820.nr_map; i++) {
... ... @@ -235,9 +234,9 @@
235 234 * so we try it repeatedly and let the resource manager
236 235 * test it.
237 236 */
238   - request_resource(res, &code_resource);
239   - request_resource(res, &data_resource);
240   - request_resource(res, &bss_resource);
  237 + request_resource(res, code_resource);
  238 + request_resource(res, data_resource);
  239 + request_resource(res, bss_resource);
241 240 #ifdef CONFIG_KEXEC
242 241 if (crashk_res.start != crashk_res.end)
243 242 request_resource(res, &crashk_res);
arch/x86/kernel/setup_32.c
... ... @@ -73,10 +73,81 @@
73 73 /*
74 74 * Machine setup..
75 75 */
76   -extern struct resource code_resource;
77   -extern struct resource data_resource;
78   -extern struct resource bss_resource;
  76 +static struct resource data_resource = {
  77 + .name = "Kernel data",
  78 + .start = 0,
  79 + .end = 0,
  80 + .flags = IORESOURCE_BUSY | IORESOURCE_MEM
  81 +};
79 82  
  83 +static struct resource code_resource = {
  84 + .name = "Kernel code",
  85 + .start = 0,
  86 + .end = 0,
  87 + .flags = IORESOURCE_BUSY | IORESOURCE_MEM
  88 +};
  89 +
  90 +static struct resource bss_resource = {
  91 + .name = "Kernel bss",
  92 + .start = 0,
  93 + .end = 0,
  94 + .flags = IORESOURCE_BUSY | IORESOURCE_MEM
  95 +};
  96 +
  97 +static struct resource video_ram_resource = {
  98 + .name = "Video RAM area",
  99 + .start = 0xa0000,
  100 + .end = 0xbffff,
  101 + .flags = IORESOURCE_BUSY | IORESOURCE_MEM
  102 +};
  103 +
  104 +static struct resource standard_io_resources[] = { {
  105 + .name = "dma1",
  106 + .start = 0x0000,
  107 + .end = 0x001f,
  108 + .flags = IORESOURCE_BUSY | IORESOURCE_IO
  109 +}, {
  110 + .name = "pic1",
  111 + .start = 0x0020,
  112 + .end = 0x0021,
  113 + .flags = IORESOURCE_BUSY | IORESOURCE_IO
  114 +}, {
  115 + .name = "timer0",
  116 + .start = 0x0040,
  117 + .end = 0x0043,
  118 + .flags = IORESOURCE_BUSY | IORESOURCE_IO
  119 +}, {
  120 + .name = "timer1",
  121 + .start = 0x0050,
  122 + .end = 0x0053,
  123 + .flags = IORESOURCE_BUSY | IORESOURCE_IO
  124 +}, {
  125 + .name = "keyboard",
  126 + .start = 0x0060,
  127 + .end = 0x006f,
  128 + .flags = IORESOURCE_BUSY | IORESOURCE_IO
  129 +}, {
  130 + .name = "dma page reg",
  131 + .start = 0x0080,
  132 + .end = 0x008f,
  133 + .flags = IORESOURCE_BUSY | IORESOURCE_IO
  134 +}, {
  135 + .name = "pic2",
  136 + .start = 0x00a0,
  137 + .end = 0x00a1,
  138 + .flags = IORESOURCE_BUSY | IORESOURCE_IO
  139 +}, {
  140 + .name = "dma2",
  141 + .start = 0x00c0,
  142 + .end = 0x00df,
  143 + .flags = IORESOURCE_BUSY | IORESOURCE_IO
  144 +}, {
  145 + .name = "fpu",
  146 + .start = 0x00f0,
  147 + .end = 0x00ff,
  148 + .flags = IORESOURCE_BUSY | IORESOURCE_IO
  149 +} };
  150 +
80 151 /* cpu data as detected by the assembly code in head.S */
81 152 struct cpuinfo_x86 new_cpu_data __cpuinitdata = { 0, 0, 0, 0, -1, 1, 0, 0, -1 };
82 153 /* common cpu data for all cpus */
... ... @@ -693,4 +764,33 @@
693 764 #endif
694 765 #endif
695 766 }
  767 +
  768 +/*
  769 + * Request address space for all standard resources
  770 + *
  771 + * This is called just before pcibios_init(), which is also a
  772 + * subsys_initcall, but is linked in later (in arch/i386/pci/common.c).
  773 + */
  774 +static int __init request_standard_resources(void)
  775 +{
  776 + int i;
  777 +
  778 + printk(KERN_INFO "Setting up standard PCI resources\n");
  779 + if (efi_enabled)
  780 + efi_initialize_iomem_resources(&code_resource,
  781 + &data_resource, &bss_resource);
  782 + else
  783 + legacy_init_iomem_resources(&code_resource,
  784 + &data_resource, &bss_resource);
  785 +
  786 + /* EFI systems may still have VGA */
  787 + request_resource(&iomem_resource, &video_ram_resource);
  788 +
  789 + /* request I/O space for devices used on all i[345]86 PCs */
  790 + for (i = 0; i < ARRAY_SIZE(standard_io_resources); i++)
  791 + request_resource(&ioport_resource, &standard_io_resources[i]);
  792 + return 0;
  793 +}
  794 +
  795 +subsys_initcall(request_standard_resources);
arch/x86/kernel/setup_64.c
... ... @@ -123,19 +123,19 @@
123 123  
124 124 #define IORESOURCE_RAM (IORESOURCE_BUSY | IORESOURCE_MEM)
125 125  
126   -struct resource data_resource = {
  126 +static struct resource data_resource = {
127 127 .name = "Kernel data",
128 128 .start = 0,
129 129 .end = 0,
130 130 .flags = IORESOURCE_RAM,
131 131 };
132   -struct resource code_resource = {
  132 +static struct resource code_resource = {
133 133 .name = "Kernel code",
134 134 .start = 0,
135 135 .end = 0,
136 136 .flags = IORESOURCE_RAM,
137 137 };
138   -struct resource bss_resource = {
  138 +static struct resource bss_resource = {
139 139 .name = "Kernel bss",
140 140 .start = 0,
141 141 .end = 0,
... ... @@ -438,7 +438,7 @@
438 438 /*
439 439 * We trust e820 completely. No explicit ROM probing in memory.
440 440 */
441   - e820_reserve_resources();
  441 + e820_reserve_resources(&code_resource, &data_resource, &bss_resource);
442 442 e820_mark_nosave_regions();
443 443  
444 444 {
include/asm-x86/e820_32.h
... ... @@ -12,6 +12,8 @@
12 12 #ifndef __E820_HEADER
13 13 #define __E820_HEADER
14 14  
  15 +#include <linux/ioport.h>
  16 +
15 17 #define HIGH_MEMORY (1024*1024)
16 18  
17 19 #ifndef __ASSEMBLY__
... ... @@ -26,6 +28,9 @@
26 28 extern void e820_register_memory(void);
27 29 extern void limit_regions(unsigned long long size);
28 30 extern void print_memory_map(char *who);
  31 +extern void legacy_init_iomem_resources(struct resource *code_resource,
  32 + struct resource *data_resource,
  33 + struct resource *bss_resource);
29 34  
30 35 #if defined(CONFIG_PM) && defined(CONFIG_HIBERNATION)
31 36 extern void e820_mark_nosave_regions(void);
... ... @@ -34,6 +39,7 @@
34 39 {
35 40 }
36 41 #endif
  42 +
37 43  
38 44 #endif/*!__ASSEMBLY__*/
39 45 #endif/*__E820_HEADER*/
include/asm-x86/e820_64.h
... ... @@ -11,6 +11,8 @@
11 11 #ifndef __E820_HEADER
12 12 #define __E820_HEADER
13 13  
  14 +#include <linux/ioport.h>
  15 +
14 16 #ifndef __ASSEMBLY__
15 17 extern unsigned long find_e820_area(unsigned long start, unsigned long end,
16 18 unsigned size);
... ... @@ -19,7 +21,8 @@
19 21 extern void setup_memory_region(void);
20 22 extern void contig_e820_setup(void);
21 23 extern unsigned long e820_end_of_ram(void);
22   -extern void e820_reserve_resources(void);
  24 +extern void e820_reserve_resources(struct resource *code_resource,
  25 + struct resource *data_resource, struct resource *bss_resource);
23 26 extern void e820_mark_nosave_regions(void);
24 27 extern int e820_any_mapped(unsigned long start, unsigned long end, unsigned type);
25 28 extern int e820_all_mapped(unsigned long start, unsigned long end, unsigned type);
include/linux/ioport.h
... ... @@ -8,6 +8,7 @@
8 8 #ifndef _LINUX_IOPORT_H
9 9 #define _LINUX_IOPORT_H
10 10  
  11 +#ifndef __ASSEMBLY__
11 12 #include <linux/compiler.h>
12 13 #include <linux/types.h>
13 14 /*
... ... @@ -153,5 +154,6 @@
153 154 extern void __devm_release_region(struct device *dev, struct resource *parent,
154 155 resource_size_t start, resource_size_t n);
155 156  
  157 +#endif /* __ASSEMBLY__ */
156 158 #endif /* _LINUX_IOPORT_H */