Temporary fix for SLiRP - at least it now works, but waltje should look at this and possibly redo it when he feels like it;

The 12 MHz 286 is now correctly 12.5 MHz.
This commit is contained in:
OBattler
2017-09-08 16:35:14 +02:00
parent 40e7a0efab
commit 576956fb66
5 changed files with 95 additions and 8 deletions

View File

@@ -240,7 +240,7 @@ CPU cpus_286[] =
{"286/6", CPU_286, 0, 6000000, 1, 0, 0, 0, 0, 0, 2,2,2,2},
{"286/8", CPU_286, 1, 8000000, 1, 0, 0, 0, 0, 0, 2,2,2,2},
{"286/10", CPU_286, 2, 10000000, 1, 0, 0, 0, 0, 0, 2,2,2,2},
{"286/12", CPU_286, 3, 12000000, 1, 0, 0, 0, 0, 0, 3,3,3,3},
{"286/12", CPU_286, 3, 12500000, 1, 0, 0, 0, 0, 0, 3,3,3,3},
{"286/16", CPU_286, 4, 16000000, 1, 0, 0, 0, 0, 0, 3,3,3,3},
{"286/20", CPU_286, 5, 20000000, 1, 0, 0, 0, 0, 0, 4,4,4,4},
{"286/25", CPU_286, 6, 25000000, 1, 0, 0, 0, 0, 0, 4,4,4,4},
@@ -266,7 +266,7 @@ CPU cpus_ps2_m30_286[] =
{
/*286*/
{"286/10", CPU_286, 2, 10000000, 1, 0, 0, 0, 0, 0, 2,2,2,2},
{"286/12", CPU_286, 3, 12000000, 1, 0, 0, 0, 0, 0, 3,3,3,3},
{"286/12", CPU_286, 3, 12500000, 1, 0, 0, 0, 0, 0, 3,3,3,3},
{"286/16", CPU_286, 4, 16000000, 1, 0, 0, 0, 0, 0, 3,3,3,3},
{"286/20", CPU_286, 5, 20000000, 1, 0, 0, 0, 0, 0, 4,4,4,4},
{"286/25", CPU_286, 6, 25000000, 1, 0, 0, 0, 0, 0, 4,4,4,4},

View File

@@ -63,6 +63,25 @@ slirp_tic(void)
}
static struct
{
int busy;
int queue_in_use;
event_t *wake_poll_thread;
event_t *poll_complete;
event_t *queue_not_in_use;
} poll_data;
void network_slirp_wait_for_poll()
{
while (poll_data.busy)
thread_wait_event(poll_data.poll_complete, -1);
thread_reset_event(poll_data.poll_complete);
}
/* Handle the receiving of frames. */
static void
poll_thread(void *arg)
@@ -76,6 +95,10 @@ poll_thread(void *arg)
evt = thread_create_event();
while (slirpq != NULL) {
startslirp();
network_slirp_wait_for_poll();
/* See if there is any work. */
slirp_tic();
@@ -98,10 +121,12 @@ poll_thread(void *arg)
/* Done with this one. */
free(qp);
endslirp();
}
thread_destroy_event(evt);
poll_tid = NULL;
evt = poll_tid = NULL;
pclog("SLiRP: polling stopped.\n");
}
@@ -125,6 +150,9 @@ network_slirp_setup(uint8_t *mac, NETRXCB func, void *arg)
poll_rx = func;
poll_arg = arg;
poll_data.wake_poll_thread = thread_create_event();
poll_data.poll_complete = thread_create_event();
pclog("SLiRP: starting thread..\n");
poll_tid = thread_create(poll_thread, mac);
@@ -184,8 +212,14 @@ network_slirp_test(void)
void
network_slirp_in(uint8_t *pkt, int pkt_len)
{
if (slirpq != NULL)
if (slirpq != NULL) {
poll_data.busy = 1;
slirp_input((const uint8_t *)pkt, pkt_len);
poll_data.busy = 0;
thread_set_event(poll_data.poll_complete);
}
}

