diff --git a/ports/ports/dosbox.inc b/ports/ports/dosbox.inc new file mode 100644 index 000000000..904998adc --- /dev/null +++ b/ports/ports/dosbox.inc @@ -0,0 +1,4 @@ +DOSBOX_REV := 3837 +DOSBOX_VERSION := svn-$(DOSBOX_REV) +DOSBOX := dosbox-$(DOSBOX_VERSION) + diff --git a/ports/ports/dosbox.mk b/ports/ports/dosbox.mk new file mode 100644 index 000000000..98ce5c611 --- /dev/null +++ b/ports/ports/dosbox.mk @@ -0,0 +1,19 @@ +include ports/dosbox.inc + +DOSBOX_SVN_URL = http://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk + +# +# Interface to top-level prepare Makefile +# +PORTS += $(DOSBOX) + +prepare:: $(CONTRIB_DIR)/$(DOSBOX) + +# +# Port-specific local rules +# +$(CONTRIB_DIR)/$(DOSBOX): + $(ECHO) "checking out 'dosbox rev. $(DOSBOX_REV)' to '$@'" + $(VERBOSE)svn export $(DOSBOX_SVN_URL)@$(DOSBOX_REV) $@ + $(VERBOSE)for i in src/app/dosbox/patches/*.patch; do \ + patch -N -p0 < $$i; done || true diff --git a/ports/run/dosbox.run b/ports/run/dosbox.run new file mode 100644 index 000000000..1db8b876b --- /dev/null +++ b/ports/run/dosbox.run @@ -0,0 +1,158 @@ +# +# Build +# + + +set build_components { + core init + drivers/timer + drivers/audio_out + server/tar_fs + drivers/framebuffer drivers/pci drivers/input + app/dosbox +} + +lappend_if [have_spec acpi] build_components drivers/acpi + +build $build_components + +create_boot_directory + +# +# Generate config +# + +append config { + + + + + + + + + + + + + + + + + } + +append_if [have_spec sdl] config { + + + + + + + } + +append_if [have_spec acpi] config { + + + + + + + + } + +append_if [have_spec vesa] config { + + + + + + + + + } + +append_if [have_spec pl11x] config { + + + + } + +append_if [have_spec ps2] config { + + + + } + +append config { + + } +append_if [have_spec acpi] config { + + + + + } +append config { + + + + + + + + + + + + + + + + + + + + +} + +install_config $config + +if {![file exists bin/dosbox.tar]} { + puts "" + puts "You need to provide 'bin/dosbox.tar' that contains the DOS game you want to" + puts "play. Mount the directory from within DosBox by entering 'mount C: '," + puts "change CWD to C: and play the game!" + puts "" + puts "(Note: for all games, which need a R/W filesystem, you cannot use 'tar_fs'.)" + puts "" + exit 1 +} + +# +# Boot modules +# + +# generic modules +set boot_modules { + core init timer audio_out_drv + tar_fs ld.lib.so + libc_fs.lib.so libc.lib.so libc_log.lib.so + libm.lib.so lwip.lib.so libpng.lib.so + stdcxx.lib.so sdl.lib.so sdl_net.lib.so pthread.lib.so zlib.lib.so + dosbox dosbox.tar +} + +# platform-specific modules +lappend_if [have_spec nova] boot_modules pci_device_pd +lappend_if [have_spec acpi] boot_modules acpi_drv +lappend_if [have_spec linux] boot_modules fb_sdl +lappend_if [have_spec pci] boot_modules pci_drv +lappend_if [have_spec vesa] boot_modules fb_drv +lappend_if [have_spec ps2] boot_modules ps2_drv +lappend_if [have_spec pl11x] boot_modules fb_drv + +build_boot_image $boot_modules + +append qemu_args " -m 256 -soundhw ac97 " + +run_genode_until forever diff --git a/ports/src/app/dosbox/config.h b/ports/src/app/dosbox/config.h new file mode 100644 index 000000000..f1186bf4f --- /dev/null +++ b/ports/src/app/dosbox/config.h @@ -0,0 +1,294 @@ +/* config.h. Generated from config.h.in by configure. */ +/* config.h.in. Generated from configure.ac by autoheader. */ + + +/* + * Copyright (C) 2002-2013 The DOSBox Team + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Library General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + + +/* Define if building universal (internal helper macro) */ +/* #undef AC_APPLE_UNIVERSAL_BUILD */ + +/* Compiling on BSD */ +/* Genode's libc is based on FreeBSD 8.2 */ +#define BSD 1 + +/* Determines if the compilers supports always_inline attribute. */ +/* #undef C_ATTRIBUTE_ALWAYS_INLINE */ + +/* Determines if the compilers supports fastcall attribute. */ +/* #undef C_ATTRIBUTE_FASTCALL */ + +/* Define to 1 to use inlined memory functions in cpu core */ +/* #undef C_CORE_INLINE */ + +/* Define to 1 to enable internal debugger, requires libcurses */ +/* #undef C_DEBUG */ + +/* Define to 1 if you want serial passthrough support (Win32, Posix and OS/2). + */ +/* #undef C_DIRECTSERIAL */ + +/* Define to 1 to use x86 dynamic cpu core */ +/* #undef C_DYNAMIC_X86 */ + +/* Define to 1 to use recompiling cpu core. Can not be used together with the + dynamic-x86 core */ +#define C_DYNREC 1 + +/* Define to 1 to enable floating point emulation */ +#define C_FPU 1 + +/* Define to 1 to use a x86 assembly fpu core */ +/* #undef C_FPU_X86 */ + +/* Determines if the compilers supports attributes for structures. */ +#define C_HAS_ATTRIBUTE 1 + +/* Determines if the compilers supports __builtin_expect for branch + prediction. */ +#define C_HAS_BUILTIN_EXPECT 1 + +/* Define to 1 if you have the mprotect function */ +#define C_HAVE_MPROTECT 1 + +/* Define to 1 to enable heavy debugging, also have to enable C_DEBUG */ +/* #undef C_HEAVY_DEBUG */ + +/* Define to 1 to enable IPX over Internet networking, requires SDL_net */ +#define C_IPX 1 + +/* Define to 1 to enable internal modem support, requires SDL_net */ +#define C_MODEM 1 + +/* Define to 1 to use opengl display output support */ +/* #undef C_OPENGL */ + +/* Define to 1 to enable SDL_sound support */ +/* #undef C_SDL_SOUND */ + +/* Define to 1 if you have setpriority support */ +#define C_SET_PRIORITY 1 + +/* Define to 1 to enable screenshots, requires libpng */ +#define C_SSHOT 1 + +/* The type of cpu this target has */ +/* we define it ourself */ +/* #undef C_TARGETCPU */ + +/* Define to 1 to use a unaligned memory access */ +#define C_UNALIGNED_MEMORY 1 + +/* define to 1 if you have XKBlib.h and X11 lib */ +/* #undef C_X11_XKB */ + +/* libm doesn't include powf */ +/* #undef DB_HAVE_NO_POWF */ + +/* struct dirent has d_type */ +#define DIRENT_HAS_D_TYPE 1 + +/* environ can be included */ +/* #undef ENVIRON_INCLUDED */ + +/* environ can be linked */ +/* #undef ENVIRON_LINKED */ + +/* Define to 1 to use ALSA for MIDI */ +/* #undef HAVE_ALSA */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_DDRAW_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_INTTYPES_H 1 + +/* Define to 1 if you have the `asound' library (-lasound). */ +/* #undef HAVE_LIBASOUND */ + +/* Define to 1 if you have the header file. */ +#define HAVE_MEMORY_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_NETINET_IN_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_PWD_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STDINT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STDLIB_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STRINGS_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STRING_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_SOCKET_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_STAT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_TYPES_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_UNISTD_H 1 + +/* Compiling on GNU/Linux */ +/* #undef LINUX */ + +/* Compiling on Mac OS X */ +/* #undef MACOSX */ + +/* Compiling on OS/2 EMX */ +/* #undef OS2 */ + +/* Name of package */ +#define PACKAGE "dosbox" + +/* Define to the address where bug reports for this package should be sent. */ +#define PACKAGE_BUGREPORT "" + +/* Define to the full name of this package. */ +#define PACKAGE_NAME "dosbox" + +/* Define to the full name and version of this package. */ +#define PACKAGE_STRING "dosbox SVN" + +/* Define to the one symbol short name of this package. */ +#define PACKAGE_TARNAME "dosbox" + +/* Define to the home page for this package. */ +#define PACKAGE_URL "" + +/* Define to the version of this package. */ +#define PACKAGE_VERSION "SVN" + +#include + +/* Define to 1 if your declares `struct tm'. */ +/* #undef TM_IN_SYS_TIME */ + +/* Version number of package */ +#define VERSION "SVN" + +/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most + significant byte first (like Motorola and SPARC, unlike Intel). */ +#if defined AC_APPLE_UNIVERSAL_BUILD +# if defined __BIG_ENDIAN__ +# define WORDS_BIGENDIAN 1 +# endif +#else +# ifndef WORDS_BIGENDIAN +/* # undef WORDS_BIGENDIAN */ +# endif +#endif + +/* Define to empty if `const' does not conform to ANSI C. */ +/* #undef const */ + +/* Define to `__inline__' or `__inline' if that's what the C compiler + calls it, or to nothing if 'inline' is not supported under any name. */ +#ifndef __cplusplus +/* #undef inline */ +#endif + +/* Define to `unsigned int' if does not define. */ +/* #undef size_t */ + +/* Define to `int` if you don't have socklen_t */ +/* #undef socklen_t */ + +#if C_ATTRIBUTE_ALWAYS_INLINE +#define INLINE inline __attribute__((always_inline)) +#else +#define INLINE inline +#endif + +#if C_ATTRIBUTE_FASTCALL +#define DB_FASTCALL __attribute__((fastcall)) +#else +#define DB_FASTCALL +#endif + +#if C_HAS_ATTRIBUTE +#define GCC_ATTRIBUTE(x) __attribute__ ((x)) +#else +#define GCC_ATTRIBUTE(x) /* attribute not supported */ +#endif + +#if C_HAS_BUILTIN_EXPECT +#define GCC_UNLIKELY(x) __builtin_expect((x),0) +#define GCC_LIKELY(x) __builtin_expect((x),1) +#else +#define GCC_UNLIKELY(x) (x) +#define GCC_LIKELY(x) (x) +#endif + + +typedef double Real64; + +#if SIZEOF_UNSIGNED_CHAR != 1 +# error "sizeof (unsigned char) != 1" +#else + typedef unsigned char Bit8u; + typedef signed char Bit8s; +#endif + +#if SIZEOF_UNSIGNED_SHORT != 2 +# error "sizeof (unsigned short) != 2" +#else + typedef unsigned short Bit16u; + typedef signed short Bit16s; +#endif + +#if SIZEOF_UNSIGNED_INT == 4 + typedef unsigned int Bit32u; + typedef signed int Bit32s; +#elif SIZEOF_UNSIGNED_LONG == 4 + typedef unsigned long Bit32u; + typedef signed long Bit32s; +#else +# error "can't find sizeof(type) of 4 bytes!" +#endif + +#if SIZEOF_UNSIGNED_LONG == 8 + typedef unsigned long Bit64u; + typedef signed long Bit64s; +#elif SIZEOF_UNSIGNED_LONG_LONG == 8 + typedef unsigned long long Bit64u; + typedef signed long long Bit64s; +#else +# error "can't find data type of 8 bytes" +#endif + +#if SIZEOF_INT_P == 4 + typedef Bit32u Bitu; + typedef Bit32s Bits; +#else + typedef Bit64u Bitu; + typedef Bit64s Bits; +#endif + + diff --git a/ports/src/app/dosbox/patches/bios.patch b/ports/src/app/dosbox/patches/bios.patch new file mode 100644 index 000000000..5dba156b5 --- /dev/null +++ b/ports/src/app/dosbox/patches/bios.patch @@ -0,0 +1,35 @@ +--- contrib/dosbox-svn-3837/src/ints/bios.cpp.orig 2013-10-21 21:45:59.350897646 +0200 ++++ contrib/dosbox-svn-3837/src/ints/bios.cpp 2013-10-21 22:02:03.526912653 +0200 +@@ -32,7 +32,7 @@ + #include "setup.h" + #include "serialport.h" + #include +-#include ++//#include + + + /* if mem_systems 0 then size_extended is reported as the real size else +@@ -490,11 +490,11 @@ + + static void BIOS_HostTimeSync() { + /* Setup time and date */ +- struct timeb timebuffer; +- ftime(&timebuffer); ++ struct timeval tv; ++ gettimeofday(&tv, NULL); + + struct tm *loctime; +- loctime = localtime (&timebuffer.time); ++ loctime = localtime (&tv.tv_sec); + + /* + loctime->tm_hour = 23; +@@ -513,7 +513,7 @@ + loctime->tm_hour*3600*1000+ + loctime->tm_min*60*1000+ + loctime->tm_sec*1000+ +- timebuffer.millitm))*(((double)PIT_TICK_RATE/65536.0)/1000.0)); ++ (tv.tv_usec * 1000)))*(((double)PIT_TICK_RATE/65536.0)/1000.0)); + mem_writed(BIOS_TIMER,ticks); + } + diff --git a/ports/src/app/dosbox/patches/int10_vesa.patch b/ports/src/app/dosbox/patches/int10_vesa.patch new file mode 100644 index 000000000..872195fd8 --- /dev/null +++ b/ports/src/app/dosbox/patches/int10_vesa.patch @@ -0,0 +1,11 @@ +--- contrib/dosbox-svn-3837/src/ints/int10_vesa.cpp.orig 2013-10-21 16:57:31.889803364 +0200 ++++ contrib/dosbox-svn-3837/src/ints/int10_vesa.cpp 2013-10-21 16:57:36.777803442 +0200 +@@ -45,7 +45,7 @@ + static char string_oem[]="S3 Incorporated. Trio64"; + static char string_vendorname[]="DOSBox Development Team"; + static char string_productname[]="DOSBox - The DOS Emulator"; +-static char string_productrev[]="DOSBox "VERSION; ++static char string_productrev[]="DOSBox " VERSION; + + #ifdef _MSC_VER + #pragma pack (1) diff --git a/ports/src/app/dosbox/patches/sdl_mapper.cpp.patch b/ports/src/app/dosbox/patches/sdl_mapper.cpp.patch new file mode 100644 index 000000000..e94d44ca3 --- /dev/null +++ b/ports/src/app/dosbox/patches/sdl_mapper.cpp.patch @@ -0,0 +1,20 @@ +--- contrib/dosbox-svn-3837/src/gui/sdl_mapper.cpp.orig 2013-10-30 13:57:07.000000000 +0100 ++++ contrib/dosbox-svn-3837/src/gui/sdl_mapper.cpp 2013-10-30 15:35:50.563742200 +0100 +@@ -416,7 +416,7 @@ + } + #if !defined (WIN32) && !defined (MACOSX) && !defined(OS2) + /* Linux adds 8 to all scancodes */ +- else key-=8; ++ //else key-=8; + #endif + #if defined (WIN32) + switch (key) { +@@ -2449,6 +2449,8 @@ + } + } + #endif ++ /* Genode's input keycodes match these of evdev */ ++ evdev_input = true; + if (evdev_input) { + sdlkey_map[0x67]=SDLK_UP; + sdlkey_map[0x6c]=SDLK_DOWN; diff --git a/ports/src/app/dosbox/target.mk b/ports/src/app/dosbox/target.mk new file mode 100644 index 000000000..7fd7abbd0 --- /dev/null +++ b/ports/src/app/dosbox/target.mk @@ -0,0 +1,58 @@ +TARGET = dosbox + +include $(REP_DIR)/ports/dosbox.inc +DOSBOX_DIR = $(REP_DIR)/contrib/$(DOSBOX) + +SRC_CC_cpu = $(notdir $(wildcard $(DOSBOX_DIR)/src/cpu/*.cpp)) +SRC_CC_debug = $(notdir $(wildcard $(DOSBOX_DIR)/src/debug/*.cpp)) +FILTER_OUT_dos = cdrom_aspi_win32.cpp cdrom_ioctl_linux.cpp cdrom_ioctl_os2.cpp \ + cdrom_ioctl_win32.cpp +SRC_CC_dos = $(filter-out $(FILTER_OUT_dos),$(notdir $(wildcard $(DOSBOX_DIR)/src/dos/*.cpp))) +SRC_CC_fpu = $(notdir $(DOSBOX_DIR)/src/fpu/fpu.cpp) +SRC_CC_gui = $(notdir $(wildcard $(DOSBOX_DIR)/src/gui/*.cpp)) +FILTER_OUT_hw = opl.cpp +SRC_CC_hw = $(filter-out $(FILTER_OUT_hw),$(notdir $(wildcard $(DOSBOX_DIR)/src/hardware/*.cpp))) +SRC_CC_hw_ser = $(notdir $(wildcard $(DOSBOX_DIR)/src/hardware/serialport/*.cpp)) +SRC_CC_ints = $(notdir $(wildcard $(DOSBOX_DIR)/src/ints/*.cpp)) +SRC_CC_misc = $(notdir $(wildcard $(DOSBOX_DIR)/src/misc/*.cpp)) +SRC_CC_shell = $(notdir $(wildcard $(DOSBOX_DIR)/src/shell/*.cpp)) + +SRC_CC = $(notdir $(DOSBOX_DIR)/src/dosbox.cpp) +SRC_CC += $(SRC_CC_cpu) $(SRC_CC_debug) $(SRC_CC_dos) $(SRC_CC_fpu) $(SRC_CC_gui) \ + $(SRC_CC_hw) $(SRC_CC_hw_ser) $(SRC_CC_ints) $(SRC_CC_ints) $(SRC_CC_misc) \ + $(SRC_CC_shell) + +vpath %.cpp $(DOSBOX_DIR)/src +vpath %.cpp $(DOSBOX_DIR)/src/cpu +vpath %.cpp $(DOSBOX_DIR)/src/debug +vpath %.cpp $(DOSBOX_DIR)/src/dos +vpath %.cpp $(DOSBOX_DIR)/src/fpu +vpath %.cpp $(DOSBOX_DIR)/src/gui +vpath %.cpp $(DOSBOX_DIR)/src/hardware +vpath %.cpp $(DOSBOX_DIR)/src/hardware/serialport +vpath %.cpp $(DOSBOX_DIR)/src/ints +vpath %.cpp $(DOSBOX_DIR)/src/misc +vpath %.cpp $(DOSBOX_DIR)/src/shell + +INC_DIR += $(PRG_DIR) +INC_DIR += $(DOSBOX_DIR)/include +INC_DIR += $(addprefix $(DOSBOX_DIR)/src, cpu debug dos fpu gui hardware hardware/serialport \ + ints misc shell) + +CC_OPT = -DHAVE_CONFIG_H -D_GNU_SOURCE=1 -D_REENTRANT +ifeq ($(filter-out $(SPECS),x86_32),) +INC_DIR += $(PRG_DIR)/x86_32 +CC_OPT += -DC_TARGETCPU=X86 +else ifeq ($(filter-out $(SPECS),x86_64),) +INC_DIR += $(PRG_DIR)/x86_64 +CC_OPT += -DC_TARGETCPU=X86_64 +endif + +CC_WARN = -Wall +CC_WARN += -Wno-unused-variable -Wno-unused-function -Wno-switch -Wno-unused-value \ + -Wno-unused-but-set-variable -Wno-format -Wno-maybe-uninitialized \ + -Wno-sign-compare -Wno-narrowing -Wno-missing-braces -Wno-array-bounds \ + -Wno-parentheses + +LIBS += libc libm libpng sdl sdl_net stdcxx zlib +LIBS += libc_log libc_fs libc_lwip_nic_dhcp config_args diff --git a/ports/src/app/dosbox/x86_32/size_defs.h b/ports/src/app/dosbox/x86_32/size_defs.h new file mode 100644 index 000000000..931fcf3fb --- /dev/null +++ b/ports/src/app/dosbox/x86_32/size_defs.h @@ -0,0 +1,17 @@ +/* The size of `int *', as computed by sizeof. */ +#define SIZEOF_INT_P 4 + +/* The size of `unsigned char', as computed by sizeof. */ +#define SIZEOF_UNSIGNED_CHAR 1 + +/* The size of `unsigned int', as computed by sizeof. */ +#define SIZEOF_UNSIGNED_INT 4 + +/* The size of `unsigned long', as computed by sizeof. */ +#define SIZEOF_UNSIGNED_LONG 4 + +/* The size of `unsigned long long', as computed by sizeof. */ +#define SIZEOF_UNSIGNED_LONG_LONG 8 + +/* The size of `unsigned short', as computed by sizeof. */ +#define SIZEOF_UNSIGNED_SHORT 2 diff --git a/ports/src/app/dosbox/x86_64/size_defs.h b/ports/src/app/dosbox/x86_64/size_defs.h new file mode 100644 index 000000000..500278c9a --- /dev/null +++ b/ports/src/app/dosbox/x86_64/size_defs.h @@ -0,0 +1,17 @@ +/* The size of `int *', as computed by sizeof. */ +#define SIZEOF_INT_P 8 + +/* The size of `unsigned char', as computed by sizeof. */ +#define SIZEOF_UNSIGNED_CHAR 1 + +/* The size of `unsigned int', as computed by sizeof. */ +#define SIZEOF_UNSIGNED_INT 4 + +/* The size of `unsigned long', as computed by sizeof. */ +#define SIZEOF_UNSIGNED_LONG 8 + +/* The size of `unsigned long long', as computed by sizeof. */ +#define SIZEOF_UNSIGNED_LONG_LONG 8 + +/* The size of `unsigned short', as computed by sizeof. */ +#define SIZEOF_UNSIGNED_SHORT 2