1*41ce3b17Snaddy.\" $OpenBSD: dma_alloc.9,v 1.8 2022/03/31 17:27:23 naddy Exp $ 286a63ab3Sderaadt.\" $NetBSD: pool.9,v 1.18 2001/06/21 11:59:01 wiz Exp $ 386a63ab3Sderaadt.\" 486a63ab3Sderaadt.\" Copyright (c) 2011 Theo de Raadt 586a63ab3Sderaadt.\" All rights reserved. 686a63ab3Sderaadt.\" 786a63ab3Sderaadt.\" Permission to use, copy, modify, and distribute this software for any 886a63ab3Sderaadt.\" purpose with or without fee is hereby granted, provided that the above 986a63ab3Sderaadt.\" copyright notice and this permission notice appear in all copies. 1086a63ab3Sderaadt.\" 1186a63ab3Sderaadt.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 1286a63ab3Sderaadt.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 1386a63ab3Sderaadt.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 1486a63ab3Sderaadt.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 1586a63ab3Sderaadt.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 1686a63ab3Sderaadt.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 1786a63ab3Sderaadt.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 1886a63ab3Sderaadt.\" 19*41ce3b17Snaddy.Dd $Mdocdate: March 31 2022 $ 2086a63ab3Sderaadt.Dt DMA_ALLOC 9 2186a63ab3Sderaadt.Os 2286a63ab3Sderaadt.Sh NAME 2386a63ab3Sderaadt.Nm dma_alloc , 2486a63ab3Sderaadt.Nm dma_free 25b3fd5372Smatthew.Nd DMA-safe memory allocator 2686a63ab3Sderaadt.Sh SYNOPSIS 27dddd2645Sschwarze.In sys/types.h 28dddd2645Sschwarze.In sys/pool.h 2986a63ab3Sderaadt.Ft void * 3086a63ab3Sderaadt.Fo dma_alloc 3186a63ab3Sderaadt.Fa "size_t size" 3286a63ab3Sderaadt.Fa "int flags" 3386a63ab3Sderaadt.Fc 3486a63ab3Sderaadt.Ft void 3586a63ab3Sderaadt.Fo dma_free 3686a63ab3Sderaadt.Fa "void *m" 3786a63ab3Sderaadt.Fa "size_t size" 3886a63ab3Sderaadt.Fc 3986a63ab3Sderaadt.Sh DESCRIPTION 40b3fd5372SmatthewThis allocator provides DMA-safe memory managed using the 41b3fd5372Smatthew.Xr pool 9 42b3fd5372Smatthewinterface. 43939c91bdSjmcIt is safe to call in most contexts and is 44939c91bdSjmctypically used for temporary buffers up to 65536 bytes. 45*41ce3b17SnaddyWhen buffers are used many times, it may be better to consider 4686a63ab3Sderaadtusing other DMA-safe allocators. 4786a63ab3Sderaadt.Pp 48939c91bdSjmcInterrupt protection is set to 4986a63ab3Sderaadt.Va IPL_VM 5086a63ab3Sderaadtusing 514efd9ef6Sjmc.Xr pool_init 9 . 5286a63ab3Sderaadt.Pp 5386a63ab3SderaadtThe 5486a63ab3Sderaadt.Ar flags 5586a63ab3Sderaadtargument is a selection of 56939c91bdSjmc.Xr pool_get 9 5786a63ab3Sderaadtflag arguments. 58dad257f2Sderaadt.Pp 59dad257f2SderaadtThe same 60dad257f2Sderaadt.Va size 61dad257f2Sderaadtargument must be passed to both 62dad257f2Sderaadt.Fn dma_alloc 63dad257f2Sderaadtand the subsequent 64dad257f2Sderaadt.Fn dma_free . 65dad257f2SderaadtAllocations over 65536 will fail. 6686a63ab3Sderaadt.Sh SEE ALSO 6786a63ab3Sderaadt.Xr bus_dma 9 , 68939c91bdSjmc.Xr mbuf 9 , 69939c91bdSjmc.Xr pool 9 70b3fd5372Smatthew.Sh HISTORY 71b3fd5372SmatthewThe 72b3fd5372Smatthew.Nm 73b3fd5372Smatthewinterface first appeared in 74b3fd5372Smatthew.Ox 4.8 . 75