History log of /openbsd-current/sys/dev/pci/amdpm.c
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
# 1.40 24-May-2024 jsg

remove unneeded includes; ok miod@


Revision tags: OPENBSD_7_3_BASE OPENBSD_7_4_BASE OPENBSD_7_5_BASE
# 1.39 04-Feb-2023 cheloha

timecounting: remove incomplete PPS support

The timecounting code has had stubs for pulse-per-second (PPS) polling
since it was imported in 2004. At this point it seems unlikely that
anyone is going to finish adding PPS support, so let's remove the stubs:

- Delete the dead tc_poll_pps() call from tc_windup().
- Remove all tc_poll_pps symbols from the kernel.

Link: https://marc.info/?l=openbsd-tech&m=167519035723210&w=2

ok miod@


Revision tags: OPENBSD_7_1_BASE OPENBSD_7_2_BASE
# 1.38 11-Mar-2022 mpi

Constify struct cfattach.


Revision tags: OPENBSD_6_9_BASE OPENBSD_7_0_BASE
# 1.37 23-Feb-2021 cheloha

timecounting: use C99-style initialization for all timecounter structs

The timecounter struct is large and I think it may change in the
future. Changing it later will be easier if we use C99-style
initialization for all timecounter structs. It also makes reading the
code a bit easier.

For reasons I cannot explain, switching to C99-style initialization
sometimes changes the hash of the resulting object file, even though
the resulting struct should be the same. So there is a binary change
here, but only sometimes. No behavior should change in either case.

I can't compile-test this everywhere but I have been staring at the
diff for days now and I'm relatively confident this will not break
compilation. Fingers crossed.

ok gnezdo@


Revision tags: OPENBSD_6_8_BASE
# 1.36 06-Jul-2020 pirofti

Add support for timeconting in userland.

This diff exposes parts of clock_gettime(2) and gettimeofday(2) to
userland via libc eliberating processes from the need for a context
switch everytime they want to count the passage of time.

If a timecounter clock can be exposed to userland than it needs to set
its tc_user member to a non-zero value. Tested with one or multiple
counters per architecture.

The timing data is shared through a pointer found in the new ELF
auxiliary vector AUX_openbsd_timekeep containing timehands information
that is frequently updated by the kernel.

Timing differences between the last kernel update and the current time
are adjusted in userland by the tc_get_timecount() function inside the
MD usertc.c file.

This permits a much more responsive environment, quite visible in
browsers, office programs and gaming (apparently one is are able to fly
in Minecraft now).

Tested by robert@, sthen@, naddy@, kmos@, phessler@, and many others!

OK from at least kettenis@, cheloha@, naddy@, sthen@


# 1.35 29-May-2020 deraadt

dev/rndvar.h no longer has statistical interfaces (removed during various
conversion steps). it only contains kernel prototypes for 4 interfaces,
all of which legitimately belong in sys/systm.h, which are already included
by all enqueue_randomness() users.


Revision tags: OPENBSD_6_7_BASE
# 1.34 09-Jan-2020 mpi

Convert sleeps of 1sec or more to tsleep_nsec(9).

ok bluhm@


Revision tags: OPENBSD_6_4_BASE OPENBSD_6_5_BASE OPENBSD_6_6_BASE
# 1.33 28-Apr-2018 jasper

replace add_*_randomness with enqueue_randomness()

this gets rid of the source annotation which doesn't really add
anything other than adding complexitiy. randomess is generally
good enough that the few extra bits that the source type would
add are not worth it.

ok mikeb@ deraadt@


Revision tags: OPENBSD_5_5_BASE OPENBSD_5_6_BASE OPENBSD_5_7_BASE OPENBSD_5_8_BASE OPENBSD_5_9_BASE OPENBSD_6_0_BASE OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE
# 1.32 06-Dec-2013 deraadt

Add a DVACT_WAKEUP op to the *_activate() API. This is called after the
kernel resumes normal (non-cold, able to run processes, etc) operation.
Previously we were relying on specific DVACT_RESUME op's in drivers
creating callback/threads themselves, but that has become too common,
indicating the need for a built-in mechanism.
ok dlg kettenis, tested by a sufficient amount of people


# 1.31 01-Oct-2013 sf

Use %z* for size_t

while there, fix a few %d into %u


Revision tags: OPENBSD_5_4_BASE
# 1.30 03-Jul-2013 sf

fix: cast void * to char *, fix format args for (u)int64_t,
tc_frequency is unsigned

ok kettenis@


# 1.29 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.28 05-Oct-2012 haesbaert

Avoid uninitiliazed use of ctl and corresponding warnings.
Part of the work to remove -Wno-uninitialized.

ok kettenis@


# 1.27 16-Aug-2012 tedu

we are past the point where timecounters may disappear
ok miod


Revision tags: OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE
# 1.26 09-Apr-2011 deraadt

use unique wait channels


Revision tags: OPENBSD_4_8_BASE OPENBSD_4_9_BASE
# 1.25 08-Aug-2010 deraadt

at resume time, re-nable the AMDPM_RNGEN bit


# 1.24 08-Apr-2010 tedu

these files don't need to include proc.h anymore. ok oga for agp


Revision tags: OPENBSD_4_4_BASE OPENBSD_4_5_BASE OPENBSD_4_6_BASE OPENBSD_4_7_BASE
# 1.23 26-Jun-2008 ray

First pass at removing clauses 3 and 4 from NetBSD licenses.

Not sure what's more surprising: how long it took for NetBSD to
catch up to the rest of the BSDs (including UCB), or the amount of
code that NetBSD has claimed for itself without attributing to the
actual authors.

OK deraadt@


# 1.22 06-May-2008 markus

AMD_8111_PMC has timecounter, too; ok grange@ some time ago


Revision tags: OPENBSD_4_2_BASE OPENBSD_4_3_BASE
# 1.21 03-May-2007 dlg

convert lockmgr style locks to rwlocks.

input from art@


Revision tags: OPENBSD_4_1_BASE
# 1.20 11-Dec-2006 deraadt

do not bus_space_map devices which are at address 0; ok kettenis


# 1.19 28-Nov-2006 kettenis

acpi may steal power management functionality, in which case we
cannot io map the device. Bail out without warning. If we want
to retain the rgn we could re-enable io and be very very careful.

ok deraadt@


# 1.18 28-Sep-2006 grange

Provide more info in error messages so we can see what's going
on. And some cosmetics in debug messages while here.


Revision tags: OPENBSD_4_0_BASE
# 1.17 09-Mar-2006 dlg

unbreak the tree. i dunno how this compiled on my box at home.

found by marco@


# 1.16 08-Mar-2006 dlg

amdpmreg.h is only used by amdpm.c, so merge the header into the c file.
this unclutters the tree a bit.

ok deraadt@


# 1.15 08-Mar-2006 dlg

tweak the debug macros a bit


# 1.14 08-Mar-2006 dlg

fix support for the smbus controller on nforce 1 chipsets. only try to
use the timer and rng on amd chips.

diff, testing, and patience from gwk


# 1.13 07-Mar-2006 dlg

whitespace fixes


Revision tags: OPENBSD_3_9_BASE
# 1.12 15-Jan-2006 grange

In iic_exec don't fail immediately if bus is already busy. It might be
running a BIOS' transfer so wait a bit and try again.


# 1.11 09-Jan-2006 deraadt

with an offset tweak, this can also support the nvidia nforce smbus
same unit is found on amd756 and amd8111. try to support the RNG as
well. from gklok@cogeco.ca


# 1.10 06-Jan-2006 brad

remove NetBSD's event counter code.

ok grange@


# 1.9 05-Jan-2006 grange

knf


# 1.8 05-Jan-2006 grange

Add my copyright.


# 1.7 05-Jan-2006 grange

Add SMBus host interface support for amdpm(4).

ok deraadt@


# 1.6 02-Jan-2006 brad

use pci_matchbyid.


Revision tags: OPENBSD_3_7_BASE OPENBSD_3_8_BASE
# 1.5 17-Sep-2004 grange

Some cleanup:
- don't mix unsigned and u_int across the code
- un'static some funcs

ok art@


Revision tags: OPENBSD_3_6_BASE
# 1.4 28-Jul-2004 tholo

This touches only MI code, and adds new time keeping code. The
code is all conditionalized on __HAVE_TIMECOUNTER, and not
enabled on any platforms.

adjtime(2) support exists, courtesy of nordin@, sysctl(2) support
and a concept of quality for each time source attached exists.

