diff options
author | David Gwynne <dlg@cvs.openbsd.org> | 2007-02-19 12:04:02 +0000 |
---|---|---|
committer | David Gwynne <dlg@cvs.openbsd.org> | 2007-02-19 12:04:02 +0000 |
commit | d8c36eb7b3ac43753d22eb50fb34cc00b7aeb14a (patch) | |
tree | 3d4f575470ae494f6d264fa15d0bc3d0cfc9c59c /sys/dev/ata | |
parent | 37ebaf159aba995950aaa1567e12448c3fbf63b8 (diff) |
code to set up a global pool for allocating ata_xfers out of, and for
accessing that pool.
Diffstat (limited to 'sys/dev/ata')
-rw-r--r-- | sys/dev/ata/atascsi.c | 54 |
1 files changed, 51 insertions, 3 deletions
diff --git a/sys/dev/ata/atascsi.c b/sys/dev/ata/atascsi.c index 11d3fad099a..69aaad24b3e 100644 --- a/sys/dev/ata/atascsi.c +++ b/sys/dev/ata/atascsi.c @@ -1,4 +1,4 @@ -/* $OpenBSD: atascsi.c,v 1.5 2007/02/19 11:57:45 dlg Exp $ */ +/* $OpenBSD: atascsi.c,v 1.6 2007/02/19 12:04:01 dlg Exp $ */ /* * Copyright (c) 2007 David Gwynne <dlg@openbsd.org> @@ -23,6 +23,7 @@ #include <sys/malloc.h> #include <sys/device.h> #include <sys/proc.h> +#include <sys/pool.h> #include <sys/queue.h> #include <scsi/scsi_all.h> @@ -43,8 +44,6 @@ struct atascsi { struct scsibus_softc *as_scsibus; }; -int atascsi_probe(struct atascsi *, int); - int atascsi_cmd(struct scsi_xfer *); /* template */ @@ -60,6 +59,8 @@ struct scsi_device atascsi_device = { NULL, NULL, NULL, NULL }; +int atascsi_probe(struct atascsi *, int); + int atascsi_disk_cmd(struct scsi_xfer *); int atascsi_disk_inq(struct scsi_xfer *); int atascsi_disk_capacity(struct scsi_xfer *); @@ -70,6 +71,16 @@ int atascsi_atapi_cmd(struct scsi_xfer *); int atascsi_stuffup(struct scsi_xfer *); + +int ata_running = 0; +struct pool ata_xfer_pool; + +void ata_init(void); +void ata_destroy(void); + +struct ata_xfer *ata_get_xfer(int); +void ata_put_xfer(struct ata_xfer *); + struct atascsi * atascsi_attach(struct device *self, struct atascsi_attach_args *aaa) { @@ -249,3 +260,40 @@ atascsi_stuffup(struct scsi_xfer *xs) splx(s); return (COMPLETE); } + +void +ata_init(void) +{ + if (ata_running++) + return; + + pool_init(&ata_xfer_pool, sizeof(struct ata_xfer), 0, 0, 0, "xapl", + NULL); +} + +void +ata_destroy(void) +{ + if (--ata_running) + return; + + pool_destroy(&ata_xfer_pool); +} + +struct ata_xfer * +ata_get_xfer(int nosleep) +{ + struct ata_xfer *xa; + + xa = pool_get(&ata_xfer_pool, nosleep ? PR_NOWAIT : PR_WAITOK); + + return (xa); +} + +void +ata_put_xfer(struct ata_xfer *xa) +{ + pool_put(&ata_xfer_pool, xa); +} + + |