2
* Utility routines for calling the Virtual DMA Services.
6
* Copyright (C) 2011 Oracle Corporation
8
* This file is part of VirtualBox Open Source Edition (OSE), as
9
* available from http://www.virtualbox.org. This file is free software;
10
* you can redistribute it and/or modify it under the terms of the GNU
11
* General Public License (GPL) as published by the Free Software
12
* Foundation, in version 2 as it comes in the "COPYING" file of the
13
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
14
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
23
uint8_t major; /* VDS spec major version number. */
24
uint8_t minor; /* VDS spec minor version number. */
25
uint16_t flags; /* Capabilities/status flags. */
26
uint16_t prod_no; /* Product number. */
27
uint16_t prod_rev; /* Product revision number. */
28
uint32_t max_buf; /* Maximum buffer size supported. */
31
int vds_is_present( void )
33
uint8_t __far *vds_flags;
35
vds_flags = MK_FP( 0x40, VDS_FLAGS_OFS );
36
return( !!(*vds_flags & VDS_PRESENT) );
39
int vds_lock_sg( vds_edds __far *edds );
40
#pragma aux vds_lock_sg = \
48
parm [es di] value [ax];
50
int vds_unlock_sg( vds_edds __far *edds );
51
#pragma aux vds_unlock_sg = \
59
parm [es di] value [ax];
63
* Convert a real mode 16:16 segmented address to a simple 32-bit
66
uint32_t vds_real_to_lin( void __far *ptr )
68
return( ((uint32_t)FP_SEG( ptr ) << 4) + FP_OFF( ptr ) );
72
* Build a VDS-style scatter/gather list, regardless of whether VDS is
73
* present or not. This routine either calls VDS to do the work or
74
* trivially creates the list if no remapping is needed.
76
int vds_build_sg_list( vds_edds __far *edds, void __far *buf, uint32_t len )
80
/* NB: The num_avail field in the EDDS must be set correctly! */
81
edds->region_size = len;
82
edds->offset = vds_real_to_lin( buf );
83
edds->seg_sel = 0; /* Indicates a linear address. */
84
if( vds_is_present() ) {
85
/* VDS is present, use it. */
86
rc = vds_lock_sg( edds );
88
/* No VDS, do it ourselves with one S/G entry. */
90
edds->u.sg[0].phys_addr = edds->offset;
91
edds->u.sg[0].size = len;
98
* Free a VDS-style scatter/gather list, regardless of whether VDS
101
int vds_free_sg_list( vds_edds __far *edds )
105
if( vds_is_present() ) {
106
/* VDS is present, use it. */
107
rc = vds_unlock_sg( edds );
109
/* No VDS, not much to do. */
110
/* We could check here if the EDDS had in fact been built by us.
111
* But if VDS really went away, what can we do about it anyway?