Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Index: sys/x86/isa/atrtc.c
- ===================================================================
- --- sys/x86/isa/atrtc.c (revision 267519)
- +++ sys/x86/isa/atrtc.c (working copy)
- @@ -31,6 +31,7 @@
- __FBSDID("$FreeBSD$");
- #include "opt_isa.h"
- +#include "opt_acpi.h"
- #include <sys/param.h>
- #include <sys/systm.h>
- @@ -53,6 +54,10 @@
- #include <machine/intr_machdep.h>
- #include "clock_if.h"
- +#include <contrib/dev/acpica/include/acpi.h>
- +#include <contrib/dev/acpica/include/accommon.h>
- +#include <dev/acpica/acpivar.h>
- +
- #define RTC_LOCK do { if (!kdb_active) mtx_lock_spin(&clock_lock); } while (0)
- #define RTC_UNLOCK do { if (!kdb_active) mtx_unlock_spin(&clock_lock); } while (0)
- @@ -161,8 +166,33 @@
- struct resource *intr_res;
- void *intr_handler;
- struct eventtimer et;
- + ACPI_HANDLE acpi_handle; /* Handle of the PNP0B00 node */
- };
- +static ACPI_STATUS
- +acpi_rtc_cmos_handler(UINT32 function, ACPI_PHYSICAL_ADDRESS address, UINT32 width,
- + UINT64 *value, void *context, void *region_context)
- +{
- + struct atrtc_softc *sc;
- +
- + sc = (struct atrtc_softc *)context;
- + if (!value || !sc)
- + return AE_BAD_PARAMETER;
- + if (width != 8 || address >= 64U)
- + return AE_BAD_PARAMETER;
- + switch (function) {
- + case ACPI_READ:
- + *((UINT8 *)value) = rtcin((int)address);
- + break;
- + case ACPI_WRITE:
- + writertc((int)address, *((UINT8 *)value));
- + break;
- + default:
- + return AE_BAD_PARAMETER;
- + }
- + return AE_OK;
- +}
- +
- static int
- rtc_start(struct eventtimer *et, sbintime_t first, sbintime_t period)
- {
- @@ -245,10 +275,17 @@
- int i;
- sc = device_get_softc(dev);
- + sc->acpi_handle = acpi_get_handle(dev);
- sc->port_res = bus_alloc_resource(dev, SYS_RES_IOPORT, &sc->port_rid,
- IO_RTC, IO_RTC + 1, 2, RF_ACTIVE);
- if (sc->port_res == NULL)
- device_printf(dev, "Warning: Couldn't map I/O.\n");
- + if (ACPI_FAILURE(AcpiInstallAddressSpaceHandler(sc->acpi_handle,
- + ACPI_ADR_SPACE_CMOS, acpi_rtc_cmos_handler, NULL, sc)))
- + {
- + device_printf(dev, "Error registering ACPI CMOS address space handler.\n");
- + return 0;
- + }
- atrtc_start();
- clock_register(dev, 1000000);
- bzero(&sc->et, sizeof(struct eventtimer));
- @@ -286,6 +323,15 @@
- return(0);
- }
- +static int atrtc_detach(device_t dev)
- +{
- + struct atrtc_softc *sc;
- +
- + sc = device_get_softc(dev);
- + AcpiRemoveAddressSpaceHandler(sc->acpi_handle, ACPI_ADR_SPACE_CMOS, acpi_rtc_cmos_handler);
- + return bus_generic_detach(dev);
- +}
- +
- static int
- atrtc_resume(device_t dev)
- {
- @@ -366,7 +412,7 @@
- /* Device interface */
- DEVMETHOD(device_probe, atrtc_probe),
- DEVMETHOD(device_attach, atrtc_attach),
- - DEVMETHOD(device_detach, bus_generic_detach),
- + DEVMETHOD(device_detach, atrtc_detach),
- DEVMETHOD(device_shutdown, bus_generic_shutdown),
- DEVMETHOD(device_suspend, bus_generic_suspend),
- /* XXX stop statclock? */
- @@ -402,3 +448,4 @@
- rtcin(RTC_STATUSA), rtcin(RTC_STATUSB), rtcin(RTC_INTR));
- }
- #endif /* DDB */
- +
Add Comment
Please, Sign In to add comment