b7e4024f5de31891a480064dd4e41a5631a22811
[coreboot.git] / src / arch / i386 / boot / tables.c
1 #include <console/console.h>
2 #include <mem.h>
3 #include <cpu/cpu.h>
4 #include <boot/tables.h>
5 #include <boot/linuxbios_tables.h>
6 #include <arch/pirq_routing.h>
7 #include <arch/smp/mpspec.h>
8 #include <arch/acpi.h>
9 #include "linuxbios_table.h"
10
11 #if CONFIG_SMP && CONFIG_MAX_PHYSICAL_CPUS && (CONFIG_MAX_PHYSICAL_CPUS < CONFIG_MAX_CPUS)
12 static void remove_logical_cpus(unsigned long *processor_map)
13 {
14         /* To turn off hyperthreading just remove the logical
15          * cpus from the processor map.
16          */
17         int disable_logical_cpus = !CONFIG_LOGICAL_CPUS;
18         if (get_option(&disable_logical_cpus,"hyper_threading")) {
19                 disable_logical_cpus = !CONFIG_LOGICAL_CPUS;
20         }
21         if (disable_logical_cpus) {
22                 /* disable logical cpus */
23                 int cnt;
24                 for(cnt=CONFIG_MAX_PHYSICAL_CPUS;cnt<CONFIG_MAX_CPUS;cnt++)
25                         processor_map[cnt]=0;
26                 printk_debug("logical cpus disabled\n");
27         }
28 }
29 #else
30
31 #define remove_logical_cpus(processor_map) do {} while(0) 
32
33 #endif /* CONFIG_SMP && CONFIG_MAX_PHYSICAL_CPUS */
34
35 struct lb_memory *write_tables(struct mem_range *mem, unsigned long *processor_map)
36 {
37         unsigned long low_table_start, low_table_end;
38         unsigned long rom_table_start, rom_table_end;
39
40         rom_table_start = 0xf0000;
41         rom_table_end =   0xf0000;
42         /* Start low addr at 16 bytes instead of 0 because of a buglet
43          * in the generic linux unzip code, as it tests for the a20 line.
44          */
45         low_table_start = 0;
46         low_table_end = 16;
47
48         post_code(0x9a);
49         check_pirq_routing_table();
50
51         /* This table must be betweeen 0xf0000 & 0x100000 */
52         rom_table_end = copy_pirq_routing_table(rom_table_end);
53         rom_table_end = (rom_table_end + 1023) & ~1023;
54
55         /* copy the smp block to address 0 */
56         post_code(0x96);
57
58         /* The smp table must be in 0-1K, 639K-640K, or 960K-1M */
59         remove_logical_cpus(processor_map);
60         low_table_end = write_smp_table(low_table_end, processor_map);
61
62         /* Write ACPI tables */
63         low_table_end = write_acpi_tables(low_table_end);
64         
65         /* Don't write anything in the traditional x86 BIOS data segment */
66         if (low_table_end < 0x500) {
67                 low_table_end = 0x500;
68         }
69
70         /* The linuxbios table must be in 0-4K or 960K-1M */
71         write_linuxbios_table(processor_map, mem,
72                               low_table_start, low_table_end,
73                               rom_table_start >> 10, rom_table_end >> 10);
74
75         return get_lb_mem();
76 }