Commit 42fd8c19b58fe8f8fe7559ea53b1cef12fc06240

Authored by Simon Glass
Committed by Bin Meng
1 parent 0ec28e0266

x86: Use unsigned long for address in table generation

We should use unsigned long rather than u32 for addresses. Update this so
that the table-generation code builds correctly on 64-bit machines.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>

Showing 13 changed files with 29 additions and 36 deletions Side-by-side Diff

... ... @@ -264,7 +264,7 @@
264 264 return irq_router_common_init(dev);
265 265 }
266 266  
267   -u32 write_pirq_routing_table(u32 addr)
  267 +ulong write_pirq_routing_table(ulong addr)
268 268 {
269 269 if (!pirq_routing_table)
270 270 return addr;
arch/x86/include/asm/acpi_table.h
... ... @@ -316,5 +316,5 @@
316 316 u8 cpu, u16 flags, u8 lint);
317 317 u32 acpi_fill_madt(u32 current);
318 318 void acpi_create_gnvs(struct acpi_global_nvs *gnvs);
319   -u32 write_acpi_tables(u32 start);
  319 +ulong write_acpi_tables(ulong start);
arch/x86/include/asm/mpspec.h
... ... @@ -456,7 +456,7 @@
456 456 * @addr: start address to write MP table
457 457 * @return: end address of MP table
458 458 */
459   -u32 write_mp_table(u32 addr);
  459 +ulong write_mp_table(ulong addr);
460 460  
461 461 #endif /* __ASM_MPSPEC_H */
arch/x86/include/asm/sfi.h
... ... @@ -132,7 +132,7 @@
132 132 * @base: Address to write table to
133 133 * @return address to use for the next table
134 134 */
135   -u32 write_sfi_table(u32 base);
  135 +ulong write_sfi_table(ulong base);
136 136  
137 137 #endif /*_LINUX_SFI_H */
arch/x86/include/asm/tables.h
... ... @@ -65,7 +65,7 @@
65 65 * @start: start address to write PIRQ routing table
66 66 * @return: end address of PIRQ routing table
67 67 */
68   -u32 write_pirq_routing_table(u32 start);
  68 +ulong write_pirq_routing_table(ulong start);
69 69  
70 70 #endif /* _X86_TABLES_H_ */
arch/x86/lib/acpi_table.c
... ... @@ -327,7 +327,7 @@
327 327 * QEMU's version of write_acpi_tables is defined in
328 328 * arch/x86/cpu/qemu/acpi_table.c
329 329 */
330   -u32 write_acpi_tables(u32 start)
  330 +ulong write_acpi_tables(ulong start)
331 331 {
332 332 u32 current;
333 333 struct acpi_rsdp *rsdp;
... ... @@ -345,7 +345,7 @@
345 345 /* Align ACPI tables to 16 byte */
346 346 current = ALIGN(current, 16);
347 347  
348   - debug("ACPI: Writing ACPI tables at %x\n", start);
  348 + debug("ACPI: Writing ACPI tables at %lx\n", start);
349 349  
350 350 /* We need at least an RSDP and an RSDT Table */
351 351 rsdp = (struct acpi_rsdp *)current;
arch/x86/lib/mpspec.c
... ... @@ -365,7 +365,7 @@
365 365 bus_isa, 0, MP_APIC_ALL, 1);
366 366 }
367 367  
368   -u32 write_mp_table(u32 addr)
  368 +ulong write_mp_table(ulong addr)
