Removed kernel_windows. Assume a Windows NT-derived operating system.

Fixed some calling convention annotations.
Fixed some MSVC warnings.
This commit is contained in:
James Touton 2015-08-06 02:09:10 -07:00
parent 49f33770ac
commit 4499902ac5
5 changed files with 24 additions and 190 deletions

View File

@ -66,7 +66,7 @@ SRCS = ../main.cpp main_windows.cpp ../prefs.cpp ../prefs_items.cpp prefs_window
../scsi.cpp ../dummy/scsi_dummy.cpp ../video.cpp ../SDL/video_sdl.cpp \
video_blit.cpp ../audio.cpp ../SDL/audio_sdl.cpp clip_windows.cpp \
../extfs.cpp extfs_windows.cpp ../user_strings.cpp user_strings_windows.cpp \
vm_alloc.cpp sigsegv.cpp posix_emu.cpp util_windows.cpp kernel_windows.cpp \
vm_alloc.cpp sigsegv.cpp posix_emu.cpp util_windows.cpp \
../dummy/prefs_editor_dummy.cpp BasiliskII.rc \
$(CDENABLESRCS) $(ROUTERSRCS) $(CPUSRCS) $(SLIRP_OBJS)

View File

@ -38,7 +38,7 @@
#include "b2ether/inc/b2ether_hl.h"
#include "ether_windows.h"
#include "router/router.h"
#include "kernel_windows.h"
#include "util_windows.h"
#include "libslirp.h"
// Define to let the slirp library determine the right timeout for select()
@ -175,10 +175,10 @@ static bool tap_set_status(LPADAPTER fd, ULONG status);
static bool tap_get_mac(LPADAPTER fd, LPBYTE addr);
static bool tap_receive_packet(LPADAPTER fd, LPPACKET lpPacket, BOOLEAN Sync);
static bool tap_send_packet(LPADAPTER fd, LPPACKET lpPacket, BOOLEAN Sync, BOOLEAN recycle);
static WINAPI unsigned int slirp_receive_func(void *arg);
static WINAPI unsigned int ether_thread_feed_int(void *arg);
static WINAPI unsigned int ether_thread_get_packets_nt(void *arg);
static WINAPI unsigned int ether_thread_write_packets(void *arg);
static unsigned int WINAPI slirp_receive_func(void *arg);
static unsigned int WINAPI ether_thread_feed_int(void *arg);
static unsigned int WINAPI ether_thread_get_packets_nt(void *arg);
static unsigned int WINAPI ether_thread_write_packets(void *arg);
static void init_queue(void);
static void final_queue(void);
static bool allocate_read_packets(void);
@ -403,26 +403,10 @@ bool ether_init(void)
// No need to enter wait state if we can avoid it.
// These all terminate fast.
if(pfnInitializeCriticalSectionAndSpinCount) {
pfnInitializeCriticalSectionAndSpinCount( &fetch_csection, 5000 );
} else {
InitializeCriticalSection( &fetch_csection );
}
if(pfnInitializeCriticalSectionAndSpinCount) {
pfnInitializeCriticalSectionAndSpinCount( &queue_csection, 5000 );
} else {
InitializeCriticalSection( &queue_csection );
}
if(pfnInitializeCriticalSectionAndSpinCount) {
pfnInitializeCriticalSectionAndSpinCount( &send_csection, 5000 );
} else {
InitializeCriticalSection( &send_csection );
}
if(pfnInitializeCriticalSectionAndSpinCount) {
pfnInitializeCriticalSectionAndSpinCount( &wpool_csection, 5000 );
} else {
InitializeCriticalSection( &wpool_csection );
}
InitializeCriticalSectionAndSpinCount( &fetch_csection, 5000 );
InitializeCriticalSectionAndSpinCount( &queue_csection, 5000 );
InitializeCriticalSectionAndSpinCount( &send_csection, 5000 );
InitializeCriticalSectionAndSpinCount( &wpool_csection, 5000 );
ether_th = (HANDLE)_beginthreadex( 0, 0, ether_thread_feed_int, 0, 0, &ether_tid );
if (!ether_th) {
@ -497,8 +481,8 @@ void ether_exit(void)
if(int_send_now) ReleaseSemaphore(int_send_now,1,NULL);
D(bug("CancelIO if needed\n"));
if (fd && fd->hFile && pfnCancelIo)
pfnCancelIo(fd->hFile);
if (fd && fd->hFile)
CancelIo(fd->hFile);
// Wait max 2 secs to shut down pending io. After that, kill them.
D(bug("Wait delay\n"));
@ -992,7 +976,7 @@ static LPPACKET get_write_packet( UINT len )
return Packet;
}
static unsigned int ether_thread_write_packets(void *arg)
unsigned int WINAPI ether_thread_write_packets(void *arg)
{
LPPACKET Packet;
@ -1246,7 +1230,7 @@ static bool tap_set_status(LPADAPTER fd, ULONG status)
DWORD len = 0;
return DeviceIoControl(fd->hFile, TAP_IOCTL_SET_MEDIA_STATUS,
&status, sizeof (status),
&status, sizeof (status), &len, NULL);
&status, sizeof (status), &len, NULL) != FALSE;
}
static bool tap_get_mac(LPADAPTER fd, LPBYTE addr)
@ -1254,8 +1238,7 @@ static bool tap_get_mac(LPADAPTER fd, LPBYTE addr)
DWORD len = 0;
return DeviceIoControl(fd->hFile, TAP_IOCTL_GET_MAC,
addr, 6,
addr, 6, &len, NULL);
addr, 6, &len, NULL) != FALSE;
}
static VOID CALLBACK tap_write_completion(
@ -1309,7 +1292,7 @@ static bool tap_send_packet(
recycle_write_packet(lpPacket);
}
return Result;
return Result != FALSE;
}
static bool tap_receive_packet(LPADAPTER fd, LPPACKET lpPacket, BOOLEAN Sync)
@ -1348,7 +1331,7 @@ static bool tap_receive_packet(LPADAPTER fd, LPPACKET lpPacket, BOOLEAN Sync)
lpPacket->BytesReceived = 0;
}
return Result;
return Result != FALSE;
}
@ -1366,7 +1349,7 @@ void slirp_output(const uint8 *packet, int len)
enqueue_packet(packet, len);
}
static unsigned int slirp_receive_func(void *arg)
unsigned int WINAPI slirp_receive_func(void *arg)
{
D(bug("slirp_receive_func\n"));
thread_active_2 = true;
@ -1508,7 +1491,7 @@ static void free_read_packets(void)
}
}
static unsigned int ether_thread_get_packets_nt(void *arg)
unsigned int WINAPI ether_thread_get_packets_nt(void *arg)
{
static uint8 packet[1514];
int i, packet_sz = 0;
@ -1565,7 +1548,7 @@ static unsigned int ether_thread_get_packets_nt(void *arg)
return 0;
}
static unsigned int ether_thread_feed_int(void *arg)
unsigned int WINAPI ether_thread_feed_int(void *arg)
{
bool looping;

View File

@ -1,88 +0,0 @@
/*
* kernel_windows.cpp
*
* Basilisk II (C) 1997-2008 Christian Bauer
*
* Windows platform specific code copyright (C) Lauri Pesonen
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "sysdeps.h"
#include "prefs.h"
#include "kernel_windows.h"
// From main_windows.cpp
extern DWORD win_os;
extern DWORD win_os_major;
static HMODULE hKernel32 = 0;
static HMODULE hUser32 = 0;
static HMODULE hB2Win32 = 0;
UINT (WINAPI *pfnGetWriteWatch) (DWORD,PVOID,SIZE_T,PVOID *,LPDWORD,LPDWORD) = 0;
BOOL (WINAPI *pfnInitializeCriticalSectionAndSpinCount) (LPCRITICAL_SECTION,DWORD) = 0;
BOOL (WINAPI *pfnCancelIo) (HANDLE) = 0;
BOOL (WINAPI *pfnGETCDSECTORS) (BYTE,DWORD,WORD,LPBYTE) = 0;
UINT (WINAPI *pfnSendInput) (UINT,LPVOID,int) = 0;
BOOL (WINAPI *pfnGetDiskFreeSpaceEx) (LPCSTR,PULARGE_INTEGER,PULARGE_INTEGER,PULARGE_INTEGER) = 0;
void KernelInit( void )
{
hKernel32 = LoadLibrary( "kernel32.dll" );
hUser32 = LoadLibrary( "user32.dll" );
if(hKernel32) {
if(win_os == VER_PLATFORM_WIN32_WINDOWS) {
// NT5 RC2 Kernel exports GetWriteWatch(), but VirtualAlloc(MEM_WRITE_WATCH) fails
pfnGetWriteWatch = (UINT (WINAPI *)(DWORD,PVOID,SIZE_T,PVOID *,LPDWORD,LPDWORD))GetProcAddress( hKernel32, "GetWriteWatch" );
}
pfnInitializeCriticalSectionAndSpinCount = (BOOL (WINAPI *)(LPCRITICAL_SECTION,DWORD))GetProcAddress( hKernel32, "InitializeCriticalSectionAndSpinCount" );
pfnCancelIo = (BOOL (WINAPI *)(HANDLE))GetProcAddress( hKernel32, "CancelIo" );
pfnGetDiskFreeSpaceEx = (BOOL (WINAPI *)(LPCSTR,PULARGE_INTEGER,PULARGE_INTEGER,PULARGE_INTEGER))GetProcAddress( hKernel32, "GetDiskFreeSpaceExA" );
}
if(hUser32) {
// Win98 has this one too.
// if(win_os == VER_PLATFORM_WIN32_NT) {
pfnSendInput = (UINT (WINAPI *)(UINT,LPVOID,int))GetProcAddress( hUser32, "SendInput" );
// }
}
if(win_os == VER_PLATFORM_WIN32_WINDOWS) {
hB2Win32 = LoadLibrary( "B2Win32.dll" );
if(hB2Win32) {
pfnGETCDSECTORS = (BOOL (WINAPI *)(BYTE,DWORD,WORD,LPBYTE))GetProcAddress( hB2Win32, "GETCDSECTORS" );
}
}
}
void KernelExit( void )
{
if(hKernel32) {
FreeLibrary( hKernel32 );
hKernel32 = 0;
}
if(hUser32) {
FreeLibrary( hUser32 );
hUser32 = 0;
}
if(hB2Win32) {
FreeLibrary( hB2Win32 );
hB2Win32 = 0;
}
pfnGetWriteWatch = 0;
pfnInitializeCriticalSectionAndSpinCount = 0;
pfnCancelIo = 0;
pfnSendInput = 0;
pfnGETCDSECTORS = 0;
}

View File

@ -1,36 +0,0 @@
/*
* kernel_windows.h
*
* Basilisk II (C) 1997-2008 Christian Bauer
*
* Windows platform specific code copyright (C) Lauri Pesonen
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef _KERNEL_WINDOWS_H_
#define _KERNEL_WINDOWS_H_
extern UINT (WINAPI *pfnGetWriteWatch) (DWORD,PVOID,SIZE_T,PVOID *,LPDWORD,LPDWORD);
extern BOOL (WINAPI *pfnInitializeCriticalSectionAndSpinCount) (LPCRITICAL_SECTION,DWORD);
extern BOOL (WINAPI *pfnCancelIo) (HANDLE);
extern BOOL (WINAPI *pfnGETCDSECTORS) (BYTE,DWORD,WORD,LPBYTE);
extern UINT (WINAPI *pfnSendInput) (UINT,LPVOID,int);
extern BOOL (WINAPI *pfnGetDiskFreeSpaceEx) (LPCSTR,PULARGE_INTEGER,PULARGE_INTEGER,PULARGE_INTEGER);
void KernelInit( void );
void KernelExit( void );
#endif // _KERNEL_WINDOWS_H_

View File

@ -49,7 +49,6 @@ using std::string;
#include "vm_alloc.h"
#include "sigsegv.h"
#include "util_windows.h"
#include "kernel_windows.h"
#if USE_JIT
extern void flush_icache_range(uint8 *start, uint32 size); // from compemu_support.cpp
@ -91,9 +90,6 @@ static SDL_mutex *intflag_lock = NULL; // Mutex to protect InterruptFlags
#define LOCK_INTFLAGS SDL_LockMutex(intflag_lock)
#define UNLOCK_INTFLAGS SDL_UnlockMutex(intflag_lock)
DWORD win_os; // Windows OS id
DWORD win_os_major; // Windows OS version major
#if USE_SCRATCHMEM_SUBTERFUGE
uint8 *ScratchMem = NULL; // Scratch memory for Mac ROM writes
#endif
@ -219,7 +215,7 @@ int main(int argc, char **argv)
// Initialize variables
RAMBaseHost = NULL;
ROMBaseHost = NULL;
srand(time(NULL));
srand(unsigned(time(NULL)));
tzset();
// Print some info
@ -239,7 +235,7 @@ int main(int argc, char **argv)
} else if (strcmp(argv[i], "--config") == 0) {
argv[i++] = NULL;
if (i < argc) {
extern string UserPrefsPath; // from prefs_unix.cpp
extern string UserPrefsPath; // from prefs_windows.cpp
UserPrefsPath = argv[i];
argv[i] = NULL;
}
@ -281,28 +277,10 @@ int main(int argc, char **argv)
}
}
// Check we are using a Windows NT kernel >= 4.0
OSVERSIONINFO osvi;
ZeroMemory(&osvi, sizeof(OSVERSIONINFO));
osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
if (!GetVersionEx(&osvi)) {
ErrorAlert("Could not determine OS type");
QuitEmulator();
}
win_os = osvi.dwPlatformId;
win_os_major = osvi.dwMajorVersion;
if (win_os != VER_PLATFORM_WIN32_NT || win_os_major < 4) {
ErrorAlert(STR_NO_WIN32_NT_4);
QuitEmulator();
}
// Check that drivers are installed
if (!check_drivers())
QuitEmulator();
// Load win32 libraries
KernelInit();
// FIXME: default to DIB driver
if (getenv("SDL_VIDEODRIVER") == NULL)
putenv("SDL_VIDEODRIVER=windib");
@ -386,7 +364,7 @@ int main(int argc, char **argv)
// Load Mac ROM
HANDLE rom_fh = CreateFile(rom_path ? rom_path : ROM_FILE_NAME,
GENERIC_READ,
0, NULL,
FILE_SHARE_READ, NULL,
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL,
NULL);
@ -495,9 +473,6 @@ void QuitEmulator(void)
// Exit preferences
PrefsExit();
// Release win32 libraries
KernelExit();
exit(0);
}
@ -631,7 +606,7 @@ static int tick_func(void *arg)
next += 16625;
int64 delay = next - GetTicks_usec();
if (delay > 0)
Delay_usec(delay);
Delay_usec(uint32(delay));
else if (delay < -16625)
next = GetTicks_usec();
ticks++;