History log of /freebsd-11-stable/sys/i386/bios/apm.c
Revision Date Author Comments
(<<< Hide modified files)
(Show modified files >>>)
# 359652 06-Apr-2020 hselasky

MFC r333806:
Use NULL for SYSINIT's last arg, which is a pointer type

Sponsored by: The FreeBSD Foundation


# 302408 07-Jul-2016 gjb

Copy head@r302406 to stable/11 as part of the 11.0-RELEASE cycle.
Prune svn:mergeinfo from the new branch, as nothing has been merged
here.

Additional commits post-branch will follow.

Approved by: re (implicit)
Sponsored by: The FreeBSD Foundation


/freebsd-11-stable/MAINTAINERS
/freebsd-11-stable/cddl
/freebsd-11-stable/cddl/contrib/opensolaris
/freebsd-11-stable/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/print
/freebsd-11-stable/cddl/contrib/opensolaris/cmd/zfs
/freebsd-11-stable/cddl/contrib/opensolaris/lib/libzfs
/freebsd-11-stable/contrib/amd
/freebsd-11-stable/contrib/apr
/freebsd-11-stable/contrib/apr-util
/freebsd-11-stable/contrib/atf
/freebsd-11-stable/contrib/binutils
/freebsd-11-stable/contrib/bmake
/freebsd-11-stable/contrib/byacc
/freebsd-11-stable/contrib/bzip2
/freebsd-11-stable/contrib/com_err
/freebsd-11-stable/contrib/compiler-rt
/freebsd-11-stable/contrib/dialog
/freebsd-11-stable/contrib/dma
/freebsd-11-stable/contrib/dtc
/freebsd-11-stable/contrib/ee
/freebsd-11-stable/contrib/elftoolchain
/freebsd-11-stable/contrib/elftoolchain/ar
/freebsd-11-stable/contrib/elftoolchain/brandelf
/freebsd-11-stable/contrib/elftoolchain/elfdump
/freebsd-11-stable/contrib/expat
/freebsd-11-stable/contrib/file
/freebsd-11-stable/contrib/gcc
/freebsd-11-stable/contrib/gcclibs/libgomp
/freebsd-11-stable/contrib/gdb
/freebsd-11-stable/contrib/gdtoa
/freebsd-11-stable/contrib/groff
/freebsd-11-stable/contrib/ipfilter
/freebsd-11-stable/contrib/ldns
/freebsd-11-stable/contrib/ldns-host
/freebsd-11-stable/contrib/less
/freebsd-11-stable/contrib/libarchive
/freebsd-11-stable/contrib/libarchive/cpio
/freebsd-11-stable/contrib/libarchive/libarchive
/freebsd-11-stable/contrib/libarchive/libarchive_fe
/freebsd-11-stable/contrib/libarchive/tar
/freebsd-11-stable/contrib/libc++
/freebsd-11-stable/contrib/libc-vis
/freebsd-11-stable/contrib/libcxxrt
/freebsd-11-stable/contrib/libexecinfo
/freebsd-11-stable/contrib/libpcap
/freebsd-11-stable/contrib/libstdc++
/freebsd-11-stable/contrib/libucl
/freebsd-11-stable/contrib/libxo
/freebsd-11-stable/contrib/llvm
/freebsd-11-stable/contrib/llvm/projects/libunwind
/freebsd-11-stable/contrib/llvm/tools/clang
/freebsd-11-stable/contrib/llvm/tools/lldb
/freebsd-11-stable/contrib/llvm/tools/llvm-dwarfdump
/freebsd-11-stable/contrib/llvm/tools/llvm-lto
/freebsd-11-stable/contrib/mdocml
/freebsd-11-stable/contrib/mtree
/freebsd-11-stable/contrib/ncurses
/freebsd-11-stable/contrib/netcat
/freebsd-11-stable/contrib/ntp
/freebsd-11-stable/contrib/nvi
/freebsd-11-stable/contrib/one-true-awk
/freebsd-11-stable/contrib/openbsm
/freebsd-11-stable/contrib/openpam
/freebsd-11-stable/contrib/openresolv
/freebsd-11-stable/contrib/pf
/freebsd-11-stable/contrib/sendmail
/freebsd-11-stable/contrib/serf
/freebsd-11-stable/contrib/sqlite3
/freebsd-11-stable/contrib/subversion
/freebsd-11-stable/contrib/tcpdump
/freebsd-11-stable/contrib/tcsh
/freebsd-11-stable/contrib/tnftp
/freebsd-11-stable/contrib/top
/freebsd-11-stable/contrib/top/install-sh
/freebsd-11-stable/contrib/tzcode/stdtime
/freebsd-11-stable/contrib/tzcode/zic
/freebsd-11-stable/contrib/tzdata
/freebsd-11-stable/contrib/unbound
/freebsd-11-stable/contrib/vis
/freebsd-11-stable/contrib/wpa
/freebsd-11-stable/contrib/xz
/freebsd-11-stable/crypto/heimdal
/freebsd-11-stable/crypto/openssh
/freebsd-11-stable/crypto/openssl
/freebsd-11-stable/gnu/lib
/freebsd-11-stable/gnu/usr.bin/binutils
/freebsd-11-stable/gnu/usr.bin/cc/cc_tools
/freebsd-11-stable/gnu/usr.bin/gdb
/freebsd-11-stable/lib/libc/locale/ascii.c
/freebsd-11-stable/sys/cddl/contrib/opensolaris
/freebsd-11-stable/sys/contrib/dev/acpica
/freebsd-11-stable/sys/contrib/ipfilter
/freebsd-11-stable/sys/contrib/libfdt
/freebsd-11-stable/sys/contrib/octeon-sdk
/freebsd-11-stable/sys/contrib/x86emu
/freebsd-11-stable/sys/contrib/xz-embedded
/freebsd-11-stable/usr.sbin/bhyve/atkbdc.h
/freebsd-11-stable/usr.sbin/bhyve/bhyvegc.c
/freebsd-11-stable/usr.sbin/bhyve/bhyvegc.h
/freebsd-11-stable/usr.sbin/bhyve/console.c
/freebsd-11-stable/usr.sbin/bhyve/console.h
/freebsd-11-stable/usr.sbin/bhyve/pci_fbuf.c
/freebsd-11-stable/usr.sbin/bhyve/pci_xhci.c
/freebsd-11-stable/usr.sbin/bhyve/pci_xhci.h
/freebsd-11-stable/usr.sbin/bhyve/ps2kbd.c
/freebsd-11-stable/usr.sbin/bhyve/ps2kbd.h
/freebsd-11-stable/usr.sbin/bhyve/ps2mouse.c
/freebsd-11-stable/usr.sbin/bhyve/ps2mouse.h
/freebsd-11-stable/usr.sbin/bhyve/rfb.c
/freebsd-11-stable/usr.sbin/bhyve/rfb.h
/freebsd-11-stable/usr.sbin/bhyve/sockstream.c
/freebsd-11-stable/usr.sbin/bhyve/sockstream.h
/freebsd-11-stable/usr.sbin/bhyve/usb_emul.c
/freebsd-11-stable/usr.sbin/bhyve/usb_emul.h
/freebsd-11-stable/usr.sbin/bhyve/usb_mouse.c
/freebsd-11-stable/usr.sbin/bhyve/vga.c
/freebsd-11-stable/usr.sbin/bhyve/vga.h
# 267992 28-Jun-2014 hselasky

