aboutsummaryrefslogtreecommitdiffstats
path: root/arch/i386/kernel/setup.c
diff options
context:
space:
mode:
authorDmitry Torokhov <dtor_core@ameritech.net>2006-04-02 00:08:05 -0500
committerDmitry Torokhov <dtor_core@ameritech.net>2006-04-02 00:08:05 -0500
commit95d465fd750897ab32462a6702fbfe1b122cbbc0 (patch)
tree65c38b2f11c51bb6932e44dd6c92f15b0091abfe /arch/i386/kernel/setup.c
parent642fde17dceceb56c7ba2762733ac688666ae657 (diff)
parent683aa4012f53b2ada0f430487e05d37b0d94e90a (diff)
Manual merge with Linus.
Conflicts: arch/powerpc/kernel/setup-common.c drivers/input/keyboard/hil_kbd.c drivers/input/mouse/hil_ptr.c
Diffstat (limited to 'arch/i386/kernel/setup.c')
-rw-r--r--arch/i386/kernel/setup.c149
1 files changed, 31 insertions, 118 deletions
diff --git a/arch/i386/kernel/setup.c b/arch/i386/kernel/setup.c
index a0b407585679..eacc3f0a2ea4 100644
--- a/arch/i386/kernel/setup.c
+++ b/arch/i386/kernel/setup.c
@@ -47,6 +47,7 @@
47#include <linux/kexec.h> 47#include <linux/kexec.h>
48#include <linux/crash_dump.h> 48#include <linux/crash_dump.h>
49#include <linux/dmi.h> 49#include <linux/dmi.h>
50#include <linux/pfn.h>
50 51
51#include <video/edid.h> 52#include <video/edid.h>
52 53
@@ -1059,10 +1060,10 @@ static int __init
1059free_available_memory(unsigned long start, unsigned long end, void *arg) 1060free_available_memory(unsigned long start, unsigned long end, void *arg)
1060{ 1061{
1061 /* check max_low_pfn */ 1062 /* check max_low_pfn */
1062 if (start >= ((max_low_pfn + 1) << PAGE_SHIFT)) 1063 if (start >= (max_low_pfn << PAGE_SHIFT))
1063 return 0; 1064 return 0;
1064 if (end >= ((max_low_pfn + 1) << PAGE_SHIFT)) 1065 if (end >= (max_low_pfn << PAGE_SHIFT))
1065 end = (max_low_pfn + 1) << PAGE_SHIFT; 1066 end = max_low_pfn << PAGE_SHIFT;
1066 if (start < end) 1067 if (start < end)
1067 free_bootmem(start, end - start); 1068 free_bootmem(start, end - start);
1068 1069
@@ -1287,9 +1288,7 @@ legacy_init_iomem_resources(struct resource *code_resource, struct resource *dat
1287 probe_roms(); 1288 probe_roms();
1288 for (i = 0; i < e820.nr_map; i++) { 1289 for (i = 0; i < e820.nr_map; i++) {
1289 struct resource *res; 1290 struct resource *res;
1290 if (e820.map[i].addr + e820.map[i].size > 0x100000000ULL) 1291 res = kzalloc(sizeof(struct resource), GFP_ATOMIC);
1291 continue;
1292 res = alloc_bootmem_low(sizeof(struct resource));
1293 switch (e820.map[i].type) { 1292 switch (e820.map[i].type) {
1294 case E820_RAM: res->name = "System RAM"; break; 1293 case E820_RAM: res->name = "System RAM"; break;
1295 case E820_ACPI: res->name = "ACPI Tables"; break; 1294 case E820_ACPI: res->name = "ACPI Tables"; break;
@@ -1317,13 +1316,15 @@ legacy_init_iomem_resources(struct resource *code_resource, struct resource *dat
1317 1316
1318/* 1317/*
1319 * Request address space for all standard resources 1318 * Request address space for all standard resources
1319 *
1320 * This is called just before pcibios_assign_resources(), which is also
1321 * an fs_initcall, but is linked in later (in arch/i386/pci/i386.c).
1320 */ 1322 */
1321static void __init register_memory(void) 1323static int __init request_standard_resources(void)
1322{ 1324{
1323 unsigned long gapstart, gapsize, round; 1325 int i;
1324 unsigned long long last;
1325 int i;
1326 1326
1327 printk("Setting up standard PCI resources\n");
1327 if (efi_enabled) 1328 if (efi_enabled)
1328 efi_initialize_iomem_resources(&code_resource, &data_resource); 1329 efi_initialize_iomem_resources(&code_resource, &data_resource);
1329 else 1330 else
@@ -1335,6 +1336,16 @@ static void __init register_memory(void)
1335 /* request I/O space for devices used on all i[345]86 PCs */ 1336 /* request I/O space for devices used on all i[345]86 PCs */
1336 for (i = 0; i < STANDARD_IO_RESOURCES; i++) 1337 for (i = 0; i < STANDARD_IO_RESOURCES; i++)
1337 request_resource(&ioport_resource, &standard_io_resources[i]); 1338 request_resource(&ioport_resource, &standard_io_resources[i]);
1339 return 0;
1340}
1341
1342fs_initcall(request_standard_resources);
1343
1344static void __init register_memory(void)
1345{
1346 unsigned long gapstart, gapsize, round;
1347 unsigned long long last;
1348 int i;
1338 1349
1339 /* 1350 /*
1340 * Search for the bigest gap in the low 32 bits of the e820 1351 * Search for the bigest gap in the low 32 bits of the e820
@@ -1378,101 +1389,6 @@ static void __init register_memory(void)
1378 pci_mem_start, gapstart, gapsize); 1389 pci_mem_start, gapstart, gapsize);
1379} 1390}
1380 1391
1381/* Use inline assembly to define this because the nops are defined
1382 as inline assembly strings in the include files and we cannot
1383 get them easily into strings. */
1384asm("\t.data\nintelnops: "
1385 GENERIC_NOP1 GENERIC_NOP2 GENERIC_NOP3 GENERIC_NOP4 GENERIC_NOP5 GENERIC_NOP6
1386 GENERIC_NOP7 GENERIC_NOP8);
1387asm("\t.data\nk8nops: "
1388 K8_NOP1 K8_NOP2 K8_NOP3 K8_NOP4 K8_NOP5 K8_NOP6
1389 K8_NOP7 K8_NOP8);
1390asm("\t.data\nk7nops: "
1391 K7_NOP1 K7_NOP2 K7_NOP3 K7_NOP4 K7_NOP5 K7_NOP6
1392 K7_NOP7 K7_NOP8);
1393
1394extern unsigned char intelnops[], k8nops[], k7nops[];
1395static unsigned char *intel_nops[ASM_NOP_MAX+1] = {
1396 NULL,
1397 intelnops,
1398 intelnops + 1,
1399 intelnops + 1 + 2,
1400 intelnops + 1 + 2 + 3,
1401 intelnops + 1 + 2 + 3 + 4,
1402 intelnops + 1 + 2 + 3 + 4 + 5,
1403 intelnops + 1 + 2 + 3 + 4 + 5 + 6,
1404 intelnops + 1 + 2 + 3 + 4 + 5 + 6 + 7,
1405};
1406static unsigned char *k8_nops[ASM_NOP_MAX+1] = {
1407 NULL,
1408 k8nops,
1409 k8nops + 1,
1410 k8nops + 1 + 2,
1411 k8nops + 1 + 2 + 3,
1412 k8nops + 1 + 2 + 3 + 4,
1413 k8nops + 1 + 2 + 3 + 4 + 5,
1414 k8nops + 1 + 2 + 3 + 4 + 5 + 6,
1415 k8nops + 1 + 2 + 3 + 4 + 5 + 6 + 7,
1416};
1417static unsigned char *k7_nops[ASM_NOP_MAX+1] = {
1418 NULL,
1419 k7nops,
1420 k7nops + 1,
1421 k7nops + 1 + 2,
1422 k7nops + 1 + 2 + 3,
1423 k7nops + 1 + 2 + 3 + 4,
1424 k7nops + 1 + 2 + 3 + 4 + 5,
1425 k7nops + 1 + 2 + 3 + 4 + 5 + 6,
1426 k7nops + 1 + 2 + 3 + 4 + 5 + 6 + 7,
1427};
1428static struct nop {
1429 int cpuid;
1430 unsigned char **noptable;
1431} noptypes[] = {
1432 { X86_FEATURE_K8, k8_nops },
1433 { X86_FEATURE_K7, k7_nops },
1434 { -1, NULL }
1435};
1436
1437/* Replace instructions with better alternatives for this CPU type.
1438
1439 This runs before SMP is initialized to avoid SMP problems with
1440 self modifying code. This implies that assymetric systems where
1441 APs have less capabilities than the boot processor are not handled.
1442 Tough. Make sure you disable such features by hand. */
1443void apply_alternatives(void *start, void *end)
1444{
1445 struct alt_instr *a;
1446 int diff, i, k;
1447 unsigned char **noptable = intel_nops;
1448 for (i = 0; noptypes[i].cpuid >= 0; i++) {
1449 if (boot_cpu_has(noptypes[i].cpuid)) {
1450 noptable = noptypes[i].noptable;
1451 break;
1452 }
1453 }
1454 for (a = start; (void *)a < end; a++) {
1455 if (!boot_cpu_has(a->cpuid))
1456 continue;
1457 BUG_ON(a->replacementlen > a->instrlen);
1458 memcpy(a->instr, a->replacement, a->replacementlen);
1459 diff = a->instrlen - a->replacementlen;
1460 /* Pad the rest with nops */
1461 for (i = a->replacementlen; diff > 0; diff -= k, i += k) {
1462 k = diff;
1463 if (k > ASM_NOP_MAX)
1464 k = ASM_NOP_MAX;
1465 memcpy(a->instr + i, noptable[k], k);
1466 }
1467 }
1468}
1469
1470void __init alternative_instructions(void)
1471{
1472 extern struct alt_instr __alt_instructions[], __alt_instructions_end[];
1473 apply_alternatives(__alt_instructions, __alt_instructions_end);
1474}
1475
1476static char * __init machine_specific_memory_setup(void); 1392static char * __init machine_specific_memory_setup(void);
1477 1393
1478#ifdef CONFIG_MCA 1394#ifdef CONFIG_MCA
@@ -1555,6 +1471,16 @@ void __init setup_arch(char **cmdline_p)
1555 1471
1556 parse_cmdline_early(cmdline_p); 1472 parse_cmdline_early(cmdline_p);
1557 1473
1474#ifdef CONFIG_EARLY_PRINTK
1475 {
1476 char *s = strstr(*cmdline_p, "earlyprintk=");
1477 if (s) {
1478 setup_early_printk(strchr(s, '=') + 1);
1479 printk("early console enabled\n");
1480 }
1481 }
1482#endif
1483
1558 max_low_pfn = setup_memory(); 1484 max_low_pfn = setup_memory();
1559 1485
1560 /* 1486 /*
@@ -1579,19 +1505,6 @@ void __init setup_arch(char **cmdline_p)
1579 * NOTE: at this point the bootmem allocator is fully available. 1505 * NOTE: at this point the bootmem allocator is fully available.
1580 */ 1506 */
1581 1507
1582#ifdef CONFIG_EARLY_PRINTK
1583 {
1584 char *s = strstr(*cmdline_p, "earlyprintk=");
1585 if (s) {
1586 extern void setup_early_printk(char *);
1587
1588 setup_early_printk(strchr(s, '=') + 1);
1589 printk("early console enabled\n");
1590 }
1591 }
1592#endif
1593
1594
1595 dmi_scan_machine(); 1508 dmi_scan_machine();
1596 1509
1597#ifdef CONFIG_X86_GENERICARCH 1510#ifdef CONFIG_X86_GENERICARCH