summaryrefslogtreecommitdiff
path: root/sys/dev
diff options
context:
space:
mode:
authorAlexander Yurchenko <grange@cvs.openbsd.org>2006-09-29 19:38:53 +0000
committerAlexander Yurchenko <grange@cvs.openbsd.org>2006-09-29 19:38:53 +0000
commit8c967acc0e8a0433a9436bf0460349f3d37aa74a (patch)
treee57c71ec13a6f653dc5d17d159a879c7dde044f7 /sys/dev
parentb5bda7b5f4907a3fb96ec778992b94852d2fc4d1 (diff)
Extend bus master interface so that block read/write operations
can be offloaded to hardware.
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/onewire/onewire.c48
-rw-r--r--sys/dev/onewire/onewirevar.h6
2 files changed, 33 insertions, 21 deletions
diff --git a/sys/dev/onewire/onewire.c b/sys/dev/onewire/onewire.c
index 9860dfb1301..0873c4b97d9 100644
--- a/sys/dev/onewire/onewire.c
+++ b/sys/dev/onewire/onewire.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: onewire.c,v 1.2 2006/08/03 18:48:13 grange Exp $ */
+/* $OpenBSD: onewire.c,v 1.3 2006/09/29 19:38:52 grange Exp $ */
/*
* Copyright (c) 2006 Alexander Yurchenko <grange@openbsd.org>
@@ -240,6 +240,34 @@ onewire_write_byte(void *arg, int value)
bus->bus_bit(bus->bus_cookie, (value >> i) & 0x1);
}
+void
+onewire_read_block(void *arg, void *buf, int len)
+{
+ struct onewire_softc *sc = arg;
+ struct onewire_bus *bus = sc->sc_bus;
+ u_int8_t *p = buf;
+
+ if (bus->bus_read_block != NULL)
+ return (bus->bus_read_block(bus->bus_cookie, buf, len));
+
+ while (len--)
+ *p++ = onewire_read_byte(arg);
+}
+
+void
+onewire_write_block(void *arg, const void *buf, int len)
+{
+ struct onewire_softc *sc = arg;
+ struct onewire_bus *bus = sc->sc_bus;
+ const u_int8_t *p = buf;
+
+ if (bus->bus_write_block != NULL)
+ return (bus->bus_write_block(bus->bus_cookie, buf, len));
+
+ while (len--)
+ onewire_write_byte(arg, *p++);
+}
+
int
onewire_triplet(void *arg, int dir)
{
@@ -269,24 +297,6 @@ onewire_triplet(void *arg, int dir)
}
void
-onewire_read_block(void *arg, void *buf, int len)
-{
- u_int8_t *p = buf;
-
- while (len--)
- *p++ = onewire_read_byte(arg);
-}
-
-void
-onewire_write_block(void *arg, const void *buf, int len)
-{
- const u_int8_t *p = buf;
-
- while (len--)
- onewire_write_byte(arg, *p++);
-}
-
-void
onewire_matchrom(void *arg, u_int64_t rom)
{
int i;
diff --git a/sys/dev/onewire/onewirevar.h b/sys/dev/onewire/onewirevar.h
index 51b7ea4a434..9da8c335bff 100644
--- a/sys/dev/onewire/onewirevar.h
+++ b/sys/dev/onewire/onewirevar.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: onewirevar.h,v 1.1 2006/03/04 16:27:03 grange Exp $ */
+/* $OpenBSD: onewirevar.h,v 1.2 2006/09/29 19:38:52 grange Exp $ */
/*
* Copyright (c) 2006 Alexander Yurchenko <grange@openbsd.org>
@@ -31,6 +31,8 @@ struct onewire_bus {
int (*bus_bit)(void *, int);
int (*bus_read_byte)(void *);
void (*bus_write_byte)(void *, int);
+ void (*bus_read_block)(void *, void *, int);
+ void (*bus_write_block)(void *, const void *, int);
int (*bus_triplet)(void *, int);
};
@@ -41,9 +43,9 @@ int onewire_reset(void *);
int onewire_bit(void *, int);
int onewire_read_byte(void *);
void onewire_write_byte(void *, int);
-int onewire_triplet(void *, int);
void onewire_read_block(void *, void *, int);
void onewire_write_block(void *, const void *, int);
+int onewire_triplet(void *, int);
void onewire_matchrom(void *, u_int64_t);
#define ONEWIRE_NOWAIT 0x0001