Pull in r267961 and r267973 again. Fix for issues reported will follow.


# 267985 27-Jun-2014 gjb

Revert r267961, r267973:

These changes prevent sysctl(8) from returning proper output,
such as:

1) no output from sysctl(8)
2) erroneously returning ENOMEM with tools like truss(1)
or uname(1)
truss: can not get etype: Cannot allocate memory


# 267961 27-Jun-2014 hselasky

Extend the meaning of the CTLFLAG_TUN flag to automatically check if
there is an environment variable which shall initialize the SYSCTL
during early boot. This works for all SYSCTL types both statically and
dynamically created ones, except for the SYSCTL NODE type and SYSCTLs
which belong to VNETs. A new flag, CTLFLAG_NOFETCH, has been added to
be used in the case a tunable sysctl has a custom initialisation
function allowing the sysctl to still be marked as a tunable. The
kernel SYSCTL API is mostly the same, with a few exceptions for some
special operations like iterating childrens of a static/extern SYSCTL
node. This operation should probably be made into a factored out
common macro, hence some device drivers use this. The reason for
changing the SYSCTL API was the need for a SYSCTL parent OID pointer
and not only the SYSCTL parent OID list pointer in order to quickly
generate the sysctl path. The motivation behind this patch is to avoid
parameter loading cludges inside the OFED driver subsystem. Instead of
adding special code to the OFED driver subsystem to post-load tunables
into dynamically created sysctls, we generalize this in the kernel.

Other changes:
- Corrected a possibly incorrect sysctl name from "hw.cbb.intr_mask"
to "hw.pcic.intr_mask".
- Removed redundant TUNABLE statements throughout the kernel.
- Some minor code rewrites in connection to removing not needed
TUNABLE statements.
- Added a missing SYSCTL_DECL().
- Wrapped two very long lines.
- Avoid malloc()/free() inside sysctl string handling, in case it is
called to initialize a sysctl from a tunable, hence malloc()/free() is
not ready when sysctls from the sysctl dataset are registered.
- Bumped FreeBSD version to indicate SYSCTL API change.

MFC after: 2 weeks
Sponsored by: Mellanox Technologies


# 241885 22-Oct-2012 eadler

This isn't functionally identical. In some cases a hint to disable
unit 0 would in fact disable all units.

This reverts r241856

Approved by: cperciva (implicit)


# 241856 22-Oct-2012 eadler

Now that device disabling is generic, remove extraneous code from the
device drivers that used to provide this feature.

Reviewed by: des
Approved by: cperciva
MFC after: 1 week


# 220844 19-Apr-2011 jkim

Do not invoke resume event handlers if suspend was successful.

Pointy hat to: jkim


# 220839 19-Apr-2011 jkim

Add suspend/resume event handlers for apm(4) as well.


# 215139 11-Nov-2010 jkim

Add compat shim for apm(4) to translate APM BIOS function numbers from i386
to PC98-specific ones. Any binaries using apm ioctl(4) commands but built
for i386 should also work on PC98 now.

Reviewed by: imp, nyan


# 198707 31-Oct-2009 ed

Unobfuscate unit number handling in apm(4).

There is no need to use the lower 4 bits of the unit number to store the
device type number. Just use 0 and 1 to distinguish them. devfs also
guarantees that there can never be an open call on a device that has a
unit number different to 0 and 1, so there is no need to check for this
in open().


# 191781 04-May-2009 mav

Oops, sorry. Fix for fix.


# 191780 04-May-2009 mav

There is no atrtc driver in pc98, so hide atrtcclock_disable variable usage
in APM driver for this platform. This should fix pc98 build.


# 191766 03-May-2009 mav

Rename statclock_disable variable to atrtcclock_disable that it actually is,
and hide it inside of atrtc driver. Add new tunable hint.atrtc.0.clock
controlling it. Setting it to 0 disables using RTC clock as stat-/
profclock sources.

Teach i386 and amd64 SMP platforms to emulate stat-/profclocks using i8254
hardclock, when LAPIC and RTC clocks are disabled.

This allows to reduce global interrupt rate of idle system down to about
100 interrupts per core, permitting C3 and deeper C-states provide maximum
CPU power efficiency.


# 183397 27-Sep-2008 ed

Replace all calls to minor() with dev2unit().

After I removed all the unit2minor()/minor2unit() calls from the kernel
yesterday, I realised calling minor() everywhere is quite confusing.
Character devices now only have the ability to store a unit number, not
a minor number. Remove the confusion by using dev2unit() everywhere.

This commit could also be considered as a bug fix. A lot of drivers call
minor(), while they should actually be calling dev2unit(). In -CURRENT
this isn't a problem, but it turns out we never had any problem reports
related to that issue in the past. I suspect not many people connect
more than 256 pieces of the same hardware.

Reviewed by: kib


# 178429 22-Apr-2008 phk

Now that all platforms use genclock, shuffle things around slightly
for better structure.

Much of this is related to <sys/clock.h>, which should really have
been called <sys/calendar.h>, but unless and until we need the name,
the repocopy can wait.

In general the kernel does not know about minutes, hours, days,
timezones, daylight savings time, leap-years and such. All that
is theoretically a matter for userland only.

