diff options
author | Eduardo Habkost <ehabkost@redhat.com> | 2015-05-15 14:19:01 -0300 |
---|---|---|
committer | Michael S. Tsirkin <mst@redhat.com> | 2015-05-31 16:26:42 +0200 |
commit | 99fbeafee8b568e796863980365080abdb8d675e (patch) | |
tree | 74117cb2f532ae82c436ee4aec6e1fe1477dcc2b /hw/i386 | |
parent | 211b5b1d0a31f2f7593d6858a0b10487fb7b7fac (diff) |
pc: Generate init functions with a macro
All pc-i440fx and pc-q35 init functions simply call the corresponding
compat function and then call the main init function. Use a macro to
generate that code.
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Diffstat (limited to 'hw/i386')
-rw-r--r-- | hw/i386/pc_piix.c | 154 | ||||
-rw-r--r-- | hw/i386/pc_q35.c | 92 |
2 files changed, 76 insertions, 170 deletions
diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c index 01f938f83d..e77486c62c 100644 --- a/hw/i386/pc_piix.c +++ b/hw/i386/pc_piix.c @@ -413,18 +413,6 @@ static void pc_compat_1_2(MachineState *machine) x86_cpu_compat_kvm_no_autoenable(FEAT_KVM, 1 << KVM_FEATURE_PV_EOI); } -static void pc_init_pci_2_3(MachineState *machine) -{ - pc_compat_2_3(machine); - pc_init1(machine); -} - -static void pc_init_pci_2_2(MachineState *machine) -{ - pc_compat_2_2(machine); - pc_init1(machine); -} - /* PC compat function for pc-0.10 to pc-0.13 */ static void pc_compat_0_13(MachineState *machine) { @@ -432,62 +420,6 @@ static void pc_compat_0_13(MachineState *machine) kvmclock_enabled = false; } -static void pc_init_pci_2_1(MachineState *machine) -{ - pc_compat_2_1(machine); - pc_init1(machine); -} - -static void pc_init_pci_2_0(MachineState *machine) -{ - pc_compat_2_0(machine); - pc_init1(machine); -} - -static void pc_init_pci_1_7(MachineState *machine) -{ - pc_compat_1_7(machine); - pc_init1(machine); -} - -static void pc_init_pci_1_6(MachineState *machine) -{ - pc_compat_1_6(machine); - pc_init1(machine); -} - -static void pc_init_pci_1_5(MachineState *machine) -{ - pc_compat_1_5(machine); - pc_init1(machine); -} - -static void pc_init_pci_1_4(MachineState *machine) -{ - pc_compat_1_4(machine); - pc_init1(machine); -} - -static void pc_init_pci_1_3(MachineState *machine) -{ - pc_compat_1_3(machine); - pc_init1(machine); -} - -/* PC machine init function for pc-0.14 to pc-1.2 */ -static void pc_init_pci_1_2(MachineState *machine) -{ - pc_compat_1_2(machine); - pc_init1(machine); -} - -/* PC init function for pc-0.10 to pc-0.13 */ -static void pc_init_pci_no_kvmclock(MachineState *machine) -{ - pc_compat_0_13(machine); - pc_init1(machine); -} - static void pc_init_isa(MachineState *machine) { pci_enabled = false; @@ -520,6 +452,16 @@ static void pc_xen_hvm_init(MachineState *machine) } #endif +#define DEFINE_I440FX_MACHINE(suffix, name, compatfn, optionfn) \ + static void pc_init_##suffix(MachineState *machine) \ + { \ + void (*compat)(MachineState *m) = (compatfn); \ + if (compat) { \ + compat(machine); \ + } \ + pc_init1(machine); \ + } \ + DEFINE_PC_MACHINE(suffix, name, pc_init_##suffix, optionfn) static void pc_i440fx_machine_options(MachineClass *m) { @@ -538,8 +480,8 @@ static void pc_i440fx_2_4_machine_options(MachineClass *m) m->is_default = 1; } -DEFINE_PC_MACHINE(v2_4, "pc-i440fx-2.4", pc_init1, - pc_i440fx_2_4_machine_options) +DEFINE_I440FX_MACHINE(v2_4, "pc-i440fx-2.4", NULL, + pc_i440fx_2_4_machine_options) static void pc_i440fx_2_3_machine_options(MachineClass *m) @@ -550,8 +492,8 @@ static void pc_i440fx_2_3_machine_options(MachineClass *m) SET_MACHINE_COMPAT(m, PC_COMPAT_2_3); } -DEFINE_PC_MACHINE(v2_3, "pc-i440fx-2.3", pc_init_pci_2_3, - pc_i440fx_2_3_machine_options); +DEFINE_I440FX_MACHINE(v2_3, "pc-i440fx-2.3", pc_compat_2_3, + pc_i440fx_2_3_machine_options); static void pc_i440fx_2_2_machine_options(MachineClass *m) @@ -560,8 +502,8 @@ static void pc_i440fx_2_2_machine_options(MachineClass *m) SET_MACHINE_COMPAT(m, PC_COMPAT_2_2); } -DEFINE_PC_MACHINE(v2_2, "pc-i440fx-2.2", pc_init_pci_2_2, - pc_i440fx_2_2_machine_options); +DEFINE_I440FX_MACHINE(v2_2, "pc-i440fx-2.2", pc_compat_2_2, + pc_i440fx_2_2_machine_options); static void pc_i440fx_2_1_machine_options(MachineClass *m) @@ -571,8 +513,8 @@ static void pc_i440fx_2_1_machine_options(MachineClass *m) SET_MACHINE_COMPAT(m, PC_COMPAT_2_1); } -DEFINE_PC_MACHINE(v2_1, "pc-i440fx-2.1", pc_init_pci_2_1, - pc_i440fx_2_1_machine_options); +DEFINE_I440FX_MACHINE(v2_1, "pc-i440fx-2.1", pc_compat_2_1, + pc_i440fx_2_1_machine_options); @@ -582,8 +524,8 @@ static void pc_i440fx_2_0_machine_options(MachineClass *m) SET_MACHINE_COMPAT(m, PC_COMPAT_2_0); } -DEFINE_PC_MACHINE(v2_0, "pc-i440fx-2.0", pc_init_pci_2_0, - pc_i440fx_2_0_machine_options); +DEFINE_I440FX_MACHINE(v2_0, "pc-i440fx-2.0", pc_compat_2_0, + pc_i440fx_2_0_machine_options); static void pc_i440fx_1_7_machine_options(MachineClass *m) @@ -593,8 +535,8 @@ static void pc_i440fx_1_7_machine_options(MachineClass *m) SET_MACHINE_COMPAT(m, PC_COMPAT_1_7); } -DEFINE_PC_MACHINE(v1_7, "pc-i440fx-1.7", pc_init_pci_1_7, - pc_i440fx_1_7_machine_options); +DEFINE_I440FX_MACHINE(v1_7, "pc-i440fx-1.7", pc_compat_1_7, + pc_i440fx_1_7_machine_options); static void pc_i440fx_1_6_machine_options(MachineClass *m) @@ -603,8 +545,8 @@ static void pc_i440fx_1_6_machine_options(MachineClass *m) SET_MACHINE_COMPAT(m, PC_COMPAT_1_6); } -DEFINE_PC_MACHINE(v1_6, "pc-i440fx-1.6", pc_init_pci_1_6, - pc_i440fx_1_6_machine_options); +DEFINE_I440FX_MACHINE(v1_6, "pc-i440fx-1.6", pc_compat_1_6, + pc_i440fx_1_6_machine_options); static void pc_i440fx_1_5_machine_options(MachineClass *m) @@ -613,8 +555,8 @@ static void pc_i440fx_1_5_machine_options(MachineClass *m) SET_MACHINE_COMPAT(m, PC_COMPAT_1_5); } -DEFINE_PC_MACHINE(v1_5, "pc-i440fx-1.5", pc_init_pci_1_5, - pc_i440fx_1_5_machine_options); +DEFINE_I440FX_MACHINE(v1_5, "pc-i440fx-1.5", pc_compat_1_5, + pc_i440fx_1_5_machine_options); static void pc_i440fx_1_4_machine_options(MachineClass *m) @@ -624,8 +566,8 @@ static void pc_i440fx_1_4_machine_options(MachineClass *m) SET_MACHINE_COMPAT(m, PC_COMPAT_1_4); } -DEFINE_PC_MACHINE(v1_4, "pc-i440fx-1.4", pc_init_pci_1_4, - pc_i440fx_1_4_machine_options); +DEFINE_I440FX_MACHINE(v1_4, "pc-i440fx-1.4", pc_compat_1_4, + pc_i440fx_1_4_machine_options); #define PC_COMPAT_1_3 \ @@ -655,8 +597,8 @@ static void pc_i440fx_1_3_machine_options(MachineClass *m) SET_MACHINE_COMPAT(m, PC_COMPAT_1_3); } -DEFINE_PC_MACHINE(v1_3, "pc-1.3", pc_init_pci_1_3, - pc_i440fx_1_3_machine_options); +DEFINE_I440FX_MACHINE(v1_3, "pc-1.3", pc_compat_1_3, + pc_i440fx_1_3_machine_options); #define PC_COMPAT_1_2 \ @@ -693,8 +635,8 @@ static void pc_i440fx_1_2_machine_options(MachineClass *m) SET_MACHINE_COMPAT(m, PC_COMPAT_1_2); } -DEFINE_PC_MACHINE(v1_2, "pc-1.2", pc_init_pci_1_2, - pc_i440fx_1_2_machine_options); +DEFINE_I440FX_MACHINE(v1_2, "pc-1.2", pc_compat_1_2, + pc_i440fx_1_2_machine_options); #define PC_COMPAT_1_1 \ @@ -735,8 +677,8 @@ static void pc_i440fx_1_1_machine_options(MachineClass *m) SET_MACHINE_COMPAT(m, PC_COMPAT_1_1); } -DEFINE_PC_MACHINE(v1_1, "pc-1.1", pc_init_pci_1_2, - pc_i440fx_1_1_machine_options); +DEFINE_I440FX_MACHINE(v1_1, "pc-1.1", pc_compat_1_2, + pc_i440fx_1_1_machine_options); #define PC_COMPAT_1_0 \ @@ -766,8 +708,8 @@ static void pc_i440fx_1_0_machine_options(MachineClass *m) SET_MACHINE_COMPAT(m, PC_COMPAT_1_0); } -DEFINE_PC_MACHINE(v1_0, "pc-1.0", pc_init_pci_1_2, - pc_i440fx_1_0_machine_options); +DEFINE_I440FX_MACHINE(v1_0, "pc-1.0", pc_compat_1_2, + pc_i440fx_1_0_machine_options); #define PC_COMPAT_0_15 \ @@ -780,8 +722,8 @@ static void pc_i440fx_0_15_machine_options(MachineClass *m) SET_MACHINE_COMPAT(m, PC_COMPAT_0_15); } -DEFINE_PC_MACHINE(v0_15, "pc-0.15", pc_init_pci_1_2, - pc_i440fx_0_15_machine_options); +DEFINE_I440FX_MACHINE(v0_15, "pc-0.15", pc_compat_1_2, + pc_i440fx_0_15_machine_options); #define PC_COMPAT_0_14 \ @@ -819,8 +761,8 @@ static void pc_i440fx_0_14_machine_options(MachineClass *m) SET_MACHINE_COMPAT(m, PC_COMPAT_0_14); } -DEFINE_PC_MACHINE(v0_14, "pc-0.14", pc_init_pci_1_2, - pc_i440fx_0_14_machine_options); +DEFINE_I440FX_MACHINE(v0_14, "pc-0.14", pc_compat_1_2, + pc_i440fx_0_14_machine_options); #define PC_COMPAT_0_13 \ @@ -854,8 +796,8 @@ static void pc_i440fx_0_13_machine_options(MachineClass *m) SET_MACHINE_COMPAT(m, PC_COMPAT_0_13); } -DEFINE_PC_MACHINE(v0_13, "pc-0.13", pc_init_pci_no_kvmclock, - pc_i440fx_0_13_machine_options); +DEFINE_I440FX_MACHINE(v0_13, "pc-0.13", pc_compat_0_13, + pc_i440fx_0_13_machine_options); #define PC_COMPAT_0_12 \ @@ -889,8 +831,8 @@ static void pc_i440fx_0_12_machine_options(MachineClass *m) SET_MACHINE_COMPAT(m, PC_COMPAT_0_12); } -DEFINE_PC_MACHINE(v0_12, "pc-0.12", pc_init_pci_no_kvmclock, - pc_i440fx_0_12_machine_options); +DEFINE_I440FX_MACHINE(v0_12, "pc-0.12", pc_compat_0_13, + pc_i440fx_0_12_machine_options); #define PC_COMPAT_0_11 \ @@ -920,8 +862,8 @@ static void pc_i440fx_0_11_machine_options(MachineClass *m) SET_MACHINE_COMPAT(m, PC_COMPAT_0_11); } -DEFINE_PC_MACHINE(v0_11, "pc-0.11", pc_init_pci_no_kvmclock, - pc_i440fx_0_11_machine_options); +DEFINE_I440FX_MACHINE(v0_11, "pc-0.11", pc_compat_0_13, + pc_i440fx_0_11_machine_options); #define PC_COMPAT_0_10 \ @@ -955,8 +897,8 @@ static void pc_i440fx_0_10_machine_options(MachineClass *m) SET_MACHINE_COMPAT(m, PC_COMPAT_0_10); } -DEFINE_PC_MACHINE(v0_10, "pc-0.10", pc_init_pci_no_kvmclock, - pc_i440fx_0_10_machine_options); +DEFINE_I440FX_MACHINE(v0_10, "pc-0.10", pc_compat_0_13, + pc_i440fx_0_10_machine_options); static void isapc_machine_options(MachineClass *m) diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c index 6a9fe58500..68b4867d31 100644 --- a/hw/i386/pc_q35.c +++ b/hw/i386/pc_q35.c @@ -366,53 +366,17 @@ static void pc_compat_1_4(MachineState *machine) x86_cpu_compat_set_features("Westmere", FEAT_1_ECX, 0, CPUID_EXT_PCLMULQDQ); } -static void pc_q35_init_2_3(MachineState *machine) -{ - pc_compat_2_3(machine); - pc_q35_init(machine); -} - -static void pc_q35_init_2_2(MachineState *machine) -{ - pc_compat_2_2(machine); - pc_q35_init(machine); -} - -static void pc_q35_init_2_1(MachineState *machine) -{ - pc_compat_2_1(machine); - pc_q35_init(machine); -} - -static void pc_q35_init_2_0(MachineState *machine) -{ - pc_compat_2_0(machine); - pc_q35_init(machine); -} +#define DEFINE_Q35_MACHINE(suffix, name, compatfn, optionfn) \ + static void pc_init_##suffix(MachineState *machine) \ + { \ + void (*compat)(MachineState *m) = (compatfn); \ + if (compat) { \ + compat(machine); \ + } \ + pc_q35_init(machine); \ + } \ + DEFINE_PC_MACHINE(suffix, name, pc_init_##suffix, optionfn) -static void pc_q35_init_1_7(MachineState *machine) -{ - pc_compat_1_7(machine); - pc_q35_init(machine); -} - -static void pc_q35_init_1_6(MachineState *machine) -{ - pc_compat_1_6(machine); - pc_q35_init(machine); -} - -static void pc_q35_init_1_5(MachineState *machine) -{ - pc_compat_1_5(machine); - pc_q35_init(machine); -} - -static void pc_q35_init_1_4(MachineState *machine) -{ - pc_compat_1_4(machine); - pc_q35_init(machine); -} static void pc_q35_machine_options(MachineClass *m) { @@ -431,8 +395,8 @@ static void pc_q35_2_4_machine_options(MachineClass *m) m->alias = "q35"; } -DEFINE_PC_MACHINE(v2_4, "pc-q35-2.4", pc_q35_init, - pc_q35_2_4_machine_options); +DEFINE_Q35_MACHINE(v2_4, "pc-q35-2.4", NULL, + pc_q35_2_4_machine_options); static void pc_q35_2_3_machine_options(MachineClass *m) @@ -442,8 +406,8 @@ static void pc_q35_2_3_machine_options(MachineClass *m) SET_MACHINE_COMPAT(m, PC_COMPAT_2_3); } -DEFINE_PC_MACHINE(v2_3, "pc-q35-2.3", pc_q35_init_2_3, - pc_q35_2_3_machine_options); +DEFINE_Q35_MACHINE(v2_3, "pc-q35-2.3", pc_compat_2_3, + pc_q35_2_3_machine_options); static void pc_q35_2_2_machine_options(MachineClass *m) @@ -452,8 +416,8 @@ static void pc_q35_2_2_machine_options(MachineClass *m) SET_MACHINE_COMPAT(m, PC_COMPAT_2_2); } -DEFINE_PC_MACHINE(v2_2, "pc-q35-2.2", pc_q35_init_2_2, - pc_q35_2_2_machine_options); +DEFINE_Q35_MACHINE(v2_2, "pc-q35-2.2", pc_compat_2_2, + pc_q35_2_2_machine_options); static void pc_q35_2_1_machine_options(MachineClass *m) @@ -463,8 +427,8 @@ static void pc_q35_2_1_machine_options(MachineClass *m) SET_MACHINE_COMPAT(m, PC_COMPAT_2_1); } -DEFINE_PC_MACHINE(v2_1, "pc-q35-2.1", pc_q35_init_2_1, - pc_q35_2_1_machine_options); +DEFINE_Q35_MACHINE(v2_1, "pc-q35-2.1", pc_compat_2_1, + pc_q35_2_1_machine_options); static void pc_q35_2_0_machine_options(MachineClass *m) @@ -473,8 +437,8 @@ static void pc_q35_2_0_machine_options(MachineClass *m) SET_MACHINE_COMPAT(m, PC_COMPAT_2_0); } -DEFINE_PC_MACHINE(v2_0, "pc-q35-2.0", pc_q35_init_2_0, - pc_q35_2_0_machine_options); +DEFINE_Q35_MACHINE(v2_0, "pc-q35-2.0", pc_compat_2_0, + pc_q35_2_0_machine_options); static void pc_q35_1_7_machine_options(MachineClass *m) @@ -484,8 +448,8 @@ static void pc_q35_1_7_machine_options(MachineClass *m) SET_MACHINE_COMPAT(m, PC_COMPAT_1_7); } -DEFINE_PC_MACHINE(v1_7, "pc-q35-1.7", pc_q35_init_1_7, - pc_q35_1_7_machine_options); +DEFINE_Q35_MACHINE(v1_7, "pc-q35-1.7", pc_compat_1_7, + pc_q35_1_7_machine_options); static void pc_q35_1_6_machine_options(MachineClass *m) @@ -494,8 +458,8 @@ static void pc_q35_1_6_machine_options(MachineClass *m) SET_MACHINE_COMPAT(m, PC_COMPAT_1_6); } -DEFINE_PC_MACHINE(v1_6, "pc-q35-1.6", pc_q35_init_1_6, - pc_q35_1_6_machine_options); +DEFINE_Q35_MACHINE(v1_6, "pc-q35-1.6", pc_compat_1_6, + pc_q35_1_6_machine_options); static void pc_q35_1_5_machine_options(MachineClass *m) @@ -504,8 +468,8 @@ static void pc_q35_1_5_machine_options(MachineClass *m) SET_MACHINE_COMPAT(m, PC_COMPAT_1_5); } -DEFINE_PC_MACHINE(v1_5, "pc-q35-1.5", pc_q35_init_1_5, - pc_q35_1_5_machine_options); +DEFINE_Q35_MACHINE(v1_5, "pc-q35-1.5", pc_compat_1_5, + pc_q35_1_5_machine_options); static void pc_q35_1_4_machine_options(MachineClass *m) @@ -515,5 +479,5 @@ static void pc_q35_1_4_machine_options(MachineClass *m) SET_MACHINE_COMPAT(m, PC_COMPAT_1_4); } -DEFINE_PC_MACHINE(v1_4, "pc-q35-1.4", pc_q35_init_1_4, - pc_q35_1_4_machine_options); +DEFINE_Q35_MACHINE(v1_4, "pc-q35-1.4", pc_compat_1_4, + pc_q35_1_4_machine_options); |