369 369 {
370 370 struct mp_config_table *mc;
371 371 int ioapic_id, ioapic_ver;
... ... @@ -38,14 +38,14 @@
38 38 tab->table[tab->count] = tab->entry_start;
39 39 tab->entry_start += sizeof(struct sfi_table_header);
40 40  
41   - return (void *)tab->entry_start;
  41 + return (void *)(uintptr_t)tab->entry_start;
42 42 }
43 43  
44 44 static void finish_table(struct table_info *tab, const char *sig, void *entry)
45 45 {
46 46 struct sfi_table_header *hdr;
47 47  
48   - hdr = (struct sfi_table_header *)(tab->base + tab->ptr);
  48 + hdr = (struct sfi_table_header *)(uintptr_t)(tab->base + tab->ptr);
49 49 strcpy(hdr->sig, sig);
50 50 hdr->len = sizeof(*hdr) + ((ulong)entry - tab->entry_start);
51 51 hdr->rev = 1;
... ... @@ -131,7 +131,7 @@
131 131 return 0;
132 132 }
133 133  
134   -u32 write_sfi_table(u32 base)
  134 +ulong write_sfi_table(ulong base)
135 135 {
136 136 struct table_info table;
137 137  
arch/x86/lib/tables.c
... ... @@ -12,20 +12,13 @@
12 12 #include <asm/acpi_table.h>
13 13 #include <asm/coreboot_tables.h>
14 14  
15   -#ifdef CONFIG_GENERATE_SMBIOS_TABLE
16   -static u32 write_smbios_table_wrapper(u32 addr)
17   -{
18   - return write_smbios_table(addr);
19   -}
20   -#endif
21   -
22 15 /**
23 16 * Function prototype to write a specific configuration table
24 17 *
25 18 * @addr: start address to write the table
26 19 * @return: end address of the table
27 20 */
28   -typedef u32 (*table_write)(u32 addr);
  21 +typedef ulong (*table_write)(ulong addr);
29 22  
30 23 static table_write table_write_funcs[] = {
31 24 #ifdef CONFIG_GENERATE_PIRQ_TABLE
... ... @@ -41,7 +34,7 @@
41 34 write_acpi_tables,
42 35 #endif
43 36 #ifdef CONFIG_GENERATE_SMBIOS_TABLE
44   - write_smbios_table_wrapper,
  37 + write_smbios_table,
45 38 #endif
46 39 };
47 40  
arch/x86/lib/zimage.c
... ... @@ -165,7 +165,7 @@
165 165 * A very old kernel MUST have its real-mode code
166 166 * loaded at 0x90000
167 167 */
168   - if ((u32)setup_base != 0x90000) {
  168 + if ((ulong)setup_base != 0x90000) {
169 169 /* Copy the real-mode kernel */
170 170 memmove((void *)0x90000, setup_base, setup_size);
171 171  
... ... @@ -32,7 +32,7 @@
32 32 * be ignored.
33 33 * @return: 0 on success, or negative value on failure
34 34 */
35   -static int bios_linker_allocate(struct bios_linker_entry *entry, u32 *addr)
  35 +static int bios_linker_allocate(struct bios_linker_entry *entry, ulong *addr)
36 36 {
37 37 uint32_t size, align;
38 38 struct fw_file *file;
... ... @@ -147,7 +147,7 @@
147 147 }
148 148  
149 149 /* This function loads and patches ACPI tables provided by QEMU */
150   -u32 write_acpi_tables(u32 addr)
  150 +ulong write_acpi_tables(ulong addr)
151 151 {
152 152 int i, ret = 0;
153 153 struct fw_file *file;
... ... @@ -225,7 +225,7 @@
225 225 * @handle: the structure's handle, a unique 16-bit number
226 226 * @return: size of the structure
227 227 */
228   -typedef int (*smbios_write_type)(uintptr_t *addr, int handle);
  228 +typedef int (*smbios_write_type)(ulong *addr, int handle);
229 229  
230 230 /**
231 231 * write_smbios_table() - Write SMBIOS table
... ... @@ -235,7 +235,7 @@
235 235 * @addr: start address to write SMBIOS table
236 236 * @return: end address of SMBIOS table
237 237 */
238   -uintptr_t write_smbios_table(uintptr_t addr);
  238 +ulong write_smbios_table(ulong addr);
239 239  
240 240 #endif /* _SMBIOS_H_ */
... ... @@ -73,7 +73,7 @@
73 73 return len + 1;
74 74 }
75 75  
76   -static int smbios_write_type0(uintptr_t *current, int handle)
  76 +static int smbios_write_type0(ulong *current, int handle)
77 77 {
78 78 struct smbios_type0 *t = (struct smbios_type0 *)*current;
79 79 int len = sizeof(struct smbios_type0);
... ... @@ -108,7 +108,7 @@
108 108 return len;
109 109 }
110 110  
111   -static int smbios_write_type1(uintptr_t *current, int handle)
  111 +static int smbios_write_type1(ulong *current, int handle)
112 112 {
113 113 struct smbios_type1 *t = (struct smbios_type1 *)*current;
114 114 int len = sizeof(struct smbios_type1);
... ... @@ -129,7 +129,7 @@
129 129 return len;
130 130 }
131 131  
132   -static int smbios_write_type2(uintptr_t *current, int handle)
  132 +static int smbios_write_type2(ulong *current, int handle)
133 133 {
134 134 struct smbios_type2 *t = (struct smbios_type2 *)*current;
135 135 int len = sizeof(struct smbios_type2);
... ... @@ -147,7 +147,7 @@
147 147 return len;
148 148 }
149 149  
150   -static int smbios_write_type3(uintptr_t *current, int handle)
  150 +static int smbios_write_type3(ulong *current, int handle)
151 151 {
152 152 struct smbios_type3 *t = (struct smbios_type3 *)*current;
153 153 int len = sizeof(struct smbios_type3);
... ... @@ -199,7 +199,7 @@
199 199 t->processor_version = smbios_add_string(t->eos, name);
200 200 }
201 201  
202   -static int smbios_write_type4(uintptr_t *current, int handle)
  202 +static int smbios_write_type4(ulong *current, int handle)
203 203 {
204 204 struct smbios_type4 *t = (struct smbios_type4 *)*current;
205 205 int len = sizeof(struct smbios_type4);
... ... @@ -221,7 +221,7 @@
221 221 return len;
222 222 }
223 223  
224   -static int smbios_write_type32(uintptr_t *current, int handle)
  224 +static int smbios_write_type32(ulong *current, int handle)
225 225 {
226 226 struct smbios_type32 *t = (struct smbios_type32 *)*current;
227 227 int len = sizeof(struct smbios_type32);
... ... @@ -234,7 +234,7 @@
234 234 return len;
235 235 }
236 236  
237   -static int smbios_write_type127(uintptr_t *current, int handle)
  237 +static int smbios_write_type127(ulong *current, int handle)
238 238 {
239 239 struct smbios_type127 *t = (struct smbios_type127 *)*current;
240 240 int len = sizeof(struct smbios_type127);
241 241  
... ... @@ -257,10 +257,10 @@
257 257 smbios_write_type127
258 258 };
259 259  
260   -uintptr_t write_smbios_table(uintptr_t addr)
  260 +ulong write_smbios_table(ulong addr)
261 261 {
262 262 struct smbios_entry *se;
263   - u32 tables;
  263 + ulong tables;
264 264 int len = 0;
265 265 int max_struct_size = 0;
266 266 int handle = 0;
... ... @@ -271,7 +271,7 @@
271 271 /* 16 byte align the table address */
272 272 addr = ALIGN(addr, 16);
273 273  
274   - se = (struct smbios_entry *)addr;
  274 + se = (struct smbios_entry *)(uintptr_t)addr;
275 275 memset(se, 0, sizeof(struct smbios_entry));
276 276  
277 277 addr += sizeof(struct smbios_entry);
... ... @@ -280,7 +280,7 @@
280 280  
281 281 /* populate minimum required tables */
282 282 for (i = 0; i < ARRAY_SIZE(smbios_write_funcs); i++) {
283   - int tmp = smbios_write_funcs[i](&addr, handle++);
  283 + int tmp = smbios_write_funcs[i]((ulong *)&addr, handle++);
284 284 max_struct_size = max(max_struct_size, tmp);
285 285 len += tmp;
286 286 }