High quality time sources exists for PIIX4 ACPI timer as well as
some AMD power management chips. This will have to be redone
once we actually add ACPI support (at that time we need to use
the ACPI interfaces to get at these clocks).

ok art@ ken@ miod@ jmc@ and many more


Revision tags: OPENBSD_3_3_BASE OPENBSD_3_4_BASE OPENBSD_3_5_BASE SMP_SYNC_A SMP_SYNC_B UBC_SYNC_A
# 1.3 04-Nov-2002 fgsch

make this compile; reported by pluf, mickey ok.


Revision tags: OPENBSD_3_2_BASE UBC_SYNC_B
# 1.2 05-Jun-2002 mickey

branches: 1.2.2;
steal'' performance calculating loop from pchb.c and have a uniform output


# 1.1 05-Jun-2002 mickey

a driver for the rng on the amd768 power management device (no actual power management capabilities are supported yet; from netbsd


# 1.39 04-Feb-2023 cheloha

timecounting: remove incomplete PPS support

The timecounting code has had stubs for pulse-per-second (PPS) polling
since it was imported in 2004. At this point it seems unlikely that
anyone is going to finish adding PPS support, so let's remove the stubs:

- Delete the dead tc_poll_pps() call from tc_windup().
- Remove all tc_poll_pps symbols from the kernel.

Link: https://marc.info/?l=openbsd-tech&m=167519035723210&w=2

ok miod@


Revision tags: OPENBSD_7_1_BASE OPENBSD_7_2_BASE
# 1.38 11-Mar-2022 mpi

Constify struct cfattach.


Revision tags: OPENBSD_6_9_BASE OPENBSD_7_0_BASE
# 1.37 23-Feb-2021 cheloha

timecounting: use C99-style initialization for all timecounter structs

The timecounter struct is large and I think it may change in the
future. Changing it later will be easier if we use C99-style
initialization for all timecounter structs. It also makes reading the
code a bit easier.

For reasons I cannot explain, switching to C99-style initialization
sometimes changes the hash of the resulting object file, even though
the resulting struct should be the same. So there is a binary change
here, but only sometimes. No behavior should change in either case.

I can't compile-test this everywhere but I have been staring at the
diff for days now and I'm relatively confident this will not break
compilation. Fingers crossed.

ok gnezdo@


Revision tags: OPENBSD_6_8_BASE
# 1.36 06-Jul-2020 pirofti

Add support for timeconting in userland.

This diff exposes parts of clock_gettime(2) and gettimeofday(2) to
userland via libc eliberating processes from the need for a context
switch everytime they want to count the passage of time.

If a timecounter clock can be exposed to userland than it needs to set
its tc_user member to a non-zero value. Tested with one or multiple
counters per architecture.

The timing data is shared through a pointer found in the new ELF
auxiliary vector AUX_openbsd_timekeep containing timehands information
that is frequently updated by the kernel.

Timing differences between the last kernel update and the current time
are adjusted in userland by the tc_get_timecount() function inside the
MD usertc.c file.

This permits a much more responsive environment, quite visible in
browsers, office programs and gaming (apparently one is are able to fly
in Minecraft now).

Tested by robert@, sthen@, naddy@, kmos@, phessler@, and many others!

OK from at least kettenis@, cheloha@, naddy@, sthen@


# 1.35 29-May-2020 deraadt

dev/rndvar.h no longer has statistical interfaces (removed during various
conversion steps). it only contains kernel prototypes for 4 interfaces,
all of which legitimately belong in sys/systm.h, which are already included
by all enqueue_randomness() users.


Revision tags: OPENBSD_6_7_BASE
# 1.34 09-Jan-2020 mpi

Convert sleeps of 1sec or more to tsleep_nsec(9).

ok bluhm@


Revision tags: OPENBSD_6_4_BASE OPENBSD_6_5_BASE OPENBSD_6_6_BASE
# 1.33 28-Apr-2018 jasper

replace add_*_randomness with enqueue_randomness()

this gets rid of the source annotation which doesn't really add
anything other than adding complexitiy. randomess is generally
good enough that the few extra bits that the source type would
add are not worth it.

ok mikeb@ deraadt@


Revision tags: OPENBSD_5_5_BASE OPENBSD_5_6_BASE OPENBSD_5_7_BASE OPENBSD_5_8_BASE OPENBSD_5_9_BASE OPENBSD_6_0_BASE OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE
# 1.32 06-Dec-2013 deraadt

Add a DVACT_WAKEUP op to the *_activate() API. This is called after the
kernel resumes normal (non-cold, able to run processes, etc) operation.
Previously we were relying on specific DVACT_RESUME op's in drivers
creating callback/threads themselves, but that has become too common,
indicating the need for a built-in mechanism.
ok dlg kettenis, tested by a sufficient amount of people


# 1.31 01-Oct-2013 sf

Use %z* for size_t

while there, fix a few %d into %u


Revision tags: OPENBSD_5_4_BASE
# 1.30 03-Jul-2013 sf

fix: cast void * to char *, fix format args for (u)int64_t,
tc_frequency is unsigned

ok kettenis@


# 1.29 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.28 05-Oct-2012 haesbaert

Avoid uninitiliazed use of ctl and corresponding warnings.
Part of the work to remove -Wno-uninitialized.

ok kettenis@


# 1.27 16-Aug-2012 tedu

we are past the point where timecounters may disappear
ok miod


Revision tags: OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE
# 1.26 09-Apr-2011 deraadt

use unique wait channels


Revision tags: OPENBSD_4_8_BASE OPENBSD_4_9_BASE
# 1.25 08-Aug-2010 deraadt

at resume time, re-nable the AMDPM_RNGEN bit


# 1.24 08-Apr-2010 tedu

these files don't need to include proc.h anymore. ok oga for agp


Revision tags: OPENBSD_4_4_BASE OPENBSD_4_5_BASE OPENBSD_4_6_BASE OPENBSD_4_7_BASE
# 1.23 26-Jun-2008 ray

First pass at removing clauses 3 and 4 from NetBSD licenses.

Not sure what's more surprising: how long it took for NetBSD to
catch up to the rest of the BSDs (including UCB), or the amount of
code that NetBSD has claimed for itself without attributing to the
actual authors.

OK deraadt@


# 1.22 06-May-2008 markus

AMD_8111_PMC has timecounter, too; ok grange@ some time ago


Revision tags: OPENBSD_4_2_BASE OPENBSD_4_3_BASE
# 1.21 03-May-2007 dlg

convert lockmgr style locks to rwlocks.

input from art@


Revision tags: OPENBSD_4_1_BASE
# 1.20 11-Dec-2006 deraadt

do not bus_space_map devices which are at address 0; ok kettenis


# 1.19 28-Nov-2006 kettenis

acpi may steal power management functionality, in which case we
cannot io map the device. Bail out without warning. If we want
to retain the rgn we could re-enable io and be very very careful.

ok deraadt@


# 1.18 28-Sep-2006 grange

Provide more info in error messages so we can see what's going
on. And some cosmetics in debug messages while here.


Revision tags: OPENBSD_4_0_BASE
# 1.17 09-Mar-2006 dlg

unbreak the tree. i dunno how this compiled on my box at home.

found by marco@


# 1.16 08-Mar-2006 dlg

amdpmreg.h is only used by amdpm.c, so merge the header into the c file.
this unclutters the tree a bit.

ok deraadt@


# 1.15 08-Mar-2006 dlg

tweak the debug macros a bit


# 1.14 08-Mar-2006 dlg

fix support for the smbus controller on nforce 1 chipsets. only try to
use the timer and rng on amd chips.

diff, testing, and patience from gwk


# 1.13 07-Mar-2006 dlg

whitespace fixes


Revision tags: OPENBSD_3_9_BASE
# 1.12 15-Jan-2006 grange

In iic_exec don't fail immediately if bus is already busy. It might be
running a BIOS' transfer so wait a bit and try again.


# 1.11 09-Jan-2006 deraadt

with an offset tweak, this can also support the nvidia nforce smbus
same unit is found on amd756 and amd8111. try to support the RNG as
well. from gklok@cogeco.ca


# 1.10 06-Jan-2006 brad

remove NetBSD's event counter code.

ok grange@


# 1.9 05-Jan-2006 grange

knf


# 1.8 05-Jan-2006 grange

Add my copyright.


# 1.7 05-Jan-2006 grange

Add SMBus host interface support for amdpm(4).

ok deraadt@


# 1.6 02-Jan-2006 brad

use pci_matchbyid.


Revision tags: OPENBSD_3_7_BASE OPENBSD_3_8_BASE
# 1.5 17-Sep-2004 grange

Some cleanup:
- don't mix unsigned and u_int across the code
- un'static some funcs

ok art@


Revision tags: OPENBSD_3_6_BASE
# 1.4 28-Jul-2004 tholo

This touches only MI code, and adds new time keeping code. The
code is all conditionalized on __HAVE_TIMECOUNTER, and not
enabled on any platforms.

adjtime(2) support exists, courtesy of nordin@, sysctl(2) support
and a concept of quality for each time source attached exists.

High quality time sources exists for PIIX4 ACPI timer as well as
some AMD power management chips. This will have to be redone
once we actually add ACPI support (at that time we need to use
the ACPI interfaces to get at these clocks).

ok art@ ken@ miod@ jmc@ and many more


Revision tags: OPENBSD_3_3_BASE OPENBSD_3_4_BASE OPENBSD_3_5_BASE SMP_SYNC_A SMP_SYNC_B UBC_SYNC_A
# 1.3 04-Nov-2002 fgsch

make this compile; reported by pluf, mickey ok.


Revision tags: OPENBSD_3_2_BASE UBC_SYNC_B
# 1.2 05-Jun-2002 mickey

branches: 1.2.2;
steal'' performance calculating loop from pchb.c and have a uniform output


# 1.1 05-Jun-2002 mickey

a driver for the rng on the amd768 power management device (no actual power management capabilities are supported yet; from netbsd


# 1.38 11-Mar-2022 mpi

Constify struct cfattach.


Revision tags: OPENBSD_6_9_BASE OPENBSD_7_0_BASE
# 1.37 23-Feb-2021 cheloha

timecounting: use C99-style initialization for all timecounter structs

The timecounter struct is large and I think it may change in the
future. Changing it later will be easier if we use C99-style
initialization for all timecounter structs. It also makes reading the
code a bit easier.

For reasons I cannot explain, switching to C99-style initialization
sometimes changes the hash of the resulting object file, even though
the resulting struct should be the same. So there is a binary change
here, but only sometimes. No behavior should change in either case.

I can't compile-test this everywhere but I have been staring at the
diff for days now and I'm relatively confident this will not break
compilation. Fingers crossed.

ok gnezdo@


Revision tags: OPENBSD_6_8_BASE
# 1.36 06-Jul-2020 pirofti

Add support for timeconting in userland.

This diff exposes parts of clock_gettime(2) and gettimeofday(2) to
userland via libc eliberating processes from the need for a context
switch everytime they want to count the passage of time.

If a timecounter clock can be exposed to userland than it needs to set
its tc_user member to a non-zero value. Tested with one or multiple
counters per architecture.

The timing data is shared through a pointer found in the new ELF
auxiliary vector AUX_openbsd_timekeep containing timehands information
that is frequently updated by the kernel.

Timing differences between the last kernel update and the current time
are adjusted in userland by the tc_get_timecount() function inside the
MD usertc.c file.

This permits a much more responsive environment, quite visible in
browsers, office programs and gaming (apparently one is are able to fly
in Minecraft now).

Tested by robert@, sthen@, naddy@, kmos@, phessler@, and many others!

OK from at least kettenis@, cheloha@, naddy@, sthen@


# 1.35 29-May-2020 deraadt

dev/rndvar.h no longer has statistical interfaces (removed during various
conversion steps). it only contains kernel prototypes for 4 interfaces,
all of which legitimately belong in sys/systm.h, which are already included
by all enqueue_randomness() users.


Revision tags: OPENBSD_6_7_BASE
# 1.34 09-Jan-2020 mpi

Convert sleeps of 1sec or more to tsleep_nsec(9).

ok bluhm@


Revision tags: OPENBSD_6_4_BASE OPENBSD_6_5_BASE OPENBSD_6_6_BASE
# 1.33 28-Apr-2018 jasper

replace add_*_randomness with enqueue_randomness()

this gets rid of the source annotation which doesn't really add
anything other than adding complexitiy. randomess is generally
good enough that the few extra bits that the source type would
add are not worth it.

ok mikeb@ deraadt@


Revision tags: OPENBSD_5_5_BASE OPENBSD_5_6_BASE OPENBSD_5_7_BASE OPENBSD_5_8_BASE OPENBSD_5_9_BASE OPENBSD_6_0_BASE OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE
# 1.32 06-Dec-2013 deraadt

Add a DVACT_WAKEUP op to the *_activate() API. This is called after the
kernel resumes normal (non-cold, able to run processes, etc) operation.
Previously we were relying on specific DVACT_RESUME op's in drivers
creating callback/threads themselves, but that has become too common,
indicating the need for a built-in mechanism.
ok dlg kettenis, tested by a sufficient amount of people


# 1.31 01-Oct-2013 sf

Use %z* for size_t

while there, fix a few %d into %u


Revision tags: OPENBSD_5_4_BASE
# 1.30 03-Jul-2013 sf

fix: cast void * to char *, fix format args for (u)int64_t,
tc_frequency is unsigned

ok kettenis@


# 1.29 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.28 05-Oct-2012 haesbaert

Avoid uninitiliazed use of ctl and corresponding warnings.
Part of the work to remove -Wno-uninitialized.

ok kettenis@


# 1.27 16-Aug-2012 tedu

we are past the point where timecounters may disappear
ok miod


Revision tags: OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE
# 1.26 09-Apr-2011 deraadt

use unique wait channels


Revision tags: OPENBSD_4_8_BASE OPENBSD_4_9_BASE
# 1.25 08-Aug-2010 deraadt

at resume time, re-nable the AMDPM_RNGEN bit


# 1.24 08-Apr-2010 tedu

these files don't need to include proc.h anymore. ok oga for agp


Revision tags: OPENBSD_4_4_BASE OPENBSD_4_5_BASE OPENBSD_4_6_BASE OPENBSD_4_7_BASE
# 1.23 26-Jun-2008 ray

First pass at removing clauses 3 and 4 from NetBSD licenses.

Not sure what's more surprising: how long it took for NetBSD to
catch up to the rest of the BSDs (including UCB), or the amount of
code that NetBSD has claimed for itself without attributing to the
actual authors.

OK deraadt@


# 1.22 06-May-2008 markus

AMD_8111_PMC has timecounter, too; ok grange@ some time ago


Revision tags: OPENBSD_4_2_BASE OPENBSD_4_3_BASE
# 1.21 03-May-2007 dlg

convert lockmgr style locks to rwlocks.

input from art@


Revision tags: OPENBSD_4_1_BASE
# 1.20 11-Dec-2006 deraadt

do not bus_space_map devices which are at address 0; ok kettenis


# 1.19 28-Nov-2006 kettenis

acpi may steal power management functionality, in which case we
cannot io map the device. Bail out without warning. If we want
to retain the rgn we could re-enable io and be very very careful.

ok deraadt@


# 1.18 28-Sep-2006 grange

Provide more info in error messages so we can see what's going
on. And some cosmetics in debug messages while here.


Revision tags: OPENBSD_4_0_BASE
# 1.17 09-Mar-2006 dlg

unbreak the tree. i dunno how this compiled on my box at home.

found by marco@


# 1.16 08-Mar-2006 dlg

amdpmreg.h is only used by amdpm.c, so merge the header into the c file.
this unclutters the tree a bit.

ok deraadt@


# 1.15 08-Mar-2006 dlg

tweak the debug macros a bit


# 1.14 08-Mar-2006 dlg

fix support for the smbus controller on nforce 1 chipsets. only try to
use the timer and rng on amd chips.

diff, testing, and patience from gwk


# 1.13 07-Mar-2006 dlg

whitespace fixes


Revision tags: OPENBSD_3_9_BASE
# 1.12 15-Jan-2006 grange

In iic_exec don't fail immediately if bus is already busy. It might be
running a BIOS' transfer so wait a bit and try again.


# 1.11 09-Jan-2006 deraadt

with an offset tweak, this can also support the nvidia nforce smbus
same unit is found on amd756 and amd8111. try to support the RNG as
well. from gklok@cogeco.ca


# 1.10 06-Jan-2006 brad

remove NetBSD's event counter code.

ok grange@


# 1.9 05-Jan-2006 grange

knf


# 1.8 05-Jan-2006 grange

Add my copyright.


# 1.7 05-Jan-2006 grange

Add SMBus host interface support for amdpm(4).

ok deraadt@


# 1.6 02-Jan-2006 brad

use pci_matchbyid.


Revision tags: OPENBSD_3_7_BASE OPENBSD_3_8_BASE
# 1.5 17-Sep-2004 grange

Some cleanup:
- don't mix unsigned and u_int across the code
- un'static some funcs

ok art@


Revision tags: OPENBSD_3_6_BASE
# 1.4 28-Jul-2004 tholo

This touches only MI code, and adds new time keeping code. The
code is all conditionalized on __HAVE_TIMECOUNTER, and not
enabled on any platforms.

adjtime(2) support exists, courtesy of nordin@, sysctl(2) support
and a concept of quality for each time source attached exists.

High quality time sources exists for PIIX4 ACPI timer as well as
some AMD power management chips. This will have to be redone
once we actually add ACPI support (at that time we need to use
the ACPI interfaces to get at these clocks).

ok art@ ken@ miod@ jmc@ and many more


Revision tags: OPENBSD_3_3_BASE OPENBSD_3_4_BASE OPENBSD_3_5_BASE SMP_SYNC_A SMP_SYNC_B UBC_SYNC_A
# 1.3 04-Nov-2002 fgsch

make this compile; reported by pluf, mickey ok.


Revision tags: OPENBSD_3_2_BASE UBC_SYNC_B
# 1.2 05-Jun-2002 mickey

branches: 1.2.2;
steal'' performance calculating loop from pchb.c and have a uniform output


# 1.1 05-Jun-2002 mickey

a driver for the rng on the amd768 power management device (no actual power management capabilities are supported yet; from netbsd


# 1.37 23-Feb-2021 cheloha

timecounting: use C99-style initialization for all timecounter structs

The timecounter struct is large and I think it may change in the
future. Changing it later will be easier if we use C99-style
initialization for all timecounter structs. It also makes reading the
code a bit easier.

For reasons I cannot explain, switching to C99-style initialization
sometimes changes the hash of the resulting object file, even though
the resulting struct should be the same. So there is a binary change
here, but only sometimes. No behavior should change in either case.

I can't compile-test this everywhere but I have been staring at the
diff for days now and I'm relatively confident this will not break
compilation. Fingers crossed.

ok gnezdo@


Revision tags: OPENBSD_6_8_BASE
# 1.36 06-Jul-2020 pirofti

Add support for timeconting in userland.

This diff exposes parts of clock_gettime(2) and gettimeofday(2) to
userland via libc eliberating processes from the need for a context
switch everytime they want to count the passage of time.

If a timecounter clock can be exposed to userland than it needs to set
its tc_user member to a non-zero value. Tested with one or multiple
counters per architecture.

The timing data is shared through a pointer found in the new ELF
auxiliary vector AUX_openbsd_timekeep containing timehands information
that is frequently updated by the kernel.

Timing differences between the last kernel update and the current time
are adjusted in userland by the tc_get_timecount() function inside the
MD usertc.c file.

This permits a much more responsive environment, quite visible in
browsers, office programs and gaming (apparently one is are able to fly
in Minecraft now).

Tested by robert@, sthen@, naddy@, kmos@, phessler@, and many others!

OK from at least kettenis@, cheloha@, naddy@, sthen@


# 1.35 29-May-2020 deraadt

dev/rndvar.h no longer has statistical interfaces (removed during various
conversion steps). it only contains kernel prototypes for 4 interfaces,
all of which legitimately belong in sys/systm.h, which are already included
by all enqueue_randomness() users.


Revision tags: OPENBSD_6_7_BASE
# 1.34 09-Jan-2020 mpi

Convert sleeps of 1sec or more to tsleep_nsec(9).

ok bluhm@


Revision tags: OPENBSD_6_4_BASE OPENBSD_6_5_BASE OPENBSD_6_6_BASE
# 1.33 28-Apr-2018 jasper

replace add_*_randomness with enqueue_randomness()

this gets rid of the source annotation which doesn't really add
anything other than adding complexitiy. randomess is generally
good enough that the few extra bits that the source type would
add are not worth it.

ok mikeb@ deraadt@


Revision tags: OPENBSD_5_5_BASE OPENBSD_5_6_BASE OPENBSD_5_7_BASE OPENBSD_5_8_BASE OPENBSD_5_9_BASE OPENBSD_6_0_BASE OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE
# 1.32 06-Dec-2013 deraadt

Add a DVACT_WAKEUP op to the *_activate() API. This is called after the
kernel resumes normal (non-cold, able to run processes, etc) operation.
Previously we were relying on specific DVACT_RESUME op's in drivers
creating callback/threads themselves, but that has become too common,
indicating the need for a built-in mechanism.
ok dlg kettenis, tested by a sufficient amount of people


# 1.31 01-Oct-2013 sf

Use %z* for size_t

while there, fix a few %d into %u


Revision tags: OPENBSD_5_4_BASE
# 1.30 03-Jul-2013 sf

fix: cast void * to char *, fix format args for (u)int64_t,
tc_frequency is unsigned

ok kettenis@


# 1.29 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.28 05-Oct-2012 haesbaert

Avoid uninitiliazed use of ctl and corresponding warnings.
Part of the work to remove -Wno-uninitialized.

ok kettenis@


# 1.27 16-Aug-2012 tedu

we are past the point where timecounters may disappear
ok miod


Revision tags: OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE
# 1.26 09-Apr-2011 deraadt

use unique wait channels


Revision tags: OPENBSD_4_8_BASE OPENBSD_4_9_BASE
# 1.25 08-Aug-2010 deraadt

at resume time, re-nable the AMDPM_RNGEN bit


# 1.24 08-Apr-2010 tedu

these files don't need to include proc.h anymore. ok oga for agp


Revision tags: OPENBSD_4_4_BASE OPENBSD_4_5_BASE OPENBSD_4_6_BASE OPENBSD_4_7_BASE
# 1.23 26-Jun-2008 ray

First pass at removing clauses 3 and 4 from NetBSD licenses.

Not sure what's more surprising: how long it took for NetBSD to
catch up to the rest of the BSDs (including UCB), or the amount of
code that NetBSD has claimed for itself without attributing to the
actual authors.

OK deraadt@


# 1.22 06-May-2008 markus

AMD_8111_PMC has timecounter, too; ok grange@ some time ago


Revision tags: OPENBSD_4_2_BASE OPENBSD_4_3_BASE
# 1.21 03-May-2007 dlg

convert lockmgr style locks to rwlocks.

input from art@


Revision tags: OPENBSD_4_1_BASE
# 1.20 11-Dec-2006 deraadt

do not bus_space_map devices which are at address 0; ok kettenis


# 1.19 28-Nov-2006 kettenis

acpi may steal power management functionality, in which case we
cannot io map the device. Bail out without warning. If we want
to retain the rgn we could re-enable io and be very very careful.

ok deraadt@


# 1.18 28-Sep-2006 grange

Provide more info in error messages so we can see what's going
on. And some cosmetics in debug messages while here.


Revision tags: OPENBSD_4_0_BASE
# 1.17 09-Mar-2006 dlg

unbreak the tree. i dunno how this compiled on my box at home.

found by marco@


# 1.16 08-Mar-2006 dlg

amdpmreg.h is only used by amdpm.c, so merge the header into the c file.
this unclutters the tree a bit.

ok deraadt@


# 1.15 08-Mar-2006 dlg

tweak the debug macros a bit


# 1.14 08-Mar-2006 dlg

fix support for the smbus controller on nforce 1 chipsets. only try to
use the timer and rng on amd chips.

diff, testing, and patience from gwk


# 1.13 07-Mar-2006 dlg

whitespace fixes


Revision tags: OPENBSD_3_9_BASE
# 1.12 15-Jan-2006 grange

In iic_exec don't fail immediately if bus is already busy. It might be
running a BIOS' transfer so wait a bit and try again.


# 1.11 09-Jan-2006 deraadt

with an offset tweak, this can also support the nvidia nforce smbus
same unit is found on amd756 and amd8111. try to support the RNG as
well. from gklok@cogeco.ca


# 1.10 06-Jan-2006 brad

remove NetBSD's event counter code.

ok grange@


# 1.9 05-Jan-2006 grange

knf


# 1.8 05-Jan-2006 grange

Add my copyright.


# 1.7 05-Jan-2006 grange

Add SMBus host interface support for amdpm(4).

ok deraadt@


# 1.6 02-Jan-2006 brad

use pci_matchbyid.


Revision tags: OPENBSD_3_7_BASE OPENBSD_3_8_BASE
# 1.5 17-Sep-2004 grange

Some cleanup:
- don't mix unsigned and u_int across the code
- un'static some funcs

ok art@


Revision tags: OPENBSD_3_6_BASE
# 1.4 28-Jul-2004 tholo

This touches only MI code, and adds new time keeping code. The
code is all conditionalized on __HAVE_TIMECOUNTER, and not
enabled on any platforms.

adjtime(2) support exists, courtesy of nordin@, sysctl(2) support
and a concept of quality for each time source attached exists.

High quality time sources exists for PIIX4 ACPI timer as well as
some AMD power management chips. This will have to be redone
once we actually add ACPI support (at that time we need to use
the ACPI interfaces to get at these clocks).

ok art@ ken@ miod@ jmc@ and many more


Revision tags: OPENBSD_3_3_BASE OPENBSD_3_4_BASE OPENBSD_3_5_BASE SMP_SYNC_A SMP_SYNC_B UBC_SYNC_A
# 1.3 04-Nov-2002 fgsch

make this compile; reported by pluf, mickey ok.


Revision tags: OPENBSD_3_2_BASE UBC_SYNC_B
# 1.2 05-Jun-2002 mickey

branches: 1.2.2;
steal'' performance calculating loop from pchb.c and have a uniform output


# 1.1 05-Jun-2002 mickey

a driver for the rng on the amd768 power management device (no actual power management capabilities are supported yet; from netbsd


# 1.36 06-Jul-2020 pirofti

Add support for timeconting in userland.

This diff exposes parts of clock_gettime(2) and gettimeofday(2) to
userland via libc eliberating processes from the need for a context
switch everytime they want to count the passage of time.

If a timecounter clock can be exposed to userland than it needs to set
its tc_user member to a non-zero value. Tested with one or multiple
counters per architecture.

The timing data is shared through a pointer found in the new ELF
auxiliary vector AUX_openbsd_timekeep containing timehands information
that is frequently updated by the kernel.

Timing differences between the last kernel update and the current time
are adjusted in userland by the tc_get_timecount() function inside the
MD usertc.c file.

This permits a much more responsive environment, quite visible in
browsers, office programs and gaming (apparently one is are able to fly
in Minecraft now).

Tested by robert@, sthen@, naddy@, kmos@, phessler@, and many others!

OK from at least kettenis@, cheloha@, naddy@, sthen@


# 1.35 29-May-2020 deraadt

dev/rndvar.h no longer has statistical interfaces (removed during various
conversion steps). it only contains kernel prototypes for 4 interfaces,
all of which legitimately belong in sys/systm.h, which are already included
by all enqueue_randomness() users.


Revision tags: OPENBSD_6_7_BASE
# 1.34 09-Jan-2020 mpi

Convert sleeps of 1sec or more to tsleep_nsec(9).

ok bluhm@


Revision tags: OPENBSD_6_4_BASE OPENBSD_6_5_BASE OPENBSD_6_6_BASE
# 1.33 28-Apr-2018 jasper

replace add_*_randomness with enqueue_randomness()

this gets rid of the source annotation which doesn't really add
anything other than adding complexitiy. randomess is generally
good enough that the few extra bits that the source type would
add are not worth it.

ok mikeb@ deraadt@


Revision tags: OPENBSD_5_5_BASE OPENBSD_5_6_BASE OPENBSD_5_7_BASE OPENBSD_5_8_BASE OPENBSD_5_9_BASE OPENBSD_6_0_BASE OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE
# 1.32 06-Dec-2013 deraadt

Add a DVACT_WAKEUP op to the *_activate() API. This is called after the
kernel resumes normal (non-cold, able to run processes, etc) operation.
Previously we were relying on specific DVACT_RESUME op's in drivers
creating callback/threads themselves, but that has become too common,
indicating the need for a built-in mechanism.
ok dlg kettenis, tested by a sufficient amount of people


# 1.31 01-Oct-2013 sf

Use %z* for size_t

while there, fix a few %d into %u


Revision tags: OPENBSD_5_4_BASE
# 1.30 03-Jul-2013 sf

fix: cast void * to char *, fix format args for (u)int64_t,
tc_frequency is unsigned

ok kettenis@


# 1.29 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.28 05-Oct-2012 haesbaert

Avoid uninitiliazed use of ctl and corresponding warnings.
Part of the work to remove -Wno-uninitialized.

ok kettenis@


# 1.27 16-Aug-2012 tedu

we are past the point where timecounters may disappear
ok miod


Revision tags: OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE
# 1.26 09-Apr-2011 deraadt

use unique wait channels


Revision tags: OPENBSD_4_8_BASE OPENBSD_4_9_BASE
# 1.25 08-Aug-2010 deraadt

at resume time, re-nable the AMDPM_RNGEN bit


# 1.24 08-Apr-2010 tedu

these files don't need to include proc.h anymore. ok oga for agp


Revision tags: OPENBSD_4_4_BASE OPENBSD_4_5_BASE OPENBSD_4_6_BASE OPENBSD_4_7_BASE
# 1.23 26-Jun-2008 ray

First pass at removing clauses 3 and 4 from NetBSD licenses.

Not sure what's more surprising: how long it took for NetBSD to
catch up to the rest of the BSDs (including UCB), or the amount of
code that NetBSD has claimed for itself without attributing to the
actual authors.

OK deraadt@


# 1.22 06-May-2008 markus

AMD_8111_PMC has timecounter, too; ok grange@ some time ago


Revision tags: OPENBSD_4_2_BASE OPENBSD_4_3_BASE
# 1.21 03-May-2007 dlg

convert lockmgr style locks to rwlocks.

input from art@


Revision tags: OPENBSD_4_1_BASE
# 1.20 11-Dec-2006 deraadt

do not bus_space_map devices which are at address 0; ok kettenis


# 1.19 28-Nov-2006 kettenis

acpi may steal power management functionality, in which case we
cannot io map the device. Bail out without warning. If we want
to retain the rgn we could re-enable io and be very very careful.

ok deraadt@


# 1.18 28-Sep-2006 grange

Provide more info in error messages so we can see what's going
on. And some cosmetics in debug messages while here.


Revision tags: OPENBSD_4_0_BASE
# 1.17 09-Mar-2006 dlg

unbreak the tree. i dunno how this compiled on my box at home.

found by marco@


# 1.16 08-Mar-2006 dlg

amdpmreg.h is only used by amdpm.c, so merge the header into the c file.
this unclutters the tree a bit.

ok deraadt@


# 1.15 08-Mar-2006 dlg

tweak the debug macros a bit


# 1.14 08-Mar-2006 dlg

fix support for the smbus controller on nforce 1 chipsets. only try to
use the timer and rng on amd chips.

diff, testing, and patience from gwk


# 1.13 07-Mar-2006 dlg

whitespace fixes


Revision tags: OPENBSD_3_9_BASE
# 1.12 15-Jan-2006 grange

In iic_exec don't fail immediately if bus is already busy. It might be
running a BIOS' transfer so wait a bit and try again.


# 1.11 09-Jan-2006 deraadt

with an offset tweak, this can also support the nvidia nforce smbus
same unit is found on amd756 and amd8111. try to support the RNG as
well. from gklok@cogeco.ca


# 1.10 06-Jan-2006 brad

remove NetBSD's event counter code.

ok grange@


# 1.9 05-Jan-2006 grange

knf


# 1.8 05-Jan-2006 grange

Add my copyright.


# 1.7 05-Jan-2006 grange

Add SMBus host interface support for amdpm(4).

ok deraadt@


# 1.6 02-Jan-2006 brad

use pci_matchbyid.


Revision tags: OPENBSD_3_7_BASE OPENBSD_3_8_BASE
# 1.5 17-Sep-2004 grange

Some cleanup:
- don't mix unsigned and u_int across the code
- un'static some funcs

ok art@


Revision tags: OPENBSD_3_6_BASE
# 1.4 28-Jul-2004 tholo

This touches only MI code, and adds new time keeping code. The
code is all conditionalized on __HAVE_TIMECOUNTER, and not
enabled on any platforms.

adjtime(2) support exists, courtesy of nordin@, sysctl(2) support
and a concept of quality for each time source attached exists.

High quality time sources exists for PIIX4 ACPI timer as well as
some AMD power management chips. This will have to be redone
once we actually add ACPI support (at that time we need to use
the ACPI interfaces to get at these clocks).

ok art@ ken@ miod@ jmc@ and many more


Revision tags: OPENBSD_3_3_BASE OPENBSD_3_4_BASE OPENBSD_3_5_BASE SMP_SYNC_A SMP_SYNC_B UBC_SYNC_A
# 1.3 04-Nov-2002 fgsch

make this compile; reported by pluf, mickey ok.


Revision tags: OPENBSD_3_2_BASE UBC_SYNC_B
# 1.2 05-Jun-2002 mickey

branches: 1.2.2;
steal'' performance calculating loop from pchb.c and have a uniform output


# 1.1 05-Jun-2002 mickey

a driver for the rng on the amd768 power management device (no actual power management capabilities are supported yet; from netbsd


# 1.35 29-May-2020 deraadt

dev/rndvar.h no longer has statistical interfaces (removed during various
conversion steps). it only contains kernel prototypes for 4 interfaces,
all of which legitimately belong in sys/systm.h, which are already included
by all enqueue_randomness() users.


Revision tags: OPENBSD_6_7_BASE
# 1.34 09-Jan-2020 mpi

Convert sleeps of 1sec or more to tsleep_nsec(9).

ok bluhm@


Revision tags: OPENBSD_6_4_BASE OPENBSD_6_5_BASE OPENBSD_6_6_BASE
# 1.33 28-Apr-2018 jasper

replace add_*_randomness with enqueue_randomness()

this gets rid of the source annotation which doesn't really add
anything other than adding complexitiy. randomess is generally
good enough that the few extra bits that the source type would
add are not worth it.

ok mikeb@ deraadt@


Revision tags: OPENBSD_5_5_BASE OPENBSD_5_6_BASE OPENBSD_5_7_BASE OPENBSD_5_8_BASE OPENBSD_5_9_BASE OPENBSD_6_0_BASE OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE
# 1.32 06-Dec-2013 deraadt

Add a DVACT_WAKEUP op to the *_activate() API. This is called after the
kernel resumes normal (non-cold, able to run processes, etc) operation.
Previously we were relying on specific DVACT_RESUME op's in drivers
creating callback/threads themselves, but that has become too common,
indicating the need for a built-in mechanism.
ok dlg kettenis, tested by a sufficient amount of people


# 1.31 01-Oct-2013 sf

Use %z* for size_t

while there, fix a few %d into %u


Revision tags: OPENBSD_5_4_BASE
# 1.30 03-Jul-2013 sf

fix: cast void * to char *, fix format args for (u)int64_t,
tc_frequency is unsigned

ok kettenis@


# 1.29 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.28 05-Oct-2012 haesbaert

Avoid uninitiliazed use of ctl and corresponding warnings.
Part of the work to remove -Wno-uninitialized.

ok kettenis@


# 1.27 16-Aug-2012 tedu

we are past the point where timecounters may disappear
ok miod


Revision tags: OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE
# 1.26 09-Apr-2011 deraadt

use unique wait channels


Revision tags: OPENBSD_4_8_BASE OPENBSD_4_9_BASE
# 1.25 08-Aug-2010 deraadt

at resume time, re-nable the AMDPM_RNGEN bit


# 1.24 08-Apr-2010 tedu

these files don't need to include proc.h anymore. ok oga for agp


Revision tags: OPENBSD_4_4_BASE OPENBSD_4_5_BASE OPENBSD_4_6_BASE OPENBSD_4_7_BASE
# 1.23 26-Jun-2008 ray

First pass at removing clauses 3 and 4 from NetBSD licenses.

Not sure what's more surprising: how long it took for NetBSD to
catch up to the rest of the BSDs (including UCB), or the amount of
code that NetBSD has claimed for itself without attributing to the
actual authors.

OK deraadt@


# 1.22 06-May-2008 markus

AMD_8111_PMC has timecounter, too; ok grange@ some time ago


Revision tags: OPENBSD_4_2_BASE OPENBSD_4_3_BASE
# 1.21 03-May-2007 dlg

convert lockmgr style locks to rwlocks.

input from art@


Revision tags: OPENBSD_4_1_BASE
# 1.20 11-Dec-2006 deraadt

do not bus_space_map devices which are at address 0; ok kettenis


# 1.19 28-Nov-2006 kettenis

acpi may steal power management functionality, in which case we
cannot io map the device. Bail out without warning. If we want
to retain the rgn we could re-enable io and be very very careful.

ok deraadt@


# 1.18 28-Sep-2006 grange

Provide more info in error messages so we can see what's going
on. And some cosmetics in debug messages while here.


Revision tags: OPENBSD_4_0_BASE
# 1.17 09-Mar-2006 dlg

unbreak the tree. i dunno how this compiled on my box at home.

found by marco@


# 1.16 08-Mar-2006 dlg

amdpmreg.h is only used by amdpm.c, so merge the header into the c file.
this unclutters the tree a bit.

ok deraadt@


# 1.15 08-Mar-2006 dlg

tweak the debug macros a bit


# 1.14 08-Mar-2006 dlg

fix support for the smbus controller on nforce 1 chipsets. only try to
use the timer and rng on amd chips.

diff, testing, and patience from gwk


# 1.13 07-Mar-2006 dlg

whitespace fixes


Revision tags: OPENBSD_3_9_BASE
# 1.12 15-Jan-2006 grange

In iic_exec don't fail immediately if bus is already busy. It might be
running a BIOS' transfer so wait a bit and try again.


# 1.11 09-Jan-2006 deraadt

with an offset tweak, this can also support the nvidia nforce smbus
same unit is found on amd756 and amd8111. try to support the RNG as
well. from gklok@cogeco.ca


# 1.10 06-Jan-2006 brad

remove NetBSD's event counter code.

ok grange@


# 1.9 05-Jan-2006 grange

knf


# 1.8 05-Jan-2006 grange

Add my copyright.


# 1.7 05-Jan-2006 grange

Add SMBus host interface support for amdpm(4).

ok deraadt@


# 1.6 02-Jan-2006 brad

use pci_matchbyid.


Revision tags: OPENBSD_3_7_BASE OPENBSD_3_8_BASE
# 1.5 17-Sep-2004 grange

Some cleanup:
- don't mix unsigned and u_int across the code
- un'static some funcs

ok art@


Revision tags: OPENBSD_3_6_BASE
# 1.4 28-Jul-2004 tholo

This touches only MI code, and adds new time keeping code. The
code is all conditionalized on __HAVE_TIMECOUNTER, and not
enabled on any platforms.

adjtime(2) support exists, courtesy of nordin@, sysctl(2) support
and a concept of quality for each time source attached exists.

High quality time sources exists for PIIX4 ACPI timer as well as
some AMD power management chips. This will have to be redone
once we actually add ACPI support (at that time we need to use
the ACPI interfaces to get at these clocks).

ok art@ ken@ miod@ jmc@ and many more


Revision tags: OPENBSD_3_3_BASE OPENBSD_3_4_BASE OPENBSD_3_5_BASE SMP_SYNC_A SMP_SYNC_B UBC_SYNC_A
# 1.3 04-Nov-2002 fgsch

make this compile; reported by pluf, mickey ok.


Revision tags: OPENBSD_3_2_BASE UBC_SYNC_B
# 1.2 05-Jun-2002 mickey

branches: 1.2.2;
steal'' performance calculating loop from pchb.c and have a uniform output


# 1.1 05-Jun-2002 mickey

a driver for the rng on the amd768 power management device (no actual power management capabilities are supported yet; from netbsd


# 1.34 09-Jan-2020 mpi

Convert sleeps of 1sec or more to tsleep_nsec(9).

ok bluhm@


Revision tags: OPENBSD_6_4_BASE OPENBSD_6_5_BASE OPENBSD_6_6_BASE
# 1.33 28-Apr-2018 jasper

replace add_*_randomness with enqueue_randomness()

this gets rid of the source annotation which doesn't really add
anything other than adding complexitiy. randomess is generally
good enough that the few extra bits that the source type would
add are not worth it.

ok mikeb@ deraadt@


Revision tags: OPENBSD_5_5_BASE OPENBSD_5_6_BASE OPENBSD_5_7_BASE OPENBSD_5_8_BASE OPENBSD_5_9_BASE OPENBSD_6_0_BASE OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE
# 1.32 06-Dec-2013 deraadt

Add a DVACT_WAKEUP op to the *_activate() API. This is called after the
kernel resumes normal (non-cold, able to run processes, etc) operation.
Previously we were relying on specific DVACT_RESUME op's in drivers
creating callback/threads themselves, but that has become too common,
indicating the need for a built-in mechanism.
ok dlg kettenis, tested by a sufficient amount of people


# 1.31 01-Oct-2013 sf

Use %z* for size_t

while there, fix a few %d into %u


Revision tags: OPENBSD_5_4_BASE
# 1.30 03-Jul-2013 sf

fix: cast void * to char *, fix format args for (u)int64_t,
tc_frequency is unsigned

ok kettenis@


# 1.29 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.28 05-Oct-2012 haesbaert

Avoid uninitiliazed use of ctl and corresponding warnings.
Part of the work to remove -Wno-uninitialized.

ok kettenis@


# 1.27 16-Aug-2012 tedu

we are past the point where timecounters may disappear
ok miod


Revision tags: OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE
# 1.26 09-Apr-2011 deraadt

use unique wait channels


Revision tags: OPENBSD_4_8_BASE OPENBSD_4_9_BASE
# 1.25 08-Aug-2010 deraadt

at resume time, re-nable the AMDPM_RNGEN bit


# 1.24 08-Apr-2010 tedu

these files don't need to include proc.h anymore. ok oga for agp


Revision tags: OPENBSD_4_4_BASE OPENBSD_4_5_BASE OPENBSD_4_6_BASE OPENBSD_4_7_BASE
# 1.23 26-Jun-2008 ray

First pass at removing clauses 3 and 4 from NetBSD licenses.

Not sure what's more surprising: how long it took for NetBSD to
catch up to the rest of the BSDs (including UCB), or the amount of
code that NetBSD has claimed for itself without attributing to the
actual authors.

OK deraadt@


# 1.22 06-May-2008 markus

AMD_8111_PMC has timecounter, too; ok grange@ some time ago


Revision tags: OPENBSD_4_2_BASE OPENBSD_4_3_BASE
# 1.21 03-May-2007 dlg

convert lockmgr style locks to rwlocks.

input from art@


Revision tags: OPENBSD_4_1_BASE
# 1.20 11-Dec-2006 deraadt

do not bus_space_map devices which are at address 0; ok kettenis


# 1.19 28-Nov-2006 kettenis

acpi may steal power management functionality, in which case we
cannot io map the device. Bail out without warning. If we want
to retain the rgn we could re-enable io and be very very careful.

ok deraadt@


# 1.18 28-Sep-2006 grange

Provide more info in error messages so we can see what's going
on. And some cosmetics in debug messages while here.


Revision tags: OPENBSD_4_0_BASE
# 1.17 09-Mar-2006 dlg

unbreak the tree. i dunno how this compiled on my box at home.

found by marco@


# 1.16 08-Mar-2006 dlg

amdpmreg.h is only used by amdpm.c, so merge the header into the c file.
this unclutters the tree a bit.

ok deraadt@


# 1.15 08-Mar-2006 dlg

tweak the debug macros a bit


# 1.14 08-Mar-2006 dlg

fix support for the smbus controller on nforce 1 chipsets. only try to
use the timer and rng on amd chips.

diff, testing, and patience from gwk


# 1.13 07-Mar-2006 dlg

whitespace fixes


Revision tags: OPENBSD_3_9_BASE
# 1.12 15-Jan-2006 grange

In iic_exec don't fail immediately if bus is already busy. It might be
running a BIOS' transfer so wait a bit and try again.


# 1.11 09-Jan-2006 deraadt

with an offset tweak, this can also support the nvidia nforce smbus
same unit is found on amd756 and amd8111. try to support the RNG as
well. from gklok@cogeco.ca


# 1.10 06-Jan-2006 brad

remove NetBSD's event counter code.

ok grange@


# 1.9 05-Jan-2006 grange

knf


# 1.8 05-Jan-2006 grange

Add my copyright.


# 1.7 05-Jan-2006 grange

Add SMBus host interface support for amdpm(4).

ok deraadt@


# 1.6 02-Jan-2006 brad

use pci_matchbyid.


Revision tags: OPENBSD_3_7_BASE OPENBSD_3_8_BASE
# 1.5 17-Sep-2004 grange

Some cleanup:
- don't mix unsigned and u_int across the code
- un'static some funcs

ok art@


Revision tags: OPENBSD_3_6_BASE
# 1.4 28-Jul-2004 tholo

This touches only MI code, and adds new time keeping code. The
code is all conditionalized on __HAVE_TIMECOUNTER, and not
enabled on any platforms.

adjtime(2) support exists, courtesy of nordin@, sysctl(2) support
and a concept of quality for each time source attached exists.

High quality time sources exists for PIIX4 ACPI timer as well as
some AMD power management chips. This will have to be redone
once we actually add ACPI support (at that time we need to use
the ACPI interfaces to get at these clocks).

ok art@ ken@ miod@ jmc@ and many more


Revision tags: OPENBSD_3_3_BASE OPENBSD_3_4_BASE OPENBSD_3_5_BASE SMP_SYNC_A SMP_SYNC_B UBC_SYNC_A
# 1.3 04-Nov-2002 fgsch

make this compile; reported by pluf, mickey ok.


Revision tags: OPENBSD_3_2_BASE UBC_SYNC_B
# 1.2 05-Jun-2002 mickey

branches: 1.2.2;
steal'' performance calculating loop from pchb.c and have a uniform output


# 1.1 05-Jun-2002 mickey

a driver for the rng on the amd768 power management device (no actual power management capabilities are supported yet; from netbsd


# 1.33 28-Apr-2018 jasper

replace add_*_randomness with enqueue_randomness()

this gets rid of the source annotation which doesn't really add
anything other than adding complexitiy. randomess is generally
good enough that the few extra bits that the source type would
add are not worth it.

ok mikeb@ deraadt@


Revision tags: OPENBSD_5_5_BASE OPENBSD_5_6_BASE OPENBSD_5_7_BASE OPENBSD_5_8_BASE OPENBSD_5_9_BASE OPENBSD_6_0_BASE OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE
# 1.32 06-Dec-2013 deraadt

Add a DVACT_WAKEUP op to the *_activate() API. This is called after the
kernel resumes normal (non-cold, able to run processes, etc) operation.
Previously we were relying on specific DVACT_RESUME op's in drivers
creating callback/threads themselves, but that has become too common,
indicating the need for a built-in mechanism.
ok dlg kettenis, tested by a sufficient amount of people


# 1.31 01-Oct-2013 sf

Use %z* for size_t

while there, fix a few %d into %u


Revision tags: OPENBSD_5_4_BASE
# 1.30 03-Jul-2013 sf

fix: cast void * to char *, fix format args for (u)int64_t,
tc_frequency is unsigned

ok kettenis@


# 1.29 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.28 05-Oct-2012 haesbaert

Avoid uninitiliazed use of ctl and corresponding warnings.
Part of the work to remove -Wno-uninitialized.

ok kettenis@


# 1.27 16-Aug-2012 tedu

we are past the point where timecounters may disappear
ok miod


Revision tags: OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE
# 1.26 09-Apr-2011 deraadt

use unique wait channels


Revision tags: OPENBSD_4_8_BASE OPENBSD_4_9_BASE
# 1.25 08-Aug-2010 deraadt

at resume time, re-nable the AMDPM_RNGEN bit


# 1.24 08-Apr-2010 tedu

these files don't need to include proc.h anymore. ok oga for agp


Revision tags: OPENBSD_4_4_BASE OPENBSD_4_5_BASE OPENBSD_4_6_BASE OPENBSD_4_7_BASE
# 1.23 26-Jun-2008 ray

First pass at removing clauses 3 and 4 from NetBSD licenses.

Not sure what's more surprising: how long it took for NetBSD to
catch up to the rest of the BSDs (including UCB), or the amount of
code that NetBSD has claimed for itself without attributing to the
actual authors.

OK deraadt@


# 1.22 06-May-2008 markus

AMD_8111_PMC has timecounter, too; ok grange@ some time ago


Revision tags: OPENBSD_4_2_BASE OPENBSD_4_3_BASE
# 1.21 03-May-2007 dlg

convert lockmgr style locks to rwlocks.

input from art@


Revision tags: OPENBSD_4_1_BASE
# 1.20 11-Dec-2006 deraadt

do not bus_space_map devices which are at address 0; ok kettenis


# 1.19 28-Nov-2006 kettenis

acpi may steal power management functionality, in which case we
cannot io map the device. Bail out without warning. If we want
to retain the rgn we could re-enable io and be very very careful.

ok deraadt@


# 1.18 28-Sep-2006 grange

Provide more info in error messages so we can see what's going
on. And some cosmetics in debug messages while here.


Revision tags: OPENBSD_4_0_BASE
# 1.17 09-Mar-2006 dlg

unbreak the tree. i dunno how this compiled on my box at home.

found by marco@


# 1.16 08-Mar-2006 dlg

amdpmreg.h is only used by amdpm.c, so merge the header into the c file.
this unclutters the tree a bit.

ok deraadt@


# 1.15 08-Mar-2006 dlg

tweak the debug macros a bit


# 1.14 08-Mar-2006 dlg

fix support for the smbus controller on nforce 1 chipsets. only try to
use the timer and rng on amd chips.

diff, testing, and patience from gwk


# 1.13 07-Mar-2006 dlg

whitespace fixes


Revision tags: OPENBSD_3_9_BASE
# 1.12 15-Jan-2006 grange

In iic_exec don't fail immediately if bus is already busy. It might be
running a BIOS' transfer so wait a bit and try again.


# 1.11 09-Jan-2006 deraadt

with an offset tweak, this can also support the nvidia nforce smbus
same unit is found on amd756 and amd8111. try to support the RNG as
well. from gklok@cogeco.ca


# 1.10 06-Jan-2006 brad

remove NetBSD's event counter code.

ok grange@


# 1.9 05-Jan-2006 grange

knf


# 1.8 05-Jan-2006 grange

Add my copyright.


# 1.7 05-Jan-2006 grange

Add SMBus host interface support for amdpm(4).

ok deraadt@


# 1.6 02-Jan-2006 brad

use pci_matchbyid.


Revision tags: OPENBSD_3_7_BASE OPENBSD_3_8_BASE
# 1.5 17-Sep-2004 grange

Some cleanup:
- don't mix unsigned and u_int across the code
- un'static some funcs

ok art@


Revision tags: OPENBSD_3_6_BASE
# 1.4 28-Jul-2004 tholo

This touches only MI code, and adds new time keeping code. The
code is all conditionalized on __HAVE_TIMECOUNTER, and not
enabled on any platforms.

adjtime(2) support exists, courtesy of nordin@, sysctl(2) support
and a concept of quality for each time source attached exists.

High quality time sources exists for PIIX4 ACPI timer as well as
some AMD power management chips. This will have to be redone
once we actually add ACPI support (at that time we need to use
the ACPI interfaces to get at these clocks).

ok art@ ken@ miod@ jmc@ and many more


Revision tags: OPENBSD_3_3_BASE OPENBSD_3_4_BASE OPENBSD_3_5_BASE SMP_SYNC_A SMP_SYNC_B UBC_SYNC_A
# 1.3 04-Nov-2002 fgsch

make this compile; reported by pluf, mickey ok.


Revision tags: OPENBSD_3_2_BASE UBC_SYNC_B
# 1.2 05-Jun-2002 mickey

branches: 1.2.2;
steal'' performance calculating loop from pchb.c and have a uniform output


# 1.1 05-Jun-2002 mickey

a driver for the rng on the amd768 power management device (no actual power management capabilities are supported yet; from netbsd


Revision tags: OPENBSD_5_5_BASE OPENBSD_5_6_BASE OPENBSD_5_7_BASE OPENBSD_5_8_BASE OPENBSD_5_9_BASE OPENBSD_6_0_BASE OPENBSD_6_1_BASE OPENBSD_6_2_BASE
# 1.32 06-Dec-2013 deraadt

Add a DVACT_WAKEUP op to the *_activate() API. This is called after the
kernel resumes normal (non-cold, able to run processes, etc) operation.
Previously we were relying on specific DVACT_RESUME op's in drivers
creating callback/threads themselves, but that has become too common,
indicating the need for a built-in mechanism.
ok dlg kettenis, tested by a sufficient amount of people


# 1.31 01-Oct-2013 sf

Use %z* for size_t

while there, fix a few %d into %u


Revision tags: OPENBSD_5_4_BASE
# 1.30 03-Jul-2013 sf

fix: cast void * to char *, fix format args for (u)int64_t,
tc_frequency is unsigned

ok kettenis@


# 1.29 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.28 05-Oct-2012 haesbaert

Avoid uninitiliazed use of ctl and corresponding warnings.
Part of the work to remove -Wno-uninitialized.

ok kettenis@


# 1.27 16-Aug-2012 tedu

we are past the point where timecounters may disappear
ok miod


Revision tags: OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE
# 1.26 09-Apr-2011 deraadt

use unique wait channels


Revision tags: OPENBSD_4_8_BASE OPENBSD_4_9_BASE
# 1.25 08-Aug-2010 deraadt

at resume time, re-nable the AMDPM_RNGEN bit


# 1.24 08-Apr-2010 tedu

these files don't need to include proc.h anymore. ok oga for agp


Revision tags: OPENBSD_4_4_BASE OPENBSD_4_5_BASE OPENBSD_4_6_BASE OPENBSD_4_7_BASE
# 1.23 26-Jun-2008 ray

First pass at removing clauses 3 and 4 from NetBSD licenses.

Not sure what's more surprising: how long it took for NetBSD to
catch up to the rest of the BSDs (including UCB), or the amount of
code that NetBSD has claimed for itself without attributing to the
actual authors.

OK deraadt@


# 1.22 06-May-2008 markus

AMD_8111_PMC has timecounter, too; ok grange@ some time ago


Revision tags: OPENBSD_4_2_BASE OPENBSD_4_3_BASE
# 1.21 03-May-2007 dlg

convert lockmgr style locks to rwlocks.

input from art@


Revision tags: OPENBSD_4_1_BASE
# 1.20 11-Dec-2006 deraadt

do not bus_space_map devices which are at address 0; ok kettenis


# 1.19 28-Nov-2006 kettenis

acpi may steal power management functionality, in which case we
cannot io map the device. Bail out without warning. If we want
to retain the rgn we could re-enable io and be very very careful.

ok deraadt@


# 1.18 28-Sep-2006 grange

Provide more info in error messages so we can see what's going
on. And some cosmetics in debug messages while here.


Revision tags: OPENBSD_4_0_BASE
# 1.17 09-Mar-2006 dlg

unbreak the tree. i dunno how this compiled on my box at home.

found by marco@


# 1.16 08-Mar-2006 dlg

amdpmreg.h is only used by amdpm.c, so merge the header into the c file.
this unclutters the tree a bit.

ok deraadt@


# 1.15 08-Mar-2006 dlg

tweak the debug macros a bit


# 1.14 08-Mar-2006 dlg

fix support for the smbus controller on nforce 1 chipsets. only try to
use the timer and rng on amd chips.

diff, testing, and patience from gwk


# 1.13 07-Mar-2006 dlg

whitespace fixes


Revision tags: OPENBSD_3_9_BASE
# 1.12 15-Jan-2006 grange

In iic_exec don't fail immediately if bus is already busy. It might be
running a BIOS' transfer so wait a bit and try again.


# 1.11 09-Jan-2006 deraadt

with an offset tweak, this can also support the nvidia nforce smbus
same unit is found on amd756 and amd8111. try to support the RNG as
well. from gklok@cogeco.ca


# 1.10 06-Jan-2006 brad

remove NetBSD's event counter code.

ok grange@


# 1.9 05-Jan-2006 grange

knf


# 1.8 05-Jan-2006 grange

Add my copyright.


# 1.7 05-Jan-2006 grange

Add SMBus host interface support for amdpm(4).

ok deraadt@


# 1.6 02-Jan-2006 brad

use pci_matchbyid.


Revision tags: OPENBSD_3_7_BASE OPENBSD_3_8_BASE
# 1.5 17-Sep-2004 grange

Some cleanup:
- don't mix unsigned and u_int across the code
- un'static some funcs

ok art@


Revision tags: OPENBSD_3_6_BASE
# 1.4 28-Jul-2004 tholo

This touches only MI code, and adds new time keeping code. The
code is all conditionalized on __HAVE_TIMECOUNTER, and not
enabled on any platforms.

adjtime(2) support exists, courtesy of nordin@, sysctl(2) support
and a concept of quality for each time source attached exists.

High quality time sources exists for PIIX4 ACPI timer as well as
some AMD power management chips. This will have to be redone
once we actually add ACPI support (at that time we need to use
the ACPI interfaces to get at these clocks).

ok art@ ken@ miod@ jmc@ and many more


Revision tags: OPENBSD_3_3_BASE OPENBSD_3_4_BASE OPENBSD_3_5_BASE SMP_SYNC_A SMP_SYNC_B UBC_SYNC_A
# 1.3 04-Nov-2002 fgsch

make this compile; reported by pluf, mickey ok.


Revision tags: OPENBSD_3_2_BASE UBC_SYNC_B
# 1.2 05-Jun-2002 mickey

branches: 1.2.2;
steal'' performance calculating loop from pchb.c and have a uniform output


# 1.1 05-Jun-2002 mickey

a driver for the rng on the amd768 power management device (no actual power management capabilities are supported yet; from netbsd