├── .editorconfig ├── .gitignore ├── AUTHORS ├── COPYING ├── ChangeLog ├── INSTALL ├── Makefile.am ├── NEWS ├── README.md ├── THANKS ├── autogen.sh ├── configure.ac ├── doc └── Makefile.am ├── doxygen.cfg ├── extras └── Doxyfile ├── m4 ├── Makefile.am ├── doxygen.m4 ├── libpcap.m4 ├── pthreads.m4 ├── sdl.m4 └── x11.m4 └── src ├── AliM1543C.cpp ├── AliM1543C.h ├── AliM1543C_ide.cpp ├── AliM1543C_ide.h ├── AliM1543C_usb.cpp ├── AliM1543C_usb.h ├── AlphaCPU.cpp ├── AlphaCPU.h ├── AlphaCPU_ieeefloat.cpp ├── AlphaCPU_vaxfloat.cpp ├── AlphaCPU_vmspal.cpp ├── AlphaSim.cpp ├── Cirrus.cpp ├── Cirrus.h ├── Configurator.cpp ├── Configurator.h ├── DEC21143.cpp ├── DEC21143.h ├── DEC21143_mii.h ├── DEC21143_tulipreg.h ├── DMA.cpp ├── DMA.h ├── DPR.cpp ├── DPR.h ├── Disk.cpp ├── Disk.h ├── DiskController.cpp ├── DiskController.h ├── DiskDevice.cpp ├── DiskDevice.h ├── DiskFile.cpp ├── DiskFile.h ├── DiskRam.cpp ├── DiskRam.h ├── Ethernet.cpp ├── Ethernet.h ├── Flash.cpp ├── Flash.h ├── FloppyController.cpp ├── FloppyController.h ├── FreeTextQuestion.h ├── Keyboard.cpp ├── Keyboard.h ├── Makefile.am ├── MultipleChoiceQuestion.h ├── NumberQuestion.h ├── PCIDevice.cpp ├── PCIDevice.h ├── Port80.cpp ├── Port80.h ├── Question.h ├── S3Trio64.cpp ├── S3Trio64.h ├── SCSIBus.cpp ├── SCSIBus.h ├── SCSIDevice.cpp ├── SCSIDevice.h ├── Serial.cpp ├── Serial.h ├── ShrinkingChoiceQuestion.h ├── StdAfx.cpp ├── StdAfx.h ├── Sym53C810.cpp ├── Sym53C810.h ├── Sym53C895.cpp ├── Sym53C895.h ├── System.cpp ├── System.h ├── SystemComponent.cpp ├── SystemComponent.h ├── TraceEngine.cpp ├── TraceEngine.h ├── VGA.cpp ├── VGA.h ├── VS2022 ├── es40-cfg.vcxproj ├── es40-cfg.vcxproj.filters ├── es40.sln ├── es40.vcxproj └── es40.vcxproj.filters ├── base ├── AutoPtr.h ├── Bugcheck.cpp ├── Bugcheck.h ├── ErrorHandler.cpp ├── ErrorHandler.h ├── Event.cpp ├── Event.h ├── Event_POSIX.cpp ├── Event_POSIX.h ├── Event_WIN32.cpp ├── Event_WIN32.h ├── Exception.cpp ├── Exception.h ├── Foundation.h ├── Mutex.cpp ├── Mutex.h ├── Mutex_POSIX.cpp ├── Mutex_POSIX.h ├── Mutex_WIN32.cpp ├── Mutex_WIN32.h ├── NumberFormatter.cpp ├── NumberFormatter.h ├── Platform.h ├── Platform_POSIX.h ├── Platform_VMS.h ├── Platform_WIN32.h ├── Poco.h ├── RWLock.cpp ├── RWLock.h ├── RWLock_POSIX.cpp ├── RWLock_POSIX.h ├── RWLock_WIN32.cpp ├── RWLock_WIN32.h ├── RefCountedObject.cpp ├── RefCountedObject.h ├── Runnable.cpp ├── Runnable.h ├── ScopedLock.h ├── Semaphore.cpp ├── Semaphore.h ├── Semaphore_POSIX.cpp ├── Semaphore_POSIX.h ├── Semaphore_WIN32.cpp ├── Semaphore_WIN32.h ├── SignalHandler.cpp ├── SignalHandler.h ├── SingletonHolder.h ├── Thread.cpp ├── Thread.h ├── ThreadLocal.cpp ├── ThreadLocal.h ├── Thread_POSIX.cpp ├── Thread_POSIX.h ├── Thread_WIN32.cpp ├── Thread_WIN32.h ├── Timestamp.cpp ├── Timestamp.h ├── Types.h └── UnWindows.h ├── config_debug.h ├── config_vms.h ├── config_win32.h ├── cpu_arith.h ├── cpu_bwx.h ├── cpu_control.h ├── cpu_debug.h ├── cpu_defs.h ├── cpu_fp_branch.h ├── cpu_fp_memory.h ├── cpu_fp_operate.h ├── cpu_logical.h ├── cpu_memory.h ├── cpu_misc.h ├── cpu_mvi.h ├── cpu_pal.h ├── cpu_vax.h ├── datatypes.h ├── dox.cpp ├── es40-cfg.cpp ├── es40.cfg ├── es40_debug.cpp ├── es40_debug.h ├── es40_endian.h ├── es40_float.h ├── gui ├── gui.cpp ├── gui.h ├── gui_win32.cpp ├── gui_win32_font.h ├── gui_x11.cpp ├── keymap.cpp ├── keymap.h ├── plugin.h ├── scancodes.cpp ├── scancodes.h ├── sdl.cpp ├── sdl_fonts.h ├── sdlkeys.h └── vga.h ├── lockstep.cpp ├── lockstep.h ├── make_vms.com ├── make_vms.sh └── telnet.h /.editorconfig: -------------------------------------------------------------------------------- 1 | # See https://editorconfig.org/ 2 | root = true 3 | 4 | [*] 5 | end_of_line = lf 6 | max_line_length = 80 7 | insert_final_newline = true 8 | 9 | [*.{c,h}] 10 | indent_style = space 11 | indent_size = 2 12 | 13 | -------------------------------------------------------------------------------- /AUTHORS: -------------------------------------------------------------------------------- 1 | Authors of es40. 2 | See also the files THANKS and ChangeLog. 3 | 4 | Camiel Vanderhoeven designed and implemented es40. 5 | -------------------------------------------------------------------------------- /ChangeLog: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gdwnldsKSC/es40/bce8dacde45cee8f58f122be6ed24602c51cdbd8/ChangeLog -------------------------------------------------------------------------------- /Makefile.am: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # ES40 emulator. 3 | # Copyright (C) 2007-2008 by the ES40 Emulator Project 4 | # 5 | # Website: http://www.es40.org 6 | # E-mail : camiel@es40.org 7 | # 8 | # This program is free software; you can redistribute it and/or 9 | # modify it under the terms of the GNU General Public License 10 | # as published by the Free Software Foundation; either version 2 11 | # of the License, or (at your option) any later version. 12 | # 13 | # This program is distributed in the hope that it will be useful, 14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | # GNU General Public License for more details. 17 | # 18 | # You should have received a copy of the GNU General Public License 19 | # along with this program; if not, write to the Free Software 20 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 21 | # 02110-1301, USA. 22 | # 23 | # Although this is not required, the author would appreciate being notified of, 24 | # and receiving any modifications you may make to the source code that might serve 25 | # the general public. 26 | # 27 | ################################################################################ 28 | # 29 | # $Id$ 30 | # 31 | # X-1.2 Camiel Vanderhoeven 31-MAY-2008 32 | # Add parts of Poco. 33 | # 34 | # X-1.1 Camiel Vanderhoeven 20-MAR-2008 35 | # File Created. 36 | # 37 | ################################################################################ 38 | 39 | EXTRA_DIST = reconf configure 40 | SUBDIRS = m4 src doc 41 | -------------------------------------------------------------------------------- /NEWS: -------------------------------------------------------------------------------- 1 | es40 -- History of visible changes. 2 | 3 | Copyright (C) 2007-2008, the ES40 Emulator Project 4 | See the end for copying conditions. 5 | 6 | Please send es40 bug reports to iamcamiel@gmail.com. 7 | 8 | Please refer to ChangeLog for version history. 9 | 10 | ------------------------------------------------------- 11 | Copying information: 12 | 13 | Copyright (C) 2007-2008, the ES40 Emulator Project 14 | 15 | Permission is granted to anyone to make or distribute verbatim copies 16 | of this document as received, in any medium, provided that the 17 | copyright notice and this permission notice are preserved, 18 | thus giving the recipient permission to redistribute in turn. 19 | 20 | Permission is granted to distribute modified versions 21 | of this document, or of portions of it, 22 | under the above conditions, provided also that they 23 | carry prominent notices stating who last changed them. 24 | 25 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## DEC ES40 Simulator 2 | 3 | es40 is free software. Please see the file COPYING for details. 4 | For documentation, please see the files in the doc subdirectory. 5 | For building and installation instructions please see the INSTALL file. 6 | 7 | Windows build - VS2022 x64 target only currently. 8 | Requires npcap (upgrade from old legacy winpcap - last release 2013) 9 | Currently using latest npcap 1.75, with npcap-sdk-1.13.zip extracted to c:\program files\npcap\ 10 | 11 | Formerly used poco c++ libraries, but they were copied into the source tree directly, 12 | perhaps we can update these at some point? 13 | 14 | libSDL 1.2 current master as of 5/8/2023 https://github.com/libsdl-org/SDL-1.2 15 | Extract contents of SDL-1.2-master folder into C:\Program Files\SDL\ 16 | SDL Built with VS 2022, using the included SDL_VS2010.sln project file. 17 | Follow instructions in VisualC.html - automatic project conversion for VS2013 works. 18 | 19 | 20 | Direct SDK can be found here: 21 | https://www.microsoft.com/en-us/download/details.aspx?id=6812 22 | 23 | 24 | Install that and the SDL_config.h copy per documentation and should build without issue 25 | on latest, fully updated VS2022 17.5.5 26 | 27 | Move compiled SDL.lib and SDLmain.lib to C:\Program Files\SDL\lib\ from target outdir 28 | SDL.dll will be required to be placed with the compiled es40 application 29 | 30 | Older VS version support will be dropped from this branch as we move forward. 31 | This is initial build currentlyto re-create and reproduce the build environment 32 | currently using src\VS2022\es40.sln 33 | 34 | Now we can build es40-cfg and es40! Yay! Don't forget to copy SDL.dll into the appropriate 35 | release or debug output directory! 36 | 37 | 38 | gdwnldsKSC - 5/9/2023 VS2022 build, works great. 39 | -------------------------------------------------------------------------------- /THANKS: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gdwnldsKSC/es40/bce8dacde45cee8f58f122be6ed24602c51cdbd8/THANKS -------------------------------------------------------------------------------- /autogen.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | autoreconf -I m4 --install --verbose 4 | 5 | -------------------------------------------------------------------------------- /configure.ac: -------------------------------------------------------------------------------- 1 | # -*- Autoconf -*- 2 | ################################################################################ 3 | # ES40 emulator. 4 | # Copyright (C) 2007-2008 by the ES40 Emulator Project 5 | # 6 | # Website: http://www.es40.org 7 | # E-mail : camiel@es40.org 8 | # 9 | # This program is free software; you can redistribute it and/or 10 | # modify it under the terms of the GNU General Public License 11 | # as published by the Free Software Foundation; either version 2 12 | # of the License, or (at your option) any later version. 13 | # 14 | # This program is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with this program; if not, write to the Free Software 21 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 22 | # 02110-1301, USA. 23 | # 24 | # Although this is not required, the author would appreciate being notified of, 25 | # and receiving any modifications you may make to the source code that might serve 26 | # the general public. 27 | # 28 | ################################################################################ 29 | # 30 | # $Id$ 31 | # 32 | # X-1.3 Camiel Vanderhoeven 31-MAY-2008 33 | # Add parts of Poco. 34 | # 35 | # X-1.2 Camiel Vanderhoeven 04-APR-2008 36 | # Version number set to "0.18+" 37 | # 38 | # X-1.1 Camiel Vanderhoeven 20-MAR-2008 39 | # File Created. 40 | # 41 | ################################################################################ 42 | # 43 | # Process this file with autoconf to produce a configure script. 44 | 45 | AC_PREREQ(2.61) 46 | AC_INIT(es40, 0.18+, iamcamiel@gmail.com) 47 | AC_CONFIG_SRCDIR([src/Flash.cpp]) 48 | AM_CONFIG_HEADER([src/config.h]) 49 | AM_INIT_AUTOMAKE([foreign subdir-objects]) 50 | 51 | # Checks for programs. 52 | AC_PROG_CXX 53 | AC_PROG_CC 54 | 55 | # Checks for header files. 56 | AC_HEADER_STDC 57 | AC_HEADER_SYS_WAIT 58 | AC_CHECK_HEADERS([arpa/inet.h arpa/telnet.h ctype.h errno.h fcntl.h in.h inet.h inttypes.h malloc.h netinet/in.h process.h pthread.h signal.h socket.h stdint.h stdlib.h string.h sys/param.h sys/socket.h sys/time.h unistd.h windows.h winsock2.h ws2tcpip.h]) 59 | 60 | # Checks for typedefs, structures, and compiler characteristics. 61 | AC_HEADER_STDBOOL 62 | AC_C_CONST 63 | AC_C_INLINE 64 | AC_TYPE_INT16_T 65 | AC_TYPE_INT32_T 66 | AC_TYPE_INT64_T 67 | AC_TYPE_INT8_T 68 | AC_TYPE_PID_T 69 | AC_TYPE_SIZE_T 70 | AC_TYPE_SSIZE_T 71 | AC_HEADER_TIME 72 | AC_STRUCT_TM 73 | AC_TYPE_UINT16_T 74 | AC_TYPE_UINT32_T 75 | AC_TYPE_UINT64_T 76 | AC_TYPE_UINT8_T 77 | 78 | # Checks for library functions. 79 | AC_FUNC_ERROR_AT_LINE 80 | AC_FUNC_FORK 81 | AC_FUNC_MALLOC 82 | AC_FUNC_REALLOC 83 | AC_FUNC_SELECT_ARGTYPES 84 | AC_TYPE_SIGNAL 85 | AC_CHECK_FUNCS([alarm atexit fopen fopen64 fseek fseeko fseeko64 _fseeki64 ftell ftello ftello64 _ftelli64 gmtime_s inet_aton isblank memset pow select socket sqrt strcasecmp _stricmp strchr strdup _strdup strncasecmp _stricasecmp strspn]) 86 | 87 | # Check for pthreads 88 | AX_PTHREAD 89 | CXXFLAGS="$CXXFLAGS $PTHREAD_CFLAGS" 90 | LDFLAGS="$LDFLAGS $PTHREAD_LDFLAGS" 91 | LIBS="$LIBS $PTHREAD_LIBS" 92 | 93 | # Use our own method to search for PCAP 94 | AM_PATH_PCAP( 95 | CXXFLAGS="$CXXFLAGS $PCAP_CFLAGS -DHAVE_PCAP" 96 | LIBS="$LIBS $PCAP_LIBS" 97 | ,:) 98 | 99 | # Use our own method to search for X11 100 | AM_PATH_X11( 101 | CXXFLAGS="$CXXFLAGS $X11_CFLAGS -DHAVE_X11" 102 | LIBS="$LIBS $X11_LIBS" 103 | ,:) 104 | 105 | # Use pkg-config to find SDL 106 | PKG_CHECK_MODULES([SDL],[sdl >= 1.2.0], 107 | [ 108 | AC_DEFINE([HAVE_SDL],[1],"Use SDL") 109 | CXXFLAGS="$CXXFLAGS $SDL_CFLAGS -DHAVE_SDL" 110 | LIBS="$LIBS $SDL_LIBS" 111 | ] 112 | ) 113 | 114 | # Generate the various makefiles. 115 | AC_OUTPUT(Makefile doc/Makefile m4/Makefile src/Makefile) 116 | -------------------------------------------------------------------------------- /doc/Makefile.am: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # ES40 emulator. 3 | # Copyright (C) 2007-2008 by the ES40 Emulator Project 4 | # 5 | # Website: http://sourceforge.net/projects/es40 6 | # E-mail : camiel@camicom.com 7 | # 8 | # This program is free software; you can redistribute it and/or 9 | # modify it under the terms of the GNU General Public License 10 | # as published by the Free Software Foundation; either version 2 11 | # of the License, or (at your option) any later version. 12 | # 13 | # This program is distributed in the hope that it will be useful, 14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | # GNU General Public License for more details. 17 | # 18 | # You should have received a copy of the GNU General Public License 19 | # along with this program; if not, write to the Free Software 20 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 21 | # 02110-1301, USA. 22 | # 23 | # Although this is not required, the author would appreciate being notified of, 24 | # and receiving any modifications you may make to the source code that might serve 25 | # the general public. 26 | # 27 | ################################################################################ 28 | # 29 | # $Id$ 30 | # 31 | # X-1.1 Camiel Vanderhoeven 20-MAR-2008 32 | # File Created. 33 | # 34 | ################################################################################ 35 | -------------------------------------------------------------------------------- /m4/Makefile.am: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # ES40 emulator. 3 | # Copyright (C) 2007-2008 by the ES40 Emulator Project 4 | # 5 | # Website: http://sourceforge.net/projects/es40 6 | # E-mail : camiel@camicom.com 7 | # 8 | # This program is free software; you can redistribute it and/or 9 | # modify it under the terms of the GNU General Public License 10 | # as published by the Free Software Foundation; either version 2 11 | # of the License, or (at your option) any later version. 12 | # 13 | # This program is distributed in the hope that it will be useful, 14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | # GNU General Public License for more details. 17 | # 18 | # You should have received a copy of the GNU General Public License 19 | # along with this program; if not, write to the Free Software 20 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 21 | # 02110-1301, USA. 22 | # 23 | # Although this is not required, the author would appreciate being notified of, 24 | # and receiving any modifications you may make to the source code that might serve 25 | # the general public. 26 | # 27 | ################################################################################ 28 | # 29 | # $Id$ 30 | # 31 | # X-1.1 Camiel Vanderhoeven 20-MAR-2008 32 | # File Created. 33 | # 34 | ################################################################################ 35 | 36 | # Install m4 macros in this directory 37 | m4datadir = $(datadir)/aclocal 38 | 39 | # List your m4 macros here 40 | m4macros = 41 | 42 | # The following is boilerplate 43 | m4data_DATA = $(m4macros) 44 | EXTRA_DIST = $(m4data_DATA) 45 | 46 | -------------------------------------------------------------------------------- /m4/libpcap.m4: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # ES40 emulator. 3 | # Copyright (C) 2007-2008 by the ES40 Emulator Project 4 | # 5 | # Website: http://sourceforge.net/projects/es40 6 | # E-mail : camiel@camicom.com 7 | # 8 | # This program is free software; you can redistribute it and/or 9 | # modify it under the terms of the GNU General Public License 10 | # as published by the Free Software Foundation; either version 2 11 | # of the License, or (at your option) any later version. 12 | # 13 | # This program is distributed in the hope that it will be useful, 14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | # GNU General Public License for more details. 17 | # 18 | # You should have received a copy of the GNU General Public License 19 | # along with this program; if not, write to the Free Software 20 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 21 | # 02110-1301, USA. 22 | # 23 | # Although this is not required, the author would appreciate being notified of, 24 | # and receiving any modifications you may make to the source code that might serve 25 | # the general public. 26 | # 27 | ################################################################################ 28 | # 29 | # $Id$ 30 | # 31 | # X-1.1 Camiel Vanderhoeven 20-MAR-2008 32 | # File Created. 33 | # 34 | ################################################################################ 35 | # 36 | # Check if libpcap is installed, and configure paths 37 | 38 | dnl AM_PATH_PCAP([ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]) 39 | dnl Test for PCAP, and define PCAP_CFLAGS and PCAP_LIBS 40 | dnl 41 | 42 | AC_DEFUN([ES_PCAP_INC_WHERE1], [ 43 | ac_cv_found_pcap_inc=no 44 | if test -f "$1/pcap.h" ; then 45 | ac_cv_found_pcap_inc=yes 46 | fi 47 | ]) 48 | 49 | AC_DEFUN([ES_PCAP_INC_WHERE], [ 50 | for i in $1; do 51 | AC_MSG_CHECKING(for pcap header in $i) 52 | ES_PCAP_INC_WHERE1($i) 53 | if test "$ac_cv_found_pcap_inc" = "yes"; then 54 | ac_cv_pcap_where_inc=$i 55 | AC_MSG_RESULT(found) 56 | break 57 | else 58 | AC_MSG_RESULT(not here) 59 | fi 60 | done 61 | ]) 62 | 63 | AC_DEFUN([ES_PCAP_LIB_WHERE1], [ 64 | saved_LIBS=$LIBS 65 | LIBS="$saved_LIBS -L$1 -lpcap" 66 | AC_TRY_LINK(, 67 | [pcap_lookupdev("");], 68 | [ac_cv_found_pcap_lib=yes], 69 | ac_cv_found_pcap_lib=no) 70 | LIBS=$saved_LIBS 71 | ]) 72 | 73 | AC_DEFUN([ES_PCAP_LIB_WHERE], [ 74 | for i in $1; do 75 | AC_MSG_CHECKING(for pcap library in $i) 76 | ES_PCAP_LIB_WHERE1($i) 77 | if test "$ac_cv_found_pcap_lib" = "yes"; then 78 | ac_cv_pcap_where_lib=$i 79 | AC_MSG_RESULT(found) 80 | break 81 | else 82 | AC_MSG_RESULT(not here) 83 | fi 84 | done 85 | ]) 86 | 87 | 88 | AC_DEFUN([AM_PATH_PCAP], 89 | [dnl 90 | dnl Get the cflags and libraries for libpcap 91 | dnl 92 | 93 | ES_PCAP_LIB_WHERE(/usr/ng/lib /usr/lib /usr/local/lib) 94 | ES_PCAP_INC_WHERE(/usr/ng/include /usr/include /usr/local/include) 95 | 96 | AC_MSG_CHECKING(whether pcap is available) 97 | 98 | if test "X$ac_cv_pcap_where_lib" = "X" -o "X$ac_cv_pcap_where_inc" = "X"; then 99 | ac_cv_found_pcap=no 100 | AC_MSG_RESULT(no) 101 | PCAP_CFLAGS="" 102 | PCAP_LIBS="" 103 | ifelse([$2], , :, [$2]) 104 | else 105 | ac_cv_found_pcap=yes 106 | AC_MSG_RESULT(yes) 107 | PCAP_INC_DIR=$ac_cv_pcap_where_inc 108 | PCAP_LIB_DIR=$ac_cv_pcap_where_lib 109 | PCAP_CFLAGS="-I${PCAP_INC_DIR}" 110 | if test "X$PCAP_LIB_DIR" = "X"; then 111 | PCAP_LIBS="-lpcap" 112 | else 113 | PCAP_LIBS="-L${PCAP_LIB_DIR} -lpcap" 114 | fi 115 | ifelse([$1], , :, [$1]) 116 | fi 117 | AC_SUBST(PCAP_CFLAGS) 118 | AC_SUBST(PCAP_LIBS) 119 | ]) 120 | -------------------------------------------------------------------------------- /m4/sdl.m4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gdwnldsKSC/es40/bce8dacde45cee8f58f122be6ed24602c51cdbd8/m4/sdl.m4 -------------------------------------------------------------------------------- /m4/x11.m4: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # ES40 emulator. 3 | # Copyright (C) 2007-2008 by the ES40 Emulator Project 4 | # 5 | # Website: http://sourceforge.net/projects/es40 6 | # E-mail : camiel@camicom.com 7 | # 8 | # This program is free software; you can redistribute it and/or 9 | # modify it under the terms of the GNU General Public License 10 | # as published by the Free Software Foundation; either version 2 11 | # of the License, or (at your option) any later version. 12 | # 13 | # This program is distributed in the hope that it will be useful, 14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | # GNU General Public License for more details. 17 | # 18 | # You should have received a copy of the GNU General Public License 19 | # along with this program; if not, write to the Free Software 20 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 21 | # 02110-1301, USA. 22 | # 23 | # Although this is not required, the author would appreciate being notified of, 24 | # and receiving any modifications you may make to the source code that might serve 25 | # the general public. 26 | # 27 | ################################################################################ 28 | # 29 | # $Id$ 30 | # 31 | # X-1.1 Camiel Vanderhoeven 20-MAR-2008 32 | # File Created. 33 | # 34 | ################################################################################ 35 | # 36 | # Check if X11 is installed, and configure paths 37 | 38 | dnl AM_PATH_X11([ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]) 39 | dnl test for X11, and define X11_CFLAGS and X11_LIBS 40 | dnl 41 | 42 | AC_DEFUN([AM_PATH_X11], 43 | [dnl 44 | dnl Get the cflags and libraries for X11 45 | dnl 46 | 47 | AC_PATH_X([X11],[X11/Xlib.h],[XOpenDisplay(NULL)]) 48 | 49 | not_really_there="" 50 | if test "X$no_x" = "X"; then 51 | if test "X$x_includes" = "X"; then 52 | AC_TRY_CPP([#include ], , not_really_there="yes") 53 | else 54 | if test ! -r $x_includes/X11/Intrinsic.h; then 55 | not_really_there="yes" 56 | fi 57 | fi 58 | fi 59 | 60 | if test "$no_x" = "yes" -o "$not_really_there" = "yes"; then 61 | AC_MSG_CHECKING(for X11 header files) 62 | X11_CFLAGS="" 63 | AC_TRY_CPP([#include ], , X11_CFLAGS="nope") 64 | if test "$X11_CFLAGS" = "nope"; then 65 | dirs="/usr/unsupported/include /usr/local/include /usr/X386/include /usr/include/X11R4 /usr/X11R5/include /usr/include/X11R5 /usr/openwin/include /usr/X11/include /usr/sww/include /usr/X11R6/include /usr/include/X11R6" 66 | for i in $dirs ; do 67 | if test -r $i/X11/Intrinsic.h; then 68 | AC_MSG_RESULT($i) 69 | X11_CFLAGS=" -I$i" 70 | break 71 | fi 72 | done 73 | fi 74 | else 75 | if test "$x_includes" != ""; then 76 | X11_CFLAGS=-I$x_includes 77 | else 78 | X11_CFLAGS="" 79 | fi 80 | fi 81 | if test "$X11_CFLAGS" = "nope"; then 82 | AC_MSG_RESULT(couldn't find any!) 83 | fi 84 | 85 | if test "$no_x" = "yes"; then 86 | AC_MSG_CHECKING(for X11 libraries) 87 | X11_LIBS="nope" 88 | dirs="/usr/unsupported/lib /usr/local/lib /usr/X386/lib /usr/lib/X11R4 /usr/X11R5/lib /usr/lib/X11R5 /usr/X11R6/lib /usr/lib/X11R6 /usr/openwin/lib /usr/X11/lib /usr/sww/X11/lib" 89 | for i in $dirs ; do 90 | if test -r $i/libX11.a -o -r $i/libX11.so -o -r $i/libX11.sl; then 91 | AC_MSG_RESULT($i) 92 | X11_LIBS="-L$i -lX11" 93 | break 94 | fi 95 | done 96 | else 97 | if test "$x_libraries" = ""; then 98 | X11_LIBS=-"lX11" 99 | else 100 | X11_LIBS="-L$x_libraries -lX11" 101 | fi 102 | fi 103 | if test "$X11_LIBS" = "nope" ; then 104 | AC_CHECK_LIB(Xwindow, XCreateWindow, X11_LIBS=-lXwindow) 105 | fi 106 | if test "$X11_LIBS" = "nope" ; then 107 | AC_MSG_RESULT(couldn't find any!) 108 | fi 109 | 110 | AC_MSG_CHECKING(whether to use X11) 111 | if test "$X11_FLAGS" = "nope" -o "$X11_LIBS" = "nope"; then 112 | AC_MSG_RESULT(no) 113 | X11_FLAGS="" 114 | X11_LIBS="" 115 | ifelse([$2], , :, [$2]) 116 | else 117 | AC_MSG_RESULT(yes) 118 | ifelse([$1], , :, [$1]) 119 | fi 120 | AC_SUBST(X11_CFLAGS) 121 | AC_SUBST(X11_LIBS) 122 | ]) 123 | -------------------------------------------------------------------------------- /src/AliM1543C_usb.h: -------------------------------------------------------------------------------- 1 | /* ES40 emulator. 2 | * Copyright (C) 2007-2008 by the ES40 Emulator Project 3 | * 4 | * WWW : http://sourceforge.net/projects/es40 5 | * E-mail : camiel@camicom.com 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2 10 | * of the License, or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | * 21 | * Although this is not required, the author would appreciate being notified of, 22 | * and receiving any modifications you may make to the source code that might serve 23 | * the general public. 24 | */ 25 | 26 | /** 27 | * \file 28 | * Contains the definitions for the emulated Ali M1543C USB chipset part. 29 | * 30 | * $Id$ 31 | * 32 | * X-1.5 Brian wheeler 18-FEB-2008 33 | * Implemented HCI register space. 34 | * 35 | * X-1.4 Camiel Vanderhoeven 08-JAN-2008 36 | * Comments. 37 | * 38 | * X-1.3 Camiel Vanderhoeven 02-JAN-2008 39 | * Comments. 40 | * 41 | * X-1.2 Camiel Vanderhoeven 17-DEC-2007 42 | * SaveState file format 2.1 43 | * 44 | * X-1.1 Camiel Vanderhoeven 10-DEC-2007 45 | * Initial version in CVS; this part was split off from the CAliM1543C 46 | * class. 47 | **/ 48 | #if !defined(INCLUDED_ALIM1543C_USB_H_) 49 | #define INCLUDED_ALIM1543C_USB_H_ 50 | 51 | #include "PCIDevice.h" 52 | 53 | /** 54 | * \brief Emulated USB part of ALi M1543C multi-function device. 55 | * 56 | * \todo This device is just a stub. Not functional yet. 57 | * 58 | * Documentation consulted: 59 | * - Ali M1543C B1 South Bridge Version 1.20 60 | * (http://mds.gotdns.com/sensors/docs/ali/1543dScb1-120.pdf) 61 | * . 62 | **/ 63 | class CAliM1543C_usb : public CPCIDevice 64 | { 65 | public: 66 | virtual int SaveState(FILE* f); 67 | virtual int RestoreState(FILE* f); 68 | 69 | CAliM1543C_usb(CConfigurator* cfg, class CSystem* c, int pcibus, int pcidev); 70 | virtual ~CAliM1543C_usb(); 71 | virtual void WriteMem_Bar(int func, int bar, u32 address, int dsize, 72 | u32 data); 73 | virtual u32 ReadMem_Bar(int func, int bar, u32 address, int dsize); 74 | private: 75 | u64 usb_hci_read(u64 address, int dsize); 76 | void usb_hci_write(u64 address, int dsize, u64 data); 77 | 78 | /// The state structure contains all elements that need to be saved to the statefile. 79 | struct SUSB_state 80 | { 81 | u32 usb_data[0x110 / 4]; 82 | } state; 83 | }; 84 | #endif // !defined(INCLUDED_ALIM1543C_USB_H_) 85 | -------------------------------------------------------------------------------- /src/DMA.h: -------------------------------------------------------------------------------- 1 | /* ES40 emulator. 2 | * Copyright (C) 2007-2008 by the ES40 Emulator Project 3 | * 4 | * WWW : http://es40.org 5 | * E-mail : camiel@es40.org 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2 10 | * of the License, or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | * 21 | * Although this is not required, the author would appreciate being notified of, 22 | * and receiving any modifications you may make to the source code that might serve 23 | * the general public. 24 | */ 25 | 26 | /** 27 | * \file 28 | * Contains the definitions for the emulated DMA controller. 29 | * 30 | * $Id$ 31 | * 32 | * X-1.5 Camiel Vanderhoeven 29-APR-2008 33 | * Removed unused reference to floppy disk image. 34 | * 35 | * X-1.4 Brian Wheeler 29-APR-2008 36 | * Fixed floppy disk implementation. 37 | * 38 | * X-1.3 Brian Wheeler 18-APR-2008 39 | * Rewrote DMA code to make it ready for floppy support. 40 | * 41 | * X-1.2 Camiel Vanderhoeven 14-MAR-2008 42 | * Formatting. 43 | * 44 | * X-1.1 Camiel Vanderhoeven 26-FEB-2008 45 | * Created. Contains code previously found in AliM1543C.h 46 | * 47 | * \author Camiel Vanderhoeven (camiel@camicom.com / http://www.camicom.com) 48 | **/ 49 | #if !defined(INCLUDED_DMA_H) 50 | #define INCLUDED_DMA_H 51 | 52 | #include "SystemComponent.h" 53 | 54 | /** 55 | * \brief Emulated DMA controller. 56 | **/ 57 | 58 | 59 | class CDMA : public CSystemComponent 60 | { 61 | public: 62 | CDMA(CConfigurator* cfg, CSystem* c); 63 | virtual ~CDMA(); 64 | 65 | virtual int DoClock(); 66 | virtual void WriteMem(int index, u64 address, int dsize, u64 data); 67 | virtual u64 ReadMem(int index, u64 address, int dsize); 68 | virtual int SaveState(FILE* f); 69 | virtual int RestoreState(FILE* f); 70 | 71 | void set_request(int index, int channel, int data); 72 | void send_data(int channel, void *data); 73 | void recv_data(int channel, void *data); 74 | int get_count(int channel) { return state.channel[channel].count; }; 75 | 76 | private: 77 | void do_dma(); 78 | 79 | /// The state structure contains all elements that need to be saved to the statefile. 80 | struct SDMA_state 81 | { 82 | /// DMA channel state 83 | struct SDMA_chan 84 | { 85 | bool a_lobyte; // address lobyte expected 86 | bool c_lobyte; // count lobyte expected 87 | u16 current; 88 | u16 base; 89 | u16 pagebase; 90 | u16 count; 91 | u8 mode; 92 | } channel[8]; 93 | 94 | /// DMA controller state 95 | struct SDMA_ctrl 96 | { 97 | u8 status; 98 | u8 command; 99 | u8 request; 100 | u8 mask; 101 | } controller[2]; 102 | } 103 | state; 104 | }; 105 | 106 | #define DMA_IO_BASE 0x1000 107 | #define DMA0_IO_MAIN DMA_IO_BASE + 0 108 | #define DMA1_IO_MAIN DMA_IO_BASE + 1 109 | #define DMA_IO_LPAGE DMA_IO_BASE + 2 110 | #define DMA_IO_HPAGE DMA_IO_BASE + 3 111 | #define DMA0_IO_CHANNEL DMA_IO_BASE + 4 112 | #define DMA1_IO_CHANNEL DMA_IO_BASE + 5 113 | #define DMA0_IO_EXT DMA_IO_BASE + 6 114 | #define DMA1_IO_EXT DMA_IO_BASE + 7 115 | 116 | extern CDMA *theDMA; 117 | 118 | #endif // !defined(INCLUDED_DMA_H) 119 | -------------------------------------------------------------------------------- /src/DPR.h: -------------------------------------------------------------------------------- 1 | /* ES40 emulator. 2 | * Copyright (C) 2007-2008 by the ES40 Emulator Project 3 | * 4 | * Website: http://sourceforge.net/projects/es40 5 | * E-mail : camiel@camicom.com 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2 10 | * of the License, or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | * 21 | * Although this is not required, the author would appreciate being notified of, 22 | * and receiving any modifications you may make to the source code that might serve 23 | * the general public. 24 | */ 25 | 26 | /** 27 | * \file 28 | * Contains the definitions for the emulated Dual Port Ram and RMC devices. 29 | * 30 | * $Id$ 31 | * 32 | * X-1.12 Camiel Vanderhoeven 13-MAR-2008 33 | * Create init(), start_threads() and stop_threads() functions. 34 | * 35 | * X-1.11 Camiel Vanderhoeven 05-MAR-2008 36 | * Multi-threading version. 37 | * 38 | * X-1.10 Camiel Vanderhoeven 02-JAN-2008 39 | * Comments. 40 | * 41 | * X-1.9 Camiel Vanderhoeven 17-DEC-2007 42 | * SaveState file format 2.1 43 | * 44 | * X-1.8 Camiel Vanderhoeven 10-DEC-2007 45 | * Changes to make the TraceEngine work again after recent changes. 46 | * 47 | * X-1.7 Camiel Vanderhoeven 10-DEC-2007 48 | * Use configurator. 49 | * 50 | * X-1.6 Camiel Vanderhoeven 30-MAR-2007 51 | * Added old changelog comments. 52 | * 53 | * X-1.5 Camiel Vanderhoeven 16-FEB-2007 54 | * Added functions SaveStateF and RestoreStateF. 55 | * 56 | * X-1.4 Camiel Vanderhoeven 7-FEB-2007 57 | * Added comments. 58 | * 59 | * X-1.3 Camiel Vanderhoeven 7-FEB-2007 60 | * Added comments. 61 | * 62 | * X-1.2 Brian Wheeler 3-FEB-2007 63 | * Formatting. 64 | * 65 | * X-1.1 Camiel Vanderhoeven 19-JAN-2007 66 | * Initial version in CVS. 67 | * 68 | * \author Camiel Vanderhoeven (camiel@camicom.com / http://www.camicom.com) 69 | **/ 70 | #if !defined(INCLUDED_DPR_H) 71 | #define INCLUDED_DPR_H 72 | 73 | #include "SystemComponent.h" 74 | 75 | /** 76 | * \brief Emulated dual-port RAM and management controller. 77 | **/ 78 | class CDPR : public CSystemComponent 79 | { 80 | public: 81 | CDPR(CConfigurator* cfg, class CSystem* c); 82 | virtual ~CDPR(); 83 | virtual void init(); 84 | virtual void WriteMem(int index, u64 address, int dsize, u64 data); 85 | virtual u64 ReadMem(int index, u64 address, int dsize); 86 | virtual int SaveState(FILE* f); 87 | virtual int RestoreState(FILE* f); 88 | void SaveStateF(); 89 | void RestoreStateF(); 90 | void SaveStateF(char* fn); 91 | void RestoreStateF(char* fn); 92 | protected: 93 | 94 | /// The state structure contains all elements that need to be saved to the statefile. 95 | struct SDPR_state 96 | { 97 | u8 ram[16 * 1024]; 98 | } state; 99 | }; 100 | 101 | extern CDPR* theDPR; 102 | #endif // !defined(INCLUDED_DPR_H_) 103 | -------------------------------------------------------------------------------- /src/DiskController.cpp: -------------------------------------------------------------------------------- 1 | /* ES40 emulator. 2 | * Copyright (C) 2007-2008 by the ES40 Emulator Project 3 | * 4 | * WWW : http://es40.org 5 | * E-mail : camiel@es40.org 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2 10 | * of the License, or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | * 21 | * Although this is not required, the author would appreciate being notified of, 22 | * and receiving any modifications you may make to the source code that might serve 23 | * the general public. 24 | */ 25 | 26 | /** 27 | * \file 28 | * Contains definitions for the disk controller base class. 29 | * 30 | * $Id$ 31 | * 32 | * X-1.15 Camiel Vanderhoeven 29-APR-2008 33 | * CDiskController is no longer a CPCIDevice. devices that are both 34 | * should multiple inherit both. 35 | * 36 | * X-1.14 Camiel Vanderhoeven 14-MAR-2008 37 | * Formatting. 38 | * 39 | * X-1.13 Camiel Vanderhoeven 14-MAR-2008 40 | * 1. More meaningful exceptions replace throwing (int) 1. 41 | * 2. U64 macro replaces X64 macro. 42 | * 43 | * X-1.12 Camiel Vanderhoeven 14-JAN-2008 44 | * Removed unreferenced variable. 45 | * 46 | * X-1.11 Brian Wheeler 13-JAN-2008 47 | * Avoid deleting Disk devices twice. 48 | * 49 | * X-1.9 Camiel Vanderhoeven 12-JAN-2008 50 | * Made register_disk void and virtual. 51 | * 52 | * X-1.8 Camiel Vanderhoeven 29-DEC-2007 53 | * Fix memory-leak. 54 | * 55 | * X-1.7 Camiel Vanderhoeven 28-DEC-2007 56 | * Keep the compiler happy. 57 | * 58 | * X-1.6 Camiel Vanderhoeven 18-DEC-2007 59 | * Initialize pointers to 0 in constructor. (doh!) 60 | * 61 | * X-1.5 Camiel Vanderhoeven 17-DEC-2007 62 | * Removed excessive whitespace. 63 | * 64 | * X-1.4 Brian Wheeler 16-DEC-2007 65 | * Added newline at end of file. 66 | * 67 | * X-1.3 Camiel Vanderhoeven 16-DEC-2007 68 | * Include Disk.h, so children's destructors can be called. 69 | * 70 | * X-1.2 Camiel Vanderhoeven 14-DEC-2007 71 | * Delete children upon destruction. 72 | * 73 | * X-1.1 Camiel Vanderhoeven 12-DEC-2007 74 | * Initial version in CVS. 75 | **/ 76 | #include "StdAfx.h" 77 | #include "DiskController.h" 78 | #include "Disk.h" 79 | 80 | CDiskController::CDiskController(int num_busses, int num_devices) 81 | { 82 | num_bus = num_busses; 83 | num_dev = num_devices; 84 | 85 | disks = (CDisk**) calloc(num_bus * num_dev, sizeof(CDisk *)); 86 | } 87 | 88 | CDiskController::~CDiskController(void) 89 | { 90 | free(disks); 91 | } 92 | 93 | void CDiskController::register_disk(class CDisk* dsk, int bus, int dev) 94 | { 95 | if(bus >= num_bus) 96 | FAILURE(Configuration, "Can't register disk: bus number out of range"); 97 | if(dev >= num_dev) 98 | FAILURE(Configuration, "Can't register disk: device number out of range"); 99 | 100 | disks[bus * num_bus + dev] = dsk; 101 | } 102 | 103 | class CDisk* CDiskController::get_disk(int bus, int dev) 104 | { 105 | if(bus >= num_bus) 106 | return 0; 107 | if(dev >= num_dev) 108 | return 0; 109 | 110 | return disks[bus * num_bus + dev]; 111 | } 112 | -------------------------------------------------------------------------------- /src/DiskController.h: -------------------------------------------------------------------------------- 1 | /* ES40 emulator. 2 | * Copyright (C) 2007-2008 by the ES40 Emulator Project 3 | * 4 | * WWW : http://es40.org 5 | * E-mail : camiel@es40.org 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2 10 | * of the License, or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | * 21 | * Although this is not required, the author would appreciate being notified of, 22 | * and receiving any modifications you may make to the source code that might serve 23 | * the general public. 24 | */ 25 | 26 | /** 27 | * \file 28 | * Contains definitions for the disk controller base class. 29 | * 30 | * $Id$ 31 | * 32 | * X-1.5 Camiel Vanderhoeven 29-APR-2008 33 | * CDiskController is no longer a CPCIDevice. devices that are both 34 | * should multiple inherit both. 35 | * 36 | * X-1.4 Camiel Vanderhoeven 14-MAR-2008 37 | * Formatting. 38 | * 39 | * X-1.3 Camiel Vanderhoeven 12-JAN-2008 40 | * Made register_disk void and virtual. 41 | * 42 | * X-1.2 Camiel Vanderhoeven 02-JAN-2008 43 | * Comments. 44 | * 45 | * X-1.1 Camiel Vanderhoeven 12-DEC-2007 46 | * Initial version in CVS. 47 | **/ 48 | #if !defined(__DISKCONTROLLER_H__) 49 | #define __DISKCONTROLLER_H__ 50 | 51 | /** 52 | * \brief Abstract base class for disk controllers (uses CDisk's) 53 | **/ 54 | class CDiskController 55 | { 56 | public: 57 | CDiskController(int num_busses, int num_devs); 58 | ~CDiskController(void); 59 | 60 | virtual void register_disk(class CDisk* dsk, int bus, int dev); 61 | class CDisk* get_disk(int bus, int dev); 62 | private: 63 | int num_bus; 64 | int num_dev; 65 | 66 | class CDisk** disks; 67 | }; 68 | #endif //!defined(__DISKCONTROLLER_H__) 69 | -------------------------------------------------------------------------------- /src/DiskDevice.h: -------------------------------------------------------------------------------- 1 | /* ES40 emulator. 2 | * Copyright (C) 2007 by the ES40 Emulator Project 3 | * 4 | * WWW : http://sourceforge.net/projects/es40 5 | * E-mail : camiel@camicom.com 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2 10 | * of the License, or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | * 21 | * Although this is not required, the author would appreciate being notified of, 22 | * and receiving any modifications you may make to the source code that might serve 23 | * the general public. 24 | */ 25 | 26 | /** 27 | * \file 28 | * Contains definitions to use a raw device as a disk image. 29 | * 30 | * $Id$ 31 | * 32 | * X-1.3 Camiel Vanderhoeven 09-JAN-2008 33 | * Save disk state to state file. 34 | * 35 | * X-1.2 Camiel Vanderhoeven 06-JAN-2008 36 | * Support changing the block size (required for SCSI, ATAPI). 37 | * 38 | * X-1.1 Camiel Vanderhoeven 05-JAN-2008 39 | * Initial version in CVS. 40 | **/ 41 | #if !defined(__DISKDEV_H__) 42 | #define __DISKDEV_H__ 43 | 44 | #include "Disk.h" 45 | 46 | /** 47 | * \brief Emulated disk that uses a raw device. 48 | **/ 49 | class CDiskDevice : public CDisk 50 | { 51 | public: 52 | CDiskDevice(CConfigurator* cfg, CSystem* sys, CDiskController* c, 53 | int idebus, int idedev); 54 | virtual ~CDiskDevice(void); 55 | 56 | virtual bool seek_byte(off_t_large byte); 57 | virtual size_t read_bytes(void* dest, size_t bytes); 58 | virtual size_t write_bytes(void* src, size_t bytes); 59 | protected: 60 | #if defined(_WIN32) 61 | HANDLE handle; 62 | char* buffer; 63 | size_t buffer_size; 64 | size_t dev_block_size; 65 | #else 66 | FILE* handle; 67 | #endif 68 | char* filename; 69 | }; 70 | #endif //!defined(__DISKFILE_H__) 71 | -------------------------------------------------------------------------------- /src/DiskFile.h: -------------------------------------------------------------------------------- 1 | /* ES40 emulator. 2 | * Copyright (C) 2007 by the ES40 Emulator Project 3 | * 4 | * WWW : http://sourceforge.net/projects/es40 5 | * E-mail : camiel@camicom.com 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2 10 | * of the License, or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | * 21 | * Although this is not required, the author would appreciate being notified of, 22 | * and receiving any modifications you may make to the source code that might serve 23 | * the general public. 24 | */ 25 | 26 | /** 27 | * \file 28 | * Contains definitions to use a file as a disk image. 29 | * 30 | * $Id$ 31 | * 32 | * X-1.7 Camiel Vanderhoeven 09-JAN-2008 33 | * Save disk state to state file. 34 | * 35 | * X-1.6 Camiel Vanderhoeven 06-JAN-2008 36 | * Support changing the block size (required for SCSI, ATAPI). 37 | * 38 | * X-1.5 Camiel Vanderhoeven 04-JAN-2008 39 | * 64-bit file I/O. 40 | * 41 | * X-1.4 Camiel Vanderhoeven 02-JAN-2008 42 | * Comments. 43 | * 44 | * X-1.3 Camiel Vanderhoeven 28-DEC-2007 45 | * Keep the compiler happy. 46 | * 47 | * X-1.2 Camiel Vanderhoeven 20-DEC-2007 48 | * Close files and free memory when the emulator shuts down. 49 | * 50 | * X-1.1 Camiel Vanderhoeven 12-DEC-2007 51 | * Initial version in CVS. 52 | **/ 53 | #if !defined(__DISKFILE_H__) 54 | #define __DISKFILE_H__ 55 | 56 | #include "Disk.h" 57 | 58 | /** 59 | * \brief Emulated disk that uses an image file. 60 | **/ 61 | class CDiskFile : public CDisk 62 | { 63 | public: 64 | CDiskFile(CConfigurator* cfg, CSystem* sys, CDiskController* c, 65 | int idebus, int idedev); 66 | virtual ~CDiskFile(void); 67 | 68 | virtual bool seek_byte(off_t_large byte); 69 | virtual size_t read_bytes(void* dest, size_t bytes); 70 | virtual size_t write_bytes(void* src, size_t bytes); 71 | 72 | FILE* get_handle() { return handle; }; 73 | protected: 74 | FILE* handle; 75 | char* filename; 76 | }; 77 | #endif //!defined(__DISKFILE_H__) 78 | -------------------------------------------------------------------------------- /src/DiskRam.h: -------------------------------------------------------------------------------- 1 | /* ES40 emulator. 2 | * Copyright (C) 2007-2008 by the ES40 Emulator Project 3 | * 4 | * WWW : http://sourceforge.net/projects/es40 5 | * E-mail : camiel@camicom.com 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2 10 | * of the License, or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | * 21 | * Although this is not required, the author would appreciate being notified of, 22 | * and receiving any modifications you may make to the source code that might serve 23 | * the general public. 24 | */ 25 | 26 | /** 27 | * \file 28 | * Contains definitions to use a RAM disk. 29 | * 30 | * $Id$ 31 | * 32 | * X-1.9 Camiel Vanderhoeven 12-JAN-2008 33 | * Avoid compiler warnings. 34 | * 35 | * X-1.8 Camiel Vanderhoeven 09-JAN-2008 36 | * Save disk state to state file. 37 | * 38 | * X-1.7 Camiel Vanderhoeven 06-JAN-2008 39 | * Support changing the block size (required for SCSI, ATAPI). 40 | * 41 | * X-1.6 Camiel Vanderhoeven 04-JAN-2008 42 | * 64-bit file I/O. 43 | * 44 | * X-1.5 Camiel Vanderhoeven 02-JAN-2008 45 | * Comments. 46 | * 47 | * X-1.4 Camiel Vanderhoeven 28-DEC-2007 48 | * Keep the compiler happy. 49 | * 50 | * X-1.3 Camiel Vanderhoeven 20-DEC-2007 51 | * Close files and free memory when the emulator shuts down. 52 | * 53 | * X-1.2 Brian Wheeler 16-DEC-2007 54 | * Corrected some weird uses of size_t... 55 | * 56 | * X-1.1 Camiel Vanderhoeven 12-DEC-2007 57 | * Initial version in CVS. 58 | **/ 59 | #if !defined(__DISKRAM_H__) 60 | #define __DISKRAM_H__ 61 | 62 | #include "Disk.h" 63 | 64 | /** 65 | * \brief Emulated disk that uses RAM. 66 | **/ 67 | class CDiskRam : public CDisk 68 | { 69 | public: 70 | CDiskRam(CConfigurator* cfg, CSystem* sys, CDiskController* c, int idebus, 71 | int idedev); 72 | virtual ~CDiskRam(void); 73 | 74 | virtual bool seek_byte(off_t_large byte); 75 | virtual size_t read_bytes(void* dest, size_t bytes); 76 | virtual size_t write_bytes(void* src, size_t bytes); 77 | protected: 78 | void* ramdisk; 79 | }; 80 | #endif //!defined(__DISKFILE_H__) 81 | -------------------------------------------------------------------------------- /src/Ethernet.h: -------------------------------------------------------------------------------- 1 | /* ES40 emulator. 2 | * Copyright (C) 2007-2008 by the ES40 Emulator Project 3 | * 4 | * WWW : http://sourceforge.net/projects/es40 5 | * E-mail : camiel@camicom.com 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2 10 | * of the License, or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | * 21 | * Although this is not required, the author would appreciate being notified of, 22 | * and receiving any modifications you may make to the source code that might serve 23 | * the general public. 24 | * 25 | * Parts of this file based upon GXemul, which is Copyright (C) 2004-2007 26 | * Anders Gavare. All rights reserved. 27 | */ 28 | 29 | /** 30 | * \file 31 | * Contains the definitions for the packet queue and other NIC support routines. 32 | * 33 | * $Id$ 34 | * 35 | * X-1.3 Camiel Vanderhoeven 26-MAR-2008 36 | * Fix compiler warnings. 37 | * 38 | * X-1.2 Camiel Vanderhoeven 14-MAR-2008 39 | * Formatting. 40 | * 41 | * X-1.1 David Hittner 26-FEB-2008 42 | * File creation. 43 | **/ 44 | #if !defined(INCLUDED_ETHERNET_H) 45 | #define INCLUDED_ETHERNET_H 46 | 47 | #define ETH_MAX_PACKET_RAW 1514 48 | #define ETH_MAX_PACKET_CRC 1518 49 | 50 | struct eth_frame 51 | { // ethernet (wire) frame 52 | u8 src[6]; // source address 53 | u8 dst[6]; // destination address 54 | u8 protocol[2]; // protocol 55 | u8 data[1500]; // data: variable 46-1500 bytes 56 | u8 crc_fill[4]; // space for max packet crc 57 | }; 58 | 59 | struct eth_packet 60 | { // ethernet packet 61 | int len; // size of packet 62 | int used; // bytes used (consumed) 63 | u8 frame[ETH_MAX_PACKET_CRC]; // ethernet frame 64 | }; 65 | 66 | /** 67 | * \brief Packet Queue for Ethernet packets. 68 | **/ 69 | class CPacketQueue 70 | { // Ethernet Packet Queue 71 | 72 | //private: 73 | public: 74 | const char* name; // queue name 75 | int max; // maximum items allowed in queue 76 | int head; // first item in queue 77 | int tail; // last item in queue 78 | int cnt; // current item count 79 | int highwater; // highwater mark (statistics) 80 | int dropped; // packets dropped because queue was full 81 | eth_packet* packets; // packet array; dynamically allocated 82 | public: 83 | inline int count() { return cnt; } 84 | 85 | // get current count 86 | inline int lost() { return dropped; } 87 | 88 | // get number of lost packets 89 | void flush(); // empties packet queue 90 | bool add_tail(const u8* packet_data, int packet_len, bool calc_crc, 91 | bool need_crc); // adds pcap packet to queue 92 | bool get_head(eth_packet& packet); // get packet at head 93 | CPacketQueue(const char* name, int max); // constructor 94 | ~ CPacketQueue(); // destructor 95 | }; 96 | #endif // !defined(INCLUDED_ETHERNET_H) 97 | -------------------------------------------------------------------------------- /src/Flash.h: -------------------------------------------------------------------------------- 1 | /* ES40 emulator. 2 | * Copyright (C) 2007-2008 by the ES40 Emulator Project 3 | * 4 | * Website: http://sourceforge.net/projects/es40 5 | * E-mail : camiel@camicom.com 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2 10 | * of the License, or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | * 21 | * Although this is not required, the author would appreciate being notified of, 22 | * and receiving any modifications you may make to the source code that might serve 23 | * the general public. 24 | */ 25 | 26 | /** 27 | * \file 28 | * Contains the definitions for the emulated Flash ROM devices. 29 | * 30 | * $Id$ 31 | * 32 | * X-1.11 Camiel Vanderhoeven 02-JAN-2008 33 | * Comments. 34 | * 35 | * X-1.10 Camiel Vanderhoeven 17-DEC-2007 36 | * SaveState file format 2.1 37 | * 38 | * X-1.9 Camiel Vanderhoeven 10-DEC-2007 39 | * Changes to make the TraceEngine work again after recent changes. 40 | * 41 | * X-1.8 Camiel Vanderhoeven 10-DEC-2007 42 | * Use configurator. 43 | * 44 | * X-1.7 Camiel Vanderhoeven 30-MAR-2007 45 | * Added old changelog comments. 46 | * 47 | * X-1.6 Camiel Vanderhoeven 16-FEB-2007 48 | * Added SaveStateF and RestoreStateF functions. 49 | * 50 | * X-1.5 Camiel Vanderhoeven 12-FEB-2007 51 | * Formatting. 52 | * 53 | * X-1.4 Camiel Vanderhoeven 12-FEB-2007 54 | * Added comments. 55 | * 56 | * X-1.3 Camiel Vanderhoeven 7-FEB-2007 57 | * Added comments. 58 | * 59 | * X-1.2 Brian Wheeler 3-FEB-2007 60 | * Formatting. 61 | * 62 | * X-1.1 Camiel Vanderhoeven 19-JAN-2007 63 | * Initial version in CVS. 64 | * 65 | * 66 | * \author Camiel Vanderhoeven (camiel@camicom.com / http://www.camicom.com) 67 | **/ 68 | #if !defined(INCLUDED_FLASH_H) 69 | #define INCLUDED_FLASH_H 70 | 71 | #include "SystemComponent.h" 72 | 73 | /** 74 | * \brief Emulated flash memory. 75 | * 76 | * Flash memory is only used for storing configuration data (such as SRM console variables), 77 | * it is not used for firmware. 78 | **/ 79 | class CFlash : public CSystemComponent 80 | { 81 | public: 82 | virtual void WriteMem(int index, u64 address, int dsize, u64 data); 83 | virtual u64 ReadMem(int index, u64 address, int dsize); 84 | CFlash(CConfigurator* cfg, class CSystem* c); 85 | virtual ~CFlash(); 86 | virtual int SaveState(FILE* f); 87 | virtual int RestoreState(FILE* f); 88 | void SaveStateF(); 89 | void RestoreStateF(); 90 | void SaveStateF(char* fn); 91 | void RestoreStateF(char* fn); 92 | protected: 93 | 94 | /// The state structure contains all elements that need to be saved to the statefile. 95 | struct SFlash_state 96 | { 97 | u8 Flash[2 * 1024 * 1024]; 98 | int mode; 99 | } state; 100 | }; 101 | 102 | extern CFlash* theSROM; 103 | #endif // !defined(INCLUDED_FLASH_H) 104 | -------------------------------------------------------------------------------- /src/FreeTextQuestion.h: -------------------------------------------------------------------------------- 1 | /* ES40 emulator. 2 | * Copyright (C) 2007-2008 by the ES40 Emulator Project 3 | * 4 | * WWW : http://sourceforge.net/projects/es40 5 | * E-mail : camiel@camicom.com 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2 10 | * of the License, or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | * 21 | * Although this is not required, the author would appreciate being notified of, 22 | * and receiving any modifications you may make to the source code that might serve 23 | * the general public. 24 | */ 25 | 26 | /** 27 | * \file 28 | * FreeTextQuestion class for Configuration file creator. 29 | * 30 | * $Id$ 31 | * 32 | * X-1.1 Camiel Vanderhoeven 28-MAR-2008 33 | * File created. 34 | **/ 35 | 36 | /** 37 | * Question class that allows free-format text input. 38 | **/ 39 | class FreeTextQuestion: public Question 40 | { 41 | public: 42 | /** 43 | * Define a list of options to show following the question, 44 | * to show the user what values are acceptable. 45 | **/ 46 | void setOptions(string options) 47 | { 48 | mOptions = options; 49 | } 50 | 51 | /** 52 | * Ask the question, and return the answer. 53 | **/ 54 | virtual string ask() 55 | { 56 | for(;;) 57 | { 58 | cout << mQuestion; 59 | 60 | /* If there is an options list, display it after the 61 | * question enclosed in (). 62 | */ 63 | if (mOptions != "") 64 | cout << " (" << mOptions << ")"; 65 | 66 | /* If there is a default value, display it after the 67 | * question enclosed in []. 68 | */ 69 | if (mDefault != "") 70 | cout << " [" << mDefault << "]"; 71 | 72 | cout << ": "; 73 | 74 | /* Get the answer. 75 | */ 76 | getline(cin, mAnswer); 77 | 78 | /* If the question is answered with '?', display the 79 | * explanation, then ask again. 80 | */ 81 | if (mAnswer == "?") 82 | { 83 | explain(); 84 | continue; 85 | } 86 | 87 | /* If the question is answered with , set the 88 | * answer to the default answer. 89 | */ 90 | if (mAnswer =="") 91 | mAnswer = mDefault; 92 | 93 | /* Return the answer. 94 | */ 95 | return mAnswer; 96 | } 97 | } 98 | 99 | protected: 100 | /** List of options to show after the question. */ 101 | string mOptions; 102 | }; 103 | -------------------------------------------------------------------------------- /src/Makefile.am: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # ES40 emulator. 3 | # Copyright (C) 2007-2008 by the ES40 Emulator Project 4 | # 5 | # Website: http://www.es40.org 6 | # E-mail : camiel@es40.org 7 | # 8 | # This program is free software; you can redistribute it and/or 9 | # modify it under the terms of the GNU General Public License 10 | # as published by the Free Software Foundation; either version 2 11 | # of the License, or (at your option) any later version. 12 | # 13 | # This program is distributed in the hope that it will be useful, 14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | # GNU General Public License for more details. 17 | # 18 | # You should have received a copy of the GNU General Public License 19 | # along with this program; if not, write to the Free Software 20 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 21 | # 02110-1301, USA. 22 | # 23 | # Although this is not required, the author would appreciate being notified of, 24 | # and receiving any modifications you may make to the source code that might serve 25 | # the general public. 26 | # 27 | ################################################################################ 28 | # 29 | # $Id$ 30 | # 31 | # X-1.6 Caolan McNamara 12-JUN-2008 32 | # Fixes to build on Fedora 9 / gcc 4.3.0. 33 | # 34 | # X-1.5 Camiel Vanderhoeven 31-MAY-2008 35 | # Add parts of Poco. 36 | # 37 | # X-1.4 Camiel Vanderhoeven 04-APR-2008 38 | # Added comments. 39 | # 40 | # X-1.3 Camiel Vanderhoeven 29-MAR-2008 41 | # Added es40_cfg. 42 | # 43 | # X-1.1 Camiel Vanderhoeven 20-MAR-2008 44 | # File Created. 45 | # 46 | ################################################################################ 47 | 48 | bin_PROGRAMS = es40 es40_idb es40_lss es40_lsm es40_cfg 49 | 50 | es40_SOURCES = AliM1543C.cpp \ 51 | AliM1543C_ide.cpp \ 52 | AliM1543C_usb.cpp \ 53 | AlphaCPU.cpp \ 54 | AlphaCPU_ieeefloat.cpp \ 55 | AlphaCPU_vaxfloat.cpp \ 56 | AlphaCPU_vmspal.cpp \ 57 | AlphaSim.cpp \ 58 | Cirrus.cpp \ 59 | Configurator.cpp \ 60 | DEC21143.cpp \ 61 | Disk.cpp \ 62 | DiskController.cpp \ 63 | DiskDevice.cpp \ 64 | DiskFile.cpp \ 65 | DiskRam.cpp \ 66 | DMA.cpp \ 67 | DPR.cpp \ 68 | es40_debug.cpp \ 69 | Ethernet.cpp \ 70 | Flash.cpp \ 71 | FloppyController.cpp \ 72 | Keyboard.cpp \ 73 | lockstep.cpp \ 74 | PCIDevice.cpp \ 75 | Port80.cpp \ 76 | S3Trio64.cpp \ 77 | SCSIBus.cpp \ 78 | SCSIDevice.cpp \ 79 | Serial.cpp \ 80 | StdAfx.cpp \ 81 | Sym53C810.cpp \ 82 | Sym53C895.cpp \ 83 | SystemComponent.cpp \ 84 | System.cpp \ 85 | TraceEngine.cpp \ 86 | VGA.cpp \ 87 | gui/gui.cpp \ 88 | gui/gui_x11.cpp \ 89 | gui/keymap.cpp \ 90 | gui/scancodes.cpp \ 91 | gui/sdl.cpp \ 92 | base/Bugcheck.cpp \ 93 | base/ErrorHandler.cpp \ 94 | base/Event.cpp \ 95 | base/Exception.cpp \ 96 | base/Mutex.cpp \ 97 | base/NumberFormatter.cpp \ 98 | base/RefCountedObject.cpp \ 99 | base/Runnable.cpp \ 100 | base/RWLock.cpp \ 101 | base/Semaphore.cpp \ 102 | base/SignalHandler.cpp \ 103 | base/ThreadLocal.cpp \ 104 | base/Thread.cpp \ 105 | base/Timestamp.cpp 106 | 107 | es40_idb_SOURCES = $(es40_SOURCES) 108 | es40_lss_SOURCES = $(es40_SOURCES) 109 | es40_lsm_SOURCES = $(es40_SOURCES) 110 | 111 | es40_idb_CXXFLAGS = -DIDB 112 | es40_lss_CXXFLAGS = -DIDB -DLSS 113 | es40_lsm_CXXFLAGS = -DIDB -DLSM 114 | 115 | es40_cfg_SOURCES = es40-cfg.cpp \ 116 | base/Exception.cpp 117 | 118 | -------------------------------------------------------------------------------- /src/NumberQuestion.h: -------------------------------------------------------------------------------- 1 | /* ES40 emulator. 2 | * Copyright (C) 2007-2008 by the ES40 Emulator Project 3 | * 4 | * WWW : http://sourceforge.net/projects/es40 5 | * E-mail : camiel@camicom.com 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2 10 | * of the License, or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | * 21 | * Although this is not required, the author would appreciate being notified of, 22 | * and receiving any modifications you may make to the source code that might serve 23 | * the general public. 24 | */ 25 | 26 | /** 27 | * \file 28 | * NumberQuestion class for Configuration file creator. 29 | * 30 | * $Id$ 31 | * 32 | * X-1.1 Camiel Vanderhoeven 28-MAR-2008 33 | * File created. 34 | **/ 35 | 36 | /** 37 | * Convert an integer to a string. 38 | **/ 39 | inline string i2s(int x) 40 | { 41 | ostringstream o; 42 | o << x; 43 | return o.str(); 44 | } 45 | 46 | /** 47 | * Convert a string to an integer. 48 | * 49 | * Throws a CLogicException when the input is not numeric. 50 | **/ 51 | inline int s2i(const string x) 52 | { 53 | istringstream i(x); 54 | int x1; 55 | char c; 56 | if (!(i >> x1) || i.get(c)) 57 | FAILURE(Logic,"invalid conversion");; 58 | return x1; 59 | } 60 | 61 | /** 62 | * Question class that accepts a numeric answer within 63 | * a defined range. 64 | **/ 65 | class NumberQuestion: public FreeTextQuestion 66 | { 67 | public: 68 | /** 69 | * Define the allowable range for the answer. 70 | **/ 71 | void setRange(int low, int high) 72 | { 73 | mLow = low; mHigh = high; 74 | } 75 | 76 | /** 77 | * Convert the answer to a number. 78 | **/ 79 | int getNum() 80 | { 81 | return s2i(mAnswer); 82 | } 83 | 84 | /** 85 | * Ask the question and return the answer. 86 | **/ 87 | virtual string ask() 88 | { 89 | /* Set the options list to (low-high). 90 | */ 91 | setOptions(i2s(mLow) + "-" + i2s(mHigh)); 92 | 93 | /* Keep repeating the question until a valid 94 | * answer is received. 95 | */ 96 | for (;;) 97 | { 98 | int value; 99 | 100 | /* Ask the question as a FreeTextQuestion. This 101 | * takes care of the explanation and default 102 | * value handling. 103 | */ 104 | FreeTextQuestion::ask(); 105 | 106 | try 107 | { 108 | /* Convert the answer to an integer. 109 | */ 110 | value = s2i(mAnswer); 111 | 112 | /* If the answer is within the allowed range, 113 | * return it. 114 | */ 115 | if ( value >= mLow && value <= mHigh) 116 | return mAnswer; 117 | 118 | /* The answer is out of range. 119 | */ 120 | cout << "\nPlease enter a value that is within the indicated range, or '?' for help.\n\n"; 121 | } 122 | catch(CLogicException) 123 | { 124 | /* The answer is not a number. 125 | */ 126 | cout << "\nPlease enter an integer value.\n\n"; 127 | } 128 | } 129 | } 130 | 131 | protected: 132 | /** Low limit of the allowed range. */ 133 | int mLow; 134 | /** High limit of the allowed range. */ 135 | int mHigh; 136 | }; 137 | -------------------------------------------------------------------------------- /src/Port80.h: -------------------------------------------------------------------------------- 1 | /* ES40 emulator. 2 | * Copyright (C) 2007-2008 by the ES40 Emulator Project 3 | * 4 | * WWW : http://sourceforge.net/projects/es40 5 | * E-mail : camiel@camicom.com 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2 10 | * of the License, or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | * 21 | * Although this is not required, the author would appreciate being notified of, 22 | * and receiving any modifications you may make to the source code that might serve 23 | * the general public. 24 | */ 25 | 26 | /** 27 | * \file 28 | * Contains the definitions for the emulated Port 80 device. 29 | * 30 | * $Id$ 31 | * 32 | * X-1.9 Camiel Vanderhoeven 02-JAN-2008 33 | * Comments. 34 | * 35 | * X-1.8 Camiel Vanderhoeven 17-DEC-2007 36 | * SaveState file format 2.1 37 | * 38 | * X-1.7 Camiel Vanderhoeven 10-DEC-2007 39 | * Use configurator. 40 | * 41 | * X-1.6 Camiel Vanderhoeven 30-MAR-2007 42 | * Added old changelog comments. 43 | * 44 | * X-1.5 Camiel Vanderhoeven 16-FEB-2007 45 | * Changed header guards 46 | * 47 | * X-1.4 Camiel Vanderhoeven 12-FEB-2007 48 | * Added comments. 49 | * 50 | * X-1.3 Camiel Vanderhoeven 9-FEB-2007 51 | * Added comments. 52 | * 53 | * X-1.2 Brian Wheeler 3-FEB-2007 54 | * Formatting. 55 | * 56 | * X-1.1 Camiel Vanderhoeven 19-JAN-2007 57 | * Initial version in CVS. 58 | * 59 | * \author Camiel Vanderhoeven (camiel@camicom.com / http://www.camicom.com) 60 | **/ 61 | #if !defined(INCLUDED_PORT80_H) 62 | #define INCLUDED_PORT80_H 63 | 64 | #include "SystemComponent.h" 65 | 66 | /** 67 | * \brief Emulated port 80. 68 | * 69 | * Port 80 is a port without a real function, that is used to slow things down. 70 | * Since our emulator is slow enough already ;-) this port has no function at 71 | * all, but it needs to be there to avoid error messages about non-existing 72 | * hardware. 73 | **/ 74 | class CPort80 : public CSystemComponent 75 | { 76 | public: 77 | CPort80(CConfigurator* cfg, class CSystem* c); 78 | virtual ~CPort80(); 79 | virtual u64 ReadMem(int index, u64 address, int dsize); 80 | virtual void WriteMem(int index, u64 address, int dsize, u64 data); 81 | virtual int SaveState(FILE* f); 82 | virtual int RestoreState(FILE* f); 83 | protected: 84 | 85 | /// The state structure contains all elements that need to be saved to the statefile. 86 | struct SPort80_state 87 | { 88 | u8 p80; /**< Last value written.*/ 89 | } state; 90 | }; 91 | #endif // !defined(INCLUDED_PORT80_H) 92 | -------------------------------------------------------------------------------- /src/Question.h: -------------------------------------------------------------------------------- 1 | /* ES40 emulator. 2 | * Copyright (C) 2007-2008 by the ES40 Emulator Project 3 | * 4 | * WWW : http://sourceforge.net/projects/es40 5 | * E-mail : camiel@camicom.com 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2 10 | * of the License, or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | * 21 | * Although this is not required, the author would appreciate being notified of, 22 | * and receiving any modifications you may make to the source code that might serve 23 | * the general public. 24 | */ 25 | 26 | /** 27 | * \file 28 | * Question class for Configuration file creator. 29 | * 30 | * $Id$ 31 | * 32 | * X-1.1 Camiel Vanderhoeven 28-MAR-2008 33 | * File created. 34 | **/ 35 | 36 | /** 37 | * Abstract Question base class. 38 | **/ 39 | class Question 40 | { 41 | public: 42 | /** 43 | * Return the answer previously given. 44 | **/ 45 | string getAnswer() 46 | { 47 | return mAnswer; 48 | } 49 | 50 | /** 51 | * Set the answer. 52 | **/ 53 | void setAnswer(string answer) 54 | { 55 | mAnswer = answer; 56 | } 57 | 58 | /** 59 | * Define an explanation for the question, that will be shown when 60 | * the question is answered with '?'. 61 | **/ 62 | void setExplanation(string explanation) 63 | { 64 | mExplanation = explanation; 65 | } 66 | 67 | /** 68 | * Define the question to ask. 69 | **/ 70 | void setQuestion(string question) 71 | { 72 | mQuestion = question; 73 | } 74 | 75 | /** 76 | * Define a default value to use when the question is answered 77 | * with a . 78 | **/ 79 | void setDefault(string defval) 80 | { 81 | mDefault = defval; 82 | } 83 | 84 | /** 85 | * Ask the question, and return the value given. 86 | **/ 87 | virtual string ask() = 0; 88 | 89 | /** 90 | * Display the explanation. 91 | **/ 92 | virtual void explain() 93 | { 94 | cout << "\nEXPLANATION:\n" << mExplanation << "\n\n"; 95 | } 96 | 97 | protected: 98 | /** The stored answer. */ 99 | string mAnswer; 100 | 101 | /** An explanation for the question. */ 102 | string mExplanation; 103 | 104 | /** The question to ask. */ 105 | string mQuestion; 106 | 107 | /** Default value. */ 108 | string mDefault; 109 | }; 110 | -------------------------------------------------------------------------------- /src/SCSIBus.h: -------------------------------------------------------------------------------- 1 | /* ES40 emulator. 2 | * Copyright (C) 2007-2008 by the ES40 Emulator Project 3 | * 4 | * WWW : http://sourceforge.net/projects/es40 5 | * E-mail : camiel@camicom.com 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2 10 | * of the License, or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | * 21 | * Although this is not required, the author would appreciate being notified of, 22 | * and receiving any modifications you may make to the source code that might serve 23 | * the general public. 24 | */ 25 | 26 | /** 27 | * \file 28 | * Contains definitions for the SCSI bus class. 29 | * 30 | * $Id$ 31 | * 32 | * X-1.2 Camiel Vanderhoeven 20-JAN-2008 33 | * Avoid compiler warnings. 34 | * 35 | * X-1.1 Camiel Vanderhoeven 12-JAN-2008 36 | * Initial version in CVS. 37 | **/ 38 | #if !defined(__SCSIBUS__H__) 39 | #define __SCSIBUS__H__ 40 | 41 | #include "SystemComponent.h" 42 | #include "SCSIDevice.h" 43 | 44 | /** 45 | * \brief Emulated SCSI bus. 46 | * 47 | * connects SCSI Devices (class CSCSIDevice) together; SCSI devices are 48 | * disks and controllers. 49 | **/ 50 | class CSCSIBus : public CSystemComponent 51 | { 52 | public: 53 | CSCSIBus(CConfigurator* cfg, CSystem* c); 54 | ~ CSCSIBus(void); 55 | virtual int SaveState(FILE* f); 56 | virtual int RestoreState(FILE* f); 57 | 58 | void scsi_register(CSCSIDevice* dev, int bus, int target); 59 | void scsi_unregister(CSCSIDevice* dev, int target); 60 | 61 | bool arbitrate(int initiator); 62 | bool select(int initiator, int target); 63 | void set_phase(int target, int phase); 64 | int get_phase() { return state.phase; }; 65 | 66 | /**< Get current SCSI bus phase **/ 67 | void free_bus(int initiator); 68 | 69 | CSCSIDevice* targets[16]; /**< pointers to the SCSI devices that respond to the 15 possible target id's. **/ 70 | int target_bus_no[16]; /**< indicates what bus this is for each connected SCSI device. always 0 for disks, 71 | but controllers could have multiple SCSI busses. **/ 72 | 73 | /// The state structure contains all elements that need to be saved to the statefile 74 | struct SSCSI_state 75 | { 76 | int initiator; /**< SCSI id of the initiator. **/ 77 | int target; /**< SCSI id of the target. **/ 78 | int phase; /**< SCSI bus phase. **/ 79 | } state; 80 | }; 81 | 82 | #define SCSI_PHASE_FREE - 2 83 | #define SCSI_PHASE_ARBITRATION - 1 84 | #define SCSI_PHASE_DATA_OUT 0 85 | #define SCSI_PHASE_DATA_IN 1 86 | #define SCSI_PHASE_COMMAND 2 87 | #define SCSI_PHASE_STATUS 3 88 | #define SCSI_PHASE_MSG_OUT 6 89 | #define SCSI_PHASE_MSG_IN 7 90 | #endif 91 | -------------------------------------------------------------------------------- /src/SCSIDevice.h: -------------------------------------------------------------------------------- 1 | /* ES40 emulator. 2 | * Copyright (C) 2007-2008 by the ES40 Emulator Project 3 | * 4 | * WWW : http://sourceforge.net/projects/es40 5 | * E-mail : camiel@camicom.com 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2 10 | * of the License, or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | * 21 | * Although this is not required, the author would appreciate being notified of, 22 | * and receiving any modifications you may make to the source code that might serve 23 | * the general public. 24 | */ 25 | 26 | /** 27 | * \file 28 | * Contains definitions for the SCSI device base class. 29 | * 30 | * $Id$ 31 | * 32 | * X-1.2 Brian Wheeler 27-FEB-2008 33 | * Avoid compiler warnings. 34 | * 35 | * X-1.1 Camiel Vanderhoeven 12-JAN-2008 36 | * Initial version in CVS. 37 | **/ 38 | #if !defined(__SCSIDEVICE__H__) 39 | #define __SCSIDEVICE__H__ 40 | 41 | /** 42 | * \brief Base class for emulated SCSI devices. 43 | * 44 | * Connects to one or more SCSI busses (class CSCSIBus) together; derived 45 | * SCSI devices are disks and controllers. 46 | **/ 47 | class CSCSIDevice 48 | { 49 | public: 50 | CSCSIDevice(void); 51 | virtual ~CSCSIDevice(void); 52 | 53 | void scsi_register(int busno, class CSCSIBus* with, int target); 54 | 55 | bool scsi_arbitrate(int bus); 56 | bool scsi_select(int bus, int target); 57 | virtual void scsi_select_me(int bus); 58 | void scsi_set_phase(int bus, int phase); 59 | int scsi_get_phase(int bus); 60 | void scsi_free(int bus); 61 | 62 | virtual size_t scsi_expected_xfer_me(int bus); 63 | size_t scsi_expected_xfer(int bus); 64 | 65 | virtual void* scsi_xfer_ptr_me(int bus, size_t bytes); 66 | void* scsi_xfer_ptr(int bus, size_t bytes); 67 | 68 | virtual void scsi_xfer_done_me(int bus); 69 | void scsi_xfer_done(int bus); 70 | protected: 71 | class CSCSIBus* scsi_bus[10]; /**< SCSI busses this device connects to. Disks 72 | connect to 1 bus only, controllers can have 73 | several SCSI busses. **/ 74 | int scsi_initiator_id[10]; /**< Main SCSI id of this device on each of the busses. **/ 75 | }; 76 | #endif 77 | -------------------------------------------------------------------------------- /src/ShrinkingChoiceQuestion.h: -------------------------------------------------------------------------------- 1 | /* ES40 emulator. 2 | * Copyright (C) 2007-2008 by the ES40 Emulator Project 3 | * 4 | * WWW : http://sourceforge.net/projects/es40 5 | * E-mail : camiel@camicom.com 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2 10 | * of the License, or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | * 21 | * Although this is not required, the author would appreciate being notified of, 22 | * and receiving any modifications you may make to the source code that might serve 23 | * the general public. 24 | */ 25 | 26 | /** 27 | * \file 28 | * Configuration file creator. 29 | * 30 | * $Id$ 31 | * 32 | * X-1.1 Camiel Vanderhoeven 28-MAR-2008 33 | * File created. 34 | **/ 35 | 36 | /** 37 | * Question class implementing a "Shrinking Choice" question. 38 | * 39 | * A shrinking choice question is a multiple choice question 40 | * where each answer given is removed from the list of valid 41 | * answers. 42 | **/ 43 | class ShrinkingChoiceQuestion: public MultipleChoiceQuestion 44 | { 45 | /** 46 | * Overridden to remove the answer that was given from the 47 | * allowed answer set. 48 | **/ 49 | virtual void haveChosen(string choice) 50 | { 51 | dropChoice(choice); 52 | } 53 | }; 54 | -------------------------------------------------------------------------------- /src/StdAfx.cpp: -------------------------------------------------------------------------------- 1 | /* ES40 emulator. 2 | * Copyright (C) 2007 by Camiel Vanderhoeven 3 | * 4 | * Website: www.camicom.com 5 | * E-mail : camiel@camicom.com 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2 10 | * of the License, or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | * 21 | * Although this is not required, the author would appreciate being notified of, 22 | * and receiving any modifications you may make to the source code that might serve 23 | * the general public. 24 | * 25 | * stdafx.cpp : source file that includes just the standard includes 26 | * AlphaSim.pch will be the pre-compiled header 27 | * stdafx.obj will contain the pre-compiled type information 28 | */ 29 | 30 | /** 31 | * \file 32 | * Source file that includes just the standard includes. 33 | * AlphaSim.pch will be the pre-compiled header. 34 | * stdafx.obj will contain the pre-compiled type information. 35 | * 36 | * \author Camiel Vanderhoeven (camiel@camicom.com / http://www.camicom.com) 37 | **/ 38 | #include "StdAfx.h" 39 | 40 | // TODO: reference any additional headers you need in STDAFX.H 41 | // and not in this file 42 | -------------------------------------------------------------------------------- /src/System.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gdwnldsKSC/es40/bce8dacde45cee8f58f122be6ed24602c51cdbd8/src/System.cpp -------------------------------------------------------------------------------- /src/System.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gdwnldsKSC/es40/bce8dacde45cee8f58f122be6ed24602c51cdbd8/src/System.h -------------------------------------------------------------------------------- /src/SystemComponent.cpp: -------------------------------------------------------------------------------- 1 | /* ES40 emulator. 2 | * Copyright (C) 2007 by the ES40 Emulator Project 3 | * 4 | * WWW : http://sourceforge.net/projects/es40 5 | * E-mail : camiel@camicom.com 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2 10 | * of the License, or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | * 21 | * Although this is not required, the author would appreciate being notified of, 22 | * and receiving any modifications you may make to the source code that might serve 23 | * the general public. 24 | */ 25 | 26 | /** 27 | * \file 28 | * Contains code for the base class for devices that connect to the chipset. 29 | * 30 | * X-1.12 Camiel Vanderhoeven 13-MAR-2008 31 | * Create init(), start_threads() and stop_threads() functions. 32 | * 33 | * X-1.11 Camiel Vanderhoeven 29-DEC-2007 34 | * Fix memory-leak. 35 | * 36 | * X-1.10 Camiel Vanderhoeven 28-DEC-2007 37 | * Keep the compiler happy. 38 | * 39 | * X-1.9 Camiel Vanderhoeven 17-DEC-2007 40 | * SaveState file format 2.1 41 | * 42 | * X-1.8 Camiel Vanderhoeven 10-DEC-2007 43 | * Use configurator. 44 | * 45 | * X-1.7 Camiel Vanderhoeven 30-MAR-2007 46 | * Added old changelog comments. 47 | * 48 | * X-1.6 Brian Wheeler 13-FEB-2007 49 | * Formatting. 50 | * 51 | * X-1.5 Camiel Vanderhoeven 12-FEB-2007 52 | * Added comments. 53 | * 54 | * X-1.4 Camiel Vanderhoeven 9-FEB-2007 55 | * Added comments. 56 | * 57 | * X-1.3 Brian Wheeler 3-FEB-2007 58 | * Formatting. 59 | * 60 | * X-1.2 Brian Wheeler 3-FEB-2007 61 | * Includes are now case-correct (necessary on Linux) 62 | * 63 | * X-1.1 Camiel Vanderhoeven 19-JAN-2007 64 | * Initial version in CVS. 65 | * 66 | * \author Camiel Vanderhoeven (camiel@camicom.com / http://www.camicom.com) 67 | **/ 68 | #include "StdAfx.h" 69 | #include "SystemComponent.h" 70 | #include "System.h" 71 | 72 | /** 73 | * Constructor. 74 | **/ 75 | CSystemComponent::CSystemComponent(CConfigurator* cfg, CSystem* system) 76 | { 77 | char* a; 78 | char* b; 79 | 80 | system->RegisterComponent(this); 81 | cSystem = system; 82 | myCfg = cfg; 83 | 84 | a = myCfg->get_myName(); 85 | b = myCfg->get_myValue(); 86 | 87 | CHECK_ALLOCATION(devid_string = (char*) malloc(strlen(a) + strlen(b) + 3)); 88 | sprintf(devid_string, "%s(%s)", a, b); 89 | } 90 | 91 | /** 92 | * destructor. 93 | **/ 94 | CSystemComponent::~CSystemComponent() 95 | { 96 | free(devid_string); 97 | devid_string = nullptr; 98 | } 99 | -------------------------------------------------------------------------------- /src/VGA.cpp: -------------------------------------------------------------------------------- 1 | /* ES40 emulator. 2 | * Copyright (C) 2007-2008 by the ES40 Emulator Project 3 | * 4 | * WWW : http://sourceforge.net/projects/es40 5 | * E-mail : camiel@camicom.com 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2 10 | * of the License, or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | * 21 | * Although this is not required, the author would appreciate being notified of, 22 | * and receiving any modifications you may make to the source code that might serve 23 | * the general public. 24 | */ 25 | 26 | /** 27 | * \file 28 | * Contains the code for the VGA base class. 29 | * 30 | * $Id$ 31 | * 32 | * X-1.6 Camiel Vanderhoeven 24-MAR-2008 33 | * Added comments. 34 | * 35 | * X-1.5 Camiel Vanderhoeven 14-MAR-2008 36 | * Formatting. 37 | * 38 | * X-1.4 Camiel Vanderhoeven 14-MAR-2008 39 | * 1. More meaningful exceptions replace throwing (int) 1. 40 | * 2. U64 macro replaces X64 macro. 41 | * 42 | * X-1.3 Brian Wheeler 27-FEB-2008 43 | * Avoid compiler warnings. 44 | * 45 | * X-1.2 Camiel Vanderhoeven 28-DEC-2007 46 | * Throw exceptions rather than just exiting when errors occur. 47 | * 48 | * X-1.1 Camiel Vanderhoeven 10-DEC-2007 49 | * Initial version in CVS. 50 | **/ 51 | #include "StdAfx.h" 52 | #include "VGA.h" 53 | 54 | /** 55 | * Constructor. 56 | * 57 | * Checks if more than one VGA card is present. If so, throws a failure. 58 | **/ 59 | CVGA::CVGA(class CConfigurator* cfg, class CSystem* c, int pcibus, int pcidev) : CPCIDevice(cfg, c, pcibus, pcidev) 60 | { 61 | if(theVGA != 0) 62 | FAILURE(Configuration, "More than one VGA"); 63 | theVGA = this; 64 | } 65 | 66 | /** 67 | * Destructor. 68 | **/ 69 | CVGA::~CVGA(void) 70 | { } 71 | 72 | /** 73 | * Variable pointer to the one and only VGA card. 74 | **/ 75 | CVGA* theVGA = 0; 76 | -------------------------------------------------------------------------------- /src/VGA.h: -------------------------------------------------------------------------------- 1 | /* ES40 emulator. 2 | * Copyright (C) 2007-2008 by the ES40 Emulator Project 3 | * 4 | * WWW : http://sourceforge.net/projects/es40 5 | * E-mail : camiel@camicom.com 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2 10 | * of the License, or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | * 21 | * Although this is not required, the author would appreciate being notified of, 22 | * and receiving any modifications you may make to the source code that might serve 23 | * the general public. 24 | */ 25 | 26 | /** 27 | * \file 28 | * Contains the definitions for the VGA base class. 29 | * 30 | * $Id$ 31 | * 32 | * X-1.4 Camiel Vanderhoeven 20-JAN-2008 33 | * Added X11 GUI. 34 | * 35 | * X-1.3 Camiel Vanderhoeven 02-JAN-2008 36 | * Comments. 37 | * 38 | * X-1.2 Brian Wheeler 10-DEC-2007 39 | * Made include's case-correct. 40 | * 41 | * X-1.1 Camiel Vanderhoeven 10-DEC-2007 42 | * Initial version in CVS. 43 | **/ 44 | #if !defined(__VGA_H__) 45 | #define __VGA_H__ 46 | 47 | #include "PCIDevice.h" 48 | 49 | /** 50 | * \brief Abstract base class for PCI VGA cards. 51 | **/ 52 | class CVGA : public CPCIDevice 53 | { 54 | public: 55 | CVGA(class CConfigurator* cfg, class CSystem* c, int pcibus, int pcidev); 56 | ~ CVGA(void); 57 | 58 | virtual u8 get_actl_palette_idx(u8 index) = 0; 59 | virtual void redraw_area(unsigned x0, unsigned y0, unsigned width, 60 | unsigned height) = 0; 61 | }; 62 | 63 | extern CVGA* theVGA; 64 | #endif 65 | -------------------------------------------------------------------------------- /src/VS2022/es40-cfg.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | Source Files 23 | 24 | 25 | 26 | 27 | Header Files 28 | 29 | 30 | Header Files 31 | 32 | 33 | Header Files 34 | 35 | 36 | Header Files 37 | 38 | 39 | Header Files 40 | 41 | 42 | Header Files 43 | 44 | 45 | -------------------------------------------------------------------------------- /src/base/Bugcheck.cpp: -------------------------------------------------------------------------------- 1 | /* ES40 emulator. 2 | * Copyright (C) 2007-2008 by the ES40 Emulator Project 3 | * 4 | * WWW : http://www.es40.org 5 | * E-mail : camiel@es40.org 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2 10 | * of the License, or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | * 21 | * Although this is not required, the author would appreciate being notified of, 22 | * and receiving any modifications you may make to the source code that might serve 23 | * the general public. 24 | * 25 | * Parts of this file based upon the Poco C++ Libraries, which is Copyright (C) 26 | * 2004-2006, Applied Informatics Software Engineering GmbH. and Contributors. 27 | */ 28 | 29 | /** 30 | * $Id$ 31 | * 32 | * X-1.1 Camiel Vanderhoeven 31-MAY-2008 33 | * Initial version for ES40 emulator. 34 | **/ 35 | 36 | // 37 | // Bugcheck.cpp 38 | // 39 | // $Id$ 40 | // 41 | // Library: Foundation 42 | // Package: Core 43 | // Module: Bugcheck 44 | // 45 | // Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. 46 | // and Contributors. 47 | // 48 | // Permission is hereby granted, free of charge, to any person or organization 49 | // obtaining a copy of the software and accompanying documentation covered by 50 | // this license (the "Software") to use, reproduce, display, distribute, 51 | // execute, and transmit the Software, and to prepare derivative works of the 52 | // Software, and to permit third-parties to whom the Software is furnished to 53 | // do so, all subject to the following: 54 | // 55 | // The copyright notices in the Software and this entire statement, including 56 | // the above license grant, this restriction and the following disclaimer, 57 | // must be included in all copies of the Software, in whole or in part, and 58 | // all derivative works of the Software, unless such copies or derivative 59 | // works are solely in the form of machine-executable object code generated by 60 | // a source language processor. 61 | // 62 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 63 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 64 | // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT 65 | // SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE 66 | // FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, 67 | // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 68 | // DEALINGS IN THE SOFTWARE. 69 | // 70 | 71 | 72 | #include "Bugcheck.h" 73 | #include "Exception.h" 74 | #include 75 | 76 | void CBugcheck::assertion(const char* cond, const char* file, int line) 77 | { 78 | throw CAssertionViolationException(what(cond, file, line)); 79 | } 80 | 81 | void CBugcheck::nullPointer(const char* ptr, const char* file, int line) 82 | { 83 | throw CNullPointerException(what(ptr, file, line)); 84 | } 85 | 86 | void CBugcheck::bugcheck(const char* file, int line) 87 | { 88 | throw CBugcheckException(what(0, file, line)); 89 | } 90 | 91 | void CBugcheck::bugcheck(const char* msg, const char* file, int line) 92 | { 93 | std::string m("Bugcheck"); 94 | if (msg) 95 | { 96 | m.append(": "); 97 | m.append(msg); 98 | } 99 | throw CBugcheckException(what(msg, file, line)); 100 | } 101 | 102 | void CBugcheck::debugger(const char* file, int line) 103 | { 104 | //Debugger::enter(file, line); 105 | } 106 | 107 | 108 | void CBugcheck::debugger(const char* msg, const char* file, int line) 109 | { 110 | //Debugger::enter(msg, file, line); 111 | } 112 | 113 | std::string CBugcheck::what(const char* msg, const char* file, int line) 114 | { 115 | std::ostringstream str; 116 | if (msg) str << msg << " "; 117 | str << "in file \"" << file << "\", line " << line; 118 | return str.str(); 119 | } 120 | -------------------------------------------------------------------------------- /src/base/Event.cpp: -------------------------------------------------------------------------------- 1 | /* ES40 emulator. 2 | * Copyright (C) 2007-2008 by the ES40 Emulator Project 3 | * 4 | * WWW : http://www.es40.org 5 | * E-mail : camiel@es40.org 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2 10 | * of the License, or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | * 21 | * Although this is not required, the author would appreciate being notified of, 22 | * and receiving any modifications you may make to the source code that might serve 23 | * the general public. 24 | * 25 | * Parts of this file based upon the Poco C++ Libraries, which is Copyright (C) 26 | * 2004-2006, Applied Informatics Software Engineering GmbH. and Contributors. 27 | */ 28 | 29 | /** 30 | * $Id$ 31 | * 32 | * X-1.1 Camiel Vanderhoeven 31-MAY-2008 33 | * Initial version for ES40 emulator. 34 | **/ 35 | 36 | // 37 | // Event.cpp 38 | // 39 | // $Id$ 40 | // 41 | // Library: Foundation 42 | // Package: Threading 43 | // Module: Event 44 | // 45 | // Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. 46 | // and Contributors. 47 | // 48 | // Permission is hereby granted, free of charge, to any person or organization 49 | // obtaining a copy of the software and accompanying documentation covered by 50 | // this license (the "Software") to use, reproduce, display, distribute, 51 | // execute, and transmit the Software, and to prepare derivative works of the 52 | // Software, and to permit third-parties to whom the Software is furnished to 53 | // do so, all subject to the following: 54 | // 55 | // The copyright notices in the Software and this entire statement, including 56 | // the above license grant, this restriction and the following disclaimer, 57 | // must be included in all copies of the Software, in whole or in part, and 58 | // all derivative works of the Software, unless such copies or derivative 59 | // works are solely in the form of machine-executable object code generated by 60 | // a source language processor. 61 | // 62 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 63 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 64 | // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT 65 | // SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE 66 | // FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, 67 | // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 68 | // DEALINGS IN THE SOFTWARE. 69 | // 70 | 71 | 72 | #include "Event.h" 73 | 74 | 75 | #if defined(POCO_OS_FAMILY_WINDOWS) 76 | #include "Event_WIN32.cpp" 77 | #else 78 | #include "Event_POSIX.cpp" 79 | #endif 80 | 81 | CEvent::CEvent(bool autoReset): CEventImpl(autoReset) 82 | { 83 | } 84 | 85 | 86 | CEvent::~CEvent() 87 | { 88 | } 89 | -------------------------------------------------------------------------------- /src/base/Event_POSIX.h: -------------------------------------------------------------------------------- 1 | /* ES40 emulator. 2 | * Copyright (C) 2007-2008 by the ES40 Emulator Project 3 | * 4 | * WWW : http://www.es40.org 5 | * E-mail : camiel@es40.org 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2 10 | * of the License, or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | * 21 | * Although this is not required, the author would appreciate being notified of, 22 | * and receiving any modifications you may make to the source code that might serve 23 | * the general public. 24 | * 25 | * Parts of this file based upon the Poco C++ Libraries, which is Copyright (C) 26 | * 2004-2006, Applied Informatics Software Engineering GmbH. and Contributors. 27 | */ 28 | 29 | /** 30 | * $Id$ 31 | * 32 | * X-1.1 Camiel Vanderhoeven 31-MAY-2008 33 | * Initial version for ES40 emulator. 34 | **/ 35 | 36 | // 37 | // Event_POSIX.h 38 | // 39 | // $Id$ 40 | // 41 | // Library: Foundation 42 | // Package: Threading 43 | // Module: Event 44 | // 45 | // Definition of the EventImpl class for POSIX Threads. 46 | // 47 | // Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. 48 | // and Contributors. 49 | // 50 | // Permission is hereby granted, free of charge, to any person or organization 51 | // obtaining a copy of the software and accompanying documentation covered by 52 | // this license (the "Software") to use, reproduce, display, distribute, 53 | // execute, and transmit the Software, and to prepare derivative works of the 54 | // Software, and to permit third-parties to whom the Software is furnished to 55 | // do so, all subject to the following: 56 | // 57 | // The copyright notices in the Software and this entire statement, including 58 | // the above license grant, this restriction and the following disclaimer, 59 | // must be included in all copies of the Software, in whole or in part, and 60 | // all derivative works of the Software, unless such copies or derivative 61 | // works are solely in the form of machine-executable object code generated by 62 | // a source language processor. 63 | // 64 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 65 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 66 | // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT 67 | // SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE 68 | // FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, 69 | // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 70 | // DEALINGS IN THE SOFTWARE. 71 | // 72 | 73 | 74 | #ifndef Foundation_Event_POSIX_INCLUDED 75 | #define Foundation_Event_POSIX_INCLUDED 76 | 77 | 78 | #include "Foundation.h" 79 | #include "Exception.h" 80 | #include 81 | #include 82 | 83 | 84 | class CEventImpl 85 | { 86 | protected: 87 | CEventImpl(bool autoReset); 88 | ~CEventImpl(); 89 | void setImpl(); 90 | void waitImpl(); 91 | bool waitImpl(long milliseconds); 92 | void resetImpl(); 93 | 94 | private: 95 | bool _auto; 96 | volatile bool _state; 97 | pthread_mutex_t _mutex; 98 | pthread_cond_t _cond; 99 | }; 100 | 101 | 102 | // 103 | // inlines 104 | // 105 | inline void CEventImpl::setImpl() 106 | { 107 | if (pthread_mutex_lock(&_mutex)) 108 | throw CSystemException("cannot signal event (lock)"); 109 | _state = true; 110 | if (pthread_cond_broadcast(&_cond)) 111 | { 112 | pthread_mutex_unlock(&_mutex); 113 | throw CSystemException("cannot signal event"); 114 | } 115 | pthread_mutex_unlock(&_mutex); 116 | } 117 | 118 | 119 | inline void CEventImpl::resetImpl() 120 | { 121 | if (pthread_mutex_lock(&_mutex)) 122 | throw CSystemException("cannot reset event"); 123 | _state = false; 124 | pthread_mutex_unlock(&_mutex); 125 | } 126 | 127 | #endif // Foundation_Event_POSIX_INCLUDED 128 | -------------------------------------------------------------------------------- /src/base/Event_WIN32.cpp: -------------------------------------------------------------------------------- 1 | /* ES40 emulator. 2 | * Copyright (C) 2007-2008 by the ES40 Emulator Project 3 | * 4 | * WWW : http://www.es40.org 5 | * E-mail : camiel@es40.org 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2 10 | * of the License, or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | * 21 | * Although this is not required, the author would appreciate being notified of, 22 | * and receiving any modifications you may make to the source code that might serve 23 | * the general public. 24 | * 25 | * Parts of this file based upon the Poco C++ Libraries, which is Copyright (C) 26 | * 2004-2006, Applied Informatics Software Engineering GmbH. and Contributors. 27 | */ 28 | 29 | /** 30 | * $Id$ 31 | * 32 | * X-1.1 Camiel Vanderhoeven 31-MAY-2008 33 | * Initial version for ES40 emulator. 34 | **/ 35 | 36 | // 37 | // Event_WIN32.cpp 38 | // 39 | // $Id$ 40 | // 41 | // Library: Foundation 42 | // Package: Threading 43 | // Module: Event 44 | // 45 | // Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. 46 | // and Contributors. 47 | // 48 | // Permission is hereby granted, free of charge, to any person or organization 49 | // obtaining a copy of the software and accompanying documentation covered by 50 | // this license (the "Software") to use, reproduce, display, distribute, 51 | // execute, and transmit the Software, and to prepare derivative works of the 52 | // Software, and to permit third-parties to whom the Software is furnished to 53 | // do so, all subject to the following: 54 | // 55 | // The copyright notices in the Software and this entire statement, including 56 | // the above license grant, this restriction and the following disclaimer, 57 | // must be included in all copies of the Software, in whole or in part, and 58 | // all derivative works of the Software, unless such copies or derivative 59 | // works are solely in the form of machine-executable object code generated by 60 | // a source language processor. 61 | // 62 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 63 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 64 | // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT 65 | // SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE 66 | // FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, 67 | // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 68 | // DEALINGS IN THE SOFTWARE. 69 | // 70 | 71 | 72 | #include "Event_WIN32.h" 73 | 74 | 75 | CEventImpl::CEventImpl(bool autoReset) 76 | { 77 | _event = CreateEventW(NULL, autoReset ? FALSE : TRUE, FALSE, NULL); 78 | if (!_event) 79 | throw CSystemException("cannot create event"); 80 | } 81 | 82 | 83 | CEventImpl::~CEventImpl() 84 | { 85 | CloseHandle(_event); 86 | } 87 | 88 | 89 | void CEventImpl::waitImpl() 90 | { 91 | switch (WaitForSingleObject(_event, INFINITE)) 92 | { 93 | case WAIT_OBJECT_0: 94 | return; 95 | default: 96 | throw CSystemException("wait for event failed"); 97 | } 98 | } 99 | 100 | 101 | bool CEventImpl::waitImpl(long milliseconds) 102 | { 103 | switch (WaitForSingleObject(_event, milliseconds + 1)) 104 | { 105 | case WAIT_TIMEOUT: 106 | return false; 107 | case WAIT_OBJECT_0: 108 | return true; 109 | default: 110 | throw CSystemException("wait for event failed"); 111 | } 112 | } 113 | 114 | -------------------------------------------------------------------------------- /src/base/Event_WIN32.h: -------------------------------------------------------------------------------- 1 | /* ES40 emulator. 2 | * Copyright (C) 2007-2008 by the ES40 Emulator Project 3 | * 4 | * WWW : http://www.es40.org 5 | * E-mail : camiel@es40.org 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2 10 | * of the License, or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | * 21 | * Although this is not required, the author would appreciate being notified of, 22 | * and receiving any modifications you may make to the source code that might serve 23 | * the general public. 24 | * 25 | * Parts of this file based upon the Poco C++ Libraries, which is Copyright (C) 26 | * 2004-2006, Applied Informatics Software Engineering GmbH. and Contributors. 27 | */ 28 | 29 | /** 30 | * $Id$ 31 | * 32 | * X-1.1 Camiel Vanderhoeven 31-MAY-2008 33 | * Initial version for ES40 emulator. 34 | **/ 35 | 36 | // 37 | // Event_WIN32.h 38 | // 39 | // $Id$ 40 | // 41 | // Library: Foundation 42 | // Package: Threading 43 | // Module: Event 44 | // 45 | // Definition of the EventImpl class for WIN32. 46 | // 47 | // Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. 48 | // and Contributors. 49 | // 50 | // Permission is hereby granted, free of charge, to any person or organization 51 | // obtaining a copy of the software and accompanying documentation covered by 52 | // this license (the "Software") to use, reproduce, display, distribute, 53 | // execute, and transmit the Software, and to prepare derivative works of the 54 | // Software, and to permit third-parties to whom the Software is furnished to 55 | // do so, all subject to the following: 56 | // 57 | // The copyright notices in the Software and this entire statement, including 58 | // the above license grant, this restriction and the following disclaimer, 59 | // must be included in all copies of the Software, in whole or in part, and 60 | // all derivative works of the Software, unless such copies or derivative 61 | // works are solely in the form of machine-executable object code generated by 62 | // a source language processor. 63 | // 64 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 65 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 66 | // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT 67 | // SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE 68 | // FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, 69 | // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 70 | // DEALINGS IN THE SOFTWARE. 71 | // 72 | 73 | 74 | #ifndef Foundation_Event_WIN32_INCLUDED 75 | #define Foundation_Event_WIN32_INCLUDED 76 | 77 | 78 | #include "Foundation.h" 79 | #include "Exception.h" 80 | #include "UnWindows.h" 81 | 82 | 83 | class CEventImpl 84 | { 85 | protected: 86 | CEventImpl(bool autoReset = false); 87 | ~CEventImpl(); 88 | void setImpl(); 89 | void waitImpl(); 90 | bool waitImpl(long milliseconds); 91 | void resetImpl(); 92 | 93 | private: 94 | HANDLE _event; 95 | }; 96 | 97 | 98 | // 99 | // inlines 100 | // 101 | inline void CEventImpl::setImpl() 102 | { 103 | if (!SetEvent(_event)) 104 | { 105 | throw CSystemException("cannot signal event"); 106 | } 107 | } 108 | 109 | 110 | inline void CEventImpl::resetImpl() 111 | { 112 | if (!ResetEvent(_event)) 113 | { 114 | throw CSystemException("cannot reset event"); 115 | } 116 | } 117 | 118 | #endif // Foundation_Event_WIN32_INCLUDED 119 | -------------------------------------------------------------------------------- /src/base/Foundation.h: -------------------------------------------------------------------------------- 1 | /* ES40 emulator. 2 | * Copyright (C) 2007-2008 by the ES40 Emulator Project 3 | * 4 | * WWW : http://www.es40.org 5 | * E-mail : camiel@es40.org 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2 10 | * of the License, or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | * 21 | * Although this is not required, the author would appreciate being notified of, 22 | * and receiving any modifications you may make to the source code that might serve 23 | * the general public. 24 | * 25 | * Parts of this file based upon the Poco C++ Libraries, which is Copyright (C) 26 | * 2004-2006, Applied Informatics Software Engineering GmbH. and Contributors. 27 | */ 28 | 29 | /** 30 | * $Id$ 31 | * 32 | * X-1.1 Camiel Vanderhoeven 31-MAY-2008 33 | * Initial version for ES40 emulator. 34 | **/ 35 | 36 | // 37 | // Foundation.h 38 | // 39 | // $Id$ 40 | // 41 | // Library: Foundation 42 | // Package: Core 43 | // Module: Foundation 44 | // 45 | // Basic definitions for the POCO Foundation library. 46 | // This file must be the first file included by every other Foundation 47 | // header file. 48 | // 49 | // Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. 50 | // and Contributors. 51 | // 52 | // Permission is hereby granted, free of charge, to any person or organization 53 | // obtaining a copy of the software and accompanying documentation covered by 54 | // this license (the "Software") to use, reproduce, display, distribute, 55 | // execute, and transmit the Software, and to prepare derivative works of the 56 | // Software, and to permit third-parties to whom the Software is furnished to 57 | // do so, all subject to the following: 58 | // 59 | // The copyright notices in the Software and this entire statement, including 60 | // the above license grant, this restriction and the following disclaimer, 61 | // must be included in all copies of the Software, in whole or in part, and 62 | // all derivative works of the Software, unless such copies or derivative 63 | // works are solely in the form of machine-executable object code generated by 64 | // a source language processor. 65 | // 66 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 67 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 68 | // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT 69 | // SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE 70 | // FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, 71 | // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 72 | // DEALINGS IN THE SOFTWARE. 73 | // 74 | 75 | 76 | #ifndef Foundation_Foundation_INCLUDED 77 | #define Foundation_Foundation_INCLUDED 78 | 79 | 80 | // 81 | // Include library configuration 82 | // 83 | //CAVA #include "Config.h" 84 | 85 | // 86 | // Include platform-specific definitions 87 | // 88 | #include "Platform.h" 89 | #if defined(_WIN32) 90 | #include "Platform_WIN32.h" 91 | #elif defined(__VMS) 92 | #include "Platform_VMS.h" 93 | #elif defined(POCO_OS_FAMILY_UNIX) 94 | #include "Platform_POSIX.h" 95 | #endif 96 | 97 | 98 | // 99 | // POCO_JOIN 100 | // 101 | // The following piece of macro magic joins the two 102 | // arguments together, even when one of the arguments is 103 | // itself a macro (see 16.3.1 in C++ standard). The key 104 | // is that macro expansion of macro arguments does not 105 | // occur in POCO_DO_JOIN2 but does in POCO_DO_JOIN. 106 | // 107 | #define POCO_JOIN(X, Y) POCO_DO_JOIN(X, Y) 108 | #define POCO_DO_JOIN(X, Y) POCO_DO_JOIN2(X, Y) 109 | #define POCO_DO_JOIN2(X, Y) X##Y 110 | 111 | 112 | // 113 | // Pull in basic definitions 114 | // 115 | #include "Bugcheck.h" 116 | #include "Types.h" 117 | #include 118 | #include 119 | 120 | #endif // Foundation_Foundation_INCLUDED 121 | -------------------------------------------------------------------------------- /src/base/Mutex.cpp: -------------------------------------------------------------------------------- 1 | /* ES40 emulator. 2 | * Copyright (C) 2007-2008 by the ES40 Emulator Project 3 | * 4 | * WWW : http://www.es40.org 5 | * E-mail : camiel@es40.org 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2 10 | * of the License, or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | * 21 | * Although this is not required, the author would appreciate being notified of, 22 | * and receiving any modifications you may make to the source code that might serve 23 | * the general public. 24 | * 25 | * Parts of this file based upon the Poco C++ Libraries, which is Copyright (C) 26 | * 2004-2006, Applied Informatics Software Engineering GmbH. and Contributors. 27 | */ 28 | 29 | /** 30 | * $Id$ 31 | * 32 | * X-1.2 Caolan McNamara 12-JUN-2008 33 | * Fixes to build on Fedora 9 / gcc 4.3.0. 34 | * 35 | * X-1.1 Camiel Vanderhoeven 31-MAY-2008 36 | * Initial version for ES40 emulator. 37 | **/ 38 | 39 | // 40 | // Mutex.cpp 41 | // 42 | // $Id$ 43 | // 44 | // Library: Foundation 45 | // Package: Threading 46 | // Module: Mutex 47 | // 48 | // Copyright (c) 2004-2008, Applied Informatics Software Engineering GmbH. 49 | // and Contributors. 50 | // 51 | // Permission is hereby granted, free of charge, to any person or organization 52 | // obtaining a copy of the software and accompanying documentation covered by 53 | // this license (the "Software") to use, reproduce, display, distribute, 54 | // execute, and transmit the Software, and to prepare derivative works of the 55 | // Software, and to permit third-parties to whom the Software is furnished to 56 | // do so, all subject to the following: 57 | // 58 | // The copyright notices in the Software and this entire statement, including 59 | // the above license grant, this restriction and the following disclaimer, 60 | // must be included in all copies of the Software, in whole or in part, and 61 | // all derivative works of the Software, unless such copies or derivative 62 | // works are solely in the form of machine-executable object code generated by 63 | // a source language processor. 64 | // 65 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 66 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 67 | // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT 68 | // SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE 69 | // FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, 70 | // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 71 | // DEALINGS IN THE SOFTWARE. 72 | // 73 | 74 | #include "Mutex.h" 75 | #include 76 | 77 | #if defined(POCO_OS_FAMILY_WINDOWS) 78 | #include "Mutex_WIN32.cpp" 79 | #else 80 | #include "Mutex_POSIX.cpp" 81 | #endif 82 | 83 | CMutex::CMutex() 84 | { 85 | lockName = strdup("anon"); 86 | } 87 | 88 | CMutex::CMutex(const char* lName) 89 | { 90 | lockName = strdup(lName); 91 | } 92 | 93 | 94 | CMutex::~CMutex() 95 | { 96 | free(lockName); 97 | } 98 | 99 | CFastMutex::CFastMutex() 100 | { 101 | lockName = strdup("anon"); 102 | } 103 | 104 | CFastMutex::CFastMutex(const char* lName) 105 | { 106 | lockName = strdup(lName); 107 | } 108 | 109 | 110 | CFastMutex::~CFastMutex() 111 | { 112 | free(lockName); 113 | } 114 | -------------------------------------------------------------------------------- /src/base/Mutex_POSIX.h: -------------------------------------------------------------------------------- 1 | /* ES40 emulator. 2 | * Copyright (C) 2007-2008 by the ES40 Emulator Project 3 | * 4 | * WWW : http://www.es40.org 5 | * E-mail : camiel@es40.org 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2 10 | * of the License, or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | * 21 | * Although this is not required, the author would appreciate being notified of, 22 | * and receiving any modifications you may make to the source code that might serve 23 | * the general public. 24 | * 25 | * Parts of this file based upon the Poco C++ Libraries, which is Copyright (C) 26 | * 2004-2006, Applied Informatics Software Engineering GmbH. and Contributors. 27 | */ 28 | 29 | /** 30 | * $Id$ 31 | * 32 | * X-1.1 Camiel Vanderhoeven 31-MAY-2008 33 | * Initial version for ES40 emulator. 34 | **/ 35 | 36 | // 37 | // Mutex_POSIX.h 38 | // 39 | // $Id$ 40 | // 41 | // Library: Foundation 42 | // Package: Threading 43 | // Module: Mutex 44 | // 45 | // Definition of the MutexImpl and FastMutexImpl classes for POSIX Threads. 46 | // 47 | // Copyright (c) 2004-2008, Applied Informatics Software Engineering GmbH. 48 | // and Contributors. 49 | // 50 | // Permission is hereby granted, free of charge, to any person or organization 51 | // obtaining a copy of the software and accompanying documentation covered by 52 | // this license (the "Software") to use, reproduce, display, distribute, 53 | // execute, and transmit the Software, and to prepare derivative works of the 54 | // Software, and to permit third-parties to whom the Software is furnished to 55 | // do so, all subject to the following: 56 | // 57 | // The copyright notices in the Software and this entire statement, including 58 | // the above license grant, this restriction and the following disclaimer, 59 | // must be included in all copies of the Software, in whole or in part, and 60 | // all derivative works of the Software, unless such copies or derivative 61 | // works are solely in the form of machine-executable object code generated by 62 | // a source language processor. 63 | // 64 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 65 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 66 | // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT 67 | // SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE 68 | // FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, 69 | // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 70 | // DEALINGS IN THE SOFTWARE. 71 | // 72 | 73 | 74 | #ifndef Foundation_Mutex_POSIX_INCLUDED 75 | #define Foundation_Mutex_POSIX_INCLUDED 76 | 77 | 78 | #include "Foundation.h" 79 | #include "Exception.h" 80 | #include 81 | #include 82 | 83 | class CMutexImpl 84 | { 85 | protected: 86 | CMutexImpl(); 87 | CMutexImpl(bool fast); 88 | ~CMutexImpl(); 89 | void lockImpl(); 90 | bool tryLockImpl(); 91 | bool tryLockImpl(long milliseconds); 92 | void unlockImpl(); 93 | 94 | private: 95 | pthread_mutex_t _mutex; 96 | }; 97 | 98 | 99 | class CFastMutexImpl: public CMutexImpl 100 | { 101 | protected: 102 | CFastMutexImpl(); 103 | ~CFastMutexImpl(); 104 | }; 105 | 106 | 107 | // 108 | // inlines 109 | // 110 | inline void CMutexImpl::lockImpl() 111 | { 112 | if (pthread_mutex_lock(&_mutex)) 113 | throw CSystemException("cannot lock mutex"); 114 | } 115 | 116 | 117 | inline bool CMutexImpl::tryLockImpl() 118 | { 119 | int rc = pthread_mutex_trylock(&_mutex); 120 | if (rc == 0) 121 | return true; 122 | else if (rc == EBUSY) 123 | return false; 124 | else 125 | throw CSystemException("cannot lock mutex"); 126 | 127 | } 128 | 129 | 130 | inline void CMutexImpl::unlockImpl() 131 | { 132 | if (pthread_mutex_unlock(&_mutex)) 133 | throw CSystemException("cannot unlock mutex"); 134 | } 135 | 136 | #endif // Foundation_Mutex_POSIX_INCLUDED 137 | -------------------------------------------------------------------------------- /src/base/Mutex_WIN32.cpp: -------------------------------------------------------------------------------- 1 | /* ES40 emulator. 2 | * Copyright (C) 2007-2008 by the ES40 Emulator Project 3 | * 4 | * WWW : http://www.es40.org 5 | * E-mail : camiel@es40.org 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2 10 | * of the License, or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | * 21 | * Although this is not required, the author would appreciate being notified of, 22 | * and receiving any modifications you may make to the source code that might serve 23 | * the general public. 24 | * 25 | * Parts of this file based upon the Poco C++ Libraries, which is Copyright (C) 26 | * 2004-2006, Applied Informatics Software Engineering GmbH. and Contributors. 27 | */ 28 | 29 | /** 30 | * $Id$ 31 | * 32 | * X-1.1 Camiel Vanderhoeven 31-MAY-2008 33 | * Initial version for ES40 emulator. 34 | **/ 35 | 36 | // 37 | // Mutex_WIN32.cpp 38 | // 39 | // $Id$ 40 | // 41 | // Library: Foundation 42 | // Package: Threading 43 | // Module: Mutex 44 | // 45 | // Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. 46 | // and Contributors. 47 | // 48 | // Permission is hereby granted, free of charge, to any person or organization 49 | // obtaining a copy of the software and accompanying documentation covered by 50 | // this license (the "Software") to use, reproduce, display, distribute, 51 | // execute, and transmit the Software, and to prepare derivative works of the 52 | // Software, and to permit third-parties to whom the Software is furnished to 53 | // do so, all subject to the following: 54 | // 55 | // The copyright notices in the Software and this entire statement, including 56 | // the above license grant, this restriction and the following disclaimer, 57 | // must be included in all copies of the Software, in whole or in part, and 58 | // all derivative works of the Software, unless such copies or derivative 59 | // works are solely in the form of machine-executable object code generated by 60 | // a source language processor. 61 | // 62 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 63 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 64 | // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT 65 | // SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE 66 | // FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, 67 | // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 68 | // DEALINGS IN THE SOFTWARE. 69 | // 70 | 71 | 72 | #include "Mutex_WIN32.h" 73 | #include "Timestamp.h" 74 | 75 | CMutexImpl::CMutexImpl() 76 | { 77 | // the fct has a boolean return value under WInnNt/2000/XP but not on Win98 78 | // the return only checks if the input address of &_cs was valid, so it is safe to omit it 79 | InitializeCriticalSectionAndSpinCount(&_cs, 4000); 80 | } 81 | 82 | 83 | CMutexImpl::~CMutexImpl() 84 | { 85 | DeleteCriticalSection(&_cs); 86 | } 87 | 88 | 89 | bool CMutexImpl::tryLockImpl(long milliseconds) 90 | { 91 | const int sleepMillis = 5; 92 | CTimestamp now; 93 | CTimestamp::TimeDiff diff(CTimestamp::TimeDiff(milliseconds)*1000); 94 | do 95 | { 96 | try 97 | { 98 | if (TryEnterCriticalSection(&_cs) == TRUE) 99 | return true; 100 | } 101 | catch (...) 102 | { 103 | throw CSystemException("cannot lock mutex"); 104 | } 105 | Sleep(sleepMillis); 106 | } 107 | while (!now.isElapsed(diff)); 108 | return false; 109 | } 110 | -------------------------------------------------------------------------------- /src/base/Mutex_WIN32.h: -------------------------------------------------------------------------------- 1 | /* ES40 emulator. 2 | * Copyright (C) 2007-2008 by the ES40 Emulator Project 3 | * 4 | * WWW : http://www.es40.org 5 | * E-mail : camiel@es40.org 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2 10 | * of the License, or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | * 21 | * Although this is not required, the author would appreciate being notified of, 22 | * and receiving any modifications you may make to the source code that might serve 23 | * the general public. 24 | * 25 | * Parts of this file based upon the Poco C++ Libraries, which is Copyright (C) 26 | * 2004-2006, Applied Informatics Software Engineering GmbH. and Contributors. 27 | */ 28 | 29 | /** 30 | * $Id$ 31 | * 32 | * X-1.1 Camiel Vanderhoeven 31-MAY-2008 33 | * Initial version for ES40 emulator. 34 | **/ 35 | 36 | // 37 | // Mutex_WIN32.h 38 | // 39 | // $Id$ 40 | // 41 | // Library: Foundation 42 | // Package: Threading 43 | // Module: Mutex 44 | // 45 | // Definition of the MutexImpl and FastMutexImpl classes for WIN32. 46 | // 47 | // Copyright (c) 2004-2008, Applied Informatics Software Engineering GmbH. 48 | // and Contributors. 49 | // 50 | // Permission is hereby granted, free of charge, to any person or organization 51 | // obtaining a copy of the software and accompanying documentation covered by 52 | // this license (the "Software") to use, reproduce, display, distribute, 53 | // execute, and transmit the Software, and to prepare derivative works of the 54 | // Software, and to permit third-parties to whom the Software is furnished to 55 | // do so, all subject to the following: 56 | // 57 | // The copyright notices in the Software and this entire statement, including 58 | // the above license grant, this restriction and the following disclaimer, 59 | // must be included in all copies of the Software, in whole or in part, and 60 | // all derivative works of the Software, unless such copies or derivative 61 | // works are solely in the form of machine-executable object code generated by 62 | // a source language processor. 63 | // 64 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 65 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 66 | // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT 67 | // SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE 68 | // FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, 69 | // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 70 | // DEALINGS IN THE SOFTWARE. 71 | // 72 | 73 | 74 | #ifndef Foundation_Mutex_WIN32_INCLUDED 75 | #define Foundation_Mutex_WIN32_INCLUDED 76 | 77 | #include "Foundation.h" 78 | #include "Exception.h" 79 | #include "UnWindows.h" 80 | 81 | class CMutexImpl 82 | { 83 | protected: 84 | CMutexImpl(); 85 | ~CMutexImpl(); 86 | void lockImpl(); 87 | bool tryLockImpl(); 88 | bool tryLockImpl(long milliseconds); 89 | void unlockImpl(); 90 | 91 | private: 92 | CRITICAL_SECTION _cs; 93 | }; 94 | 95 | 96 | typedef CMutexImpl CFastMutexImpl; 97 | 98 | 99 | // 100 | // inlines 101 | // 102 | inline void CMutexImpl::lockImpl() 103 | { 104 | try 105 | { 106 | EnterCriticalSection(&_cs); 107 | } 108 | catch (...) 109 | { 110 | throw CSystemException("cannot lock mutex"); 111 | } 112 | } 113 | 114 | 115 | inline bool CMutexImpl::tryLockImpl() 116 | { 117 | try 118 | { 119 | return TryEnterCriticalSection(&_cs) == TRUE; 120 | } 121 | catch (...) 122 | { 123 | } 124 | throw CSystemException("cannot lock mutex"); 125 | } 126 | 127 | 128 | inline void CMutexImpl::unlockImpl() 129 | { 130 | LeaveCriticalSection(&_cs); 131 | } 132 | 133 | #endif // Foundation_Mutex_WIN32_INCLUDED 134 | -------------------------------------------------------------------------------- /src/base/Platform_POSIX.h: -------------------------------------------------------------------------------- 1 | /* ES40 emulator. 2 | * Copyright (C) 2007-2008 by the ES40 Emulator Project 3 | * 4 | * WWW : http://www.es40.org 5 | * E-mail : camiel@es40.org 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2 10 | * of the License, or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | * 21 | * Although this is not required, the author would appreciate being notified of, 22 | * and receiving any modifications you may make to the source code that might serve 23 | * the general public. 24 | * 25 | * Parts of this file based upon the Poco C++ Libraries, which is Copyright (C) 26 | * 2004-2006, Applied Informatics Software Engineering GmbH. and Contributors. 27 | */ 28 | 29 | /** 30 | * $Id$ 31 | * 32 | * X-1.1 Camiel Vanderhoeven 31-MAY-2008 33 | * Initial version for ES40 emulator. 34 | **/ 35 | 36 | // 37 | // Platform_POSIX.h 38 | // 39 | // $Id$ 40 | // 41 | // Library: Foundation 42 | // Package: Core 43 | // Module: Platform 44 | // 45 | // Platform and architecture identification macros 46 | // and platform-specific definitions for various POSIX platforms 47 | // 48 | // Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. 49 | // and Contributors. 50 | // 51 | // Permission is hereby granted, free of charge, to any person or organization 52 | // obtaining a copy of the software and accompanying documentation covered by 53 | // this license (the "Software") to use, reproduce, display, distribute, 54 | // execute, and transmit the Software, and to prepare derivative works of the 55 | // Software, and to permit third-parties to whom the Software is furnished to 56 | // do so, all subject to the following: 57 | // 58 | // The copyright notices in the Software and this entire statement, including 59 | // the above license grant, this restriction and the following disclaimer, 60 | // must be included in all copies of the Software, in whole or in part, and 61 | // all derivative works of the Software, unless such copies or derivative 62 | // works are solely in the form of machine-executable object code generated by 63 | // a source language processor. 64 | // 65 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 66 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 67 | // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT 68 | // SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE 69 | // FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, 70 | // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 71 | // DEALINGS IN THE SOFTWARE. 72 | // 73 | 74 | 75 | #ifndef Foundation_Platform_POSIX_INCLUDED 76 | #define Foundation_Platform_POSIX_INCLUDED 77 | 78 | 79 | // 80 | // PA-RISC based HP-UX platforms have some issues... 81 | // 82 | #if defined(hpux) || defined(_hpux) 83 | #if defined(__hppa) || defined(__hppa__) 84 | #define POCO_NO_SYS_SELECT_H 1 85 | #if defined(__HP_aCC) 86 | #define POCO_NO_TEMPLATE_ICOMPARE 1 87 | #endif 88 | #endif 89 | #endif 90 | 91 | 92 | #endif // Foundation_Platform_POSIX_INCLUDED 93 | -------------------------------------------------------------------------------- /src/base/Poco.h: -------------------------------------------------------------------------------- 1 | /* ES40 emulator. 2 | * Copyright (C) 2007-2008 by the ES40 Emulator Project 3 | * 4 | * WWW : http://www.es40.org 5 | * E-mail : camiel@es40.org 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2 10 | * of the License, or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | * 21 | * Although this is not required, the author would appreciate being notified of, 22 | * and receiving any modifications you may make to the source code that might serve 23 | * the general public. 24 | * 25 | * Parts of this file based upon the Poco C++ Libraries, which is Copyright (C) 26 | * 2004-2006, Applied Informatics Software Engineering GmbH. and Contributors. 27 | */ 28 | 29 | /** 30 | * $Id$ 31 | * 32 | * X-1.1 Camiel Vanderhoeven 31-MAY-2008 33 | * Initial version for ES40 emulator. 34 | **/ 35 | 36 | // 37 | // Poco.h 38 | // 39 | // $Id$ 40 | // 41 | // Library: Foundation 42 | // Package: Core 43 | // Module: Foundation 44 | // 45 | // Basic definitions for the POCO libraries. 46 | // 47 | // Copyright (c) 2006, Applied Informatics Software Engineering GmbH. 48 | // and Contributors. 49 | // 50 | // Permission is hereby granted, free of charge, to any person or organization 51 | // obtaining a copy of the software and accompanying documentation covered by 52 | // this license (the "Software") to use, reproduce, display, distribute, 53 | // execute, and transmit the Software, and to prepare derivative works of the 54 | // Software, and to permit third-parties to whom the Software is furnished to 55 | // do so, all subject to the following: 56 | // 57 | // The copyright notices in the Software and this entire statement, including 58 | // the above license grant, this restriction and the following disclaimer, 59 | // must be included in all copies of the Software, in whole or in part, and 60 | // all derivative works of the Software, unless such copies or derivative 61 | // works are solely in the form of machine-executable object code generated by 62 | // a source language processor. 63 | // 64 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 65 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 66 | // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT 67 | // SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE 68 | // FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, 69 | // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 70 | // DEALINGS IN THE SOFTWARE. 71 | // 72 | 73 | 74 | #ifndef Foundation_Poco_INCLUDED 75 | #define Foundation_Poco_INCLUDED 76 | 77 | 78 | #include "Foundation.h" 79 | 80 | 81 | #endif // Foundation_Poco_INCLUDED 82 | -------------------------------------------------------------------------------- /src/base/RWLock.cpp: -------------------------------------------------------------------------------- 1 | /* ES40 emulator. 2 | * Copyright (C) 2007-2008 by the ES40 Emulator Project 3 | * 4 | * WWW : http://www.es40.org 5 | * E-mail : camiel@es40.org 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2 10 | * of the License, or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | * 21 | * Although this is not required, the author would appreciate being notified of, 22 | * and receiving any modifications you may make to the source code that might serve 23 | * the general public. 24 | * 25 | * Parts of this file based upon the Poco C++ Libraries, which is Copyright (C) 26 | * 2004-2006, Applied Informatics Software Engineering GmbH. and Contributors. 27 | */ 28 | 29 | /** 30 | * $Id$ 31 | * 32 | * X-1.2 Caolan McNamara 12-JUN-2008 33 | * Fixes to build on Fedora 9 / gcc 4.3.0. 34 | * 35 | * X-1.1 Camiel Vanderhoeven 31-MAY-2008 36 | * Initial version for ES40 emulator. 37 | **/ 38 | 39 | // 40 | // RWLock.cpp 41 | // 42 | // $Id$ 43 | // 44 | // Library: Foundation 45 | // Package: Threading 46 | // Module: RWLock 47 | // 48 | // Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. 49 | // and Contributors. 50 | // 51 | // Permission is hereby granted, free of charge, to any person or organization 52 | // obtaining a copy of the software and accompanying documentation covered by 53 | // this license (the "Software") to use, reproduce, display, distribute, 54 | // execute, and transmit the Software, and to prepare derivative works of the 55 | // Software, and to permit third-parties to whom the Software is furnished to 56 | // do so, all subject to the following: 57 | // 58 | // The copyright notices in the Software and this entire statement, including 59 | // the above license grant, this restriction and the following disclaimer, 60 | // must be included in all copies of the Software, in whole or in part, and 61 | // all derivative works of the Software, unless such copies or derivative 62 | // works are solely in the form of machine-executable object code generated by 63 | // a source language processor. 64 | // 65 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 66 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 67 | // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT 68 | // SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE 69 | // FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, 70 | // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 71 | // DEALINGS IN THE SOFTWARE. 72 | // 73 | 74 | 75 | #include "RWLock.h" 76 | #include 77 | 78 | #if defined(POCO_OS_FAMILY_WINDOWS) 79 | #include "RWLock_WIN32.cpp" 80 | #else 81 | #include "RWLock_POSIX.cpp" 82 | #endif 83 | 84 | CRWLock::CRWLock() 85 | { 86 | lockName = strdup("anon"); 87 | } 88 | 89 | CRWLock::CRWLock(const char* lName) 90 | { 91 | lockName = strdup(lName); 92 | } 93 | 94 | 95 | CRWLock::~CRWLock() 96 | { 97 | free(lockName); 98 | } 99 | -------------------------------------------------------------------------------- /src/base/RWLock_POSIX.cpp: -------------------------------------------------------------------------------- 1 | /* ES40 emulator. 2 | * Copyright (C) 2007-2008 by the ES40 Emulator Project 3 | * 4 | * WWW : http://www.es40.org 5 | * E-mail : camiel@es40.org 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2 10 | * of the License, or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | * 21 | * Although this is not required, the author would appreciate being notified of, 22 | * and receiving any modifications you may make to the source code that might serve 23 | * the general public. 24 | * 25 | * Parts of this file based upon the Poco C++ Libraries, which is Copyright (C) 26 | * 2004-2006, Applied Informatics Software Engineering GmbH. and Contributors. 27 | */ 28 | 29 | /** 30 | * $Id$ 31 | * 32 | * X-1.1 Camiel Vanderhoeven 31-MAY-2008 33 | * Initial version for ES40 emulator. 34 | **/ 35 | 36 | // 37 | // RWLock_POSIX.cpp 38 | // 39 | // $Id$ 40 | // 41 | // Library: Foundation 42 | // Package: Threading 43 | // Module: RWLock 44 | // 45 | // Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. 46 | // and Contributors. 47 | // 48 | // Permission is hereby granted, free of charge, to any person or organization 49 | // obtaining a copy of the software and accompanying documentation covered by 50 | // this license (the "Software") to use, reproduce, display, distribute, 51 | // execute, and transmit the Software, and to prepare derivative works of the 52 | // Software, and to permit third-parties to whom the Software is furnished to 53 | // do so, all subject to the following: 54 | // 55 | // The copyright notices in the Software and this entire statement, including 56 | // the above license grant, this restriction and the following disclaimer, 57 | // must be included in all copies of the Software, in whole or in part, and 58 | // all derivative works of the Software, unless such copies or derivative 59 | // works are solely in the form of machine-executable object code generated by 60 | // a source language processor. 61 | // 62 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 63 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 64 | // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT 65 | // SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE 66 | // FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, 67 | // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 68 | // DEALINGS IN THE SOFTWARE. 69 | // 70 | 71 | 72 | #include "RWLock_POSIX.h" 73 | 74 | 75 | CRWLockImpl::CRWLockImpl() 76 | { 77 | if (pthread_rwlock_init(&_rwl, NULL)) 78 | throw CSystemException("cannot create reader/writer lock"); 79 | } 80 | 81 | 82 | CRWLockImpl::~CRWLockImpl() 83 | { 84 | pthread_rwlock_destroy(&_rwl); 85 | } 86 | -------------------------------------------------------------------------------- /src/base/RWLock_WIN32.h: -------------------------------------------------------------------------------- 1 | /* ES40 emulator. 2 | * Copyright (C) 2007-2008 by the ES40 Emulator Project 3 | * 4 | * WWW : http://www.es40.org 5 | * E-mail : camiel@es40.org 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2 10 | * of the License, or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | * 21 | * Although this is not required, the author would appreciate being notified of, 22 | * and receiving any modifications you may make to the source code that might serve 23 | * the general public. 24 | * 25 | * Parts of this file based upon the Poco C++ Libraries, which is Copyright (C) 26 | * 2004-2006, Applied Informatics Software Engineering GmbH. and Contributors. 27 | */ 28 | 29 | /** 30 | * $Id$ 31 | * 32 | * X-1.1 Camiel Vanderhoeven 31-MAY-2008 33 | * Initial version for ES40 emulator. 34 | **/ 35 | 36 | // 37 | // RWLock_WIN32.h 38 | // 39 | // $Id$ 40 | // 41 | // Library: Foundation 42 | // Package: Threading 43 | // Module: RWLock 44 | // 45 | // Definition of the RWLockImpl class for WIN32. 46 | // 47 | // Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. 48 | // and Contributors. 49 | // 50 | // Permission is hereby granted, free of charge, to any person or organization 51 | // obtaining a copy of the software and accompanying documentation covered by 52 | // this license (the "Software") to use, reproduce, display, distribute, 53 | // execute, and transmit the Software, and to prepare derivative works of the 54 | // Software, and to permit third-parties to whom the Software is furnished to 55 | // do so, all subject to the following: 56 | // 57 | // The copyright notices in the Software and this entire statement, including 58 | // the above license grant, this restriction and the following disclaimer, 59 | // must be included in all copies of the Software, in whole or in part, and 60 | // all derivative works of the Software, unless such copies or derivative 61 | // works are solely in the form of machine-executable object code generated by 62 | // a source language processor. 63 | // 64 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 65 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 66 | // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT 67 | // SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE 68 | // FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, 69 | // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 70 | // DEALINGS IN THE SOFTWARE. 71 | // 72 | 73 | 74 | #ifndef Foundation_RWLock_WIN32_INCLUDED 75 | #define Foundation_RWLock_WIN32_INCLUDED 76 | 77 | 78 | #include "Foundation.h" 79 | #include "Exception.h" 80 | #include "UnWindows.h" 81 | 82 | 83 | class CRWLockImpl 84 | { 85 | protected: 86 | CRWLockImpl(); 87 | ~CRWLockImpl(); 88 | void readLockImpl(); 89 | bool tryReadLockImpl(); 90 | void writeLockImpl(); 91 | bool tryWriteLockImpl(); 92 | void unlockImpl(); 93 | 94 | private: 95 | void addWriter(); 96 | void removeWriter(); 97 | 98 | HANDLE _mutex; 99 | HANDLE _readEvent; 100 | HANDLE _writeEvent; 101 | unsigned _readers; 102 | unsigned _writers; 103 | }; 104 | 105 | #endif // Foundation_RWLock_WIN32_INCLUDED 106 | -------------------------------------------------------------------------------- /src/base/RefCountedObject.cpp: -------------------------------------------------------------------------------- 1 | /* ES40 emulator. 2 | * Copyright (C) 2007-2008 by the ES40 Emulator Project 3 | * 4 | * WWW : http://www.es40.org 5 | * E-mail : camiel@es40.org 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2 10 | * of the License, or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | * 21 | * Although this is not required, the author would appreciate being notified of, 22 | * and receiving any modifications you may make to the source code that might serve 23 | * the general public. 24 | * 25 | * Parts of this file based upon the Poco C++ Libraries, which is Copyright (C) 26 | * 2004-2006, Applied Informatics Software Engineering GmbH. and Contributors. 27 | */ 28 | 29 | /** 30 | * $Id$ 31 | * 32 | * X-1.1 Camiel Vanderhoeven 31-MAY-2008 33 | * Initial version for ES40 emulator. 34 | **/ 35 | 36 | // 37 | // RefCountedObject.cpp 38 | // 39 | // $Id$ 40 | // 41 | // Library: Foundation 42 | // Package: Core 43 | // Module: RefCountedObject 44 | // 45 | // Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. 46 | // and Contributors. 47 | // 48 | // Permission is hereby granted, free of charge, to any person or organization 49 | // obtaining a copy of the software and accompanying documentation covered by 50 | // this license (the "Software") to use, reproduce, display, distribute, 51 | // execute, and transmit the Software, and to prepare derivative works of the 52 | // Software, and to permit third-parties to whom the Software is furnished to 53 | // do so, all subject to the following: 54 | // 55 | // The copyright notices in the Software and this entire statement, including 56 | // the above license grant, this restriction and the following disclaimer, 57 | // must be included in all copies of the Software, in whole or in part, and 58 | // all derivative works of the Software, unless such copies or derivative 59 | // works are solely in the form of machine-executable object code generated by 60 | // a source language processor. 61 | // 62 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 63 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 64 | // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT 65 | // SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE 66 | // FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, 67 | // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 68 | // DEALINGS IN THE SOFTWARE. 69 | // 70 | 71 | #include "Mutex.h" 72 | #include "RefCountedObject.h" 73 | 74 | CRefCountedObject::CRefCountedObject(): _rc(1), _rcMutex("rc") 75 | { 76 | } 77 | 78 | 79 | CRefCountedObject::~CRefCountedObject() 80 | { 81 | } 82 | 83 | 84 | void CRefCountedObject::duplicate() const 85 | { 86 | _rcMutex.lock(); 87 | ++_rc; 88 | _rcMutex.unlock(); 89 | } 90 | 91 | 92 | void CRefCountedObject::release() const 93 | { 94 | _rcMutex.lock(); 95 | int rc = --_rc; 96 | _rcMutex.unlock(); 97 | if (rc == 0) delete this; 98 | } 99 | -------------------------------------------------------------------------------- /src/base/RefCountedObject.h: -------------------------------------------------------------------------------- 1 | /* ES40 emulator. 2 | * Copyright (C) 2007-2008 by the ES40 Emulator Project 3 | * 4 | * WWW : http://www.es40.org 5 | * E-mail : camiel@es40.org 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2 10 | * of the License, or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | * 21 | * Although this is not required, the author would appreciate being notified of, 22 | * and receiving any modifications you may make to the source code that might serve 23 | * the general public. 24 | * 25 | * Parts of this file based upon the Poco C++ Libraries, which is Copyright (C) 26 | * 2004-2006, Applied Informatics Software Engineering GmbH. and Contributors. 27 | */ 28 | 29 | /** 30 | * $Id$ 31 | * 32 | * X-1.1 Camiel Vanderhoeven 31-MAY-2008 33 | * Initial version for ES40 emulator. 34 | **/ 35 | 36 | // 37 | // RefCountedObject.h 38 | // 39 | // $Id$ 40 | // 41 | // Library: Foundation 42 | // Package: Core 43 | // Module: RefCountedObject 44 | // 45 | // Definition of the RefCountedObject class. 46 | // 47 | // Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. 48 | // and Contributors. 49 | // 50 | // Permission is hereby granted, free of charge, to any person or organization 51 | // obtaining a copy of the software and accompanying documentation covered by 52 | // this license (the "Software") to use, reproduce, display, distribute, 53 | // execute, and transmit the Software, and to prepare derivative works of the 54 | // Software, and to permit third-parties to whom the Software is furnished to 55 | // do so, all subject to the following: 56 | // 57 | // The copyright notices in the Software and this entire statement, including 58 | // the above license grant, this restriction and the following disclaimer, 59 | // must be included in all copies of the Software, in whole or in part, and 60 | // all derivative works of the Software, unless such copies or derivative 61 | // works are solely in the form of machine-executable object code generated by 62 | // a source language processor. 63 | // 64 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 65 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 66 | // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT 67 | // SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE 68 | // FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, 69 | // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 70 | // DEALINGS IN THE SOFTWARE. 71 | // 72 | 73 | 74 | #ifndef Foundation_RefCountedObject_INCLUDED 75 | #define Foundation_RefCountedObject_INCLUDED 76 | 77 | 78 | #include "Foundation.h" 79 | #include "Mutex.h" 80 | 81 | class CRefCountedObject 82 | /// A base class for objects that employ 83 | /// reference counting based garbage collection. 84 | /// 85 | /// Reference-counted objects inhibit construction 86 | /// by copying and assignment. 87 | { 88 | public: 89 | CRefCountedObject(); 90 | /// Creates the RefCountedObject. 91 | /// The initial reference count is one. 92 | 93 | void duplicate() const; 94 | /// Increments the object's reference count. 95 | 96 | void release() const; 97 | /// Decrements the object's reference count 98 | /// and deletes the object if the count 99 | /// reaches zero. 100 | 101 | int referenceCount() const; 102 | /// Returns the reference count. 103 | 104 | protected: 105 | virtual ~CRefCountedObject(); 106 | /// Destroys the RefCountedObject. 107 | 108 | private: 109 | CRefCountedObject(const CRefCountedObject&); 110 | CRefCountedObject& operator = (const CRefCountedObject&); 111 | 112 | mutable int _rc; 113 | mutable CFastMutex _rcMutex; 114 | }; 115 | 116 | 117 | // 118 | // inlines 119 | // 120 | inline int CRefCountedObject::referenceCount() const 121 | { 122 | return _rc; 123 | } 124 | 125 | #endif // Foundation_RefCountedObject_INCLUDED 126 | -------------------------------------------------------------------------------- /src/base/Runnable.cpp: -------------------------------------------------------------------------------- 1 | /* ES40 emulator. 2 | * Copyright (C) 2007-2008 by the ES40 Emulator Project 3 | * 4 | * WWW : http://www.es40.org 5 | * E-mail : camiel@es40.org 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2 10 | * of the License, or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | * 21 | * Although this is not required, the author would appreciate being notified of, 22 | * and receiving any modifications you may make to the source code that might serve 23 | * the general public. 24 | * 25 | * Parts of this file based upon the Poco C++ Libraries, which is Copyright (C) 26 | * 2004-2006, Applied Informatics Software Engineering GmbH. and Contributors. 27 | */ 28 | 29 | /** 30 | * $Id$ 31 | * 32 | * X-1.1 Camiel Vanderhoeven 31-MAY-2008 33 | * Initial version for ES40 emulator. 34 | **/ 35 | 36 | // 37 | // Runnable.cpp 38 | // 39 | // $Id$ 40 | // 41 | // Library: Foundation 42 | // Package: Threading 43 | // Module: Thread 44 | // 45 | // Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. 46 | // and Contributors. 47 | // 48 | // Permission is hereby granted, free of charge, to any person or organization 49 | // obtaining a copy of the software and accompanying documentation covered by 50 | // this license (the "Software") to use, reproduce, display, distribute, 51 | // execute, and transmit the Software, and to prepare derivative works of the 52 | // Software, and to permit third-parties to whom the Software is furnished to 53 | // do so, all subject to the following: 54 | // 55 | // The copyright notices in the Software and this entire statement, including 56 | // the above license grant, this restriction and the following disclaimer, 57 | // must be included in all copies of the Software, in whole or in part, and 58 | // all derivative works of the Software, unless such copies or derivative 59 | // works are solely in the form of machine-executable object code generated by 60 | // a source language processor. 61 | // 62 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 63 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 64 | // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT 65 | // SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE 66 | // FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, 67 | // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 68 | // DEALINGS IN THE SOFTWARE. 69 | // 70 | 71 | 72 | #include "Runnable.h" 73 | 74 | CRunnable::CRunnable() 75 | { 76 | } 77 | 78 | 79 | CRunnable::~CRunnable() 80 | { 81 | } 82 | -------------------------------------------------------------------------------- /src/base/Runnable.h: -------------------------------------------------------------------------------- 1 | /* ES40 emulator. 2 | * Copyright (C) 2007-2008 by the ES40 Emulator Project 3 | * 4 | * WWW : http://www.es40.org 5 | * E-mail : camiel@es40.org 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2 10 | * of the License, or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | * 21 | * Although this is not required, the author would appreciate being notified of, 22 | * and receiving any modifications you may make to the source code that might serve 23 | * the general public. 24 | * 25 | * Parts of this file based upon the Poco C++ Libraries, which is Copyright (C) 26 | * 2004-2006, Applied Informatics Software Engineering GmbH. and Contributors. 27 | */ 28 | 29 | /** 30 | * $Id$ 31 | * 32 | * X-1.1 Camiel Vanderhoeven 31-MAY-2008 33 | * Initial version for ES40 emulator. 34 | **/ 35 | 36 | // 37 | // Runnable.h 38 | // 39 | // $Id$ 40 | // 41 | // Library: Foundation 42 | // Package: Threading 43 | // Module: Thread 44 | // 45 | // Definition of the Runnable class. 46 | // 47 | // Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. 48 | // and Contributors. 49 | // 50 | // Permission is hereby granted, free of charge, to any person or organization 51 | // obtaining a copy of the software and accompanying documentation covered by 52 | // this license (the "Software") to use, reproduce, display, distribute, 53 | // execute, and transmit the Software, and to prepare derivative works of the 54 | // Software, and to permit third-parties to whom the Software is furnished to 55 | // do so, all subject to the following: 56 | // 57 | // The copyright notices in the Software and this entire statement, including 58 | // the above license grant, this restriction and the following disclaimer, 59 | // must be included in all copies of the Software, in whole or in part, and 60 | // all derivative works of the Software, unless such copies or derivative 61 | // works are solely in the form of machine-executable object code generated by 62 | // a source language processor. 63 | // 64 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 65 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 66 | // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT 67 | // SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE 68 | // FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, 69 | // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 70 | // DEALINGS IN THE SOFTWARE. 71 | // 72 | 73 | 74 | #ifndef Foundation_Runnable_INCLUDED 75 | #define Foundation_Runnable_INCLUDED 76 | 77 | 78 | #include "Foundation.h" 79 | 80 | class CRunnable 81 | /// The Runnable interface with the run() method 82 | /// must be implemented by classes that provide 83 | /// an entry point for a thread. 84 | { 85 | public: 86 | CRunnable(); 87 | virtual ~CRunnable(); 88 | 89 | virtual void run() = 0; 90 | /// Do whatever the thread needs to do. Must 91 | /// be overridden by subclasses. 92 | }; 93 | 94 | #endif // Foundation_Runnable_INCLUDED 95 | -------------------------------------------------------------------------------- /src/base/ScopedLock.h: -------------------------------------------------------------------------------- 1 | /* ES40 emulator. 2 | * Copyright (C) 2007-2008 by the ES40 Emulator Project 3 | * 4 | * WWW : http://www.es40.org 5 | * E-mail : camiel@es40.org 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2 10 | * of the License, or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | * 21 | * Although this is not required, the author would appreciate being notified of, 22 | * and receiving any modifications you may make to the source code that might serve 23 | * the general public. 24 | * 25 | * Parts of this file based upon the Poco C++ Libraries, which is Copyright (C) 26 | * 2004-2006, Applied Informatics Software Engineering GmbH. and Contributors. 27 | */ 28 | 29 | /** 30 | * $Id$ 31 | * 32 | * X-1.1 Camiel Vanderhoeven 31-MAY-2008 33 | * Initial version for ES40 emulator. 34 | **/ 35 | 36 | // 37 | // ScopedLock.h 38 | // 39 | // $Id$ 40 | // 41 | // Library: Foundation 42 | // Package: Threading 43 | // Module: Mutex 44 | // 45 | // Definition of the ScopedLock template class. 46 | // 47 | // Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. 48 | // and Contributors. 49 | // 50 | // Permission is hereby granted, free of charge, to any person or organization 51 | // obtaining a copy of the software and accompanying documentation covered by 52 | // this license (the "Software") to use, reproduce, display, distribute, 53 | // execute, and transmit the Software, and to prepare derivative works of the 54 | // Software, and to permit third-parties to whom the Software is furnished to 55 | // do so, all subject to the following: 56 | // 57 | // The copyright notices in the Software and this entire statement, including 58 | // the above license grant, this restriction and the following disclaimer, 59 | // must be included in all copies of the Software, in whole or in part, and 60 | // all derivative works of the Software, unless such copies or derivative 61 | // works are solely in the form of machine-executable object code generated by 62 | // a source language processor. 63 | // 64 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 65 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 66 | // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT 67 | // SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE 68 | // FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, 69 | // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 70 | // DEALINGS IN THE SOFTWARE. 71 | // 72 | 73 | 74 | #ifndef Foundation_ScopedLock_INCLUDED 75 | #define Foundation_ScopedLock_INCLUDED 76 | 77 | 78 | #include "Foundation.h" 79 | 80 | /** 81 | * \brief A class that simplifies thread synchronization with a mutex or fastmutex. 82 | * 83 | * The constructor accepts a Mutex and locks it. 84 | * The destructor unlocks the mutex. 85 | **/ 86 | template 87 | class CScopedLock 88 | { 89 | public: 90 | inline CScopedLock(M* mutex): _mutex(mutex) 91 | { 92 | _mutex->lock(LOCK_TIMEOUT_MS); 93 | } 94 | inline ~CScopedLock() 95 | { 96 | _mutex->unlock(); 97 | } 98 | 99 | private: 100 | M* _mutex; 101 | 102 | CScopedLock(); 103 | CScopedLock(const CScopedLock&); 104 | CScopedLock& operator = (const CScopedLock&); 105 | }; 106 | 107 | #endif // Foundation_ScopedLock_INCLUDED 108 | -------------------------------------------------------------------------------- /src/base/Semaphore.cpp: -------------------------------------------------------------------------------- 1 | /* ES40 emulator. 2 | * Copyright (C) 2007-2008 by the ES40 Emulator Project 3 | * 4 | * WWW : http://www.es40.org 5 | * E-mail : camiel@es40.org 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2 10 | * of the License, or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | * 21 | * Although this is not required, the author would appreciate being notified of, 22 | * and receiving any modifications you may make to the source code that might serve 23 | * the general public. 24 | * 25 | * Parts of this file based upon the Poco C++ Libraries, which is Copyright (C) 26 | * 2004-2006, Applied Informatics Software Engineering GmbH. and Contributors. 27 | */ 28 | 29 | /** 30 | * $Id$ 31 | * 32 | * X-1.1 Camiel Vanderhoeven 31-MAY-2008 33 | * Initial version for ES40 emulator. 34 | **/ 35 | 36 | // 37 | // Semaphore.cpp 38 | // 39 | // $Id$ 40 | // 41 | // Library: Foundation 42 | // Package: Threading 43 | // Module: Semaphore 44 | // 45 | // Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. 46 | // and Contributors. 47 | // 48 | // Permission is hereby granted, free of charge, to any person or organization 49 | // obtaining a copy of the software and accompanying documentation covered by 50 | // this license (the "Software") to use, reproduce, display, distribute, 51 | // execute, and transmit the Software, and to prepare derivative works of the 52 | // Software, and to permit third-parties to whom the Software is furnished to 53 | // do so, all subject to the following: 54 | // 55 | // The copyright notices in the Software and this entire statement, including 56 | // the above license grant, this restriction and the following disclaimer, 57 | // must be included in all copies of the Software, in whole or in part, and 58 | // all derivative works of the Software, unless such copies or derivative 59 | // works are solely in the form of machine-executable object code generated by 60 | // a source language processor. 61 | // 62 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 63 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 64 | // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT 65 | // SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE 66 | // FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, 67 | // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 68 | // DEALINGS IN THE SOFTWARE. 69 | // 70 | 71 | 72 | #include "Semaphore.h" 73 | 74 | 75 | #if defined(POCO_OS_FAMILY_WINDOWS) 76 | #include "Semaphore_WIN32.cpp" 77 | #else 78 | #include "Semaphore_POSIX.cpp" 79 | #endif 80 | 81 | 82 | CSemaphore::CSemaphore(int n): CSemaphoreImpl(n, n) 83 | { 84 | } 85 | 86 | 87 | CSemaphore::CSemaphore(int n, int max): CSemaphoreImpl(n, max) 88 | { 89 | } 90 | 91 | 92 | CSemaphore::~CSemaphore() 93 | { 94 | } 95 | -------------------------------------------------------------------------------- /src/base/Semaphore_POSIX.h: -------------------------------------------------------------------------------- 1 | /* ES40 emulator. 2 | * Copyright (C) 2007-2008 by the ES40 Emulator Project 3 | * 4 | * WWW : http://www.es40.org 5 | * E-mail : camiel@es40.org 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2 10 | * of the License, or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | * 21 | * Although this is not required, the author would appreciate being notified of, 22 | * and receiving any modifications you may make to the source code that might serve 23 | * the general public. 24 | * 25 | * Parts of this file based upon the Poco C++ Libraries, which is Copyright (C) 26 | * 2004-2006, Applied Informatics Software Engineering GmbH. and Contributors. 27 | */ 28 | 29 | /** 30 | * $Id$ 31 | * 32 | * X-1.1 Camiel Vanderhoeven 31-MAY-2008 33 | * Initial version for ES40 emulator. 34 | **/ 35 | 36 | // 37 | // Semaphore_POSIX.h 38 | // 39 | // $Id$ 40 | // 41 | // Library: Foundation 42 | // Package: Threading 43 | // Module: Semaphore 44 | // 45 | // Definition of the SemaphoreImpl class for POSIX Threads. 46 | // 47 | // Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. 48 | // and Contributors. 49 | // 50 | // Permission is hereby granted, free of charge, to any person or organization 51 | // obtaining a copy of the software and accompanying documentation covered by 52 | // this license (the "Software") to use, reproduce, display, distribute, 53 | // execute, and transmit the Software, and to prepare derivative works of the 54 | // Software, and to permit third-parties to whom the Software is furnished to 55 | // do so, all subject to the following: 56 | // 57 | // The copyright notices in the Software and this entire statement, including 58 | // the above license grant, this restriction and the following disclaimer, 59 | // must be included in all copies of the Software, in whole or in part, and 60 | // all derivative works of the Software, unless such copies or derivative 61 | // works are solely in the form of machine-executable object code generated by 62 | // a source language processor. 63 | // 64 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 65 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 66 | // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT 67 | // SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE 68 | // FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, 69 | // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 70 | // DEALINGS IN THE SOFTWARE. 71 | // 72 | 73 | 74 | #ifndef Foundation_Semaphore_POSIX_INCLUDED 75 | #define Foundation_Semaphore_POSIX_INCLUDED 76 | 77 | 78 | #include "Foundation.h" 79 | #include "Exception.h" 80 | #include 81 | #include 82 | 83 | class CSemaphoreImpl 84 | { 85 | protected: 86 | CSemaphoreImpl(int n, int max); 87 | ~CSemaphoreImpl(); 88 | void setImpl(); 89 | void waitImpl(); 90 | bool waitImpl(long milliseconds); 91 | 92 | private: 93 | volatile int _n; 94 | int _max; 95 | pthread_mutex_t _mutex; 96 | pthread_cond_t _cond; 97 | }; 98 | 99 | 100 | // 101 | // inlines 102 | // 103 | inline void CSemaphoreImpl::setImpl() 104 | { 105 | if (pthread_mutex_lock(&_mutex)) 106 | throw CSystemException("cannot signal semaphore (lock)"); 107 | if (_n < _max) 108 | { 109 | ++_n; 110 | } 111 | else 112 | { 113 | pthread_mutex_unlock(&_mutex); 114 | throw CSystemException("cannot signal semaphore: count would exceed maximum"); 115 | } 116 | if (pthread_cond_signal(&_cond)) 117 | { 118 | pthread_mutex_unlock(&_mutex); 119 | throw CSystemException("cannot signal semaphore"); 120 | } 121 | pthread_mutex_unlock(&_mutex); 122 | } 123 | 124 | 125 | #endif // Foundation_Semaphore_POSIX_INCLUDED 126 | -------------------------------------------------------------------------------- /src/base/Semaphore_WIN32.cpp: -------------------------------------------------------------------------------- 1 | /* ES40 emulator. 2 | * Copyright (C) 2007-2008 by the ES40 Emulator Project 3 | * 4 | * WWW : http://www.es40.org 5 | * E-mail : camiel@es40.org 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2 10 | * of the License, or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | * 21 | * Although this is not required, the author would appreciate being notified of, 22 | * and receiving any modifications you may make to the source code that might serve 23 | * the general public. 24 | * 25 | * Parts of this file based upon the Poco C++ Libraries, which is Copyright (C) 26 | * 2004-2006, Applied Informatics Software Engineering GmbH. and Contributors. 27 | */ 28 | 29 | /** 30 | * $Id$ 31 | * 32 | * X-1.1 Camiel Vanderhoeven 31-MAY-2008 33 | * Initial version for ES40 emulator. 34 | **/ 35 | 36 | // 37 | // Semaphore_WIN32.cpp 38 | // 39 | // $Id$ 40 | // 41 | // Library: Foundation 42 | // Package: Threading 43 | // Module: Semaphore 44 | // 45 | // Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. 46 | // and Contributors. 47 | // 48 | // Permission is hereby granted, free of charge, to any person or organization 49 | // obtaining a copy of the software and accompanying documentation covered by 50 | // this license (the "Software") to use, reproduce, display, distribute, 51 | // execute, and transmit the Software, and to prepare derivative works of the 52 | // Software, and to permit third-parties to whom the Software is furnished to 53 | // do so, all subject to the following: 54 | // 55 | // The copyright notices in the Software and this entire statement, including 56 | // the above license grant, this restriction and the following disclaimer, 57 | // must be included in all copies of the Software, in whole or in part, and 58 | // all derivative works of the Software, unless such copies or derivative 59 | // works are solely in the form of machine-executable object code generated by 60 | // a source language processor. 61 | // 62 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 63 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 64 | // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT 65 | // SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE 66 | // FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, 67 | // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 68 | // DEALINGS IN THE SOFTWARE. 69 | // 70 | 71 | 72 | #include "Semaphore_WIN32.h" 73 | 74 | CSemaphoreImpl::CSemaphoreImpl(int n, int max) 75 | { 76 | poco_assert (n >= 0 && max > 0 && n <= max); 77 | 78 | _sema = CreateSemaphoreW(NULL, n, max, NULL); 79 | if (!_sema) 80 | { 81 | throw CSystemException("cannot create semaphore"); 82 | } 83 | } 84 | 85 | 86 | CSemaphoreImpl::~CSemaphoreImpl() 87 | { 88 | CloseHandle(_sema); 89 | } 90 | 91 | 92 | void CSemaphoreImpl::waitImpl() 93 | { 94 | switch (WaitForSingleObject(_sema, INFINITE)) 95 | { 96 | case WAIT_OBJECT_0: 97 | return; 98 | default: 99 | throw CSystemException("wait for semaphore failed"); 100 | } 101 | } 102 | 103 | 104 | bool CSemaphoreImpl::waitImpl(long milliseconds) 105 | { 106 | switch (WaitForSingleObject(_sema, milliseconds + 1)) 107 | { 108 | case WAIT_TIMEOUT: 109 | return false; 110 | case WAIT_OBJECT_0: 111 | return true; 112 | default: 113 | throw CSystemException("wait for semaphore failed"); 114 | } 115 | } 116 | -------------------------------------------------------------------------------- /src/base/Semaphore_WIN32.h: -------------------------------------------------------------------------------- 1 | /* ES40 emulator. 2 | * Copyright (C) 2007-2008 by the ES40 Emulator Project 3 | * 4 | * WWW : http://www.es40.org 5 | * E-mail : camiel@es40.org 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2 10 | * of the License, or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | * 21 | * Although this is not required, the author would appreciate being notified of, 22 | * and receiving any modifications you may make to the source code that might serve 23 | * the general public. 24 | * 25 | * Parts of this file based upon the Poco C++ Libraries, which is Copyright (C) 26 | * 2004-2006, Applied Informatics Software Engineering GmbH. and Contributors. 27 | */ 28 | 29 | /** 30 | * $Id$ 31 | * 32 | * X-1.1 Camiel Vanderhoeven 31-MAY-2008 33 | * Initial version for ES40 emulator. 34 | **/ 35 | 36 | // 37 | // Semaphore_WIN32.h 38 | // 39 | // $Id$ 40 | // 41 | // Library: Foundation 42 | // Package: Threading 43 | // Module: Semaphore 44 | // 45 | // Definition of the SemaphoreImpl class for WIN32. 46 | // 47 | // Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. 48 | // and Contributors. 49 | // 50 | // Permission is hereby granted, free of charge, to any person or organization 51 | // obtaining a copy of the software and accompanying documentation covered by 52 | // this license (the "Software") to use, reproduce, display, distribute, 53 | // execute, and transmit the Software, and to prepare derivative works of the 54 | // Software, and to permit third-parties to whom the Software is furnished to 55 | // do so, all subject to the following: 56 | // 57 | // The copyright notices in the Software and this entire statement, including 58 | // the above license grant, this restriction and the following disclaimer, 59 | // must be included in all copies of the Software, in whole or in part, and 60 | // all derivative works of the Software, unless such copies or derivative 61 | // works are solely in the form of machine-executable object code generated by 62 | // a source language processor. 63 | // 64 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 65 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 66 | // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT 67 | // SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE 68 | // FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, 69 | // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 70 | // DEALINGS IN THE SOFTWARE. 71 | // 72 | 73 | 74 | #ifndef Foundation_Semaphore_WIN32_INCLUDED 75 | #define Foundation_Semaphore_WIN32_INCLUDED 76 | 77 | 78 | #include "Foundation.h" 79 | #include "Exception.h" 80 | #include "UnWindows.h" 81 | 82 | class CSemaphoreImpl 83 | { 84 | protected: 85 | CSemaphoreImpl(int n, int max); 86 | ~CSemaphoreImpl(); 87 | void setImpl(); 88 | void waitImpl(); 89 | bool waitImpl(long milliseconds); 90 | 91 | private: 92 | HANDLE _sema; 93 | }; 94 | 95 | 96 | // 97 | // inlines 98 | // 99 | inline void CSemaphoreImpl::setImpl() 100 | { 101 | if (!ReleaseSemaphore(_sema, 1, NULL)) 102 | { 103 | throw CSystemException("cannot signal semaphore"); 104 | } 105 | } 106 | 107 | #endif // Foundation_Semaphore_WIN32_INCLUDED 108 | -------------------------------------------------------------------------------- /src/base/SingletonHolder.h: -------------------------------------------------------------------------------- 1 | /* ES40 emulator. 2 | * Copyright (C) 2007-2008 by the ES40 Emulator Project 3 | * 4 | * WWW : http://www.es40.org 5 | * E-mail : camiel@es40.org 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2 10 | * of the License, or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | * 21 | * Although this is not required, the author would appreciate being notified of, 22 | * and receiving any modifications you may make to the source code that might serve 23 | * the general public. 24 | * 25 | * Parts of this file based upon the Poco C++ Libraries, which is Copyright (C) 26 | * 2004-2006, Applied Informatics Software Engineering GmbH. and Contributors. 27 | */ 28 | 29 | /** 30 | * $Id$ 31 | * 32 | * X-1.1 Camiel Vanderhoeven 31-MAY-2008 33 | * Initial version for ES40 emulator. 34 | **/ 35 | 36 | // 37 | // SingletonHolder.h 38 | // 39 | // $Id$ 40 | // 41 | // Library: Foundation 42 | // Package: Core 43 | // Module: SingletonHolder 44 | // 45 | // Definition of the SingletonHolder template. 46 | // 47 | // Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. 48 | // and Contributors. 49 | // 50 | // Permission is hereby granted, free of charge, to any person or organization 51 | // obtaining a copy of the software and accompanying documentation covered by 52 | // this license (the "Software") to use, reproduce, display, distribute, 53 | // execute, and transmit the Software, and to prepare derivative works of the 54 | // Software, and to permit third-parties to whom the Software is furnished to 55 | // do so, all subject to the following: 56 | // 57 | // The copyright notices in the Software and this entire statement, including 58 | // the above license grant, this restriction and the following disclaimer, 59 | // must be included in all copies of the Software, in whole or in part, and 60 | // all derivative works of the Software, unless such copies or derivative 61 | // works are solely in the form of machine-executable object code generated by 62 | // a source language processor. 63 | // 64 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 65 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 66 | // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT 67 | // SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE 68 | // FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, 69 | // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 70 | // DEALINGS IN THE SOFTWARE. 71 | // 72 | 73 | 74 | #ifndef Foundation_SingletonHolder_INCLUDED 75 | #define Foundation_SingletonHolder_INCLUDED 76 | 77 | 78 | #include "Foundation.h" 79 | #include "Mutex.h" 80 | 81 | template 82 | class CSingletonHolder 83 | /// This is a helper template class for managing 84 | /// singleton objects allocated on the heap. 85 | /// The class ensures proper deletion (including 86 | /// calling of the destructor) of singleton objects 87 | /// when the application that created them terminates. 88 | { 89 | public: 90 | CSingletonHolder() 91 | /// Creates the SingletonHolder. 92 | { 93 | _pS = 0; 94 | } 95 | ~CSingletonHolder() 96 | /// Destroys the SingletonHolder and the singleton 97 | /// object that it holds. 98 | { 99 | delete _pS; 100 | } 101 | S* get() 102 | /// Returns a pointer to the singleton object 103 | /// hold by the SingletonHolder. The first call 104 | /// to get will create the singleton. 105 | { 106 | CFastMutex::CScopedLock lock(&_m); 107 | if (!_pS) _pS = new S; 108 | return _pS; 109 | } 110 | 111 | private: 112 | S* _pS; 113 | CFastMutex _m; 114 | }; 115 | 116 | #endif // Foundation_SingletonHolder_INCLUDED 117 | -------------------------------------------------------------------------------- /src/base/ThreadLocal.cpp: -------------------------------------------------------------------------------- 1 | /* ES40 emulator. 2 | * Copyright (C) 2007-2008 by the ES40 Emulator Project 3 | * 4 | * WWW : http://www.es40.org 5 | * E-mail : camiel@es40.org 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2 10 | * of the License, or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | * 21 | * Although this is not required, the author would appreciate being notified of, 22 | * and receiving any modifications you may make to the source code that might serve 23 | * the general public. 24 | * 25 | * Parts of this file based upon the Poco C++ Libraries, which is Copyright (C) 26 | * 2004-2006, Applied Informatics Software Engineering GmbH. and Contributors. 27 | */ 28 | 29 | /** 30 | * $Id$ 31 | * 32 | * X-1.1 Camiel Vanderhoeven 31-MAY-2008 33 | * Initial version for ES40 emulator. 34 | **/ 35 | 36 | // 37 | // ThreadLocal.cpp 38 | // 39 | // $Id$ 40 | // 41 | // Library: Foundation 42 | // Package: Threading 43 | // Module: Thread 44 | // 45 | // Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. 46 | // and Contributors. 47 | // 48 | // Permission is hereby granted, free of charge, to any person or organization 49 | // obtaining a copy of the software and accompanying documentation covered by 50 | // this license (the "Software") to use, reproduce, display, distribute, 51 | // execute, and transmit the Software, and to prepare derivative works of the 52 | // Software, and to permit third-parties to whom the Software is furnished to 53 | // do so, all subject to the following: 54 | // 55 | // The copyright notices in the Software and this entire statement, including 56 | // the above license grant, this restriction and the following disclaimer, 57 | // must be included in all copies of the Software, in whole or in part, and 58 | // all derivative works of the Software, unless such copies or derivative 59 | // works are solely in the form of machine-executable object code generated by 60 | // a source language processor. 61 | // 62 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 63 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 64 | // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT 65 | // SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE 66 | // FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, 67 | // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 68 | // DEALINGS IN THE SOFTWARE. 69 | // 70 | 71 | 72 | #include "ThreadLocal.h" 73 | #include "SingletonHolder.h" 74 | #include "Thread.h" 75 | 76 | CTLSAbstractSlot::CTLSAbstractSlot() 77 | { 78 | } 79 | 80 | 81 | CTLSAbstractSlot::~CTLSAbstractSlot() 82 | { 83 | } 84 | 85 | 86 | CThreadLocalStorage::CThreadLocalStorage() 87 | { 88 | } 89 | 90 | 91 | CThreadLocalStorage::~CThreadLocalStorage() 92 | { 93 | for (CTLSMap::iterator it = _map.begin(); it != _map.end(); ++it) 94 | { 95 | delete it->second; 96 | } 97 | } 98 | 99 | 100 | CTLSAbstractSlot*& CThreadLocalStorage::get(const void* key) 101 | { 102 | CTLSMap::iterator it = _map.find(key); 103 | if (it == _map.end()) 104 | return _map.insert(CTLSMap::value_type(key, static_cast(0))).first->second; 105 | else 106 | return it->second; 107 | } 108 | 109 | 110 | CThreadLocalStorage& CThreadLocalStorage::current() 111 | { 112 | CThread* pThread = CThread::current(); 113 | if (pThread) 114 | { 115 | return pThread->tls(); 116 | } 117 | else 118 | { 119 | static CSingletonHolder sh; 120 | return *sh.get(); 121 | } 122 | } 123 | 124 | 125 | void CThreadLocalStorage::clear() 126 | { 127 | CThread* pThread = CThread::current(); 128 | if (pThread) 129 | pThread->clearTLS(); 130 | } 131 | -------------------------------------------------------------------------------- /src/config_debug.h: -------------------------------------------------------------------------------- 1 | // This is config_debug.h 2 | // 3 | // This file contains the debug configuration options. 4 | // This file was generated by configure_1.sh 5 | // 6 | // $Id$ 7 | 8 | // Define to 1 if you want to show the cycle counter 9 | #define HIDE_COUNTER 1 10 | 11 | // Define to 1 if you want to show estimate speed 12 | #undef MIPS_ESTIMATE 13 | 14 | // Define to 1 if you want to show memory map 15 | #undef DUMP_MEMMAP 16 | 17 | // Define to 1 if you want to check for overlapping of memory ranges 18 | #define CHECK_MEM_RANGES 1 19 | 20 | // Define to 1 if you want to use the new floating-point implementation 21 | #undef HAVE_NEW_FP 22 | 23 | // Define to 1 if you want to enable VGA debugging 24 | #undef DEBUG_VGA 25 | 26 | // Define to 1 if you want to enable Serial Port debugging 27 | #undef DEBUG_SERIAL 28 | 29 | // Define to 1 if you want to enable IDE General debugging 30 | #undef DEBUG_IDE 31 | 32 | // Define to 1 if you want to enable IDE Busmaster debugging 33 | #undef DEBUG_IDE_BUSMASTER 34 | 35 | // Define to 1 if you want to enable IDE Command debugging 36 | #undef DEBUG_IDE_COMMAND 37 | 38 | // Define to 1 if you want to enable IDE CMD debugging 39 | #undef DEBUG_IDE_CMD 40 | 41 | // Define to 1 if you want to enable IDE DMA debugging 42 | #undef DEBUG_IDE_DMA 43 | 44 | // Define to 1 if you want to enable IDE Interrupt debugging 45 | #undef DEBUG_IDE_INTERRUPT 46 | 47 | // Define to 1 if you want to enable IDE Command Register debugging 48 | #undef DEBUG_IDE_REG_COMMAND 49 | 50 | // Define to 1 if you want to enable IDE Control Register debugging 51 | #undef DEBUG_IDE_REG_CONTROL 52 | 53 | // Define to 1 if you want to enable IDE ATAPI Packet debugging 54 | #undef DEBUG_IDE_PACKET 55 | 56 | // Define to 1 if you want to enable IDE Thread debugging 57 | #undef DEBUG_IDE_THREADS 58 | 59 | // Define to 1 if you want to enable IDE Mutexes debugging 60 | #undef DEBUG_IDE_LOCKS 61 | 62 | // Define to 1 if you want to enable IDE Multiple debugging 63 | #undef DEBUG_IDE_MULTIPLE 64 | 65 | // Define to 1 if you want to enable Floating Point conversions debugging 66 | #undef DEBUG_FP_CONVERSION 67 | 68 | // Define to 1 if you want to enable Floating Point load/store debugging 69 | #undef DEBUG_FP_LOADSTORE 70 | 71 | // Define to 1 if you want to enable General NIC debugging 72 | #undef DEBUG_NIC 73 | 74 | // Define to 1 if you want to enable NIC Filter debugging 75 | #undef DEBUG_NIC_FILTER 76 | 77 | // Define to 1 if you want to enable NIC Serial ROM debugging 78 | #undef DEBUG_NIC_SROM 79 | 80 | // Define to 1 if you want to enable unknown memory access debugging 81 | #undef DEBUG_UNKMEM 82 | 83 | // Define to 1 if you want to enable PCI debugging 84 | #undef DEBUG_PCI 85 | 86 | // Define to 1 if you want to enable Translationbuffer debugging 87 | #undef DEBUG_TB 88 | 89 | // Define to 1 if you want to enable I/O Port Access debugging 90 | #undef DEBUG_PORTACCESS 91 | 92 | // Define to 1 if you want to enable Keyboard debugging 93 | #undef DEBUG_KBD 94 | 95 | // Define to 1 if you want to enable Programmable Interrupt Controller (PIC) debugging 96 | #undef DEBUG_PIC 97 | 98 | // Define to 1 if you want to enable Printer port debugging 99 | #undef DEBUG_LPT 100 | 101 | // Define to 1 if you want to enable USB Controller debugging 102 | #undef DEBUG_USB 103 | 104 | // Define to 1 if you want to enable SCSI Device debugging 105 | #undef DEBUG_SCSI 106 | 107 | // Define to 1 if you want to enable Symbios SCSI Controller debugging 108 | #undef DEBUG_SYM 109 | 110 | // Define to 1 if you want to enable Symbios Registers debugging 111 | #undef DEBUG_SYM_REGS 112 | 113 | // Define to 1 if you want to enable Symbios SCRIPTS Execution debugging 114 | #undef DEBUG_SYM_SCRIPTS 115 | 116 | // Define to 1 if you want to enable DMA Controller debugging 117 | #undef DEBUG_DMA 118 | 119 | // Define to 1 if you want to enable backtrace on SIGSEGV debugging 120 | #undef DEBUG_BACKTRACE 121 | 122 | // Define to 1 if you want to enable mutex debugging 123 | #undef DEBUG_LOCKS 124 | 125 | // Define to 1 if you want to enable SDL Key translation debugging 126 | #undef DEBUG_SDL_KEY 127 | -------------------------------------------------------------------------------- /src/cpu_control.h: -------------------------------------------------------------------------------- 1 | /* ES40 emulator. 2 | * Copyright (C) 2007-2008 by the ES40 Emulator Project 3 | * 4 | * WWW : http://sourceforge.net/projects/es40 5 | * E-mail : camiel@camicom.com 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2 10 | * of the License, or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | * 21 | * Although this is not required, the author would appreciate being notified of, 22 | * and receiving any modifications you may make to the source code that might serve 23 | * the general public. 24 | */ 25 | 26 | /** 27 | * \file 28 | * Contains code macros for the processor control instructions. 29 | * Based on ARM chapter 4.3 30 | * 31 | * $Id$ 32 | * 33 | * X-1.6 Camiel Vanderhoeven 14-MAR-2008 34 | * 1. More meaningful exceptions replace throwing (int) 1. 35 | * 2. U64 macro replaces X64 macro. 36 | * 37 | * X-1.5 Camiel Vanderhoeven 30-JAN-2008 38 | * Always use set_pc or add_pc to change the program counter. 39 | * 40 | * X-1.4 Camiel Vanderhoeven 30-JAN-2008 41 | * Remember number of instructions left in current memory page, so 42 | * that the translation-buffer doens't need to be consulted on every 43 | * instruction fetch when the Icache is disabled. 44 | * 45 | * X-1.3 Camiel Vanderhoeven 11-APR-2007 46 | * Moved all data that should be saved to a state file to a structure 47 | * "state". 48 | * 49 | * X-1.2 Camiel Vanderhoeven 30-MAR-2007 50 | * Added old changelog comments. 51 | * 52 | * X-1.1 Camiel Vanderhoeven 18-FEB-2007 53 | * File created. Contains code previously found in AlphaCPU.h 54 | **/ 55 | #define DO_BEQ if(!state.r[REG_1]) \ 56 | add_pc(DISP_21 * 4); 57 | 58 | #define DO_BGE if((s64) state.r[REG_1] >= 0) \ 59 | add_pc(DISP_21 * 4); 60 | 61 | #define DO_BGT if((s64) state.r[REG_1] > 0) \ 62 | add_pc(DISP_21 * 4); 63 | 64 | #define DO_BLBC if(!(state.r[REG_1] & 1)) \ 65 | add_pc(DISP_21 * 4); 66 | 67 | #define DO_BLBS if(state.r[REG_1] & 1) \ 68 | add_pc(DISP_21 * 4); 69 | 70 | #define DO_BLE if((s64) state.r[REG_1] <= 0) \ 71 | add_pc(DISP_21 * 4); 72 | 73 | #define DO_BLT if((s64) state.r[REG_1] < 0) \ 74 | add_pc(DISP_21 * 4); 75 | 76 | #define DO_BNE if(state.r[REG_1]) \ 77 | add_pc(DISP_21 * 4); 78 | 79 | #define DO_BR \ 80 | { \ 81 | state.r[REG_1] = state.pc &~U64(0x3); \ 82 | add_pc(DISP_21 * 4); \ 83 | } 84 | 85 | #define DO_BSR DO_BR 86 | 87 | #define DO_JMP \ 88 | { \ 89 | temp_64 = state.r[REG_2] &~U64(0x3); \ 90 | state.r[REG_1] = state.pc &~U64(0x3); \ 91 | set_pc(temp_64 | (state.pc & 3)); \ 92 | } 93 | 94 | // JSR, RET and JSR_COROUTINE is really JMP, just with different prediction bits. 95 | -------------------------------------------------------------------------------- /src/cpu_logical.h: -------------------------------------------------------------------------------- 1 | /* ES40 emulator. 2 | * Copyright (C) 2007-2008 by the ES40 Emulator Project 3 | * 4 | * Website: http://sourceforge.net/projects/es40 5 | * E-mail : camiel@camicom.com 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2 10 | * of the License, or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | * 21 | * Although this is not required, the author would appreciate being notified of, 22 | * and receiving any modifications you may make to the source code that might serve 23 | * the general public. 24 | */ 25 | 26 | /** 27 | * \file 28 | * Contains code macros for the processor logical instructions. 29 | * Based on ARM chapter 4.5. 30 | * 31 | * $Id$ 32 | * 33 | * X-1.5 Camiel Vanderhoeven 14-MAR-2008 34 | * 1. More meaningful exceptions replace throwing (int) 1. 35 | * 2. U64 macro replaces X64 macro. 36 | * 37 | * X-1.4 Camiel Vanderhoeven 11-APR-2007 38 | * Moved all data that should be saved to a state file to a structure 39 | * "state". 40 | * 41 | * X-1.3 Camiel Vanderhoeven 30-MAR-2007 42 | * Added old changelog comments. 43 | * 44 | * X-1.2 Camiel Vanderhoeven 19-FEB-2007 45 | * Fixed a compiler-dependent bug (possible >> or <= 0) \ 63 | state.r[REG_3] = V_2; 64 | #define DO_CMOVGT if((s64) state.r[REG_1] > 0) \ 65 | state.r[REG_3] = V_2; 66 | #define DO_CMOVLBC if(!(state.r[REG_1] & U64(0x1))) \ 67 | state.r[REG_3] = V_2; 68 | #define DO_CMOVLBS if(state.r[REG_1] & U64(0x1)) \ 69 | state.r[REG_3] = V_2; 70 | #define DO_CMOVLE if((s64) state.r[REG_1] <= 0) \ 71 | state.r[REG_3] = V_2; 72 | #define DO_CMOVLT if((s64) state.r[REG_1] < 0) \ 73 | state.r[REG_3] = V_2; 74 | #define DO_CMOVNE if(state.r[REG_1]) \ 75 | state.r[REG_3] = V_2; 76 | 77 | #define DO_SLL state.r[REG_3] = state.r[REG_1] << (V_2 & 63); 78 | #define DO_SRA state.r[REG_3] = (V_2 & 63) ? \ 79 | ( \ 80 | (state.r[REG_1] >> (V_2 & 63)) | \ 81 | ((state.r[REG_1] >> 63) ? (X64_QUAD << (64 - (V_2 & 63))) : 0) \ 82 | ) : state.r[REG_1]; 83 | #define DO_SRL state.r[REG_3] = state.r[REG_1] >> (V_2 & 63); 84 | -------------------------------------------------------------------------------- /src/cpu_vax.h: -------------------------------------------------------------------------------- 1 | /* ES40 emulator. 2 | * Copyright (C) 2007 by Camiel Vanderhoeven 3 | * 4 | * Website: www.camicom.com 5 | * E-mail : camiel@camicom.com 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2 10 | * of the License, or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | * 21 | * Although this is not required, the author would appreciate being notified of, 22 | * and receiving any modifications you may make to the source code that might serve 23 | * the general public. 24 | */ 25 | 26 | /** 27 | * \file 28 | * Contains code macros for the processor VAX compatibility instructions. 29 | * 30 | * X-1.3 Camiel Vanderhoeven 11-APR-2007 31 | * Moved all data that should be saved to a state file to a structure 32 | * "state". 33 | * 34 | * X-1.2 Camiel Vanderhoeven 30-MAR-2007 35 | * Added old changelog comments. 36 | * 37 | * X-1.1 Camiel Vanderhoeven 18-FEB-2007 38 | * File created. Contains code previously found in AlphaCPU.h 39 | * 40 | * \author Camiel Vanderhoeven (camiel@camicom.com / http://www.camicom.com) 41 | **/ 42 | #define DO_RC state.r[REG_1] = state.bIntrFlag ? 1 : 0; \ 43 | state.bIntrFlag = false; 44 | 45 | #define DO_RS state.r[REG_1] = state.bIntrFlag ? 1 : 0; \ 46 | state.bIntrFlag = true; 47 | -------------------------------------------------------------------------------- /src/gui/keymap.h: -------------------------------------------------------------------------------- 1 | /* ES40 emulator. 2 | * Copyright (C) 2007-2008 by the ES40 Emulator Project 3 | * 4 | * WWW : http://sourceforge.net/projects/es40 5 | * E-mail : camiel@camicom.com 6 | * 7 | * This file is based upon Bochs. 8 | * 9 | * Copyright (C) 2002 MandrakeSoft S.A. 10 | * 11 | * MandrakeSoft S.A. 12 | * 43, rue d'Aboukir 13 | * 75002 Paris - France 14 | * http://www.linux-mandrake.com/ 15 | * http://www.mandrakesoft.com/ 16 | * 17 | * This library is free software; you can redistribute it and/or 18 | * modify it under the terms of the GNU Lesser General Public 19 | * License as published by the Free Software Foundation; either 20 | * version 2 of the License, or (at your option) any later version. 21 | * 22 | * This library is distributed in the hope that it will be useful, 23 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 24 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 25 | * Lesser General Public License for more details. 26 | * 27 | * You should have received a copy of the GNU Lesser General Public 28 | * License along with this library; if not, write to the Free Software 29 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 30 | */ 31 | 32 | /** 33 | * \file 34 | * Contains the definitions for the bx_keymap_c class used for keyboard 35 | * interfacing with SDL and other device interfaces. 36 | * 37 | * $Id$ 38 | * 39 | * X-1.7 Camiel Vanderhoeven 26-MAR-2008 40 | * Fix compiler warnings. 41 | * 42 | * X-1.6 Camiel Vanderhoeven 14-MAR-2008 43 | * Formatting. 44 | * 45 | * X-1.4 Camiel Vanderhoeven 02-JAN-2008 46 | * Comments. 47 | * 48 | * X-1.3 Camiel Vanderhoeven 10-DEC-2007 49 | * Use Configurator. 50 | * 51 | * X-1.2 Camiel Vanderhoeven 7-DEC-2007 52 | * Code cleanup. 53 | * 54 | * X-1.1 Camiel Vanderhoeven 6-DEC-2007 55 | * Initial version for ES40 emulator. 56 | * 57 | **/ 58 | #include "../Configurator.h" 59 | 60 | // In case of unknown symbol 61 | #define BX_KEYMAP_UNKNOWN 0xFFFFFFFF 62 | 63 | /// Structure of an element of the keymap table 64 | typedef struct 65 | { 66 | u32 baseKey; // base key 67 | u32 modKey; // modifier key that must be held down 68 | s32 ascii; // ascii equivalent, if any 69 | u32 hostKey; // value that the host's OS or library recognizes 70 | } BXKeyEntry; 71 | 72 | /** 73 | * \brief Keymap, used to map host keys to scancodes. 74 | **/ 75 | class bx_keymap_c 76 | { 77 | public: 78 | bx_keymap_c(CConfigurator* cfg); 79 | ~ bx_keymap_c(void); 80 | 81 | void loadKeymap(u32 stringToSymbol (const char*)); 82 | void loadKeymap(u32 stringToSymbol (const char*), 83 | const char *filename); 84 | bool isKeymapLoaded(); 85 | 86 | BXKeyEntry* findHostKey(u32 hostkeynum); 87 | BXKeyEntry* findAsciiChar(u8 ascii); 88 | const char* getBXKeyName(u32 key); 89 | private: 90 | u32 convertStringToBXKey(const char* ); 91 | CConfigurator* myCfg; 92 | 93 | BXKeyEntry* keymapTable; 94 | u16 keymapCount; 95 | }; 96 | 97 | extern bx_keymap_c* bx_keymap; 98 | -------------------------------------------------------------------------------- /src/gui/plugin.h: -------------------------------------------------------------------------------- 1 | /* ES40 emulator. 2 | * Copyright (C) 2007-2008 by the ES40 Emulator Project 3 | * 4 | * WWW : http://sourceforge.net/projects/es40 5 | * E-mail : camiel@camicom.com 6 | * 7 | * Copyright (C) 2002 MandrakeSoft S.A. 8 | * 9 | * MandrakeSoft S.A. 10 | * 43, rue d'Aboukir 11 | * 75002 Paris - France 12 | * http://www.linux-mandrake.com/ 13 | * http://www.mandrakesoft.com/ 14 | * 15 | * This library is free software; you can redistribute it and/or 16 | * modify it under the terms of the GNU Lesser General Public 17 | * License as published by the Free Software Foundation; either 18 | * version 2 of the License, or (at your option) any later version. 19 | * 20 | * This library is distributed in the hope that it will be useful, 21 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 22 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 23 | * Lesser General Public License for more details. 24 | * 25 | * You should have received a copy of the GNU Lesser General Public 26 | * License along with this library; if not, write to the Free Software 27 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 28 | */ 29 | 30 | /** 31 | * \file 32 | * Contains the definitions for use with bx_..._gui_c classes used for 33 | * interfacing with SDL and other device interfaces. 34 | * 35 | * $Id$ 36 | * 37 | * X-1.5 Camiel Vanderhoeven 20-JAN-2008 38 | * Added X11 GUI. 39 | * 40 | * X-1.4 Camiel Vanderhoeven 19-JAN-2008 41 | * Added win32 GUI. 42 | * 43 | * X-1.3 Camiel Vanderhoeven 02-JAN-2008 44 | * Comments. 45 | * 46 | * X-1.2 Camiel Vanderhoeven 10-DEC-2007 47 | * Simplified this for use with ES40. 48 | * 49 | * X-1.1 Camiel Vanderhoeven 6-DEC-2007 50 | * Initial version for ES40 emulator. 51 | * 52 | **/ 53 | 54 | ///////////////////////////////////////////////////////////////////////// 55 | // 56 | // This file provides macros and types needed for plugins. It is based on 57 | // the plugin.h file from plex86, but with significant changes to make 58 | // it work in Bochs. 59 | // Plex86 is Copyright (C) 1999-2000 The plex86 developers team 60 | // 61 | ///////////////////////////////////////////////////////////////////////// 62 | #ifndef __PLUGIN_H 63 | #define __PLUGIN_H 64 | 65 | #define PLUG_load_plugin(cfg, name) \ 66 | { \ 67 | lib##name##_LTX_plugin_init(cfg); \ 68 | } 69 | #define PLUG_unload_plugin(name) \ 70 | { \ 71 | lib##name##_LTX_plugin_fini(); \ 72 | } 73 | 74 | #define DECLARE_PLUGIN_INIT_FINI_FOR_MODULE(mod) \ 75 | int lib##mod##_LTX_plugin_init(CConfigurator* cfg); \ 76 | void lib##mod##_LTX_plugin_fini(void); 77 | 78 | #if defined(HAVE_SDL) 79 | DECLARE_PLUGIN_INIT_FINI_FOR_MODULE(sdl) 80 | #endif 81 | #if defined(_WIN32) 82 | DECLARE_PLUGIN_INIT_FINI_FOR_MODULE(win32) 83 | #endif 84 | #if defined(HAVE_X11) 85 | DECLARE_PLUGIN_INIT_FINI_FOR_MODULE(x11) 86 | #endif 87 | #endif /* __PLUGIN_H */ 88 | -------------------------------------------------------------------------------- /src/gui/scancodes.h: -------------------------------------------------------------------------------- 1 | /* ES40 emulator. 2 | * Copyright (C) 2007-2008 by the ES40 Emulator Project 3 | * 4 | * WWW : http://sourceforge.net/projects/es40 5 | * E-mail : camiel@camicom.com 6 | * 7 | * This file is based upon Bochs. 8 | * 9 | * Copyright (C) 2002 MandrakeSoft S.A. 10 | * 11 | * MandrakeSoft S.A. 12 | * 43, rue d'Aboukir 13 | * 75002 Paris - France 14 | * http://www.linux-mandrake.com/ 15 | * http://www.mandrakesoft.com/ 16 | * 17 | * This library is free software; you can redistribute it and/or 18 | * modify it under the terms of the GNU Lesser General Public 19 | * License as published by the Free Software Foundation; either 20 | * version 2 of the License, or (at your option) any later version. 21 | * 22 | * This library is distributed in the hope that it will be useful, 23 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 24 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 25 | * Lesser General Public License for more details. 26 | * 27 | * You should have received a copy of the GNU Lesser General Public 28 | * License along with this library; if not, write to the Free Software 29 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 30 | */ 31 | 32 | /** 33 | * \file 34 | * Contains definitions for scancode table. 35 | * 36 | * $Id$ 37 | * X-1.3 Camiel Vanderhoeven 02-JAN-2008 38 | * Comments. 39 | * 40 | * X-1.1 Camiel Vanderhoeven 6-DEC-2007 41 | * Initial version for ES40 emulator. 42 | * 43 | **/ 44 | #include "gui.h" 45 | #ifndef BX_SCANCODES_H 46 | #define BX_SCANCODES_H 47 | 48 | // Translation table of the 8042 49 | extern unsigned char translation8042[256]; 50 | 51 | typedef struct 52 | { 53 | const char* make; 54 | const char* brek; 55 | } scancode; 56 | 57 | // Scancodes table 58 | extern scancode scancodes[BX_KEY_NBKEYS][3]; 59 | #endif 60 | -------------------------------------------------------------------------------- /src/lockstep.h: -------------------------------------------------------------------------------- 1 | /* ES40 emulator. 2 | * Copyright (C) 2007 by Camiel Vanderhoeven 3 | * 4 | * Website: www.camicom.com 5 | * E-mail : camiel@camicom.com 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2 10 | * of the License, or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | * 21 | * Although this is not required, the author would appreciate being notified of, 22 | * and receiving any modifications you may make to the source code that might serve 23 | * the general public. 24 | */ 25 | 26 | /** 27 | * \file 28 | * Contains telnet declarations for the lock-step code. 29 | * 30 | * X-1.2 Camiel Vanderhoeven 30-MAR-2007 31 | * Added old changelog comments. 32 | * 33 | * X-1.1 Camiel Vanderhoeven 28-FEB-2007 34 | * Created to support lockstep debugging. 35 | * 36 | * \author Camiel Vanderhoeven (camiel@camicom.com / http://www.camicom.com) 37 | **/ 38 | #if !defined(INCLUDED_LOCKSTEP_H) 39 | #define INCLUDED_LOCKSTEP_H 40 | 41 | #include "telnet.h" 42 | 43 | #if defined(IDB) && (defined(LS_MASTER) || defined(LS_SLAVE)) 44 | extern int ls_Socket; 45 | 46 | #if defined(LS_MASTER) 47 | extern char ls_IP[30]; 48 | #else 49 | extern int ls_listenSocket; 50 | #endif 51 | void lockstep_init(); 52 | void lockstep_sync_m2s(char* s); 53 | void lockstep_sync_s2m(char* s); 54 | void lockstep_compare(char* s); 55 | void lockstep_send(char* s); 56 | void lockstep_receive(char* s, int sz); 57 | #endif // defined(IDB) && (defined(LS_MASTER) || defined(LS_SLAVE)) 58 | #endif // !defined(INCLUDED_LOCKSTEP_H) 59 | --------------------------------------------------------------------------------