Skip to content

Commit 3c9cb6d

Browse files
yhluIngo Molnar
authored andcommitted
x86: introduce x86_quirks
introduce x86_quirks array of boot-time quirk methods. No change in functionality intended. Signed-off-by: Yinghai Lu <yhlu.kernel@gmail.com> Signed-off-by: Ingo Molnar <mingo@elte.hu>
1 parent 5f1f2b3 commit 3c9cb6d

File tree

6 files changed

+50
-64
lines changed

6 files changed

+50
-64
lines changed

arch/x86/kernel/e820.c

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1299,11 +1299,6 @@ void __init e820_reserve_resources(void)
12991299
}
13001300
}
13011301

1302-
/*
1303-
* Non-standard memory setup can be specified via this quirk:
1304-
*/
1305-
char * (*arch_memory_setup_quirk)(void);
1306-
13071302
char *__init default_machine_specific_memory_setup(void)
13081303
{
13091304
char *who = "BIOS-e820";
@@ -1344,8 +1339,8 @@ char *__init default_machine_specific_memory_setup(void)
13441339

13451340
char *__init __attribute__((weak)) machine_specific_memory_setup(void)
13461341
{
1347-
if (arch_memory_setup_quirk) {
1348-
char *who = arch_memory_setup_quirk();
1342+
if (x86_quirks->arch_memory_setup) {
1343+
char *who = x86_quirks->arch_memory_setup();
13491344

13501345
if (who)
13511346
return who;

arch/x86/kernel/mpparse.c

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#include <asm/bios_ebda.h>
2828
#include <asm/e820.h>
2929
#include <asm/trampoline.h>
30+
#include <asm/setup.h>
3031

3132
#include <mach_apic.h>
3233
#ifdef CONFIG_X86_32
@@ -725,21 +726,15 @@ static inline void __init construct_default_ISA_mptable(int mpc_default_type)
725726

726727
static struct intel_mp_floating *mpf_found;
727728

728-
/*
729-
* Machine specific quirk for finding the SMP config before other setup
730-
* activities destroy the table:
731-
*/
732-
int (*mach_get_smp_config_quirk)(unsigned int early);
733-
734729
/*
735730
* Scan the memory blocks for an SMP configuration block.
736731
*/
737732
static void __init __get_smp_config(unsigned int early)
738733
{
739734
struct intel_mp_floating *mpf = mpf_found;
740735

741-
if (mach_get_smp_config_quirk) {
742-
if (mach_get_smp_config_quirk(early))
736+
if (x86_quirks->mach_get_smp_config) {
737+
if (x86_quirks->mach_get_smp_config(early))
743738
return;
744739
}
745740
if (acpi_lapic && early)
@@ -899,14 +894,12 @@ static int __init smp_scan_config(unsigned long base, unsigned long length,
899894
return 0;
900895
}
901896

902-
int (*mach_find_smp_config_quirk)(unsigned int reserve);
903-
904897
static void __init __find_smp_config(unsigned int reserve)
905898
{
906899
unsigned int address;
907900

908-
if (mach_find_smp_config_quirk) {
909-
if (mach_find_smp_config_quirk(reserve))
901+
if (x86_quirks->mach_find_smp_config) {
902+
if (x86_quirks->mach_find_smp_config(reserve))
910903
return;
911904
}
912905
/*

arch/x86/kernel/setup.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -574,6 +574,10 @@ static int __init setup_elfcorehdr(char *arg)
574574
early_param("elfcorehdr", setup_elfcorehdr);
575575
#endif
576576

577+
static struct x86_quirks default_x86_quirks __initdata;
578+
579+
struct x86_quirks *x86_quirks __initdata = &default_x86_quirks;
580+
577581
/*
578582
* Determine if we were loaded by an EFI loader. If so, then we have also been
579583
* passed the efi memmap, systab, etc., so we should use these data structures

arch/x86/kernel/visws_quirks.c

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ int is_visws_box(void)
7373
return visws_board_type >= 0;
7474
}
7575

76-
static int __init visws_time_init_quirk(void)
76+
static int __init visws_time_init(void)
7777
{
7878
printk(KERN_INFO "Starting Cobalt Timer system clock\n");
7979

@@ -93,7 +93,7 @@ static int __init visws_time_init_quirk(void)
9393
return 0;
9494
}
9595

96-
static int __init visws_pre_intr_init_quirk(void)
96+
static int __init visws_pre_intr_init(void)
9797
{
9898
init_VISWS_APIC_irqs();
9999

@@ -114,7 +114,7 @@ EXPORT_SYMBOL(sgivwfb_mem_size);
114114

115115
long long mem_size __initdata = 0;
116116

117-
static char * __init visws_memory_setup_quirk(void)
117+
static char * __init visws_memory_setup(void)
118118
{
119119
long long gfx_mem_size = 8 * MB;
120120

@@ -176,7 +176,7 @@ static void visws_machine_power_off(void)
176176
outl(PIIX_SPECIAL_STOP, 0xCFC);
177177
}
178178

179-
static int __init visws_get_smp_config_quirk(unsigned int early)
179+
static int __init visws_get_smp_config(unsigned int early)
180180
{
181181
/*
182182
* Prevent MP-table parsing by the generic code:
@@ -192,7 +192,7 @@ extern unsigned int __cpuinitdata maxcpus;
192192
* No problem for Linux.
193193
*/
194194

195-
static void __init MP_processor_info (struct mpc_config_processor *m)
195+
static void __init MP_processor_info(struct mpc_config_processor *m)
196196
{
197197
int ver, logical_apicid;
198198
physid_mask_t apic_cpus;
@@ -232,7 +232,7 @@ static void __init MP_processor_info (struct mpc_config_processor *m)
232232
apic_version[m->mpc_apicid] = ver;
233233
}
234234

235-
int __init visws_find_smp_config_quirk(unsigned int reserve)
235+
static int __init visws_find_smp_config(unsigned int reserve)
236236
{
237237
struct mpc_config_processor *mp = phys_to_virt(CO_CPU_TAB_PHYS);
238238
unsigned short ncpus = readw(phys_to_virt(CO_CPU_NUM_PHYS));
@@ -258,7 +258,17 @@ int __init visws_find_smp_config_quirk(unsigned int reserve)
258258
return 1;
259259
}
260260

261-
extern int visws_trap_init_quirk(void);
261+
static int visws_trap_init(void);
262+
263+
static struct x86_quirks visws_x86_quirks __initdata = {
264+
.arch_time_init = visws_time_init,
265+
.arch_pre_intr_init = visws_pre_intr_init,
266+
.arch_memory_setup = visws_memory_setup,
267+
.arch_intr_init = NULL,
268+
.arch_trap_init = visws_trap_init,
269+
.mach_get_smp_config = visws_get_smp_config,
270+
.mach_find_smp_config = visws_find_smp_config,
271+
};
262272

263273
void __init visws_early_detect(void)
264274
{
@@ -272,16 +282,10 @@ void __init visws_early_detect(void)
272282

273283
/*
274284
* Install special quirks for timer, interrupt and memory setup:
275-
*/
276-
arch_time_init_quirk = visws_time_init_quirk;
277-
arch_pre_intr_init_quirk = visws_pre_intr_init_quirk;
278-
arch_memory_setup_quirk = visws_memory_setup_quirk;
279-
280-
/*
281285
* Fall back to generic behavior for traps:
286+
* Override generic MP-table parsing:
282287
*/
283-
arch_intr_init_quirk = NULL;
284-
arch_trap_init_quirk = visws_trap_init_quirk;
288+
x86_quirks = &visws_x86_quirks;
285289

286290
/*
287291
* Install reboot quirks:
@@ -294,12 +298,6 @@ void __init visws_early_detect(void)
294298
*/
295299
no_broadcast = 0;
296300

297-
/*
298-
* Override generic MP-table parsing:
299-
*/
300-
mach_get_smp_config_quirk = visws_get_smp_config_quirk;
301-
mach_find_smp_config_quirk = visws_find_smp_config_quirk;
302-
303301
#ifdef CONFIG_X86_IO_APIC
304302
/*
305303
* Turn off IO-APIC detection and initialization:
@@ -426,7 +424,7 @@ static __init void cobalt_init(void)
426424
co_apic_read(CO_APIC_ID));
427425
}
428426

429-
int __init visws_trap_init_quirk(void)
427+
static int __init visws_trap_init(void)
430428
{
431429
lithium_init();
432430
cobalt_init();

arch/x86/mach-default/setup.c

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,6 @@
1010
#include <asm/e820.h>
1111
#include <asm/setup.h>
1212

13-
/*
14-
* Any quirks to be performed to initialize timers/irqs/etc?
15-
*/
16-
int (*arch_time_init_quirk)(void);
17-
int (*arch_pre_intr_init_quirk)(void);
18-
int (*arch_intr_init_quirk)(void);
19-
int (*arch_trap_init_quirk)(void);
20-
2113
#ifdef CONFIG_HOTPLUG_CPU
2214
#define DEFAULT_SEND_IPI (1)
2315
#else
@@ -37,8 +29,8 @@ int no_broadcast=DEFAULT_SEND_IPI;
3729
**/
3830
void __init pre_intr_init_hook(void)
3931
{
40-
if (arch_pre_intr_init_quirk) {
41-
if (arch_pre_intr_init_quirk())
32+
if (x86_quirks->arch_pre_intr_init) {
33+
if (x86_quirks->arch_pre_intr_init())
4234
return;
4335
}
4436
init_ISA_irqs();
@@ -64,8 +56,8 @@ static struct irqaction irq2 = {
6456
**/
6557
void __init intr_init_hook(void)
6658
{
67-
if (arch_intr_init_quirk) {
68-
if (arch_intr_init_quirk())
59+
if (x86_quirks->arch_intr_init) {
60+
if (x86_quirks->arch_intr_init())
6961
return;
7062
}
7163
#ifdef CONFIG_X86_LOCAL_APIC
@@ -97,8 +89,8 @@ void __init pre_setup_arch_hook(void)
9789
**/
9890
void __init trap_init_hook(void)
9991
{
100-
if (arch_trap_init_quirk) {
101-
if (arch_trap_init_quirk())
92+
if (x86_quirks->arch_trap_init) {
93+
if (x86_quirks->arch_trap_init())
10294
return;
10395
}
10496
}
@@ -119,13 +111,13 @@ static struct irqaction irq0 = {
119111
**/
120112
void __init time_init_hook(void)
121113
{
122-
if (arch_time_init_quirk) {
114+
if (x86_quirks->arch_time_init) {
123115
/*
124116
* A nonzero return code does not mean failure, it means
125117
* that the architecture quirk does not want any
126118
* generic (timer) setup to be performed after this:
127119
*/
128-
if (arch_time_init_quirk())
120+
if (x86_quirks->arch_time_init())
129121
return;
130122
}
131123

include/asm-x86/setup.h

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,17 @@ static inline int is_visws_box(void) { return 0; }
1919
/*
2020
* Any setup quirks to be performed?
2121
*/
22-
extern int (*arch_time_init_quirk)(void);
23-
extern int (*arch_pre_intr_init_quirk)(void);
24-
extern int (*arch_intr_init_quirk)(void);
25-
extern int (*arch_trap_init_quirk)(void);
26-
extern char * (*arch_memory_setup_quirk)(void);
27-
extern int (*mach_get_smp_config_quirk)(unsigned int early);
28-
extern int (*mach_find_smp_config_quirk)(unsigned int reserve);
22+
struct x86_quirks {
23+
int (*arch_time_init)(void);
24+
int (*arch_pre_intr_init)(void);
25+
int (*arch_intr_init)(void);
26+
int (*arch_trap_init)(void);
27+
char * (*arch_memory_setup)(void);
28+
int (*mach_get_smp_config)(unsigned int early);
29+
int (*mach_find_smp_config)(unsigned int reserve);
30+
};
31+
32+
extern struct x86_quirks *x86_quirks;
2933

3034
#ifndef CONFIG_PARAVIRT
3135
#define paravirt_post_allocator_init() do {} while (0)

0 commit comments

Comments
 (0)