aboutsummaryrefslogtreecommitdiff
path: root/vbox.c
diff options
context:
space:
mode:
authorJavier <dev.git@javispedro.com>2022-04-15 09:32:31 +0200
committerJavier <dev.git@javispedro.com>2022-04-15 09:32:31 +0200
commit528069dc5992bd069a3c1783db50d630c3d355b4 (patch)
treef7557ae7158d5c3bb781961fa695718407975781 /vbox.c
parenta84f04eb1be124e7fdefb486bf01626ff96d2d04 (diff)
downloadvbados-528069dc5992bd069a3c1783db50d630c3d355b4.tar.gz
vbados-528069dc5992bd069a3c1783db50d630c3d355b4.zip
use different buffer sizes for vbx mouse & sf
Diffstat (limited to 'vbox.c')
-rw-r--r--vbox.c28
1 files changed, 14 insertions, 14 deletions
diff --git a/vbox.c b/vbox.c
index eb05f1b..8c6d28a 100644
--- a/vbox.c
+++ b/vbox.c
@@ -77,18 +77,19 @@ int vbox_init_device(LPVBOXCOMM vb)
return 0;
}
-int vbox_init_buffer(LPVBOXCOMM vb)
+int vbox_init_buffer(LPVBOXCOMM vb, unsigned size)
{
+ vb->dds.regionSize = size;
+ vb->dds.segOrSelector = FP_SEG(&vb->buf);
+ vb->dds.offset = FP_OFF(&vb->buf);
+ vb->dds.bufferId = 0;
+ vb->dds.physicalAddress = 0;
+ vb->vds = false;
+
if (vds_available()) {
// Use the Virtual DMA Service to get the physical address of this buffer
int err;
- vb->dds.regionSize = sizeof(vb->buf);
- vb->dds.segOrSelector = FP_SEG(&vb->buf);
- vb->dds.offset = FP_OFF(&vb->buf);
- vb->dds.bufferId = 0;
- vb->dds.physicalAddress = 0;
-
err = vds_lock_dma_buffer_region(&vb->dds, VDS_NO_AUTO_ALLOC);
if (err) {
// As far as I have seen, most VDS providers always keep low memory contiguous,
@@ -98,12 +99,11 @@ int vbox_init_buffer(LPVBOXCOMM vb)
dlog_endline();
return err;
}
- } else {
- vb->dds.regionSize = 0; // So that we don't try to unlock it later
- vb->dds.segOrSelector = FP_SEG(&vb->buf);
- vb->dds.offset = FP_OFF(&vb->buf);
- vb->dds.bufferId = 0;
+ vb->vds = true;
+ } else {
+ // If VDS is not available,
+ // we assume a 1:1 mapping between linear and physical addresses
vb->dds.physicalAddress = linear_addr(&vb->buf);
}
@@ -112,8 +112,7 @@ int vbox_init_buffer(LPVBOXCOMM vb)
int vbox_release_buffer(LPVBOXCOMM vb)
{
- if (vds_available() && vb->dds.regionSize) {
-
+ if (vb->vds && vds_available()) {
int err = vds_unlock_dma_buffer_region(&vb->dds, 0);
if (err) {
dlog_print("Error while VDS unlocking, err=");
@@ -122,6 +121,7 @@ int vbox_release_buffer(LPVBOXCOMM vb)
// Ignore the error, it's not like we can do anything
}
}
+ vb->vds = false;
vb->dds.regionSize = 0;
vb->dds.segOrSelector = 0;
vb->dds.offset = 0;