diff options
author | Jaroslav Hensl <emulator@emulace.cz> | 2024-07-29 12:35:53 +0200 |
---|---|---|
committer | Jaroslav Hensl <emulator@emulace.cz> | 2024-07-29 12:35:53 +0200 |
commit | aa6a69c3b3e147581eb6f1339ae73e876841ef95 (patch) | |
tree | 4fba4a7a3774b12c924f8de81108364694977eb4 | |
parent | fa14048fc349d2a0d3ba58b313dcc3137a48dd1d (diff) | |
download | vmdisp9x-aa6a69c3b3e147581eb6f1339ae73e876841ef95.tar.gz |
critical sections reworked, resolution set fix
-rw-r--r-- | makefile | 2 | ||||
-rw-r--r-- | vmware/svga.c | 4 | ||||
-rw-r--r-- | vxd_lib.c | 37 | ||||
-rw-r--r-- | vxd_lib.h | 1 | ||||
-rw-r--r-- | vxd_main.c | 9 | ||||
-rw-r--r-- | vxd_mouse.c | 10 | ||||
-rw-r--r-- | vxd_svga.c | 16 | ||||
-rw-r--r-- | vxd_svga.h | 1 | ||||
-rw-r--r-- | vxd_svga_cb.c | 52 | ||||
-rw-r--r-- | vxd_svga_mem.c | 18 |
10 files changed, 37 insertions, 113 deletions
@@ -12,7 +12,7 @@ OBJS += & INCS = -I$(%WATCOM)\h\win -Iddk -Ivmware
-VER_BUILD = 70
+VER_BUILD = 71
FLAGS = -DDRV_VER_BUILD=$(VER_BUILD)
diff --git a/vmware/svga.c b/vmware/svga.c index 4bfe6e2..69bb245 100644 --- a/vmware/svga.c +++ b/vmware/svga.c @@ -534,6 +534,8 @@ SVGA_SetModeLegacy(uint32 width, // IN gSVGA.width = width; gSVGA.height = height; gSVGA.bpp = bpp; + + SVGA_Disable(); /* this is reset for virtualbox, otherwise sometimes ignore the changes */ SVGA_WriteReg(SVGA_REG_WIDTH, width); SVGA_WriteReg(SVGA_REG_HEIGHT, height); @@ -560,6 +562,8 @@ SVGA_SetModeLegacy(uint32 width, // IN SVGA_WriteReg(SVGA_REG_ENABLE, TRUE); gSVGA.pitch = SVGA_ReadReg(SVGA_REG_BYTES_PER_LINE); + + SVGA_Flush(); } @@ -162,42 +162,15 @@ volatile void __cdecl Begin_Critical_Section(ULONG Flags) static ULONG sFlags;
sFlags = Flags;
- if(cs_count == 0)
- {
- _asm push ecx
- _asm mov ecx, [sFlags]
- VMMCall(Begin_Critical_Section);
- _asm pop ecx
- }
- cs_count++;
+ _asm push ecx
+ _asm mov ecx, [sFlags]
+ VMMCall(Begin_Critical_Section);
+ _asm pop ecx
}
volatile void __cdecl End_Critical_Section()
{
- if(cs_count == 0)
- {
- dbg_printf(dbg_cs_underflow);
- return;
- }
-
- --cs_count;
- if(cs_count == 0)
- {
- VMMCall(End_Critical_Section);
- }
-}
-
-void Cleanup_Critical_Section()
-{
- if(cs_count > 0)
- {
- dbg_printf(dbg_cs_active);
-
- while(cs_count != 0)
- {
- End_Critical_Section();
- }
- }
+ VMMCall(End_Critical_Section);
}
ULONG __cdecl Create_Semaphore(ULONG TokenCount)
@@ -43,7 +43,6 @@ DWORD __cdecl _RegCloseKey(DWORD hKey); DWORD __cdecl _RegQueryValueEx(DWORD hKey, char *lpszValueName, DWORD *lpdwReserved, DWORD *lpdwType, BYTE *lpbData, DWORD *lpcbData);
volatile void __cdecl Begin_Critical_Section(ULONG Flags);
volatile void __cdecl End_Critical_Section();
-void Cleanup_Critical_Section();
ULONG __cdecl Create_Semaphore(ULONG TokenCount);
void __cdecl Destroy_Semaphore(ULONG SemHandle);
void __cdecl Wait_Semaphore(ULONG semHandle, ULONG flags);
@@ -229,6 +229,7 @@ WORD __stdcall VXD_API_Proc(PCRS_32 state) WORD service = state->Client_EDX & 0xFFFF;
// dbg_printf(dbg_vxd_api, service);
+ Begin_Critical_Section(0);
switch(service)
{
@@ -369,8 +370,6 @@ WORD __stdcall VXD_API_Proc(PCRS_32 state) }
- Cleanup_Critical_Section();
-
if(rc == 0xFFFF)
{
state->Client_EFlags |= 0x1; // set carry
@@ -380,6 +379,8 @@ WORD __stdcall VXD_API_Proc(PCRS_32 state) state->Client_EFlags &= 0xFFFFFFFEUL; // clear carry
}
+ End_Critical_Section();
+
return rc;
}
@@ -497,6 +498,8 @@ DWORD __stdcall Device_IO_Control_proc(DWORD vmhandle, struct DIOCParams *params DWORD *outBuf = (DWORD*)params->lpOutBuffer;
DWORD rc = 1;
+ Begin_Critical_Section(0);
+
//dbg_printf(dbg_deviceiocontrol, params->dwIoControlCode);
switch(params->dwIoControlCode)
@@ -642,8 +645,8 @@ DWORD __stdcall Device_IO_Control_proc(DWORD vmhandle, struct DIOCParams *params break;
}
- Cleanup_Critical_Section();
//dbg_printf(dbg_deviceiocontrol_leave);
+ End_Critical_Section();
return rc;
}
diff --git a/vxd_mouse.c b/vxd_mouse.c index 6c11747..be4b7b1 100644 --- a/vxd_mouse.c +++ b/vxd_mouse.c @@ -116,7 +116,6 @@ BOOL mouse_load() /* erase cursor if present */
FBHDA_access_begin(0);
- Begin_Critical_Section(0);
mouse_valid = FALSE;
/* check and alocate/resize buffer */
@@ -152,8 +151,6 @@ BOOL mouse_load() mouse_xormask_data == NULL ||
mouse_swap_data == NULL)
{
- End_Critical_Section();
-
FBHDA_access_end(0);
return FALSE;
}
@@ -190,8 +187,7 @@ BOOL mouse_load() mouse_empty = cursor_is_empty();
//dbg_printf(dbg_cursor_empty, mouse_empty);
- End_Critical_Section();
-
+
/* blit new cursor */
FBHDA_access_end(0);
@@ -276,10 +272,8 @@ BOOL mouse_blit() {
if(mouse_valid && mouse_visible && !mouse_empty)
{
- Begin_Critical_Section(0);
draw_save(mouse_x, mouse_y);
draw_blit(mouse_x, mouse_y);
- End_Critical_Section();
return TRUE;
}
@@ -291,8 +285,6 @@ void mouse_erase() {
if(mouse_valid && mouse_visible && !mouse_empty)
{
- Begin_Critical_Section(0);
draw_restore();
- End_Critical_Section();
}
}
@@ -730,7 +730,7 @@ static void SVGA_defineScreen(DWORD w, DWORD h, DWORD bpp) }
}
- submit_cmdbuf(cmdoff, SVGA_CB_SYNC/*|SVGA_CB_FORCE_FIFO*/, 0);
+ submit_cmdbuf(cmdoff, SVGA_CB_SYNC|SVGA_CB_FORCE_FIFO, 0);
}
@@ -795,12 +795,11 @@ BOOL SVGA_setmode(DWORD w, DWORD h, DWORD bpp) mouse_invalidate();
FBHDA_access_begin(0);
- Begin_Critical_Section(0);
//SVGA_OTable_unload(); // unload otables
/* Make sure, that we drain full FIFO */
SVGA_Sync();
- SVGA_Flush_CB_critical();
+ SVGA_Flush_CB();
#if 0
/* delete old screen at its objects */
@@ -810,7 +809,7 @@ BOOL SVGA_setmode(DWORD w, DWORD h, DWORD bpp) {
st_destroyScreen();
SVGA_Sync();
- SVGA_Flush_CB_critical();
+ SVGA_Flush_CB();
}
}
/* JH: OK, we should normally clean after ourselves,
@@ -836,7 +835,7 @@ BOOL SVGA_setmode(DWORD w, DWORD h, DWORD bpp) /* VMware, vGPU10: OK, when screen has change, whoale GPU is reset including FIFO */
SVGA_Enable();
- SVGA_Flush_CB_critical(); /* make sure, that is really set */
+ SVGA_Flush(); /* make sure, that is really set */
/* setting screen by fifo, this method is required in VB 6.1 */
if(SVGA_hasAccelScreen())
@@ -849,8 +848,9 @@ BOOL SVGA_setmode(DWORD w, DWORD h, DWORD bpp) SVGA_Enable();
}
- SVGA_Flush_CB_critical();
+ SVGA_Flush();
}
+ SVGA_Sync();
/* start command buffer context 0 */
SVGA_CB_start();
@@ -858,7 +858,7 @@ BOOL SVGA_setmode(DWORD w, DWORD h, DWORD bpp) has3D = SVGA3D_Init();
SVGA_Sync();
- SVGA_Flush_CB_critical();
+ SVGA_Flush_CB();
if(st_useable(bpp))
{
@@ -914,8 +914,6 @@ BOOL SVGA_setmode(DWORD w, DWORD h, DWORD bpp) hda->flags &= ~((DWORD)FB_ACCEL_VMSVGA3D);
}
- End_Critical_Section();
-
mouse_invalidate();
FBHDA_access_end(0);
@@ -46,7 +46,6 @@ DWORD map_pm16(DWORD vm, DWORD linear, DWORD size); void SVGA_Sync();
void SVGA_Flush_CB();
-void SVGA_Flush_CB_critical();
/* mouse */
BOOL SVGA_mouse_hw();
diff --git a/vxd_svga_cb.c b/vxd_svga_cb.c index 47242b4..c73da2f 100644 --- a/vxd_svga_cb.c +++ b/vxd_svga_cb.c @@ -108,7 +108,7 @@ static uint64 cb_next_id = {0, 0}; #define WAIT_FOR_CB_SYNC_1 SVGA_Sync();
/* wait for all commands */
-void SVGA_Flush_CB_critical()
+void SVGA_Flush_CB()
{
/* wait for actual CB */
while(!CB_queue_check(NULL))
@@ -120,13 +120,6 @@ void SVGA_Flush_CB_critical() SVGA_Flush();
}
-void SVGA_Flush_CB()
-{
- Begin_Critical_Section(0);
- SVGA_Flush_CB_critical();
- End_Critical_Section();
-}
-
/**
* Allocate memory for command buffer
**/
@@ -136,8 +129,6 @@ DWORD *SVGA_CMB_alloc_size(DWORD datasize) SVGACBHeader *cb;
cb_queue_t *q;
- Begin_Critical_Section(0);
-
q = (cb_queue_t*)_PageAllocate(RoundToPages(datasize+sizeof(SVGACBHeader)+sizeof(cb_queue_t)), PG_SYS, 0, 0, 0x0, 0x100000, &phy, PAGECONTIG | PAGEUSEALIGN | PAGEFIXED);
if(q)
@@ -153,10 +144,8 @@ DWORD *SVGA_CMB_alloc_size(DWORD datasize) cb->ptr.pa.hi = 0;
cb->ptr.pa.low = phy + sizeof(cb_queue_t) + sizeof(SVGACBHeader);
- End_Critical_Section();
return (DWORD*)(cb+1);
}
- End_Critical_Section();
return NULL;
}
@@ -164,14 +153,10 @@ DWORD *SVGA_CMB_alloc_size(DWORD datasize) void SVGA_CMB_free(DWORD *cmb)
{
SVGACBHeader *cb = ((SVGACBHeader *)cmb)-1;
-
- Begin_Critical_Section(0);
-
+
WAIT_FOR_CB(cb, 1);
_PageFree(cb-1, 0);
-
- End_Critical_Section();
}
DWORD *SVGA_CMB_alloc()
@@ -469,7 +454,7 @@ static void flags_fence_insert(DWORD cb_flags, uint32 fence) #define flags_fifo_fence_need(_flags) (((_flags) & (SVGA_CB_SYNC | SVGA_CB_FORCE_FENCE | SVGA_CB_PRESENT | SVGA_CB_RENDER | SVGA_CB_UPDATE)) != 0)
#define flags_cb_fence_need(_flags) (((_flags) & (SVGA_CB_FORCE_FENCE)) != 0)
-static void SVGA_CMB_submit_critical(DWORD FBPTR cmb, DWORD cmb_size, SVGA_CMB_status_t FBPTR status, DWORD flags, DWORD DXCtxId)
+void SVGA_CMB_submit(DWORD FBPTR cmb, DWORD cmb_size, SVGA_CMB_status_t FBPTR status, DWORD flags, DWORD DXCtxId)
{
DWORD fence = 0;
SVGACBHeader *cb = ((SVGACBHeader *)cmb)-1;
@@ -484,11 +469,6 @@ static void SVGA_CMB_submit_critical(DWORD FBPTR cmb, DWORD cmb_size, SVGA_CMB_s CB_queue_check_inline(NULL);
} while(CB_queue_is_flags_set(cbq_check) ||
cb_queue_info.items >= (SVGA_CB_MAX_QUEUED_PER_CONTEXT-1));
-
- if(!CB_queue_item_valid(cb))
- {
- return;
- }
}
if(status)
@@ -699,22 +679,13 @@ void wait_for_cmdbuf() {
SVGACBHeader *cb;
- Begin_Critical_Section(0);
cb = ((SVGACBHeader *)cmdbuf)-1;
WAIT_FOR_CB(cb, 0);
}
void submit_cmdbuf(DWORD cmdsize, DWORD flags, DWORD dx)
{
- SVGA_CMB_submit_critical(cmdbuf, cmdsize, NULL, flags, dx);
- End_Critical_Section();
-}
-
-void SVGA_CMB_submit(DWORD FBPTR cmb, DWORD cmb_size, SVGA_CMB_status_t FBPTR status, DWORD flags, DWORD DXCtxId)
-{
- Begin_Critical_Section(0);
- SVGA_CMB_submit_critical(cmb, cmb_size, status, flags, DXCtxId);
- End_Critical_Section();
+ SVGA_CMB_submit(cmdbuf, cmdsize, NULL, flags, dx);
}
static DWORD SVGA_CB_ctr(DWORD data_size)
@@ -723,8 +694,6 @@ static DWORD SVGA_CB_ctr(DWORD data_size) dbg_printf(dbg_ctr_start);
- //Begin_Critical_Section(0);
-
cb->status = SVGA_CB_STATUS_NONE;
cb->errorOffset = 0;
cb->offset = 0; /* VMware modified this, needs to be clear */
@@ -751,8 +720,6 @@ static DWORD SVGA_CB_ctr(DWORD data_size) SVGA_Sync();
}
- //End_Critical_Section();
-
return cb->status;
}
@@ -841,7 +808,7 @@ void SVGA_CMB_wait_update() }
}
-static void *mob_cb[SVGA_CB_MAX_QUEUED_PER_CONTEXT];
+static void *mob_cmb[SVGA_CB_MAX_QUEUED_PER_CONTEXT];
static DWORD mob_act = 0;
void mob_cb_alloc()
@@ -849,21 +816,24 @@ void mob_cb_alloc() int i = 0;
for(i = 0; i < async_mobs; i++)
{
- mob_cb[i] = SVGA_CMB_alloc_size(1024);
+ mob_cmb[i] = SVGA_CMB_alloc_size(1024);
}
}
void *mob_cb_get()
{
+ SVGACBHeader *cb;
int id = mob_act++;
if(mob_act >= async_mobs)
{
mob_act = 0;
}
- WAIT_FOR_CB(mob_cb[id], 0);
+ cb = ((SVGACBHeader *)mob_cmb[id])-1;
+
+ WAIT_FOR_CB(cb, 0);
- return mob_cb[id];
+ return mob_cmb[id];
}
diff --git a/vxd_svga_mem.c b/vxd_svga_mem.c index 7d2a95f..95ee53d 100644 --- a/vxd_svga_mem.c +++ b/vxd_svga_mem.c @@ -667,8 +667,6 @@ BOOL SVGA_region_create(SVGA_region_info_t *rinfo) rinfo->size = new_size;
- Begin_Critical_Section(0);
-
if(cache_use(rinfo))
{
goto spare_region_used;
@@ -725,7 +723,6 @@ BOOL SVGA_region_create(SVGA_region_info_t *rinfo) if(!maddr)
{
- End_Critical_Section();
return FALSE;
}
@@ -767,7 +764,6 @@ BOOL SVGA_region_create(SVGA_region_info_t *rinfo) if(!pgblk)
{
_PageFree((PVOID)laddr, 0);
- End_Critical_Section();
return FALSE;
}
@@ -846,8 +842,6 @@ BOOL SVGA_region_create(SVGA_region_info_t *rinfo) SVGA_WriteReg(SVGA_REG_GMR_ID, rinfo->region_id);
SVGA_WriteReg(SVGA_REG_GMR_DESCRIPTOR, rinfo->region_ppn);
SVGA_Sync(); // notify register change
-
- //SVGA_Flush_CB_critical();
}
else
{
@@ -891,8 +885,6 @@ BOOL SVGA_region_create(SVGA_region_info_t *rinfo) svga_db->stat_regions_usage += rinfo->size;
- End_Critical_Section();
-
dbg_printf(dbg_gmr_succ, rinfo->region_id, rinfo->size);
return TRUE;
@@ -906,8 +898,7 @@ void SVGA_region_free(SVGA_region_info_t *rinfo) {
BOOL saved_in_cache;
BYTE *free_ptr = (BYTE*)rinfo->address;
-
- Begin_Critical_Section(0);
+
svga_db->stat_regions_usage -= rinfo->size;
saved_in_cache = cache_insert(rinfo);
@@ -942,7 +933,7 @@ void SVGA_region_free(SVGA_region_info_t *rinfo) if(!rinfo->mobonly)
{
SVGA_Sync();
- SVGA_Flush_CB_critical();
+ SVGA_Flush_CB();
SVGA_WriteReg(SVGA_REG_GMR_ID, rinfo->region_id);
SVGA_WriteReg(SVGA_REG_GMR_DESCRIPTOR, 0);
@@ -970,7 +961,6 @@ void SVGA_region_free(SVGA_region_info_t *rinfo) _PageFree((PVOID)free_ptr, 0);
}
}
- End_Critical_Section();
//dbg_printf(dbg_pagefree_end, rinfo->region_id, rinfo->size, saved_in_cache);
@@ -990,8 +980,6 @@ void SVGA_flushcache() {
int i;
- Begin_Critical_Section(0);
-
for(i = 0; i < cache_state.free_index_max ; i++)
{
cache_delete(i);
@@ -1002,7 +990,5 @@ void SVGA_flushcache() cache_state.cnt_large = 0;
cache_state.cnt_medium = 0;
cache_state.cnt_small = 0;
-
- End_Critical_Section();
}
|