From 3c6472bf20be2716a4a755244da69aabed7be192 Mon Sep 17 00:00:00 2001 From: David Gwynne Date: Tue, 12 Dec 2006 02:19:38 +0000 Subject: add wrappers for reading and writing a ports registers called ahci_pread, and ahci_pwrite. these will use an io handle into a window of the controllers register space that can be created with bus_space_subregion, and which is stored in the ahci_port struct. --- sys/dev/pci/ahci.c | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'sys/dev/pci') diff --git a/sys/dev/pci/ahci.c b/sys/dev/pci/ahci.c index 752a41ffa0c..8f33c2e1f4a 100644 --- a/sys/dev/pci/ahci.c +++ b/sys/dev/pci/ahci.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ahci.c,v 1.23 2006/12/12 02:13:32 dlg Exp $ */ +/* $OpenBSD: ahci.c,v 1.24 2006/12/12 02:19:37 dlg Exp $ */ /* * Copyright (c) 2006 David Gwynne @@ -180,6 +180,9 @@ struct ahci_ccb { }; struct ahci_port { + struct ahci_softc *ap_sc; + bus_space_handle_t ap_ioh; + struct ahci_ccb *ap_ccbs; TAILQ_HEAD(, ahci_ccb) ap_ccb_free; @@ -227,6 +230,8 @@ void ahci_dmamem_free(struct ahci_softc *, u_int32_t ahci_read(struct ahci_softc *, bus_size_t); void ahci_write(struct ahci_softc *, bus_size_t, u_int32_t); +u_int32_t ahci_pread(struct ahci_port *, bus_size_t); +void ahci_pwrite(struct ahci_port *, bus_size_t, u_int32_t); int ahci_wait_eq(struct ahci_softc *, bus_size_t, u_int32_t, u_int32_t); int ahci_wait_ne(struct ahci_softc *, bus_size_t, @@ -467,6 +472,22 @@ ahci_write(struct ahci_softc *sc, bus_size_t r, u_int32_t v) BUS_SPACE_BARRIER_WRITE); } +u_int32_t +ahci_pread(struct ahci_port *ap, bus_size_t r) +{ + bus_space_barrier(ap->ap_sc->sc_iot, ap->ap_ioh, r, 4, + BUS_SPACE_BARRIER_READ); + return (bus_space_read_4(ap->ap_sc->sc_iot, ap->ap_ioh, r)); +} + +void +ahci_pwrite(struct ahci_port *ap, bus_size_t r, u_int32_t v) +{ + bus_space_write_4(ap->ap_sc->sc_iot, ap->ap_ioh, r, v); + bus_space_barrier(ap->ap_sc->sc_iot, ap->ap_ioh, r, 4, + BUS_SPACE_BARRIER_WRITE); +} + int ahci_wait_eq(struct ahci_softc *sc, bus_size_t r, u_int32_t mask, u_int32_t target) -- cgit v1.2.3