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 * @guest_late_init: guest late init
121 * @x2apic_available: X2APIC detection
122 * @init_mem_mapping: setup early mappings during init_mem_mapping()
124 struct x86_hyper_init
{
125 void (*init_platform
)(void);
126 void (*guest_late_init
)(void);
127 bool (*x2apic_available
)(void);
128 void (*init_mem_mapping
)(void);
132 * struct x86_init_ops - functions for platform specific setup
135 struct x86_init_ops
{
136 struct x86_init_resources resources
;
137 struct x86_init_mpparse mpparse
;
138 struct x86_init_irqs irqs
;
139 struct x86_init_oem oem
;
140 struct x86_init_paging paging
;
141 struct x86_init_timers timers
;
142 struct x86_init_iommu iommu
;
143 struct x86_init_pci pci
;
144 struct x86_hyper_init hyper
;
148 * struct x86_cpuinit_ops - platform specific cpu hotplug setups
149 * @setup_percpu_clockev: set up the per cpu clock event device
150 * @early_percpu_clock_init: early init of the per cpu clock event device
152 struct x86_cpuinit_ops
{
153 void (*setup_percpu_clockev
)(void);
154 void (*early_percpu_clock_init
)(void);
155 void (*fixup_cpu_id
)(struct cpuinfo_x86
*c
, int node
);
161 * struct x86_legacy_devices - legacy x86 devices
163 * @pnpbios: this platform can have a PNPBIOS. If this is disabled the platform
164 * is known to never have a PNPBIOS.
166 * These are devices known to require LPC or ISA bus. The definition of legacy
167 * devices adheres to the ACPI 5.2.9.3 IA-PC Boot Architecture flag
168 * ACPI_FADT_LEGACY_DEVICES. These devices consist of user visible devices on
169 * the LPC or ISA bus. User visible devices are devices that have end-user
170 * accessible connectors (for example, LPT parallel port). Legacy devices on
171 * the LPC bus consist for example of serial and parallel ports, PS/2 keyboard
172 * / mouse, and the floppy disk controller. A system that lacks all known
173 * legacy devices can assume all devices can be detected exclusively via
174 * standard device enumeration mechanisms including the ACPI namespace.
176 * A system which has does not have ACPI_FADT_LEGACY_DEVICES enabled must not
177 * have any of the legacy devices enumerated below present.
179 struct x86_legacy_devices
{
184 * enum x86_legacy_i8042_state - i8042 keyboard controller state
185 * @X86_LEGACY_I8042_PLATFORM_ABSENT: the controller is always absent on
186 * given platform/subarch.
187 * @X86_LEGACY_I8042_FIRMWARE_ABSENT: firmware reports that the controller
189 * @X86_LEGACY_i8042_EXPECTED_PRESENT: the controller is likely to be
190 * present, the i8042 driver should probe for controller existence.
192 enum x86_legacy_i8042_state
{
193 X86_LEGACY_I8042_PLATFORM_ABSENT
,
194 X86_LEGACY_I8042_FIRMWARE_ABSENT
,
195 X86_LEGACY_I8042_EXPECTED_PRESENT
,
199 * struct x86_legacy_features - legacy x86 features
201 * @i8042: indicated if we expect the device to have i8042 controller
203 * @rtc: this device has a CMOS real-time clock present
204 * @reserve_bios_regions: boot code will search for the EBDA address and the
205 * start of the 640k - 1M BIOS region. If false, the platform must
206 * ensure that its memory map correctly reserves sub-1MB regions as needed.
207 * @devices: legacy x86 devices, refer to struct x86_legacy_devices
208 * documentation for further details.
210 struct x86_legacy_features
{
211 enum x86_legacy_i8042_state i8042
;
214 int reserve_bios_regions
;
215 struct x86_legacy_devices devices
;
219 * struct x86_hyper_runtime - x86 hypervisor specific runtime callbacks
221 * @pin_vcpu: pin current vcpu to specified physical cpu (run rarely)
223 struct x86_hyper_runtime
{
224 void (*pin_vcpu
)(int cpu
);
228 * struct x86_platform_ops - platform specific runtime functions
229 * @calibrate_cpu: calibrate CPU
230 * @calibrate_tsc: calibrate TSC, if different from CPU
231 * @get_wallclock: get time from HW clock like RTC etc.
232 * @set_wallclock: set time back to HW clock
233 * @is_untracked_pat_range exclude from PAT logic
234 * @nmi_init enable NMI on cpus
235 * @save_sched_clock_state: save state for sched_clock() on suspend
236 * @restore_sched_clock_state: restore state for sched_clock() on resume
237 * @apic_post_init: adjust apic if needed
238 * @legacy: legacy features
239 * @set_legacy_features: override legacy features. Use of this callback
240 * is highly discouraged. You should only need
241 * this if your hardware platform requires further
242 * custom fine tuning far beyond what may be
243 * possible in x86_early_init_platform_quirks() by
244 * only using the current x86_hardware_subarch
246 * @hyper: x86 hypervisor specific runtime callbacks
248 struct x86_platform_ops
{
249 unsigned long (*calibrate_cpu
)(void);
250 unsigned long (*calibrate_tsc
)(void);
251 void (*get_wallclock
)(struct timespec
*ts
);
252 int (*set_wallclock
)(const struct timespec
*ts
);
253 void (*iommu_shutdown
)(void);
254 bool (*is_untracked_pat_range
)(u64 start
, u64 end
);
255 void (*nmi_init
)(void);
256 unsigned char (*get_nmi_reason
)(void);
257 void (*save_sched_clock_state
)(void);
258 void (*restore_sched_clock_state
)(void);
259 void (*apic_post_init
)(void);
260 struct x86_legacy_features legacy
;
261 void (*set_legacy_features
)(void);
262 struct x86_hyper_runtime hyper
;
268 int (*setup_msi_irqs
)(struct pci_dev
*dev
, int nvec
, int type
);
269 void (*teardown_msi_irq
)(unsigned int irq
);
270 void (*teardown_msi_irqs
)(struct pci_dev
*dev
);
271 void (*restore_msi_irqs
)(struct pci_dev
*dev
);
274 struct x86_io_apic_ops
{
275 unsigned int (*read
) (unsigned int apic
, unsigned int reg
);
276 void (*disable
)(void);
279 extern struct x86_init_ops x86_init
;
280 extern struct x86_cpuinit_ops x86_cpuinit
;
281 extern struct x86_platform_ops x86_platform
;
282 extern struct x86_msi_ops x86_msi
;
283 extern struct x86_io_apic_ops x86_io_apic_ops
;
285 extern void x86_early_init_platform_quirks(void);
286 extern void x86_init_noop(void);
287 extern void x86_init_uint_noop(unsigned int unused
);