diff --git a/src/Makefile.local b/src/Makefile.local new file mode 100644 index 000000000..9b9988201 --- /dev/null +++ b/src/Makefile.local @@ -0,0 +1,42 @@ +# +# 86Box A hypervisor and IBM PC system emulator that specializes in +# running old operating systems and software designed for IBM +# PC systems and compatibles from 1981 through fairly recent +# system designs based on the PCI bus. +# +# This file is part of the 86Box distribution. +# +# Prefix for localizing the general Makefile.mingw for local +# settings, so we can avoid changing the main one for all of +# our local setups. +# +# Version: @(#)Makefile.local 1.0.2 2017/05/23 +# +# Author: Fred N. van Kempen, +# + +######################################################################### +# Anything here will override defaults in Makefile.MinGW. # +######################################################################### + + +DEBUG = y +OPTIM = n +COPTIM = -O1 + +# Name of the executable. +PROG = yourexe + +# Various compile-time options. +STUFF = #-DROM_TRACE=0xC800 -DIO_TRACE=0x70 +EXTRAS = #-DYOURNAME + + + +######################################################################### +# Include the master Makefile.MinGW for the rest. # +######################################################################### +include Makefile.mingw + + +# End of Makefile.local. diff --git a/src/Makefile.mingw b/src/Makefile.mingw index 49f095965..4ba3565e2 100644 --- a/src/Makefile.mingw +++ b/src/Makefile.mingw @@ -8,7 +8,7 @@ # # Modified Makefile for Win32 MinGW 32-bit environment. # -# Version: @(#)Makefile.mingw 1.0.14 2017/05/21 +# Version: @(#)Makefile.mingw 1.0.16 2017/05/22 # # Authors: Kotori, # Fred N. van Kempen, @@ -17,21 +17,33 @@ # # Name of the executable. +ifndef PROG PROG = 86Box +endif # Various compile-time options. # -DROM_TRACE=0xcd800 traces ROM access from segment C800 # -DIO_TACE=0x66 traces I/O on port 0x66 +ifndef STUFF STUFF = +endif # Add feature selections here. # -DBUGGER adds the ISA BusBugger emulation. -EXTRAS = +ifndef EXTRAS +EXTRAS = lala +endif # Do we want a debugging build? +ifndef DEBUG DEBUG = n +endif +ifndef OPTIM OPTIM = y +endif +ifndef X64 X64 = n +endif ######################################################################### @@ -43,27 +55,33 @@ CPP = g++.exe CC = gcc.exe WINDRES = windres.exe -OPTS = -DWIN32 -I$(PLAT) -I$(X64INC) $(EXTRAS) $(STUFF) +OPTS = -DWIN32 -I$(PLAT) $(EXTRAS) $(STUFF) ifeq ($(DEBUG), y) ifeq ($(VRAMDUMP), y) DFLAGS = -march=i686 -ggdb -DDEBUG -DENABLE_VRAM_DUMP else DFLAGS = -march=i686 -ggdb -DDEBUG endif +ifndef COPTIM COPTIM = -Og +endif else ifeq ($(OPTIM), y) DFLAGS = -march=native +ifndef COPTIM COPTIM = -O6 +endif else ifeq ($(X64), y) DFLAGS = else DFLAGS = -march=i686 endif +ifndef COPTIM COPTIM = -O3 endif endif +endif ifeq ($(OPTIM), y) AOPTIM = -mtune=native else @@ -102,17 +120,17 @@ CPUOBJ = cpu.o 386.o 386_dynarec.o 386_dynarec_ops.o 808x.o \ codegen_timing_winchip.o $(PLATCG) \ x86seg.o x87.o SYSOBJ = model.o \ - headland.o \ - i430hx.o i430lx.o i430fx.o i430nx.o i430vx.o i440fx.o \ - neat.o \ - ali1429.o \ - opti495.o \ - scat.o \ - sis496.o \ - wd76c10.o \ - acer386sx.o acerm3a.o amstrad.o \ - compaq.o olivetti_m24.o jim.o ps1.o ps2.o ps2_mca.o \ - tandy_eeprom.o tandy_rom.o + headland.o \ + i430hx.o i430lx.o i430fx.o i430nx.o i430vx.o i440fx.o \ + neat.o \ + ali1429.o \ + opti495.o \ + scat.o \ + sis496.o \ + wd76c10.o \ + acer386sx.o acerm3a.o amstrad.o \ + compaq.o olivetti_m24.o jim.o ps1.o ps2.o ps2_mca.o \ + tandy_eeprom.o tandy_rom.o DEVOBJ = bugger.o lpt.o serial.o \ um8669f.o pc87306.o sis85c471.o w83877f.o \ keyboard.o \ @@ -133,53 +151,53 @@ DEVOBJ = bugger.o lpt.o serial.o \ cdrom_dosbox.o cdrom_image.o cdrom_ioctl.o cdrom_null.o USBOBJ = usb.o NETOBJ = network.o \ - net_pcap.o net_slirp.o \ - net_ne2000.o + net_pcap.o net_slirp.o \ + net_ne2000.o SCSIOBJ = scsi.o scsi_disk.o scsi_buslogic.o scsi_aha154x.o SNDOBJ = sound.o \ - convolve.o convolve-sse.o envelope.o extfilt.o \ - filter.o pot.o sid.o voice.o wave6581__ST.o \ - wave6581_P_T.o wave6581_PS_.o wave6581_PST.o \ - wave8580__ST.o wave8580_P_T.o wave8580_PS_.o \ - wave8580_PST.o wave.o \ - dbopl.o nukedopl.o openal.o \ - snd_speaker.o snd_ps1.o snd_pssj.o \ - snd_adlib.o snd_adlibgold.o snd_ad1848.o \ - snd_sb.o snd_sb_dsp.o snd_cms.o snd_dbopl.o \ - snd_emu8k.o snd_gus.o snd_opl.o \ - snd_mpu401.o snd_pas16.o snd_resid.o \ - snd_sn76489.o snd_ssi2001.o snd_wss.o \ - snd_ym7128.o + convolve.o convolve-sse.o envelope.o extfilt.o \ + filter.o pot.o sid.o voice.o wave6581__ST.o \ + wave6581_P_T.o wave6581_PS_.o wave6581_PST.o \ + wave8580__ST.o wave8580_P_T.o wave8580_PS_.o \ + wave8580_PST.o wave.o \ + dbopl.o nukedopl.o openal.o \ + snd_speaker.o snd_ps1.o snd_pssj.o \ + snd_adlib.o snd_adlibgold.o snd_ad1848.o \ + snd_sb.o snd_sb_dsp.o snd_cms.o snd_dbopl.o \ + snd_emu8k.o snd_gus.o snd_opl.o \ + snd_mpu401.o snd_pas16.o snd_resid.o \ + snd_sn76489.o snd_ssi2001.o snd_wss.o \ + snd_ym7128.o VIDOBJ = video.o \ - vid_cga.o vid_cga_comp.o vid_mda.o vid_ega.o \ - vid_vga.o vid_svga.o vid_svga_render.o \ - vid_hercules.o vid_herculesplus.o vid_incolor.o \ - vid_colorplus.o \ - vid_genius.o \ - vid_s3.o vid_s3_virge.o \ - vid_et4000.o vid_et4000w32.o vid_icd2061.o \ - vid_oti067.o \ - vid_paradise.o \ - vid_tvga.o vid_tgui9440.o vid_tkd8001_ramdac.o \ - vid_ati_eeprom.o vid_ati18800.o vid_ati28800.o \ - vid_ati68860_ramdac.o vid_ati_mach64.o \ - vid_ics2595.o \ - vid_sdac_ramdac.o \ - vid_stg_ramdac.o \ - vid_unk_ramdac.o \ - vid_wy700.o \ - vid_voodoo.o \ - vid_pcjr.o vid_ps1_svga.o \ - vid_olivetti_m24.o \ - vid_pc1512.o vid_pc1640.o vid_pc200.o \ - vid_tandy.o vid_tandysl.o + vid_cga.o vid_cga_comp.o vid_mda.o vid_ega.o \ + vid_vga.o vid_svga.o vid_svga_render.o \ + vid_hercules.o vid_herculesplus.o vid_incolor.o \ + vid_colorplus.o \ + vid_genius.o \ + vid_s3.o vid_s3_virge.o \ + vid_et4000.o vid_et4000w32.o vid_icd2061.o \ + vid_oti067.o \ + vid_paradise.o \ + vid_tvga.o vid_tgui9440.o vid_tkd8001_ramdac.o \ + vid_ati_eeprom.o vid_ati18800.o vid_ati28800.o \ + vid_ati68860_ramdac.o vid_ati_mach64.o \ + vid_ics2595.o \ + vid_sdac_ramdac.o \ + vid_stg_ramdac.o \ + vid_unk_ramdac.o \ + vid_wy700.o \ + vid_voodoo.o \ + vid_pcjr.o vid_ps1_svga.o \ + vid_olivetti_m24.o \ + vid_pc1512.o vid_pc1640.o vid_pc200.o \ + vid_tandy.o vid_tandysl.o WINOBJ = win.o \ - win_d3d.o win_d3d-fs.o \ - win_ddraw.o win_ddraw-fs.o win_ddraw-screenshot.o \ - win_language.o win_status.o win_opendir.o win_dynld.o \ - win_video.o win_serial.o win_mouse.o \ - win_joystick.o win_midi.o \ - win_settings.o win_deviceconfig.o win_joystickconfig.o \ + win_ddraw.o win_ddraw_fs.o win_ddraw_screenshot.o \ + win_d3d.o win_d3d_fs.o \ + win_language.o win_status.o win_opendir.o win_dynld.o \ + win_video.o win_serial.o win_mouse.o \ + win_joystick.o win_midi.o \ + win_settings.o win_deviceconfig.o win_joystickconfig.o \ 86Box.res OBJ = $(MAINOBJ) $(CPUOBJ) $(SYSOBJ) $(DEVOBJ) $(USBOBJ) \ $(NETOBJ) $(SCSIOBJ) $(SNDOBJ) $(VIDOBJ) $(WINOBJ) @@ -197,7 +215,7 @@ LIBS = -mwindows -lcomctl32 -lwinmm -lopenal.dll -lopenal -lddraw \ # Build rules. %.o: %.c @echo $< - @$(CC) $(CFLAGS) -c $< + $(CC) $(CFLAGS) -c $< %.o: %.cc @echo $< diff --git a/src/WIN/win.c b/src/WIN/win.c index af72b0ef1..4b6c771d0 100644 --- a/src/WIN/win.c +++ b/src/WIN/win.c @@ -1,21 +1,10 @@ /* Copyright holders: Sarah Walker, Tenshi see COPYING for more details */ -#define UNICODE -#define _WIN32_WINNT 0x0501 -#define BITMAP WINDOWS_BITMAP -#include -#include -#undef BITMAP - -#include -#include -#include -#include -#include -#include -#include #include +#include +#include +#include #include "../86box.h" #include "../device.h" #include "../disc.h" @@ -45,10 +34,12 @@ #include "win.h" #include "win_ddraw.h" -#include "win_ddraw-fs.h" #include "win_d3d.h" -#include "win_d3d-fs.h" #include "win_language.h" +#include +#include +#include +#include #include "resource.h" diff --git a/src/WIN/win.h b/src/WIN/win.h index 255c15a6e..1d4feec57 100644 --- a/src/WIN/win.h +++ b/src/WIN/win.h @@ -8,13 +8,16 @@ */ #ifndef BOX_WIN_H # define BOX_WIN_H - -#if 0 -# define UNICODE +# ifndef NO_UNICODE +# define UNICODE +# endif # define BITMAP WINDOWS_BITMAP +//# ifdef _WIN32_WINNT +//# undef _WIN32_WINNT +//# define _WIN32_WINNT 0x0501 +//# endif # include # undef BITMAP -#endif #define szClassName L"86BoxMainWnd" diff --git a/src/WIN/win_crashdump.c b/src/WIN/win_crashdump.c index 3fee061b3..957ce296e 100644 --- a/src/WIN/win_crashdump.c +++ b/src/WIN/win_crashdump.c @@ -12,174 +12,214 @@ #include "../86box.h" #include "win_crashdump.h" -PVOID hExceptionHandler; -char* ExceptionHandlerBuffer; + #define ExceptionHandlerBufferSize (10240) -LONG CALLBACK MakeCrashDump(PEXCEPTION_POINTERS ExceptionInfo) { - // Win32-specific functions will be used wherever possible, just in case the C stdlib-equivalents try to allocate memory. - // (The Win32-specific functions are generally just wrappers over NT system calls anyway.) - - if ((ExceptionInfo->ExceptionRecord->ExceptionCode >> 28) != 0xC) { - // The exception code is not a fatal exception (highest 4 bits of ntstatus = 0xC) - // Not going to crash, let's not make a crash dump - return EXCEPTION_CONTINUE_SEARCH; - } - - // So, the program is about to crash. Oh no what do? - // Let's create a crash dump file as a debugging-aid. - - // First, get the path to 86Box.exe. - char* CurrentBufferPointer; - GetModuleFileName(NULL,ExceptionHandlerBuffer,ExceptionHandlerBufferSize); - if (GetLastError() != ERROR_SUCCESS) { - // Could not get the full path of 86Box.exe. Just create the file in the current directory. - CurrentBufferPointer = ExceptionHandlerBuffer; - } else { - // Walk through the string backwards looking for the last backslash, so as to remove the "86Box.exe" filename from the string. - CurrentBufferPointer = &ExceptionHandlerBuffer[strlen(ExceptionHandlerBuffer)]; - for (; CurrentBufferPointer > ExceptionHandlerBuffer; CurrentBufferPointer--) { - if (CurrentBufferPointer[0] == '\\') { - // Found the backslash, null terminate the string after it. - CurrentBufferPointer[1] = 0; - break; - } - } - - CurrentBufferPointer = &ExceptionHandlerBuffer[strlen(ExceptionHandlerBuffer)]; - } - - // What would a good filename be? It should contain the current date and time so as to be (hopefully!) unique. - SYSTEMTIME SystemTime; - GetSystemTime(&SystemTime); - sprintf(CurrentBufferPointer, - "86box-%d%02d%02d-%02d-%02d-%02d-%03d.dmp", - SystemTime.wYear, - SystemTime.wMonth, - SystemTime.wDay, - SystemTime.wHour, - SystemTime.wMinute, - SystemTime.wSecond, - SystemTime.wMilliseconds); - - DWORD Error; - - // Now the filename is in the buffer, the file can be created. - HANDLE hDumpFile = CreateFile( - ExceptionHandlerBuffer, // The filename of the file to open. - GENERIC_WRITE, // The permissions to request. - 0, // Make sure other processes can't touch the crash dump at all while it's open. - NULL, // Leave the security descriptor undefined, it doesn't matter. - OPEN_ALWAYS, // Opens the file if it exists, creates a new file if it doesn't. - FILE_ATTRIBUTE_NORMAL, // File attributes / etc don't matter. - NULL); // A template file is not being used. - - // Check to make sure the file was actually created. - if (hDumpFile == INVALID_HANDLE_VALUE) { - // CreateFile() failed, so just do nothing more. - return EXCEPTION_CONTINUE_SEARCH; - } - - // Now the file is open, let's write the data we were passed out in a human-readable format. - - // Let's get the name of the module where the exception occured. - HMODULE hMods[1024]; - MODULEINFO modInfo; - HMODULE ipModule = 0; - DWORD cbNeeded; - // Try to get a list of all loaded modules. - if (EnumProcessModules(GetCurrentProcess(), hMods, sizeof(hMods), &cbNeeded)) { - // The list was obtained, walk through each of the modules. - for (DWORD i = 0; i < (cbNeeded / sizeof(HMODULE)); i++) { - // For each module, get the module information (base address, size, entry point) - GetModuleInformation(GetCurrentProcess(), hMods[i], &modInfo, sizeof(MODULEINFO)); - // If the exception address is located in the range of where this module is loaded... - if ( - (ExceptionInfo->ExceptionRecord->ExceptionAddress >= modInfo.lpBaseOfDll) && - (ExceptionInfo->ExceptionRecord->ExceptionAddress < (modInfo.lpBaseOfDll + modInfo.SizeOfImage)) - ) { - // ...this is the module we're looking for! - ipModule = hMods[i]; - break; - } +static PVOID hExceptionHandler; +static char *ExceptionHandlerBuffer; + + +LONG CALLBACK MakeCrashDump(PEXCEPTION_POINTERS ExceptionInfo) +{ + SYSTEMTIME SystemTime; + HANDLE hDumpFile; + DWORD Error; + char *BufPtr; + + /* + * Win32-specific functions will be used wherever possible, + * just in case the C stdlib-equivalents try to allocate + * memory. + * (The Win32-specific functions are generally just wrappers + * over NT system calls anyway.) + */ + if ((ExceptionInfo->ExceptionRecord->ExceptionCode >> 28) != 0xC) { + /* + * ExceptionCode is not a fatal exception (high 4b of + * ntstatus = 0xC) Not going to crash, let's not make + * a crash dump. + */ + return(EXCEPTION_CONTINUE_SEARCH); + } + + /* + * So, the program is about to crash. Oh no what do? + * Let's create a crash dump file as a debugging-aid. + * + * First, get the path to the executable. + */ + GetModuleFileName(NULL,ExceptionHandlerBuffer,ExceptionHandlerBufferSize); + if (GetLastError() != ERROR_SUCCESS) { + /* Could not get full path, create in current directory. */ + BufPtr = ExceptionHandlerBuffer; + } else { + /* + * Walk through the string backwards looking for the + * last backslash, so as to remove the "86Box.exe" + * filename from the string. + */ + BufPtr = &ExceptionHandlerBuffer[strlen(ExceptionHandlerBuffer)]; + for (; BufPtr > ExceptionHandlerBuffer; BufPtr--) { + if (BufPtr[0] == '\\') { + /* Found backslash, terminate the string after it. */ + BufPtr[1] = 0; + break; } } + + BufPtr = &ExceptionHandlerBuffer[strlen(ExceptionHandlerBuffer)]; + } - // Start to put the crash-dump string into the buffer. + /* + * What would a good filename be? + * + * It should contain the current date and time so as + * to be (hopefully!) unique. + */ + GetSystemTime(&SystemTime); + sprintf(CurrentBufferPointer, + "86box-%d%02d%02d-%02d-%02d-%02d-%03d.dmp", + SystemTime.wYear, + SystemTime.wMonth, + SystemTime.wDay, + SystemTime.wHour, + SystemTime.wMinute, + SystemTime.wSecond, + SystemTime.wMilliseconds); + + /* Now the filename is in the buffer, the file can be created. */ + hDumpFile = CreateFile( + ExceptionHandlerBuffer, // The filename of the file to open. + GENERIC_WRITE, // The permissions to request. + 0, // Make sure other processes can't + // touch the crash dump at all + // while it's open. + NULL, // Leave the security descriptor + // undefined, it doesn't matter. + OPEN_ALWAYS, // Opens the file if it exists, + // creates a new file if it doesn't. + FILE_ATTRIBUTE_NORMAL, // File attributes / etc don't matter. + NULL); // A template file is not being used. - sprintf(ExceptionHandlerBuffer, - "86Box version %s crashed on %d-%02d-%02d %02d:%02d:%02d.%03d\r\n\r\n" - "" - "Exception details:\r\n" - "Exception NTSTATUS code: 0x%08x\r\n" - "Occured at address: 0x%p", - emulator_version, SystemTime.wYear, SystemTime.wMonth, SystemTime.wDay, SystemTime.wHour, SystemTime.wMinute, SystemTime.wSecond, SystemTime.wMilliseconds, - - ExceptionInfo->ExceptionRecord->ExceptionCode, - ExceptionInfo->ExceptionRecord->ExceptionAddress); - + /* Check to make sure the file was actually created. */ + if (hDumpFile == INVALID_HANDLE_VALUE) { + /* CreateFile() failed, so just do nothing more. */ + return(EXCEPTION_CONTINUE_SEARCH); + } - // If we found the module that the exception occured in, get the full path to the module the exception occured at and include it. - CurrentBufferPointer = &ExceptionHandlerBuffer[strlen(ExceptionHandlerBuffer)]; - if (ipModule != 0) { - sprintf(CurrentBufferPointer," ["); - GetModuleFileName(ipModule,&CurrentBufferPointer[2],ExceptionHandlerBufferSize - strlen(ExceptionHandlerBuffer)); - if (GetLastError() == ERROR_SUCCESS) { - CurrentBufferPointer = &ExceptionHandlerBuffer[strlen(ExceptionHandlerBuffer)]; - sprintf(CurrentBufferPointer,"]"); - CurrentBufferPointer += 1; + // Now the file is open, let's write the data we were passed out in a human-readable format. + + // Let's get the name of the module where the exception occured. + HMODULE hMods[1024]; + MODULEINFO modInfo; + HMODULE ipModule = 0; + DWORD cbNeeded; + + // Try to get a list of all loaded modules. + if (EnumProcessModules(GetCurrentProcess(), + hMods, sizeof(hMods), &cbNeeded)) { + // The list was obtained, walk through each of the modules. + for (DWORD i = 0; i < (cbNeeded / sizeof(HMODULE)); i++) { + // For each module, get the module information + // (base address, size, entry point) + GetModuleInformation(GetCurrentProcess(), + hMods[i], &modInfo, sizeof(MODULEINFO)); + // If the exception address is located in the range of + // where this module is loaded... + if ( (ExceptionInfo->ExceptionRecord->ExceptionAddress >= modInfo.lpBaseOfDll) && + (ExceptionInfo->ExceptionRecord->ExceptionAddress < (modInfo.lpBaseOfDll + modInfo.SizeOfImage))) { + // ...this is the module we're looking for! + ipModule = hMods[i]; + break; } } + } - // Continue to create the crash-dump string. - sprintf(CurrentBufferPointer, - "\r\n" - "Number of parameters: %d\r\n" - "Exception parameters: ", - ExceptionInfo->ExceptionRecord->NumberParameters); - - // Add the exception parameters to the crash-dump string. - for (int i = 0; i < ExceptionInfo->ExceptionRecord->NumberParameters; i++) { - CurrentBufferPointer = &ExceptionHandlerBuffer[strlen(ExceptionHandlerBuffer)]; - sprintf(CurrentBufferPointer,"0x%p ",ExceptionInfo->ExceptionRecord->ExceptionInformation[i]); + // Start to put the crash-dump string into the buffer. + sprintf(ExceptionHandlerBuffer, + "86Box version %s crashed on %d-%02d-%02d %02d:%02d:%02d.%03d\r\n\r\n" + "" + "Exception details:\r\n" + "Exception NTSTATUS code: 0x%08x\r\n" + "Occured at address: 0x%p", + emulator_version, + SystemTime.wYear, SystemTime.wMonth, SystemTime.wDay, + SystemTime.wHour, SystemTime.wMinute, SystemTime.wSecond, + SystemTime.wMilliseconds, + ExceptionInfo->ExceptionRecord->ExceptionCode, + ExceptionInfo->ExceptionRecord->ExceptionAddress); + + // If we found the module that the exception occured in, get the full path to the module the exception occured at and include it. + BufPtr = &ExceptionHandlerBuffer[strlen(ExceptionHandlerBuffer)]; + if (ipModule != 0) { + sprintf(BufPtr," ["); + GetModuleFileName(ipModule, &BufPtr[2], + ExceptionHandlerBufferSize - strlen(ExceptionHandlerBuffer)); + if (GetLastError() == ERROR_SUCCESS) { + BufPtr = &ExceptionHandlerBuffer[strlen(ExceptionHandlerBuffer)]; + sprintf(BufPtr,"]"); + BufPtr += 1; } + } - CurrentBufferPointer = &ExceptionHandlerBuffer[strlen(ExceptionHandlerBuffer) - 1]; + // Continue to create the crash-dump string. + sprintf(BufPtr, + "\r\n" + "Number of parameters: %d\r\n" + "Exception parameters: ", + ExceptionInfo->ExceptionRecord->NumberParameters); - PCONTEXT Registers = ExceptionInfo->ContextRecord; + // Add the exception parameters to the crash-dump string. + for (int i = 0; i < ExceptionInfo->ExceptionRecord->NumberParameters; i++) { + BufPtr = &ExceptionHandlerBuffer[strlen(ExceptionHandlerBuffer)]; + sprintf(BufPtr,"0x%p ", + ExceptionInfo->ExceptionRecord->ExceptionInformation[i]); + } + BufPtr = &ExceptionHandlerBuffer[strlen(ExceptionHandlerBuffer) - 1]; + + PCONTEXT Registers = ExceptionInfo->ContextRecord; - #if defined(__i386__) && !defined(__x86_64) - // This binary is being compiled for x86, include a register dump. - sprintf(CurrentBufferPointer, - "\r\n" - "Register dump:\r\n" - "eax=0x%08x ebx=0x%08x ecx=0x%08x edx=0x%08x ebp=0x%08x esp=0x%08x esi=0x%08x edi=0x%08x eip=0x%08x\r\n" - "\r\n", - Registers->Eax, Registers->Ebx, Registers->Ecx, Registers->Edx, Registers->Ebp, Registers->Esp, Registers->Esi, Registers->Edi, Registers->Eip); - #else - // Register dump is supported by no other architectures right now. MinGW headers seem to lack the x64 CONTEXT structure definition. - sprintf(CurrentBufferPointer,"\r\n"); - #endif +#if defined(__i386__) && !defined(__x86_64) + // This binary is being compiled for x86, include a register dump. + sprintf(BufPtr, + "\r\n" + "Register dump:\r\n" + "eax=0x%08x ebx=0x%08x ecx=0x%08x edx=0x%08x ebp=0x%08x esp=0x%08x esi=0x%08x edi=0x%08x eip=0x%08x\r\n" + "\r\n", + Registers->Eax, Registers->Ebx, Registers->Ecx, Registers->Edx, Registers->Ebp, Registers->Esp, Registers->Esi, Registers->Edi, Registers->Eip); +#else + // Register dump is supported by no other architectures right now. MinGW headers seem to lack the x64 CONTEXT structure definition. + sprintf(BufPtr,"\r\n"); +#endif - // The crash-dump string has been created, write it to disk. - WriteFile(hDumpFile, - ExceptionHandlerBuffer, - strlen(ExceptionHandlerBuffer), - NULL, - NULL); - - // Finally, close the file. - CloseHandle(hDumpFile); - - // And return, therefore causing the crash, but only after the crash dump has been created. - - return EXCEPTION_CONTINUE_SEARCH; + // The crash-dump string has been created, write it to disk. + WriteFile(hDumpFile, ExceptionHandlerBuffer, + strlen(ExceptionHandlerBuffer), NULL, NULL); + + // Finally, close the file. + CloseHandle(hDumpFile); + + // And return, therefore causing the crash, + // but only after the crash dump has been created. + return(EXCEPTION_CONTINUE_SEARCH); } -void InitCrashDump() { - // An exception handler should not allocate memory, so allocate 10kb for it to use if it gets called, an amount which should be more than enough. - ExceptionHandlerBuffer = malloc(ExceptionHandlerBufferSize); - // Register the exception handler. Zero first argument means this exception handler gets called last, therefore, crash dump is only made, when a crash is going to happen. - hExceptionHandler = AddVectoredExceptionHandler(0,MakeCrashDump); + +void InitCrashDump(void) +{ + /* + * An exception handler should not allocate memory, + * so allocate 10kb for it to use if it gets called, + * an amount which should be more than enough. + */ + ExceptionHandlerBuffer = malloc(ExceptionHandlerBufferSize); + + /* + * Register the exception handler. + * Zero first argument means this exception handler gets + * called last, therefore, crash dump is only made, when + * a crash is going to happen. + */ + hExceptionHandler = AddVectoredExceptionHandler(0, MakeCrashDump); } diff --git a/src/WIN/win_d3d-fs.h b/src/WIN/win_d3d-fs.h deleted file mode 100644 index 41ca32e21..000000000 --- a/src/WIN/win_d3d-fs.h +++ /dev/null @@ -1,13 +0,0 @@ -/* Copyright holders: Sarah Walker, Tenshi - see COPYING for more details -*/ -#ifdef __cplusplus -extern "C" { -#endif - int d3d_fs_init(HWND h); - void d3d_fs_close(); - void d3d_fs_reset(); - void d3d_fs_resize(int x, int y); -#ifdef __cplusplus -} -#endif diff --git a/src/WIN/win_d3d.cc b/src/WIN/win_d3d.cc index 258bcd4f8..ce2d9a3b5 100644 --- a/src/WIN/win_d3d.cc +++ b/src/WIN/win_d3d.cc @@ -2,14 +2,9 @@ see COPYING for more details */ #include -#define UNICODE -#define BITMAP WINDOWS_BITMAP -#include -#undef BITMAP -#include +#include "../video/video.h" #include "win.h" #include "win_d3d.h" -#include "../video/video.h" #include "win_cgapal.h" #include "resource.h" diff --git a/src/WIN/win_d3d.h b/src/WIN/win_d3d.h index 7210d454b..5994a87b1 100644 --- a/src/WIN/win_d3d.h +++ b/src/WIN/win_d3d.h @@ -1,13 +1,32 @@ /* Copyright holders: Sarah Walker, Tenshi see COPYING for more details */ +#ifndef WIN_D3D_H +# define WIN_D3D_H +# define UNICODE +# define BITMAP WINDOWS_BITMAP +# include +# include +# undef BITMAP + + #ifdef __cplusplus extern "C" { #endif - int d3d_init(HWND h); - void d3d_close(); - void d3d_reset(); - void d3d_resize(int x, int y); + +extern int d3d_init(HWND h); +extern void d3d_close(void); +extern void d3d_reset(void); +extern void d3d_resize(int x, int y); + +extern int d3d_fs_init(HWND h); +extern void d3d_fs_close(void); +extern void d3d_fs_reset(void); +extern void d3d_fs_resize(int x, int y); + #ifdef __cplusplus } #endif + + +#endif /*WIN_D3D_H*/ diff --git a/src/WIN/win_d3d-fs.cc b/src/WIN/win_d3d_fs.cc similarity index 99% rename from src/WIN/win_d3d-fs.cc rename to src/WIN/win_d3d_fs.cc index 4e6a367cb..9e410ec3b 100644 --- a/src/WIN/win_d3d-fs.cc +++ b/src/WIN/win_d3d_fs.cc @@ -3,15 +3,10 @@ */ #include #include -#define UNICODE -#define BITMAP WINDOWS_BITMAP -#include -#undef BITMAP -#include #include "../86box.h" #include "../video/video.h" #include "win.h" -#include "win_d3d-fs.h" +#include "win_d3d.h" #include "win_cgapal.h" #include "resource.h" @@ -110,6 +105,7 @@ static CUSTOMVERTEX d3d_verts[] = {2048.0f, 2048.0f, 1.0f, 1.0f, 1.0f, 1.0f}, }; + void cgapal_rebuild(void) { int c; @@ -133,6 +129,7 @@ void cgapal_rebuild(void) } } + int d3d_fs_init(HWND h) { HRESULT hr; @@ -197,6 +194,7 @@ int d3d_fs_init(HWND h) return 1; } + static void d3d_fs_close_objects(void) { if (d3dTexture) @@ -211,6 +209,7 @@ static void d3d_fs_close_objects(void) } } + static void d3d_fs_init_objects(void) { D3DLOCKED_RECT dr; @@ -248,6 +247,7 @@ static void d3d_fs_init_objects(void) d3ddev->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR); } + /*void d3d_resize(int x, int y) { HRESULT hr; @@ -258,6 +258,7 @@ static void d3d_fs_init_objects(void) d3d_reset(); }*/ + void d3d_fs_reset(void) { HRESULT hr; @@ -293,6 +294,7 @@ void d3d_fs_reset(void) device_force_redraw(); } + void d3d_fs_close(void) { if (d3dTexture) @@ -318,6 +320,7 @@ void d3d_fs_close(void) DestroyWindow(d3d_device_window); } + static void d3d_fs_size(RECT window_rect, double *l, double *t, double *r, double *b, int w, int h) { int ratio_w, ratio_h; @@ -368,6 +371,7 @@ static void d3d_fs_size(RECT window_rect, double *l, double *t, double *r, doubl } } + static void d3d_fs_blit_memtoscreen(int x, int y, int y1, int y2, int w, int h) { HRESULT hr = D3D_OK; @@ -466,6 +470,7 @@ static void d3d_fs_blit_memtoscreen(int x, int y, int y1, int y2, int w, int h) PostMessage(ghwnd, WM_RESETD3D, 0, 0); } + static void d3d_fs_blit_memtoscreen_8(int x, int y, int w, int h) { HRESULT hr = D3D_OK; @@ -573,6 +578,7 @@ static void d3d_fs_blit_memtoscreen_8(int x, int y, int w, int h) PostMessage(ghwnd, WM_RESETD3D, 0, 0); } + void d3d_fs_take_screenshot(wchar_t *fn) { LPDIRECT3DSURFACE9 d3dSurface = NULL; diff --git a/src/WIN/win_ddraw-fs.h b/src/WIN/win_ddraw-fs.h deleted file mode 100644 index 048c9c160..000000000 --- a/src/WIN/win_ddraw-fs.h +++ /dev/null @@ -1,11 +0,0 @@ -/* Copyright holders: Sarah Walker, Tenshi - see COPYING for more details -*/ -#ifdef __cplusplus -extern "C" { -#endif - int ddraw_fs_init(HWND h); - void ddraw_fs_close(); -#ifdef __cplusplus -} -#endif diff --git a/src/WIN/win_ddraw-screenshot.h b/src/WIN/win_ddraw-screenshot.h deleted file mode 100644 index 4739174a1..000000000 --- a/src/WIN/win_ddraw-screenshot.h +++ /dev/null @@ -1,4 +0,0 @@ -/* Copyright holders: Tenshi - see COPYING for more details -*/ -void ddraw_common_take_screenshot(wchar_t *fn, IDirectDrawSurface7 *pDDSurface); diff --git a/src/WIN/win_ddraw.cc b/src/WIN/win_ddraw.cc index af329eb29..dd985baf8 100644 --- a/src/WIN/win_ddraw.cc +++ b/src/WIN/win_ddraw.cc @@ -3,13 +3,8 @@ */ #include #include -#define UNICODE -#define BITMAP WINDOWS_BITMAP -#include -#undef BITMAP #include "../video/video.h" #include "win_ddraw.h" -#include "win_ddraw-screenshot.h" #include "win_cgapal.h" diff --git a/src/WIN/win_ddraw.h b/src/WIN/win_ddraw.h index a4044899d..5090aa0cc 100644 --- a/src/WIN/win_ddraw.h +++ b/src/WIN/win_ddraw.h @@ -1,12 +1,30 @@ /* Copyright holders: Sarah Walker, Tenshi see COPYING for more details */ +#ifndef WIN_DDRAW_H +# define WIN_DDRAW_H +# define UNICODE +# define BITMAP WINDOWS_BITMAP +# include +# undef BITMAP + + #ifdef __cplusplus extern "C" { #endif - int ddraw_init(HWND h); - void ddraw_close(); + +extern int ddraw_init(HWND h); +extern void ddraw_close(void); + +extern int ddraw_fs_init(HWND h); +extern void ddraw_fs_close(void); + +extern void ddraw_common_take_screenshot(wchar_t *fn, + IDirectDrawSurface7 *pDDSurface); + #ifdef __cplusplus } #endif + +#endif /*WIN_DDRAW_H*/ diff --git a/src/WIN/win_ddraw-fs.cc b/src/WIN/win_ddraw_fs.cc similarity index 97% rename from src/WIN/win_ddraw-fs.cc rename to src/WIN/win_ddraw_fs.cc index 42fd984ed..88649f7e9 100644 --- a/src/WIN/win_ddraw-fs.cc +++ b/src/WIN/win_ddraw_fs.cc @@ -2,16 +2,22 @@ see COPYING for more details */ #include -#define UNICODE -#define BITMAP WINDOWS_BITMAP -#include -#undef BITMAP #include "../video/video.h" -#include "win_ddraw-fs.h" -#include "win_ddraw-screenshot.h" +#include "win_ddraw.h" #include "win_cgapal.h" +static LPDIRECTDRAW lpdd = NULL; +static LPDIRECTDRAW7 lpdd7 = NULL; +static LPDIRECTDRAWSURFACE7 lpdds_pri = NULL; +static LPDIRECTDRAWSURFACE7 lpdds_back = NULL; +static LPDIRECTDRAWSURFACE7 lpdds_back2 = NULL; +static LPDIRECTDRAWCLIPPER lpdd_clipper = NULL; +static DDSURFACEDESC2 ddsd; +static HWND ddraw_hwnd; +static int ddraw_w, ddraw_h; + + extern "C" void fatal(const char *format, ...); extern "C" void pclog(const char *format, ...); @@ -22,19 +28,9 @@ extern "C" void ddraw_fs_close(void); extern "C" void video_blit_complete(void); -static void ddraw_fs_blit_memtoscreen(int x, int y, int y1, int y2, int w, int h); -static void ddraw_fs_blit_memtoscreen_8(int x, int y, int w, int h); +static void ddraw_fs_blit_memtoscreen(int, int, int, int, int, int); +static void ddraw_fs_blit_memtoscreen_8(int, int, int, int); -static LPDIRECTDRAW lpdd = NULL; -static LPDIRECTDRAW7 lpdd7 = NULL; -static LPDIRECTDRAWSURFACE7 lpdds_pri = NULL; -static LPDIRECTDRAWSURFACE7 lpdds_back = NULL; -static LPDIRECTDRAWSURFACE7 lpdds_back2 = NULL; -static LPDIRECTDRAWCLIPPER lpdd_clipper = NULL; -static DDSURFACEDESC2 ddsd; - -static HWND ddraw_hwnd; -static int ddraw_w, ddraw_h; int ddraw_fs_init(HWND h) { diff --git a/src/WIN/win_ddraw-screenshot.cc b/src/WIN/win_ddraw_screenshot.cc similarity index 94% rename from src/WIN/win_ddraw-screenshot.cc rename to src/WIN/win_ddraw_screenshot.cc index bb3cb6660..717b94348 100644 --- a/src/WIN/win_ddraw-screenshot.cc +++ b/src/WIN/win_ddraw_screenshot.cc @@ -5,25 +5,20 @@ #include #define UNICODE #define BITMAP WINDOWS_BITMAP -#include +#include #undef BITMAP #include "../video/video.h" #include "win.h" -#include "win_ddraw-screenshot.h" +#include "win_ddraw.h" #include "win_language.h" -extern "C" void fatal(const char *format, ...); +HBITMAP hbitmap; +int xs, ys, ys2; + + extern "C" void pclog(const char *format, ...); -extern "C" void device_force_redraw(void); - -extern "C" void ddraw_init(HWND h); -extern "C" void ddraw_close(void); - -HBITMAP hbitmap; - -int xs, ys, ys2; void CopySurface(IDirectDrawSurface7 *pDDSurface) { @@ -58,6 +53,7 @@ void CopySurface(IDirectDrawSurface7 *pDDSurface) return ; } + void DoubleLines(uint8_t *dst, uint8_t *src) { int i = 0; diff --git a/src/WIN/win_deviceconfig.c b/src/WIN/win_deviceconfig.c index 457a38f75..c64dd3af7 100644 --- a/src/WIN/win_deviceconfig.c +++ b/src/WIN/win_deviceconfig.c @@ -1,19 +1,18 @@ /* Copyright holders: Sarah Walker see COPYING for more details */ -#define BITMAP WINDOWS_BITMAP -#include -#include -#undef BITMAP - #include "../ibm.h" #include "../config.h" #include "../device.h" #include "resource.h" +#define NO_UNICODE /*FIXME: not Unicode? */ #include "win.h" +#include + static device_t *config_device; + static BOOL CALLBACK deviceconfig_dlgproc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam) { HWND h; diff --git a/src/config.c b/src/config.c index 04557b544..26e65cfe6 100644 --- a/src/config.c +++ b/src/config.c @@ -6,8 +6,6 @@ #include #include #include -#include - #include "cdrom.h" #include "config.h" #include "device.h" @@ -30,15 +28,8 @@ #include "sound/snd_opl.h" #include "sound/sound.h" #include "video/video.h" - -#ifndef __unix -#define UNICODE -#define BITMAP WINDOWS_BITMAP -#include -#undef BITMAP #include "win.h" #include "win_language.h" -#endif wchar_t config_file_default[256]; diff --git a/src/net_ne2000.c b/src/net_ne2000.c index e0435367c..88b97cf40 100644 --- a/src/net_ne2000.c +++ b/src/net_ne2000.c @@ -11,7 +11,7 @@ * NOTE: Its still a mess, but we're getting there. The file will * also implement an NE1000 for 8-bit ISA systems. * - * Version: @(#)net_ne2000.c 1.0.5 2017/05/21 + * Version: @(#)net_ne2000.c 1.0.6 2017/05/23 * * Authors: Fred N. van Kempen, * Peter Grehan, grehan@iprg.nokia.com> @@ -37,8 +37,9 @@ #include "network.h" #include "net_ne2000.h" #include "bswap.h" + #ifdef WALTJE -# define ENABLE_NE2000_LOG 1 +# define ENABLE_NE2000_LOG 2 #endif @@ -202,7 +203,7 @@ typedef struct { uint8_t mem[NE2K_MEMSIZ]; /* on-chip packet memory */ int board; - int is_rtl8029as; + int is_pci; char name[32]; uint32_t base_address; int base_irq; @@ -210,11 +211,10 @@ typedef struct { bios_size, bios_mask; bar_t pci_bar[2]; - int disable_netbios; + uint8_t pci_regs[256]; int tx_timer_index; int tx_timer_active; uint8_t maclocal[6]; /* configured MAC (local) address */ - uint8_t pci_regs[256]; uint8_t eeprom[128]; /* for RTL8029AS */ rom_t bios_rom; } nic_t; @@ -234,10 +234,10 @@ nelog(int lvl, const char *fmt, ...) va_start(ap, fmt); vprintf(fmt, ap); va_end(ap); + fflush(stdout); } #endif } -#define pclog nelog /* reset - restore state to power-up, cancelling all i/o */ @@ -247,7 +247,7 @@ nic_reset(void *priv, int reset) nic_t *dev = (nic_t *)priv; int i; - pclog(1, "%s: reset\n", dev->name); + nelog(1, "%s: reset\n", dev->name); /* Initialize the MAC address area by doubling the physical address */ dev->macaddr[0] = dev->physaddr[0]; @@ -264,9 +264,8 @@ nic_reset(void *priv, int reset) dev->macaddr[11] = dev->physaddr[5]; /* ne2k signature */ - for (i = 12; i < 32; i++) { + for (i=12; i<32; i++) dev->macaddr[i] = 0x57; - } /* Zero out registers and memory */ memset(&dev->CR, 0x00, sizeof(dev->CR) ); @@ -324,7 +323,7 @@ chipmem_read(nic_t *dev, uint32_t addr, unsigned int len) uint32_t retval = 0; if ((len == 2) && (addr & 0x1)) { - pclog(1, "%s: unaligned chipmem word read\n", dev->name); + nelog(3, "%s: unaligned chipmem word read\n", dev->name); } /* ROM'd MAC address */ @@ -352,9 +351,9 @@ chipmem_read(nic_t *dev, uint32_t addr, unsigned int len) return(retval); } - pclog(1, "%s: out-of-bounds chipmem read, %04X\n", dev->name, addr); + nelog(3, "%s: out-of-bounds chipmem read, %04X\n", dev->name, addr); - if (dev->is_rtl8029as) { + if (dev->is_pci) { return(0xff); } else { switch(len) { @@ -373,7 +372,7 @@ static void chipmem_write(nic_t *dev, uint32_t addr, uint32_t val, unsigned len) { if ((len == 2) && (addr & 0x1)) { - pclog(1, "%s: unaligned chipmem word write\n", dev->name); + nelog(3, "%s: unaligned chipmem word write\n", dev->name); } if ((addr >= NE2K_MEMSTART) && (addr < NE2K_MEMEND)) { @@ -386,7 +385,7 @@ chipmem_write(nic_t *dev, uint32_t addr, uint32_t val, unsigned len) dev->mem[addr-NE2K_MEMSTART+3] = val >> 24; } } else { - pclog(1, "%s: out-of-bounds chipmem write, %04X\n", dev->name, addr); + nelog(3, "%s: out-of-bounds chipmem write, %04X\n", dev->name, addr); } } @@ -411,11 +410,11 @@ asic_read(nic_t *dev, uint32_t off, unsigned int len) and the source-address and length registers must have been initialised. */ if (len > dev->remote_bytes) { - pclog(1, "%s: DMA read underrun iolen=%d remote_bytes=%d\n", + nelog(3, "%s: DMA read underrun iolen=%d remote_bytes=%d\n", dev->name, len, dev->remote_bytes); } - pclog(2, "%s: DMA read: addr=%4x remote_bytes=%d\n", + nelog(3, "%s: DMA read: addr=%4x remote_bytes=%d\n", dev->name, dev->remote_dma,dev->remote_bytes); retval = chipmem_read(dev, dev->remote_dma, len); @@ -457,7 +456,7 @@ asic_read(nic_t *dev, uint32_t off, unsigned int len) break; default: - pclog(1, "%s: ASIC read invalid address %04x\n", + nelog(3, "%s: ASIC read invalid address %04x\n", dev->name, (unsigned)off); break; } @@ -469,17 +468,17 @@ asic_read(nic_t *dev, uint32_t off, unsigned int len) static void asic_write(nic_t *dev, uint32_t off, uint32_t val, unsigned len) { - pclog(2, "%s: asic write addr=0x%02x, value=0x%04x\n", + nelog(3, "%s: asic write addr=0x%02x, value=0x%04x\n", dev->name, (unsigned)off, (unsigned) val); switch(off) { case 0x00: /* Data register - see asic_read for a description */ if ((len > 1) && (dev->DCR.wdsize == 0)) { - pclog(2, "%s: DMA write length %d on byte mode operation\n", + nelog(3, "%s: DMA write length %d on byte mode operation\n", dev->name, len); break; } if (dev->remote_bytes == 0) { - pclog(2, "%s: DMA write, byte count 0\n", dev->name); + nelog(3, "%s: DMA write, byte count 0\n", dev->name); } chipmem_write(dev, dev->remote_dma, val, len); @@ -517,7 +516,7 @@ asic_write(nic_t *dev, uint32_t off, uint32_t val, unsigned len) break; default: /* this is invalid, but happens under win95 device detection */ - pclog(1, "%s: ASIC write invalid address %04x, ignoring\n", + nelog(3, "%s: ASIC write invalid address %04x, ignoring\n", dev->name, (unsigned)off); break; } @@ -533,7 +532,7 @@ page0_read(nic_t *dev, uint32_t off, unsigned int len) if (len > 1) { /* encountered with win98 hardware probe */ - pclog(1, "%s: bad length! Page0 read from register 0x%02x, len=%u\n", + nelog(3, "%s: bad length! Page0 read from register 0x%02x, len=%u\n", dev->name, off, len); return(retval); } @@ -567,7 +566,7 @@ page0_read(nic_t *dev, uint32_t off, unsigned int len) case 0x06: /* FIFO */ /* reading FIFO is only valid in loopback mode */ - pclog(1, "%s: reading FIFO not supported yet\n", dev->name); + nelog(3, "%s: reading FIFO not supported yet\n", dev->name); retval = dev->fifo; break; @@ -591,19 +590,19 @@ page0_read(nic_t *dev, uint32_t off, unsigned int len) break; case 0x0a: /* reserved / RTL8029ID0 */ - if (dev->is_rtl8029as) { + if (dev->is_pci) { retval = 0x50; } else { - pclog(1, "%s: reserved Page0 read - 0x0a\n", dev->name); + nelog(3, "%s: reserved Page0 read - 0x0a\n", dev->name); retval = 0xff; } break; case 0x0b: /* reserved / RTL8029ID1 */ - if (dev->is_rtl8029as) { + if (dev->is_pci) { retval = 0x43; } else { - pclog(1, "%s: reserved Page0 read - 0x0b\n", dev->name); + nelog(3, "%s: reserved Page0 read - 0x0b\n", dev->name); retval = 0xff; } break; @@ -632,12 +631,12 @@ page0_read(nic_t *dev, uint32_t off, unsigned int len) break; default: - pclog(1, "%s: Page0 register 0x%02x out of range\n", + nelog(3, "%s: Page0 register 0x%02x out of range\n", dev->name, off); break; } - pclog(2, "%s: Page0 read from register 0x%02x, value=0x%02x\n", + nelog(3, "%s: Page0 read from register 0x%02x, value=0x%02x\n", dev->name, off, retval); return(retval); @@ -659,7 +658,7 @@ page0_write(nic_t *dev, uint32_t off, uint32_t val, unsigned len) return; } - pclog(2, "%s: Page0 write to register 0x%02x, value=0x%02x\n", + nelog(3, "%s: Page0 write to register 0x%02x, value=0x%02x\n", dev->name, off, val); switch(off) { @@ -749,7 +748,7 @@ page0_write(nic_t *dev, uint32_t off, uint32_t val, unsigned len) case 0x0c: /* RCR */ /* Check if the reserved bits are set */ if (val & 0xc0) { - pclog(1, "%s: RCR write, reserved bits set\n", + nelog(3, "%s: RCR write, reserved bits set\n", dev->name); } @@ -762,30 +761,30 @@ page0_write(nic_t *dev, uint32_t off, uint32_t val, unsigned len) dev->RCR.monitor = ((val & 0x20) == 0x20); /* Monitor bit is a little suspicious... */ - if (val & 0x20) pclog(1, "%s: RCR write, monitor bit set!\n", + if (val & 0x20) nelog(3, "%s: RCR write, monitor bit set!\n", dev->name); break; case 0x0d: /* TCR */ /* Check reserved bits */ - if (val & 0xe0) pclog(1, "%s: TCR write, reserved bits set\n", + if (val & 0xe0) nelog(3, "%s: TCR write, reserved bits set\n", dev->name); /* Test loop mode (not supported) */ if (val & 0x06) { dev->TCR.loop_cntl = (val & 0x6) >> 1; - pclog(1, "%s: TCR write, loop mode %d not supported\n", + nelog(3, "%s: TCR write, loop mode %d not supported\n", dev->name, dev->TCR.loop_cntl); } else { dev->TCR.loop_cntl = 0; } /* Inhibit-CRC not supported. */ - if (val & 0x01) pclog(1, + if (val & 0x01) nelog(3, "%s: TCR write, inhibit-CRC not supported\n",dev->name); /* Auto-transmit disable very suspicious */ - if (val & 0x08) pclog(1, + if (val & 0x08) nelog(3, "%s: TCR write, auto transmit disable not supported\n", dev->name); @@ -795,16 +794,16 @@ page0_write(nic_t *dev, uint32_t off, uint32_t val, unsigned len) case 0x0e: /* DCR */ /* the loopback mode is not suppported yet */ - if (! (val & 0x08)) pclog(1, + if (! (val & 0x08)) nelog(3, "%s: DCR write, loopback mode selected\n", dev->name); /* It is questionable to set longaddr and auto_rx, since * they are not supported on the NE2000. Print a warning * and continue. */ if (val & 0x04) - pclog(1, "%s: DCR write - LAS set ???\n", dev->name); + nelog(3, "%s: DCR write - LAS set ???\n", dev->name); if (val & 0x10) - pclog(1, "%s: DCR write - AR set ???\n", dev->name); + nelog(3, "%s: DCR write - AR set ???\n", dev->name); /* Set other values. */ dev->DCR.wdsize = ((val & 0x01) == 0x01); @@ -818,7 +817,7 @@ page0_write(nic_t *dev, uint32_t off, uint32_t val, unsigned len) case 0x0f: /* IMR */ /* Check for reserved bit */ if (val & 0x80) - pclog(1, "%s: IMR write, reserved bit set\n",dev->name); + nelog(3, "%s: IMR write, reserved bit set\n",dev->name); /* Set other values */ dev->IMR.rx_inte = ((val & 0x01) == 0x01); @@ -843,7 +842,7 @@ page0_write(nic_t *dev, uint32_t off, uint32_t val, unsigned len) break; default: - pclog(1, "%s: Page0 write, bad register 0x%02x\n", + nelog(3, "%s: Page0 write, bad register 0x%02x\n", dev->name, off); break; } @@ -855,7 +854,7 @@ page0_write(nic_t *dev, uint32_t off, uint32_t val, unsigned len) static uint32_t page1_read(nic_t *dev, uint32_t off, unsigned int len) { - pclog(2, "%s: Page1 read from register 0x%02x, len=%u\n", + nelog(3, "%s: Page1 read from register 0x%02x, len=%u\n", dev->name, off, len); switch(off) { @@ -868,7 +867,7 @@ page1_read(nic_t *dev, uint32_t off, unsigned int len) return(dev->physaddr[off - 1]); case 0x07: /* CURR */ - pclog(2, "%s: returning current page: 0x%02x\n", + nelog(3, "%s: returning current page: 0x%02x\n", dev->name, (dev->curr_page)); return(dev->curr_page); @@ -883,7 +882,7 @@ page1_read(nic_t *dev, uint32_t off, unsigned int len) return(dev->mchash[off - 8]); default: - pclog(1, "%s: Page1 read register 0x%02x out of range\n", + nelog(3, "%s: Page1 read register 0x%02x out of range\n", dev->name, off); return(0); } @@ -893,7 +892,7 @@ page1_read(nic_t *dev, uint32_t off, unsigned int len) static void page1_write(nic_t *dev, uint32_t off, uint32_t val, unsigned len) { - pclog(2, "%s: Page1 write to register 0x%02x, len=%u, value=0x%04x\n", + nelog(3, "%s: Page1 write to register 0x%02x, len=%u, value=0x%04x\n", dev->name, off, len, val); switch(off) { @@ -904,7 +903,7 @@ page1_write(nic_t *dev, uint32_t off, uint32_t val, unsigned len) case 0x05: case 0x06: dev->physaddr[off - 1] = val; - if (off == 6) pclog(1, + if (off == 6) nelog(3, "%s: physical address set to %02x:%02x:%02x:%02x:%02x:%02x\n", dev->name, dev->physaddr[0], dev->physaddr[1], @@ -928,7 +927,7 @@ page1_write(nic_t *dev, uint32_t off, uint32_t val, unsigned len) break; default: - pclog(1, "%s: Page1 write register 0x%02x out of range\n", + nelog(3, "%s: Page1 write register 0x%02x out of range\n", dev->name, off); break; } @@ -940,7 +939,7 @@ page1_write(nic_t *dev, uint32_t off, uint32_t val, unsigned len) static uint32_t page2_read(nic_t *dev, uint32_t off, unsigned int len) { - pclog(2, "%s: Page2 read from register 0x%02x, len=%u\n", + nelog(3, "%s: Page2 read from register 0x%02x, len=%u\n", dev->name, off, len); switch(off) { @@ -969,7 +968,7 @@ page2_read(nic_t *dev, uint32_t off, unsigned int len) case 0x09: case 0x0a: case 0x0b: - pclog(1, "%s: reserved Page2 read - register 0x%02x\n", + nelog(3, "%s: reserved Page2 read - register 0x%02x\n", dev->name, off); return(0xff); @@ -1005,7 +1004,7 @@ page2_read(nic_t *dev, uint32_t off, unsigned int len) (dev->IMR.rx_inte)); default: - pclog(1, "%s: Page2 register 0x%02x out of range\n", + nelog(3, "%s: Page2 register 0x%02x out of range\n", dev->name, off); break; } @@ -1020,7 +1019,7 @@ page2_write(nic_t *dev, uint32_t off, uint32_t val, unsigned len) /* Maybe all writes here should be BX_PANIC()'d, since they affect internal operation, but let them through for now and print a warning. */ - pclog(2, "%s: Page2 write to register 0x%02x, len=%u, value=0x%04x\n", + nelog(3, "%s: Page2 write to register 0x%02x, len=%u, value=0x%04x\n", dev->name, off, len, val); switch(off) { case 0x01: /* CLDA0 */ @@ -1040,7 +1039,7 @@ page2_write(nic_t *dev, uint32_t off, uint32_t val, unsigned len) break; case 0x04: - pclog(1, "page 2 write to reserved register 0x04\n"); + nelog(3, "page 2 write to reserved register 0x04\n"); break; case 0x05: /* Local Next-packet pointer */ @@ -1067,12 +1066,12 @@ page2_write(nic_t *dev, uint32_t off, uint32_t val, unsigned len) case 0x0d: case 0x0e: case 0x0f: - pclog(1, "%s: Page2 write to reserved register 0x%02x\n", + nelog(3, "%s: Page2 write to reserved register 0x%02x\n", dev->name, off); break; default: - pclog(1, "%s: Page2 write, illegal register 0x%02x\n", + nelog(3, "%s: Page2 write, illegal register 0x%02x\n", dev->name, off); break; } @@ -1083,7 +1082,7 @@ page2_write(nic_t *dev, uint32_t off, uint32_t val, unsigned len) static uint32_t page3_read(nic_t *dev, uint32_t off, unsigned int len) { - if (dev->is_rtl8029as) switch(off) { + if (dev->is_pci) switch(off) { case 0x3: /* CONFIG0 */ return(0x00); @@ -1097,7 +1096,7 @@ page3_read(nic_t *dev, uint32_t off, unsigned int len) break; } - pclog(1, "%s: Page3 read register 0x%02x attempted\n", dev->name, off); + nelog(3, "%s: Page3 read register 0x%02x attempted\n", dev->name, off); return(0x00); } @@ -1105,7 +1104,7 @@ page3_read(nic_t *dev, uint32_t off, unsigned int len) static void page3_write(nic_t *dev, uint32_t off, uint32_t val, unsigned len) { - pclog(1, "%s: Page3 write register 0x%02x attempted\n", dev->name, off); + nelog(3, "%s: Page3 write register 0x%02x attempted\n", dev->name, off); } @@ -1121,7 +1120,7 @@ read_cr(nic_t *dev) (dev->CR.tx_packet << 2) | (dev->CR.start << 1) | (dev->CR.stop)); - pclog(2, "%s: read CR returns 0x%02x\n", dev->name, retval); + nelog(3, "%s: read CR returns 0x%02x\n", dev->name, retval); return(retval); } @@ -1130,11 +1129,11 @@ read_cr(nic_t *dev) static void write_cr(nic_t *dev, uint32_t val) { - pclog(2, "%s: wrote 0x%02x to CR\n", dev->name, val); + nelog(3, "%s: wrote 0x%02x to CR\n", dev->name, val); /* Validate remote-DMA */ if ((val & 0x38) == 0x00) { - pclog(2, "%s: CR write - invalid rDMA value 0\n", dev->name); + nelog(3, "%s: CR write - invalid rDMA value 0\n", dev->name); val |= 0x20; /* dma_cmd == 4 is a safe default */ } @@ -1150,9 +1149,8 @@ write_cr(nic_t *dev, uint32_t val) /* If start command issued, the RST bit in the ISR */ /* must be cleared */ - if ((val & 0x02) && !dev->CR.start) { + if ((val & 0x02) && !dev->CR.start) dev->ISR.reset = 0; - } dev->CR.start = ((val & 0x02) == 0x02); dev->CR.pgsel = (val & 0xc0) >> 6; @@ -1162,14 +1160,14 @@ write_cr(nic_t *dev, uint32_t val) /* Set up DMA read from receive ring */ dev->remote_start = dev->remote_dma = dev->bound_ptr * 256; dev->remote_bytes = (uint16_t) chipmem_read(dev, dev->bound_ptr * 256 + 2, 2); - pclog(2, "%s: sending buffer #x%x length %d\n", + nelog(3, "%s: sending buffer #x%x length %d\n", dev->name, dev->remote_start, dev->remote_bytes); } /* Check for start-tx */ if ((val & 0x04) && dev->TCR.loop_cntl) { if (dev->TCR.loop_cntl != 1) { - pclog(1, "%s: loop mode %d not supported\n", + nelog(3, "%s: loop mode %d not supported\n", dev->name, dev->TCR.loop_cntl); } else { nic_rx(dev, @@ -1177,15 +1175,15 @@ write_cr(nic_t *dev, uint32_t val) dev->tx_bytes); } } else if (val & 0x04) { - if (dev->CR.stop || (!dev->CR.start && !dev->is_rtl8029as)) { + if (dev->CR.stop || (!dev->CR.start && !dev->is_pci)) { if (dev->tx_bytes == 0) /* njh@bandsman.co.uk */ { return; /* Solaris9 probe */ } - pclog(1, "%s: CR write - tx start, dev in reset\n", dev->name); + nelog(3, "%s: CR write - tx start, dev in reset\n", dev->name); } if (dev->tx_bytes == 0) - pclog(1, "%s: CR write - tx start, tx bytes == 0\n", dev->name); + nelog(3, "%s: CR write - tx start, tx bytes == 0\n", dev->name); /* Send the packet to the system driver */ dev->CR.tx_packet = 1; @@ -1194,7 +1192,7 @@ write_cr(nic_t *dev, uint32_t val) /* some more debug */ if (dev->tx_timer_active) - pclog(1, "%s: CR write, tx timer still active\n", dev->name); + nelog(3, "%s: CR write, tx timer still active\n", dev->name); nic_tx(dev, val); } @@ -1206,9 +1204,8 @@ write_cr(nic_t *dev, uint32_t val) dev->ISR.rdma_done = 1; if (dev->IMR.rdma_inte) { picint(1 << dev->base_irq); - if (! dev->is_rtl8029as) { + if (! dev->is_pci) picintc(1 << dev->base_irq); - } } } } @@ -1220,7 +1217,7 @@ nic_read(nic_t *dev, uint32_t addr, unsigned len) uint32_t retval = 0; int off = addr - dev->base_address; - pclog(2, "%s: read addr %x, len %d\n", dev->name, addr, len); + nelog(3, "%s: read addr %x, len %d\n", dev->name, addr, len); if (off >= 0x10) { retval = asic_read(dev, off - 0x10, len); @@ -1244,7 +1241,7 @@ nic_read(nic_t *dev, uint32_t addr, unsigned len) break; default: - pclog(1, "%s: unknown value of pgsel in read - %d\n", + nelog(3, "%s: unknown value of pgsel in read - %d\n", dev->name, dev->CR.pgsel); break; } @@ -1284,7 +1281,7 @@ nic_write(nic_t *dev, uint32_t addr, uint32_t val, unsigned len) { int off = addr - dev->base_address; - pclog(2, "%s: write addr %x, value %x len %d\n", dev->name, addr, val, len); + nelog(3, "%s: write addr %x, value %x len %d\n", dev->name, addr, val, len); /* The high 16 bytes of i/o space are for the ne2000 asic - the low 16 bytes are for the DS8390, with the current @@ -1312,7 +1309,7 @@ nic_write(nic_t *dev, uint32_t addr, uint32_t val, unsigned len) break; default: - pclog(1, "%s: unknown value of pgsel in write - %d\n", + nelog(3, "%s: unknown value of pgsel in write - %d\n", dev->name, dev->CR.pgsel); break; } @@ -1348,7 +1345,7 @@ nic_writel(uint16_t addr, uint32_t val, void *priv) static void nic_ioset(nic_t *dev, uint16_t addr) { - if (dev->is_rtl8029as) { + if (dev->is_pci) { io_sethandler(addr, 16, nic_readb, nic_readw, nic_readl, nic_writeb, nic_writew, nic_writel, dev); @@ -1375,7 +1372,7 @@ nic_ioset(nic_t *dev, uint16_t addr) static void nic_ioremove(nic_t *dev, int16_t addr) { - if (dev->is_rtl8029as) { + if (dev->is_pci) { io_removehandler(addr, 16, nic_readb, nic_readw, nic_readl, nic_writeb, nic_writew, nic_writel, dev); @@ -1407,13 +1404,14 @@ nic_update_bios(nic_t *dev) reg_bios_enable = 1; /* PCI BIOS stuff, just enable_disable. */ - if (!dev->disable_netbios && reg_bios_enable) { + if ((dev->bios_addr > 0) && reg_bios_enable) { mem_mapping_enable(&dev->bios_rom.mapping); - mem_mapping_set_addr(&dev->bios_rom.mapping, dev->bios_addr, 0x10000); - pclog(1, "%s: BIOS now at: %06X\n", dev->name, dev->bios_addr); + mem_mapping_set_addr(&dev->bios_rom.mapping, + dev->bios_addr, dev->bios_size); + nelog(1, "%s: BIOS now at: %06X\n", dev->name, dev->bios_addr); } else { mem_mapping_disable(&dev->bios_rom.mapping); - if (dev->is_rtl8029as) + if (dev->is_pci) dev->pci_bar[1].addr = 0; } } @@ -1517,7 +1515,7 @@ nic_pci_write(int func, int addr, uint8_t val, void *priv) dev->base_address = dev->pci_bar[0].addr & 0xff00; /* Log the new base. */ - pclog(1, "%s: PCI: new I/O base is %04X\n", + nelog(1, "%s: PCI: new I/O base is %04X\n", dev->name, dev->base_address); /* We're done, so get out of the here. */ if (val & PCI_COMMAND_IO) @@ -1527,8 +1525,8 @@ nic_pci_write(int func, int addr, uint8_t val, void *priv) case 0x30: case 0x31: case 0x32: case 0x33: dev->pci_bar[1].addr_regs[addr & 3] = val; dev->pci_bar[1].addr_regs[1] &= dev->bios_mask; - dev->bios_addr = dev->pci_bar[1].addr & 0xffffe000; dev->pci_bar[1].addr &= 0xffffe000; + dev->bios_addr = dev->pci_bar[1].addr; dev->pci_bar[1].addr |= 0x1801; nic_update_bios(dev); return; @@ -1540,7 +1538,7 @@ nic_pci_write(int func, int addr, uint8_t val, void *priv) case 0x3C: dev->pci_regs[addr] = val; if (val != 0xFF) { - pclog(1, "%s: IRQ now: %i\n", dev->name, val); + nelog(1, "%s: IRQ now: %i\n", dev->name, val); dev->base_irq = irq; } return; @@ -1607,28 +1605,25 @@ nic_rx(void *priv, uint8_t *buf, int io_len) { static uint8_t bcast_addr[6] = {0xff,0xff,0xff,0xff,0xff,0xff}; nic_t *dev = (nic_t *)priv; - int pages; - int avail; - int idx; - int nextpage; uint8_t pkthdr[4]; - uint8_t *pktbuf = (uint8_t *) buf; uint8_t *startptr; - uint32_t mac_cmp32[2]; - uint16_t mac_cmp16[2]; + int pages, avail; + int idx, nextpage; + int endbytes; if (io_len != 60) - pclog(2, "%s: rx_frame with length %d\n", dev->name, io_len); + nelog(2, "%s: rx_frame with length %d\n", dev->name, io_len); - if ((dev->CR.stop != 0) || (dev->page_start == 0)) return; + if ((dev->CR.stop != 0) || (dev->page_start == 0)) return; /* Add the pkt header + CRC to the length, and work out how many 256-byte pages the frame would occupy */ - pages = (io_len + 4 + 4 + 255)/256; + pages = (io_len + sizeof(pkthdr) + sizeof(uint32_t) + 255)/256; if (dev->curr_page < dev->bound_ptr) { avail = dev->bound_ptr - dev->curr_page; } else { - avail = (dev->page_stop - dev->page_start) - (dev->curr_page - dev->bound_ptr); + avail = (dev->page_stop - dev->page_start) - + (dev->curr_page - dev->bound_ptr); } /* Avoid getting into a buffer overflow condition by not attempting @@ -1639,90 +1634,91 @@ nic_rx(void *priv, uint8_t *buf, int io_len) || (avail == pages) #endif ) { - pclog(1, "%s: no space\n", dev->name); + nelog(1, "%s: no space\n", dev->name); return; } if ((io_len < 40/*60*/) && !dev->RCR.runts_ok) { - pclog(1, "%s: rejected small packet, length %d\n", dev->name, io_len); + nelog(1, "%s: rejected small packet, length %d\n", dev->name, io_len); return; } - /* some computers don't care... */ - if (io_len < 60) { - io_len=60; - } + /* Some computers don't care... */ + if (io_len < 60) + io_len = 60; - /* Do address filtering if not in promiscuous mode */ + nelog(2, "%s: rx_frame %x:%x:%x:%x:%x:%x > %x:%x:%x:%x:%x:%x len %d\n", + dev->name, + buf[6], buf[7], buf[8], buf[9], buf[10], buf[11], + buf[0], buf[1], buf[2], buf[3], buf[4], buf[5], + io_len); + + /* Do address filtering if not in promiscuous mode. */ if (! dev->RCR.promisc) { - /* Received. */ - mac_cmp32[0] = *(uint32_t *) (buf); - mac_cmp16[0] = *(uint16_t *) (((uint8_t *) buf) + 4); - - /* Local. */ - mac_cmp32[1] = *(uint32_t *) (bcast_addr); - mac_cmp16[1] = *(uint16_t *) (bcast_addr+4); - if ((mac_cmp32[0] == mac_cmp32[1]) && (mac_cmp16[0] == mac_cmp16[1])) { + /* If this is a broadcast frame.. */ + if (! memcmp(buf, bcast_addr, 6)) { + /* Broadcast not enabled, we're done. */ if (! dev->RCR.broadcast) { + nelog(2, "%s: rx_frame BC disabled\n", dev->name); return; } - } else if (pktbuf[0] & 0x01) { - if (! dev->RCR.multicast) { - return; - } - idx = mcast_index(buf); - if (!(dev->mchash[idx >> 3] & (1 << (idx & 0x7)))) { - return; - } - } else if (0 != memcmp(buf, dev->physaddr, 6)) { - return; } - } else { - pclog(2, "%s: rx_frame promiscuous receive\n", dev->name); - } - pclog(2, "%s: rx_frame %d to %x:%x:%x:%x:%x:%x from %x:%x:%x:%x:%x:%x\n", - dev->name, io_len, - pktbuf[0], pktbuf[1], pktbuf[2], pktbuf[3], pktbuf[4], pktbuf[5], - pktbuf[6], pktbuf[7], pktbuf[8], pktbuf[9], pktbuf[10], pktbuf[11]); + /* If this is a multicast frame.. */ + else if (buf[0] & 0x01) { + /* Multicast not enabled, we're done. */ + if (! dev->RCR.multicast) { +#if 1 + nelog(2, "%s: rx_frame MC disabled\n", dev->name); +#endif + return; + } + + /* Are we listening to this multicast address? */ + idx = mcast_index(buf); + if (! (dev->mchash[idx>>3] & (1<<(idx&0x7)))) { + nelog(2, "%s: rx_frame MC not listed\n", dev->name); + return; + } + } + + /* Unicast, must be for us.. */ + else if (memcmp(buf, dev->physaddr, 6)) return; + } else { + nelog(2, "%s: rx_frame promiscuous receive\n", dev->name); + } nextpage = dev->curr_page + pages; - if (nextpage >= dev->page_stop) { - nextpage -= dev->page_stop - dev->page_start; - } + if (nextpage >= dev->page_stop) + nextpage -= (dev->page_stop - dev->page_start); - /* Setup packet header */ - pkthdr[0] = 0; /* rx status - old behavior - pkthdr[0] = 1; /* Probably better to set it all the time - rather than set it to 0, which is clearly wrong. */ - if (pktbuf[0] & 0x01) { - pkthdr[0] |= 0x20; /* rx status += multicast packet */ - } + /* Set up packet header. */ + pkthdr[0] = 0x01; /* RXOK - packet is OK */ + if (buf[0] & 0x01) + pkthdr[0] |= 0x20; /* MULTICAST packet */ pkthdr[1] = nextpage; /* ptr to next packet */ - pkthdr[2] = (io_len + 4) & 0xff; /* length-low */ - pkthdr[3] = (io_len + 4) >> 8; /* length-hi */ + pkthdr[2] = (io_len + sizeof(pkthdr))&0xff; /* length-low */ + pkthdr[3] = (io_len + sizeof(pkthdr))>>8; /* length-hi */ + nelog(2, "%s: rx_frame pkthdr [%02x %02x %02x %02x]\n", + dev->name, pkthdr[0], pkthdr[1], pkthdr[2], pkthdr[3]); - /* copy into buffer, update curpage, and signal interrupt if config'd */ - startptr = & dev->mem[dev->curr_page * 256 - NE2K_MEMSTART]; + /* Copy into buffer, update curpage, and signal interrupt if config'd */ + startptr = &dev->mem[(dev->curr_page * 256) - NE2K_MEMSTART]; + memcpy(startptr, pkthdr, sizeof(pkthdr)); if ((nextpage > dev->curr_page) || ((dev->curr_page + pages) == dev->page_stop)) { - *(uint32_t *) startptr = *(uint32_t *) pkthdr; - memcpy(startptr + 4, buf, io_len); - dev->curr_page = nextpage; + memcpy(startptr+sizeof(pkthdr), buf, io_len); } else { - int endbytes = (dev->page_stop - dev->curr_page) * 256; - *(uint32_t *) startptr = *(uint32_t *) pkthdr; - memcpy(startptr + 4, buf, endbytes - 4); - startptr = & dev->mem[dev->page_start * 256 - NE2K_MEMSTART]; - memcpy(startptr, (void *)(pktbuf + endbytes - 4), io_len - endbytes + 8); - dev->curr_page = nextpage; + endbytes = (dev->page_stop - dev->curr_page) * 256; + memcpy(startptr+sizeof(pkthdr), buf, endbytes-sizeof(pkthdr)); + startptr = &dev->mem[(dev->page_start * 256) - NE2K_MEMSTART]; + memcpy(startptr, buf+endbytes-sizeof(pkthdr), io_len-endbytes+8); } + dev->curr_page = nextpage; dev->RSR.rx_ok = 1; - if (pktbuf[0] & 0x80) { + if (buf[0] & 0x80) dev->RSR.rx_mbit = 1; - } - dev->ISR.pkt_rx = 1; if (dev->IMR.rx_inte) @@ -1736,8 +1732,8 @@ nic_rom_init(nic_t *dev, wchar_t *s) FILE *f = romfopen(s, L"rb"); uint32_t temp; - if (f != NULL) { - dev->disable_netbios = 1; + if (f == NULL) { + dev->bios_addr = 0x00000; nic_update_bios(dev); return; } @@ -1754,14 +1750,11 @@ nic_rom_init(nic_t *dev, wchar_t *s) dev->bios_mask = (dev->bios_size >> 8) & 0xff; dev->bios_mask = (0x100 - dev->bios_mask) & 0xff; -#if 1 - /* Shouldn't we use the configured address?? --FvK */ - rom_init(&dev->bios_rom, s, 0xd0000, - dev->bios_size, dev->bios_size - 1, 0, MEM_MAPPING_EXTERNAL); -#else rom_init(&dev->bios_rom, s, dev->bios_addr, dev->bios_size, dev->bios_size - 1, 0, MEM_MAPPING_EXTERNAL); -#endif + + nelog(1, "%s: BIOS enabled at %06lX (size %ld)\n", + dev->name, dev->bios_addr, dev->bios_size); } @@ -1788,37 +1781,41 @@ nic_init(int board) dev = malloc(sizeof(nic_t)); memset(dev, 0x00, sizeof(nic_t)); dev->board = board; - dev->is_rtl8029as = (PCI && (board == NE2K_RTL8029AS)) ? 1 : 0; - if (board == NE2K_RTL8029AS) { - strcpy(dev->name, "RTL8029AS"); - } else if (board == NE2K_NE1000) { - strcpy(dev->name, "NE1000"); - } else { - strcpy(dev->name, "NE2000"); + switch(dev->board) { + case NE2K_NE1000: + strcpy(dev->name, "NE1000"); + dev->maclocal[0] = 0x00; /* 00:00:D8 (NE1000 ISA OID) */ + dev->maclocal[1] = 0x00; + dev->maclocal[2] = 0xD8; + break; + + case NE2K_NE2000: + strcpy(dev->name, "NE2000"); + dev->maclocal[0] = 0x00; /* 00:A0:0C (NE2000 compatible OID) */ + dev->maclocal[1] = 0xA0; + dev->maclocal[2] = 0x0C; + break; + + case NE2K_RTL8029AS: + dev->is_pci = (PCI) ? 1 : 0; + strcpy(dev->name, "RTL8029AS"); + dev->maclocal[0] = 0x00; /* 00:20:18 (RTL 8029AS PCI OID) */ + dev->maclocal[1] = 0x20; + dev->maclocal[2] = 0x18; + break; } dev->base_irq = device_get_config_int("irq"); - dev->disable_netbios = device_get_config_int("disable_netbios"); - if (dev->is_rtl8029as) { + if (dev->is_pci) dev->base_address = 0x340; - } else { + else dev->base_address = device_get_config_int("addr"); - } + dev->bios_addr = device_get_config_int("bios_addr"); /* See if we have a local MAC address configured. */ mac = device_get_config_int_ex("mac", -1); - /* Set up our MAC address. */ -#if 1 - if (dev->is_rtl8029as) { - dev->maclocal[0] = 0xDE /* 0x00 */; /* 00:20:18 (RTL 8029AS PCI vendor prefix). */ - dev->maclocal[1] = 0x20; - dev->maclocal[2] = 0x18; - } else { - dev->maclocal[0] = 0xDE /* 0x00 */; /* 00:00:D8 (NE2000 ISA vendor prefix). */ - dev->maclocal[1] = 0x00; - dev->maclocal[2] = 0xD8; - } + /* Set up our BIA. */ if (mac & 0xff000000) { /* Generating new MAC. */ dev->maclocal[3] = disc_random_generate(); @@ -1828,33 +1825,20 @@ nic_init(int board) } else { dev->maclocal[3] = (mac>>16) & 0xff; dev->maclocal[4] = (mac>>8) & 0xff; -#if 1 dev->maclocal[5] = (mac & 0xfe); -#else - dev->maclocal[5] = (mac & 0xff) | 1; -#endif } -#else - dev->maclocal[0] = 0xac; - dev->maclocal[1] = 0xde; - dev->maclocal[2] = 0x48; - dev->maclocal[3] = 0x88; - dev->maclocal[4] = 0xbb; - dev->maclocal[5] = 0xaa; -#endif memcpy(dev->physaddr, dev->maclocal, sizeof(dev->maclocal)); - pclog(1,"%s: I/O=%04x, IRQ=%d, MAC=%02x:%02x:%02x:%02x:%02x:%02x BIOS=%d\n", + nelog(1,"%s: I/O=%04x, IRQ=%d, MAC=%02x:%02x:%02x:%02x:%02x:%02x\n", dev->name, dev->base_address, dev->base_irq, dev->physaddr[0], dev->physaddr[1], dev->physaddr[2], - dev->physaddr[3], dev->physaddr[4], dev->physaddr[5], - !dev->disable_netbios); + dev->physaddr[3], dev->physaddr[4], dev->physaddr[5]); if (network_attach(dev, dev->physaddr, nic_rx) < 0) { #if 0 msgbox_error_wstr(ghwnd, L"Unable to init platform network"); #endif - pclog(1, "%s: unable to init platform network type %d\n", + nelog(1, "%s: unable to init platform network type %d\n", dev->name, network_type); #if 0 /* @@ -1868,18 +1852,18 @@ nic_init(int board) #endif } - if (dev->is_rtl8029as) + if (dev->is_pci) pci_add(nic_pci_read, nic_pci_write, dev); nic_ioset(dev, dev->base_address); - if (! dev->disable_netbios) { - nic_rom_init(dev, dev->is_rtl8029as ? L"roms/rtl8029as.rom" + if (dev->bios_addr > 0) { + nic_rom_init(dev, dev->is_pci ? L"roms/rtl8029as.rom" : L"roms/ne2000.rom"); - if (dev->is_rtl8029as) + if (dev->is_pci) mem_mapping_disable(&dev->bios_rom.mapping); } - if (dev->is_rtl8029as) { + if (dev->is_pci) { dev->pci_regs[0x04] = 1; dev->pci_regs[0x05] = 0; dev->pci_regs[0x07] = 2; @@ -1888,19 +1872,18 @@ nic_init(int board) dev->pci_regs[0x0B] = 2; dev->pci_bar[0].addr_regs[0] = 1; - - if (! dev->disable_netbios) { - dev->pci_bar[1].addr = 0; - dev->bios_addr = 0; - } else { + + if (dev->bios_addr > 0) { + /* What is it.. F800 or D000 (bios_addr) ? */ dev->pci_bar[1].addr = 0x000F8000; dev->pci_bar[1].addr_regs[1] = dev->bios_mask; dev->pci_bar[1].addr |= 0x1801; - dev->bios_addr = 0xD0000; + } else { + dev->pci_bar[1].addr = 0; } dev->pci_regs[0x3C] = dev->base_irq; - pclog(1, "%s: IRQ=%i\n", dev->name, dev->pci_regs[0x3C]); + nelog(1, "%s: IRQ=%i\n", dev->name, dev->pci_regs[0x3C]); dev->pci_regs[0x3D] = 1; memset(dev->eeprom, 0x00, sizeof(dev->eeprom)); @@ -1918,8 +1901,8 @@ nic_init(int board) nic_reset(dev, 0); - pclog(1, "%s: %s init 0x%X %d\n", dev->name, - dev->is_rtl8029as?"PCI":"ISA", dev->base_address, dev->base_irq); + nelog(1, "%s: %s init 0x%X %d\n", dev->name, + dev->is_pci?"PCI":"ISA", dev->base_address, dev->base_irq); return(dev); } @@ -1937,7 +1920,7 @@ nic_close(void *priv) free(dev); - pclog(1, "%s: closed\n", dev->name); + nelog(1, "%s: closed\n", dev->name); } @@ -2011,7 +1994,21 @@ static device_config_t ne1000_config[] = "mac", "MAC Address", CONFIG_MAC, "", -1 }, { - "disable_netbios", "Disable network BIOS", CONFIG_BINARY, "", 0 + "bios_addr", "BIOS address", CONFIG_SELECTION, "", 0, + { + { + "Disabled", 0x00000 + }, + { + "D000", 0xD0000 + }, + { + "C000", 0xC0000 + }, + { + "" + } + }, }, { "", "", -1 @@ -2073,7 +2070,21 @@ static device_config_t ne2000_config[] = "mac", "MAC Address", CONFIG_MAC, "", -1 }, { - "disable_netbios", "Disable network BIOS", CONFIG_BINARY, "", 0 + "bios_addr", "BIOS address", CONFIG_SELECTION, "", 0, + { + { + "Disabled", 0x00000 + }, + { + "D000", 0xD0000 + }, + { + "C000", 0xC0000 + }, + { + "" + } + }, }, { "", "", -1 @@ -2109,7 +2120,21 @@ static device_config_t rtl8029as_config[] = "mac", "MAC Address", CONFIG_MAC, "", -1 }, { - "disable_netbios", "Disable network BIOS", CONFIG_BINARY, "", 0 + "bios_addr", "BIOS address", CONFIG_SELECTION, "", 0, + { + { + "Disabled", 0x00000 + }, + { + "D000", 0xD0000 + }, + { + "C000", 0xC0000 + }, + { + "" + } + }, }, { "", "", -1 diff --git a/src/net_pcap.c b/src/net_pcap.c index 448738715..a1b2292b0 100644 --- a/src/net_pcap.c +++ b/src/net_pcap.c @@ -8,7 +8,7 @@ * * Handle WinPcap library processing. * - * Version: @(#)net_pcap.c 1.0.3 2017/05/21 + * Version: @(#)net_pcap.c 1.0.4 2017/05/23 * * Author: Fred N. van Kempen, */ @@ -180,7 +180,7 @@ network_pcap_setup(uint8_t *mac, NETRXCB func, void *arg) } /* Create a MAC address based packet filter. */ - pclog(" Installing packet filter for MAC=%02x:%02x:%02x:%02x:%02x\n", + pclog(" Installing packet filter for MAC=%02x:%02x:%02x:%02x:%02x:%02x\n", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]); sprintf(filter_exp, "( ((ether dst ff:ff:ff:ff:ff:ff) or (ether dst %02x:%02x:%02x:%02x:%02x:%02x)) and not (ether src %02x:%02x:%02x:%02x:%02x:%02x) )", diff --git a/src/network.c b/src/network.c index 90bd69aac..c4cd9c547 100644 --- a/src/network.c +++ b/src/network.c @@ -12,7 +12,7 @@ * it should be malloc'ed and then linked to the NETCARD def. * Will be done later. * - * Version: @(#)network.c 1.0.5 2017/05/21 + * Version: @(#)network.c 1.0.6 2017/05/22 * * Authors: Kotori, * Fred N. van Kempen, @@ -25,14 +25,8 @@ #include "device.h" #include "network.h" #include "net_ne2000.h" -#ifndef unix -# define UNICODE -# define BITMAP WINDOWS_BITMAP -# include -# undef BITMAP -# include "win.h" -# include "win_language.h" -#endif +#include "win.h" +#include "win_language.h" static netcard_t net_cards[] = { diff --git a/src/pc.c b/src/pc.c index 7e05e9260..66e0bb4ef 100644 --- a/src/pc.c +++ b/src/pc.c @@ -57,18 +57,10 @@ #include "video/video.h" #include "video/vid_voodoo.h" #include "amstrad.h" -#ifdef WALTJE -# define UNICODE -# include "plat_dir.h" -#endif - -#ifndef __unix -#define UNICODE -#define BITMAP WINDOWS_BITMAP -#include -#undef BITMAP #include "win.h" #include "win_language.h" +#ifdef WALTJE +# include "plat_dir.h" #endif