diff --git a/bochs/iodev/display/voodoo.cc b/bochs/iodev/display/voodoo.cc index ab217e12d..bc02d7a93 100644 --- a/bochs/iodev/display/voodoo.cc +++ b/bochs/iodev/display/voodoo.cc @@ -166,19 +166,19 @@ BX_THREAD_FUNC(cmdfifo_thread, indata) while (1) { #ifdef WIN32 if (WaitForSingleObject(v->fbi.cmdfifo[0].event, 1) == WAIT_OBJECT_0) { - BX_LOCK(cmdfifo_mutex); while (v->fbi.cmdfifo[0].enable && (v->fbi.cmdfifo[0].depth >= v->fbi.cmdfifo[0].depth_needed)) { cmdfifo_process(); } + BX_LOCK(cmdfifo_mutex); v->fbi.cmdfifo[0].cmd_ready = 0; BX_UNLOCK(cmdfifo_mutex); } #else while (!v->fbi.cmdfifo[0].event) BX_MSLEEP(1); - BX_LOCK(cmdfifo_mutex); while (v->fbi.cmdfifo[0].enable && (v->fbi.cmdfifo[0].depth >= v->fbi.cmdfifo[0].depth_needed)) { cmdfifo_process(); } + BX_LOCK(cmdfifo_mutex); v->fbi.cmdfifo[0].cmd_ready = 0; v->fbi.cmdfifo[0].event = 0; BX_UNLOCK(cmdfifo_mutex); @@ -614,7 +614,9 @@ void bx_voodoo_c::vertical_timer_handler(void *this_ptr) #ifdef WIN32 SetEvent(v->fbi.cmdfifo[0].event); #else + BX_LOCK(cmdfifo_mutex); v->fbi.cmdfifo[0].event = 1; + BX_UNLOCK(cmdfifo_mutex); #endif } diff --git a/bochs/iodev/display/voodoo_func.h b/bochs/iodev/display/voodoo_func.h index cdafd36ed..3e4adbd57 100644 --- a/bochs/iodev/display/voodoo_func.h +++ b/bochs/iodev/display/voodoo_func.h @@ -2406,7 +2406,9 @@ Bit32u cmdfifo_calc_depth_needed(void) if (v->fbi.cmdfifo[0].depth == 0) return needed; + BX_LOCK(cmdfifo_mutex); command = *(Bit32u*)(&v->fbi.ram[v->fbi.cmdfifo[0].rdptr & v->fbi.mask]); + BX_UNLOCK(cmdfifo_mutex); type = (Bit8u)(command & 0x07); switch (type) { case 0: @@ -2461,7 +2463,9 @@ void cmdfifo_w(Bit32u fbi_offset, Bit32u data) *(Bit32u*)(&v->fbi.ram[fbi_offset]) = data; v->fbi.cmdfifo[0].depth++; if (v->fbi.cmdfifo[0].depth_needed == BX_MAX_BIT32U) { + BX_UNLOCK(cmdfifo_mutex); v->fbi.cmdfifo[0].depth_needed = cmdfifo_calc_depth_needed(); + BX_LOCK(cmdfifo_mutex); } if (v->fbi.cmdfifo[0].depth >= v->fbi.cmdfifo[0].depth_needed) { v->fbi.cmdfifo[0].cmd_ready = 1; @@ -2473,9 +2477,11 @@ Bit32u cmdfifo_r(void) { Bit32u data; + BX_LOCK(cmdfifo_mutex); data = *(Bit32u*)(&v->fbi.ram[v->fbi.cmdfifo[0].rdptr & v->fbi.mask]); v->fbi.cmdfifo[0].rdptr += 4; v->fbi.cmdfifo[0].depth--; + BX_UNLOCK(cmdfifo_mutex); return data; }