Skip to content

Commit

Permalink
[PATCH] Convert x86-64 to early param
Browse files Browse the repository at this point in the history
Instead of hackish manual parsing

Requires earlier i386 patchkit, but also fixes i386 early_printk again.

I removed some obsolete really early parameters which didn't do anything useful.
Also made a few parameters that needed it early (mostly oops printing setup)

Also removed one panic check that wasn't visible without
early console anyways (the early console is now initialized after that
panic)

This cleans up a lot of code.

Signed-off-by: Andi Kleen <ak@suse.de>
  • Loading branch information
Andi Kleen authored and Andi Kleen committed Sep 26, 2006
1 parent 1a3f239 commit 2c8c0e6
Show file tree
Hide file tree
Showing 16 changed files with 159 additions and 275 deletions.
34 changes: 19 additions & 15 deletions arch/x86_64/kernel/apic.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
#include <asm/idle.h>
#include <asm/proto.h>
#include <asm/timex.h>
#include <asm/apic.h>

int apic_verbosity;
int apic_runs_main_timer;
Expand Down Expand Up @@ -546,18 +547,24 @@ static void apic_pm_activate(void) { }

static int __init apic_set_verbosity(char *str)
{
if (str == NULL) {
skip_ioapic_setup = 0;
ioapic_force = 1;
return 0;
}
if (strcmp("debug", str) == 0)
apic_verbosity = APIC_DEBUG;
else if (strcmp("verbose", str) == 0)
apic_verbosity = APIC_VERBOSE;
else
else {
printk(KERN_WARNING "APIC Verbosity level %s not recognised"
" use apic=verbose or apic=debug", str);
" use apic=verbose or apic=debug\n", str);
return -EINVAL;
}

return 1;
return 0;
}

__setup("apic=", apic_set_verbosity);
early_param("apic", apic_set_verbosity);

/*
* Detect and enable local APICs on non-SMP boards.
Expand Down Expand Up @@ -1078,14 +1085,17 @@ int __init APIC_init_uniprocessor (void)
static __init int setup_disableapic(char *str)
{
disable_apic = 1;
return 1;
}
clear_bit(X86_FEATURE_APIC, boot_cpu_data.x86_capability);
return 0;
}
early_param("disableapic", setup_disableapic);

/* same as disableapic, for compatibility */
static __init int setup_nolapic(char *str)
{
disable_apic = 1;
return 1;
return setup_disableapic(str);
}
early_param("nolapic", setup_nolapic);

static __init int setup_noapictimer(char *str)
{
Expand Down Expand Up @@ -1118,11 +1128,5 @@ static __init int setup_apicpmtimer(char *s)
}
__setup("apicpmtimer", setup_apicpmtimer);

/* dummy parsing: see setup.c */

__setup("disableapic", setup_disableapic);
__setup("nolapic", setup_nolapic); /* same as disableapic, for compatibility */

__setup("noapictimer", setup_noapictimer);

/* no "lapic" flag - we only use the lapic when the BIOS tells us so. */
53 changes: 43 additions & 10 deletions arch/x86_64/kernel/e820.c
Original file line number Diff line number Diff line change
Expand Up @@ -596,31 +596,64 @@ void __init setup_memory_region(void)
e820_print_map(who);
}

void __init parse_memopt(char *p, char **from)
{
end_user_pfn = memparse(p, from);
static int __init parse_memopt(char *p)
{
if (!p)
return -EINVAL;
end_user_pfn = memparse(p, &p);
end_user_pfn >>= PAGE_SHIFT;
return 0;
}
early_param("mem", parse_memopt);

static int userdef __initdata;

void __init parse_memmapopt(char *p, char **from)
static int __init parse_memmap_opt(char *p)
{
char *oldp;
unsigned long long start_at, mem_size;

mem_size = memparse(p, from);
p = *from;
if (!strcmp(p, "exactmap")) {
#ifdef CONFIG_CRASH_DUMP
/* If we are doing a crash dump, we
* still need to know the real mem
* size before original memory map is
* reset.
*/
saved_max_pfn = e820_end_of_ram();
#endif
end_pfn_map = 0;
e820.nr_map = 0;
userdef = 1;
return 0;
}

oldp = p;
mem_size = memparse(p, &p);
if (p == oldp)
return -EINVAL;
if (*p == '@') {
start_at = memparse(p+1, from);
start_at = memparse(p+1, &p);
add_memory_region(start_at, mem_size, E820_RAM);
} else if (*p == '#') {
start_at = memparse(p+1, from);
start_at = memparse(p+1, &p);
add_memory_region(start_at, mem_size, E820_ACPI);
} else if (*p == '$') {
start_at = memparse(p+1, from);
start_at = memparse(p+1, &p);
add_memory_region(start_at, mem_size, E820_RESERVED);
} else {
end_user_pfn = (mem_size >> PAGE_SHIFT);
}
p = *from;
return *p == '\0' ? 0 : -EINVAL;
}
early_param("memmap", parse_memmap_opt);

void finish_e820_parsing(void)
{
if (userdef) {
printk(KERN_INFO "user-defined physical RAM map:\n");
e820_print_map("user");
}
}

unsigned long pci_mem_start = 0xaeedbabe;
Expand Down
20 changes: 8 additions & 12 deletions arch/x86_64/kernel/early_printk.c
Original file line number Diff line number Diff line change
Expand Up @@ -215,20 +215,16 @@ void early_printk(const char *fmt, ...)

static int __initdata keep_early;

int __init setup_early_printk(char *opt)
static int __init setup_early_printk(char *buf)
{
char *space;
char buf[256];
if (!buf)
return 0;

if (early_console_initialized)
return 1;

strlcpy(buf,opt,sizeof(buf));
space = strchr(buf, ' ');
if (space)
*space = 0;
return 0;
early_console_initialized = 1;

if (strstr(buf,"keep"))
if (!strcmp(buf,"keep"))
keep_early = 1;

if (!strncmp(buf, "serial", 6)) {
Expand All @@ -248,11 +244,12 @@ int __init setup_early_printk(char *opt)
early_console = &simnow_console;
keep_early = 1;
}
early_console_initialized = 1;
register_console(early_console);
return 0;
}

early_param("earlyprintk", setup_early_printk);

void __init disable_early_printk(void)
{
if (!early_console_initialized || !early_console)
Expand All @@ -266,4 +263,3 @@ void __init disable_early_printk(void)
}
}