Parts of kernel code does however care: badly designed filesystems
store timestamps in local time and RTC chips almost universally
track time in a YY-MM-DD HH:MM:SS format, and sometimes in local
timezone instead of UTC. For this we have <sys/clock.h>

<sys/time.h> on the other hand, deals with time_t, timeval, timespec
and so on. These know only seconds and fractions thereof.

Move inittodr() and resettodr() prototypes to <sys/time.h>.
Retain the names as it is one of the few surviving PDP/VAX references.

Move startrtclock() to <machine/clock.h> on relevant platforms, it
is a MD call between machdep.c/clock.c. Remove references to it
elsewhere.

Remove a lot of unnecessary <sys/clock.h> includes.

Move the machdep.disable_rtc_set sysctl to subr_rtc.c where it belongs.
XXX: should be kern.disable_rtc_set really, it's not MD.


# 174324 05-Dec-2007 njl

Hold Giant over the entire execution of the suspend path instead of
dropping it after each call into newbus. This doesn't fix any known
problems but seems more correct.

Submitted by: Marko Zec <zec / icir.org>


# 173598 14-Nov-2007 julian

Apply the same sort of locking done in
sys/dev/acpica/acpi.c rev 1.196 a while ago:

Grab Giant around calls to DEVICE_SUSPEND/RESUME in
acpi_SetSleepState().
If we are resuming non-MPSAFE drivers, they need Giant held for them.
This may fix some obscure suspend/resume problems. It has fixed keyrate
setting problems that were triggered by cardbus (MPSAFE) changing the
ordering for syscons resume (non-MPSAFE). Also, add some asserts that
Giant is held in our suspend/resume and shutdown methods.

Submitted by: Marko Zec


# 172836 20-Oct-2007 julian

Rename the kthread_xxx (e.g. kthread_create()) calls
to kproc_xxx as they actually make whole processes.
Thos makes way for us to add REAL kthread_create() and friends
that actually make theads. it turns out that most of these
calls actually end up being moved back to the thread version
when it's added. but we need to make this cosmetic change first.

I'd LOVE to do this rename in 7.0 so that we can eventually MFC the
new kthread_xxx() calls.


# 162954 02-Oct-2006 phk

First part of a little cleanup in the calendar/timezone/RTC handling.

Move relevant variables to <sys/clock.h> and fix #includes as necessary.

Use libkern's much more time- & spamce-efficient BCD routines.


# 158922 25-May-2006 imp

APM was calling the suspend process from a timeout. This meant that
other timeouts could not happen while suspending, including timeouts
for things like msleep. This caused the system to hang on suspend
when the cbb was enabled, since its suspend path powered down the
socket which used a timeout to wait for it to be done.

APM now creates a thread when it is enabled, and deletes the thread
when it is disabled. This thread takes the place of the timeout by
doing its polling every ~.9s. When the thread is disabled, it will
wakeup early, otherwise it times out and polls the varius things the
old timeout polled (APM events, suspend delays, etc).

This makes my Sony VAIO 505TS suspend/resume correctly when APM is
enabled (ACPI is black listed on my 505TS).

This will likely fix other problems with the suspend path where
drivers would sleep with msleep and/or do other timeouts. Maybe
there's some special case code that would use DELAY while suspending
and msleep otherwise that can be revisited and removed.

This was also tested by glebius@, who pointed out that in the patch I
sent him, I'd forgotten apm_saver.c

MFC After: 3 weeks


# 144964 12-Apr-2005 mdodd

- Consistently protect against NULL dereference.
- Simplify conditional logic to make code easier to read.


# 139790 06-Jan-2005 imp

/* -> /*- for copyright notices, minor format tweaks as necessary


# 136520 14-Oct-2004 njl

Remove local hacks to set flags now that the device probe does this for us.
Tested on every device except sio_pci and the pc98 fd.c. Perhaps something
similar should be done for the "disabled" hints also.

MFC after: 2 weeks


# 130605 16-Jun-2004 imp

o Return ai_batteries as 0xffffffff instead of -1. This is a nop change, but
placates gcc which seems to like to complain about -1 being assigned to
an unsigned value. It is well defined and intended, but since signess bugs
are being hunted just change to 0xffffffff.
o Mask the lower 8 bits, not the lower 4 bits for the ai_capabilities word.
All 8 bits are defined and the 0xf was almost certainly a typo.
o Define APM_UNKNOWN to 0xff for emulation layer.


# 130585 16-Jun-2004 phk

Do the dreaded s/dev_t/struct cdev */
Bump __FreeBSD_version accordingly.


# 129882 30-May-2004 phk

Add missing #include <sys/module.h>


# 126080 21-Feb-2004 phk

Device megapatch 4/6:

Introduce d_version field in struct cdevsw, this must always be
initialized to D_VERSION.

Flip sense of D_NOGIANT flag to D_NEEDGIANT, this involves removing
four D_NOGIANT flags and adding 145 D_NEEDGIANT flags.


# 126076 21-Feb-2004 phk

Device megapatch 1/6:

Free approx 86 major numbers with a mostly automatically generated patch.

A number of strategic drivers have been left behind by caution, and a few
because they still (ab)use their major number.


# 122352 09-Nov-2003 tanimura

- Implement selwakeuppri() which allows raising the priority of a
thread being waken up. The thread waken up can run at a priority as
high as after tsleep().

- Replace selwakeup()s with selwakeuppri()s and pass appropriate
priorities.

- Add cv_broadcastpri() which raises the priority of the broadcast
threads. Used by selwakeuppri() if collision occurs.

Not objected in: -arch, -current


# 117167 02-Jul-2003 jhb

- Use the new resource_disabled() helper function to see if devices are
disabled.
- Change the apm driver to match the acpi driver's behavior by checking to
see if the device is disabled in the identify routine instead of in the
probe routine. This way if the device is disabled it is never created.

Note that a few places (ips(4), Alpha SMP) used "disable" instead of
"disabled" for their hint names, and these hints must be changed to
"disabled". If this is a big problem, resource_disabled() can always be
changed to honor both names.


# 116665 22-Jun-2003 mdodd

Implement a loader tunable/sysctl to allow the user to request that
the APM driver byte-swap battery time values. (For broken laptops.)

PR: i386/42439
Submitted by: Bruce M Simpson <bms@spc.org>


# 115679 02-Jun-2003 obrien

Use __FBSDID().


