Implement unload and sync operations.

This commit is contained in:
Marcel Moolenaar 2015-07-03 05:44:58 +00:00
parent 9d0e5a1718
commit 42d3ab5d1b
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=285074
2 changed files with 45 additions and 0 deletions

View File

@ -306,6 +306,28 @@ proto_busdma_md_load(struct proto_busdma *busdma, struct proto_md *md,
return (0);
}
static int
proto_busdma_md_unload(struct proto_busdma *busdma, struct proto_md *md)
{
if (!md->physaddr)
return (ENXIO);
bus_dmamap_unload(md->bd_tag, md->bd_map);
md->physaddr = 0;
return (0);
}
static int
proto_busdma_sync(struct proto_busdma *busdma, struct proto_md *md,
struct proto_ioc_busdma *ioc)
{
if (!md->physaddr)
return (ENXIO);
bus_dmamap_sync(md->bd_tag, md->bd_map, ioc->u.sync.op);
return (0);
}
static struct proto_md *
proto_busdma_md_lookup(struct proto_busdma *busdma, u_long key)
{
@ -419,6 +441,22 @@ proto_busdma_ioctl(struct proto_softc *sc, struct proto_busdma *busdma,
}
error = proto_busdma_md_load(busdma, md, ioc, td);
break;
case PROTO_IOC_BUSDMA_MD_UNLOAD:
md = proto_busdma_md_lookup(busdma, ioc->key);
if (md == NULL) {
error = EINVAL;
break;
}
error = proto_busdma_md_unload(busdma, md);
break;
case PROTO_IOC_BUSDMA_SYNC:
md = proto_busdma_md_lookup(busdma, ioc->key);
if (md == NULL) {
error = EINVAL;
break;
}
error = proto_busdma_sync(busdma, md, ioc);
break;
default:
error = EINVAL;
break;

View File

@ -50,6 +50,8 @@ struct proto_ioc_busdma {
#define PROTO_IOC_BUSDMA_MD_CREATE 20
#define PROTO_IOC_BUSDMA_MD_DESTROY 21
#define PROTO_IOC_BUSDMA_MD_LOAD 22
#define PROTO_IOC_BUSDMA_MD_UNLOAD 29
#define PROTO_IOC_BUSDMA_SYNC 30
unsigned long key;
union {
struct {
@ -72,6 +74,11 @@ struct proto_ioc_busdma {
unsigned long bus_addr;
unsigned int bus_nsegs;
} md;
struct {
unsigned int op;
unsigned long base;
unsigned long size;
} sync;
} u;
unsigned long result;
};