__setup("earlyprintk=", setup_early_printk);
15 changes: 0 additions & 15 deletions arch/x86_64/kernel/head64.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ static void __init copy_bootdata(char *real_mode_data)

void __init x86_64_start_kernel(char * real_mode_data)
{
char *s;
int i;

for (i = 0; i < 256; i++)
Expand All @@ -85,19 +84,5 @@ void __init x86_64_start_kernel(char * real_mode_data)
#ifdef CONFIG_SMP
cpu_set(0, cpu_online_map);
#endif
s = strstr(saved_command_line, "earlyprintk=");
if (s != NULL)
setup_early_printk(strchr(s, '=') + 1);
#ifdef CONFIG_NUMA
s = strstr(saved_command_line, "numa=");
if (s != NULL)
numa_setup(s+5);
#endif
if (strstr(saved_command_line, "disableapic"))
disable_apic = 1;
/* You need early console to see that */
if (__pa_symbol(&_end) >= KERNEL_TEXT_SIZE)
panic("Kernel too big for kernel mapping\n");

start_kernel();
}
15 changes: 7 additions & 8 deletions arch/x86_64/kernel/io_apic.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ int sis_apic_bug; /* not actually supported, dummy for compile */

static int no_timer_check;

int disable_timer_pin_1 __initdata;
static int disable_timer_pin_1 __initdata;

int timer_over_8254 __initdata = 0;

Expand Down Expand Up @@ -253,18 +253,17 @@ int ioapic_force;
static int __init disable_ioapic_setup(char *str)
{
skip_ioapic_setup = 1;
return 1;
return 0;
}
early_param("noapic", disable_ioapic_setup);

static int __init enable_ioapic_setup(char *str)
/* Actually the next is obsolete, but keep it for paranoid reasons -AK */
static int __init disable_timer_pin_setup(char *arg)
{
ioapic_force = 1;
skip_ioapic_setup = 0;
disable_timer_pin_1 = 1;
return 1;
}

__setup("noapic", disable_ioapic_setup);
__setup("apic", enable_ioapic_setup);
__setup("disable_timer_pin_1", disable_timer_pin_setup);

static int __init setup_disable_8254_timer(char *s)
{
Expand Down
28 changes: 28 additions & 0 deletions arch/x86_64/kernel/machine_kexec.c
Original file line number Diff line number Diff line change
Expand Up @@ -226,3 +226,31 @@ NORET_TYPE void machine_kexec(struct kimage *image)
rnk = (relocate_new_kernel_t) control_code_buffer;
(*rnk)(page_list, control_code_buffer, image->start, start_pgtable);
}

/* crashkernel=size@addr specifies the location to reserve for
* a crash kernel. By reserving this memory we guarantee
* that linux never set's it up as a DMA target.
* Useful for holding code to do something appropriate
* after a kernel panic.
*/
static int __init setup_crashkernel(char *arg)
{
unsigned long size, base;
char *p;
if (!arg)
return -EINVAL;
size = memparse(arg, &p);
if (arg == p)
return -EINVAL;
if (*p == '@') {
base = memparse(p+1, &p);
/* FIXME: Do I want a sanity check to validate the
* memory range? Yes you do, but it's too early for
* e820 -AK */
crashk_res.start = base;
crashk_res.end = base + size - 1;
}
return 0;
}
early_param("crashkernel", setup_crashkernel);

7 changes: 5 additions & 2 deletions arch/x86_64/kernel/pci-dma.c
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,9 @@ __init int iommu_setup(char *p)
{
iommu_merge = 1;

if (!p)
return -EINVAL;

while (*p) {
if (!strncmp(p,"off",3))
no_iommu = 1;
Expand Down Expand Up @@ -278,9 +281,9 @@ __init int iommu_setup(char *p)
if (*p == ',')
++p;
}
return 1;
return 0;
}
__setup("iommu=", iommu_setup);
early_param("iommu", iommu_setup);

void __init pci_iommu_alloc(void)
{
Expand Down
Loading

0 comments on commit 2c8c0e6

Please sign in to comment.