# 112590 25-Mar-2003 mdodd

Merge PC98 support.


# 112551 24-Mar-2003 mdodd

Use repo-copied files in sys/i386/bios.


# 111815 03-Mar-2003 phk

Gigacommit to improve device-driver source compatibility between
branches:

Initialize struct cdevsw using C99 sparse initializtion and remove
all initializations to default values.

This patch is automatically generated and has been tested by compiling
LINT with all the fields in struct cdevsw in reverse order on alpha,
sparc64 and i386.

Approved by: re(scottl)


# 105216 16-Oct-2002 phk

Be consistent about functions being static.

Spotted by: FlexeLint.


# 103864 23-Sep-2002 jhb

Hang apm off of the legacy device instead of the nexus.


# 103752 21-Sep-2002 markm

Use a function instead of embedding non-portable asm() constructs
in C code.


# 103751 21-Sep-2002 markm

Sort includes.


# 92761 20-Mar-2002 alfred

Remove __P.


# 91640 04-Mar-2002 iwasaki

Add generalized power profile code.
This makes other power-management system (APM for now) to be able to
generate power profile change events (ie. AC-line status changes), and
other kernel components, not only the ACPI components, can be notified
the events.

- move subroutines in acpi_powerprofile.c (removed) to kern/subr_power.c
- call power_profile_set_state() also from APM driver when AC-line
status changes
- add call-back function for Crusoe LongRun controlling on power
profile changes for a example


# 85835 01-Nov-2001 iwasaki

