diff options
Diffstat (limited to 'backends')
-rw-r--r-- | backends/platform/ps2/Makefile.ps2 | 193 | ||||
-rw-r--r-- | backends/platform/ps2/main_prog.ld | 4 | ||||
-rw-r--r-- | backends/platform/ps2/plugin.ld | 296 | ||||
-rw-r--r-- | backends/platform/ps2/ps2loader.cpp | 98 | ||||
-rw-r--r-- | backends/platform/ps2/systemps2.cpp | 5 |
5 files changed, 348 insertions, 248 deletions
diff --git a/backends/platform/ps2/Makefile.ps2 b/backends/platform/ps2/Makefile.ps2 index d1d2d5ebc8..15eb909107 100644 --- a/backends/platform/ps2/Makefile.ps2 +++ b/backends/platform/ps2/Makefile.ps2 @@ -1,131 +1,122 @@ # $Header: Exp $ include $(PS2SDK)/Defs.make -#These should point to the extra PS2 libs PS2_EXTRA = /home/tony/GSOC/ps2/sdk-extra PS2_EXTRA_INCS = /zlib/include /libmad/ee/include /SjPcm/ee/src /tremor -PS2_EXTRA_LIBS = /zlib/lib /libmad/ee/lib /SjPcm/ee/lib /vorbis /tremor/tremor - -#ENABLE_SCUMM = $(ENABLED) -#ENABLE_SCUMM_7_8 = $(ENABLED) -#ENABLE_HE = $(ENABLED) -#ENABLE_AGI = $(ENABLED) -#ENABLE_AGOS = $(ENABLED) -#ENABLE_CINE = $(ENABLED) -#ENABLE_CRUISE = $(ENABLED) -#ENABLE_DRASCULA = $(ENABLED) -#ENABLE_GOB = $(ENABLED) -#ENABLE_KYRA = $(ENABLED) -#ENABLE_LURE = $(ENABLED) -# ENABLE_M4 = $(ENABLED) -#ENABLE_MADE = $(ENABLED) -#ENABLE_PARALLACTION = $(ENABLED) -#ENABLE_QUEEN = $(ENABLED) -#ENABLE_SAGA = $(ENABLED) -#ENABLE_SAGA2 = $(ENABLED) -#ENABLE_IHNM = $(ENABLED) -ENABLE_SKY = $(ENABLED) -#ENABLE_SWORD1 = $(ENABLED) -#ENABLE_SWORD2 = $(ENABLED) -# ENABLE_TINSEL = $(ENABLED) -#ENABLE_TOUCHE = $(ENABLED) +PS2_EXTRA_LIBS = /zlib/lib /libmad/ee/lib /SjPcm/ee/lib /tremor/tremor # Set to 1 to enable, 0 to disable dynamic modules DYNAMIC_MODULES = 1 # Set to 1 to enable, 0 to disable more detailed printing of gcc commands -VERBOSE_BUILD=1 -# Set to 1 to enable, 0 to disable debugging support (This won't easily work "out of the box") -DEBUG=0 -# -------------------------------------------------------------------- +VERBOSE_BUILD=0 -#General variables -srcdir = ../../.. -VPATH = $(srcdir) -TARGET = elf/scummvm.elf -#EXECUTABLE = $(TARGET) - -#Variables for common ScummVM makefile -CXX = ee-g++ -G 0 -CXXFLAGS = -O2 -Wall -Wno-multichar -fno-exceptions -fno-rtti -DEFINES = -DUSE_VORBIS -DUSE_MAD -DUSE_TREMOR -DUSE_ZLIB -DFORCE_RTL -D_EE -D__PLAYSTATION2__ -ifeq ($(DEBUG),1) -DEFINES += -D__PS2_DEBUG__ -g -Wall -Wno-multichar +# Test for dynamic plugins +ifeq ($(DYNAMIC_MODULES),1) +ENABLED = DYNAMIC_PLUGIN +DEFINES = -DDYNAMIC_MODULES +PRE_OBJS_FLAGS = -Wl,--whole-archive +POST_OBJS_FLAGS = -Wl,--no-whole-archive +else +ENABLED = STATIC_PLUGIN endif -LDFLAGS := -INCDIR = ../../../ -INCLUDES = $(addprefix -I$(PS2_EXTRA),$(PS2_EXTRA_INCS)) -ifeq ($(DEBUG),1) -INCLUDES += -I $(PS2GDB)/ee -endif -INCLUDES += -I $(PS2SDK)/ee/include -I $(PS2SDK)/common/include -I ./common -I . -I $(srcdir) -I $(srcdir)/engines -DEPDIR = .deps -MODULE_DIRS += ./ -MKDIR = mkdir -p -RM = rm -f -RM_REC = rm -rf -CC = ee-gcc -G 0 -AS = ee-gcc -G 0 -LD = ee-gcc -G 0 +#control build +DISABLE_SCALERS = true +DISABLE_HQ_SCALERS = true + +ENABLE_SCUMM = $(ENABLED) +ENABLE_SCUMM_7_8 = $(ENABLED) +ENABLE_HE = $(ENABLED) +ENABLE_AGI = $(ENABLED) +ENABLE_AGOS = $(ENABLED) +ENABLE_AGOS2 = $(ENABLED) +ENABLE_CINE = $(ENABLED) +ENABLE_CRUISE = $(ENABLED) +ENABLE_DRACI = $(ENABLED) +ENABLE_DRASCULA = $(ENABLED) +ENABLE_GOB = $(ENABLED) +ENABLE_GROOVIE = $(ENABLED) +# ENABLE_GROOVIE2 = $(ENABLED) +ENABLE_IHNM = $(ENABLED) +ENABLE_KYRA = $(ENABLED) +# ENABLE_LOL = $(ENABLED) +ENABLE_LURE = $(ENABLED) +# ENABLE_M4 = $(ENABLED) +ENABLE_MADE = $(ENABLED) +ENABLE_PARALLACTION = $(ENABLED) +ENABLE_QUEEN = $(ENABLED) +ENABLE_SAGA = $(ENABLED) +ENABLE_SAGA2 = $(ENABLED) +ENABLE_SCI = $(ENABLED) +# ENABLE_SCI32 = $(ENABLED) +ENABLE_SKY = $(ENABLED) +ENABLE_SWORD1 = $(ENABLED) +ENABLE_SWORD2 = $(ENABLED) +ENABLE_TEENAGENT = $(ENABLED) +ENABLE_TINSEL = $(ENABLED) +ENABLE_TOUCHE = $(ENABLED) +ENABLE_TUCKER = $(ENABLED) + +HAVE_GCC3 = true +CC = ee-gcc +CXX = ee-g++ +AS = ee-gcc +LD = ee-gcc AR = ee-ar cru RANLIB = ee-ranlib -HAVE_GCC3 = true STRIP = ee-strip +MKDIR = mkdir -p +RM = rm -f +RM_REC = rm -rf +MODULE_DIRS = ./ + +srcdir = ../../.. +VPATH = $(srcdir) +INCDIR = ../../../ +DEPDIR = .deps + +TARGET = elf/scummvm.elf + +DEFINES += -DUSE_VORBIS -DUSE_TREMOR -DUSE_MAD -DUSE_ZLIB -DFORCE_RTL -DDISABLE_SAVEGAME_SORTING -D_EE -D__PLAYSTATION2__ -G0 -O2 -Wall -Wno-multichar -fno-rtti -fno-exceptions -DNO_ADAPTOR + +INCLUDES = $(addprefix -I$(PS2_EXTRA),$(PS2_EXTRA_INCS)) +INCLUDES += -I $(PS2SDK)/ee/include -I $(PS2SDK)/common/include -I ./common -I . -I $(srcdir) -I $(srcdir)/engines + CXX_UPDATE_DEP_FLAG = -Wp,-MMD,"$(*D)/$(DEPDIR)/$(*F).d",-MQ,"$@",-MP # Variables for dynamic plugin building PLUGIN_PREFIX = PLUGIN_SUFFIX = .plg -PLUGIN_EXTRA_DEPS = plugin.ld plugin.syms elf/scummvm.elf #comment out -mno? -#PLUGIN_LDFLAGS = -mno-crt0 $(PS2SDK)/ee/startup/crt0.o -PLUGIN_LDFLAGS = -nostartfiles -Wl,-q,--just-symbols,elf/scummvm.elf,-Tplugin.ld,--retain-symbols-file,plugin.syms -lstdc++ -lc +PLUGIN_EXTRA_DEPS = plugin.ld plugin.syms elf/scummvm.elf +PLUGIN_LDFLAGS += -nostartfiles -Wl,-q,--just-symbols,elf/scummvm.elf,-Tplugin.ld,--retain-symbols-file,plugin.syms -lstdc++ -lc -# Test for dynamic plugins -ifeq ($(DYNAMIC_MODULES),1) -ENABLED = DYNAMIC_PLUGIN -DEFINES += -DDYNAMIC_MODULES -PRE_OBJS_FLAGS = -Wl,--whole-archive -POST_OBJS_FLAGS = -Wl,--no-whole-archive -else -ENABLED = STATIC_PLUGIN -endif - -LDFLAGS += -mno-crt0 $(PS2SDK)/ee/startup/crt0.o -ifeq ($(DEBUG),1) -LDFLAGS += -L $(PS2GDB)/lib -endif +LDFLAGS = -mno-crt0 $(PS2SDK)/ee/startup/crt0.o -T main_prog.ld LDFLAGS += -L $(PS2SDK)/ee/lib -L . -LDFLAGS += $(addprefix -L$(PS2_EXTRA),$(PS2_EXTRA_LIBS)) -ifeq ($(DEBUG),1) -LDFLAGS += -lps2gdbStub -lps2ip -ldebug -endif -LDFLAGS += -lmc -lpad -lmouse -lhdd -lpoweroff -lsjpcm -lmad -ltremor -lz -lm -lc -lfileXio -lkernel -lstdc++ -LDFLAGS += - -OBJS := backends/platform/ps2/DmaPipe.o \ - backends/platform/ps2/Gs2dScreen.o \ - backends/platform/ps2/irxboot.o \ - backends/platform/ps2/ps2input.o \ - backends/platform/ps2/ps2pad.o \ - backends/platform/ps2/savefilemgr.o \ - backends/platform/ps2/fileio.o \ - backends/platform/ps2/asyncfio.o \ - backends/platform/ps2/icon.o \ - backends/platform/ps2/cd.o \ - backends/platform/ps2/eecodyvdfs.o \ - backends/platform/ps2/rpckbd.o \ - backends/platform/ps2/systemps2.o \ - backends/platform/ps2/ps2mutex.o \ - backends/platform/ps2/ps2time.o \ - backends/platform/ps2/ps2debug.o \ - backends/platform/ps2/ps2loader.o +LDFLAGS += $(addprefix -L$(PS2_EXTRA),$(PS2_EXTRA_LIBS)) +LDFLAGS += -lmc -lpad -lmouse -lhdd -lpoweroff -lsjpcm -lmad -ltremor -lz -lm -lc -lfileXio -lkernel -lstdc++ +OBJS := $(srcdir)/backends/platform/ps2/DmaPipe.o \ + $(srcdir)/backends/platform/ps2/Gs2dScreen.o \ + $(srcdir)/backends/platform/ps2/irxboot.o \ + $(srcdir)/backends/platform/ps2/ps2input.o \ + $(srcdir)/backends/platform/ps2/ps2pad.o \ + $(srcdir)/backends/platform/ps2/savefilemgr.o \ + $(srcdir)/backends/platform/ps2/fileio.o \ + $(srcdir)/backends/platform/ps2/asyncfio.o \ + $(srcdir)/backends/platform/ps2/icon.o \ + $(srcdir)/backends/platform/ps2/cd.o \ + $(srcdir)/backends/platform/ps2/eecodyvdfs.o \ + $(srcdir)/backends/platform/ps2/rpckbd.o \ + $(srcdir)/backends/platform/ps2/systemps2.o \ + $(srcdir)/backends/platform/ps2/ps2mutex.o \ + $(srcdir)/backends/platform/ps2/ps2time.o \ + $(srcdir)/backends/platform/ps2/ps2loader.o \ + $(srcdir)/backends/platform/ps2/ps2debug.o include $(srcdir)/Makefile.common -LDFLAGS += -Wl,-G,0 -T main_prog.ld #$(PS2SDK)/ee/startup/linkfile - all: $(TARGET) $(TARGET): $(OBJS) $(LD) $(PRE_OBJS_FLAGS) $(OBJS) $(POST_OBJS_FLAGS) $(LDFLAGS) -o $@ + diff --git a/backends/platform/ps2/main_prog.ld b/backends/platform/ps2/main_prog.ld index de4b534135..12f273a3a6 100644 --- a/backends/platform/ps2/main_prog.ld +++ b/backends/platform/ps2/main_prog.ld @@ -70,8 +70,9 @@ SECTIONS { *(.scommon) } + /*current PS2 Makefile disables this gp-relative section*/ __plugin_hole_start = .; - . = _gp + 0x7ff0; + . = _gp + 0x7ff00; __plugin_hole_end = .; COMMON : @@ -84,6 +85,7 @@ SECTIONS { *(.bss) *(.bss.*) *(.gnu.linkonce.b*) + /* *(COMMON) May have to take this out*/ } _end_bss = .; diff --git a/backends/platform/ps2/plugin.ld b/backends/platform/ps2/plugin.ld index 10055338d0..cc6b72340d 100644 --- a/backends/platform/ps2/plugin.ld +++ b/backends/platform/ps2/plugin.ld @@ -1,98 +1,206 @@ +OUTPUT_FORMAT("elf32-littlemips", "elf32-bigmips", + "elf32-littlemips") +OUTPUT_ARCH(mips:5900) +/* Do we need any of these for elf? + __DYNAMIC = 0; */ +_DYNAMIC_LINK = 0; PHDRS { - plugin PT_LOAD ; - shorts PT_LOAD ; + plugin PT_LOAD ; + shorts PT_LOAD ; } -SECTIONS { - /* originally was 0x00100000 but might be 0 */ - .text 0: { - _ftext = . ; - *(.text) - *(.text.*) - *(.gnu.linkonce.t*) - KEEP(*(.init)) - KEEP(*(.fini)) - QUAD(0) - } - - PROVIDE(_etext = .); - PROVIDE(etext = .); - - /* interp may or may not be needed here */ - .interp : { *(.interp) } : plugin - .reginfo : { *(.reginfo) } : plugin - - /* Global/static constructors and deconstructors. */ - .ctors ALIGN(16): { - ___plugin_ctors = .; - KEEP(*(SORT(.ctors.*))) - KEEP(*(.ctors)) - ___plugin_ctors_end = .; - } - .dtors ALIGN(16): { - ___plugin_dtors = .; - KEEP(*(SORT(.dtors.*))) - KEEP(*(.dtors)) - ___plugin_dtors_end = .; - } - - /* Static data. */ - .rodata ALIGN(128): { - *(.rodata) - *(.rodata.*) - *(.gnu.linkonce.r*) - } - - .data ALIGN(128): { - _fdata = . ; - *(.data) - *(.data.*) - *(.gnu.linkonce.d*) - SORT(CONSTRUCTORS) - } - - .rdata ALIGN(128): { *(.rdata) } - .gcc_except_table ALIGN(128): { *(.gcc_except_table) } - - /* _gp = ALIGN(128) + 0x7ff0; */ - . = __plugin_hole_start; - /* the .got line wasn't originally there */ - .got : { *(.got.plt) *(.got) } : shorts - - .lit4 ALIGN(128): { *(.lit4) } - .lit8 ALIGN(128): { *(.lit8) } - - .sdata ALIGN(128): { - *(.sdata) - *(.sdata.*) - *(.gnu.linkonce.s*) - } - - _edata = .; - PROVIDE(edata = .); - - /* Uninitialized data. */ - .sbss ALIGN(128) : { - _fbss = . ; - *(.sbss) - *(.sbss.*) - *(.gnu.linkonce.sb*) - *(.scommon) - } - - .bss ALIGN(128) : { - *(.bss) - *(.bss.*) - *(.gnu.linkonce.b*) - *(COMMON) - } - _end_bss = .; - - _end = . ; - PROVIDE(end = .); - - /* Symbols needed by crt0.s. */ - PROVIDE(_heap_size = -1); - PROVIDE(_stack = -1); - PROVIDE(_stack_size = 128 * 1024); +SECTIONS +{ + /* Read-only sections, merged into text segment: */ + . = 0; + .interp : { *(.interp) } : plugin + .reginfo : { *(.reginfo) } : plugin + .hash : { *(.hash) } + .dynsym : { *(.dynsym) } + .dynstr : { *(.dynstr) } + .gnu.version : { *(.gnu.version) } + .gnu.version_d : { *(.gnu.version_d) } + .gnu.version_r : { *(.gnu.version_r) } + .rel.dyn : + { + *(.rel.init) + *(.rel.text .rel.text.* .rel.gnu.linkonce.t.*) + *(.rel.fini) + *(.rel.rodata .rel.rodata.* .rel.gnu.linkonce.r.*) + *(.rel.data .rel.data.* .rel.gnu.linkonce.d.*) + *(.rel.tdata .rel.tdata.* .rel.gnu.linkonce.td.*) + *(.rel.tbss .rel.tbss.* .rel.gnu.linkonce.tb.*) + *(.rel.ctors) + *(.rel.dtors) + *(.rel.got) + *(.rel.sdata .rel.sdata.* .rel.gnu.linkonce.s.*) + *(.rel.sbss .rel.sbss.* .rel.gnu.linkonce.sb.*) + *(.rel.sdata2 .rel.sdata2.* .rel.gnu.linkonce.s2.*) + *(.rel.sbss2 .rel.sbss2.* .rel.gnu.linkonce.sb2.*) + *(.rel.bss .rel.bss.* .rel.gnu.linkonce.b.*) + } + .rela.dyn : + { + *(.rela.init) + *(.rela.text .rela.text.* .rela.gnu.linkonce.t.*) + *(.rela.fini) + *(.rela.rodata .rela.rodata.* .rela.gnu.linkonce.r.*) + *(.rela.data .rela.data.* .rela.gnu.linkonce.d.*) + *(.rela.tdata .rela.tdata.* .rela.gnu.linkonce.td.*) + *(.rela.tbss .rela.tbss.* .rela.gnu.linkonce.tb.*) + *(.rela.ctors) + *(.rela.dtors) + *(.rela.got) + *(.rela.sdata .rela.sdata.* .rela.gnu.linkonce.s.*) + *(.rela.sbss .rela.sbss.* .rela.gnu.linkonce.sb.*) + *(.rela.sdata2 .rela.sdata2.* .rela.gnu.linkonce.s2.*) + *(.rela.sbss2 .rela.sbss2.* .rela.gnu.linkonce.sb2.*) + *(.rela.bss .rela.bss.* .rela.gnu.linkonce.b.*) + } + .rel.plt : { *(.rel.plt) } + .rela.plt : { *(.rela.plt) } + .init : + { + KEEP (*(.init)) + } =0 + .plt : { *(.plt) } + .text : + { + _ftext = . ; + *(.text .stub .text.* .gnu.linkonce.t.*) + /* .gnu.warning sections are handled specially by elf32.em. */ + *(.gnu.warning) + *(.mips16.fn.*) *(.mips16.call.*) + } =0 + .fini : + { + KEEP (*(.fini)) + } =0 + PROVIDE (__etext = .); + PROVIDE (_etext = .); + PROVIDE (etext = .); + .rodata : { *(.rodata .rodata.* .gnu.linkonce.r.*) } + .rodata1 : { *(.rodata1) } + .sdata2 : { *(.sdata2 .sdata2.* .gnu.linkonce.s2.*) } + .sbss2 : { *(.sbss2 .sbss2.* .gnu.linkonce.sb2.*) } + .eh_frame_hdr : { *(.eh_frame_hdr) } + /* Adjust the address for the data segment. We want to adjust up to + the same address within the page on the next page up. */ + . = ALIGN(128) + (. & (128 - 1)); + /* Ensure the __preinit_array_start label is properly aligned. We + could instead move the label definition inside the section, but + the linker would then create the section even if it turns out to + be empty, which isn't pretty. */ + . = ALIGN(32 / 8); + PROVIDE (__preinit_array_start = .); + .preinit_array : { *(.preinit_array) } + PROVIDE (__preinit_array_end = .); + PROVIDE (__init_array_start = .); + .init_array : { *(.init_array) } + PROVIDE (__init_array_end = .); + PROVIDE (__fini_array_start = .); + .fini_array : { *(.fini_array) } + PROVIDE (__fini_array_end = .); + .data : + { + _fdata = . ; + *(.data .data.* .gnu.linkonce.d.*) + SORT(CONSTRUCTORS) + } + .data1 : { *(.data1) } + .tdata : { *(.tdata .tdata.* .gnu.linkonce.td.*) } + .tbss : { *(.tbss .tbss.* .gnu.linkonce.tb.*) *(.tcommon) } + .eh_frame : { KEEP (*(.eh_frame)) } + .gcc_except_table : { *(.gcc_except_table) } + .dynamic : { *(.dynamic) } + .ctors : + { + ___plugin_ctors = .; + KEEP (*(SORT(.ctors.*))) + KEEP (*(.ctors)) + ___plugin_ctors_end = .; + } + .dtors : + { + ___plugin_dtors = .; + KEEP (*(SORT(.dtors.*))) + KEEP (*(.dtors)) + ___plugin_dtors_end = .; + } + .jcr : { KEEP (*(.jcr)) } + + . = __plugin_hole_start; + .got : { *(.got.plt) *(.got) } : shorts + .lit8 : { *(.lit8) } + .lit4 : { *(.lit4) } + /* We want the small data sections together, so single-instruction offsets + can access them all, and initialized data all before uninitialized, so + we can shorten the on-disk segment size. */ + .sdata : + { + *(.sdata .sdata.* .gnu.linkonce.s.*) + } + _edata = .; + PROVIDE (edata = .); + __bss_start = .; + _fbss = .; + .sbss : + { + PROVIDE (__sbss_start = .); + PROVIDE (___sbss_start = .); + *(.dynsbss) + *(.sbss .sbss.* .gnu.linkonce.sb.*) + *(.scommon) + PROVIDE (__sbss_end = .); + PROVIDE (___sbss_end = .); + } + .bss : + { + *(.dynbss) + *(.bss .bss.* .gnu.linkonce.b.*) + *(COMMON) + /* Align here to ensure that the .bss section occupies space up to + _end. Align after .bss to ensure correct alignment even if the + .bss section disappears because there are no input sections. */ + . = ALIGN(32 / 8); + } + . = ALIGN(32 / 8); + _end = .; + PROVIDE (end = .); + /* Stabs debugging sections. */ + .stab 0 : { *(.stab) } + .stabstr 0 : { *(.stabstr) } + .stab.excl 0 : { *(.stab.excl) } + .stab.exclstr 0 : { *(.stab.exclstr) } + .stab.index 0 : { *(.stab.index) } + .stab.indexstr 0 : { *(.stab.indexstr) } + .comment 0 : { *(.comment) } + /* DWARF debug sections. + Symbols in the DWARF debugging sections are relative to the beginning + of the section so we begin them at 0. */ + /* DWARF 1 */ + .debug 0 : { *(.debug) } + .line 0 : { *(.line) } + /* GNU DWARF 1 extensions */ + .debug_srcinfo 0 : { *(.debug_srcinfo) } + .debug_sfnames 0 : { *(.debug_sfnames) } + /* DWARF 1.1 and DWARF 2 */ + .debug_aranges 0 : { *(.debug_aranges) } + .debug_pubnames 0 : { *(.debug_pubnames) } + /* DWARF 2 */ + .debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) } + .debug_abbrev 0 : { *(.debug_abbrev) } + .debug_line 0 : { *(.debug_line) } + .debug_frame 0 : { *(.debug_frame) } + .debug_str 0 : { *(.debug_str) } + .debug_loc 0 : { *(.debug_loc) } + .debug_macinfo 0 : { *(.debug_macinfo) } + /* SGI/MIPS DWARF 2 extensions */ + .debug_weaknames 0 : { *(.debug_weaknames) } + .debug_funcnames 0 : { *(.debug_funcnames) } + .debug_typenames 0 : { *(.debug_typenames) } + .debug_varnames 0 : { *(.debug_varnames) } + .gptab.sdata : { *(.gptab.data) *(.gptab.sdata) } + .gptab.sbss : { *(.gptab.bss) *(.gptab.sbss) } } + diff --git a/backends/platform/ps2/ps2loader.cpp b/backends/platform/ps2/ps2loader.cpp index a48fef94cb..8cf6fbc528 100644 --- a/backends/platform/ps2/ps2loader.cpp +++ b/backends/platform/ps2/ps2loader.cpp @@ -35,7 +35,6 @@ //#include <ps2utils.h> do these exist? #include "backends/platform/ps2/ps2loader.h" -//#include "backends/platform/ps2/powerman.h" //TODO //#define __PS2_DEBUG_PLUGINS__ @@ -45,13 +44,13 @@ #define DBG(x,...) #endif -#define seterror(x,...) fprintf(stderr,x, ## __VA_ARGS__) +#define seterror(x,...) sioprintf(x, ## __VA_ARGS__) extern char __plugin_hole_start; // Indicates start of hole in program file for shorts extern char __plugin_hole_end; // Indicates end of hole in program file extern char _gp[]; // Value of gp register -DECLARE_SINGLETON(ShortSegmentManager) // For singleton +DECLARE_SINGLETON(ShortSegmentManager); // For singleton // Get rid of symbol table in memory void DLObject::discard_symtab() { @@ -103,7 +102,7 @@ bool DLObject::relocate(int fd, unsigned long offset, unsigned long size, void * // Treat each relocation entry. Loop over all of them int cnt = size / sizeof(*rel); - //DBG("Loaded relocation table. %d entries. base address=%p\n", cnt, relSegment); + DBG("Loaded relocation table. %d entries. base address=%p\n", cnt, relSegment); bool seenHi16 = false; // For treating HI/LO16 commands int firstHi16 = -1; // Mark the point of the first hi16 seen @@ -141,9 +140,9 @@ bool DLObject::relocate(int fd, unsigned long offset, unsigned long size, void * lastHiSymVal = sym->st_value; hi16InShorts = (ShortsMan.inGeneralSegment((char *)sym->st_value)); // Fix for problem with switching btw segments - //if (debugRelocs[0]++ < DEBUG_NUM) // Print only a set number - //DBG("R_MIPS_HI16: i=%d, offset=%x, ahl = %x, target = %x\n", - //i, rel[i].r_offset, ahl, *target); + if (debugRelocs[0]++ < DEBUG_NUM) // Print only a set number + DBG("R_MIPS_HI16: i=%d, offset=%x, ahl = %x, target = %x\n", + i, rel[i].r_offset, ahl, *target); } break; @@ -194,12 +193,12 @@ bool DLObject::relocate(int fd, unsigned long offset, unsigned long size, void * *target &= 0xffff0000; // Clear the lower 16 bits of current target *target |= relocation & 0xffff; // Take the lower 16 bits of the relocation - //if (debugRelocs[1]++ < DEBUG_NUM) - //DBG("R_MIPS_LO16: i=%d, offset=%x, a=%x, ahl = %x, lastTarget = %x, origt = %x, target = %x\n", - // i, rel[i].r_offset, a, ahl, *lastTarget, origTarget, *target); - //if (lo16InShorts && debugRelocs[2]++ < DEBUG_NUM) - //DBG("R_MIPS_LO16s: i=%d, offset=%x, a=%x, ahl = %x, lastTarget = %x, origt = %x, target = %x\n", - // i, rel[i].r_offset, a, ahl, *lastTarget, origTarget, *target); + if (debugRelocs[1]++ < DEBUG_NUM) + DBG("R_MIPS_LO16: i=%d, offset=%x, a=%x, ahl = %x, lastTarget = %x, origt = %x, target = %x\n", + i, rel[i].r_offset, a, ahl, *lastTarget, origTarget, *target); + if (lo16InShorts && debugRelocs[2]++ < DEBUG_NUM) + DBG("R_MIPS_LO16s: i=%d, offset=%x, a=%x, ahl = %x, lastTarget = %x, origt = %x, target = %x\n", + i, rel[i].r_offset, a, ahl, *lastTarget, origTarget, *target); } break; @@ -211,13 +210,13 @@ bool DLObject::relocate(int fd, unsigned long offset, unsigned long size, void * *target &= 0xfc000000; // Clean lower 26 target bits *target |= (relocation & 0x03ffffff); - //if (debugRelocs[3]++ < DEBUG_NUM) - //DBG("R_MIPS_26: i=%d, offset=%x, symbol=%d, stinfo=%x, a=%x, origTarget=%x, target=%x\n", - // i, rel[i].r_offset, REL_INDEX(rel[i].r_info), sym->st_info, a, origTarget, *target); + if (debugRelocs[3]++ < DEBUG_NUM) + DBG("R_MIPS_26: i=%d, offset=%x, symbol=%d, stinfo=%x, a=%x, origTarget=%x, target=%x\n", + i, rel[i].r_offset, REL_INDEX(rel[i].r_info), sym->st_info, a, origTarget, *target); } else { - //if (debugRelocs[4]++ < DEBUG_NUM) - //DBG("R_MIPS_26: i=%d, offset=%x, symbol=%d, stinfo=%x, a=%x, origTarget=%x, target=%x\n", - // i, rel[i].r_offset, REL_INDEX(rel[i].r_info), sym->st_info, a, origTarget, *target); + if (debugRelocs[4]++ < DEBUG_NUM) + DBG("R_MIPS_26: i=%d, offset=%x, symbol=%d, stinfo=%x, a=%x, origTarget=%x, target=%x\n", + i, rel[i].r_offset, REL_INDEX(rel[i].r_info), sym->st_info, a, origTarget, *target); } break; @@ -232,9 +231,9 @@ bool DLObject::relocate(int fd, unsigned long offset, unsigned long size, void * *target &= 0xffff0000; // Clear the lower 16 bits of the target *target |= relocation & 0xffff; - //if (debugRelocs[5]++ < DEBUG_NUM) - //DBG("R_MIPS_GPREL16: i=%d, a=%x, gpVal=%x, origTarget=%x, target=%x, offset=%x\n", - // i, a, _gpVal, origTarget, *target, _shortsSegment->getOffset()); + if (debugRelocs[5]++ < DEBUG_NUM) + DBG("R_MIPS_GPREL16: i=%d, a=%x, gpVal=%x, origTarget=%x, target=%x, offset=%x\n", + i, a, _gpVal, origTarget, *target, _shortsSegment->getOffset()); } break; @@ -249,8 +248,8 @@ bool DLObject::relocate(int fd, unsigned long offset, unsigned long size, void * relocation = a + (Elf32_Addr)_segment; // Shift by main offset *target = relocation; - //if (debugRelocs[6]++ < DEBUG_NUM) - //DBG("R_MIPS_32: i=%d, a=%x, origTarget=%x, target=%x\n", i, a, origTarget, *target); + if (debugRelocs[6]++ < DEBUG_NUM) + DBG("R_MIPS_32: i=%d, a=%x, origTarget=%x, target=%x\n", i, a, origTarget, *target); } break; @@ -261,7 +260,7 @@ bool DLObject::relocate(int fd, unsigned long offset, unsigned long size, void * } } - //DBG("Done with relocation. extendedHi16=%d\n\n", extendedHi16); + DBG("Done with relocation. extendedHi16=%d\n\n", extendedHi16); free(rel); return true; @@ -279,8 +278,8 @@ bool DLObject::readElfHeader(int fd, Elf32_Ehdr *ehdr) { return false; } - //DBG("phoff = %d, phentsz = %d, phnum = %d\n", - //ehdr->e_phoff, ehdr->e_phentsize, ehdr->e_phnum); + DBG("phoff = %d, phentsz = %d, phnum = %d\n", + ehdr->e_phoff, ehdr->e_phentsize, ehdr->e_phnum); return true; } @@ -299,8 +298,8 @@ bool DLObject::readProgramHeaders(int fd, Elf32_Ehdr *ehdr, Elf32_Phdr *phdr, in return false; } - //DBG("offs = %x, filesz = %x, memsz = %x, align = %x\n", - //phdr->p_offset, phdr->p_filesz, phdr->p_memsz, phdr->p_align); + DBG("offs = %x, filesz = %x, memsz = %x, align = %x\n", + phdr->p_offset, phdr->p_filesz, phdr->p_memsz, phdr->p_align); return true; @@ -315,7 +314,7 @@ bool DLObject::loadSegment(int fd, Elf32_Phdr *phdr) { // Attempt to allocate memory for segment int extra = phdr->p_vaddr % phdr->p_align; // Get extra length TODO: check logic here - //DBG("extra mem is %x\n", extra); + DBG("extra mem is %x\n", extra); if (phdr->p_align < 0x10000) phdr->p_align = 0x10000; // Fix for wrong alignment on e.g. AGI @@ -323,7 +322,7 @@ bool DLObject::loadSegment(int fd, Elf32_Phdr *phdr) { seterror("Out of memory.\n"); return false; } - //DBG("allocated segment @ %p\n", _segment); + DBG("allocated segment @ %p\n", _segment); // Get offset to load segment into baseAddress = (char *)_segment + phdr->p_vaddr; @@ -332,14 +331,14 @@ bool DLObject::loadSegment(int fd, Elf32_Phdr *phdr) { _shortsSegment = ShortsMan.newSegment(phdr->p_memsz, (char *)phdr->p_vaddr); baseAddress = _shortsSegment->getStart(); - //DBG("shorts segment @ %p to %p. Segment wants to be at %x. Offset=%x\n", - //_shortsSegment->getStart(), _shortsSegment->getEnd(), phdr->p_vaddr, _shortsSegment->getOffset()); + DBG("shorts segment @ %p to %p. Segment wants to be at %x. Offset=%x\n", + _shortsSegment->getStart(), _shortsSegment->getEnd(), phdr->p_vaddr, _shortsSegment->getOffset()); } // Set bss segment to 0 if necessary (assumes bss is at the end) if (phdr->p_memsz > phdr->p_filesz) { - //DBG("Setting %p to %p to 0 for bss\n", baseAddress + phdr->p_filesz, baseAddress + phdr->p_memsz); + DBG("Setting %p to %p to 0 for bss\n", baseAddress + phdr->p_filesz, baseAddress + phdr->p_memsz); memset(baseAddress + phdr->p_filesz, 0, phdr->p_memsz - phdr->p_filesz); } // Read the segment into memory @@ -378,8 +377,8 @@ int DLObject::loadSymbolTable(int fd, Elf32_Ehdr *ehdr, Elf32_Shdr *shdr) { // Loop over sections, looking for symbol table linked to a string table for (int i = 0; i < ehdr->e_shnum; i++) { - //DBG("Section %d: type = %x, size = %x, entsize = %x, link = %x\n", - // i, shdr[i].sh_type, shdr[i].sh_size, shdr[i].sh_entsize, shdr[i].sh_link); + DBG("Section %d: type = %x, size = %x, entsize = %x, link = %x\n", + i, shdr[i].sh_type, shdr[i].sh_size, shdr[i].sh_entsize, shdr[i].sh_link); if (shdr[i].sh_type == SHT_SYMTAB && shdr[i].sh_entsize == sizeof(Elf32_Sym) && @@ -396,7 +395,7 @@ int DLObject::loadSymbolTable(int fd, Elf32_Ehdr *ehdr, Elf32_Shdr *shdr) { return -1; } - //DBG("Symbol section at section %d, size %x\n", _symtab_sect, shdr[_symtab_sect].sh_size); + DBG("Symbol section at section %d, size %x\n", _symtab_sect, shdr[_symtab_sect].sh_size); // Allocate memory for symbol table if (!(_symtab = malloc(shdr[_symtab_sect].sh_size))) { @@ -414,7 +413,7 @@ int DLObject::loadSymbolTable(int fd, Elf32_Ehdr *ehdr, Elf32_Shdr *shdr) { // Set number of symbols _symbol_cnt = shdr[_symtab_sect].sh_size / sizeof(Elf32_Sym); - //DBG("Loaded %d symbols.\n", _symbol_cnt); + DBG("Loaded %d symbols.\n", _symbol_cnt); return _symtab_sect; @@ -443,7 +442,7 @@ bool DLObject::loadStringTable(int fd, Elf32_Shdr *shdr) { void DLObject::relocateSymbols(Elf32_Addr offset, Elf32_Addr shortsOffset) { int shortsCount = 0, othersCount = 0; - //DBG("Relocating symbols by %x. Shorts offset=%x\n", offset, shortsOffset); + DBG("Relocating symbols by %x. Shorts offset=%x\n", offset, shortsOffset); // Loop over symbols, add relocation offset Elf32_Sym *s = (Elf32_Sym *)_symtab; @@ -466,7 +465,7 @@ void DLObject::relocateSymbols(Elf32_Addr offset, Elf32_Addr shortsOffset) { } - //DBG("Relocated %d short symbols, %d others.\n", shortsCount, othersCount); + DBG("Relocated %d short symbols, %d others.\n", shortsCount, othersCount); } bool DLObject::relocateRels(int fd, Elf32_Ehdr *ehdr, Elf32_Shdr *shdr) { @@ -546,11 +545,11 @@ bool DLObject::open(const char *path) { int fd; void *ctors_start, *ctors_end; - //DBG("open(\"%s\")\n", path); + DBG("open(\"%s\")\n", path); // Get the address of the global pointer _gpVal = (unsigned int) & _gp; - //DBG("_gpVal is %x\n", _gpVal); + DBG("_gpVal is %x\n", _gpVal); //PS2 has no "PowerMan" for suspending the system. //PowerMan.beginCriticalSection(); @@ -573,6 +572,7 @@ bool DLObject::open(const char *path) { //PowerMan.endCriticalSection(); // flush data cache + DBG("Flushing data cache"); FlushCache(0); FlushCache(2); @@ -590,11 +590,11 @@ bool DLObject::open(const char *path) { return false; } - //DBG("Calling constructors.\n"); + DBG("Calling constructors.\n"); for (void (**f)(void) = (void (**)(void))ctors_start; f != ctors_end; f++) (**f)(); - //DBG("%s opened ok.\n", path); + DBG("%s opened ok.\n", path); return true; } @@ -608,7 +608,7 @@ bool DLObject::close() { } void *DLObject::symbol(const char *name) { - //DBG("symbol(\"%s\")\n", name); + DBG("symbol(\"%s\")\n", name); if (_symtab == NULL || _strtab == NULL || _symbol_cnt < 1) { seterror("No symbol table loaded."); @@ -624,7 +624,7 @@ void *DLObject::symbol(const char *name) { !strcmp(name, _strtab + s->st_name)) { // We found the symbol - //DBG("=> %p\n", (void*)s->st_value); + DBG("=> %p\n", (void*)s->st_value); return (void*)s->st_value; } } @@ -668,14 +668,14 @@ ShortSegmentManager::Segment *ShortSegmentManager::newSegment(int size, char *or _list.insert(i, seg); - //DBG("Shorts segment size %x allocated. End = %p. Remaining space = %x. Highest so far is %p.\n", - //size, lastAddress + size, _shortsEnd - _list.back()->getEnd(), _highestAddress); + DBG("Shorts segment size %x allocated. End = %p. Remaining space = %x. Highest so far is %p.\n", + size, lastAddress + size, _shortsEnd - _list.back()->getEnd(), _highestAddress); return seg; } void ShortSegmentManager::deleteSegment(ShortSegmentManager::Segment *seg) { - //DBG("Deleting shorts segment from %p to %p.\n\n", seg->getStart(), seg->getEnd()); + DBG("Deleting shorts segment from %p to %p.\n\n", seg->getStart(), seg->getEnd()); _list.remove(seg); delete seg; } diff --git a/backends/platform/ps2/systemps2.cpp b/backends/platform/ps2/systemps2.cpp index 120f6ee157..357404c5c4 100644 --- a/backends/platform/ps2/systemps2.cpp +++ b/backends/platform/ps2/systemps2.cpp @@ -107,7 +107,6 @@ extern "C" int scummvm_main(int argc, char *argv[]); extern "C" int main(int argc, char *argv[]) { SifInitRpc(0); - ee_thread_t thisThread; int tid = GetThreadId(); ReferThreadStatus(tid, &thisThread); @@ -132,12 +131,11 @@ extern "C" int main(int argc, char *argv[]) { sioprintf("Creating system\n"); g_system = g_systemPs2 = new OSystem_PS2(argv[0]); - g_systemPs2->init(); - #ifdef DYNAMIC_MODULES PluginManager::instance().addPluginProvider(new PS2PluginProvider()); #endif + g_systemPs2->init(); sioprintf("init done. starting ScummVM.\n"); int res = scummvm_main(argc, argv); sioprintf("scummvm_main terminated: %d\n", res); @@ -343,6 +341,7 @@ OSystem_PS2::OSystem_PS2(const char *elfPath) { } void OSystem_PS2::init(void) { + //msgPrintf(FOREVER, "got to init! Now restart your console... %d\n", res); sioprintf("Timer...\n"); _scummTimerManager = new DefaultTimerManager(); _scummMixer = new Audio::MixerImpl(this, 48000); |