History log of /openbsd-current/sys/arch/amd64/amd64/mainbus.c
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
# 1.52 21-Feb-2022 mpi

Constify struct cfattach.


Revision tags: OPENBSD_7_0_BASE
# 1.51 31-Aug-2021 patrick

Identify the paravirtual bus earlier, as we need to make sure that we have
a working delay func ready before the first occurence of delay(). This is
necessary on Hyper-V Gen 2 VMs where we don't use the TSC.

Discussed with the hackroom
ok kettenis@


Revision tags: OPENBSD_6_8_BASE OPENBSD_6_9_BASE
# 1.50 14-May-2020 kettenis

Bring back the acpi(4) changes. This time around only use the ACPI _CRS
information on ACPI 5.0 and later.

ok krw@, patrick@


Revision tags: OPENBSD_6_6_BASE OPENBSD_6_7_BASE
# 1.49 07-Sep-2019 kettenis

Revert acpipci(4) changes. Too many systems are broken. We'll try again
after 6.6 as been released. The acpireg.h change stays behind.


# 1.48 28-Aug-2019 kettenis

Use ACPI information to attach PCI busses like we do on arm64. There are a
few additional quirks though, and attaching the PCI busses is delayed to
replicate the existing code more closely. That may be changed in the
future. Also tweak how we handle MSI support and respect to ACPI flag
that says we shouldn't attempt to use MSIs.

Some fallout is expected.

ok patrick@


# 1.47 17-May-2019 guenther

Mitigate Intel's Microarchitectural Data Sampling vulnerability.
If the CPU has the new VERW behavior than that is used, otherwise
use the proper sequence from Intel's "Deep Dive" doc is used in the
return-to-userspace and enter-VMM-guest paths. The enter-C3-idle
path is not mitigated because it's only a problem when SMT/HT is
enabled: mitigating everything when that's enabled would be a _huge_
set of changes that we see no point in doing.

Update vmm(4) to pass through the MSR bits so that guests can apply
the optimal mitigation.

VMM help and specific feedback from mlarkin@
vendor-portability help from jsg@ and kettenis@
ok kettenis@ mlarkin@ deraadt@ jsg@


# 1.46 04-May-2019 kettenis

Improve the interaction between efifb(4), inteldrm(4) and radeondrm(4)
when we have a serial console by introducing the notion of a "primary"
graphics device. The primary graphics device is the one set up and
used by firmware (BIOS, UEFI).

The goal is to make sure that wsdisplay0 and drm0 reliably attach to
the primary graphics device such that X works out of the box even
if you have multiple cards or if you are using a serial console.

This also fixes the situation where inteldrm(4) or radeondrm(4) would
take over the console on UEFI systems even if the kernel was booted
with a serial console.

ok jsg@


Revision tags: OPENBSD_6_4_BASE OPENBSD_6_5_BASE
# 1.45 22-Sep-2018 kettenis

branches: 1.45.2; 1.45.4;
Remap the UEFI buffer early such that we can use a write combining mapping
which speeds things up considerably compared to an uncached mapping.

ok deraadt@


# 1.44 13-Jul-2018 sf

Disable codepatching infrastructure after boot

This way, it is not available for use in ROP attacks. This diff puts the
codepatching code into a separate section and unmaps that section after boot.
In the future, the memory could potentially be reused but that would require
larger changes.

ok pguenther@


# 1.43 25-Apr-2018 jsg

Add a way to reattach efifb(4). This will be used when radeondrm(4)
attaches and claims glass console but after root is mounted if firmware
is not found efifb gets reattached to have a useable glass console.


# 1.42 20-Apr-2018 deraadt

oops, snapshot tests not ready yet


# 1.41 20-Apr-2018 deraadt

sync


Revision tags: OPENBSD_6_3_BASE
# 1.40 14-Oct-2017 jsg

reduce the amount of includes in arch/amd64
ok mpi@ deraadt@


Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE
# 1.39 25-Mar-2017 deraadt

Split vmm_probe() into a vmm_enabled() function, to better follow the
probe/attach approach used by mainbus.
ok mlarkin kettenis


# 1.38 28-Jul-2016 kettenis

Store the acpi processor ID/UID in struct cpu_info, and use it to attach
acpicpu(4) drivers to the right cpu(4).

ok mlarkin@, guenther@


Revision tags: OPENBSD_6_0_BASE
# 1.37 21-Jun-2016 jcs

add support to efifb for drawing a console on a coreboot framebuffer
if coreboot's memory table is found, it has a framebuffer entry, and
there is no previously attached efi, vga, or serial console.

useful on chromebooks that have no legacy vga device to get an early
console before inteldrm(4) attaches or, for newer chipsets, a full
console and X with wsfb(4).

ok kettenis


Revision tags: OPENBSD_5_9_BASE
# 1.36 12-Dec-2015 reyk

Identify hypervisors before configuring other children of the mainbus
(bios, CPU, interrupt handlers, pvbus). This splits the pvbus attach
function into two parts: pvbus_identify() to scan the CPUID registers
for supported hypervisors and pvbus_attach() to attach the bus, print
information, and configure the children.

This will be needed for Xen and KVM, as discussed with mikeb@ and sf@
OK mlarkin@


# 1.35 23-Nov-2015 deraadt

No longer need 'option VMM', declaring the vmm0 device is sufficient.
ok mlarkin


# 1.34 13-Nov-2015 mlarkin

vmm(4) kernel code

circulated on hackers@, no objections. Disabled by default.


# 1.33 31-Aug-2015 kettenis

Check driver name in match function such that driver only attempts to attach
when we actually want it to.

ok deraadt@


# 1.32 30-Aug-2015 kettenis

Don't try to attach efifb(4) on non-UEFI boots.

ok miod@, deraadt@


# 1.31 30-Aug-2015 yasuoka

Modify kernel to prepare boot from UEFI.

- Add new boot arg "bios_efi_info_t" to pass the paramters from UEFI
- Make bios(4) and acpi(4) be able to probe with the parameters from
UEFI
- Add efifb(8). It uses the framebuffer from UEFI and it will work as
a backend of wsdisplay(4) and wsfb (X11 video driver). Disabled by
the kernel config for this moment

input and ok kettenis


Revision tags: OPENBSD_5_8_BASE
# 1.30 21-Jul-2015 reyk

pvbus(4) was attaching too early, it has to wait for identifycpu.
Problem found on GENERIC by mlarkin.

OK mlarkin@


# 1.29 21-Jul-2015 reyk

Add pvbus(4), a pseudo-bus to attach non-PCI paravirtual devices and buses.
vmt(4) is moved from mainbus0 to pvbus0, more devices will follow.

OK sf@ deraadt@


# 1.28 14-Mar-2015 jsg

Remove some includes include-what-you-use claims don't
have any direct symbols used. Tested for indirect use by compiling
amd64/i386/sparc64 kernels.

ok tedu@ deraadt@


Revision tags: OPENBSD_5_4_BASE OPENBSD_5_5_BASE OPENBSD_5_6_BASE OPENBSD_5_7_BASE
# 1.27 30-May-2013 deraadt