Some fix for the recent apm module changes.
- Now that apm loadable module can inform its existence to other kernel
components (e.g. i386/isa/clock.c:startrtclock()'s TCS hack).
- Exchange priority of SI_SUB_CPU and SI_SUB_KLD for above purpose.
- Add simple arbitration mechanism for APM vs. ACPI. This prevents
the kernel enables both of them.
- Remove obsolete `#ifdef DEV_APM' related code.
- Add abstracted interface for Powermanagement operations. Public apm(4)
functions, such as apm_suspend(), should be replaced new interfaces.
Currently only power_pm_suspend (successor of apm_suspend) is implemented.

Reviewed by: peter, arch@ and audit@


# 83366 12-Sep-2001 julian

KSE Milestone 2
Note ALL MODULES MUST BE RECOMPILED
make the kernel aware that there are smaller units of scheduling than the
process. (but only allow one thread per process at this time).
This is functionally equivalent to teh previousl -current except
that there is a thread associated with each process.

Sorry john! (your next MFC will be a doosie!)

Reviewed by: peter@freebsd.org, dillon@freebsd.org

X-MFC after: ha ha ha ha


# 74810 26-Mar-2001 phk

Send the remains (such as I have located) of "block major numbers" to
the bit-bucket.


# 74200 13-Mar-2001 peter

Commit some tweaks I have had laying around my tree for over a year now.
Always set the APM "device" description. Some minor style tweaks.


# 70834 09-Jan-2001 wollman

select() DKI is now in <sys/selinfo.h>.


# 67882 29-Oct-2000 phk

Remove unneeded #include <sys/proc.h> lines.


# 65865 14-Sep-2000 iwasaki

Add Timer device driver for power management events.
The code for suspend/resume is derived from APM device driver.

Some people suggested the original code is somewhat buggy, but I'd
like to just move it from apm.c without any major changes for the
initial version. This code should be refined later.

To use pmtimer to adjust time at resume time, add
device pmtimer
in your kernel config file, and add
hint.pmtimer.0.at="isa"
in your device.hints

Reviewed by: -current, bde


# 64615 13-Aug-2000 ume

Add output of per battery information to apm(1).
New ioctl APMIO_GETPWSTATUS is introduced.

Reviewed by: -mobile and -current folks (no objection)


# 64251 04-Aug-2000 iwasaki

Cleanup debug messages and Add some enhancements from linux on
display control by apm -d.
- Remove APM_DEBUG to avoid re-build kernel with such a unspported optioin.
- Introduce new denug flag `debug.apm_debug' which can be controlled by
sysctl interface and loader by setting like "debug.apm_debug=1", you
will get debug messages from APM driver.
- Add some enhancements from linux on display control by apm -d. I'm
expecting that we can see some improvements on some laptops where
apm -d doesn't work correctly so far.

Reviewed by: -mobile and -current folks (no objection)
Suggested by: Susumu WAKABAYASHI <susumu@wakabaya.net>


# 63493 19-Jul-2000 imp

Except for the information gathering IOCTLs, require apm device be
opened for write. This should make the apm device read only safe.


# 57010 06-Feb-2000 n_hibma

Correctly handle suspend and resume in APM.

Up to now, errors from DEVICE_SUSPEND(root_bus) were ignored. The fix for
this problem (the introduction of defaults for device methods) has been
committed months ago by Doug Rabson.

Second, the suspended devices were not always properly resumed on error.

Third, swapped the order for calling restore hooks and restore methods, to
be in line with the cases above.

Reviewed by: Doug Rabson
Approved by: jhk


# 54017 02-Dec-1999 jlemon

Remove code to select APM version with flags to the apm0 device. This
code has been disabled for the last 4 months.

Prodded into action by: n_hibma


# 53001 08-Nov-1999 peter

Use DRIVER_MODULE(), apm.c already takes care of it's devices with
make_dev().


# 52669 30-Oct-1999 iwasaki

i8254_restore is called from apm_default_resume() to reload
the countdown register.
this should not be necessary but there are broken laptops that
do not restore the countdown register on resume.
when it happnes, it messes up the hardclock interval and system clock,
which leads to the infamous "calcru: negative time" problem.

Submitted by: kjc, iwasaki
Reviewed by: Steve O'Hara-Smith <steveo@eircom.net> and committers.
Obtained from: PAO3


# 52161 12-Oct-1999 nsayer

Fix APM's make_devs:

1. chown root:operator, chmod 660

2. Add /dev/apmctl as well as /dev/apm


# 51850 02-Oct-1999 nsayer

Prepare for the apm_saver screen saver module.

1. Break out the definition of the soft state structure into an include
file.

2. un-static the soft state and apm_display(), and group them under a
comment that notes the dependency.


# 51658 25-Sep-1999 phk

Remove five now unused fields from struct cdevsw. They should never
have been there in the first place. A GENERIC kernel shrinks almost 1k.

Add a slightly different safetybelt under nostop for tty drivers.

Add some missing FreeBSD tags


# 51463 20-Sep-1999 iwasaki

Return immediately from apm_suspend() when APM BIOS wasn't initialized.
Pressing Alt-Pause key will cause machine to reboot with apm disabled.

PR: i386/13817
Submitted by: yokota


# 51163 11-Sep-1999 iwasaki

Handle CAPABILITIESCHANGE event.
Document USERSTANDBYREQ and CAPABILITIESCHANGE events to apmd manpage.


# 51156 11-Sep-1999 nsayer

Handle UserStandbyRequests as well as the other 3 members of the
{,USER}{STANDBY,SUSPEND}REQ matrix.


# 50477 27-Aug-1999 peter

$Id$ -> $FreeBSD$


# 50254 23-Aug-1999 phk

Convert DEVFS hooks in (most) drivers to make_dev().

Diskslice/label code not yet handled.

Vinum, i4b, alpha, pc98 not dealt with (left to respective Maintainers)

Add the correct hook for devfs to kern_conf.c

The net result of this excercise is that a lot less files depends on DEVFS,
and devtoname() gets more sensible output in many cases.

A few drivers had minor additional cleanups performed relating to cdevsw
registration.

A few drivers don't register a cdevsw{} anymore, but only use make_dev().


# 50179 22-Aug-1999 peter

Add an identify method to allow apm to attach itself to the nexus
without hooks in there.


# 50157 22-Aug-1999 iwasaki

Fix `key release event prevent suspend' problem. We don't need
`sleep 1; zzz' trick now.

- APM BIOS Call for suspend/standby now should be issued with delay.
- Delay for suspend/standby can be adjusted by using sysctl(8) interface
(eg. sysctl -w machdep.apm_suspend_delay=3).


# 50107 21-Aug-1999 msmith

Implement a new generic mechanism for attaching handler functions to
events, in order to pave the way for removing a number of the ad-hoc
implementations currently in use.

Retire the at_shutdown family of functions and replace them with
new event handler lists.

Rework kern_shutdown.c to take greater advantage of the use of event
handlers.

Reviewed by: green


# 49789 14-Aug-1999 iwasaki

- Add apm_check_function_supported() and call it from
apm_bioscall() to check requested BIOS is supported or not.

- Add workaround in apm_driver_version() for the buggy BIOSes which
don't return the connection version in %ax.

PR: i386/13028
Reviewed by: sanpei@sanpei.org and Warner Losh.


# 49380 02-Aug-1999 msmith

Don't trust the segment limits that the BIOS reports; instead give it
as much space as possible to avoid lossage due to sloppy BIOS
programming.


# 49292 30-Jul-1999 msmith

Reenable the APMIO_BIOS ioctl and translate arguments into the new format
(which is more like the old than I thought).

Requested-by: imp


# 49248 30-Jul-1999 msmith

Remove all vestiges of APMIO_BIOS

Submitted by: N. Dudorov <nnd@mail.nsk.ru>


# 49222 29-Jul-1999 iwasaki

No more apm_errno. It breaks the build with APM_DEBUG,
uses (sc->bios.r.eax >> 8) & 0xff instead.


# 49197 28-Jul-1999 msmith

Major update to the kernel's BIOS-calling ability.

- Add support for calling 32-bit code in other segments
- Add support for calling 16-bit protected mode code

Update APM to use this facility.

Submitted by: jlemon


# 49185 28-Jul-1999 msmith

Remove unused real-mode APM setup support. We've been using the vm86
mode initialiser for a while now, and it's looking happy.


# 49179 28-Jul-1999 msmith

Remove some erroneous comments about how APM is initialised.


# 48984 22-Jul-1999 iwasaki

Add braces to make if-else statement clearer.

PR: 12663
Submitted by: Adam Wight <adamw@holonet.net>


# 48735 10-Jul-1999 iwasaki

Add apmd support code.


# 48557 04-Jul-1999 phk

Remove cmaj and bmaj args from DEV_DRIVER_MODULE.


# 47676 01-Jun-1999 jlemon

Unifdef VM86

Reviewed by: silence on on -current


# 47625 30-May-1999 phk

This commit should be a extensive NO-OP:

Reformat and initialize correctly all "struct cdevsw".

Initialize the d_maj and d_bmaj fields.

The d_reset field was not removed, although it is never used.

I used a program to do most of this, so all the files now use the
same consistent format. Please keep it that way.

Vinum and i4b not modified, patches emailed to respective authors.


# 47028 11-May-1999 phk

Divorce "dev_t" from the "major|minor" bitmap, which is now called
udev_t in the kernel but still called dev_t in userland.

Provide functions to manipulate both types:
major() umajor()
minor() uminor()
makedev() umakedev()
dev2udev() udev2dev()

For now they're functions, they will become in-line functions
after one of the next two steps in this process.

Return major/minor/makedev to macro-hood for userland.

Register a name in cdevsw[] for the "filedescriptor" driver.

In the kernel the udev_t appears in places where we have the
major/minor number combination, (ie: a potential device: we
may not have the driver nor the device), like in inodes, vattr,
cdevsw registration and so on, whereas the dev_t appears where
we carry around a reference to a actual device.

In the future the cdevsw and the aliased-from vnode will be hung
directly from the dev_t, along with up to two softc pointers for
the device driver and a few houskeeping bits. This will essentially
replace the current "alias" check code (same buck, bigger bang).

A little stunt has been provided to try to catch places where the
wrong type is being used (dev_t vs udev_t), if you see something
not working, #undef DEVT_FASCIST in kern/kern_conf.c and see if
it makes a difference. If it does, please try to track it down
(many hands make light work) or at least try to reproduce it
as simply as possible, and describe how to do that.

Without DEVT_FASCIST I belive this patch is a no-op.

Stylistic/posixoid comments about the userland view of the <sys/*.h>
files welcome now, from userland they now contain the end result.

Next planned step: make all dev_t's refer to the same devsw[] which
means convert BLK's to CHR's at the perimeter of the vnodes and
other places where they enter the game (bootdev, mknod, sysctl).


# 46792 09-May-1999 phk

Unconfuse DEV_MODULE() and DEV_DRIVER_MODULE() about the difference between
a major number for a dev_t.


# 46762 09-May-1999 yokota

Make apm_probe() properly return an error code when APM BIOS calls
failed, so that the apm driver won't be attached.


# 46743 08-May-1999 dfr

Move the declaration of the interrupt type from the driver structure
to the BUS_SETUP_INTR call.


# 46635 07-May-1999 phk

Continue where Julian left off in July 1998:

Virtualize bdevsw[] from cdevsw. bdevsw() is now an (inline)
function.

Join CDEV_MODULE and BDEV_MODULE to DEV_MODULE (please pay attention
to the order of the cmaj/bmaj arguments!)

Join CDEV_DRIVER_MODULE and BDEV_DRIVER_MODULE to DEV_DRIVER_MODULE
(ditto!)

(Next step will be to convert all bdev dev_t's to cdev dev_t's
before they get to do any damage^H^H^H^H^H^Hwork in the kernel.)


# 46540 05-May-1999 luoqi

Now that each cpu has its own gdt table, we need to setup apm gdt entries in
all the tables.


# 45905 21-Apr-1999 imp

DEVICE_SUSPEND was always returning ENXIO for reasons unknown. For
now we noisily ignore this (and all errors). DEVICE_SUSPEND should be
corrected, but I wanted to unbreak suspend until that happens.


# 45788 18-Apr-1999 dfr

Add support for 'disabled' probe hint.


# 45720 16-Apr-1999 peter

Bring the 'new-bus' to the i386. This extensively changes the way the
i386 platform boots, it is no longer ISA-centric, and is fully dynamic.
Most old drivers compile and run without modification via 'compatability
shims' to enable a smoother transition. eisa, isapnp and pccard* are
not yet using the new resource manager. Once fully converted, all drivers
will be loadable, including PCI and ISA.

(Some other changes appear to have snuck in, including a port of Soren's
ATA driver to the Alpha. Soren, back this out if you need to.)

This is a checkpoint of work-in-progress, but is quite functional.

The bulk of the work was done over the last few years by Doug Rabson and
Garrett Wollman.

Approved by: core


# 41664 10-Dec-1998 msmith

Perform APM power-off on power-off request, not halt request.


# 41507 04-Dec-1998 archie

Fix typo: "==" should have been "="
PR: 8280 (1/3 patches contained in this PR)
Reviewed by: Nate Williams <nate@mt.sri.com>
Submitted by: Sakari Jalovaara <sja@tekla.fi>


# 40751 30-Oct-1998 msmith

Add the ability to specify where on the at_shutdown queue a handler is
installed.

Remove cpu_power_down, and replace it with an entry at the end of the
SHUTDOWN_FINAL queue in the only place it's used (APM).

Submitted by: Some ideas from Bruce Walter <walter@fortean.com>


# 39704 28-Sep-1998 jlemon

Use defines APM_BIOS and SYSTEM_BIOS instead of hardcoding 0x53 and 0x15.


# 37414 06-Jul-1998 imp

Add the ability to suspend as well as hibernate to the system. This
is the kernel part of my commits, the userlevel stuff will be done in
a separate commit. Add the ability to suspend as well as hibernate to
syscons. Create a new virtual key like hibernate for suspend. Update
apm_bios.h to define more apm bios goodies.


# 36735 07-Jun-1998 dfr

This commit fixes various 64bit portability problems required for
FreeBSD/alpha. The most significant item is to change the command
argument to ioctl functions from int to u_long. This change brings us
inline with various other BSD versions. Driver writers may like to
use (__FreeBSD_version == 300003) to detect this change.

The prototype FreeBSD/alpha machdep will follow in a couple of days
time.


# 36596 02-Jun-1998 msmith

If vm86 services are available, use these to perform the APM BIOS
probe and intialisation. This will ultimately remove the grubby (but
functional) hack that copies a real-mode function into low memory
early in locore.s.


# 34961 30-Mar-1998 phk

Eradicate the variable "time" from the kernel, using various measures.
"time" wasn't a atomic variable, so splfoo() protection were needed
around any access to it, unless you just wanted the seconds part.

Most uses of time.tv_sec now uses the new variable time_second instead.

gettime() changed to getmicrotime(0.

Remove a couple of unneeded splfoo() protections, the new getmicrotime()
is atomic, (until Bruce sets a breakpoint in it).

A couple of places needed random data, so use read_random() instead
of mucking about with time which isn't random.

Add a new nfs_curusec() function.

Mark a couple of bogosities involving the now disappeard time variable.

Update ffs_update() to avoid the weird "== &time" checks, by fixing the
one remaining call that passwd &time as args.

Change profiling in ncr.c to use ticks instead of time. Resolution is
the same.

Add new function "tvtohz()" to avoid the bogus "splfoo(), add time, call
hzto() which subtracts time" sequences.

Reviewed by: bde


# 33181 09-Feb-1998 eivind

Staticize.


# 32726 24-Jan-1998 eivind

Make all file-system (MFS, FFS, NFS, LFS, DEVFS) related option new-style.

This introduce an xxxFS_BOOT for each of the rootable filesystems.
(Presently not required, but encouraged to allow a smooth move of option *FS
to opt_dontuse.h later.)

LFS is temporarily disabled, and will be re-enabled tomorrow.


# 31950 23-Dec-1997 nate

This patch causes the "calltodo" timer list to be decremented by the amount
of time that the laptop was suspending. Thus, select() calls that might have
suspended rather than firing at 1hr + "time suspended" since the timer was
posted.

Adding:

options APM_FIXUP_CALLTODO

to the kernel config enables the patch.

[
This patch was slightly modified to use a consistant indent style and
I removed some unused local variables. After this has been tested a
few weeks we'll make the options the default, so for now I'm now
documenting it in LINT. Mike can later if he wants.
]

Reviewed by: Mike Smith <msmith@freebsd.org>
Submitted by: Ken Key <key@cs.utk.edu>


# 31519 04-Dec-1997 imp

The Libretto's BIOS doesn't set edx on the APM_GETPWSTATUS call, so
the barrery time remaining is reported as a random number. Initialize
edx to 0xffff in this case, and to 0 in all other cases. This change
should be benign on other machines.
Reviewed by: jdp


# 31126 12-Nov-1997 jdp

Expand the APMIO_GETINFO ioctl to return the estimated remaining
battery time. For backward compatibility with old binaries, I
assigned a new ioctl number for this call, and retained the old
one as APMIO_GETINFO_OLD. I also added eight words of padding and
a version field, so that future enhancements won't require jumping
through this hoop again.


# 31102 10-Nov-1997 nate

- Convert c++ comment to c comment.

Noted by: Bruce


# 30935 04-Nov-1997 nate

- If the APM BIOS fails to suspend the system after running the
suspend hooks, run the resume hooks to re-configure the system back
to where it was.


# 30663 23-Oct-1997 nate

- Back out the last. APM_BROKEN_STATCLOCK doesn't exist in -current.


# 30650 22-Oct-1997 nate

- If APM_BROKEN_STATCLOCK is defined, make sure the statcloock is
disabled, don't rely on the flags to set it.


# 29672 21-Sep-1997 gibbs

Convert to the new callout interface.


# 26729 18-Jun-1997 wollman

Fix crash when halting where APM was configured but not enabled
by checking whether APM is active in apm_power_off() and returning
if not. (The code was already written with the expectation that
this function would return if it fails.)


# 26658 15-Jun-1997 wollman

Fix definition of apm_power off (was suffering from cut&paste syndrome).


# 26657 15-Jun-1997 wollman

When APM is configured, turn off the power when halting for good.


# 24407 30-Mar-1997 phk

Fix embarrasing typo that survived because I applied the wrong patch-
file.
Noticed by: Eric Jones <ejon@psa.pencom.com>


# 24372 29-Mar-1997 phk

Sanitize APM a bit. Convert various #ifdef to id_flags instead.
You may want to add "flags 0x31" to apm0 if you have a lousy
implementation. Read LINT.


# 24351 28-Mar-1997 phk

Try to talk to the APM BIOS with version 1.2 if possible.


# 22975 22-Feb-1997 peter

Back out part 1 of the MCFH that changed $Id$ to $FreeBSD$. We are not
ready for it yet.


# 21673 14-Jan-1997 jkh

Make the long-awaited change from $Id$ to $FreeBSD$

This will make a number of things easier in the future, as well as (finally!)
avoiding the Id-smashing problem which has plagued developers for so long.

Boy, I'm glad we're not using sup anymore. This update would have been
insane otherwise.


# 21401 07-Jan-1997 nate

> The extra include of <sys/time.h> is because apm uses microtime() and my
> <sys/param.h> doesn't include <sys/time.h>
>
> I removed the NAPM check since it's wasteful to check twice. apmprobe()
> checks the unit number, and that's the right check.

Submitted by: bde


# 21362 06-Jan-1997 nate

- Cleanup up the driver (remove un-needed parameters, white-space,
etc..), plus add a better display suspend function.
- Changed the Copyright's to reflect the new 'jp.FreeBSD.org' email
address.

Submitted by: nate & HOSOKAWA, Tatsumi <hosokawa@jp.FreeBSD.org>


# 18105 07-Sep-1996 nate

APM_DSVALUE_BUS is no longer with the addition of the correct fix to
machdep.c. We no longer walk on the data segment the BIOS sets up.


# 18084 06-Sep-1996 phk

Remove devconf, it never grew up to be of any use.


# 17867 28-Aug-1996 bde

Use (full) <> paths instead of ambiguous "" paths for headers not in
the current directory.


# 17097 11-Jul-1996 nate

Add some comments explaining what APM_DSVALUE_BUG does no that I know
what it does and why it's needed. Now I have to figure out how to fix
the bug. :)

[ No functional changes ]


# 17068 10-Jul-1996 nate

Whee. Fix two bugs which ended up cancelling each other out.
apm_setup.s was storing apm_cs16_base and apm_cs32_base addresses in
each others slots, and apm.c was reversing the result so the bugs
cancelled out, but the code looked wrong.

No functional differences unfortunately.

Submitted by: dave edmondson <davided@sco.com>


# 16471 17-Jun-1996 bde

Removed unused #includes of <i386/isa/icu.h> and <i386/isa/icu.h>. icu.h
is only used by the icu support modules and by a few drivers that know
too much about the icu (most only use it to convert `n' to `IRQn'). isa.h
is only used by ioconf.c and by a few drivers that know too much about
isa addresses (a few have to, because config is deficient).


# 16109 04-Jun-1996 nate

Freudian slip. Change M_DEVBUG -> M_DEVBUF.

Submitted by: "Stephen F. Combs" <combssf@salem.ge.com>


# 16107 04-Jun-1996 nate

Fix typo. in the APM_DSVALUE_BUG code that I missed.

Obtained from: Someone on the mailing list (sorry, I forgot who)


# 15364 23-Apr-1996 nate

- This code adds some backwards compatability hacks for buggy APM BIOS
implementations, and synchronizes us with the Nomad's latest code.

This code is based on the Nomad code, but heavily hacked by me.

Reviewed by: phk
Submitted by: the 'Nomads'


# 15360 23-Apr-1996 nate

Adds the APM hooks into the generic pccard kernel files. With this code
in place device drivers can now register power-down/power-up routines so
that we can use common routines to power-up/power-down cards for
insert/removals, suspend/resume, etc..

Reviewed by: phk
Submitted by: the 'Nomads'


# 15345 22-Apr-1996 nate

- add apm to the GENERIC kernel (disabled by default), and add some comments
regarding apm to LINT
- Disabled the statistics clock on machines which have an APM BIOS and
have the options "APM_BROKEN_STATCLOCK" enabled (which is default
in GENERIC now)
- move around some of the code in clock.c dealing with the rtc to make
it more obvios the effects of disabling the statistics clock

Reviewed by: bde


# 15298 18-Apr-1996 nate

- Addition of my name to the APM Copyright
- More code cleanups
- #ifdef DEBUG debugging code
- More consistant printfs
- Better handling of the apm_int() assembly code (mostly from Bruce Evans)

Reviewed by: bde


# 14873 28-Mar-1996 scrappy

Switched from using devfs_add_sw() to using devfs_add_swf()

Reviewed by: julian@freebsd.org


# 14715 19-Mar-1996 nate

Add some comments on the APM specs, and make the APM 'idle/busy'
functions follow them.


# 14714 19-Mar-1996 nate

Call apm_int() instead of doing direct assembly calls even when we don't
care about the return value for consistency.


# 14692 19-Mar-1996 nate

Added kernel compile time failure if more than one APM device is
configured.


# 14691 19-Mar-1996 nate

Always enable interrupts before calling the APM idle/busy routines.

Suggested by: phk@FreeBSD.org


# 14686 18-Mar-1996 nate

Minor bugfixes from the recent PC-CARD release.

Submitted by: hosokawa@mt.cs.keio.ac.jp and the rest of the Nomads


# 14682 18-Mar-1996 nate

Grr, let's actually include <sys/devconf.h> so that DEVCONF support actually
works.


# 14681 18-Mar-1996 nate

Whoops, forgot the line that sets the default state in devfs.


# 14680 18-Mar-1996 nate

Devfs support.
Submitted by: hosokawa@mt.cs.keio.ac.jp and the rest of the Nomads

Cleanup.


# 14679 18-Mar-1996 nate

Removed support for multiple APM devices.


# 14608 12-Mar-1996 nate

Return the status of the APM support (enabled/disabled) with the
APM_GETINFO ioctl.


# 14603 12-Mar-1996 nate

Removed more APM_SLOWSTART code and re-enabled some functions which
didn't require APM_SLOWSTART to be defined.


# 14581 12-Mar-1996 nate

Always initialize master_softc. This avoids panics in the idle loop due
to unitialized data if the APM support is compiled in and the probe
fails.


# 14537 11-Mar-1996 nate

Bring in most of Bruce's prot_to_real() changes into the APM BIOS
startup code.

Reviewed by: bde


# 13062 27-Dec-1995 bde

Finished removing MACH_KERNEL stuff.


# 13013 25-Dec-1995 bde

Fixed staticizing. Some functions aren't static but depend on
the undocumented previously unLINTed option `APM_SLOWSTART'.


# 12959 22-Dec-1995 phk

Cleanup.


# 12675 08-Dec-1995 julian

Pass 3 of the great devsw changes
most devsw referenced functions are now static, as they are
in the same file as their devsw structure. I've also added DEVFS
support for nearly every device in the system, however
many of the devices have 'incorrect' names under DEVFS
because I couldn't quickly work out the correct naming conventions.
(but devfs won't be coming on line for a month or so anyhow so that doesn't
matter)

If you "OWN" a device which would normally have an entry in /dev
then search for the devfs_add_devsw() entries and munge to make them right..
check out similar devices to see what I might have done in them in you
can't see what's going on..
for a laugh compare conf.c conf.h defore and after... :)
I have not doen DEVFS entries for any DISKSLICE devices yet as that will be
a much more complicated job.. (pass 5 :)

pass 4 will be to make the devsw tables of type (cdevsw * )
rather than (cdevsw)
seems to work here..
complaints to the usual places.. :)


# 12662 07-Dec-1995 dg

Untangled the vm.h include file spaghetti.


# 12521 29-Nov-1995 julian

If you're going to mechanically replicate something in 50 files
it's best to not have a (compiles cleanly) typo in it! (sigh)


# 12517 29-Nov-1995 julian

OK, that's it..
That's EVERY SINGLE driver that has an entry in conf.c..
my next trick will be to define cdevsw[] and bdevsw[]
as empty arrays and remove all those DAMNED defines as well..

Each of these drivers has a SYSINIT linker set entry
that comes in very early.. and asks teh driver to add it's own
entry to the two devsw[] tables.

some slight reworking of the commits from yesterday (added the SYSINIT
stuff and some usually wrong but token DEVFS entries to all these
devices.

BTW does anyone know where the 'ata' entries in conf.c actually reside?
seems we don't actually have a 'ataopen() etc...

If you want to add a new device in conf.c
please make sure I know
so I can keep it up to date too..

as before, this is all dependent on #if defined(JREMOD)
(and #ifdef DEVFS in parts)


# 12504 28-Nov-1995 julian

oops forgot one..


# 12352 18-Nov-1995 bde

Fixed the types of apm_default_resume() and apm_default_suspend().

Added prototypes.


# 11872 28-Oct-1995 phk

Remove unused functions and variables, make things static, and other cleanups.


# 9540 16-Jul-1995 bde

Don't include <sys/tty.h> in drivers that aren't tty drivers or in general
files that don't depend on the internals of <sys/tty.h>


# 8876 30-May-1995 rgrimes

Remove trailing whitespace.


# 6512 17-Feb-1995 phk

This is the latest version of the APM stuff from HOSOKAWA, I have looked
briefly over it, and see some serious architectural issues in this stuff.

On the other hand, I doubt that we will have any solution to these issues
before 2.1, so we might as well leave this in.

Most of the stuff is bracketed by #ifdef's so it shouldn't matter too much
in the normal case.

Reviewed by: phk
Submitted by: HOSOKAWA, Tatsumi <hosokawa@mt.cs.keio.ac.jp>


# 5122 16-Dec-1994 phk

Don't push/pop the return-val register. (DUH!)


# 5121 16-Dec-1994 phk

Grumble, try to remember what assembler syntax is used :-/

Increase polling frequency a fraction to just above 1 Hz.


# 5120 16-Dec-1994 phk

Be much more carefull about what we leave in unused registers when we call
the APM-bios.
This stabilizes a couple of APM bioses quite a bit.
They all make the mistake of going into 16-bit mode, without clearing the
top half of the 32bit registers.
Later they do a
| movw %si,$0x7331
| movw %ax,0x6(%si)
or something along those lines and crash and burn, because their segment
is already relocated, so adding 0xf0171ce9 to the base of it is bad news.

At least SystemSoft is guilty of this bummer.


# 4500 15-Nov-1994 bde

Fix type mismatches exposed by a recently added prototype.


# 4225 07-Nov-1994 phk

Calling sync will panic you more often than not.


# 3309 02-Oct-1994 phk

Ripped out a lot of stuff made to circumvent the previous bogus assy stuff.
Ripped out the "hooks". Until we know how we want to do it, we shouldn't
start hacking anyway. Still panics my machine though.


# 3287 01-Oct-1994 phk

Replaced the magic register union with inline assembler. Now it works
"mostly". My machine still panics from time to time, and I think the
problem is a stack-problem.


# 3264 01-Oct-1994 dg

Added $Id$


# 3260 01-Oct-1994 dg

Minor improvement to probe routine.

Submitted by: HOSOKAWA Tatsumi


# 3258 01-Oct-1994 dg

Laptop Advanced Power Management support by HOSOKAWA Tatsumi.

Submitted by: HOSOKAWA Tatsumi