[69300] | 1 | /* $Id: vds.h 98103 2023-01-17 14:15:46Z vboxsync $ */
|
---|
| 2 | /** @file
|
---|
| 3 | * Utility routines for calling the Virtual DMA Services.
|
---|
| 4 | */
|
---|
| 5 |
|
---|
| 6 | /*
|
---|
[98103] | 7 | * Copyright (C) 2006-2023 Oracle and/or its affiliates.
|
---|
[69300] | 8 | *
|
---|
[96407] | 9 | * This file is part of VirtualBox base platform packages, as
|
---|
| 10 | * available from https://www.virtualbox.org.
|
---|
| 11 | *
|
---|
| 12 | * This program is free software; you can redistribute it and/or
|
---|
| 13 | * modify it under the terms of the GNU General Public License
|
---|
| 14 | * as published by the Free Software Foundation, in version 3 of the
|
---|
| 15 | * License.
|
---|
| 16 | *
|
---|
| 17 | * This program is distributed in the hope that it will be useful, but
|
---|
| 18 | * WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
| 20 | * General Public License for more details.
|
---|
| 21 | *
|
---|
| 22 | * You should have received a copy of the GNU General Public License
|
---|
| 23 | * along with this program; if not, see <https://www.gnu.org/licenses>.
|
---|
| 24 | *
|
---|
| 25 | * SPDX-License-Identifier: GPL-3.0-only
|
---|
[69300] | 26 | */
|
---|
| 27 |
|
---|
[76565] | 28 | #ifndef VBOX_INCLUDED_SRC_PC_BIOS_vds_h
|
---|
| 29 | #define VBOX_INCLUDED_SRC_PC_BIOS_vds_h
|
---|
[76520] | 30 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
| 31 | # pragma once
|
---|
| 32 | #endif
|
---|
[69300] | 33 |
|
---|
[38899] | 34 | /* Virtual DMA Services (VDS) */
|
---|
| 35 |
|
---|
[42202] | 36 | #define VDS_FLAGS_OFS 0x7B /* Offset of VDS flag byte in BDA. */
|
---|
| 37 | #define VDS_PRESENT 0x20 /* The VDS present bit. */
|
---|
[38899] | 38 |
|
---|
[69300] | 39 | /** The DMA descriptor data structure. */
|
---|
| 40 | typedef struct
|
---|
| 41 | {
|
---|
[42202] | 42 | uint32_t region_size; /* Region size in bytes. */
|
---|
| 43 | uint32_t offset; /* Offset. */
|
---|
| 44 | uint16_t seg_sel; /* Segment selector. */
|
---|
| 45 | uint16_t buf_id; /* Buffer ID. */
|
---|
| 46 | uint32_t phys_addr; /* Physical address. */
|
---|
[38899] | 47 | } vds_dds;
|
---|
| 48 |
|
---|
| 49 |
|
---|
[69300] | 50 | /** Scatter/gather descriptor entry. */
|
---|
| 51 | typedef struct
|
---|
| 52 | {
|
---|
[42202] | 53 | uint32_t phys_addr; /* Physical address. */
|
---|
| 54 | uint32_t size; /* Entry size. */
|
---|
[38899] | 55 | } vds_sg;
|
---|
| 56 |
|
---|
[69300] | 57 | /** The extended DDS for scatter/gather.
|
---|
| 58 | * Note that the EDDS contains either S/G descriptors or x86-style PTEs.
|
---|
[38899] | 59 | */
|
---|
[69300] | 60 | typedef struct
|
---|
| 61 | {
|
---|
[42202] | 62 | uint32_t region_size; /* Region size in bytes. */
|
---|
| 63 | uint32_t offset; /* Offset. */
|
---|
| 64 | uint16_t seg_sel; /* Segment or selector. */
|
---|
| 65 | uint16_t resvd; /* Reserved. */
|
---|
| 66 | uint16_t num_avail; /* Number of entries available. */
|
---|
| 67 | uint16_t num_used; /* Number of entries used. */
|
---|
[69300] | 68 | union
|
---|
| 69 | {
|
---|
[42202] | 70 | vds_sg sg[1]; /* S/G entry array. */
|
---|
| 71 | uint32_t pte[1]; /* Page table entry array. */
|
---|
[38899] | 72 | } u;
|
---|
| 73 | } vds_edds;
|
---|
| 74 |
|
---|
[48947] | 75 |
|
---|
[38899] | 76 | /* VDS services */
|
---|
| 77 |
|
---|
[42202] | 78 | #define VDS_SERVICE 0x81
|
---|
[38899] | 79 |
|
---|
[42202] | 80 | #define VDS_GET_VERSION 0x02 /* Get version */
|
---|
| 81 | #define VDS_LOCK_BUFFER 0x03 /* Lock DMA buffer region */
|
---|
| 82 | #define VDS_UNLOCK_BUFFER 0x04 /* Unlock DMA buffer region */
|
---|
| 83 | #define VDS_SG_LOCK 0x05 /* Scatter/gather lock region */
|
---|
| 84 | #define VDS_SG_UNLOCK 0x06 /* Scatter/gather unlock region */
|
---|
| 85 | #define VDS_REQUEST_BUFFER 0x07 /* Request DMA buffer */
|
---|
| 86 | #define VDS_RELEASE_BUFFER 0x08 /* Release DMA buffer */
|
---|
| 87 | #define VDS_BUFFER_COPYIN 0x09 /* Copy into DMA buffer */
|
---|
| 88 | #define VDS_BUFFER_COPYOUT 0x0A /* Copy out of DMA buffer */
|
---|
| 89 | #define VDS_DISABLE_DMA_XLAT 0x0B /* Disable DMA translation */
|
---|
| 90 | #define VDS_ENABLE_DMA_XLAT 0x0C /* Enable DMA translation */
|
---|
[38899] | 91 |
|
---|
| 92 | /* VDS error codes */
|
---|
| 93 |
|
---|
[42202] | 94 | #define VDS_SUCCESS 0x00 /* No error */
|
---|
| 95 | #define VDS_ERR_NOT_CONTIG 0x01 /* Region not contiguous */
|
---|
| 96 | #define VDS_ERR_BOUNDRY_CROSS 0x02 /* Rgn crossed phys align boundary */
|
---|
| 97 | #define VDS_ERR_CANT_LOCK 0x03 /* Unable to lock pages */
|
---|
| 98 | #define VDS_ERR_NO_BUF 0x04 /* No buffer available */
|
---|
| 99 | #define VDS_ERR_RGN_TOO_BIG 0x05 /* Region too large for buffer */
|
---|
| 100 | #define VDS_ERR_BUF_IN_USE 0x06 /* Buffer currently in use */
|
---|
| 101 | #define VDS_ERR_RGN_INVALID 0x07 /* Invalid memory region */
|
---|
| 102 | #define VDS_ERR_RGN_NOT_LOCKED 0x08 /* Region was not locked */
|
---|
| 103 | #define VDS_ERR_TOO_MANY_PAGES 0x09 /* Num pages greater than table len */
|
---|
| 104 | #define VDS_ERR_INVALID_ID 0x0A /* Invalid buffer ID */
|
---|
| 105 | #define VDS_ERR_BNDRY_VIOL 0x0B /* Buffer boundary violated */
|
---|
| 106 | #define VDS_ERR_INVAL_DMACHN 0x0C /* Invalid DMA channel number */
|
---|
| 107 | #define VDS_ERR_COUNT_OVRFLO 0x0D /* Disable count overflow */
|
---|
| 108 | #define VDS_ERR_COUNT_UNDRFLO 0x0E /* Disable count underflow */
|
---|
| 109 | #define VDS_ERR_UNSUPP_FUNC 0x0F /* Function not supported */
|
---|
| 110 | #define VDS_ERR_BAD_FLAG 0x10 /* Reserved flag bits set in DX */
|
---|
[38899] | 111 |
|
---|
| 112 | /* VDS option flags */
|
---|
| 113 |
|
---|
[42202] | 114 | #define VDSF_AUTOCOPY 0x02 /* Automatic copy to/from buffer */
|
---|
| 115 | #define VDSF_NOALLOC 0x04 /* Disable auto buffer allocation */
|
---|
| 116 | #define VDSF_NOREMAP 0x08 /* Disable auto remap feature */
|
---|
| 117 | #define VDSF_NO64K 0x10 /* Region can't cross 64K boundary */
|
---|
| 118 | #define VDSF_NO128K 0x20 /* Region can't cross 128K boundary */
|
---|
| 119 | #define VDSF_COPYTBL 0x40 /* Copy page table for S/G remap */
|
---|
| 120 | #define VDSF_NPOK 0x80 /* Allow non-present pages for S/G */
|
---|
[38899] | 121 |
|
---|
| 122 | /* Higher level routines for utilizing VDS. */
|
---|
| 123 |
|
---|
[39559] | 124 | int vds_build_sg_list( vds_edds __far *edds, void __far *buf, uint32_t len );
|
---|
[38899] | 125 | int vds_free_sg_list( vds_edds __far *edds );
|
---|
| 126 |
|
---|
| 127 | /* Helper for translating 16:16 real mode addresses to 32-bit linear. */
|
---|
| 128 |
|
---|
| 129 | uint32_t vds_real_to_lin( void __far *ptr );
|
---|
[69300] | 130 |
|
---|
[76565] | 131 | #endif /* !VBOX_INCLUDED_SRC_PC_BIOS_vds_h */
|
---|
[76519] | 132 |
|
---|