From f14932c362b91ceb75e3d6c0b052e97d3e073a3f Mon Sep 17 00:00:00 2001 From: Stefanos Kornilios Mitsis Poiitids Date: Tue, 30 Sep 2014 12:00:46 +0300 Subject: [PATCH] Building on osx w/o rec or rend --- core/deps/coreio/coreio.cpp | 4 +- core/hw/mem/_vmem.cpp | 16 ++++-- core/hw/pvr/Renderer_if.cpp | 2 +- core/hw/pvr/Renderer_if.h | 8 ++- core/hw/pvr/ta_vtx.cpp | 2 +- core/linux-dist/main.cpp | 22 +++++--- core/linux/common.cpp | 16 ++++-- core/linux/nixprof.cpp | 2 +- core/nullDC.cpp | 2 +- core/rend/norend/norend.cpp | 10 +++- core/rend/rend.h | 10 +++- core/stdclass.h | 3 +- shell/mac86/Makefile | 102 ++++++++++++++++++++++++++++++++++++ 13 files changed, 174 insertions(+), 25 deletions(-) create mode 100644 shell/mac86/Makefile diff --git a/core/deps/coreio/coreio.cpp b/core/deps/coreio/coreio.cpp index afc54e905..f726bb17c 100644 --- a/core/deps/coreio/coreio.cpp +++ b/core/deps/coreio/coreio.cpp @@ -17,7 +17,7 @@ #include #include #include - #include + #include #include #include #endif @@ -262,4 +262,4 @@ size_t core_fsize(core_file* fc) else { return HTTP_GET(f->host, f->port, f->path, 0, 0,0); } -} \ No newline at end of file +} diff --git a/core/hw/mem/_vmem.cpp b/core/hw/mem/_vmem.cpp index e54f6a78a..2e0239856 100644 --- a/core/hw/mem/_vmem.cpp +++ b/core/hw/mem/_vmem.cpp @@ -570,7 +570,9 @@ error: u32 sz= 512*1024*1024 + sizeof(Sh4RCB) + ARAM_SIZE + 0x10000; void* rv=mmap(0, sz, PROT_NONE, MAP_PRIVATE | MAP_ANON, -1, 0); + verify(rv != NULL); munmap(rv,sz); + printf("%X\n",rv); return (u8*)rv + 0x10000 - unat(rv)%0x10000;//align to 64 KB (Needed for linaro mmap not to extend to next region) } #endif @@ -590,8 +592,13 @@ void _vmem_bm_reset() #else mprotect(p_sh4rcb, sizeof(p_sh4rcb->fpcb), PROT_NONE); madvise(p_sh4rcb,sizeof(p_sh4rcb->fpcb),MADV_DONTNEED); + #ifdef MADV_REMOVE + //Linux, Android madvise(p_sh4rcb,sizeof(p_sh4rcb->fpcb),MADV_REMOVE); - //madvise(p_sh4rcb,sizeof(p_sh4rcb->fpcb),MADV_FREE); + #else + //OSX, ? + madvise(p_sh4rcb,sizeof(p_sh4rcb->fpcb),MADV_FREE); + #endif #endif printf("Freeing fpcb\n"); @@ -631,6 +638,10 @@ bool _vmem_reserve() verify((sizeof(Sh4RCB)%PAGE_SIZE)==0); virt_ram_base=(u8*)_nvmem_alloc_mem(); + + if (virt_ram_base==0) + return false; + p_sh4rcb=(Sh4RCB*)virt_ram_base; #if HOST_OS==OS_WINDOWS @@ -644,9 +655,6 @@ bool _vmem_reserve() #endif virt_ram_base+=sizeof(Sh4RCB); - if (virt_ram_base==0) - return false; - //Area 0 //[0x00000000 ,0x00800000) -> unused unused_buffer(0x00000000,0x00800000); diff --git a/core/hw/pvr/Renderer_if.cpp b/core/hw/pvr/Renderer_if.cpp index 348c7a030..d4b6e83aa 100644 --- a/core/hw/pvr/Renderer_if.cpp +++ b/core/hw/pvr/Renderer_if.cpp @@ -219,7 +219,7 @@ void rend_end_wait() bool rend_init() { -#if NO_REND +#ifdef NO_REND rend = rend_norend(); #else diff --git a/core/hw/pvr/Renderer_if.h b/core/hw/pvr/Renderer_if.h index d95fcecb3..0d181a86a 100644 --- a/core/hw/pvr/Renderer_if.h +++ b/core/hw/pvr/Renderer_if.h @@ -17,6 +17,12 @@ void rend_set_fb_scale(float x,float y); void rend_text_invl(vram_block* bl); +#ifdef GLuint +GLuint +#else +u32 +#endif +GetTexture(TSP tsp,TCW tcw); /////// @@ -43,4 +49,4 @@ struct Renderer Renderer* rend_D3D11(); Renderer* rend_GLES2(); -Renderer* rend_norend(); \ No newline at end of file +Renderer* rend_norend(); diff --git a/core/hw/pvr/ta_vtx.cpp b/core/hw/pvr/ta_vtx.cpp index 7a813b7aa..5f03bfe7a 100644 --- a/core/hw/pvr/ta_vtx.cpp +++ b/core/hw/pvr/ta_vtx.cpp @@ -8,7 +8,7 @@ #include "ta.h" #include "ta_ctx.h" #include "pvr_mem.h" -#include "rend/gles/gles.h" +//#include "rend/gles/gles.h" #include "Renderer_if.h" u32 ta_type_lut[256]; diff --git a/core/linux-dist/main.cpp b/core/linux-dist/main.cpp index 44d20c2f7..c53c05e74 100755 --- a/core/linux-dist/main.cpp +++ b/core/linux-dist/main.cpp @@ -24,7 +24,7 @@ #include #endif -#if !defined(ANDROID) +#if !defined(ANDROID) && 0 #include #include #include @@ -134,6 +134,7 @@ void SetupInput() lt[port]=0; } +#if 0 if (true) { #ifdef TARGET_PANDORA const char* device = "/dev/input/event4"; @@ -154,10 +155,10 @@ void SetupInput() else perror("evdev open"); } - +#endif // Open joystick device JoyFD = open("/dev/input/js0",O_RDONLY); - +#if 0 if(JoyFD>=0) { int AxisCount,ButtonCount; @@ -181,10 +182,12 @@ void SetupInput() printf("Using Xbox 360 map\n"); } } +#endif } bool HandleKb(u32 port) { - struct input_event ie; +#if 0 + //struct input_event ie; if (kbfd < 0) return false; @@ -278,17 +281,19 @@ bool HandleKb(u32 port) { printf("type %i key %i state %i\n", ie.type, ie.code, ie.value); } #endif - +#endif +return true; } bool HandleJoystick(u32 port) { - struct js_event JE; + //struct js_event JE; // Joystick must be connected if(JoyFD<0) return false; +#if 0 while(read(JoyFD,&JE,sizeof(JE))==sizeof(JE)) if (JE.number #include #include //#include @@ -32,6 +35,7 @@ struct sigcontext uc_mcontext; } ucontext_t; #endif + #if HOST_CPU == CPU_ARM #define GET_PC_FROM_CONTEXT(c) (((ucontext_t *)(c))->uc_mcontext.arm_pc) #elif HOST_CPU == CPU_MIPS @@ -44,7 +48,7 @@ struct sigcontext uc_mcontext; #ifdef _ANDROID #define GET_PC_FROM_CONTEXT(c) (((ucontext_t *)(c))->uc_mcontext.eip) #else -#define GET_PC_FROM_CONTEXT(c) (((ucontext_t *)(c))->uc_mcontext.gregs[REG_EIP]) +#define GET_PC_FROM_CONTEXT(c) (((ucontext_t *)(c))->uc_mcontext->__ss.__eip) #endif #else #error fix ->pc support @@ -116,8 +120,10 @@ cResetEvent::cResetEvent(bool State,bool Auto) { //sem_init((sem_t*)hEvent, 0, State?1:0); verify(State==false&&Auto==true); - mutx = PTHREAD_MUTEX_INITIALIZER; - cond = PTHREAD_COND_INITIALIZER; + //mutx = PTHREAD_MUTEX_INITIALIZER; + pthread_mutex_init(&mutx, NULL); + //cond = PTHREAD_COND_INITIALIZER; + pthread_cond_init(&cond, NULL); } cResetEvent::~cResetEvent() { @@ -216,6 +222,10 @@ double os_GetSeconds() return a.tv_sec-tvs_base+a.tv_usec/1000000.0; } +void os_DebugBreak() +{ + __builtin_trap(); +} void enable_runfast() { diff --git a/core/linux/nixprof.cpp b/core/linux/nixprof.cpp index 7dd97db8d..0b8bb25eb 100644 --- a/core/linux/nixprof.cpp +++ b/core/linux/nixprof.cpp @@ -68,7 +68,7 @@ typedef struct ucontext_t #ifdef _ANDROID #define GET_PC_FROM_CONTEXT(c) (((ucontext_t *)(c))->uc_mcontext.eip) #else -#define GET_PC_FROM_CONTEXT(c) (((ucontext_t *)(c))->uc_mcontext.gregs[REG_EIP]) +#define GET_PC_FROM_CONTEXT(c) (((ucontext_t *)(c))->uc_mcontext->__ss.__eip) #endif #else #error fix ->pc support diff --git a/core/nullDC.cpp b/core/nullDC.cpp index 7d84454c0..0c537a67e 100755 --- a/core/nullDC.cpp +++ b/core/nullDC.cpp @@ -131,7 +131,7 @@ void plugins_Reset(bool Manual) void* webui_th(void* p) { - #if HOST_OS == OS_WINDOWS || HOST_OS == OS_LINUX + #if (HOST_OS == OS_WINDOWS || HOST_OS == OS_LINUX) && defined(WEBUI) webui_start(); #endif diff --git a/core/rend/norend/norend.cpp b/core/rend/norend/norend.cpp index 499227938..03ec7564a 100644 --- a/core/rend/norend/norend.cpp +++ b/core/rend/norend/norend.cpp @@ -7,6 +7,7 @@ void rend_text_invl(vram_block* bl) { } struct norend : Renderer { + bool Init() { return true; @@ -15,9 +16,14 @@ struct norend : Renderer void Resize(int w, int h) { } void Term() { } + + bool Process(TA_context* ctx) { return true; } + + void DrawOSD() { } + bool Render() { - return !pvrrc.isRTT; + return true;//!pvrrc.isRTT; } void Present() { } @@ -25,3 +31,5 @@ struct norend : Renderer Renderer* rend_norend() { return new norend(); } + +u32 GetTexture(TSP tsp,TCW tcw) { return 0; } diff --git a/core/rend/rend.h b/core/rend/rend.h index 25c7b56fc..3386fbdf8 100644 --- a/core/rend/rend.h +++ b/core/rend/rend.h @@ -1,3 +1,11 @@ #pragma once #include "hw/pvr/ta_ctx.h" -#include "hw/pvr/Renderer_if.h" \ No newline at end of file +#include "hw/pvr/Renderer_if.h" + + +#ifdef GLuint +GLuint +#else +u32 +#endif +GetTexture(TSP tsp,TCW tcw); diff --git a/core/stdclass.h b/core/stdclass.h index f7f351bbc..762bcaa54 100644 --- a/core/stdclass.h +++ b/core/stdclass.h @@ -220,7 +220,8 @@ public : #if HOST_OS==OS_WINDOWS InitializeCriticalSection(&cs); #else - mutx=PTHREAD_MUTEX_INITIALIZER; + //mutx=PTHREAD_MUTEX_INITIALIZER; + pthread_mutex_init ( &mutx, NULL); #endif } ~cMutex() diff --git a/shell/mac86/Makefile b/shell/mac86/Makefile new file mode 100644 index 000000000..aab1ebf97 --- /dev/null +++ b/shell/mac86/Makefile @@ -0,0 +1,102 @@ + +LOCAL_PATH := $(call my-dir) +FOR_LINUX :=1 +NOT_ARM := 1 +NO_REC := 1 +NO_REND := 1 +#WEBUI :=1 + +RZDCY_SRC_DIR = ../../core + +include $(RZDCY_SRC_DIR)/core.mk + + +CXX=${CC_PREFIX}g++ +CC=${CC_PREFIX}gcc +AS=${CC_PREFIX}as +STRIP=${CC_PREFIX}strip + +LD=${CC} + +MFLAGS := -m32 +#-marm -march=armv7-a -mtune=cortex-a9 -mfpu=neon -mfloat-abi=softfp -funroll-loops +ASFLAGS := -m32 +#-march=armv7-a -mfpu=neon -mfloat-abi=softfp + +LDFLAGS := -m32 -g + +SOURCES := cfg/ hw/arm7/ hw/aica/ hw/asic/ hw/ hw/gdrom/ hw/maple/ \ + hw/mem/ hw/pvr/ hw/sh4/ hw/sh4/rec_v2/ plugins/ profiler/ serial_ipc/ \ + hw/extdev/ hw/arm/ imgread/ linux/ linux-dist/ ./ rec-ARM/ deps/zlib/ deps/chdr/ deps/crypto/ arm_emitter/ + + +CXXFLAGS := -m32 -g -O3 -D RELEASE -c -D TARGET_LINUX_x86 -D HOST_NO_REC -D NO_REND +CXXFLAGS += -fno-strict-aliasing +CXXFLAGS += -ffast-math -ftree-vectorize +#-fprefetch-loop-arrays +#-std=c++0x + +CXXFLAGS += $(CFLAGS) $(MFLAGS) -fno-exceptions -fno-rtti +# CXXFLAGS += -D SUPPORT_X11 + + +ifdef PGO_MAKE + CXXFLAGS += -fprofile-generate -pg + LDFLAGS += -fprofile-generate +else + CXXFLAGS += -fomit-frame-pointer +endif + +ifdef PGO_USE + CXXFLAGS += -fprofile-use +endif + + +ifdef LTO_TEST + CXXFLAGS += -flto -fwhole-program + LDFLAGS +=-flto -fwhole-program +endif + +INCS := -I$(RZDCY_SRC_DIR) -I$(RZDCY_SRC_DIR)/deps -I$(RZDCY_SRC_DIR)/khronos -I../linux-deps/include + +LIBS := -L../linux-deps/lib/x86 -L./enta_viv +#LIBS += -lglapi +LIBS += -lm # -lrt -lEGL -lGLESv2 #-lglslcompiler -lIMGegl -lpvr2d -lsrv_um +LIBS += -lpthread # -lX11 -lXdmcp -lXau + + +OBJECTS=$(RZDCY_FILES:.cpp=.build_obj) +OBJECTS:=$(OBJECTS:.c=.build_obj) +OBJECTS:=$(OBJECTS:.S=.build_obj) +OBJECTS:=$(patsubst $(RZDCY_SRC_DIR)/%,obj/%,$(OBJECTS)) + + +EXECUTABLE_STRIPPED=nosym-reicast.elf +EXECUTABLE=reicast.elf + +PACKAGE_FILES=$(EXECUTABLE_STRIPPED) default.gcw0.desktop icon-32.png + +all: $(CPPFILES) $(EXECUTABLE) $(EXECUTABLE_STRIPPED) + +$(EXECUTABLE): $(OBJECTS) + echo $(RZDCY_FILES) + $(CXX) $(MFLAGS) $(EXTRAFLAGS) $(LDFLAGS) $(OBJECTS) $(LIBS) -o $@ + +$(EXECUTABLE_STRIPPED): $(EXECUTABLE) + cp $< $@ && $(STRIP) $@ + +obj/%.build_obj : $(RZDCY_SRC_DIR)/%.cpp + mkdir -p $(dir $@) + $(CXX) $(EXTRAFLAGS) $(INCS) $(CXXFLAGS) $< -o $@ + +obj/%.build_obj : $(RZDCY_SRC_DIR)/%.c + mkdir -p $(dir $@) + $(CC) $(EXTRAFLAGS) $(INCS) $(CXXFLAGS) $< -o $@ + +obj/%.build_obj : $(RZDCY_SRC_DIR)/%.S + mkdir -p $(dir $@) + $(AS) $(ASFLAGS) $(INCS) $< -o $@ + + +clean: + rm $(OBJECTS) $(EXECUTABLE) -f