View File

@@ -34,7 +34,7 @@ int firsttime=1;
void setpitclock(float clock)
{
cpuclock=clock;
PITCONST=clock/1193182.0;
PITCONST=clock/(1193181.0 + (2.0 / 3.0));
CGACONST=(clock/(19687503.0/11.0));
MDACONST=(clock/2032125.0);
VGACONST1=(clock/25175000.0);
@@ -79,9 +79,9 @@ void clearpit()
float pit_timer0_freq()
{
if (pit.l[0])
return 1193182.0f/(float)pit.l[0];
return (1193181.0 + (2.0 / 3.0))/(float)pit.l[0];
else
return 1193182.0f/(float)0x10000;
return (1193181.0 + (2.0 / 3.0))/(float)0x10000;
}
static void pit_set_out(PIT *pit, int t, int out)

View File

@@ -20,5 +20,13 @@ extern void thread_destroy_event(event_t *_event);
extern void thread_sleep(int t);
extern void *thread_create_mutex(wchar_t *name);
extern void thread_close_mutex(void *mutex);
extern uint8_t thread_wait_mutex(void *mutex);
extern uint8_t thread_release_mutex(void *mutex);
extern void startslirp(void);
extern void endslirp(void);
#endif /*PLAT_THREAD_H*/

View File

@@ -25,6 +25,7 @@
#include "../ibm.h"
#include "../cpu/cpu.h"
#include "../mem.h"
#include "../pic.h"
#include "../rom.h"
#include "../device.h"
#include "../nvr.h"
@@ -98,6 +99,7 @@ int winsizex=640, winsizey=480;
int efwinsizey=480;
int gfx_present[GFX_MAX];
HANDLE ghMutex;
HANDLE slirpMutex;
HANDLE mainthreadh;
int infocus=1;
int drawits=0;
@@ -278,6 +280,16 @@ void endblit(void)
ReleaseMutex(ghMutex);
}
void startslirp(void)
{
WaitForSingleObject(slirpMutex, INFINITE);
}
void endslirp(void)
{
ReleaseMutex(slirpMutex);
}
void leave_fullscreen(void)
{
leave_fullscreen_flag = 1;
@@ -428,6 +440,35 @@ void thread_destroy_event(event_t *_event)
free(event);
}
void *thread_create_mutex(wchar_t *name)
{
return (void*) CreateMutex(NULL, FALSE, name);
}
void thread_close_mutex(void *mutex)
{
CloseHandle((HANDLE) mutex);
}
uint8_t thread_wait_mutex(void *mutex)
{
DWORD dwres = WaitForSingleObject((HANDLE) mutex, INFINITE);
switch (dwres)
{
case WAIT_OBJECT_0:
return 1;
case WAIT_ABANDONED:
default:
return 0;
}
}
uint8_t thread_release_mutex(void *mutex)
{
return !!ReleaseMutex((HANDLE) mutex);
}
static void init_cdrom_host_drives(void)
{
int i = 0;
@@ -1780,7 +1821,8 @@ int WINAPI WinMain (HINSTANCE hThisInstance, HINSTANCE hPrevInstance, LPSTR lpsz
atexit(releasemouse);
ghMutex = CreateMutex(NULL, FALSE, NULL);
ghMutex = CreateMutex(NULL, FALSE, L"86Box.BlitMutex");
slirpMutex = CreateMutex(NULL, FALSE, L"86Box.SlirpMutex");
mainthreadh=(HANDLE)_beginthread(mainthread,0,NULL);
SetThreadPriority(mainthreadh, THREAD_PRIORITY_HIGHEST);
@@ -2235,6 +2277,9 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM
#endif
case IDM_CONFIG_LOAD:
picint(1 << 12);
break;
pause = 1;
if (!file_dlg_st(hwnd, IDS_2160, "", 0))
{