diff options
author | yokota <yokota@FreeBSD.org> | 1999-05-18 11:33:14 +0000 |
---|---|---|
committer | yokota <yokota@FreeBSD.org> | 1999-05-18 11:33:14 +0000 |
commit | 66a10d17ab269a894f4fceab6e92280e0182205e (patch) | |
tree | f17ac01c3f212c8954c46a86d684fdd6498a89ee /sys/dev | |
parent | 57b37c7af7478be1bcf631c78250871fc6f10ab9 (diff) | |
download | FreeBSD-src-66a10d17ab269a894f4fceab6e92280e0182205e.zip FreeBSD-src-66a10d17ab269a894f4fceab6e92280e0182205e.tar.gz |
Slight reorganization of internal interface in the keyboard controller
driver.
Diffstat (limited to 'sys/dev')
-rw-r--r-- | sys/dev/atkbdc/atkbdc.c | 12 | ||||
-rw-r--r-- | sys/dev/atkbdc/atkbdc_isa.c | 49 | ||||
-rw-r--r-- | sys/dev/atkbdc/atkbdc_subr.c | 49 | ||||
-rw-r--r-- | sys/dev/atkbdc/atkbdcreg.h | 5 | ||||
-rw-r--r-- | sys/dev/kbd/atkbdc.c | 12 | ||||
-rw-r--r-- | sys/dev/kbd/atkbdcreg.h | 5 |
6 files changed, 76 insertions, 56 deletions
diff --git a/sys/dev/atkbdc/atkbdc.c b/sys/dev/atkbdc/atkbdc.c index 0f61835..537a457 100644 --- a/sys/dev/atkbdc/atkbdc.c +++ b/sys/dev/atkbdc/atkbdc.c @@ -27,7 +27,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: $ + * $Id: atkbdc.c,v 1.1 1999/01/09 02:44:50 yokota Exp $ * from kbdio.c,v 1.13 1998/09/25 11:55:46 yokota Exp */ @@ -116,7 +116,15 @@ atkbdc_softc_t } int -atkbdc_probe_unit(atkbdc_softc_t *sc, int unit, int port) +atkbdc_probe_unit(int unit, int port) +{ + if (port <= 0) + return ENXIO; + return 0; +} + +int +atkbdc_attach_unit(int unit, atkbdc_softc_t *sc, int port) { return atkbdc_setup(sc, port); } diff --git a/sys/dev/atkbdc/atkbdc_isa.c b/sys/dev/atkbdc/atkbdc_isa.c index 88a2d11..de1ecdb 100644 --- a/sys/dev/atkbdc/atkbdc_isa.c +++ b/sys/dev/atkbdc/atkbdc_isa.c @@ -23,7 +23,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $Id: atkbdc_isa.c,v 1.4 1999/05/08 21:59:29 dfr Exp $ + * $Id: atkbdc_isa.c,v 1.5 1999/05/09 20:45:53 peter Exp $ */ #include "atkbdc.h" @@ -65,6 +65,8 @@ static int atkbdc_write_ivar(device_t bus, device_t dev, int index, static device_method_t atkbdc_methods[] = { DEVMETHOD(device_probe, atkbdc_probe), DEVMETHOD(device_attach, atkbdc_attach), + DEVMETHOD(device_suspend, bus_generic_suspend), + DEVMETHOD(device_resume, bus_generic_resume), DEVMETHOD(bus_print_child, atkbdc_print_child), DEVMETHOD(bus_read_ivar, atkbdc_read_ivar), @@ -88,31 +90,12 @@ static driver_t atkbdc_driver = { static int atkbdc_probe(device_t dev) { - atkbdc_softc_t *sc; - int unit; int error; - unit = device_get_unit(dev); - sc = *(atkbdc_softc_t **)device_get_softc(dev); - if (sc == NULL) { - /* - * We have to maintain two copies of the kbdc_softc struct, - * as the low-level console needs to have access to the - * keyboard controller before kbdc is probed and attached. - * kbdc_soft[] contains the default entry for that purpose. - * See atkbdc.c. XXX - */ - sc = atkbdc_get_softc(unit); - if (sc == NULL) - return ENOMEM; - } - device_set_desc(dev, "keyboard controller (i8042)"); - - error = atkbdc_probe_unit(sc, unit, isa_get_port(dev)); + error = atkbdc_probe_unit(device_get_unit(dev), isa_get_port(dev)); if (error == 0) - *(atkbdc_softc_t **)device_get_softc(dev) = sc; - + isa_set_portsize(dev, IO_KBDSIZE); return error; } @@ -148,11 +131,29 @@ static int atkbdc_attach(device_t dev) { atkbdc_softc_t *sc; + int unit; + int error; int i; + unit = device_get_unit(dev); sc = *(atkbdc_softc_t **)device_get_softc(dev); - if ((sc == NULL) || (sc->port <= 0)) - return ENXIO; + if (sc == NULL) { + /* + * We have to maintain two copies of the kbdc_softc struct, + * as the low-level console needs to have access to the + * keyboard controller before kbdc is probed and attached. + * kbdc_soft[] contains the default entry for that purpose. + * See atkbdc.c. XXX + */ + sc = atkbdc_get_softc(unit); + if (sc == NULL) + return ENOMEM; + } + + error = atkbdc_attach_unit(unit, sc, isa_get_port(dev)); + if (error) + return error; + *(atkbdc_softc_t **)device_get_softc(dev) = sc; /* * Add all devices configured to be attached to atkbdc0. diff --git a/sys/dev/atkbdc/atkbdc_subr.c b/sys/dev/atkbdc/atkbdc_subr.c index 88a2d11..de1ecdb 100644 --- a/sys/dev/atkbdc/atkbdc_subr.c +++ b/sys/dev/atkbdc/atkbdc_subr.c @@ -23,7 +23,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $Id: atkbdc_isa.c,v 1.4 1999/05/08 21:59:29 dfr Exp $ + * $Id: atkbdc_isa.c,v 1.5 1999/05/09 20:45:53 peter Exp $ */ #include "atkbdc.h" @@ -65,6 +65,8 @@ static int atkbdc_write_ivar(device_t bus, device_t dev, int index, static device_method_t atkbdc_methods[] = { DEVMETHOD(device_probe, atkbdc_probe), DEVMETHOD(device_attach, atkbdc_attach), + DEVMETHOD(device_suspend, bus_generic_suspend), + DEVMETHOD(device_resume, bus_generic_resume), DEVMETHOD(bus_print_child, atkbdc_print_child), DEVMETHOD(bus_read_ivar, atkbdc_read_ivar), @@ -88,31 +90,12 @@ static driver_t atkbdc_driver = { static int atkbdc_probe(device_t dev) { - atkbdc_softc_t *sc; - int unit; int error; - unit = device_get_unit(dev); - sc = *(atkbdc_softc_t **)device_get_softc(dev); - if (sc == NULL) { - /* - * We have to maintain two copies of the kbdc_softc struct, - * as the low-level console needs to have access to the - * keyboard controller before kbdc is probed and attached. - * kbdc_soft[] contains the default entry for that purpose. - * See atkbdc.c. XXX - */ - sc = atkbdc_get_softc(unit); - if (sc == NULL) - return ENOMEM; - } - device_set_desc(dev, "keyboard controller (i8042)"); - - error = atkbdc_probe_unit(sc, unit, isa_get_port(dev)); + error = atkbdc_probe_unit(device_get_unit(dev), isa_get_port(dev)); if (error == 0) - *(atkbdc_softc_t **)device_get_softc(dev) = sc; - + isa_set_portsize(dev, IO_KBDSIZE); return error; } @@ -148,11 +131,29 @@ static int atkbdc_attach(device_t dev) { atkbdc_softc_t *sc; + int unit; + int error; int i; + unit = device_get_unit(dev); sc = *(atkbdc_softc_t **)device_get_softc(dev); - if ((sc == NULL) || (sc->port <= 0)) - return ENXIO; + if (sc == NULL) { + /* + * We have to maintain two copies of the kbdc_softc struct, + * as the low-level console needs to have access to the + * keyboard controller before kbdc is probed and attached. + * kbdc_soft[] contains the default entry for that purpose. + * See atkbdc.c. XXX + */ + sc = atkbdc_get_softc(unit); + if (sc == NULL) + return ENOMEM; + } + + error = atkbdc_attach_unit(unit, sc, isa_get_port(dev)); + if (error) + return error; + *(atkbdc_softc_t **)device_get_softc(dev) = sc; /* * Add all devices configured to be attached to atkbdc0. diff --git a/sys/dev/atkbdc/atkbdcreg.h b/sys/dev/atkbdc/atkbdcreg.h index 81b0ad3..ccf64e4 100644 --- a/sys/dev/atkbdc/atkbdcreg.h +++ b/sys/dev/atkbdc/atkbdcreg.h @@ -27,7 +27,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: $ + * $Id: atkbdcreg.h,v 1.1 1999/01/09 02:44:50 yokota Exp $ * from kbdio.h,v 1.8 1998/09/25 11:55:46 yokota Exp */ @@ -201,7 +201,8 @@ typedef caddr_t KBDC; /* function prototypes */ atkbdc_softc_t *atkbdc_get_softc(int unit); -int atkbdc_probe_unit(atkbdc_softc_t *sc, int unit, int port); +int atkbdc_probe_unit(int unit, int port); +int atkbdc_attach_unit(int unit, atkbdc_softc_t *sc, int port); int atkbdc_configure(void); KBDC kbdc_open(int port); diff --git a/sys/dev/kbd/atkbdc.c b/sys/dev/kbd/atkbdc.c index 0f61835..537a457 100644 --- a/sys/dev/kbd/atkbdc.c +++ b/sys/dev/kbd/atkbdc.c @@ -27,7 +27,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: $ + * $Id: atkbdc.c,v 1.1 1999/01/09 02:44:50 yokota Exp $ * from kbdio.c,v 1.13 1998/09/25 11:55:46 yokota Exp */ @@ -116,7 +116,15 @@ atkbdc_softc_t } int -atkbdc_probe_unit(atkbdc_softc_t *sc, int unit, int port) +atkbdc_probe_unit(int unit, int port) +{ + if (port <= 0) + return ENXIO; + return 0; +} + +int +atkbdc_attach_unit(int unit, atkbdc_softc_t *sc, int port) { return atkbdc_setup(sc, port); } diff --git a/sys/dev/kbd/atkbdcreg.h b/sys/dev/kbd/atkbdcreg.h index 81b0ad3..ccf64e4 100644 --- a/sys/dev/kbd/atkbdcreg.h +++ b/sys/dev/kbd/atkbdcreg.h @@ -27,7 +27,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: $ + * $Id: atkbdcreg.h,v 1.1 1999/01/09 02:44:50 yokota Exp $ * from kbdio.h,v 1.8 1998/09/25 11:55:46 yokota Exp */ @@ -201,7 +201,8 @@ typedef caddr_t KBDC; /* function prototypes */ atkbdc_softc_t *atkbdc_get_softc(int unit); -int atkbdc_probe_unit(atkbdc_softc_t *sc, int unit, int port); +int atkbdc_probe_unit(int unit, int port); +int atkbdc_attach_unit(int unit, atkbdc_softc_t *sc, int port); int atkbdc_configure(void); KBDC kbdc_open(int port); |