Enforce ca_activate tree-walks over the entire heirarchy for all events,
cleaning up some shutdown-hook related code on the way.
(A few drivers related to sparc are still skipped at kettenis' request)
ok kettenis mlarkin, tested by many others too


Revision tags: OPENBSD_5_3_BASE
# 1.26 04-Oct-2012 ehrhardt

Use information provided by ACPI to attach secondary PCI host bridges.

ok kettenis@


# 1.25 19-Sep-2012 kettenis

Set up PCI bus number resource accounting for the main PCI bus hierarchy.


Revision tags: OPENBSD_5_1_BASE OPENBSD_5_2_BASE
# 1.24 21-Oct-2011 kettenis

Add bounds checks for access to mp_busses.


Revision tags: OPENBSD_4_9_BASE OPENBSD_5_0_BASE
# 1.23 03-Nov-2010 dlg

only let vmt match and therefore attach if mainbus is specifically asking
for vmt to attach after vmt_probe succeeds. this prevents vmt from
appearing at other attach points hanging off mainbus.

found by phessler@ and debugged gently by claudio@


Revision tags: OPENBSD_4_7_BASE OPENBSD_4_8_BASE
# 1.22 28-Dec-2009 dlg

tweak vmt to work on amd64 as well as i386. like i386, it is still
commented out in GENERIC. it needs more love.

diff by david cranshaw a long time ago. sorry it has taken so long
for me to look at it.


# 1.21 23-Nov-2009 deraadt

oops, call config_activate_children


# 1.20 23-Nov-2009 deraadt

Use config_activate_children() for our cf_activate function
ok mlarkin pirofti


Revision tags: OPENBSD_4_6_BASE
# 1.19 21-Apr-2009 kettenis

Simplify PCI config space access code. There is no way we're ever going to
see the ancient mode 2 on machines capable of running OpenBSD/amd64.

ok deraadt@, toby@, oga@


# 1.18 11-Apr-2009 kettenis

Create extents for resource accounting on the root PCI bus and populate them
based on the BIOS memory map.


# 1.17 31-Mar-2009 kettenis

bzero pci attach args


Revision tags: OPENBSD_4_5_BASE
# 1.16 13-Jan-2009 kettenis

Turn mpbios into a real device, such that people can disable it on crappy
BIOSes.

ok deraadt@ (for the amd64 bit, or the i386 bit, can't remember which)


# 1.15 21-Dec-2008 kettenis

Change the way we include mpbios code to be similar to what we do on i386.

ok deraadt@


Revision tags: OPENBSD_4_3_BASE OPENBSD_4_4_BASE
# 1.14 05-Dec-2007 deraadt

Hang acpi(4) below bios(4) instead of mainbus(4). This lets us move acpi(4)
before pcibios(4), and then.... if acpi(4) attaches, skip pcibios(4) since
it messes the machines up. Fixes claudio's HP dl320 G5, and almost assuredly
others.
ok kettenis


# 1.13 16-Nov-2007 deraadt

fix the bus_space #define nightmare, so that amd64 and i386 are much more
uniform. as a result shared code like acpi needs less #ifdef's
ok marco kettenis


Revision tags: OPENBSD_4_2_BASE
# 1.12 06-May-2007 gwk

Add the mp setperf mechanism to AMD64, like its i386 counterpart it allows
all cpus in a system supporting frequency and voltage scaling to be scaled
by the same amount corresponding to the user (or apmd on their behalf)
performance level.

This diff also teaches amd64 about acpi_hasprocfvs (ACPI has processor
frequency and voltage scaling).

It also moves initilization of the underlying setperf mechanism such
as powernow to mainbus from the cpu indentification and initilization
code inspired by similar changes dim@ made to i386 durring h2k6. This
is necessary to implement the AMD recommended method for retreiving
p_state data from the ACPI _PSS object (a diff comming soon). It will
also simplify the potential addition of enhanced speedstep as found
on newer intel processors with EMT64 capable of running OpenBSD/amd64.

MP setperf functionality verifed by myself and Johan M:son Lindman <tybolt
AT solace DOT miun DOT se> on opteron 265 and 270 systems respectively.
General testing done by many others thanks!

ok tedu, dim


Revision tags: OPENBSD_4_1_BASE
# 1.11 14-Dec-2006 kettenis

Make pci subsystem aware of domains. Each host bridge gets assigned a unique
domain number such that we can distinguish between busses with the same bus
number that are behind different host bridges. Domains can be accessed by
using different device nodes.

ok deraadt@


# 1.10 25-Nov-2006 niklas

sync amd64 to i386 w.r.t. acpi support. Also fix interrupt routing for multi-ioapic systems.
ok kettenis


# 1.9 17-Nov-2006 kettenis

Decide whether we need to attach the primary cpu by checking the CPUF_PRESENT
flag just like we do on i386.


Revision tags: OPENBSD_4_0_BASE
# 1.8 08-May-2006 gwk

Add smbios support for i386 and amd64, fix ipmi to use this new functionallity,
hook up some sysctls to add system vendor/product/version and UUID reporting.

"get it in" deraadt@


# 1.7 14-Apr-2006 marco

ANSIfy functions.
Spacing.


# 1.6 13-Mar-2006 brad

* Add "pcitag_t *pba_bridgetag" to pci_attach_args. This is set to
NULL for root PCI busses. For busses behind a bridge, it points to
a persistent copy of the bridge's pcitag_t. This can be very useful
for machine-dependent PCI bus enumeration code.

From NetBSD

ok grange@ kettenis@


# 1.5 13-Mar-2006 marco

Fix machines that need PCI access during ACPI bringup.

Help and ok kettenis.


Revision tags: OPENBSD_3_9_BASE
# 1.4 29-Dec-2005 kettenis

Fix isadma0 at isa0 at mainbus0
ok deraadt@


# 1.3 19-Oct-2005 marco

Add IPMI to amd64. Keep it disabled for now.

Prodded earlier today by deraadt@
ok krw@


Revision tags: OPENBSD_3_8_BASE
# 1.2 02-Jun-2005 tholo

Start on a basic ACPI framework -- does not do much more than read out the
ACPI tables into kernel memory and attach ACPI and HPET timers currently.

In order to test this code, enabling the devices in GENERIC as well as
the ACPI_ENABLE option is needed. This code does not do any thermal
control yet, so this should be done with care depending on the platform.

In the tree so more people can contribute to making this more fully
featured.

Ok niklas@ grange@ tedu@


Revision tags: OPENBSD_3_5_BASE OPENBSD_3_6_BASE OPENBSD_3_7_BASE SMP_SYNC_A SMP_SYNC_B
# 1.1 28-Jan-2004 mickey

an amd64 arch support.
hacked by art@ from netbsd sources and then later debugged
by me into the shape where it can host itself.
no bootloader yet as needs redoing from the
recent advanced i386 sources (anyone? ;)


# 1.51 31-Aug-2021 patrick

Identify the paravirtual bus earlier, as we need to make sure that we have
a working delay func ready before the first occurence of delay(). This is
necessary on Hyper-V Gen 2 VMs where we don't use the TSC.

Discussed with the hackroom
ok kettenis@


Revision tags: OPENBSD_6_8_BASE OPENBSD_6_9_BASE
# 1.50 14-May-2020 kettenis

Bring back the acpi(4) changes. This time around only use the ACPI _CRS
information on ACPI 5.0 and later.

ok krw@, patrick@


Revision tags: OPENBSD_6_6_BASE OPENBSD_6_7_BASE
# 1.49 07-Sep-2019 kettenis

Revert acpipci(4) changes. Too many systems are broken. We'll try again
after 6.6 as been released. The acpireg.h change stays behind.


# 1.48 28-Aug-2019 kettenis

Use ACPI information to attach PCI busses like we do on arm64. There are a
few additional quirks though, and attaching the PCI busses is delayed to
replicate the existing code more closely. That may be changed in the
future. Also tweak how we handle MSI support and respect to ACPI flag
that says we shouldn't attempt to use MSIs.

Some fallout is expected.

ok patrick@


# 1.47 17-May-2019 guenther

Mitigate Intel's Microarchitectural Data Sampling vulnerability.
If the CPU has the new VERW behavior than that is used, otherwise
use the proper sequence from Intel's "Deep Dive" doc is used in the
return-to-userspace and enter-VMM-guest paths. The enter-C3-idle
path is not mitigated because it's only a problem when SMT/HT is
enabled: mitigating everything when that's enabled would be a _huge_
set of changes that we see no point in doing.

Update vmm(4) to pass through the MSR bits so that guests can apply
the optimal mitigation.

VMM help and specific feedback from mlarkin@
vendor-portability help from jsg@ and kettenis@
ok kettenis@ mlarkin@ deraadt@ jsg@


# 1.46 04-May-2019 kettenis

Improve the interaction between efifb(4), inteldrm(4) and radeondrm(4)
when we have a serial console by introducing the notion of a "primary"
graphics device. The primary graphics device is the one set up and
used by firmware (BIOS, UEFI).

The goal is to make sure that wsdisplay0 and drm0 reliably attach to
the primary graphics device such that X works out of the box even
if you have multiple cards or if you are using a serial console.

This also fixes the situation where inteldrm(4) or radeondrm(4) would
take over the console on UEFI systems even if the kernel was booted
with a serial console.

ok jsg@


Revision tags: OPENBSD_6_4_BASE OPENBSD_6_5_BASE
# 1.45 22-Sep-2018 kettenis

branches: 1.45.2; 1.45.4;
Remap the UEFI buffer early such that we can use a write combining mapping
which speeds things up considerably compared to an uncached mapping.

ok deraadt@


# 1.44 13-Jul-2018 sf

Disable codepatching infrastructure after boot

This way, it is not available for use in ROP attacks. This diff puts the
codepatching code into a separate section and unmaps that section after boot.
In the future, the memory could potentially be reused but that would require
larger changes.

ok pguenther@


# 1.43 25-Apr-2018 jsg

Add a way to reattach efifb(4). This will be used when radeondrm(4)
attaches and claims glass console but after root is mounted if firmware
is not found efifb gets reattached to have a useable glass console.


# 1.42 20-Apr-2018 deraadt

oops, snapshot tests not ready yet


# 1.41 20-Apr-2018 deraadt

sync


Revision tags: OPENBSD_6_3_BASE
# 1.40 14-Oct-2017 jsg

reduce the amount of includes in arch/amd64
ok mpi@ deraadt@


Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE
# 1.39 25-Mar-2017 deraadt

Split vmm_probe() into a vmm_enabled() function, to better follow the
probe/attach approach used by mainbus.
ok mlarkin kettenis


# 1.38 28-Jul-2016 kettenis

Store the acpi processor ID/UID in struct cpu_info, and use it to attach
acpicpu(4) drivers to the right cpu(4).

ok mlarkin@, guenther@


Revision tags: OPENBSD_6_0_BASE
# 1.37 21-Jun-2016 jcs

add support to efifb for drawing a console on a coreboot framebuffer
if coreboot's memory table is found, it has a framebuffer entry, and
there is no previously attached efi, vga, or serial console.

useful on chromebooks that have no legacy vga device to get an early
console before inteldrm(4) attaches or, for newer chipsets, a full
console and X with wsfb(4).

ok kettenis


Revision tags: OPENBSD_5_9_BASE
# 1.36 12-Dec-2015 reyk

Identify hypervisors before configuring other children of the mainbus
(bios, CPU, interrupt handlers, pvbus). This splits the pvbus attach
function into two parts: pvbus_identify() to scan the CPUID registers
for supported hypervisors and pvbus_attach() to attach the bus, print
information, and configure the children.

This will be needed for Xen and KVM, as discussed with mikeb@ and sf@
OK mlarkin@


# 1.35 23-Nov-2015 deraadt

No longer need 'option VMM', declaring the vmm0 device is sufficient.
ok mlarkin


# 1.34 13-Nov-2015 mlarkin

vmm(4) kernel code

circulated on hackers@, no objections. Disabled by default.


# 1.33 31-Aug-2015 kettenis

Check driver name in match function such that driver only attempts to attach
when we actually want it to.

ok deraadt@


# 1.32 30-Aug-2015 kettenis

Don't try to attach efifb(4) on non-UEFI boots.

ok miod@, deraadt@


# 1.31 30-Aug-2015 yasuoka

Modify kernel to prepare boot from UEFI.

- Add new boot arg "bios_efi_info_t" to pass the paramters from UEFI
- Make bios(4) and acpi(4) be able to probe with the parameters from
UEFI
- Add efifb(8). It uses the framebuffer from UEFI and it will work as
a backend of wsdisplay(4) and wsfb (X11 video driver). Disabled by
the kernel config for this moment

input and ok kettenis


Revision tags: OPENBSD_5_8_BASE
# 1.30 21-Jul-2015 reyk

pvbus(4) was attaching too early, it has to wait for identifycpu.
Problem found on GENERIC by mlarkin.

OK mlarkin@


# 1.29 21-Jul-2015 reyk

Add pvbus(4), a pseudo-bus to attach non-PCI paravirtual devices and buses.
vmt(4) is moved from mainbus0 to pvbus0, more devices will follow.

OK sf@ deraadt@


# 1.28 14-Mar-2015 jsg

Remove some includes include-what-you-use claims don't
have any direct symbols used. Tested for indirect use by compiling
amd64/i386/sparc64 kernels.

ok tedu@ deraadt@


Revision tags: OPENBSD_5_4_BASE OPENBSD_5_5_BASE OPENBSD_5_6_BASE OPENBSD_5_7_BASE
# 1.27 30-May-2013 deraadt

Enforce ca_activate tree-walks over the entire heirarchy for all events,
cleaning up some shutdown-hook related code on the way.
(A few drivers related to sparc are still skipped at kettenis' request)
ok kettenis mlarkin, tested by many others too


Revision tags: OPENBSD_5_3_BASE
# 1.26 04-Oct-2012 ehrhardt

Use information provided by ACPI to attach secondary PCI host bridges.

ok kettenis@


# 1.25 19-Sep-2012 kettenis

Set up PCI bus number resource accounting for the main PCI bus hierarchy.


Revision tags: OPENBSD_5_1_BASE OPENBSD_5_2_BASE
# 1.24 21-Oct-2011 kettenis

Add bounds checks for access to mp_busses.


Revision tags: OPENBSD_4_9_BASE OPENBSD_5_0_BASE
# 1.23 03-Nov-2010 dlg

only let vmt match and therefore attach if mainbus is specifically asking
for vmt to attach after vmt_probe succeeds. this prevents vmt from
appearing at other attach points hanging off mainbus.

found by phessler@ and debugged gently by claudio@


Revision tags: OPENBSD_4_7_BASE OPENBSD_4_8_BASE
# 1.22 28-Dec-2009 dlg

tweak vmt to work on amd64 as well as i386. like i386, it is still
commented out in GENERIC. it needs more love.

diff by david cranshaw a long time ago. sorry it has taken so long
for me to look at it.


# 1.21 23-Nov-2009 deraadt

oops, call config_activate_children


# 1.20 23-Nov-2009 deraadt

Use config_activate_children() for our cf_activate function
ok mlarkin pirofti


Revision tags: OPENBSD_4_6_BASE
# 1.19 21-Apr-2009 kettenis

Simplify PCI config space access code. There is no way we're ever going to
see the ancient mode 2 on machines capable of running OpenBSD/amd64.

ok deraadt@, toby@, oga@


# 1.18 11-Apr-2009 kettenis

Create extents for resource accounting on the root PCI bus and populate them
based on the BIOS memory map.


# 1.17 31-Mar-2009 kettenis

bzero pci attach args


Revision tags: OPENBSD_4_5_BASE
# 1.16 13-Jan-2009 kettenis

Turn mpbios into a real device, such that people can disable it on crappy
BIOSes.

ok deraadt@ (for the amd64 bit, or the i386 bit, can't remember which)


# 1.15 21-Dec-2008 kettenis

Change the way we include mpbios code to be similar to what we do on i386.

ok deraadt@


Revision tags: OPENBSD_4_3_BASE OPENBSD_4_4_BASE
# 1.14 05-Dec-2007 deraadt

Hang acpi(4) below bios(4) instead of mainbus(4). This lets us move acpi(4)
before pcibios(4), and then.... if acpi(4) attaches, skip pcibios(4) since
it messes the machines up. Fixes claudio's HP dl320 G5, and almost assuredly
others.
ok kettenis


# 1.13 16-Nov-2007 deraadt

fix the bus_space #define nightmare, so that amd64 and i386 are much more
uniform. as a result shared code like acpi needs less #ifdef's
ok marco kettenis


Revision tags: OPENBSD_4_2_BASE
# 1.12 06-May-2007 gwk

Add the mp setperf mechanism to AMD64, like its i386 counterpart it allows
all cpus in a system supporting frequency and voltage scaling to be scaled
by the same amount corresponding to the user (or apmd on their behalf)
performance level.

This diff also teaches amd64 about acpi_hasprocfvs (ACPI has processor
frequency and voltage scaling).

It also moves initilization of the underlying setperf mechanism such
as powernow to mainbus from the cpu indentification and initilization
code inspired by similar changes dim@ made to i386 durring h2k6. This
is necessary to implement the AMD recommended method for retreiving
p_state data from the ACPI _PSS object (a diff comming soon). It will
also simplify the potential addition of enhanced speedstep as found
on newer intel processors with EMT64 capable of running OpenBSD/amd64.

MP setperf functionality verifed by myself and Johan M:son Lindman <tybolt
AT solace DOT miun DOT se> on opteron 265 and 270 systems respectively.
General testing done by many others thanks!

ok tedu, dim


Revision tags: OPENBSD_4_1_BASE
# 1.11 14-Dec-2006 kettenis

Make pci subsystem aware of domains. Each host bridge gets assigned a unique
domain number such that we can distinguish between busses with the same bus
number that are behind different host bridges. Domains can be accessed by
using different device nodes.

ok deraadt@


# 1.10 25-Nov-2006 niklas

sync amd64 to i386 w.r.t. acpi support. Also fix interrupt routing for multi-ioapic systems.
ok kettenis


# 1.9 17-Nov-2006 kettenis

Decide whether we need to attach the primary cpu by checking the CPUF_PRESENT
flag just like we do on i386.


Revision tags: OPENBSD_4_0_BASE
# 1.8 08-May-2006 gwk

Add smbios support for i386 and amd64, fix ipmi to use this new functionallity,
hook up some sysctls to add system vendor/product/version and UUID reporting.

"get it in" deraadt@


# 1.7 14-Apr-2006 marco

ANSIfy functions.
Spacing.


# 1.6 13-Mar-2006 brad

* Add "pcitag_t *pba_bridgetag" to pci_attach_args. This is set to
NULL for root PCI busses. For busses behind a bridge, it points to
a persistent copy of the bridge's pcitag_t. This can be very useful
for machine-dependent PCI bus enumeration code.

From NetBSD

ok grange@ kettenis@


# 1.5 13-Mar-2006 marco

Fix machines that need PCI access during ACPI bringup.

Help and ok kettenis.


Revision tags: OPENBSD_3_9_BASE
# 1.4 29-Dec-2005 kettenis

Fix isadma0 at isa0 at mainbus0
ok deraadt@


# 1.3 19-Oct-2005 marco

Add IPMI to amd64. Keep it disabled for now.

Prodded earlier today by deraadt@
ok krw@


Revision tags: OPENBSD_3_8_BASE
# 1.2 02-Jun-2005 tholo

Start on a basic ACPI framework -- does not do much more than read out the
ACPI tables into kernel memory and attach ACPI and HPET timers currently.

In order to test this code, enabling the devices in GENERIC as well as
the ACPI_ENABLE option is needed. This code does not do any thermal
control yet, so this should be done with care depending on the platform.

In the tree so more people can contribute to making this more fully
featured.

Ok niklas@ grange@ tedu@


Revision tags: OPENBSD_3_5_BASE OPENBSD_3_6_BASE OPENBSD_3_7_BASE SMP_SYNC_A SMP_SYNC_B
# 1.1 28-Jan-2004 mickey

an amd64 arch support.
hacked by art@ from netbsd sources and then later debugged
by me into the shape where it can host itself.
no bootloader yet as needs redoing from the
recent advanced i386 sources (anyone? ;)


# 1.50 14-May-2020 kettenis

Bring back the acpi(4) changes. This time around only use the ACPI _CRS
information on ACPI 5.0 and later.

ok krw@, patrick@


Revision tags: OPENBSD_6_6_BASE OPENBSD_6_7_BASE
# 1.49 07-Sep-2019 kettenis

Revert acpipci(4) changes. Too many systems are broken. We'll try again
after 6.6 as been released. The acpireg.h change stays behind.


# 1.48 28-Aug-2019 kettenis

Use ACPI information to attach PCI busses like we do on arm64. There are a
few additional quirks though, and attaching the PCI busses is delayed to
replicate the existing code more closely. That may be changed in the
future. Also tweak how we handle MSI support and respect to ACPI flag
that says we shouldn't attempt to use MSIs.

Some fallout is expected.

ok patrick@


# 1.47 17-May-2019 guenther

Mitigate Intel's Microarchitectural Data Sampling vulnerability.
If the CPU has the new VERW behavior than that is used, otherwise
use the proper sequence from Intel's "Deep Dive" doc is used in the
return-to-userspace and enter-VMM-guest paths. The enter-C3-idle
path is not mitigated because it's only a problem when SMT/HT is
enabled: mitigating everything when that's enabled would be a _huge_
set of changes that we see no point in doing.

Update vmm(4) to pass through the MSR bits so that guests can apply
the optimal mitigation.

VMM help and specific feedback from mlarkin@
vendor-portability help from jsg@ and kettenis@
ok kettenis@ mlarkin@ deraadt@ jsg@


# 1.46 04-May-2019 kettenis

Improve the interaction between efifb(4), inteldrm(4) and radeondrm(4)
when we have a serial console by introducing the notion of a "primary"
graphics device. The primary graphics device is the one set up and
used by firmware (BIOS, UEFI).

The goal is to make sure that wsdisplay0 and drm0 reliably attach to
the primary graphics device such that X works out of the box even
if you have multiple cards or if you are using a serial console.

This also fixes the situation where inteldrm(4) or radeondrm(4) would
take over the console on UEFI systems even if the kernel was booted
with a serial console.

ok jsg@


Revision tags: OPENBSD_6_4_BASE OPENBSD_6_5_BASE
# 1.45 22-Sep-2018 kettenis

branches: 1.45.2; 1.45.4;
Remap the UEFI buffer early such that we can use a write combining mapping
which speeds things up considerably compared to an uncached mapping.

ok deraadt@


# 1.44 13-Jul-2018 sf

Disable codepatching infrastructure after boot

This way, it is not available for use in ROP attacks. This diff puts the
codepatching code into a separate section and unmaps that section after boot.
In the future, the memory could potentially be reused but that would require
larger changes.

ok pguenther@


# 1.43 25-Apr-2018 jsg

Add a way to reattach efifb(4). This will be used when radeondrm(4)
attaches and claims glass console but after root is mounted if firmware
is not found efifb gets reattached to have a useable glass console.


# 1.42 20-Apr-2018 deraadt

oops, snapshot tests not ready yet


# 1.41 20-Apr-2018 deraadt

sync


Revision tags: OPENBSD_6_3_BASE
# 1.40 14-Oct-2017 jsg

reduce the amount of includes in arch/amd64
ok mpi@ deraadt@


Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE
# 1.39 25-Mar-2017 deraadt

Split vmm_probe() into a vmm_enabled() function, to better follow the
probe/attach approach used by mainbus.
ok mlarkin kettenis


# 1.38 28-Jul-2016 kettenis

Store the acpi processor ID/UID in struct cpu_info, and use it to attach
acpicpu(4) drivers to the right cpu(4).

ok mlarkin@, guenther@


Revision tags: OPENBSD_6_0_BASE
# 1.37 21-Jun-2016 jcs

add support to efifb for drawing a console on a coreboot framebuffer
if coreboot's memory table is found, it has a framebuffer entry, and
there is no previously attached efi, vga, or serial console.

useful on chromebooks that have no legacy vga device to get an early
console before inteldrm(4) attaches or, for newer chipsets, a full
console and X with wsfb(4).

ok kettenis


Revision tags: OPENBSD_5_9_BASE
# 1.36 12-Dec-2015 reyk

Identify hypervisors before configuring other children of the mainbus
(bios, CPU, interrupt handlers, pvbus). This splits the pvbus attach
function into two parts: pvbus_identify() to scan the CPUID registers
for supported hypervisors and pvbus_attach() to attach the bus, print
information, and configure the children.

This will be needed for Xen and KVM, as discussed with mikeb@ and sf@
OK mlarkin@


# 1.35 23-Nov-2015 deraadt

No longer need 'option VMM', declaring the vmm0 device is sufficient.
ok mlarkin


# 1.34 13-Nov-2015 mlarkin

vmm(4) kernel code

circulated on hackers@, no objections. Disabled by default.


# 1.33 31-Aug-2015 kettenis

Check driver name in match function such that driver only attempts to attach
when we actually want it to.

ok deraadt@


# 1.32 30-Aug-2015 kettenis

Don't try to attach efifb(4) on non-UEFI boots.

ok miod@, deraadt@


# 1.31 30-Aug-2015 yasuoka

Modify kernel to prepare boot from UEFI.

- Add new boot arg "bios_efi_info_t" to pass the paramters from UEFI
- Make bios(4) and acpi(4) be able to probe with the parameters from
UEFI
- Add efifb(8). It uses the framebuffer from UEFI and it will work as
a backend of wsdisplay(4) and wsfb (X11 video driver). Disabled by
the kernel config for this moment

input and ok kettenis


Revision tags: OPENBSD_5_8_BASE
# 1.30 21-Jul-2015 reyk

pvbus(4) was attaching too early, it has to wait for identifycpu.
Problem found on GENERIC by mlarkin.

OK mlarkin@


# 1.29 21-Jul-2015 reyk

Add pvbus(4), a pseudo-bus to attach non-PCI paravirtual devices and buses.
vmt(4) is moved from mainbus0 to pvbus0, more devices will follow.

OK sf@ deraadt@


# 1.28 14-Mar-2015 jsg

Remove some includes include-what-you-use claims don't
have any direct symbols used. Tested for indirect use by compiling
amd64/i386/sparc64 kernels.

ok tedu@ deraadt@


Revision tags: OPENBSD_5_4_BASE OPENBSD_5_5_BASE OPENBSD_5_6_BASE OPENBSD_5_7_BASE
# 1.27 30-May-2013 deraadt

Enforce ca_activate tree-walks over the entire heirarchy for all events,
cleaning up some shutdown-hook related code on the way.
(A few drivers related to sparc are still skipped at kettenis' request)
ok kettenis mlarkin, tested by many others too


Revision tags: OPENBSD_5_3_BASE
# 1.26 04-Oct-2012 ehrhardt

Use information provided by ACPI to attach secondary PCI host bridges.

ok kettenis@


# 1.25 19-Sep-2012 kettenis

Set up PCI bus number resource accounting for the main PCI bus hierarchy.


Revision tags: OPENBSD_5_1_BASE OPENBSD_5_2_BASE
# 1.24 21-Oct-2011 kettenis

Add bounds checks for access to mp_busses.


Revision tags: OPENBSD_4_9_BASE OPENBSD_5_0_BASE
# 1.23 03-Nov-2010 dlg

only let vmt match and therefore attach if mainbus is specifically asking
for vmt to attach after vmt_probe succeeds. this prevents vmt from
appearing at other attach points hanging off mainbus.

found by phessler@ and debugged gently by claudio@


Revision tags: OPENBSD_4_7_BASE OPENBSD_4_8_BASE
# 1.22 28-Dec-2009 dlg

tweak vmt to work on amd64 as well as i386. like i386, it is still
commented out in GENERIC. it needs more love.

diff by david cranshaw a long time ago. sorry it has taken so long
for me to look at it.


# 1.21 23-Nov-2009 deraadt

oops, call config_activate_children


# 1.20 23-Nov-2009 deraadt

Use config_activate_children() for our cf_activate function
ok mlarkin pirofti


Revision tags: OPENBSD_4_6_BASE
# 1.19 21-Apr-2009 kettenis

Simplify PCI config space access code. There is no way we're ever going to
see the ancient mode 2 on machines capable of running OpenBSD/amd64.

ok deraadt@, toby@, oga@


# 1.18 11-Apr-2009 kettenis

Create extents for resource accounting on the root PCI bus and populate them
based on the BIOS memory map.


# 1.17 31-Mar-2009 kettenis

bzero pci attach args


Revision tags: OPENBSD_4_5_BASE
# 1.16 13-Jan-2009 kettenis

Turn mpbios into a real device, such that people can disable it on crappy
BIOSes.

ok deraadt@ (for the amd64 bit, or the i386 bit, can't remember which)


# 1.15 21-Dec-2008 kettenis

Change the way we include mpbios code to be similar to what we do on i386.

ok deraadt@


Revision tags: OPENBSD_4_3_BASE OPENBSD_4_4_BASE
# 1.14 05-Dec-2007 deraadt

Hang acpi(4) below bios(4) instead of mainbus(4). This lets us move acpi(4)
before pcibios(4), and then.... if acpi(4) attaches, skip pcibios(4) since
it messes the machines up. Fixes claudio's HP dl320 G5, and almost assuredly
others.
ok kettenis


# 1.13 16-Nov-2007 deraadt

fix the bus_space #define nightmare, so that amd64 and i386 are much more
uniform. as a result shared code like acpi needs less #ifdef's
ok marco kettenis


Revision tags: OPENBSD_4_2_BASE
# 1.12 06-May-2007 gwk

Add the mp setperf mechanism to AMD64, like its i386 counterpart it allows
all cpus in a system supporting frequency and voltage scaling to be scaled
by the same amount corresponding to the user (or apmd on their behalf)
performance level.

This diff also teaches amd64 about acpi_hasprocfvs (ACPI has processor
frequency and voltage scaling).

It also moves initilization of the underlying setperf mechanism such
as powernow to mainbus from the cpu indentification and initilization
code inspired by similar changes dim@ made to i386 durring h2k6. This
is necessary to implement the AMD recommended method for retreiving
p_state data from the ACPI _PSS object (a diff comming soon). It will
also simplify the potential addition of enhanced speedstep as found
on newer intel processors with EMT64 capable of running OpenBSD/amd64.

MP setperf functionality verifed by myself and Johan M:son Lindman <tybolt
AT solace DOT miun DOT se> on opteron 265 and 270 systems respectively.
General testing done by many others thanks!

ok tedu, dim


Revision tags: OPENBSD_4_1_BASE
# 1.11 14-Dec-2006 kettenis

Make pci subsystem aware of domains. Each host bridge gets assigned a unique
domain number such that we can distinguish between busses with the same bus
number that are behind different host bridges. Domains can be accessed by
using different device nodes.

ok deraadt@


# 1.10 25-Nov-2006 niklas

sync amd64 to i386 w.r.t. acpi support. Also fix interrupt routing for multi-ioapic systems.
ok kettenis


# 1.9 17-Nov-2006 kettenis

Decide whether we need to attach the primary cpu by checking the CPUF_PRESENT
flag just like we do on i386.


Revision tags: OPENBSD_4_0_BASE
# 1.8 08-May-2006 gwk

Add smbios support for i386 and amd64, fix ipmi to use this new functionallity,
hook up some sysctls to add system vendor/product/version and UUID reporting.

"get it in" deraadt@


# 1.7 14-Apr-2006 marco

ANSIfy functions.
Spacing.


# 1.6 13-Mar-2006 brad

* Add "pcitag_t *pba_bridgetag" to pci_attach_args. This is set to
NULL for root PCI busses. For busses behind a bridge, it points to
a persistent copy of the bridge's pcitag_t. This can be very useful
for machine-dependent PCI bus enumeration code.

From NetBSD

ok grange@ kettenis@


# 1.5 13-Mar-2006 marco

Fix machines that need PCI access during ACPI bringup.

Help and ok kettenis.


Revision tags: OPENBSD_3_9_BASE
# 1.4 29-Dec-2005 kettenis

Fix isadma0 at isa0 at mainbus0
ok deraadt@


# 1.3 19-Oct-2005 marco

Add IPMI to amd64. Keep it disabled for now.

Prodded earlier today by deraadt@
ok krw@


Revision tags: OPENBSD_3_8_BASE
# 1.2 02-Jun-2005 tholo

Start on a basic ACPI framework -- does not do much more than read out the
ACPI tables into kernel memory and attach ACPI and HPET timers currently.

In order to test this code, enabling the devices in GENERIC as well as
the ACPI_ENABLE option is needed. This code does not do any thermal
control yet, so this should be done with care depending on the platform.

In the tree so more people can contribute to making this more fully
featured.

Ok niklas@ grange@ tedu@


Revision tags: OPENBSD_3_5_BASE OPENBSD_3_6_BASE OPENBSD_3_7_BASE SMP_SYNC_A SMP_SYNC_B
# 1.1 28-Jan-2004 mickey

an amd64 arch support.
hacked by art@ from netbsd sources and then later debugged
by me into the shape where it can host itself.
no bootloader yet as needs redoing from the
recent advanced i386 sources (anyone? ;)


# 1.49 07-Sep-2019 kettenis

Revert acpipci(4) changes. Too many systems are broken. We'll try again
after 6.6 as been released. The acpireg.h change stays behind.


# 1.48 28-Aug-2019 kettenis

Use ACPI information to attach PCI busses like we do on arm64. There are a
few additional quirks though, and attaching the PCI busses is delayed to
replicate the existing code more closely. That may be changed in the
future. Also tweak how we handle MSI support and respect to ACPI flag
that says we shouldn't attempt to use MSIs.

Some fallout is expected.

ok patrick@


# 1.47 17-May-2019 guenther

Mitigate Intel's Microarchitectural Data Sampling vulnerability.
If the CPU has the new VERW behavior than that is used, otherwise
use the proper sequence from Intel's "Deep Dive" doc is used in the
return-to-userspace and enter-VMM-guest paths. The enter-C3-idle
path is not mitigated because it's only a problem when SMT/HT is
enabled: mitigating everything when that's enabled would be a _huge_
set of changes that we see no point in doing.

Update vmm(4) to pass through the MSR bits so that guests can apply
the optimal mitigation.

VMM help and specific feedback from mlarkin@
vendor-portability help from jsg@ and kettenis@
ok kettenis@ mlarkin@ deraadt@ jsg@


# 1.46 04-May-2019 kettenis

Improve the interaction between efifb(4), inteldrm(4) and radeondrm(4)
when we have a serial console by introducing the notion of a "primary"
graphics device. The primary graphics device is the one set up and
used by firmware (BIOS, UEFI).

The goal is to make sure that wsdisplay0 and drm0 reliably attach to
the primary graphics device such that X works out of the box even
if you have multiple cards or if you are using a serial console.

This also fixes the situation where inteldrm(4) or radeondrm(4) would
take over the console on UEFI systems even if the kernel was booted
with a serial console.

ok jsg@


Revision tags: OPENBSD_6_4_BASE OPENBSD_6_5_BASE
# 1.45 22-Sep-2018 kettenis

branches: 1.45.2; 1.45.4;
Remap the UEFI buffer early such that we can use a write combining mapping
which speeds things up considerably compared to an uncached mapping.

ok deraadt@


# 1.44 13-Jul-2018 sf

Disable codepatching infrastructure after boot

This way, it is not available for use in ROP attacks. This diff puts the
codepatching code into a separate section and unmaps that section after boot.
In the future, the memory could potentially be reused but that would require
larger changes.

ok pguenther@


# 1.43 25-Apr-2018 jsg

Add a way to reattach efifb(4). This will be used when radeondrm(4)
attaches and claims glass console but after root is mounted if firmware
is not found efifb gets reattached to have a useable glass console.


# 1.42 20-Apr-2018 deraadt

oops, snapshot tests not ready yet


# 1.41 20-Apr-2018 deraadt

sync


Revision tags: OPENBSD_6_3_BASE
# 1.40 14-Oct-2017 jsg

reduce the amount of includes in arch/amd64
ok mpi@ deraadt@


Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE
# 1.39 25-Mar-2017 deraadt

Split vmm_probe() into a vmm_enabled() function, to better follow the
probe/attach approach used by mainbus.
ok mlarkin kettenis


# 1.38 28-Jul-2016 kettenis

Store the acpi processor ID/UID in struct cpu_info, and use it to attach
acpicpu(4) drivers to the right cpu(4).

ok mlarkin@, guenther@


Revision tags: OPENBSD_6_0_BASE
# 1.37 21-Jun-2016 jcs

add support to efifb for drawing a console on a coreboot framebuffer
if coreboot's memory table is found, it has a framebuffer entry, and
there is no previously attached efi, vga, or serial console.

useful on chromebooks that have no legacy vga device to get an early
console before inteldrm(4) attaches or, for newer chipsets, a full
console and X with wsfb(4).

ok kettenis


Revision tags: OPENBSD_5_9_BASE
# 1.36 12-Dec-2015 reyk

Identify hypervisors before configuring other children of the mainbus
(bios, CPU, interrupt handlers, pvbus). This splits the pvbus attach
function into two parts: pvbus_identify() to scan the CPUID registers
for supported hypervisors and pvbus_attach() to attach the bus, print
information, and configure the children.

This will be needed for Xen and KVM, as discussed with mikeb@ and sf@
OK mlarkin@


# 1.35 23-Nov-2015 deraadt

No longer need 'option VMM', declaring the vmm0 device is sufficient.
ok mlarkin


# 1.34 13-Nov-2015 mlarkin

vmm(4) kernel code

circulated on hackers@, no objections. Disabled by default.


# 1.33 31-Aug-2015 kettenis

Check driver name in match function such that driver only attempts to attach
when we actually want it to.

ok deraadt@


# 1.32 30-Aug-2015 kettenis

Don't try to attach efifb(4) on non-UEFI boots.

ok miod@, deraadt@


# 1.31 30-Aug-2015 yasuoka

Modify kernel to prepare boot from UEFI.

- Add new boot arg "bios_efi_info_t" to pass the paramters from UEFI
- Make bios(4) and acpi(4) be able to probe with the parameters from
UEFI
- Add efifb(8). It uses the framebuffer from UEFI and it will work as
a backend of wsdisplay(4) and wsfb (X11 video driver). Disabled by
the kernel config for this moment

input and ok kettenis


Revision tags: OPENBSD_5_8_BASE
# 1.30 21-Jul-2015 reyk

pvbus(4) was attaching too early, it has to wait for identifycpu.
Problem found on GENERIC by mlarkin.

OK mlarkin@


# 1.29 21-Jul-2015 reyk

Add pvbus(4), a pseudo-bus to attach non-PCI paravirtual devices and buses.
vmt(4) is moved from mainbus0 to pvbus0, more devices will follow.

OK sf@ deraadt@


# 1.28 14-Mar-2015 jsg

Remove some includes include-what-you-use claims don't
have any direct symbols used. Tested for indirect use by compiling
amd64/i386/sparc64 kernels.

ok tedu@ deraadt@


Revision tags: OPENBSD_5_4_BASE OPENBSD_5_5_BASE OPENBSD_5_6_BASE OPENBSD_5_7_BASE
# 1.27 30-May-2013 deraadt

Enforce ca_activate tree-walks over the entire heirarchy for all events,
cleaning up some shutdown-hook related code on the way.
(A few drivers related to sparc are still skipped at kettenis' request)
ok kettenis mlarkin, tested by many others too


Revision tags: OPENBSD_5_3_BASE
# 1.26 04-Oct-2012 ehrhardt

Use information provided by ACPI to attach secondary PCI host bridges.

ok kettenis@


# 1.25 19-Sep-2012 kettenis

Set up PCI bus number resource accounting for the main PCI bus hierarchy.


Revision tags: OPENBSD_5_1_BASE OPENBSD_5_2_BASE
# 1.24 21-Oct-2011 kettenis

Add bounds checks for access to mp_busses.


Revision tags: OPENBSD_4_9_BASE OPENBSD_5_0_BASE
# 1.23 03-Nov-2010 dlg

only let vmt match and therefore attach if mainbus is specifically asking
for vmt to attach after vmt_probe succeeds. this prevents vmt from
appearing at other attach points hanging off mainbus.

found by phessler@ and debugged gently by claudio@


Revision tags: OPENBSD_4_7_BASE OPENBSD_4_8_BASE
# 1.22 28-Dec-2009 dlg

tweak vmt to work on amd64 as well as i386. like i386, it is still
commented out in GENERIC. it needs more love.

diff by david cranshaw a long time ago. sorry it has taken so long
for me to look at it.


# 1.21 23-Nov-2009 deraadt

oops, call config_activate_children


# 1.20 23-Nov-2009 deraadt

Use config_activate_children() for our cf_activate function
ok mlarkin pirofti


Revision tags: OPENBSD_4_6_BASE
# 1.19 21-Apr-2009 kettenis

Simplify PCI config space access code. There is no way we're ever going to
see the ancient mode 2 on machines capable of running OpenBSD/amd64.

ok deraadt@, toby@, oga@


# 1.18 11-Apr-2009 kettenis

Create extents for resource accounting on the root PCI bus and populate them
based on the BIOS memory map.


# 1.17 31-Mar-2009 kettenis

bzero pci attach args


Revision tags: OPENBSD_4_5_BASE
# 1.16 13-Jan-2009 kettenis

Turn mpbios into a real device, such that people can disable it on crappy
BIOSes.

ok deraadt@ (for the amd64 bit, or the i386 bit, can't remember which)


# 1.15 21-Dec-2008 kettenis

Change the way we include mpbios code to be similar to what we do on i386.

ok deraadt@


Revision tags: OPENBSD_4_3_BASE OPENBSD_4_4_BASE
# 1.14 05-Dec-2007 deraadt

Hang acpi(4) below bios(4) instead of mainbus(4). This lets us move acpi(4)
before pcibios(4), and then.... if acpi(4) attaches, skip pcibios(4) since
it messes the machines up. Fixes claudio's HP dl320 G5, and almost assuredly
others.
ok kettenis


# 1.13 16-Nov-2007 deraadt

fix the bus_space #define nightmare, so that amd64 and i386 are much more
uniform. as a result shared code like acpi needs less #ifdef's
ok marco kettenis


Revision tags: OPENBSD_4_2_BASE
# 1.12 06-May-2007 gwk

Add the mp setperf mechanism to AMD64, like its i386 counterpart it allows
all cpus in a system supporting frequency and voltage scaling to be scaled
by the same amount corresponding to the user (or apmd on their behalf)
performance level.

This diff also teaches amd64 about acpi_hasprocfvs (ACPI has processor
frequency and voltage scaling).

It also moves initilization of the underlying setperf mechanism such
as powernow to mainbus from the cpu indentification and initilization
code inspired by similar changes dim@ made to i386 durring h2k6. This
is necessary to implement the AMD recommended method for retreiving
p_state data from the ACPI _PSS object (a diff comming soon). It will
also simplify the potential addition of enhanced speedstep as found
on newer intel processors with EMT64 capable of running OpenBSD/amd64.

MP setperf functionality verifed by myself and Johan M:son Lindman <tybolt
AT solace DOT miun DOT se> on opteron 265 and 270 systems respectively.
General testing done by many others thanks!

ok tedu, dim


Revision tags: OPENBSD_4_1_BASE
# 1.11 14-Dec-2006 kettenis

Make pci subsystem aware of domains. Each host bridge gets assigned a unique
domain number such that we can distinguish between busses with the same bus
number that are behind different host bridges. Domains can be accessed by
using different device nodes.

ok deraadt@


# 1.10 25-Nov-2006 niklas

sync amd64 to i386 w.r.t. acpi support. Also fix interrupt routing for multi-ioapic systems.
ok kettenis


# 1.9 17-Nov-2006 kettenis

Decide whether we need to attach the primary cpu by checking the CPUF_PRESENT
flag just like we do on i386.


Revision tags: OPENBSD_4_0_BASE
# 1.8 08-May-2006 gwk

Add smbios support for i386 and amd64, fix ipmi to use this new functionallity,
hook up some sysctls to add system vendor/product/version and UUID reporting.

"get it in" deraadt@


# 1.7 14-Apr-2006 marco

ANSIfy functions.
Spacing.


# 1.6 13-Mar-2006 brad

* Add "pcitag_t *pba_bridgetag" to pci_attach_args. This is set to
NULL for root PCI busses. For busses behind a bridge, it points to
a persistent copy of the bridge's pcitag_t. This can be very useful
for machine-dependent PCI bus enumeration code.

From NetBSD

ok grange@ kettenis@


# 1.5 13-Mar-2006 marco

Fix machines that need PCI access during ACPI bringup.

Help and ok kettenis.


Revision tags: OPENBSD_3_9_BASE
# 1.4 29-Dec-2005 kettenis

Fix isadma0 at isa0 at mainbus0
ok deraadt@


# 1.3 19-Oct-2005 marco

Add IPMI to amd64. Keep it disabled for now.

Prodded earlier today by deraadt@
ok krw@


Revision tags: OPENBSD_3_8_BASE
# 1.2 02-Jun-2005 tholo

Start on a basic ACPI framework -- does not do much more than read out the
ACPI tables into kernel memory and attach ACPI and HPET timers currently.

In order to test this code, enabling the devices in GENERIC as well as
the ACPI_ENABLE option is needed. This code does not do any thermal
control yet, so this should be done with care depending on the platform.

In the tree so more people can contribute to making this more fully
featured.

Ok niklas@ grange@ tedu@


Revision tags: OPENBSD_3_5_BASE OPENBSD_3_6_BASE OPENBSD_3_7_BASE SMP_SYNC_A SMP_SYNC_B
# 1.1 28-Jan-2004 mickey

an amd64 arch support.
hacked by art@ from netbsd sources and then later debugged
by me into the shape where it can host itself.
no bootloader yet as needs redoing from the
recent advanced i386 sources (anyone? ;)


# 1.48 28-Aug-2019 kettenis

Use ACPI information to attach PCI busses like we do on arm64. There are a
few additional quirks though, and attaching the PCI busses is delayed to
replicate the existing code more closely. That may be changed in the
future. Also tweak how we handle MSI support and respect to ACPI flag
that says we shouldn't attempt to use MSIs.

Some fallout is expected.

ok patrick@


# 1.47 17-May-2019 guenther

Mitigate Intel's Microarchitectural Data Sampling vulnerability.
If the CPU has the new VERW behavior than that is used, otherwise
use the proper sequence from Intel's "Deep Dive" doc is used in the
return-to-userspace and enter-VMM-guest paths. The enter-C3-idle
path is not mitigated because it's only a problem when SMT/HT is
enabled: mitigating everything when that's enabled would be a _huge_
set of changes that we see no point in doing.

Update vmm(4) to pass through the MSR bits so that guests can apply
the optimal mitigation.

VMM help and specific feedback from mlarkin@
vendor-portability help from jsg@ and kettenis@
ok kettenis@ mlarkin@ deraadt@ jsg@


# 1.46 04-May-2019 kettenis

Improve the interaction between efifb(4), inteldrm(4) and radeondrm(4)
when we have a serial console by introducing the notion of a "primary"
graphics device. The primary graphics device is the one set up and
used by firmware (BIOS, UEFI).

The goal is to make sure that wsdisplay0 and drm0 reliably attach to
the primary graphics device such that X works out of the box even
if you have multiple cards or if you are using a serial console.

This also fixes the situation where inteldrm(4) or radeondrm(4) would
take over the console on UEFI systems even if the kernel was booted
with a serial console.

ok jsg@


Revision tags: OPENBSD_6_4_BASE OPENBSD_6_5_BASE
# 1.45 22-Sep-2018 kettenis

branches: 1.45.2; 1.45.4;
Remap the UEFI buffer early such that we can use a write combining mapping
which speeds things up considerably compared to an uncached mapping.

ok deraadt@


# 1.44 13-Jul-2018 sf

Disable codepatching infrastructure after boot

This way, it is not available for use in ROP attacks. This diff puts the
codepatching code into a separate section and unmaps that section after boot.
In the future, the memory could potentially be reused but that would require
larger changes.

ok pguenther@


# 1.43 25-Apr-2018 jsg

Add a way to reattach efifb(4). This will be used when radeondrm(4)
attaches and claims glass console but after root is mounted if firmware
is not found efifb gets reattached to have a useable glass console.


# 1.42 20-Apr-2018 deraadt

oops, snapshot tests not ready yet


# 1.41 20-Apr-2018 deraadt

sync


Revision tags: OPENBSD_6_3_BASE
# 1.40 14-Oct-2017 jsg

reduce the amount of includes in arch/amd64
ok mpi@ deraadt@


Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE
# 1.39 25-Mar-2017 deraadt

Split vmm_probe() into a vmm_enabled() function, to better follow the
probe/attach approach used by mainbus.
ok mlarkin kettenis


# 1.38 28-Jul-2016 kettenis

Store the acpi processor ID/UID in struct cpu_info, and use it to attach
acpicpu(4) drivers to the right cpu(4).

ok mlarkin@, guenther@


Revision tags: OPENBSD_6_0_BASE
# 1.37 21-Jun-2016 jcs

add support to efifb for drawing a console on a coreboot framebuffer
if coreboot's memory table is found, it has a framebuffer entry, and
there is no previously attached efi, vga, or serial console.

useful on chromebooks that have no legacy vga device to get an early
console before inteldrm(4) attaches or, for newer chipsets, a full
console and X with wsfb(4).

ok kettenis


Revision tags: OPENBSD_5_9_BASE
# 1.36 12-Dec-2015 reyk

Identify hypervisors before configuring other children of the mainbus
(bios, CPU, interrupt handlers, pvbus). This splits the pvbus attach
function into two parts: pvbus_identify() to scan the CPUID registers
for supported hypervisors and pvbus_attach() to attach the bus, print
information, and configure the children.

This will be needed for Xen and KVM, as discussed with mikeb@ and sf@
OK mlarkin@


# 1.35 23-Nov-2015 deraadt

No longer need 'option VMM', declaring the vmm0 device is sufficient.
ok mlarkin


# 1.34 13-Nov-2015 mlarkin

vmm(4) kernel code

circulated on hackers@, no objections. Disabled by default.


# 1.33 31-Aug-2015 kettenis

Check driver name in match function such that driver only attempts to attach
when we actually want it to.

ok deraadt@


# 1.32 30-Aug-2015 kettenis

Don't try to attach efifb(4) on non-UEFI boots.

ok miod@, deraadt@


# 1.31 30-Aug-2015 yasuoka

Modify kernel to prepare boot from UEFI.

- Add new boot arg "bios_efi_info_t" to pass the paramters from UEFI
- Make bios(4) and acpi(4) be able to probe with the parameters from
UEFI
- Add efifb(8). It uses the framebuffer from UEFI and it will work as
a backend of wsdisplay(4) and wsfb (X11 video driver). Disabled by
the kernel config for this moment

input and ok kettenis


Revision tags: OPENBSD_5_8_BASE
# 1.30 21-Jul-2015 reyk

pvbus(4) was attaching too early, it has to wait for identifycpu.
Problem found on GENERIC by mlarkin.

OK mlarkin@


# 1.29 21-Jul-2015 reyk

Add pvbus(4), a pseudo-bus to attach non-PCI paravirtual devices and buses.
vmt(4) is moved from mainbus0 to pvbus0, more devices will follow.

OK sf@ deraadt@


# 1.28 14-Mar-2015 jsg

Remove some includes include-what-you-use claims don't
have any direct symbols used. Tested for indirect use by compiling
amd64/i386/sparc64 kernels.

ok tedu@ deraadt@


Revision tags: OPENBSD_5_4_BASE OPENBSD_5_5_BASE OPENBSD_5_6_BASE OPENBSD_5_7_BASE
# 1.27 30-May-2013 deraadt

Enforce ca_activate tree-walks over the entire heirarchy for all events,
cleaning up some shutdown-hook related code on the way.
(A few drivers related to sparc are still skipped at kettenis' request)
ok kettenis mlarkin, tested by many others too


Revision tags: OPENBSD_5_3_BASE
# 1.26 04-Oct-2012 ehrhardt

Use information provided by ACPI to attach secondary PCI host bridges.

ok kettenis@


# 1.25 19-Sep-2012 kettenis

Set up PCI bus number resource accounting for the main PCI bus hierarchy.


Revision tags: OPENBSD_5_1_BASE OPENBSD_5_2_BASE
# 1.24 21-Oct-2011 kettenis

Add bounds checks for access to mp_busses.


Revision tags: OPENBSD_4_9_BASE OPENBSD_5_0_BASE
# 1.23 03-Nov-2010 dlg

only let vmt match and therefore attach if mainbus is specifically asking
for vmt to attach after vmt_probe succeeds. this prevents vmt from
appearing at other attach points hanging off mainbus.

found by phessler@ and debugged gently by claudio@


Revision tags: OPENBSD_4_7_BASE OPENBSD_4_8_BASE
# 1.22 28-Dec-2009 dlg

tweak vmt to work on amd64 as well as i386. like i386, it is still
commented out in GENERIC. it needs more love.

diff by david cranshaw a long time ago. sorry it has taken so long
for me to look at it.


# 1.21 23-Nov-2009 deraadt

oops, call config_activate_children


# 1.20 23-Nov-2009 deraadt

Use config_activate_children() for our cf_activate function
ok mlarkin pirofti


Revision tags: OPENBSD_4_6_BASE
# 1.19 21-Apr-2009 kettenis

Simplify PCI config space access code. There is no way we're ever going to
see the ancient mode 2 on machines capable of running OpenBSD/amd64.

ok deraadt@, toby@, oga@


# 1.18 11-Apr-2009 kettenis

Create extents for resource accounting on the root PCI bus and populate them
based on the BIOS memory map.


# 1.17 31-Mar-2009 kettenis

bzero pci attach args


Revision tags: OPENBSD_4_5_BASE
# 1.16 13-Jan-2009 kettenis

Turn mpbios into a real device, such that people can disable it on crappy
BIOSes.

ok deraadt@ (for the amd64 bit, or the i386 bit, can't remember which)


# 1.15 21-Dec-2008 kettenis

Change the way we include mpbios code to be similar to what we do on i386.

ok deraadt@


Revision tags: OPENBSD_4_3_BASE OPENBSD_4_4_BASE
# 1.14 05-Dec-2007 deraadt

Hang acpi(4) below bios(4) instead of mainbus(4). This lets us move acpi(4)
before pcibios(4), and then.... if acpi(4) attaches, skip pcibios(4) since
it messes the machines up. Fixes claudio's HP dl320 G5, and almost assuredly
others.
ok kettenis


# 1.13 16-Nov-2007 deraadt

fix the bus_space #define nightmare, so that amd64 and i386 are much more
uniform. as a result shared code like acpi needs less #ifdef's
ok marco kettenis


Revision tags: OPENBSD_4_2_BASE
# 1.12 06-May-2007 gwk

Add the mp setperf mechanism to AMD64, like its i386 counterpart it allows
all cpus in a system supporting frequency and voltage scaling to be scaled
by the same amount corresponding to the user (or apmd on their behalf)
performance level.

This diff also teaches amd64 about acpi_hasprocfvs (ACPI has processor
frequency and voltage scaling).

It also moves initilization of the underlying setperf mechanism such
as powernow to mainbus from the cpu indentification and initilization
code inspired by similar changes dim@ made to i386 durring h2k6. This
is necessary to implement the AMD recommended method for retreiving
p_state data from the ACPI _PSS object (a diff comming soon). It will
also simplify the potential addition of enhanced speedstep as found
on newer intel processors with EMT64 capable of running OpenBSD/amd64.

MP setperf functionality verifed by myself and Johan M:son Lindman <tybolt
AT solace DOT miun DOT se> on opteron 265 and 270 systems respectively.
General testing done by many others thanks!

ok tedu, dim


Revision tags: OPENBSD_4_1_BASE
# 1.11 14-Dec-2006 kettenis

Make pci subsystem aware of domains. Each host bridge gets assigned a unique
domain number such that we can distinguish between busses with the same bus
number that are behind different host bridges. Domains can be accessed by
using different device nodes.

ok deraadt@


# 1.10 25-Nov-2006 niklas

sync amd64 to i386 w.r.t. acpi support. Also fix interrupt routing for multi-ioapic systems.
ok kettenis


# 1.9 17-Nov-2006 kettenis

Decide whether we need to attach the primary cpu by checking the CPUF_PRESENT
flag just like we do on i386.


Revision tags: OPENBSD_4_0_BASE
# 1.8 08-May-2006 gwk

Add smbios support for i386 and amd64, fix ipmi to use this new functionallity,
hook up some sysctls to add system vendor/product/version and UUID reporting.

"get it in" deraadt@


# 1.7 14-Apr-2006 marco

ANSIfy functions.
Spacing.


# 1.6 13-Mar-2006 brad

* Add "pcitag_t *pba_bridgetag" to pci_attach_args. This is set to
NULL for root PCI busses. For busses behind a bridge, it points to
a persistent copy of the bridge's pcitag_t. This can be very useful
for machine-dependent PCI bus enumeration code.

From NetBSD

ok grange@ kettenis@


# 1.5 13-Mar-2006 marco

Fix machines that need PCI access during ACPI bringup.

Help and ok kettenis.


Revision tags: OPENBSD_3_9_BASE
# 1.4 29-Dec-2005 kettenis

Fix isadma0 at isa0 at mainbus0
ok deraadt@


# 1.3 19-Oct-2005 marco

Add IPMI to amd64. Keep it disabled for now.

Prodded earlier today by deraadt@
ok krw@


Revision tags: OPENBSD_3_8_BASE
# 1.2 02-Jun-2005 tholo

Start on a basic ACPI framework -- does not do much more than read out the
ACPI tables into kernel memory and attach ACPI and HPET timers currently.

In order to test this code, enabling the devices in GENERIC as well as
the ACPI_ENABLE option is needed. This code does not do any thermal
control yet, so this should be done with care depending on the platform.

In the tree so more people can contribute to making this more fully
featured.

Ok niklas@ grange@ tedu@


Revision tags: OPENBSD_3_5_BASE OPENBSD_3_6_BASE OPENBSD_3_7_BASE SMP_SYNC_A SMP_SYNC_B
# 1.1 28-Jan-2004 mickey

an amd64 arch support.
hacked by art@ from netbsd sources and then later debugged
by me into the shape where it can host itself.
no bootloader yet as needs redoing from the
recent advanced i386 sources (anyone? ;)


# 1.47 17-May-2019 guenther

Mitigate Intel's Microarchitectural Data Sampling vulnerability.
If the CPU has the new VERW behavior than that is used, otherwise
use the proper sequence from Intel's "Deep Dive" doc is used in the
return-to-userspace and enter-VMM-guest paths. The enter-C3-idle
path is not mitigated because it's only a problem when SMT/HT is
enabled: mitigating everything when that's enabled would be a _huge_
set of changes that we see no point in doing.

Update vmm(4) to pass through the MSR bits so that guests can apply
the optimal mitigation.

VMM help and specific feedback from mlarkin@
vendor-portability help from jsg@ and kettenis@
ok kettenis@ mlarkin@ deraadt@ jsg@


# 1.46 04-May-2019 kettenis

Improve the interaction between efifb(4), inteldrm(4) and radeondrm(4)
when we have a serial console by introducing the notion of a "primary"
graphics device. The primary graphics device is the one set up and
used by firmware (BIOS, UEFI).

The goal is to make sure that wsdisplay0 and drm0 reliably attach to
the primary graphics device such that X works out of the box even
if you have multiple cards or if you are using a serial console.

This also fixes the situation where inteldrm(4) or radeondrm(4) would
take over the console on UEFI systems even if the kernel was booted
with a serial console.

ok jsg@


Revision tags: OPENBSD_6_4_BASE OPENBSD_6_5_BASE
# 1.45 22-Sep-2018 kettenis

Remap the UEFI buffer early such that we can use a write combining mapping
which speeds things up considerably compared to an uncached mapping.

ok deraadt@


# 1.44 13-Jul-2018 sf

Disable codepatching infrastructure after boot

This way, it is not available for use in ROP attacks. This diff puts the
codepatching code into a separate section and unmaps that section after boot.
In the future, the memory could potentially be reused but that would require
larger changes.

ok pguenther@


# 1.43 25-Apr-2018 jsg

Add a way to reattach efifb(4). This will be used when radeondrm(4)
attaches and claims glass console but after root is mounted if firmware
is not found efifb gets reattached to have a useable glass console.


# 1.42 20-Apr-2018 deraadt

oops, snapshot tests not ready yet


# 1.41 20-Apr-2018 deraadt

sync


Revision tags: OPENBSD_6_3_BASE
# 1.40 14-Oct-2017 jsg

reduce the amount of includes in arch/amd64
ok mpi@ deraadt@


Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE
# 1.39 25-Mar-2017 deraadt

Split vmm_probe() into a vmm_enabled() function, to better follow the
probe/attach approach used by mainbus.
ok mlarkin kettenis


# 1.38 28-Jul-2016 kettenis

Store the acpi processor ID/UID in struct cpu_info, and use it to attach
acpicpu(4) drivers to the right cpu(4).

ok mlarkin@, guenther@


Revision tags: OPENBSD_6_0_BASE
# 1.37 21-Jun-2016 jcs

add support to efifb for drawing a console on a coreboot framebuffer
if coreboot's memory table is found, it has a framebuffer entry, and
there is no previously attached efi, vga, or serial console.

useful on chromebooks that have no legacy vga device to get an early
console before inteldrm(4) attaches or, for newer chipsets, a full
console and X with wsfb(4).

ok kettenis


Revision tags: OPENBSD_5_9_BASE
# 1.36 12-Dec-2015 reyk

Identify hypervisors before configuring other children of the mainbus
(bios, CPU, interrupt handlers, pvbus). This splits the pvbus attach
function into two parts: pvbus_identify() to scan the CPUID registers
for supported hypervisors and pvbus_attach() to attach the bus, print
information, and configure the children.

This will be needed for Xen and KVM, as discussed with mikeb@ and sf@
OK mlarkin@


# 1.35 23-Nov-2015 deraadt

No longer need 'option VMM', declaring the vmm0 device is sufficient.
ok mlarkin


# 1.34 13-Nov-2015 mlarkin

vmm(4) kernel code

circulated on hackers@, no objections. Disabled by default.


# 1.33 31-Aug-2015 kettenis

Check driver name in match function such that driver only attempts to attach
when we actually want it to.

ok deraadt@


# 1.32 30-Aug-2015 kettenis

Don't try to attach efifb(4) on non-UEFI boots.

ok miod@, deraadt@


# 1.31 30-Aug-2015 yasuoka

Modify kernel to prepare boot from UEFI.

- Add new boot arg "bios_efi_info_t" to pass the paramters from UEFI
- Make bios(4) and acpi(4) be able to probe with the parameters from
UEFI
- Add efifb(8). It uses the framebuffer from UEFI and it will work as
a backend of wsdisplay(4) and wsfb (X11 video driver). Disabled by
the kernel config for this moment

input and ok kettenis


Revision tags: OPENBSD_5_8_BASE
# 1.30 21-Jul-2015 reyk

pvbus(4) was attaching too early, it has to wait for identifycpu.
Problem found on GENERIC by mlarkin.

OK mlarkin@


# 1.29 21-Jul-2015 reyk

Add pvbus(4), a pseudo-bus to attach non-PCI paravirtual devices and buses.
vmt(4) is moved from mainbus0 to pvbus0, more devices will follow.

OK sf@ deraadt@


# 1.28 14-Mar-2015 jsg

Remove some includes include-what-you-use claims don't
have any direct symbols used. Tested for indirect use by compiling
amd64/i386/sparc64 kernels.

ok tedu@ deraadt@


Revision tags: OPENBSD_5_4_BASE OPENBSD_5_5_BASE OPENBSD_5_6_BASE OPENBSD_5_7_BASE
# 1.27 30-May-2013 deraadt

Enforce ca_activate tree-walks over the entire heirarchy for all events,
cleaning up some shutdown-hook related code on the way.
(A few drivers related to sparc are still skipped at kettenis' request)
ok kettenis mlarkin, tested by many others too


Revision tags: OPENBSD_5_3_BASE
# 1.26 04-Oct-2012 ehrhardt

Use information provided by ACPI to attach secondary PCI host bridges.

ok kettenis@


# 1.25 19-Sep-2012 kettenis

Set up PCI bus number resource accounting for the main PCI bus hierarchy.


Revision tags: OPENBSD_5_1_BASE OPENBSD_5_2_BASE
# 1.24 21-Oct-2011 kettenis

Add bounds checks for access to mp_busses.


Revision tags: OPENBSD_4_9_BASE OPENBSD_5_0_BASE
# 1.23 03-Nov-2010 dlg

only let vmt match and therefore attach if mainbus is specifically asking
for vmt to attach after vmt_probe succeeds. this prevents vmt from
appearing at other attach points hanging off mainbus.

found by phessler@ and debugged gently by claudio@


Revision tags: OPENBSD_4_7_BASE OPENBSD_4_8_BASE
# 1.22 28-Dec-2009 dlg

tweak vmt to work on amd64 as well as i386. like i386, it is still
commented out in GENERIC. it needs more love.

diff by david cranshaw a long time ago. sorry it has taken so long
for me to look at it.


# 1.21 23-Nov-2009 deraadt

oops, call config_activate_children


# 1.20 23-Nov-2009 deraadt

Use config_activate_children() for our cf_activate function
ok mlarkin pirofti


Revision tags: OPENBSD_4_6_BASE
# 1.19 21-Apr-2009 kettenis

Simplify PCI config space access code. There is no way we're ever going to
see the ancient mode 2 on machines capable of running OpenBSD/amd64.

ok deraadt@, toby@, oga@


# 1.18 11-Apr-2009 kettenis

Create extents for resource accounting on the root PCI bus and populate them
based on the BIOS memory map.


# 1.17 31-Mar-2009 kettenis

bzero pci attach args


Revision tags: OPENBSD_4_5_BASE
# 1.16 13-Jan-2009 kettenis

Turn mpbios into a real device, such that people can disable it on crappy
BIOSes.

ok deraadt@ (for the amd64 bit, or the i386 bit, can't remember which)


# 1.15 21-Dec-2008 kettenis

Change the way we include mpbios code to be similar to what we do on i386.

ok deraadt@


Revision tags: OPENBSD_4_3_BASE OPENBSD_4_4_BASE
# 1.14 05-Dec-2007 deraadt

Hang acpi(4) below bios(4) instead of mainbus(4). This lets us move acpi(4)
before pcibios(4), and then.... if acpi(4) attaches, skip pcibios(4) since
it messes the machines up. Fixes claudio's HP dl320 G5, and almost assuredly
others.
ok kettenis


# 1.13 16-Nov-2007 deraadt

fix the bus_space #define nightmare, so that amd64 and i386 are much more
uniform. as a result shared code like acpi needs less #ifdef's
ok marco kettenis


Revision tags: OPENBSD_4_2_BASE
# 1.12 06-May-2007 gwk

Add the mp setperf mechanism to AMD64, like its i386 counterpart it allows
all cpus in a system supporting frequency and voltage scaling to be scaled
by the same amount corresponding to the user (or apmd on their behalf)
performance level.

This diff also teaches amd64 about acpi_hasprocfvs (ACPI has processor
frequency and voltage scaling).

It also moves initilization of the underlying setperf mechanism such
as powernow to mainbus from the cpu indentification and initilization
code inspired by similar changes dim@ made to i386 durring h2k6. This
is necessary to implement the AMD recommended method for retreiving
p_state data from the ACPI _PSS object (a diff comming soon). It will
also simplify the potential addition of enhanced speedstep as found
on newer intel processors with EMT64 capable of running OpenBSD/amd64.

MP setperf functionality verifed by myself and Johan M:son Lindman <tybolt
AT solace DOT miun DOT se> on opteron 265 and 270 systems respectively.
General testing done by many others thanks!

ok tedu, dim


Revision tags: OPENBSD_4_1_BASE
# 1.11 14-Dec-2006 kettenis

Make pci subsystem aware of domains. Each host bridge gets assigned a unique
domain number such that we can distinguish between busses with the same bus
number that are behind different host bridges. Domains can be accessed by
using different device nodes.

ok deraadt@


# 1.10 25-Nov-2006 niklas

sync amd64 to i386 w.r.t. acpi support. Also fix interrupt routing for multi-ioapic systems.
ok kettenis


# 1.9 17-Nov-2006 kettenis

Decide whether we need to attach the primary cpu by checking the CPUF_PRESENT
flag just like we do on i386.


Revision tags: OPENBSD_4_0_BASE
# 1.8 08-May-2006 gwk

Add smbios support for i386 and amd64, fix ipmi to use this new functionallity,
hook up some sysctls to add system vendor/product/version and UUID reporting.

"get it in" deraadt@


# 1.7 14-Apr-2006 marco

ANSIfy functions.
Spacing.


# 1.6 13-Mar-2006 brad

* Add "pcitag_t *pba_bridgetag" to pci_attach_args. This is set to
NULL for root PCI busses. For busses behind a bridge, it points to
a persistent copy of the bridge's pcitag_t. This can be very useful
for machine-dependent PCI bus enumeration code.

From NetBSD

ok grange@ kettenis@


# 1.5 13-Mar-2006 marco

Fix machines that need PCI access during ACPI bringup.

Help and ok kettenis.


Revision tags: OPENBSD_3_9_BASE
# 1.4 29-Dec-2005 kettenis

Fix isadma0 at isa0 at mainbus0
ok deraadt@


# 1.3 19-Oct-2005 marco

Add IPMI to amd64. Keep it disabled for now.

Prodded earlier today by deraadt@
ok krw@


Revision tags: OPENBSD_3_8_BASE
# 1.2 02-Jun-2005 tholo

Start on a basic ACPI framework -- does not do much more than read out the
ACPI tables into kernel memory and attach ACPI and HPET timers currently.

In order to test this code, enabling the devices in GENERIC as well as
the ACPI_ENABLE option is needed. This code does not do any thermal
control yet, so this should be done with care depending on the platform.

In the tree so more people can contribute to making this more fully
featured.

Ok niklas@ grange@ tedu@


Revision tags: OPENBSD_3_5_BASE OPENBSD_3_6_BASE OPENBSD_3_7_BASE SMP_SYNC_A SMP_SYNC_B
# 1.1 28-Jan-2004 mickey

an amd64 arch support.
hacked by art@ from netbsd sources and then later debugged
by me into the shape where it can host itself.
no bootloader yet as needs redoing from the
recent advanced i386 sources (anyone? ;)


# 1.46 04-May-2019 kettenis

Improve the interaction between efifb(4), inteldrm(4) and radeondrm(4)
when we have a serial console by introducing the notion of a "primary"
graphics device. The primary graphics device is the one set up and
used by firmware (BIOS, UEFI).

The goal is to make sure that wsdisplay0 and drm0 reliably attach to
the primary graphics device such that X works out of the box even
if you have multiple cards or if you are using a serial console.

This also fixes the situation where inteldrm(4) or radeondrm(4) would
take over the console on UEFI systems even if the kernel was booted
with a serial console.

ok jsg@


Revision tags: OPENBSD_6_4_BASE OPENBSD_6_5_BASE
# 1.45 22-Sep-2018 kettenis

Remap the UEFI buffer early such that we can use a write combining mapping
which speeds things up considerably compared to an uncached mapping.

ok deraadt@


# 1.44 13-Jul-2018 sf

Disable codepatching infrastructure after boot

This way, it is not available for use in ROP attacks. This diff puts the
codepatching code into a separate section and unmaps that section after boot.
In the future, the memory could potentially be reused but that would require
larger changes.

ok pguenther@


# 1.43 25-Apr-2018 jsg

Add a way to reattach efifb(4). This will be used when radeondrm(4)
attaches and claims glass console but after root is mounted if firmware
is not found efifb gets reattached to have a useable glass console.


# 1.42 20-Apr-2018 deraadt

oops, snapshot tests not ready yet


# 1.41 20-Apr-2018 deraadt

sync


Revision tags: OPENBSD_6_3_BASE
# 1.40 14-Oct-2017 jsg

reduce the amount of includes in arch/amd64
ok mpi@ deraadt@


Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE
# 1.39 25-Mar-2017 deraadt

Split vmm_probe() into a vmm_enabled() function, to better follow the
probe/attach approach used by mainbus.
ok mlarkin kettenis


# 1.38 28-Jul-2016 kettenis

Store the acpi processor ID/UID in struct cpu_info, and use it to attach
acpicpu(4) drivers to the right cpu(4).

ok mlarkin@, guenther@


Revision tags: OPENBSD_6_0_BASE
# 1.37 21-Jun-2016 jcs

add support to efifb for drawing a console on a coreboot framebuffer
if coreboot's memory table is found, it has a framebuffer entry, and
there is no previously attached efi, vga, or serial console.

useful on chromebooks that have no legacy vga device to get an early
console before inteldrm(4) attaches or, for newer chipsets, a full
console and X with wsfb(4).

ok kettenis


Revision tags: OPENBSD_5_9_BASE
# 1.36 12-Dec-2015 reyk

Identify hypervisors before configuring other children of the mainbus
(bios, CPU, interrupt handlers, pvbus). This splits the pvbus attach
function into two parts: pvbus_identify() to scan the CPUID registers
for supported hypervisors and pvbus_attach() to attach the bus, print
information, and configure the children.

This will be needed for Xen and KVM, as discussed with mikeb@ and sf@
OK mlarkin@


# 1.35 23-Nov-2015 deraadt

No longer need 'option VMM', declaring the vmm0 device is sufficient.
ok mlarkin


# 1.34 13-Nov-2015 mlarkin

vmm(4) kernel code

circulated on hackers@, no objections. Disabled by default.


# 1.33 31-Aug-2015 kettenis

Check driver name in match function such that driver only attempts to attach
when we actually want it to.

ok deraadt@


# 1.32 30-Aug-2015 kettenis

Don't try to attach efifb(4) on non-UEFI boots.

ok miod@, deraadt@


# 1.31 30-Aug-2015 yasuoka

Modify kernel to prepare boot from UEFI.

- Add new boot arg "bios_efi_info_t" to pass the paramters from UEFI
- Make bios(4) and acpi(4) be able to probe with the parameters from
UEFI
- Add efifb(8). It uses the framebuffer from UEFI and it will work as
a backend of wsdisplay(4) and wsfb (X11 video driver). Disabled by
the kernel config for this moment

input and ok kettenis


Revision tags: OPENBSD_5_8_BASE
# 1.30 21-Jul-2015 reyk

pvbus(4) was attaching too early, it has to wait for identifycpu.
Problem found on GENERIC by mlarkin.

OK mlarkin@


# 1.29 21-Jul-2015 reyk

Add pvbus(4), a pseudo-bus to attach non-PCI paravirtual devices and buses.
vmt(4) is moved from mainbus0 to pvbus0, more devices will follow.

OK sf@ deraadt@


# 1.28 14-Mar-2015 jsg

Remove some includes include-what-you-use claims don't
have any direct symbols used. Tested for indirect use by compiling
amd64/i386/sparc64 kernels.

ok tedu@ deraadt@


Revision tags: OPENBSD_5_4_BASE OPENBSD_5_5_BASE OPENBSD_5_6_BASE OPENBSD_5_7_BASE
# 1.27 30-May-2013 deraadt

Enforce ca_activate tree-walks over the entire heirarchy for all events,
cleaning up some shutdown-hook related code on the way.
(A few drivers related to sparc are still skipped at kettenis' request)
ok kettenis mlarkin, tested by many others too


Revision tags: OPENBSD_5_3_BASE
# 1.26 04-Oct-2012 ehrhardt

Use information provided by ACPI to attach secondary PCI host bridges.

ok kettenis@


# 1.25 19-Sep-2012 kettenis

Set up PCI bus number resource accounting for the main PCI bus hierarchy.


Revision tags: OPENBSD_5_1_BASE OPENBSD_5_2_BASE
# 1.24 21-Oct-2011 kettenis

Add bounds checks for access to mp_busses.


Revision tags: OPENBSD_4_9_BASE OPENBSD_5_0_BASE
# 1.23 03-Nov-2010 dlg

only let vmt match and therefore attach if mainbus is specifically asking
for vmt to attach after vmt_probe succeeds. this prevents vmt from
appearing at other attach points hanging off mainbus.

found by phessler@ and debugged gently by claudio@


Revision tags: OPENBSD_4_7_BASE OPENBSD_4_8_BASE
# 1.22 28-Dec-2009 dlg

tweak vmt to work on amd64 as well as i386. like i386, it is still
commented out in GENERIC. it needs more love.

diff by david cranshaw a long time ago. sorry it has taken so long
for me to look at it.


# 1.21 23-Nov-2009 deraadt

oops, call config_activate_children


# 1.20 23-Nov-2009 deraadt

Use config_activate_children() for our cf_activate function
ok mlarkin pirofti


Revision tags: OPENBSD_4_6_BASE
# 1.19 21-Apr-2009 kettenis

Simplify PCI config space access code. There is no way we're ever going to
see the ancient mode 2 on machines capable of running OpenBSD/amd64.

ok deraadt@, toby@, oga@


# 1.18 11-Apr-2009 kettenis

Create extents for resource accounting on the root PCI bus and populate them
based on the BIOS memory map.


# 1.17 31-Mar-2009 kettenis

bzero pci attach args


Revision tags: OPENBSD_4_5_BASE
# 1.16 13-Jan-2009 kettenis

Turn mpbios into a real device, such that people can disable it on crappy
BIOSes.

ok deraadt@ (for the amd64 bit, or the i386 bit, can't remember which)


# 1.15 21-Dec-2008 kettenis

Change the way we include mpbios code to be similar to what we do on i386.

ok deraadt@


Revision tags: OPENBSD_4_3_BASE OPENBSD_4_4_BASE
# 1.14 05-Dec-2007 deraadt

Hang acpi(4) below bios(4) instead of mainbus(4). This lets us move acpi(4)
before pcibios(4), and then.... if acpi(4) attaches, skip pcibios(4) since
it messes the machines up. Fixes claudio's HP dl320 G5, and almost assuredly
others.
ok kettenis


# 1.13 16-Nov-2007 deraadt

fix the bus_space #define nightmare, so that amd64 and i386 are much more
uniform. as a result shared code like acpi needs less #ifdef's
ok marco kettenis


Revision tags: OPENBSD_4_2_BASE
# 1.12 06-May-2007 gwk

Add the mp setperf mechanism to AMD64, like its i386 counterpart it allows
all cpus in a system supporting frequency and voltage scaling to be scaled
by the same amount corresponding to the user (or apmd on their behalf)
performance level.

This diff also teaches amd64 about acpi_hasprocfvs (ACPI has processor
frequency and voltage scaling).

It also moves initilization of the underlying setperf mechanism such
as powernow to mainbus from the cpu indentification and initilization
code inspired by similar changes dim@ made to i386 durring h2k6. This
is necessary to implement the AMD recommended method for retreiving
p_state data from the ACPI _PSS object (a diff comming soon). It will
also simplify the potential addition of enhanced speedstep as found
on newer intel processors with EMT64 capable of running OpenBSD/amd64.

MP setperf functionality verifed by myself and Johan M:son Lindman <tybolt
AT solace DOT miun DOT se> on opteron 265 and 270 systems respectively.
General testing done by many others thanks!

ok tedu, dim


Revision tags: OPENBSD_4_1_BASE
# 1.11 14-Dec-2006 kettenis

Make pci subsystem aware of domains. Each host bridge gets assigned a unique
domain number such that we can distinguish between busses with the same bus
number that are behind different host bridges. Domains can be accessed by
using different device nodes.

ok deraadt@


# 1.10 25-Nov-2006 niklas

sync amd64 to i386 w.r.t. acpi support. Also fix interrupt routing for multi-ioapic systems.
ok kettenis


# 1.9 17-Nov-2006 kettenis

Decide whether we need to attach the primary cpu by checking the CPUF_PRESENT
flag just like we do on i386.


Revision tags: OPENBSD_4_0_BASE
# 1.8 08-May-2006 gwk

Add smbios support for i386 and amd64, fix ipmi to use this new functionallity,
hook up some sysctls to add system vendor/product/version and UUID reporting.

"get it in" deraadt@


# 1.7 14-Apr-2006 marco

ANSIfy functions.
Spacing.


# 1.6 13-Mar-2006 brad

* Add "pcitag_t *pba_bridgetag" to pci_attach_args. This is set to
NULL for root PCI busses. For busses behind a bridge, it points to
a persistent copy of the bridge's pcitag_t. This can be very useful
for machine-dependent PCI bus enumeration code.

From NetBSD

ok grange@ kettenis@


# 1.5 13-Mar-2006 marco

Fix machines that need PCI access during ACPI bringup.

Help and ok kettenis.


Revision tags: OPENBSD_3_9_BASE
# 1.4 29-Dec-2005 kettenis

Fix isadma0 at isa0 at mainbus0
ok deraadt@


# 1.3 19-Oct-2005 marco

Add IPMI to amd64. Keep it disabled for now.

Prodded earlier today by deraadt@
ok krw@


Revision tags: OPENBSD_3_8_BASE
# 1.2 02-Jun-2005 tholo

Start on a basic ACPI framework -- does not do much more than read out the
ACPI tables into kernel memory and attach ACPI and HPET timers currently.

In order to test this code, enabling the devices in GENERIC as well as
the ACPI_ENABLE option is needed. This code does not do any thermal
control yet, so this should be done with care depending on the platform.

In the tree so more people can contribute to making this more fully
featured.

Ok niklas@ grange@ tedu@


Revision tags: OPENBSD_3_5_BASE OPENBSD_3_6_BASE OPENBSD_3_7_BASE SMP_SYNC_A SMP_SYNC_B
# 1.1 28-Jan-2004 mickey

an amd64 arch support.
hacked by art@ from netbsd sources and then later debugged
by me into the shape where it can host itself.
no bootloader yet as needs redoing from the
recent advanced i386 sources (anyone? ;)


# 1.45 22-Sep-2018 kettenis

Remap the UEFI buffer early such that we can use a write combining mapping
which speeds things up considerably compared to an uncached mapping.

ok deraadt@


# 1.44 13-Jul-2018 sf

Disable codepatching infrastructure after boot

This way, it is not available for use in ROP attacks. This diff puts the
codepatching code into a separate section and unmaps that section after boot.
In the future, the memory could potentially be reused but that would require
larger changes.

ok pguenther@


# 1.43 25-Apr-2018 jsg

Add a way to reattach efifb(4). This will be used when radeondrm(4)
attaches and claims glass console but after root is mounted if firmware
is not found efifb gets reattached to have a useable glass console.


# 1.42 20-Apr-2018 deraadt

oops, snapshot tests not ready yet


# 1.41 20-Apr-2018 deraadt

sync


Revision tags: OPENBSD_6_3_BASE
# 1.40 14-Oct-2017 jsg

reduce the amount of includes in arch/amd64
ok mpi@ deraadt@


Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE
# 1.39 25-Mar-2017 deraadt

Split vmm_probe() into a vmm_enabled() function, to better follow the
probe/attach approach used by mainbus.
ok mlarkin kettenis


# 1.38 28-Jul-2016 kettenis

Store the acpi processor ID/UID in struct cpu_info, and use it to attach
acpicpu(4) drivers to the right cpu(4).

ok mlarkin@, guenther@


Revision tags: OPENBSD_6_0_BASE
# 1.37 21-Jun-2016 jcs

add support to efifb for drawing a console on a coreboot framebuffer
if coreboot's memory table is found, it has a framebuffer entry, and
there is no previously attached efi, vga, or serial console.

useful on chromebooks that have no legacy vga device to get an early
console before inteldrm(4) attaches or, for newer chipsets, a full
console and X with wsfb(4).

ok kettenis


Revision tags: OPENBSD_5_9_BASE
# 1.36 12-Dec-2015 reyk

Identify hypervisors before configuring other children of the mainbus
(bios, CPU, interrupt handlers, pvbus). This splits the pvbus attach
function into two parts: pvbus_identify() to scan the CPUID registers
for supported hypervisors and pvbus_attach() to attach the bus, print
information, and configure the children.

This will be needed for Xen and KVM, as discussed with mikeb@ and sf@
OK mlarkin@


# 1.35 23-Nov-2015 deraadt

No longer need 'option VMM', declaring the vmm0 device is sufficient.
ok mlarkin


# 1.34 13-Nov-2015 mlarkin

vmm(4) kernel code

circulated on hackers@, no objections. Disabled by default.


# 1.33 31-Aug-2015 kettenis

Check driver name in match function such that driver only attempts to attach
when we actually want it to.

ok deraadt@


# 1.32 30-Aug-2015 kettenis

Don't try to attach efifb(4) on non-UEFI boots.

ok miod@, deraadt@


# 1.31 30-Aug-2015 yasuoka

Modify kernel to prepare boot from UEFI.

- Add new boot arg "bios_efi_info_t" to pass the paramters from UEFI
- Make bios(4) and acpi(4) be able to probe with the parameters from
UEFI
- Add efifb(8). It uses the framebuffer from UEFI and it will work as
a backend of wsdisplay(4) and wsfb (X11 video driver). Disabled by
the kernel config for this moment

input and ok kettenis


Revision tags: OPENBSD_5_8_BASE
# 1.30 21-Jul-2015 reyk

pvbus(4) was attaching too early, it has to wait for identifycpu.
Problem found on GENERIC by mlarkin.

OK mlarkin@


# 1.29 21-Jul-2015 reyk

Add pvbus(4), a pseudo-bus to attach non-PCI paravirtual devices and buses.
vmt(4) is moved from mainbus0 to pvbus0, more devices will follow.

OK sf@ deraadt@


# 1.28 14-Mar-2015 jsg

Remove some includes include-what-you-use claims don't
have any direct symbols used. Tested for indirect use by compiling
amd64/i386/sparc64 kernels.

ok tedu@ deraadt@


Revision tags: OPENBSD_5_4_BASE OPENBSD_5_5_BASE OPENBSD_5_6_BASE OPENBSD_5_7_BASE
# 1.27 30-May-2013 deraadt

Enforce ca_activate tree-walks over the entire heirarchy for all events,
cleaning up some shutdown-hook related code on the way.
(A few drivers related to sparc are still skipped at kettenis' request)
ok kettenis mlarkin, tested by many others too


Revision tags: OPENBSD_5_3_BASE
# 1.26 04-Oct-2012 ehrhardt

Use information provided by ACPI to attach secondary PCI host bridges.

ok kettenis@


# 1.25 19-Sep-2012 kettenis

Set up PCI bus number resource accounting for the main PCI bus hierarchy.


Revision tags: OPENBSD_5_1_BASE OPENBSD_5_2_BASE
# 1.24 21-Oct-2011 kettenis

Add bounds checks for access to mp_busses.


Revision tags: OPENBSD_4_9_BASE OPENBSD_5_0_BASE
# 1.23 03-Nov-2010 dlg

only let vmt match and therefore attach if mainbus is specifically asking
for vmt to attach after vmt_probe succeeds. this prevents vmt from
appearing at other attach points hanging off mainbus.

found by phessler@ and debugged gently by claudio@


Revision tags: OPENBSD_4_7_BASE OPENBSD_4_8_BASE
# 1.22 28-Dec-2009 dlg

tweak vmt to work on amd64 as well as i386. like i386, it is still
commented out in GENERIC. it needs more love.

diff by david cranshaw a long time ago. sorry it has taken so long
for me to look at it.


# 1.21 23-Nov-2009 deraadt

oops, call config_activate_children


# 1.20 23-Nov-2009 deraadt

Use config_activate_children() for our cf_activate function
ok mlarkin pirofti


Revision tags: OPENBSD_4_6_BASE
# 1.19 21-Apr-2009 kettenis

Simplify PCI config space access code. There is no way we're ever going to
see the ancient mode 2 on machines capable of running OpenBSD/amd64.

ok deraadt@, toby@, oga@


# 1.18 11-Apr-2009 kettenis

Create extents for resource accounting on the root PCI bus and populate them
based on the BIOS memory map.


# 1.17 31-Mar-2009 kettenis

bzero pci attach args


Revision tags: OPENBSD_4_5_BASE
# 1.16 13-Jan-2009 kettenis

Turn mpbios into a real device, such that people can disable it on crappy
BIOSes.

ok deraadt@ (for the amd64 bit, or the i386 bit, can't remember which)


# 1.15 21-Dec-2008 kettenis

Change the way we include mpbios code to be similar to what we do on i386.

ok deraadt@


Revision tags: OPENBSD_4_3_BASE OPENBSD_4_4_BASE
# 1.14 05-Dec-2007 deraadt

Hang acpi(4) below bios(4) instead of mainbus(4). This lets us move acpi(4)
before pcibios(4), and then.... if acpi(4) attaches, skip pcibios(4) since
it messes the machines up. Fixes claudio's HP dl320 G5, and almost assuredly
others.
ok kettenis


# 1.13 16-Nov-2007 deraadt

fix the bus_space #define nightmare, so that amd64 and i386 are much more
uniform. as a result shared code like acpi needs less #ifdef's
ok marco kettenis


Revision tags: OPENBSD_4_2_BASE
# 1.12 06-May-2007 gwk

Add the mp setperf mechanism to AMD64, like its i386 counterpart it allows
all cpus in a system supporting frequency and voltage scaling to be scaled
by the same amount corresponding to the user (or apmd on their behalf)
performance level.

This diff also teaches amd64 about acpi_hasprocfvs (ACPI has processor
frequency and voltage scaling).

It also moves initilization of the underlying setperf mechanism such
as powernow to mainbus from the cpu indentification and initilization
code inspired by similar changes dim@ made to i386 durring h2k6. This
is necessary to implement the AMD recommended method for retreiving
p_state data from the ACPI _PSS object (a diff comming soon). It will
also simplify the potential addition of enhanced speedstep as found
on newer intel processors with EMT64 capable of running OpenBSD/amd64.

MP setperf functionality verifed by myself and Johan M:son Lindman <tybolt
AT solace DOT miun DOT se> on opteron 265 and 270 systems respectively.
General testing done by many others thanks!

ok tedu, dim


Revision tags: OPENBSD_4_1_BASE
# 1.11 14-Dec-2006 kettenis

Make pci subsystem aware of domains. Each host bridge gets assigned a unique
domain number such that we can distinguish between busses with the same bus
number that are behind different host bridges. Domains can be accessed by
using different device nodes.

ok deraadt@


# 1.10 25-Nov-2006 niklas

sync amd64 to i386 w.r.t. acpi support. Also fix interrupt routing for multi-ioapic systems.
ok kettenis


# 1.9 17-Nov-2006 kettenis

Decide whether we need to attach the primary cpu by checking the CPUF_PRESENT
flag just like we do on i386.


Revision tags: OPENBSD_4_0_BASE
# 1.8 08-May-2006 gwk

Add smbios support for i386 and amd64, fix ipmi to use this new functionallity,
hook up some sysctls to add system vendor/product/version and UUID reporting.

"get it in" deraadt@


# 1.7 14-Apr-2006 marco

ANSIfy functions.
Spacing.


# 1.6 13-Mar-2006 brad

* Add "pcitag_t *pba_bridgetag" to pci_attach_args. This is set to
NULL for root PCI busses. For busses behind a bridge, it points to
a persistent copy of the bridge's pcitag_t. This can be very useful
for machine-dependent PCI bus enumeration code.

From NetBSD

ok grange@ kettenis@


# 1.5 13-Mar-2006 marco

Fix machines that need PCI access during ACPI bringup.

Help and ok kettenis.


Revision tags: OPENBSD_3_9_BASE
# 1.4 29-Dec-2005 kettenis

Fix isadma0 at isa0 at mainbus0
ok deraadt@


# 1.3 19-Oct-2005 marco

Add IPMI to amd64. Keep it disabled for now.

Prodded earlier today by deraadt@
ok krw@


Revision tags: OPENBSD_3_8_BASE
# 1.2 02-Jun-2005 tholo

Start on a basic ACPI framework -- does not do much more than read out the
ACPI tables into kernel memory and attach ACPI and HPET timers currently.

In order to test this code, enabling the devices in GENERIC as well as
the ACPI_ENABLE option is needed. This code does not do any thermal
control yet, so this should be done with care depending on the platform.

In the tree so more people can contribute to making this more fully
featured.

Ok niklas@ grange@ tedu@


Revision tags: OPENBSD_3_5_BASE OPENBSD_3_6_BASE OPENBSD_3_7_BASE SMP_SYNC_A SMP_SYNC_B
# 1.1 28-Jan-2004 mickey

an amd64 arch support.
hacked by art@ from netbsd sources and then later debugged
by me into the shape where it can host itself.
no bootloader yet as needs redoing from the
recent advanced i386 sources (anyone? ;)


# 1.44 13-Jul-2018 sf

Disable codepatching infrastructure after boot

This way, it is not available for use in ROP attacks. This diff puts the
codepatching code into a separate section and unmaps that section after boot.
In the future, the memory could potentially be reused but that would require
larger changes.

ok pguenther@


# 1.43 25-Apr-2018 jsg

Add a way to reattach efifb(4). This will be used when radeondrm(4)
attaches and claims glass console but after root is mounted if firmware
is not found efifb gets reattached to have a useable glass console.


# 1.42 20-Apr-2018 deraadt

oops, snapshot tests not ready yet


# 1.41 20-Apr-2018 deraadt

sync


Revision tags: OPENBSD_6_3_BASE
# 1.40 14-Oct-2017 jsg

reduce the amount of includes in arch/amd64
ok mpi@ deraadt@


Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE
# 1.39 25-Mar-2017 deraadt

Split vmm_probe() into a vmm_enabled() function, to better follow the
probe/attach approach used by mainbus.
ok mlarkin kettenis


# 1.38 28-Jul-2016 kettenis

Store the acpi processor ID/UID in struct cpu_info, and use it to attach
acpicpu(4) drivers to the right cpu(4).

ok mlarkin@, guenther@


Revision tags: OPENBSD_6_0_BASE
# 1.37 21-Jun-2016 jcs

add support to efifb for drawing a console on a coreboot framebuffer
if coreboot's memory table is found, it has a framebuffer entry, and
there is no previously attached efi, vga, or serial console.

useful on chromebooks that have no legacy vga device to get an early
console before inteldrm(4) attaches or, for newer chipsets, a full
console and X with wsfb(4).

ok kettenis


Revision tags: OPENBSD_5_9_BASE
# 1.36 12-Dec-2015 reyk

Identify hypervisors before configuring other children of the mainbus
(bios, CPU, interrupt handlers, pvbus). This splits the pvbus attach
function into two parts: pvbus_identify() to scan the CPUID registers
for supported hypervisors and pvbus_attach() to attach the bus, print
information, and configure the children.

This will be needed for Xen and KVM, as discussed with mikeb@ and sf@
OK mlarkin@


# 1.35 23-Nov-2015 deraadt

No longer need 'option VMM', declaring the vmm0 device is sufficient.
ok mlarkin


# 1.34 13-Nov-2015 mlarkin

vmm(4) kernel code

circulated on hackers@, no objections. Disabled by default.


# 1.33 31-Aug-2015 kettenis

Check driver name in match function such that driver only attempts to attach
when we actually want it to.

ok deraadt@


# 1.32 30-Aug-2015 kettenis

Don't try to attach efifb(4) on non-UEFI boots.

ok miod@, deraadt@


# 1.31 30-Aug-2015 yasuoka

Modify kernel to prepare boot from UEFI.

- Add new boot arg "bios_efi_info_t" to pass the paramters from UEFI
- Make bios(4) and acpi(4) be able to probe with the parameters from
UEFI
- Add efifb(8). It uses the framebuffer from UEFI and it will work as
a backend of wsdisplay(4) and wsfb (X11 video driver). Disabled by
the kernel config for this moment

input and ok kettenis


Revision tags: OPENBSD_5_8_BASE
# 1.30 21-Jul-2015 reyk

pvbus(4) was attaching too early, it has to wait for identifycpu.
Problem found on GENERIC by mlarkin.

OK mlarkin@


# 1.29 21-Jul-2015 reyk

Add pvbus(4), a pseudo-bus to attach non-PCI paravirtual devices and buses.
vmt(4) is moved from mainbus0 to pvbus0, more devices will follow.

OK sf@ deraadt@


# 1.28 14-Mar-2015 jsg

Remove some includes include-what-you-use claims don't
have any direct symbols used. Tested for indirect use by compiling
amd64/i386/sparc64 kernels.

ok tedu@ deraadt@


Revision tags: OPENBSD_5_4_BASE OPENBSD_5_5_BASE OPENBSD_5_6_BASE OPENBSD_5_7_BASE
# 1.27 30-May-2013 deraadt

Enforce ca_activate tree-walks over the entire heirarchy for all events,
cleaning up some shutdown-hook related code on the way.
(A few drivers related to sparc are still skipped at kettenis' request)
ok kettenis mlarkin, tested by many others too


Revision tags: OPENBSD_5_3_BASE
# 1.26 04-Oct-2012 ehrhardt

Use information provided by ACPI to attach secondary PCI host bridges.

ok kettenis@


# 1.25 19-Sep-2012 kettenis

Set up PCI bus number resource accounting for the main PCI bus hierarchy.


Revision tags: OPENBSD_5_1_BASE OPENBSD_5_2_BASE
# 1.24 21-Oct-2011 kettenis

Add bounds checks for access to mp_busses.


Revision tags: OPENBSD_4_9_BASE OPENBSD_5_0_BASE
# 1.23 03-Nov-2010 dlg

only let vmt match and therefore attach if mainbus is specifically asking
for vmt to attach after vmt_probe succeeds. this prevents vmt from
appearing at other attach points hanging off mainbus.

found by phessler@ and debugged gently by claudio@


Revision tags: OPENBSD_4_7_BASE OPENBSD_4_8_BASE
# 1.22 28-Dec-2009 dlg

tweak vmt to work on amd64 as well as i386. like i386, it is still
commented out in GENERIC. it needs more love.

diff by david cranshaw a long time ago. sorry it has taken so long
for me to look at it.


# 1.21 23-Nov-2009 deraadt

oops, call config_activate_children


# 1.20 23-Nov-2009 deraadt

Use config_activate_children() for our cf_activate function
ok mlarkin pirofti


Revision tags: OPENBSD_4_6_BASE
# 1.19 21-Apr-2009 kettenis

Simplify PCI config space access code. There is no way we're ever going to
see the ancient mode 2 on machines capable of running OpenBSD/amd64.

ok deraadt@, toby@, oga@


# 1.18 11-Apr-2009 kettenis

Create extents for resource accounting on the root PCI bus and populate them
based on the BIOS memory map.


# 1.17 31-Mar-2009 kettenis

bzero pci attach args


Revision tags: OPENBSD_4_5_BASE
# 1.16 13-Jan-2009 kettenis

Turn mpbios into a real device, such that people can disable it on crappy
BIOSes.

ok deraadt@ (for the amd64 bit, or the i386 bit, can't remember which)


# 1.15 21-Dec-2008 kettenis

Change the way we include mpbios code to be similar to what we do on i386.

ok deraadt@


Revision tags: OPENBSD_4_3_BASE OPENBSD_4_4_BASE
# 1.14 05-Dec-2007 deraadt

Hang acpi(4) below bios(4) instead of mainbus(4). This lets us move acpi(4)
before pcibios(4), and then.... if acpi(4) attaches, skip pcibios(4) since
it messes the machines up. Fixes claudio's HP dl320 G5, and almost assuredly
others.
ok kettenis


# 1.13 16-Nov-2007 deraadt

fix the bus_space #define nightmare, so that amd64 and i386 are much more
uniform. as a result shared code like acpi needs less #ifdef's
ok marco kettenis


Revision tags: OPENBSD_4_2_BASE
# 1.12 06-May-2007 gwk

Add the mp setperf mechanism to AMD64, like its i386 counterpart it allows
all cpus in a system supporting frequency and voltage scaling to be scaled
by the same amount corresponding to the user (or apmd on their behalf)
performance level.

This diff also teaches amd64 about acpi_hasprocfvs (ACPI has processor
frequency and voltage scaling).

It also moves initilization of the underlying setperf mechanism such
as powernow to mainbus from the cpu indentification and initilization
code inspired by similar changes dim@ made to i386 durring h2k6. This
is necessary to implement the AMD recommended method for retreiving
p_state data from the ACPI _PSS object (a diff comming soon). It will
also simplify the potential addition of enhanced speedstep as found
on newer intel processors with EMT64 capable of running OpenBSD/amd64.

MP setperf functionality verifed by myself and Johan M:son Lindman <tybolt
AT solace DOT miun DOT se> on opteron 265 and 270 systems respectively.
General testing done by many others thanks!

ok tedu, dim


Revision tags: OPENBSD_4_1_BASE
# 1.11 14-Dec-2006 kettenis

Make pci subsystem aware of domains. Each host bridge gets assigned a unique
domain number such that we can distinguish between busses with the same bus
number that are behind different host bridges. Domains can be accessed by
using different device nodes.

ok deraadt@


# 1.10 25-Nov-2006 niklas

sync amd64 to i386 w.r.t. acpi support. Also fix interrupt routing for multi-ioapic systems.
ok kettenis


# 1.9 17-Nov-2006 kettenis

Decide whether we need to attach the primary cpu by checking the CPUF_PRESENT
flag just like we do on i386.


Revision tags: OPENBSD_4_0_BASE
# 1.8 08-May-2006 gwk

Add smbios support for i386 and amd64, fix ipmi to use this new functionallity,
hook up some sysctls to add system vendor/product/version and UUID reporting.

"get it in" deraadt@


# 1.7 14-Apr-2006 marco

ANSIfy functions.
Spacing.


# 1.6 13-Mar-2006 brad

* Add "pcitag_t *pba_bridgetag" to pci_attach_args. This is set to
NULL for root PCI busses. For busses behind a bridge, it points to
a persistent copy of the bridge's pcitag_t. This can be very useful
for machine-dependent PCI bus enumeration code.

From NetBSD

ok grange@ kettenis@


# 1.5 13-Mar-2006 marco

Fix machines that need PCI access during ACPI bringup.

Help and ok kettenis.


Revision tags: OPENBSD_3_9_BASE
# 1.4 29-Dec-2005 kettenis

Fix isadma0 at isa0 at mainbus0
ok deraadt@


# 1.3 19-Oct-2005 marco

Add IPMI to amd64. Keep it disabled for now.

Prodded earlier today by deraadt@
ok krw@


Revision tags: OPENBSD_3_8_BASE
# 1.2 02-Jun-2005 tholo

Start on a basic ACPI framework -- does not do much more than read out the
ACPI tables into kernel memory and attach ACPI and HPET timers currently.

In order to test this code, enabling the devices in GENERIC as well as
the ACPI_ENABLE option is needed. This code does not do any thermal
control yet, so this should be done with care depending on the platform.

In the tree so more people can contribute to making this more fully
featured.

Ok niklas@ grange@ tedu@


Revision tags: OPENBSD_3_5_BASE OPENBSD_3_6_BASE OPENBSD_3_7_BASE SMP_SYNC_A SMP_SYNC_B
# 1.1 28-Jan-2004 mickey

an amd64 arch support.
hacked by art@ from netbsd sources and then later debugged
by me into the shape where it can host itself.
no bootloader yet as needs redoing from the
recent advanced i386 sources (anyone? ;)


# 1.43 25-Apr-2018 jsg

Add a way to reattach efifb(4). This will be used when radeondrm(4)
attaches and claims glass console but after root is mounted if firmware
is not found efifb gets reattached to have a useable glass console.


# 1.42 20-Apr-2018 deraadt

oops, snapshot tests not ready yet


# 1.41 20-Apr-2018 deraadt

sync


Revision tags: OPENBSD_6_3_BASE
# 1.40 14-Oct-2017 jsg

reduce the amount of includes in arch/amd64
ok mpi@ deraadt@


Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE
# 1.39 25-Mar-2017 deraadt

Split vmm_probe() into a vmm_enabled() function, to better follow the
probe/attach approach used by mainbus.
ok mlarkin kettenis


# 1.38 28-Jul-2016 kettenis

Store the acpi processor ID/UID in struct cpu_info, and use it to attach
acpicpu(4) drivers to the right cpu(4).

ok mlarkin@, guenther@


Revision tags: OPENBSD_6_0_BASE
# 1.37 21-Jun-2016 jcs

add support to efifb for drawing a console on a coreboot framebuffer
if coreboot's memory table is found, it has a framebuffer entry, and
there is no previously attached efi, vga, or serial console.

useful on chromebooks that have no legacy vga device to get an early
console before inteldrm(4) attaches or, for newer chipsets, a full
console and X with wsfb(4).

ok kettenis


Revision tags: OPENBSD_5_9_BASE
# 1.36 12-Dec-2015 reyk

Identify hypervisors before configuring other children of the mainbus
(bios, CPU, interrupt handlers, pvbus). This splits the pvbus attach
function into two parts: pvbus_identify() to scan the CPUID registers
for supported hypervisors and pvbus_attach() to attach the bus, print
information, and configure the children.

This will be needed for Xen and KVM, as discussed with mikeb@ and sf@
OK mlarkin@


# 1.35 23-Nov-2015 deraadt

No longer need 'option VMM', declaring the vmm0 device is sufficient.
ok mlarkin


# 1.34 13-Nov-2015 mlarkin

vmm(4) kernel code

circulated on hackers@, no objections. Disabled by default.


# 1.33 31-Aug-2015 kettenis

Check driver name in match function such that driver only attempts to attach
when we actually want it to.

ok deraadt@


# 1.32 30-Aug-2015 kettenis

Don't try to attach efifb(4) on non-UEFI boots.

ok miod@, deraadt@


# 1.31 30-Aug-2015 yasuoka

Modify kernel to prepare boot from UEFI.

- Add new boot arg "bios_efi_info_t" to pass the paramters from UEFI
- Make bios(4) and acpi(4) be able to probe with the parameters from
UEFI
- Add efifb(8). It uses the framebuffer from UEFI and it will work as
a backend of wsdisplay(4) and wsfb (X11 video driver). Disabled by
the kernel config for this moment

input and ok kettenis


Revision tags: OPENBSD_5_8_BASE
# 1.30 21-Jul-2015 reyk

pvbus(4) was attaching too early, it has to wait for identifycpu.
Problem found on GENERIC by mlarkin.

OK mlarkin@


# 1.29 21-Jul-2015 reyk

Add pvbus(4), a pseudo-bus to attach non-PCI paravirtual devices and buses.
vmt(4) is moved from mainbus0 to pvbus0, more devices will follow.

OK sf@ deraadt@


# 1.28 14-Mar-2015 jsg

Remove some includes include-what-you-use claims don't
have any direct symbols used. Tested for indirect use by compiling
amd64/i386/sparc64 kernels.

ok tedu@ deraadt@


Revision tags: OPENBSD_5_4_BASE OPENBSD_5_5_BASE OPENBSD_5_6_BASE OPENBSD_5_7_BASE
# 1.27 30-May-2013 deraadt

Enforce ca_activate tree-walks over the entire heirarchy for all events,
cleaning up some shutdown-hook related code on the way.
(A few drivers related to sparc are still skipped at kettenis' request)
ok kettenis mlarkin, tested by many others too


Revision tags: OPENBSD_5_3_BASE
# 1.26 04-Oct-2012 ehrhardt

Use information provided by ACPI to attach secondary PCI host bridges.

ok kettenis@


# 1.25 19-Sep-2012 kettenis

Set up PCI bus number resource accounting for the main PCI bus hierarchy.


Revision tags: OPENBSD_5_1_BASE OPENBSD_5_2_BASE
# 1.24 21-Oct-2011 kettenis

Add bounds checks for access to mp_busses.


Revision tags: OPENBSD_4_9_BASE OPENBSD_5_0_BASE
# 1.23 03-Nov-2010 dlg

only let vmt match and therefore attach if mainbus is specifically asking
for vmt to attach after vmt_probe succeeds. this prevents vmt from
appearing at other attach points hanging off mainbus.

found by phessler@ and debugged gently by claudio@


Revision tags: OPENBSD_4_7_BASE OPENBSD_4_8_BASE
# 1.22 28-Dec-2009 dlg

tweak vmt to work on amd64 as well as i386. like i386, it is still
commented out in GENERIC. it needs more love.

diff by david cranshaw a long time ago. sorry it has taken so long
for me to look at it.


# 1.21 23-Nov-2009 deraadt

oops, call config_activate_children


# 1.20 23-Nov-2009 deraadt

Use config_activate_children() for our cf_activate function
ok mlarkin pirofti


Revision tags: OPENBSD_4_6_BASE
# 1.19 21-Apr-2009 kettenis

Simplify PCI config space access code. There is no way we're ever going to
see the ancient mode 2 on machines capable of running OpenBSD/amd64.

ok deraadt@, toby@, oga@


# 1.18 11-Apr-2009 kettenis

Create extents for resource accounting on the root PCI bus and populate them
based on the BIOS memory map.


# 1.17 31-Mar-2009 kettenis

bzero pci attach args


Revision tags: OPENBSD_4_5_BASE
# 1.16 13-Jan-2009 kettenis

Turn mpbios into a real device, such that people can disable it on crappy
BIOSes.

ok deraadt@ (for the amd64 bit, or the i386 bit, can't remember which)


# 1.15 21-Dec-2008 kettenis

Change the way we include mpbios code to be similar to what we do on i386.

ok deraadt@


Revision tags: OPENBSD_4_3_BASE OPENBSD_4_4_BASE
# 1.14 05-Dec-2007 deraadt

Hang acpi(4) below bios(4) instead of mainbus(4). This lets us move acpi(4)
before pcibios(4), and then.... if acpi(4) attaches, skip pcibios(4) since
it messes the machines up. Fixes claudio's HP dl320 G5, and almost assuredly
others.
ok kettenis


# 1.13 16-Nov-2007 deraadt

fix the bus_space #define nightmare, so that amd64 and i386 are much more
uniform. as a result shared code like acpi needs less #ifdef's
ok marco kettenis


Revision tags: OPENBSD_4_2_BASE
# 1.12 06-May-2007 gwk

Add the mp setperf mechanism to AMD64, like its i386 counterpart it allows
all cpus in a system supporting frequency and voltage scaling to be scaled
by the same amount corresponding to the user (or apmd on their behalf)
performance level.

This diff also teaches amd64 about acpi_hasprocfvs (ACPI has processor
frequency and voltage scaling).

It also moves initilization of the underlying setperf mechanism such
as powernow to mainbus from the cpu indentification and initilization
code inspired by similar changes dim@ made to i386 durring h2k6. This
is necessary to implement the AMD recommended method for retreiving
p_state data from the ACPI _PSS object (a diff comming soon). It will
also simplify the potential addition of enhanced speedstep as found
on newer intel processors with EMT64 capable of running OpenBSD/amd64.

MP setperf functionality verifed by myself and Johan M:son Lindman <tybolt
AT solace DOT miun DOT se> on opteron 265 and 270 systems respectively.
General testing done by many others thanks!

ok tedu, dim


Revision tags: OPENBSD_4_1_BASE
# 1.11 14-Dec-2006 kettenis

Make pci subsystem aware of domains. Each host bridge gets assigned a unique
domain number such that we can distinguish between busses with the same bus
number that are behind different host bridges. Domains can be accessed by
using different device nodes.

ok deraadt@


# 1.10 25-Nov-2006 niklas

sync amd64 to i386 w.r.t. acpi support. Also fix interrupt routing for multi-ioapic systems.
ok kettenis


# 1.9 17-Nov-2006 kettenis

Decide whether we need to attach the primary cpu by checking the CPUF_PRESENT
flag just like we do on i386.


Revision tags: OPENBSD_4_0_BASE
# 1.8 08-May-2006 gwk

Add smbios support for i386 and amd64, fix ipmi to use this new functionallity,
hook up some sysctls to add system vendor/product/version and UUID reporting.

"get it in" deraadt@


# 1.7 14-Apr-2006 marco

ANSIfy functions.
Spacing.


# 1.6 13-Mar-2006 brad

* Add "pcitag_t *pba_bridgetag" to pci_attach_args. This is set to
NULL for root PCI busses. For busses behind a bridge, it points to
a persistent copy of the bridge's pcitag_t. This can be very useful
for machine-dependent PCI bus enumeration code.

From NetBSD

ok grange@ kettenis@


# 1.5 13-Mar-2006 marco

Fix machines that need PCI access during ACPI bringup.

Help and ok kettenis.


Revision tags: OPENBSD_3_9_BASE
# 1.4 29-Dec-2005 kettenis

Fix isadma0 at isa0 at mainbus0
ok deraadt@


# 1.3 19-Oct-2005 marco

Add IPMI to amd64. Keep it disabled for now.

Prodded earlier today by deraadt@
ok krw@


Revision tags: OPENBSD_3_8_BASE
# 1.2 02-Jun-2005 tholo

Start on a basic ACPI framework -- does not do much more than read out the
ACPI tables into kernel memory and attach ACPI and HPET timers currently.

In order to test this code, enabling the devices in GENERIC as well as
the ACPI_ENABLE option is needed. This code does not do any thermal
control yet, so this should be done with care depending on the platform.

In the tree so more people can contribute to making this more fully
featured.

Ok niklas@ grange@ tedu@


Revision tags: OPENBSD_3_5_BASE OPENBSD_3_6_BASE OPENBSD_3_7_BASE SMP_SYNC_A SMP_SYNC_B
# 1.1 28-Jan-2004 mickey

an amd64 arch support.
hacked by art@ from netbsd sources and then later debugged
by me into the shape where it can host itself.
no bootloader yet as needs redoing from the
recent advanced i386 sources (anyone? ;)


# 1.40 14-Oct-2017 jsg

reduce the amount of includes in arch/amd64
ok mpi@ deraadt@


Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE
# 1.39 25-Mar-2017 deraadt

Split vmm_probe() into a vmm_enabled() function, to better follow the
probe/attach approach used by mainbus.
ok mlarkin kettenis


# 1.38 28-Jul-2016 kettenis

Store the acpi processor ID/UID in struct cpu_info, and use it to attach
acpicpu(4) drivers to the right cpu(4).

ok mlarkin@, guenther@


Revision tags: OPENBSD_6_0_BASE
# 1.37 21-Jun-2016 jcs

add support to efifb for drawing a console on a coreboot framebuffer
if coreboot's memory table is found, it has a framebuffer entry, and
there is no previously attached efi, vga, or serial console.

useful on chromebooks that have no legacy vga device to get an early
console before inteldrm(4) attaches or, for newer chipsets, a full
console and X with wsfb(4).

ok kettenis


Revision tags: OPENBSD_5_9_BASE
# 1.36 12-Dec-2015 reyk

Identify hypervisors before configuring other children of the mainbus
(bios, CPU, interrupt handlers, pvbus). This splits the pvbus attach
function into two parts: pvbus_identify() to scan the CPUID registers
for supported hypervisors and pvbus_attach() to attach the bus, print
information, and configure the children.

This will be needed for Xen and KVM, as discussed with mikeb@ and sf@
OK mlarkin@


# 1.35 23-Nov-2015 deraadt

No longer need 'option VMM', declaring the vmm0 device is sufficient.
ok mlarkin


# 1.34 13-Nov-2015 mlarkin

vmm(4) kernel code

circulated on hackers@, no objections. Disabled by default.


# 1.33 31-Aug-2015 kettenis

Check driver name in match function such that driver only attempts to attach
when we actually want it to.

ok deraadt@


# 1.32 30-Aug-2015 kettenis

Don't try to attach efifb(4) on non-UEFI boots.

ok miod@, deraadt@


# 1.31 30-Aug-2015 yasuoka

Modify kernel to prepare boot from UEFI.

- Add new boot arg "bios_efi_info_t" to pass the paramters from UEFI
- Make bios(4) and acpi(4) be able to probe with the parameters from
UEFI
- Add efifb(8). It uses the framebuffer from UEFI and it will work as
a backend of wsdisplay(4) and wsfb (X11 video driver). Disabled by
the kernel config for this moment

input and ok kettenis


Revision tags: OPENBSD_5_8_BASE
# 1.30 21-Jul-2015 reyk

pvbus(4) was attaching too early, it has to wait for identifycpu.
Problem found on GENERIC by mlarkin.

OK mlarkin@


# 1.29 21-Jul-2015 reyk

Add pvbus(4), a pseudo-bus to attach non-PCI paravirtual devices and buses.
vmt(4) is moved from mainbus0 to pvbus0, more devices will follow.

OK sf@ deraadt@


# 1.28 14-Mar-2015 jsg

Remove some includes include-what-you-use claims don't
have any direct symbols used. Tested for indirect use by compiling
amd64/i386/sparc64 kernels.

ok tedu@ deraadt@


Revision tags: OPENBSD_5_4_BASE OPENBSD_5_5_BASE OPENBSD_5_6_BASE OPENBSD_5_7_BASE
# 1.27 30-May-2013 deraadt

Enforce ca_activate tree-walks over the entire heirarchy for all events,
cleaning up some shutdown-hook related code on the way.
(A few drivers related to sparc are still skipped at kettenis' request)
ok kettenis mlarkin, tested by many others too


Revision tags: OPENBSD_5_3_BASE
# 1.26 04-Oct-2012 ehrhardt

Use information provided by ACPI to attach secondary PCI host bridges.

ok kettenis@


# 1.25 19-Sep-2012 kettenis

Set up PCI bus number resource accounting for the main PCI bus hierarchy.


Revision tags: OPENBSD_5_1_BASE OPENBSD_5_2_BASE
# 1.24 21-Oct-2011 kettenis

Add bounds checks for access to mp_busses.


Revision tags: OPENBSD_4_9_BASE OPENBSD_5_0_BASE
# 1.23 03-Nov-2010 dlg

only let vmt match and therefore attach if mainbus is specifically asking
for vmt to attach after vmt_probe succeeds. this prevents vmt from
appearing at other attach points hanging off mainbus.

found by phessler@ and debugged gently by claudio@


Revision tags: OPENBSD_4_7_BASE OPENBSD_4_8_BASE
# 1.22 28-Dec-2009 dlg

tweak vmt to work on amd64 as well as i386. like i386, it is still
commented out in GENERIC. it needs more love.

diff by david cranshaw a long time ago. sorry it has taken so long
for me to look at it.


# 1.21 23-Nov-2009 deraadt

oops, call config_activate_children


# 1.20 23-Nov-2009 deraadt

Use config_activate_children() for our cf_activate function
ok mlarkin pirofti


Revision tags: OPENBSD_4_6_BASE
# 1.19 21-Apr-2009 kettenis

Simplify PCI config space access code. There is no way we're ever going to
see the ancient mode 2 on machines capable of running OpenBSD/amd64.

ok deraadt@, toby@, oga@


# 1.18 11-Apr-2009 kettenis

Create extents for resource accounting on the root PCI bus and populate them
based on the BIOS memory map.


# 1.17 31-Mar-2009 kettenis

bzero pci attach args


Revision tags: OPENBSD_4_5_BASE
# 1.16 13-Jan-2009 kettenis

Turn mpbios into a real device, such that people can disable it on crappy
BIOSes.

ok deraadt@ (for the amd64 bit, or the i386 bit, can't remember which)


# 1.15 21-Dec-2008 kettenis

Change the way we include mpbios code to be similar to what we do on i386.

ok deraadt@


Revision tags: OPENBSD_4_3_BASE OPENBSD_4_4_BASE
# 1.14 05-Dec-2007 deraadt

Hang acpi(4) below bios(4) instead of mainbus(4). This lets us move acpi(4)
before pcibios(4), and then.... if acpi(4) attaches, skip pcibios(4) since
it messes the machines up. Fixes claudio's HP dl320 G5, and almost assuredly
others.
ok kettenis


# 1.13 16-Nov-2007 deraadt

fix the bus_space #define nightmare, so that amd64 and i386 are much more
uniform. as a result shared code like acpi needs less #ifdef's
ok marco kettenis


Revision tags: OPENBSD_4_2_BASE
# 1.12 06-May-2007 gwk

Add the mp setperf mechanism to AMD64, like its i386 counterpart it allows
all cpus in a system supporting frequency and voltage scaling to be scaled
by the same amount corresponding to the user (or apmd on their behalf)
performance level.

This diff also teaches amd64 about acpi_hasprocfvs (ACPI has processor
frequency and voltage scaling).

It also moves initilization of the underlying setperf mechanism such
as powernow to mainbus from the cpu indentification and initilization
code inspired by similar changes dim@ made to i386 durring h2k6. This
is necessary to implement the AMD recommended method for retreiving
p_state data from the ACPI _PSS object (a diff comming soon). It will
also simplify the potential addition of enhanced speedstep as found
on newer intel processors with EMT64 capable of running OpenBSD/amd64.

MP setperf functionality verifed by myself and Johan M:son Lindman <tybolt
AT solace DOT miun DOT se> on opteron 265 and 270 systems respectively.
General testing done by many others thanks!

ok tedu, dim


Revision tags: OPENBSD_4_1_BASE
# 1.11 14-Dec-2006 kettenis

Make pci subsystem aware of domains. Each host bridge gets assigned a unique
domain number such that we can distinguish between busses with the same bus
number that are behind different host bridges. Domains can be accessed by
using different device nodes.

ok deraadt@


# 1.10 25-Nov-2006 niklas

sync amd64 to i386 w.r.t. acpi support. Also fix interrupt routing for multi-ioapic systems.
ok kettenis


# 1.9 17-Nov-2006 kettenis

Decide whether we need to attach the primary cpu by checking the CPUF_PRESENT
flag just like we do on i386.


Revision tags: OPENBSD_4_0_BASE
# 1.8 08-May-2006 gwk

Add smbios support for i386 and amd64, fix ipmi to use this new functionallity,
hook up some sysctls to add system vendor/product/version and UUID reporting.

"get it in" deraadt@


# 1.7 14-Apr-2006 marco

ANSIfy functions.
Spacing.


# 1.6 13-Mar-2006 brad

* Add "pcitag_t *pba_bridgetag" to pci_attach_args. This is set to
NULL for root PCI busses. For busses behind a bridge, it points to
a persistent copy of the bridge's pcitag_t. This can be very useful
for machine-dependent PCI bus enumeration code.

From NetBSD

ok grange@ kettenis@


# 1.5 13-Mar-2006 marco

Fix machines that need PCI access during ACPI bringup.

Help and ok kettenis.


Revision tags: OPENBSD_3_9_BASE
# 1.4 29-Dec-2005 kettenis

Fix isadma0 at isa0 at mainbus0
ok deraadt@


# 1.3 19-Oct-2005 marco

Add IPMI to amd64. Keep it disabled for now.

Prodded earlier today by deraadt@
ok krw@


Revision tags: OPENBSD_3_8_BASE
# 1.2 02-Jun-2005 tholo

Start on a basic ACPI framework -- does not do much more than read out the
ACPI tables into kernel memory and attach ACPI and HPET timers currently.

In order to test this code, enabling the devices in GENERIC as well as
the ACPI_ENABLE option is needed. This code does not do any thermal
control yet, so this should be done with care depending on the platform.

In the tree so more people can contribute to making this more fully
featured.

Ok niklas@ grange@ tedu@


Revision tags: OPENBSD_3_5_BASE OPENBSD_3_6_BASE OPENBSD_3_7_BASE SMP_SYNC_A SMP_SYNC_B
# 1.1 28-Jan-2004 mickey

an amd64 arch support.
hacked by art@ from netbsd sources and then later debugged
by me into the shape where it can host itself.
no bootloader yet as needs redoing from the
recent advanced i386 sources (anyone? ;)