1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _ASM_X86_PLATFORM_H
3 #define _ASM_X86_PLATFORM_H
5 #include <asm/bootparam.h>
13 * struct x86_init_mpparse - platform specific mpparse ops
14 * @mpc_record: platform specific mpc record accounting
15 * @setup_ioapic_ids: platform specific ioapic id override
16 * @mpc_apic_id: platform specific mpc apic id assignment
17 * @smp_read_mpc_oem: platform specific oem mpc table setup
18 * @mpc_oem_pci_bus: platform specific pci bus setup (default NULL)
19 * @mpc_oem_bus_info: platform specific mpc bus info
20 * @find_smp_config: find the smp configuration
21 * @get_smp_config: get the smp configuration
23 struct x86_init_mpparse {
24 void (*mpc_record)(unsigned int mode);
25 void (*setup_ioapic_ids)(void);
26 int (*mpc_apic_id)(struct mpc_cpu *m);
27 void (*smp_read_mpc_oem)(struct mpc_table *mpc);
28 void (*mpc_oem_pci_bus)(struct mpc_bus *m);
29 void (*mpc_oem_bus_info)(struct mpc_bus *m, char *name);
30 void (*find_smp_config)(void);
31 void (*get_smp_config)(unsigned int early);
35 * struct x86_init_resources - platform specific resource related ops
36 * @probe_roms: probe BIOS roms
37 * @reserve_resources: reserve the standard resources for the
39 * @memory_setup: platform specific memory setup
42 struct x86_init_resources {
43 void (*probe_roms)(void);
44 void (*reserve_resources)(void);
45 char *(*memory_setup)(void);
49 * struct x86_init_irqs - platform specific interrupt setup
50 * @pre_vector_init: init code to run before interrupt vectors
52 * @intr_init: interrupt init code
53 * @trap_init: platform specific trap setup
55 struct x86_init_irqs {
56 void (*pre_vector_init)(void);
57 void (*intr_init)(void);
58 void (*trap_init)(void);
62 * struct x86_init_oem - oem platform specific customizing functions
63 * @arch_setup: platform specific architecture setup
64 * @banner: print a platform specific banner
67 void (*arch_setup)(void);
72 * struct x86_init_paging - platform specific paging functions
73 * @pagetable_init: platform specific paging initialization call to setup
74 * the kernel pagetables and prepare accessors functions.
75 * Callback must call paging_init(). Called once after the
76 * direct mapping for phys memory is available.
78 struct x86_init_paging {
79 void (*pagetable_init)(void);
83 * struct x86_init_timers - platform specific timer setup
84 * @setup_perpcu_clockev: set up the per cpu clock event device for the
86 * @timer_init: initialize the platform timer (default PIT/HPET)
87 * @wallclock_init: init the wallclock device
89 struct x86_init_timers {
90 void (*setup_percpu_clockev)(void);
91 void (*timer_init)(void);
92 void (*wallclock_init)(void);
96 * struct x86_init_iommu - platform specific iommu setup
97 * @iommu_init: platform specific iommu setup
99 struct x86_init_iommu {
100 int (*iommu_init)(void);
104 * struct x86_init_pci - platform specific pci init functions
105 * @arch_init: platform specific pci arch init call
106 * @init: platform specific pci subsystem init
107 * @init_irq: platform specific pci irq init
108 * @fixup_irqs: platform specific pci irq fixup
110 struct x86_init_pci {
111 int (*arch_init)(void);
113 void (*init_irq)(void);
114 void (*fixup_irqs)(void);
118 * struct x86_hyper_init - x86 hypervisor init functions
119 * @init_platform: platform setup
120 * @x2apic_available: X2APIC detection
121 * @init_mem_mapping: setup early mappings during init_mem_mapping()
123 struct x86_hyper_init {
124 void (*init_platform)(void);
125 bool (*x2apic_available)(void);
126 void (*init_mem_mapping)(void);
130 * struct x86_init_ops - functions for platform specific setup
133 struct x86_init_ops {
134 struct x86_init_resources resources;
135 struct x86_init_mpparse mpparse;
136 struct x86_init_irqs irqs;
137 struct x86_init_oem oem;
138 struct x86_init_paging paging;
139 struct x86_init_timers timers;
140 struct x86_init_iommu iommu;
141 struct x86_init_pci pci;
142 struct x86_hyper_init hyper;
146 * struct x86_cpuinit_ops - platform specific cpu hotplug setups
147 * @setup_percpu_clockev: set up the per cpu clock event device
148 * @early_percpu_clock_init: early init of the per cpu clock event device
150 struct x86_cpuinit_ops {
151 void (*setup_percpu_clockev)(void);
152 void (*early_percpu_clock_init)(void);
153 void (*fixup_cpu_id)(struct cpuinfo_x86 *c, int node);
159 * struct x86_legacy_devices - legacy x86 devices
161 * @pnpbios: this platform can have a PNPBIOS. If this is disabled the platform
162 * is known to never have a PNPBIOS.
164 * These are devices known to require LPC or ISA bus. The definition of legacy
165 * devices adheres to the ACPI 5.2.9.3 IA-PC Boot Architecture flag
166 * ACPI_FADT_LEGACY_DEVICES. These devices consist of user visible devices on
167 * the LPC or ISA bus. User visible devices are devices that have end-user
168 * accessible connectors (for example, LPT parallel port). Legacy devices on
169 * the LPC bus consist for example of serial and parallel ports, PS/2 keyboard
170 * / mouse, and the floppy disk controller. A system that lacks all known
171 * legacy devices can assume all devices can be detected exclusively via
172 * standard device enumeration mechanisms including the ACPI namespace.
174 * A system which has does not have ACPI_FADT_LEGACY_DEVICES enabled must not
175 * have any of the legacy devices enumerated below present.
177 struct x86_legacy_devices {
182 * enum x86_legacy_i8042_state - i8042 keyboard controller state
183 * @X86_LEGACY_I8042_PLATFORM_ABSENT: the controller is always absent on
184 * given platform/subarch.
185 * @X86_LEGACY_I8042_FIRMWARE_ABSENT: firmware reports that the controller
187 * @X86_LEGACY_i8042_EXPECTED_PRESENT: the controller is likely to be
188 * present, the i8042 driver should probe for controller existence.
190 enum x86_legacy_i8042_state {
191 X86_LEGACY_I8042_PLATFORM_ABSENT,
192 X86_LEGACY_I8042_FIRMWARE_ABSENT,
193 X86_LEGACY_I8042_EXPECTED_PRESENT,
197 * struct x86_legacy_features - legacy x86 features
199 * @i8042: indicated if we expect the device to have i8042 controller
201 * @rtc: this device has a CMOS real-time clock present
202 * @reserve_bios_regions: boot code will search for the EBDA address and the
203 * start of the 640k - 1M BIOS region. If false, the platform must
204 * ensure that its memory map correctly reserves sub-1MB regions as needed.
205 * @devices: legacy x86 devices, refer to struct x86_legacy_devices
206 * documentation for further details.
208 struct x86_legacy_features {
209 enum x86_legacy_i8042_state i8042;
211 int reserve_bios_regions;
212 struct x86_legacy_devices devices;
216 * struct x86_hyper_runtime - x86 hypervisor specific runtime callbacks
218 * @pin_vcpu: pin current vcpu to specified physical cpu (run rarely)
220 struct x86_hyper_runtime {
221 void (*pin_vcpu)(int cpu);
225 * struct x86_platform_ops - platform specific runtime functions
226 * @calibrate_cpu: calibrate CPU
227 * @calibrate_tsc: calibrate TSC, if different from CPU
228 * @get_wallclock: get time from HW clock like RTC etc.
229 * @set_wallclock: set time back to HW clock
230 * @is_untracked_pat_range exclude from PAT logic
231 * @nmi_init enable NMI on cpus
232 * @save_sched_clock_state: save state for sched_clock() on suspend
233 * @restore_sched_clock_state: restore state for sched_clock() on resume
234 * @apic_post_init: adjust apic if needed
235 * @legacy: legacy features
236 * @set_legacy_features: override legacy features. Use of this callback
237 * is highly discouraged. You should only need
238 * this if your hardware platform requires further
239 * custom fine tuning far beyond what may be
240 * possible in x86_early_init_platform_quirks() by
241 * only using the current x86_hardware_subarch
243 * @hyper: x86 hypervisor specific runtime callbacks
245 struct x86_platform_ops {
246 unsigned long (*calibrate_cpu)(void);
247 unsigned long (*calibrate_tsc)(void);
248 void (*get_wallclock)(struct timespec *ts);
249 int (*set_wallclock)(const struct timespec *ts);
250 void (*iommu_shutdown)(void);
251 bool (*is_untracked_pat_range)(u64 start, u64 end);
252 void (*nmi_init)(void);
253 unsigned char (*get_nmi_reason)(void);
254 void (*save_sched_clock_state)(void);
255 void (*restore_sched_clock_state)(void);
256 void (*apic_post_init)(void);
257 struct x86_legacy_features legacy;
258 void (*set_legacy_features)(void);
259 struct x86_hyper_runtime hyper;
265 int (*setup_msi_irqs)(struct pci_dev *dev, int nvec, int type);
266 void (*teardown_msi_irq)(unsigned int irq);
267 void (*teardown_msi_irqs)(struct pci_dev *dev);
268 void (*restore_msi_irqs)(struct pci_dev *dev);
271 struct x86_io_apic_ops {
272 unsigned int (*read) (unsigned int apic, unsigned int reg);
273 void (*disable)(void);
276 extern struct x86_init_ops x86_init;
277 extern struct x86_cpuinit_ops x86_cpuinit;
278 extern struct x86_platform_ops x86_platform;
279 extern struct x86_msi_ops x86_msi;
280 extern struct x86_io_apic_ops x86_io_apic_ops;
282 extern void x86_early_init_platform_quirks(void);
283 extern void x86_init_noop(void);
284 extern void x86_init_uint_noop(unsigned int unused);