Created
January 29, 2020 17:26
-
-
Save froggey/0873a7a7ce624c888ed3d0b58127324f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (defun make-dma-buffer (length &key persistent contiguous 32-bit element-type cache-mode) | |
| "Allocate a new DMA buffer of the given length. | |
| PERSISTENT - If true, the memory will be saved by a snapshot, though the | |
| physical addresses may change between boots. | |
| CONTIGUOUS - Allocate physical memory in a single contiguous chunk. The | |
| resulting DMA buffer will have exactly one scatter/gather entry. | |
| Allocation may fail and signal an error even if there is | |
| sufficient memory, as it might not be contiguous. | |
| 32-BIT - If true, all allocated physical memory will be below the 32-bit | |
| boundary. | |
| ELEMENT-TYPE - The element type of the buffer array. This does not affect | |
| direct access to virtual memory. | |
| CACHE-MODE - Select between :WRITE-BACK, :WRITE-THROUGH, :WRITE-COMBINING, and | |
| :UNCACHED caching modes. Defaults to :WRITE-BACK. | |
| If the DMA buffer is not persistent, then the memory will be lost and become | |
| inaccessible when the machine is booted. Attempts to access it from Lisp (either | |
| directly or via the buffer array) will signal a DMA-BUFFER-EXPIRED error. | |
| Memory will be freed automatically when the returned dma buffer object dies." | |
| ...) | |
| (define-condition dma-buffer-expired (error) ...) | |
| (defun dma-buffer-length (dma-buffer) ...) | |
| (defun dma-buffer-persistent-p (dma-buffer) ...) | |
| (defun dma-buffer-contiguous-p (dma-buffer) ...) | |
| (defun dma-buffer-element-type (dma-buffer) ...) | |
| (defun dma-buffer-cache-mode (dma-buffer) ...) | |
| (defun dma-buffer-cache-flush (dma-buffer &optional (start 0) end) | |
| "Ensure any data that may be cached by the CPU is written out to system memory." | |
| ...) | |
| (defun dma-buffer-physical-address (dma-buffer) | |
| "Return the physial address of DMA-BUFFER. | |
| This is only valid on DMA buffers that are contiguous or <= one page in size." | |
| ...) | |
| (defun dma-buffer-n-sg-entries (dma-buffer) | |
| "Return the number of scatter/gather entries in DMA-BUFFER. | |
| For contiguous buffers this will always return 1." | |
| ...) | |
| (defun dma-buffer-sg-entry (dma-buffer entry) | |
| "Return the physical address and length as values of specified scatter/gather entry." | |
| ...) | |
| (defun dma-buffer-array (dma-buffer) | |
| "Return a 1D array (for use with AREF) that is backed by the DMA buffer memory." | |
| ...) | |
| (defun dma-buffer-virtual-address (dma-buffer) | |
| "Return the virtual address where DMA-BUFFER is mapped. | |
| DMA-BUFFER must be kept live when accessing this memory." | |
| ...) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment