diff --git a/.github/workflows/compilation.yml b/.github/workflows/compilation.yml index eff824457..be70834dc 100644 --- a/.github/workflows/compilation.yml +++ b/.github/workflows/compilation.yml @@ -13,7 +13,7 @@ jobs: container: ghcr.io/ps2homebrew/ps2homebrew:main steps: - name: git checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - run: | git config --global --add safe.directory "$GITHUB_WORKSPACE" @@ -27,7 +27,7 @@ jobs: - name: Upload release artifact ELF if: ${{ success() }} - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: OPNPS2LD path: | @@ -35,7 +35,7 @@ jobs: - name: Upload release artifact info if: ${{ success() }} - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: INFO path: | @@ -56,7 +56,7 @@ jobs: container: ghcr.io/ps2homebrew/ps2homebrew:main steps: - name: git checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - run: | git config --global --add safe.directory "$GITHUB_WORKSPACE" @@ -75,17 +75,28 @@ jobs: run: sh ./make_changelog.sh - name: Upload variants artifact ELF - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: - name: OPNPS2LD-VARIANTS + name: OPNPS2LD-VARIANTS ${{ matrix.t10k }} ${{ matrix.igs }} ${{ matrix.pademu }} ${{ matrix.rtl }} path: OPNPS2LD*.ELF + merge-variants: + runs-on: ubuntu-latest + needs: build-variants + steps: + - name: Merge Artifacts + uses: actions/upload-artifact/merge@v4 + with: + name: OPNPS2LD-VARIANTS + pattern: OPNPS2LD-VARIANTS* + delete-merged: true + build-lang: runs-on: ubuntu-latest container: ghcr.io/ps2homebrew/ps2homebrew:main steps: - name: git checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - run: | git config --global --add safe.directory "$GITHUB_WORKSPACE" @@ -99,7 +110,7 @@ jobs: - name: Upload release artifact if: ${{ success() }} - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: OPNPS2LD-LANGS path: | @@ -114,7 +125,7 @@ jobs: container: ghcr.io/ps2homebrew/ps2homebrew:main steps: - name: git checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - run: | git config --global --add safe.directory "$GITHUB_WORKSPACE" @@ -130,11 +141,22 @@ jobs: mv opl.elf opl-${{ matrix.debug }}.elf - name: Upload variants artifact ELF - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: - name: opl-debug-${{ env.OPL_VERSION }}-${{ matrix.docker }} + name: opl-${{ matrix.debug }}-${{ env.OPL_VERSION }} path: opl-*.elf + merge-debug: + runs-on: ubuntu-latest + needs: build-debug + steps: + - name: Merge Artifacts + uses: actions/upload-artifact/merge@v4 + with: + name: OPNPS2LD-DEBUG + pattern: opl-* + delete-merged: true + release: needs: [build, build-variants, build-lang] runs-on: ubuntu-latest @@ -144,7 +166,7 @@ jobs: PASSWORD: ${{ secrets.PASSWORD }} steps: - name: git checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - run: git fetch --prune --unshallow @@ -153,7 +175,7 @@ jobs: echo "OPL_VERSION=$(make oplversion)" >> $GITHUB_ENV - name: Download all artifacts - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 - name: Prepare artifacts for release run: | @@ -169,7 +191,7 @@ jobs: - name: Create prerelease if: github.ref == 'refs/heads/master' - uses: marvinpinto/action-automatic-releases@latest + uses: mathieucarbou/marvinpinto-action-automatic-releases@latest with: repo_token: "${{ secrets.GITHUB_TOKEN }}" prerelease: true @@ -185,7 +207,7 @@ jobs: - name: Create release if: startsWith(github.ref, 'refs/tags/v') - uses: marvinpinto/action-automatic-releases@latest + uses: mathieucarbou/marvinpinto-action-automatic-releases@latest with: repo_token: "${{ secrets.GITHUB_TOKEN }}" prerelease: "${{ contains(github.ref, '-rc') }}" diff --git a/.gitignore b/.gitignore index c343f0fd9..d1d0d9e51 100755 --- a/.gitignore +++ b/.gitignore @@ -40,6 +40,7 @@ DETAILED_CHANGELOG # pc/iso2usbld/bin/iso2usbld IOPRP_img.c +asm/*.c # # 3rd party diff --git a/Makefile b/Makefile index a31b3b6a3..81ca51aac 100755 --- a/Makefile +++ b/Makefile @@ -78,8 +78,7 @@ IOP_OBJS = iomanx.o filexio.o ps2fs.o usbd.o bdmevent.o \ iremsndpatch.o apemodpatch.o f2techioppatch.o cleareffects.o resetspu.o \ libsd.o audsrv.o -EECORE_OBJS = ee_core.o ioprp.o util.o \ - udnl.o imgdrv.o eesync.o \ +EECORE_OBJS = ee_core.o ioprp.o util.o imgdrv.o eesync.o \ bdm_cdvdman.o IOPRP_img.o smb_cdvdman.o \ hdd_cdvdman.o hdd_hdpro_cdvdman.o cdvdfsv.o \ ingame_smstcpip.o smap_ingame.o smbman.o smbinit.o \ @@ -119,12 +118,10 @@ PNG_ASSETS_DIR = gfx/ MAPFILE = opl.map EE_LDFLAGS += -Wl,-Map,$(MAPFILE) -EE_LIBS = -L$(PS2SDK)/ports/lib -L$(GSKIT)/lib -L./lib -lgskit -ldmakit -lgskit_toolkit -lpoweroff -lfileXio -lpatches -ljpeg_ps2_addons -ljpeg -lpng -lz -ldebug -lm -lmc -lfreetype -lvux -lcdvd -lnetman -lps2ips -laudsrv -lvorbisfile -lvorbis -logg -lpadx -lelf-loader-nocolour +EE_LIBS = -L$(PS2SDK)/ports/lib -L$(GSKIT)/lib -L./lib -lgskit -ldmakit -lgskit_toolkit -lpoweroff -lfileXio -lpatches -ljpeg_ps2_addons -ljpeg -lpng -lz -lmc -lfreetype -lvux -lcdvd -lnetman -lps2ips -laudsrv -lvorbisfile -lvorbis -logg -lpadx -lelf-loader-nocolour EE_INCS += -I$(PS2SDK)/ports/include -I$(PS2SDK)/ports/include/freetype2 -I$(GSKIT)/include -I$(GSKIT)/ee/dma/include -I$(GSKIT)/ee/gs/include -I$(GSKIT)/ee/toolkit/include -Imodules/iopcore/common -Imodules/network/common -Imodules/hdd/common -Iinclude BIN2C = $(PS2SDK)/bin/bin2c -BIN2S = $(PS2SDK)/bin/bin2s -BIN2O = $(PS2SDK)/bin/bin2o # WARNING: Only extra spaces are allowed and ignored at the beginning of the conditional directives (ifeq, ifneq, ifdef, ifndef, else and endif) # but a tab is not allowed; if the line begins with a tab, it will be considered part of a recipe for a rule! @@ -136,9 +133,6 @@ endif ifeq ($(DTL_T10000),1) EE_CFLAGS += -D_DTL_T10000 EECORE_EXTRA_FLAGS += DTL_T10000=1 - UDNL_OUT = $(PS2SDK)/iop/irx/udnl-t300.irx -else - UDNL_OUT = $(PS2SDK)/iop/irx/udnl.irx endif ifeq ($(IGS),1) @@ -206,6 +200,10 @@ EE_OBJS += $(FRONTEND_OBJS) $(GFX_OBJS) $(AUDIO_OBJS) $(MISC_OBJS) $(EECORE_OBJS EE_OBJS := $(EE_OBJS:%=$(EE_OBJS_DIR)%) EE_DEPS = $($(filter %.o,$(EE_OBJS)):%.o=%.d) +# To help linking getting rid off unused functions and data +EE_CFLAGS += -fdata-sections -ffunction-sections +EE_LDFLAGS += -fdata-sections -ffunction-sections -Wl,--gc-sections + .SILENT: .PHONY: all release debug iopcore_debug eesio_debug ingame_debug deci2_debug clean rebuild pc_tools pc_tools_win32 oplversion format format-check ps2sdk-not-setup download_lng download_lwNBD languages @@ -363,8 +361,8 @@ ee_core/ee_core.elf: ee_core echo "-EE core" $(MAKE) $(IGS_FLAGS) $(PADEMU_FLAGS) $(EECORE_EXTRA_FLAGS) -C $< -$(EE_ASM_DIR)ee_core.s: ee_core/ee_core.elf | $(EE_ASM_DIR) - $(BIN2S) $< $@ eecore_elf +$(EE_ASM_DIR)ee_core.c: ee_core/ee_core.elf | $(EE_ASM_DIR) + $(BIN2C) $< $@ eecore_elf elfldr/elfldr.elf: elfldr echo "-Elf Loader" @@ -373,110 +371,107 @@ elfldr/elfldr.elf: elfldr $(EE_ASM_DIR)elfldr.s: elfldr/elfldr.elf | $(EE_ASM_DIR) $(BIN2S) $< $@ elfldr_elf -$(EE_ASM_DIR)udnl.s: $(UDNL_OUT) | $(EE_ASM_DIR) - $(BIN2S) $(UDNL_OUT) $@ udnl_irx - modules/iopcore/imgdrv/imgdrv.irx: modules/iopcore/imgdrv $(MAKE) -C $< -$(EE_ASM_DIR)imgdrv.s: modules/iopcore/imgdrv/imgdrv.irx | $(EE_ASM_DIR) - $(BIN2S) $< $@ imgdrv_irx +$(EE_ASM_DIR)imgdrv.c: modules/iopcore/imgdrv/imgdrv.irx | $(EE_ASM_DIR) + $(BIN2C) $< $@ $(*F)_irx -$(EE_ASM_DIR)eesync.s: $(PS2SDK)/iop/irx/eesync-nano.irx | $(EE_ASM_DIR) - $(BIN2S) $< $@ eesync_irx +$(EE_ASM_DIR)eesync.c: $(PS2SDK)/iop/irx/eesync-nano.irx | $(EE_ASM_DIR) + $(BIN2C) $< $@ $(*F)_irx modules/iopcore/cdvdman/bdm_cdvdman.irx: modules/iopcore/cdvdman $(MAKE) $(CDVDMAN_PS2LOGO_FLAGS) $(CDVDMAN_DEBUG_FLAGS) USE_BDM=1 -C $< all -$(EE_ASM_DIR)bdm_cdvdman.s: modules/iopcore/cdvdman/bdm_cdvdman.irx | $(EE_ASM_DIR) - $(BIN2S) $< $@ bdm_cdvdman_irx +$(EE_ASM_DIR)bdm_cdvdman.c: modules/iopcore/cdvdman/bdm_cdvdman.irx | $(EE_ASM_DIR) + $(BIN2C) $< $@ $(*F)_irx modules/iopcore/cdvdman/smb_cdvdman.irx: modules/iopcore/cdvdman $(MAKE) $(CDVDMAN_PS2LOGO_FLAGS) $(CDVDMAN_DEBUG_FLAGS) USE_SMB=1 -C $< all -$(EE_ASM_DIR)smb_cdvdman.s: modules/iopcore/cdvdman/smb_cdvdman.irx | $(EE_ASM_DIR) - $(BIN2S) $< $@ smb_cdvdman_irx +$(EE_ASM_DIR)smb_cdvdman.c: modules/iopcore/cdvdman/smb_cdvdman.irx | $(EE_ASM_DIR) + $(BIN2C) $< $@ $(*F)_irx modules/iopcore/cdvdman/hdd_cdvdman.irx: modules/iopcore/cdvdman $(MAKE) $(CDVDMAN_PS2LOGO_FLAGS) $(CDVDMAN_DEBUG_FLAGS) USE_HDD=1 -C $< all -$(EE_ASM_DIR)hdd_cdvdman.s: modules/iopcore/cdvdman/hdd_cdvdman.irx | $(EE_ASM_DIR) - $(BIN2S) $< $@ hdd_cdvdman_irx +$(EE_ASM_DIR)hdd_cdvdman.c: modules/iopcore/cdvdman/hdd_cdvdman.irx | $(EE_ASM_DIR) + $(BIN2C) $< $@ $(*F)_irx modules/iopcore/cdvdman/hdd_hdpro_cdvdman.irx: modules/iopcore/cdvdman $(MAKE) $(CDVDMAN_PS2LOGO_FLAGS) $(CDVDMAN_DEBUG_FLAGS) USE_HDPRO=1 -C $< all -$(EE_ASM_DIR)hdd_hdpro_cdvdman.s: modules/iopcore/cdvdman/hdd_hdpro_cdvdman.irx | $(EE_ASM_DIR) - $(BIN2S) $< $@ hdd_hdpro_cdvdman_irx +$(EE_ASM_DIR)hdd_hdpro_cdvdman.c: modules/iopcore/cdvdman/hdd_hdpro_cdvdman.irx | $(EE_ASM_DIR) + $(BIN2C) $< $@ $(*F)_irx modules/iopcore/cdvdfsv/cdvdfsv.irx: modules/iopcore/cdvdfsv $(MAKE) -C $< -$(EE_ASM_DIR)cdvdfsv.s: modules/iopcore/cdvdfsv/cdvdfsv.irx | $(EE_ASM_DIR) - $(BIN2S) $< $@ cdvdfsv_irx +$(EE_ASM_DIR)cdvdfsv.c: modules/iopcore/cdvdfsv/cdvdfsv.irx | $(EE_ASM_DIR) + $(BIN2C) $< $@ $(*F)_irx modules/iopcore/patches/iremsndpatch/iremsndpatch.irx: modules/iopcore/patches/iremsndpatch $(MAKE) -C $< -$(EE_ASM_DIR)iremsndpatch.s: modules/iopcore/patches/iremsndpatch/iremsndpatch.irx | $(EE_ASM_DIR) - $(BIN2S) $< $@ iremsndpatch_irx +$(EE_ASM_DIR)iremsndpatch.c: modules/iopcore/patches/iremsndpatch/iremsndpatch.irx | $(EE_ASM_DIR) + $(BIN2C) $< $@ $(*F)_irx modules/iopcore/patches/apemodpatch/apemodpatch.irx: modules/iopcore/patches/apemodpatch $(MAKE) -C $< -$(EE_ASM_DIR)apemodpatch.s: modules/iopcore/patches/apemodpatch/apemodpatch.irx | $(EE_ASM_DIR) - $(BIN2S) $< $@ apemodpatch_irx +$(EE_ASM_DIR)apemodpatch.c: modules/iopcore/patches/apemodpatch/apemodpatch.irx | $(EE_ASM_DIR) + $(BIN2C) $< $@ $(*F)_irx modules/iopcore/patches/f2techioppatch/f2techioppatch.irx: modules/iopcore/patches/f2techioppatch $(MAKE) -C $< -$(EE_ASM_DIR)f2techioppatch.s: modules/iopcore/patches/f2techioppatch/f2techioppatch.irx | $(EE_ASM_DIR) - $(BIN2S) $< $@ f2techioppatch_irx +$(EE_ASM_DIR)f2techioppatch.c: modules/iopcore/patches/f2techioppatch/f2techioppatch.irx | $(EE_ASM_DIR) + $(BIN2C) $< $@ $(*F)_irx modules/iopcore/patches/cleareffects/cleareffects.irx: modules/iopcore/patches/cleareffects $(MAKE) -C $< -$(EE_ASM_DIR)cleareffects.s: modules/iopcore/patches/cleareffects/cleareffects.irx | $(EE_ASM_DIR) - $(BIN2S) $< $@ cleareffects_irx +$(EE_ASM_DIR)cleareffects.c: modules/iopcore/patches/cleareffects/cleareffects.irx | $(EE_ASM_DIR) + $(BIN2C) $< $@ $(*F)_irx modules/iopcore/resetspu/resetspu.irx: modules/iopcore/resetspu $(MAKE) -C $< -$(EE_ASM_DIR)resetspu.s: modules/iopcore/resetspu/resetspu.irx | $(EE_ASM_DIR) - $(BIN2S) $< $@ resetspu_irx +$(EE_ASM_DIR)resetspu.c: modules/iopcore/resetspu/resetspu.irx | $(EE_ASM_DIR) + $(BIN2C) $< $@ $(*F)_irx modules/mcemu/bdm_mcemu.irx: modules/mcemu $(MAKE) $(MCEMU_DEBUG_FLAGS) $(PADEMU_FLAGS) USE_BDM=1 -C $< all -$(EE_ASM_DIR)bdm_mcemu.s: modules/mcemu/bdm_mcemu.irx - $(BIN2S) $< $@ bdm_mcemu_irx +$(EE_ASM_DIR)bdm_mcemu.c: modules/mcemu/bdm_mcemu.irx + $(BIN2C) $< $@ $(*F)_irx modules/mcemu/hdd_mcemu.irx: modules/mcemu $(MAKE) $(MCEMU_DEBUG_FLAGS) $(PADEMU_FLAGS) USE_HDD=1 -C $< all -$(EE_ASM_DIR)hdd_mcemu.s: modules/mcemu/hdd_mcemu.irx - $(BIN2S) $< $@ hdd_mcemu_irx +$(EE_ASM_DIR)hdd_mcemu.c: modules/mcemu/hdd_mcemu.irx + $(BIN2C) $< $@ $(*F)_irx modules/mcemu/smb_mcemu.irx: modules/mcemu $(MAKE) $(MCEMU_DEBUG_FLAGS) $(PADEMU_FLAGS) USE_SMB=1 -C $< all -$(EE_ASM_DIR)smb_mcemu.s: modules/mcemu/smb_mcemu.irx - $(BIN2S) $< $@ smb_mcemu_irx +$(EE_ASM_DIR)smb_mcemu.c: modules/mcemu/smb_mcemu.irx + $(BIN2C) $< $@ $(*F)_irx modules/isofs/isofs.irx: modules/isofs $(MAKE) -C $< -$(EE_ASM_DIR)isofs.s: modules/isofs/isofs.irx | $(EE_ASM_DIR) - $(BIN2S) $< $@ isofs_irx +$(EE_ASM_DIR)isofs.c: modules/isofs/isofs.irx | $(EE_ASM_DIR) + $(BIN2C) $< $@ $(*F)_irx -$(EE_ASM_DIR)usbd.s: $(PS2SDK)/iop/irx/usbd_mini.irx | $(EE_ASM_DIR) - $(BIN2S) $< $@ usbd_irx +$(EE_ASM_DIR)usbd.c: $(PS2SDK)/iop/irx/usbd_mini.irx | $(EE_ASM_DIR) + $(BIN2C) $< $@ $(*F)_irx -$(EE_ASM_DIR)libsd.s: $(PS2SDK)/iop/irx/libsd.irx | $(EE_ASM_DIR) - $(BIN2S) $< $@ libsd_irx +$(EE_ASM_DIR)libsd.c: $(PS2SDK)/iop/irx/libsd.irx | $(EE_ASM_DIR) + $(BIN2C) $< $@ $(*F)_irx -$(EE_ASM_DIR)audsrv.s: $(PS2SDK)/iop/irx/audsrv.irx | $(EE_ASM_DIR) - $(BIN2S) $< $@ audsrv_irx +$(EE_ASM_DIR)audsrv.c: $(PS2SDK)/iop/irx/audsrv.irx | $(EE_ASM_DIR) + $(BIN2C) $< $@ $(*F)_irx $(EE_OBJS_DIR)libds34bt.a: modules/ds34bt/ee/libds34bt.a cp $< $@ @@ -487,8 +482,8 @@ modules/ds34bt/ee/libds34bt.a: modules/ds34bt/ee modules/ds34bt/iop/ds34bt.irx: modules/ds34bt/iop $(MAKE) -C $< -$(EE_ASM_DIR)ds34bt.s: modules/ds34bt/iop/ds34bt.irx | $(EE_ASM_DIR) - $(BIN2S) $< $@ ds34bt_irx +$(EE_ASM_DIR)ds34bt.c: modules/ds34bt/iop/ds34bt.irx | $(EE_ASM_DIR) + $(BIN2C) $< $@ $(*F)_irx $(EE_OBJS_DIR)libds34usb.a: modules/ds34usb/ee/libds34usb.a cp $< $@ @@ -499,246 +494,246 @@ modules/ds34usb/ee/libds34usb.a: modules/ds34usb/ee modules/ds34usb/iop/ds34usb.irx: modules/ds34usb/iop $(MAKE) -C $< -$(EE_ASM_DIR)ds34usb.s: modules/ds34usb/iop/ds34usb.irx | $(EE_ASM_DIR) - $(BIN2S) $< $@ ds34usb_irx +$(EE_ASM_DIR)ds34usb.c: modules/ds34usb/iop/ds34usb.irx | $(EE_ASM_DIR) + $(BIN2C) $< $@ $(*F)_irx modules/pademu/bt_pademu.irx: modules/pademu $(MAKE) -C $< USE_BT=1 -$(EE_ASM_DIR)bt_pademu.s: modules/pademu/bt_pademu.irx - $(BIN2S) $< $@ bt_pademu_irx +$(EE_ASM_DIR)bt_pademu.c: modules/pademu/bt_pademu.irx + $(BIN2C) $< $@ $(*F)_irx modules/pademu/usb_pademu.irx: modules/pademu $(MAKE) -C $< USE_USB=1 -$(EE_ASM_DIR)usb_pademu.s: modules/pademu/usb_pademu.irx - $(BIN2S) $< $@ usb_pademu_irx +$(EE_ASM_DIR)usb_pademu.c: modules/pademu/usb_pademu.irx + $(BIN2C) $< $@ $(*F)_irx -$(EE_ASM_DIR)bdm.s: $(PS2SDK)/iop/irx/bdm.irx | $(EE_ASM_DIR) - $(BIN2S) $< $@ bdm_irx +$(EE_ASM_DIR)bdm.c: $(PS2SDK)/iop/irx/bdm.irx | $(EE_ASM_DIR) + $(BIN2C) $< $@ $(*F)_irx -$(EE_ASM_DIR)bdmfs_fatfs.s: $(PS2SDK)/iop/irx/bdmfs_fatfs.irx | $(EE_ASM_DIR) - $(BIN2S) $< $@ bdmfs_fatfs_irx +$(EE_ASM_DIR)bdmfs_fatfs.c: $(PS2SDK)/iop/irx/bdmfs_fatfs.irx | $(EE_ASM_DIR) + $(BIN2C) $< $@ $(*F)_irx -$(EE_ASM_DIR)iLinkman.s: $(PS2SDK)/iop/irx/iLinkman.irx | $(EE_ASM_DIR) - $(BIN2S) $< $@ iLinkman_irx +$(EE_ASM_DIR)iLinkman.c: $(PS2SDK)/iop/irx/iLinkman.irx | $(EE_ASM_DIR) + $(BIN2C) $< $@ $(*F)_irx ifeq ($(DEBUG),1) # block device drivers with printf's -$(EE_ASM_DIR)usbmass_bd.s: $(PS2SDK)/iop/irx/usbmass_bd.irx | $(EE_ASM_DIR) - $(BIN2S) $< $@ usbmass_bd_irx +$(EE_ASM_DIR)usbmass_bd.c: $(PS2SDK)/iop/irx/usbmass_bd.irx | $(EE_ASM_DIR) + $(BIN2C) $< $@ $(*F)_irx -$(EE_ASM_DIR)IEEE1394_bd.s: $(PS2SDK)/iop/irx/IEEE1394_bd.irx | $(EE_ASM_DIR) - $(BIN2S) $< $@ IEEE1394_bd_irx +$(EE_ASM_DIR)IEEE1394_bd.c: $(PS2SDK)/iop/irx/IEEE1394_bd.irx | $(EE_ASM_DIR) + $(BIN2C) $< $@ $(*F)_irx -$(EE_ASM_DIR)mx4sio_bd.s: $(PS2SDK)/iop/irx/mx4sio_bd.irx | $(EE_ASM_DIR) - $(BIN2S) $< $@ mx4sio_bd_irx +$(EE_ASM_DIR)mx4sio_bd.c: $(PS2SDK)/iop/irx/mx4sio_bd.irx | $(EE_ASM_DIR) + $(BIN2C) $< $@ $(*F)_irx else # block device drivers without printf's -$(EE_ASM_DIR)usbmass_bd.s: $(PS2SDK)/iop/irx/usbmass_bd_mini.irx | $(EE_ASM_DIR) - $(BIN2S) $< $@ usbmass_bd_irx +$(EE_ASM_DIR)usbmass_bd.c: $(PS2SDK)/iop/irx/usbmass_bd_mini.irx | $(EE_ASM_DIR) + $(BIN2C) $< $@ $(*F)_irx -$(EE_ASM_DIR)IEEE1394_bd.s: $(PS2SDK)/iop/irx/IEEE1394_bd_mini.irx | $(EE_ASM_DIR) - $(BIN2S) $< $@ IEEE1394_bd_irx +$(EE_ASM_DIR)IEEE1394_bd.c: $(PS2SDK)/iop/irx/IEEE1394_bd_mini.irx | $(EE_ASM_DIR) + $(BIN2C) $< $@ $(*F)_irx -$(EE_ASM_DIR)mx4sio_bd.s: $(PS2SDK)/iop/irx/mx4sio_bd_mini.irx | $(EE_ASM_DIR) - $(BIN2S) $< $@ mx4sio_bd_irx +$(EE_ASM_DIR)mx4sio_bd.c: $(PS2SDK)/iop/irx/mx4sio_bd_mini.irx | $(EE_ASM_DIR) + $(BIN2C) $< $@ $(*F)_irx endif modules/bdmevent/bdmevent.irx: modules/bdmevent $(MAKE) -C $< -$(EE_ASM_DIR)bdmevent.s: modules/bdmevent/bdmevent.irx | $(EE_ASM_DIR) - $(BIN2S) $< $@ bdmevent_irx +$(EE_ASM_DIR)bdmevent.c: modules/bdmevent/bdmevent.irx | $(EE_ASM_DIR) + $(BIN2C) $< $@ $(*F)_irx -$(EE_ASM_DIR)ps2dev9.s: $(PS2SDK)/iop/irx/ps2dev9.irx | $(EE_ASM_DIR) - $(BIN2S) $< $@ ps2dev9_irx +$(EE_ASM_DIR)ps2dev9.c: $(PS2SDK)/iop/irx/ps2dev9.irx | $(EE_ASM_DIR) + $(BIN2C) $< $@ $(*F)_irx modules/network/SMSUTILS/SMSUTILS.irx: modules/network/SMSUTILS $(MAKE) -C $< -$(EE_ASM_DIR)smsutils.s: modules/network/SMSUTILS/SMSUTILS.irx | $(EE_ASM_DIR) - $(BIN2S) $< $@ smsutils_irx +$(EE_ASM_DIR)smsutils.c: modules/network/SMSUTILS/SMSUTILS.irx | $(EE_ASM_DIR) + $(BIN2C) $< $@ $(*F)_irx -$(EE_ASM_DIR)ps2ip.s: $(PS2SDK)/iop/irx/ps2ip-nm.irx | $(EE_ASM_DIR) - $(BIN2S) $< $@ ps2ip_irx +$(EE_ASM_DIR)ps2ip.c: $(PS2SDK)/iop/irx/ps2ip-nm.irx | $(EE_ASM_DIR) + $(BIN2C) $< $@ $(*F)_irx modules/network/SMSTCPIP/SMSTCPIP.irx: modules/network/SMSTCPIP $(MAKE) $(SMSTCPIP_INGAME_CFLAGS) -C $< rebuild -$(EE_ASM_DIR)ingame_smstcpip.s: modules/network/SMSTCPIP/SMSTCPIP.irx | $(EE_ASM_DIR) - $(BIN2S) $< $@ ingame_smstcpip_irx +$(EE_ASM_DIR)ingame_smstcpip.c: modules/network/SMSTCPIP/SMSTCPIP.irx | $(EE_ASM_DIR) + $(BIN2C) $< $@ $(*F)_irx modules/network/smap-ingame/smap.irx: modules/network/smap-ingame $(MAKE) -C $< -$(EE_ASM_DIR)smap_ingame.s: modules/network/smap-ingame/smap.irx | $(EE_ASM_DIR) - $(BIN2S) $< $@ smap_ingame_irx +$(EE_ASM_DIR)smap_ingame.c: modules/network/smap-ingame/smap.irx | $(EE_ASM_DIR) + $(BIN2C) $< $@ $(*F)_irx -$(EE_ASM_DIR)smap.s: $(PS2SDK)/iop/irx/smap.irx | $(EE_ASM_DIR) - $(BIN2S) $< $@ smap_irx +$(EE_ASM_DIR)smap.c: $(PS2SDK)/iop/irx/smap.irx | $(EE_ASM_DIR) + $(BIN2C) $< $@ $(*F)_irx -$(EE_ASM_DIR)netman.s: $(PS2SDK)/iop/irx/netman.irx | $(EE_ASM_DIR) - $(BIN2S) $< $@ netman_irx +$(EE_ASM_DIR)netman.c: $(PS2SDK)/iop/irx/netman.irx | $(EE_ASM_DIR) + $(BIN2C) $< $@ $(*F)_irx -$(EE_ASM_DIR)ps2ips.s: $(PS2SDK)/iop/irx/ps2ips.irx | $(EE_ASM_DIR) - $(BIN2S) $< $@ ps2ips_irx +$(EE_ASM_DIR)ps2ips.c: $(PS2SDK)/iop/irx/ps2ips.irx | $(EE_ASM_DIR) + $(BIN2C) $< $@ $(*F)_irx -$(EE_ASM_DIR)smbman.s: $(PS2SDK)/iop/irx/smbman.irx | $(EE_ASM_DIR) - $(BIN2S) $< $@ smbman_irx +$(EE_ASM_DIR)smbman.c: $(PS2SDK)/iop/irx/smbman.irx | $(EE_ASM_DIR) + $(BIN2C) $< $@ $(*F)_irx modules/network/smbinit/smbinit.irx: modules/network/smbinit $(MAKE) -C $< -$(EE_ASM_DIR)smbinit.s: modules/network/smbinit/smbinit.irx | $(EE_ASM_DIR) - $(BIN2S) $< $@ smbinit_irx +$(EE_ASM_DIR)smbinit.c: modules/network/smbinit/smbinit.irx | $(EE_ASM_DIR) + $(BIN2C) $< $@ $(*F)_irx -$(EE_ASM_DIR)ps2atad.s: $(PS2SDK)/iop/irx/ps2atad.irx | $(EE_ASM_DIR) - $(BIN2S) $< $@ ps2atad_irx +$(EE_ASM_DIR)ps2atad.c: $(PS2SDK)/iop/irx/ps2atad.irx | $(EE_ASM_DIR) + $(BIN2C) $< $@ $(*F)_irx -$(EE_ASM_DIR)hdpro_atad.s: $(PS2SDK)/iop/irx/hdproatad.irx | $(EE_ASM_DIR) - $(BIN2S) $< $@ hdpro_atad_irx +$(EE_ASM_DIR)hdpro_atad.c: $(PS2SDK)/iop/irx/hdproatad.irx | $(EE_ASM_DIR) + $(BIN2C) $< $@ $(*F)_irx -$(EE_ASM_DIR)poweroff.s: $(PS2SDK)/iop/irx/poweroff.irx | $(EE_ASM_DIR) - $(BIN2S) $< $@ poweroff_irx +$(EE_ASM_DIR)poweroff.c: $(PS2SDK)/iop/irx/poweroff.irx | $(EE_ASM_DIR) + $(BIN2C) $< $@ $(*F)_irx modules/hdd/xhdd/xhdd.irx: modules/hdd/xhdd $(MAKE) -C $< -$(EE_ASM_DIR)xhdd.s: modules/hdd/xhdd/xhdd.irx | $(EE_ASM_DIR) - $(BIN2S) $< $@ xhdd_irx +$(EE_ASM_DIR)xhdd.c: modules/hdd/xhdd/xhdd.irx | $(EE_ASM_DIR) + $(BIN2C) $< $@ $(*F)_irx -$(EE_ASM_DIR)ps2hdd.s: $(PS2SDK)/iop/irx/ps2hdd-osd.irx - $(BIN2S) $< $@ ps2hdd_irx +$(EE_ASM_DIR)ps2hdd.c: $(PS2SDK)/iop/irx/ps2hdd-osd.irx + $(BIN2C) $< $@ $(*F)_irx -$(EE_ASM_DIR)ps2fs.s: $(PS2SDK)/iop/irx/ps2fs-osd.irx - $(BIN2S) $< $@ ps2fs_irx +$(EE_ASM_DIR)ps2fs.c: $(PS2SDK)/iop/irx/ps2fs-osd.irx + $(BIN2C) $< $@ $(*F)_irx modules/vmc/genvmc/genvmc.irx: modules/vmc/genvmc $(MAKE) $(MOD_DEBUG_FLAGS) -C $< -$(EE_ASM_DIR)genvmc.s: modules/vmc/genvmc/genvmc.irx | $(EE_ASM_DIR) - $(BIN2S) $< $@ genvmc_irx +$(EE_ASM_DIR)genvmc.c: modules/vmc/genvmc/genvmc.irx | $(EE_ASM_DIR) + $(BIN2C) $< $@ $(*F)_irx modules/network/lwNBD/lwnbdsvr.irx: modules/network/lwNBD $(MAKE) TARGET=iop -C $< -$(EE_ASM_DIR)lwnbdsvr.s: modules/network/lwNBD/lwnbdsvr.irx | $(EE_ASM_DIR) - $(BIN2S) $< $@ lwnbdsvr_irx +$(EE_ASM_DIR)lwnbdsvr.c: modules/network/lwNBD/lwnbdsvr.irx | $(EE_ASM_DIR) + $(BIN2C) $< $@ $(*F)_irx -$(EE_ASM_DIR)udptty.s: $(PS2SDK)/iop/irx/udptty.irx | $(EE_ASM_DIR) - $(BIN2S) $< $@ udptty_irx +$(EE_ASM_DIR)udptty.c: $(PS2SDK)/iop/irx/udptty.irx | $(EE_ASM_DIR) + $(BIN2C) $< $@ $(*F)_irx modules/debug/udptty-ingame/udptty.irx: modules/debug/udptty-ingame $(MAKE) -C $< -$(EE_ASM_DIR)udptty-ingame.s: modules/debug/udptty-ingame/udptty.irx | $(EE_ASM_DIR) - $(BIN2S) $< $@ udptty_ingame_irx +$(EE_ASM_DIR)udptty-ingame.c: modules/debug/udptty-ingame/udptty.irx | $(EE_ASM_DIR) + $(BIN2C) $< $@ udptty_ingame_irx -$(EE_ASM_DIR)ioptrap.s: $(PS2SDK)/iop/irx/ioptrap.irx | $(EE_ASM_DIR) - $(BIN2S) $< $@ ioptrap_irx +$(EE_ASM_DIR)ioptrap.c: $(PS2SDK)/iop/irx/ioptrap.irx | $(EE_ASM_DIR) + $(BIN2C) $< $@ $(*F)_irx modules/debug/ps2link/ps2link.irx: modules/debug/ps2link $(MAKE) -C $< -$(EE_ASM_DIR)ps2link.s: modules/debug/ps2link/ps2link.irx | $(EE_ASM_DIR) - $(BIN2S) $< $@ ps2link_irx +$(EE_ASM_DIR)ps2link.c: modules/debug/ps2link/ps2link.irx | $(EE_ASM_DIR) + $(BIN2C) $< $@ $(*F)_irx modules/network/nbns/nbns.irx: modules/network/nbns $(MAKE) -C $< -$(EE_ASM_DIR)nbns-iop.s: modules/network/nbns/nbns.irx | $(EE_ASM_DIR) - $(BIN2S) $< $@ nbns_irx +$(EE_ASM_DIR)nbns-iop.c: modules/network/nbns/nbns.irx | $(EE_ASM_DIR) + $(BIN2C) $< $@ nbns_irx modules/network/httpclient/httpclient.irx: modules/network/httpclient $(MAKE) -C $< -$(EE_ASM_DIR)httpclient-iop.s: modules/network/httpclient/httpclient.irx | $(EE_ASM_DIR) - $(BIN2S) $< $@ httpclient_irx +$(EE_ASM_DIR)httpclient-iop.c: modules/network/httpclient/httpclient.irx | $(EE_ASM_DIR) + $(BIN2C) $< $@ httpclient_irx -$(EE_ASM_DIR)iomanx.s: $(PS2SDK)/iop/irx/iomanX.irx | $(EE_ASM_DIR) - $(BIN2S) $< $@ iomanx_irx +$(EE_ASM_DIR)iomanx.c: $(PS2SDK)/iop/irx/iomanX.irx | $(EE_ASM_DIR) + $(BIN2C) $< $@ $(*F)_irx -$(EE_ASM_DIR)filexio.s: $(PS2SDK)/iop/irx/fileXio.irx | $(EE_ASM_DIR) - $(BIN2S) $< $@ filexio_irx +$(EE_ASM_DIR)filexio.c: $(PS2SDK)/iop/irx/fileXio.irx | $(EE_ASM_DIR) + $(BIN2C) $< $@ $(*F)_irx -$(EE_ASM_DIR)sio2man.s: $(PS2SDK)/iop/irx/freesio2.irx | $(EE_ASM_DIR) - $(BIN2S) $< $@ sio2man_irx +$(EE_ASM_DIR)sio2man.c: $(PS2SDK)/iop/irx/freesio2.irx | $(EE_ASM_DIR) + $(BIN2C) $< $@ $(*F)_irx -$(EE_ASM_DIR)padman.s: $(PS2SDK)/iop/irx/freepad.irx | $(EE_ASM_DIR) - $(BIN2S) $< $@ padman_irx +$(EE_ASM_DIR)padman.c: $(PS2SDK)/iop/irx/freepad.irx | $(EE_ASM_DIR) + $(BIN2C) $< $@ $(*F)_irx -$(EE_ASM_DIR)mcman.s: $(PS2SDK)/iop/irx/mcman.irx | $(EE_ASM_DIR) - $(BIN2S) $< $@ mcman_irx +$(EE_ASM_DIR)mcman.c: $(PS2SDK)/iop/irx/mcman.irx | $(EE_ASM_DIR) + $(BIN2C) $< $@ $(*F)_irx -$(EE_ASM_DIR)mcserv.s: $(PS2SDK)/iop/irx/mcserv.irx | $(EE_ASM_DIR) - $(BIN2S) $< $@ mcserv_irx +$(EE_ASM_DIR)mcserv.c: $(PS2SDK)/iop/irx/mcserv.irx | $(EE_ASM_DIR) + $(BIN2C) $< $@ $(*F)_irx -$(EE_ASM_DIR)poeveticanew.s: thirdparty/PoeVeticaNew.ttf | $(EE_ASM_DIR) - $(BIN2S) $< $@ poeveticanew_raw +$(EE_ASM_DIR)poeveticanew.c: thirdparty/PoeVeticaNew.ttf | $(EE_ASM_DIR) + $(BIN2C) $< $@ $(*F)_raw -$(EE_ASM_DIR)icon_sys.s: gfx/icon.sys | $(EE_ASM_DIR) - $(BIN2S) $< $@ icon_sys +$(EE_ASM_DIR)icon_sys.c: gfx/icon.sys | $(EE_ASM_DIR) + $(BIN2C) $< $@ $(*F) -$(EE_ASM_DIR)icon_icn.s: gfx/opl.icn | $(EE_ASM_DIR) - $(BIN2S) $< $@ icon_icn +$(EE_ASM_DIR)icon_icn.c: gfx/opl.icn | $(EE_ASM_DIR) + $(BIN2C) $< $@ $(*F) -$(EE_ASM_DIR)icon_sys_A.s: misc/icon_A.sys | $(EE_ASM_DIR) - $(BIN2S) $< $@ icon_sys_A +$(EE_ASM_DIR)icon_sys_A.c: misc/icon_A.sys | $(EE_ASM_DIR) + $(BIN2C) $< $@ $(*F) -$(EE_ASM_DIR)icon_sys_J.s: misc/icon_J.sys | $(EE_ASM_DIR) - $(BIN2S) $< $@ icon_sys_J +$(EE_ASM_DIR)icon_sys_J.c: misc/icon_J.sys | $(EE_ASM_DIR) + $(BIN2C) $< $@ $(*F) -$(EE_ASM_DIR)icon_sys_C.s: misc/icon_C.sys | $(EE_ASM_DIR) - $(BIN2S) $< $@ icon_sys_C +$(EE_ASM_DIR)icon_sys_C.c: misc/icon_C.sys | $(EE_ASM_DIR) + $(BIN2C) $< $@ $(*F) -$(EE_ASM_DIR)conf_theme_OPL.s: misc/conf_theme_OPL.cfg | $(EE_ASM_DIR) - $(BIN2S) $< $@ conf_theme_OPL_cfg +$(EE_ASM_DIR)conf_theme_OPL.c: misc/conf_theme_OPL.cfg | $(EE_ASM_DIR) + $(BIN2C) $< $@ $(*F)_cfg -$(EE_ASM_DIR)boot.s: audio/boot.adp | $(EE_ASM_DIR) - $(BIN2S) $< $@ boot_adp +$(EE_ASM_DIR)boot.c: audio/boot.adp | $(EE_ASM_DIR) + $(BIN2C) $< $@ $(*F)_adp -$(EE_ASM_DIR)cancel.s: audio/cancel.adp | $(EE_ASM_DIR) - $(BIN2S) $< $@ cancel_adp +$(EE_ASM_DIR)cancel.c: audio/cancel.adp | $(EE_ASM_DIR) + $(BIN2C) $< $@ $(*F)_adp -$(EE_ASM_DIR)confirm.s: audio/confirm.adp | $(EE_ASM_DIR) - $(BIN2S) $< $@ confirm_adp +$(EE_ASM_DIR)confirm.c: audio/confirm.adp | $(EE_ASM_DIR) + $(BIN2C) $< $@ $(*F)_adp -$(EE_ASM_DIR)cursor.s: audio/cursor.adp | $(EE_ASM_DIR) - $(BIN2S) $< $@ cursor_adp +$(EE_ASM_DIR)cursor.c: audio/cursor.adp | $(EE_ASM_DIR) + $(BIN2C) $< $@ $(*F)_adp -$(EE_ASM_DIR)message.s: audio/message.adp | $(EE_ASM_DIR) - $(BIN2S) $< $@ message_adp +$(EE_ASM_DIR)message.c: audio/message.adp | $(EE_ASM_DIR) + $(BIN2C) $< $@ $(*F)_adp -$(EE_ASM_DIR)transition.s: audio/transition.adp | $(EE_ASM_DIR) - $(BIN2S) $< $@ transition_adp +$(EE_ASM_DIR)transition.c: audio/transition.adp | $(EE_ASM_DIR) + $(BIN2C) $< $@ $(*F)_adp -$(EE_ASM_DIR)IOPRP_img.s: modules/iopcore/IOPRP.img | $(EE_ASM_DIR) - $(BIN2S) $< $@ IOPRP_img +$(EE_ASM_DIR)IOPRP_img.c: modules/iopcore/IOPRP.img | $(EE_ASM_DIR) + $(BIN2C) $< $@ $(*F) -$(EE_ASM_DIR)drvtif_ingame_irx.s: modules/debug/drvtif-ingame.irx | $(EE_ASM_DIR) - $(BIN2S) $< $@ drvtif_ingame_irx +$(EE_ASM_DIR)drvtif_ingame_irx.c: modules/debug/drvtif-ingame.irx | $(EE_ASM_DIR) + $(BIN2C) $< $@ $(*F) -$(EE_ASM_DIR)tifinet_ingame_irx.s: modules/debug/tifinet-ingame.irx | $(EE_ASM_DIR) - $(BIN2S) $< $@ tifinet_ingame_irx +$(EE_ASM_DIR)tifinet_ingame_irx.c: modules/debug/tifinet-ingame.irx | $(EE_ASM_DIR) + $(BIN2C) $< $@ $(*F) -$(EE_ASM_DIR)drvtif_irx.s: modules/debug/drvtif.irx | $(EE_ASM_DIR) - $(BIN2S) $< $@ drvtif_irx +$(EE_ASM_DIR)drvtif_irx.c: modules/debug/drvtif.irx | $(EE_ASM_DIR) + $(BIN2C) $< $@ $(*F) -$(EE_ASM_DIR)tifinet_irx.s: modules/debug/tifinet.irx | $(EE_ASM_DIR) - $(BIN2S) $< $@ tifinet_irx +$(EE_ASM_DIR)tifinet_irx.c: modules/debug/tifinet.irx | $(EE_ASM_DIR) + $(BIN2C) $< $@ $(*F) -$(EE_ASM_DIR)deci2_img.s: modules/debug/deci2.img | $(EE_ASM_DIR) - $(BIN2S) $< $@ deci2_img +$(EE_ASM_DIR)deci2_img.c: modules/debug/deci2.img | $(EE_ASM_DIR) + $(BIN2C) $< $@ $(*F) $(EE_OBJS_DIR)%.o: $(EE_SRC_DIR)%.c | $(EE_OBJS_DIR) $(EE_CC) $(EE_CFLAGS) $(EE_INCS) -c $< -o $@ -$(EE_OBJS_DIR)%.o: $(EE_ASM_DIR)%.s | $(EE_OBJS_DIR) - $(EE_AS) $(EE_ASFLAGS) $< -o $@ +$(EE_OBJS_DIR)%.o: $(EE_ASM_DIR)%.c | $(EE_OBJS_DIR) + $(EE_CC) $(EE_CFLAGS) $(EE_INCS) -c $< -o $@ -$(PNG_ASSETS:%=$(EE_ASM_DIR)%_png.s): $(EE_ASM_DIR)%_png.s: $(PNG_ASSETS_DIR)%.png | $(EE_ASM_DIR) - $(BIN2S) $< $@ $(@:$(EE_ASM_DIR)%.s=%) +$(PNG_ASSETS:%=$(EE_ASM_DIR)%_png.c): $(EE_ASM_DIR)%_png.c: $(PNG_ASSETS_DIR)%.png | $(EE_ASM_DIR) + $(BIN2C) $< $@ $(@:$(EE_ASM_DIR)%.c=%) endif diff --git a/README.md b/README.md index 106422d41..f709ad840 100644 --- a/README.md +++ b/README.md @@ -128,24 +128,30 @@ that contains the preferred partition name (for example `__common`). NBD Server

-A [NBD](https://en.wikipedia.org/wiki/Network_block_device) server replaced HDL server. -NBD is [formally documented](https://github.com/NetworkBlockDevice/nbd/blob/master/doc/proto.md) -and developed as a collaborative open standard. -The current implementation of the server is based on [lwNBD](https://github.com/bignaux/lwNBD), -go there to contribute. -The main advantage of using NBD is that the client will simulate a similar -interface to the OS as if the device was plugged directly into your machine. -All your favorite software that worked with the device directly connected to your -machine, will work with the device accessible through the network. - -Currently, only export for HDD is supported by the server. -You can use hdl-dump, pfs-shell, or even directly edit disk in some hex editor. -Example, how to install HDL game to the HDD: -Connect with your choosen client, then `hdl_dump inject_dvd ps2/nbd "Test Game" ./TEST.ISO` -and when you're done, disconnect the client. - -So you need a NBD client. -Here we list some known compatible clients and how to use them. +OPL now uses an [NBD](https://en.wikipedia.org/wiki/Network_block_device) server to share the internal hard drive, instead of HDL server. +NBD is [formally documented](https://github.com/NetworkBlockDevice/nbd/blob/master/doc/proto.md) and developed as a collaborative open standard. + +The current implementation of the server is based on [lwNBD](https://github.com/bignaux/lwNBD), go there to contribute on the NBD code itself. + +The main advantage of using NBD is that the client will expose the drive to your operating system in a similar way as a directly attached drive. +This means that any utility that worked with the drive when it was directly attached should work the same way with NBD. + +OPL currently only supports exporting (sharing out) the PS2's drive. + +You can use `hdl-dump`, `pfs-shell`, or even directly edit the disk in a hex editor. + +For example, to use `hdl_dump` to install a game to the HDD: + + * Connect with your choosen client (OS specific) + * Run `hdl_dump inject_dvd ps2/nbd "Test Game" ./TEST.ISO` + * Disconnect the client. + +To use the NBD server in OPL: + + * Grab the latest beta version (OPL 1.1.0 (current stable) has some bugs in the NBD server) - go to the [Releases](https://github.com/ps2homebrew/Open-PS2-Loader/releases) section and grab the one at the top. + * Ensure OPL is configured with an IP address (either static or DHCP). + * Open the menu and select "Start NBD server". Once it's ready, it should update the screen to say "NBD Server running..." + * Now you can connect with any of the following NBD clients. ### nbd-client diff --git a/ee_core/include/coreconfig.h b/ee_core/include/coreconfig.h new file mode 100644 index 000000000..b3d6a0a77 --- /dev/null +++ b/ee_core/include/coreconfig.h @@ -0,0 +1,74 @@ +#ifndef EE_CORE_CONFIG_H_ +#define EE_CORE_CONFIG_H_ + +#include +#define CORE_EXIT_PATH_MAX_LEN (256) +#define CORE_GAME_MODE_DESC_MAX_LEN (16) +#define CORE_GAME_ID_MAX_LEN (16) + +// Do not use "EE" as it might catch a string. +#define EE_CORE_MAGIC_0 (0x4D614730) +#define EE_CORE_MAGIC_1 (0x4D616731) +// #include "ee_core.h" + +struct GsmConfig_t +{ + s16 interlace; + s16 mode; + s16 ffmd; + u32 dx_offset; + u32 dy_offset; + u64 display; + u64 syncv; + u64 smode2; + int k576P_fix; + int kGsDxDyOffsetSupported; + int FIELD_fix; +}; + + +struct EECoreConfig_t +{ + u32 magic[2]; + + char GameMode; + char GameModeDesc[CORE_GAME_MODE_DESC_MAX_LEN]; + + int EnableDebug; + + char ExitPath[CORE_EXIT_PATH_MAX_LEN]; + + int HDDSpindown; + + char g_ps2_ip[16]; + char g_ps2_netmask[16]; + char g_ps2_gateway[16]; + unsigned char g_ps2_ETHOpMode; + + unsigned int *gCheatList; // Store hooks/codes addr+val pairs + + void *eeloadCopy; + void *initUserMemory; + + void *ModStorageStart; + void *ModStorageEnd; + + char GameID[CORE_GAME_ID_MAX_LEN]; + + u32 _CompatMask; + + ConfigParam CustomOSDConfigParam; + int enforceLanguage; + + // Keep them eitherway. + int EnablePadEmuOp; + int PadEmuSettings; + int PadMacroSettings; + + int EnableGSMOp; + struct GsmConfig_t GsmConfig; +}; + +#define USE_LOCAL_EECORE_CONFIG struct EECoreConfig_t *config = &g_ee_core_config; +extern struct EECoreConfig_t g_ee_core_config; +#endif diff --git a/ee_core/include/ee_core.h b/ee_core/include/ee_core.h index 75fc186ce..5dca2fd33 100644 --- a/ee_core/include/ee_core.h +++ b/ee_core/include/ee_core.h @@ -22,8 +22,8 @@ #include #ifdef __EESIO_DEBUG -#define DPRINTF(args...) ; -#define DINIT() ; +#define DPRINTF(args...) _print(args); +#define DINIT() InitDebug(); #else #define DPRINTF(args...) \ do { \ @@ -39,8 +39,6 @@ extern int iop_reboot_count; extern int padOpen_hooked; -extern int enforceLanguage; - enum ETH_OP_MODES { ETH_OP_MODE_AUTO = 0, ETH_OP_MODE_100M_FDX, @@ -54,10 +52,6 @@ enum ETH_OP_MODES { #define IPCONFIG_MAX_LEN 64 extern char g_ipconfig[IPCONFIG_MAX_LEN]; extern int g_ipconfig_len; -extern char g_ps2_ip[16]; -extern char g_ps2_netmask[16]; -extern char g_ps2_gateway[16]; -extern unsigned char g_ps2_ETHOpMode; extern u32 g_compat_mask; #define COMPAT_MODE_1 0x01 @@ -69,8 +63,6 @@ extern u32 g_compat_mask; #define COMPAT_MODE_7 0x40 #define COMPAT_MODE_8 0x80 -extern char GameID[16]; -extern int GameMode; enum GAME_MODE { BDM_ILK_MODE, BDM_M4S_MODE, @@ -79,19 +71,7 @@ enum GAME_MODE { HDD_MODE, }; -extern char ExitPath[32]; -extern int HDDSpindown; -extern int EnableGSMOp; -extern int EnableCheatOp; -#ifdef PADEMU -extern int EnablePadEmuOp; -extern int PadEmuSettings; -extern int PadMacroSettings; -#endif - extern int EnableDebug; #define GS_BGCOLOUR *((volatile unsigned long int *)0x120000E0) -extern int *gCheatList; // Store hooks/codes addr+val pairs - #endif diff --git a/ee_core/include/modmgr.h b/ee_core/include/modmgr.h index b85def6f7..135c4377a 100644 --- a/ee_core/include/modmgr.h +++ b/ee_core/include/modmgr.h @@ -86,7 +86,7 @@ typedef struct int LoadFileInit(); void LoadFileExit(); -int LoadModule(const char *path, int arg_len, const char *args); +int LoadModule(const char *path, int arg_len, const char *args, int mode); int LoadMemModule(int mode, void *modptr, unsigned int modsize, int arg_len, const char *args); int GetOPLModInfo(int id, void **pointer, unsigned int *size); int LoadOPLModule(int id, int mode, int arg_len, const char *args); diff --git a/ee_core/include/modules.h b/ee_core/include/modules.h index 11a8f82d0..4e9d70c8e 100644 --- a/ee_core/include/modules.h +++ b/ee_core/include/modules.h @@ -1,7 +1,6 @@ enum OPL_MODULE_ID { // Basic modules - OPL_MODULE_ID_UDNL = 1, - OPL_MODULE_ID_IOPRP, + OPL_MODULE_ID_IOPRP = 1, OPL_MODULE_ID_IMGDRV, OPL_MODULE_ID_RESETSPU, diff --git a/ee_core/include/syshook.h b/ee_core/include/syshook.h index 9608ec6ba..be5a01087 100644 --- a/ee_core/include/syshook.h +++ b/ee_core/include/syshook.h @@ -13,8 +13,6 @@ #include #include -extern ConfigParam CustomOSDConfigParam; - void Install_Kernel_Hooks(void); void Remove_Kernel_Hooks(void); @@ -23,8 +21,8 @@ extern int (*Old_SifSetReg)(u32 register_num, int register_value); extern int (*Old_ExecPS2)(void *entry, void *gp, int num_args, char *args[]); extern int (*Old_CreateThread)(ee_thread_t *thread_param); extern void (*Old_Exit)(s32 exit_code); -extern void (*Old_SetOsdConfigParam)(ConfigParam *config); -extern void (*Old_GetOsdConfigParam)(ConfigParam *config); +extern void (*Old_SetOsdConfigParam)(ConfigParam *osdconfig); +extern void (*Old_GetOsdConfigParam)(ConfigParam *osdconfig); void sysLoadElf(char *filename, int argc, char **argv); void sysExit(s32 exit_code); diff --git a/ee_core/src/cheat_api.c b/ee_core/src/cheat_api.c index 27259c70f..e6d826b8a 100644 --- a/ee_core/src/cheat_api.c +++ b/ee_core/src/cheat_api.c @@ -25,12 +25,14 @@ #include #include #include "include/cheat_api.h" +#include "coreconfig.h" /*---------------------------------*/ /* Setup PS2RD Cheat Engine params */ /*---------------------------------*/ void SetupCheats() { + USE_LOCAL_EECORE_CONFIG; code_t code; int i, j, k, nextCodeCanBeHook; @@ -41,8 +43,8 @@ void SetupCheats() while (i < MAX_CHEATLIST) { - code.addr = gCheatList[i]; - code.val = gCheatList[i + 1]; + code.addr = config->gCheatList[i]; + code.val = config->gCheatList[i + 1]; i += 2; if ((code.addr == 0) && (code.val == 0)) diff --git a/ee_core/src/igs_api.c b/ee_core/src/igs_api.c index 688d72dd9..db889edc7 100644 --- a/ee_core/src/igs_api.c +++ b/ee_core/src/igs_api.c @@ -25,6 +25,7 @@ #include "include/igs_api.h" #define NEWLIB_PORT_AWARE #include "fileio.h" +#include "coreconfig.h" static void FastDelay(int count) { @@ -388,6 +389,7 @@ static void ConvertColors16(u16 *buffer, u32 dimensions) static void SaveTextFile(u32 buffer, u16 width, u16 height, u8 pixel_size, u32 image_size, u8 Number) { + USE_LOCAL_EECORE_CONFIG; delay(1); GS_BGCOLOUR = 0x0099FF; // Orange @@ -414,7 +416,7 @@ static void SaveTextFile(u32 buffer, u16 width, u16 height, u8 pixel_size, u32 i // Sequential number, inherited from Bitmap File _strcpy(PathFilenameExtension, "mc1:/"); - _strcat(PathFilenameExtension, GameID); + _strcat(PathFilenameExtension, config->GameID); _strcat(PathFilenameExtension, "_GS("); u8todecstr(Number, u8text, 3); _strcat(PathFilenameExtension, u8text); @@ -427,7 +429,7 @@ static void SaveTextFile(u32 buffer, u16 width, u16 height, u8 pixel_size, u32 i _strcpy(text, "PS2 IGS (InGame Screenshot)\n---------------------------\n"); _strcat(text, "\n\nGame ID="); - _strcat(text, GameID); + _strcat(text, config->GameID); _strcat(text, "\nResolution="); u16todecstr(width, u16text, 5); _strcat(text, u16text); @@ -572,6 +574,7 @@ static void SaveTextFile(u32 buffer, u16 width, u16 height, u8 pixel_size, u32 i static u8 SaveBitmapFile(u16 width, u16 height, u8 pixel_size, void *buffer, u8 intffmd) { + USE_LOCAL_EECORE_CONFIG; delay(1); GS_BGCOLOUR = 0x990066; // Purple Violet @@ -612,7 +615,7 @@ static u8 SaveBitmapFile(u16 width, u16 height, u8 pixel_size, void *buffer, u8 BlinkColour(6, 0x0000FF, 1); // Red Number++; _strcpy(PathFilenameExtension, "mc1:/"); - _strcat(PathFilenameExtension, GameID); + _strcat(PathFilenameExtension, config->GameID); _strcat(PathFilenameExtension, "_GS("); u8todecstr(Number, u8text, 3); _strcat(PathFilenameExtension, u8text); @@ -776,8 +779,8 @@ int InGameScreenshot(void) // Load modules. LoadFileInit(); - LoadModule("rom0:SIO2MAN", 0, NULL); - LoadModule("rom0:MCMAN", 0, NULL); + LoadModule("rom0:SIO2MAN", 0, NULL, 0); + LoadModule("rom0:MCMAN", 0, NULL, 0); // Save IGS Bitmap File first, since it's the bigger file) intffmd = GET_SMODE2_INTFFMD(smode2); diff --git a/ee_core/src/iopmgr.c b/ee_core/src/iopmgr.c index b7adffbcc..97621bae2 100644 --- a/ee_core/src/iopmgr.c +++ b/ee_core/src/iopmgr.c @@ -15,6 +15,7 @@ #include "modmgr.h" #include "util.h" #include "syshook.h" +#include "coreconfig.h" extern int _iop_reboot_count; static int imgdrv_offset_ioprpimg = 0; @@ -22,6 +23,7 @@ static int imgdrv_offset_ioprpsiz = 0; static void ResetIopSpecial(const char *args, unsigned int arglen) { + USE_LOCAL_EECORE_CONFIG; int i; void *pIOP_buffer, *IOPRP_img, *imgdrv_irx; unsigned int length_rounded, CommandLen, size_IOPRP_img, size_imgdrv_irx; @@ -32,11 +34,11 @@ static void ResetIopSpecial(const char *args, unsigned int arglen) command[arglen] = '\0'; /* In a normal IOP reset process, the IOP reset command line will be NULL-terminated properly somewhere. Since we're now taking things into our own hands, NULL terminate it here. Some games like SOCOM3 will use a command line that isn't NULL terminated, resulting in things like "cdrom0:\RUN\IRX\DNAS300.IMGG;1" */ - _strcpy(&command[arglen + 1], "img0:"); - CommandLen = arglen + 6; + _strcpy(&command[arglen + 1], "host0:"); + CommandLen = arglen + 7; } else { - _strcpy(command, "img0:"); - CommandLen = 5; + _strcpy(command, "host0:"); + CommandLen = 6; } GetOPLModInfo(OPL_MODULE_ID_IOPRP, &IOPRP_img, &size_IOPRP_img); @@ -61,20 +63,15 @@ static void ResetIopSpecial(const char *args, unsigned int arglen) *(void **)(UNCACHED_SEG(&((unsigned char *)imgdrv_irx)[imgdrv_offset_ioprpimg])) = pIOP_buffer; *(u32 *)(UNCACHED_SEG(&((unsigned char *)imgdrv_irx)[imgdrv_offset_ioprpsiz])) = size_IOPRP_img; + LoadModule("rom0:SYSCLIB", 0, NULL, 0); LoadMemModule(0, imgdrv_irx, size_imgdrv_irx, 0, NULL); - - DIntr(); - ee_kmode_enter(); - Old_SifSetReg(SIF_REG_SMFLAG, SIF_STAT_BOOTEND); - ee_kmode_exit(); - EIntr(); - - LoadOPLModule(OPL_MODULE_ID_UDNL, SIF_RPC_M_NOWAIT, CommandLen, command); + LoadModule("rom0:UDNL", CommandLen, command, 1); DIntr(); ee_kmode_enter(); Old_SifSetReg(SIF_REG_SMFLAG, SIF_STAT_SIFINIT); Old_SifSetReg(SIF_REG_SMFLAG, SIF_STAT_CMDINIT); + Old_SifSetReg(SIF_REG_SMFLAG, SIF_STAT_BOOTEND); Old_SifSetReg(SIF_SYSREG_RPCINIT, 0); Old_SifSetReg(SIF_SYSREG_SUBADDR, (int)NULL); ee_kmode_exit(); @@ -108,15 +105,15 @@ static void ResetIopSpecial(const char *args, unsigned int arglen) #endif #ifdef PADEMU -#define PADEMU_ARG || EnablePadEmuOp +#define PADEMU_ARG || config->EnablePadEmuOp #else #define PADEMU_ARG #endif - if (GameMode == BDM_USB_MODE PADEMU_ARG) { + if (config->GameMode == BDM_USB_MODE PADEMU_ARG) { LoadOPLModule(OPL_MODULE_ID_USBD, 0, 11, "thpri=2,3"); } - switch (GameMode) { + switch (config->GameMode) { case BDM_USB_MODE: LoadOPLModule(OPL_MODULE_ID_USBMASSBD, 0, 0, NULL); break; @@ -144,6 +141,7 @@ static void ResetIopSpecial(const char *args, unsigned int arglen) /*----------------------------------------------------------------*/ int New_Reset_Iop(const char *arg, int arglen) { + USE_LOCAL_EECORE_CONFIG; DPRINTF("New_Reset_Iop start!\n"); if (EnableDebug) GS_BGCOLOUR = 0xFF00FF; // Purple @@ -177,17 +175,17 @@ int New_Reset_Iop(const char *arg, int arglen) if (iop_reboot_count >= 2) { #ifdef PADEMU - PadEmuSettings |= (LoadOPLModule(OPL_MODULE_ID_MCEMU, 0, 0, NULL) > 0) << 24; + config->PadEmuSettings |= (LoadOPLModule(OPL_MODULE_ID_MCEMU, 0, 0, NULL) > 0) << 24; #else LoadOPLModule(OPL_MODULE_ID_MCEMU, 0, 0, NULL); #endif } #ifdef PADEMU - if (iop_reboot_count >= 2 && EnablePadEmuOp) { + if (iop_reboot_count >= 2 && config->EnablePadEmuOp) { char args_for_pademu[8]; - memcpy(args_for_pademu, &PadEmuSettings, 4); - memcpy(args_for_pademu + 4, &PadMacroSettings, 4); + memcpy(args_for_pademu, &config->PadEmuSettings, 4); + memcpy(args_for_pademu + 4, &config->PadMacroSettings, 4); LoadOPLModule(OPL_MODULE_ID_PADEMU, 0, sizeof(args_for_pademu), args_for_pademu); } #endif diff --git a/ee_core/src/main.c b/ee_core/src/main.c index d1baf85b1..2d517589c 100644 --- a/ee_core/src/main.c +++ b/ee_core/src/main.c @@ -13,35 +13,15 @@ #include "syshook.h" #include "gsm_api.h" #include "cheat_api.h" - -void *ModStorageStart, *ModStorageEnd; -void *eeloadCopy, *initUserMemory; +#include "coreconfig.h" int isInit = 0; // Global data char g_ipconfig[IPCONFIG_MAX_LEN]; int g_ipconfig_len; -char g_ps2_ip[16]; -char g_ps2_netmask[16]; -char g_ps2_gateway[16]; -unsigned char g_ps2_ETHOpMode; u32 g_compat_mask; -char GameID[16]; -int GameMode; -char ExitPath[32]; -int HDDSpindown; -int EnableGSMOp; -int EnableCheatOp; -#ifdef PADEMU -int EnablePadEmuOp; -int PadEmuSettings; -int PadMacroSettings; -#endif int EnableDebug; -int *gCheatList; // Store hooks/codes addr+val pairs - -int enforceLanguage; // This function is defined as weak in ps2sdkc, so how // we are not using time zone, so we can safe some KB @@ -50,123 +30,81 @@ void _ps2sdk_timezone_update() {} DISABLE_PATCHED_FUNCTIONS(); // Disable the patched functionalities DISABLE_EXTRA_TIMERS_FUNCTIONS(); // Disable the extra functionalities for timers +struct EECoreConfig_t g_ee_core_config = {.magic[0] = EE_CORE_MAGIC_0, .magic[1] = EE_CORE_MAGIC_1}; + static int eecoreInit(int argc, char **argv) { - int i = 0; - char *p; + USE_LOCAL_EECORE_CONFIG; SifInitRpc(0); DINIT(); DPRINTF("OPL EE core start!\n"); - p = _strtok(argv[i], " "); - if (!_strncmp(argv[i], "BDM_ILK_MODE", 12)) - GameMode = BDM_ILK_MODE; - else if (!_strncmp(argv[i], "BDM_M4S_MODE", 12)) - GameMode = BDM_M4S_MODE; - else if (!_strncmp(p, "BDM_USB_MODE", 12)) - GameMode = BDM_USB_MODE; - else if (!_strncmp(p, "ETH_MODE", 8)) - GameMode = ETH_MODE; - else if (!_strncmp(p, "HDD_MODE", 8)) - GameMode = HDD_MODE; - DPRINTF("Game Mode = %d\n", GameMode); - - p = _strtok(NULL, " "); - EnableDebug = 0; - if (!_strncmp(p, "1", 1)) { - EnableDebug = 1; - DPRINTF("Debug Colors enabled\n"); - } + if (!_strncmp(config->GameModeDesc, "BDM_ILK_MODE", 12)) + config->GameMode = BDM_ILK_MODE; + else if (!_strncmp(config->GameModeDesc, "BDM_M4S_MODE", 12)) + config->GameMode = BDM_M4S_MODE; + else if (!_strncmp(config->GameModeDesc, "BDM_USB_MODE", 12)) + config->GameMode = BDM_USB_MODE; + else if (!_strncmp(config->GameModeDesc, "ETH_MODE", 8)) + config->GameMode = ETH_MODE; + else if (!_strncmp(config->GameModeDesc, "HDD_MODE", 8)) + config->GameMode = HDD_MODE; + DPRINTF("Game Mode = %d %s\n", config->GameMode, config->GameModeDesc); + + EnableDebug = config->EnableDebug; + DPRINTF("EnableDebug = %d\n", config->EnableDebug); - p = _strtok(NULL, " "); - if (!_strncmp(p, "Browser", 7)) - ExitPath[0] = '\0'; - else - _strcpy(ExitPath, p); - DPRINTF("Exit Path = (%s)\n", ExitPath); + if (!_strncmp(config->ExitPath, "Browser", 7)) + config->ExitPath[0] = '\0'; - p = _strtok(NULL, " "); - HDDSpindown = _strtoui(p); - DPRINTF("HDD Spindown = %d\n", HDDSpindown); + DPRINTF("Exit Path = (%s)\n", config->ExitPath); + DPRINTF("HDD Spindown = %d\n", config->HDDSpindown); - _strcpy(g_ps2_ip, _strtok(NULL, " ")); - _strcpy(g_ps2_netmask, _strtok(NULL, " ")); - _strcpy(g_ps2_gateway, _strtok(NULL, " ")); - g_ps2_ETHOpMode = _strtoui(_strtok(NULL, " ")); - DPRINTF("IP=%s NM=%s GW=%s mode: %d\n", g_ps2_ip, g_ps2_netmask, g_ps2_gateway, g_ps2_ETHOpMode); + DPRINTF("IP=%s NM=%s GW=%s mode: %d\n", config->g_ps2_ip, config->g_ps2_netmask, config->g_ps2_gateway, config->g_ps2_ETHOpMode); - EnableCheatOp = (gCheatList = (void *)_strtoui(_strtok(NULL, " "))) != NULL; - DPRINTF("PS2RD Cheat Engine = %s\n", EnableCheatOp == 0 ? "Disabled" : "Enabled"); + DPRINTF("PS2RD Cheat Engine = %s\n", config->gCheatList == NULL ? "Disabled" : "Enabled"); - EnableGSMOp = _strtoi(_strtok(NULL, " ")); - DPRINTF("GSM = %s\n", EnableGSMOp == 0 ? "Disabled" : "Enabled"); + DPRINTF("GSM = %s\n", config->EnableGSMOp == 0 ? "Disabled" : "Enabled"); #ifdef PADEMU - EnablePadEmuOp = _strtoi(_strtok(NULL, " ")); - DPRINTF("PADEMU = %s\n", EnablePadEmuOp == 0 ? "Disabled" : "Enabled"); + DPRINTF("PADEMU = %s\n", config->EnablePadEmuOp == 0 ? "Disabled" : "Enabled"); +#endif - PadEmuSettings = _strtoi(_strtok(NULL, " ")); + DPRINTF("enforceLanguage = %s\n", config->enforceLanguage == 0 ? "Disabled" : "Enabled"); - PadMacroSettings = _strtoi(_strtok(NULL, " ")); -#endif - CustomOSDConfigParam.spdifMode = _strtoi(_strtok(NULL, " ")); - CustomOSDConfigParam.screenType = _strtoi(_strtok(NULL, " ")); - CustomOSDConfigParam.videoOutput = _strtoi(_strtok(NULL, " ")); - CustomOSDConfigParam.japLanguage = _strtoi(_strtok(NULL, " ")); - CustomOSDConfigParam.ps1drvConfig = _strtoi(_strtok(NULL, " ")); - CustomOSDConfigParam.version = _strtoi(_strtok(NULL, " ")); - CustomOSDConfigParam.language = _strtoi(_strtok(NULL, " ")); - CustomOSDConfigParam.timezoneOffset = _strtoi(_strtok(NULL, " ")); - enforceLanguage = _strtoi(_strtok(NULL, " ")); - - i++; - - eeloadCopy = (void *)_strtoui(_strtok(argv[i], " ")); - initUserMemory = (void *)_strtoui(_strtok(NULL, " ")); - i++; - - ModStorageStart = (void *)_strtoui(_strtok(argv[i], " ")); - ModStorageEnd = (void *)_strtoui(_strtok(NULL, " ")); - i++; - - strncpy(GameID, argv[i], sizeof(GameID) - 1); - GameID[sizeof(GameID) - 1] = '\0'; - i++; - - // bitmask of the compat. settings - g_compat_mask = _strtoui(argv[i]); - DPRINTF("Compat Mask = 0x%02x\n", g_compat_mask); + DPRINTF("eeloadCopy = 0x%08X\n", config->eeloadCopy); + DPRINTF("initUserMemory = 0x%08X\n", config->initUserMemory); + + DPRINTF("ModStorageStart = 0x%08X\n", config->ModStorageStart); + DPRINTF("ModStorageEnd = 0x%08X\n", config->ModStorageEnd); - i++; + DPRINTF("GameID = %s\n", config->GameID); - if (EnableCheatOp) { + // g_compat_mask is used on ASM directly. + g_compat_mask = config->_CompatMask; + DPRINTF("Compat Mask = 0x%02x\n", g_compat_mask); + + if (config->gCheatList) { EnableCheats(); } - if (EnableGSMOp) { - s16 interlace, mode, ffmd; - u32 dx_offset, dy_offset; - u64 display, syncv, smode2; - int k576P_fix, kGsDxDyOffsetSupported, FIELD_fix; - - interlace = _strtoi(_strtok(argv[i], " ")); - mode = _strtoi(_strtok(NULL, " ")); - ffmd = _strtoi(_strtok(NULL, " ")); - display = _strtoul(_strtok(NULL, " ")); - syncv = _strtoul(_strtok(NULL, " ")); - smode2 = _strtoui(_strtok(NULL, " ")); - dx_offset = _strtoui(_strtok(NULL, " ")); - dy_offset = _strtoui(_strtok(NULL, " ")); - k576P_fix = _strtoui(_strtok(NULL, " ")); - kGsDxDyOffsetSupported = _strtoui(_strtok(NULL, " ")); - FIELD_fix = _strtoui(_strtok(NULL, " ")); - - UpdateGSMParams(interlace, mode, ffmd, display, syncv, smode2, dx_offset, dy_offset, k576P_fix, kGsDxDyOffsetSupported, FIELD_fix); + if (config->EnableGSMOp) { + UpdateGSMParams( + config->GsmConfig.interlace, + config->GsmConfig.mode, + config->GsmConfig.ffmd, + config->GsmConfig.display, + config->GsmConfig.syncv, + config->GsmConfig.smode2, + config->GsmConfig.dx_offset, + config->GsmConfig.dy_offset, + config->GsmConfig.k576P_fix, + config->GsmConfig.kGsDxDyOffsetSupported, + config->GsmConfig.FIELD_fix); EnableGSM(); } - i++; set_ipconfig(); @@ -174,12 +112,12 @@ static int eecoreInit(int argc, char **argv) DPRINTF("Installing Kernel Hooks...\n"); Install_Kernel_Hooks(); - if (EnableDebug) + if (config->EnableDebug) GS_BGCOLOUR = 0xff0000; // Blue SifExitRpc(); - return i; + return 0; } int main(int argc, char **argv) diff --git a/ee_core/src/modmgr.c b/ee_core/src/modmgr.c index 8cc560297..38b4aac1f 100644 --- a/ee_core/src/modmgr.c +++ b/ee_core/src/modmgr.c @@ -11,10 +11,10 @@ #include "modules.h" #include "modmgr.h" #include "util.h" +#include "coreconfig.h" static SifRpcClientData_t _lf_cd; static int _lf_init = 0; -extern void *ModStorageStart; /*----------------------------------------------------------------------------------------*/ /* Init LOADFILE RPC. */ @@ -50,7 +50,7 @@ void LoadFileExit() /*----------------------------------------------------------------------------------------*/ /* Load an irx module from path with waiting. */ /*----------------------------------------------------------------------------------------*/ -int LoadModule(const char *path, int arg_len, const char *args) +int LoadModule(const char *path, int arg_len, const char *args, int mode) { struct _lf_module_load_arg arg; @@ -68,7 +68,7 @@ int LoadModule(const char *path, int arg_len, const char *args) } else arg.p.arg_len = 0; - if (SifCallRpc(&_lf_cd, LF_F_MOD_LOAD, 0x0, &arg, sizeof(arg), &arg, 8, NULL, NULL) < 0) + if (SifCallRpc(&_lf_cd, LF_F_MOD_LOAD, mode, &arg, sizeof(arg), &arg, 8, NULL, NULL) < 0) return -SCE_ECALLMISS; return arg.p.result; @@ -131,8 +131,9 @@ int LoadMemModule(int mode, void *modptr, unsigned int modsize, int arg_len, con int GetOPLModInfo(int id, void **pointer, unsigned int *size) { + USE_LOCAL_EECORE_CONFIG; int i, result; - irxtab_t *irxtable = (irxtab_t *)ModStorageStart; + irxtab_t *irxtable = (irxtab_t *)config->ModStorageStart; for (i = 0, result = -1; i < irxtable->count; i++) { if (GET_OPL_MOD_ID(irxtable->modules[i].info) == id) { diff --git a/ee_core/src/padhook.c b/ee_core/src/padhook.c index 19cd5b17d..2ebe04e8d 100644 --- a/ee_core/src/padhook.c +++ b/ee_core/src/padhook.c @@ -34,6 +34,7 @@ #endif #include "cheat_api.h" #include "cd_igr_rpc.h" +#include "coreconfig.h" /* scePadPortOpen & scePad2CreateSocket prototypes */ static int (*scePadPortOpen)(int port, int slot, void *addr); @@ -60,6 +61,7 @@ extern void *_end; // Load home ELF static void t_loadElf(void) { + USE_LOCAL_EECORE_CONFIG; int ret; char *argv[2]; t_ExecData elf; @@ -80,22 +82,22 @@ static void t_loadElf(void) GS_BGCOLOUR = 0xFF8000; // Blue sky // Load basic modules - LoadModule("rom0:SIO2MAN", 0, NULL); - LoadModule("rom0:MCMAN", 0, NULL); + LoadModule("rom0:SIO2MAN", 0, NULL, 0); + LoadModule("rom0:MCMAN", 0, NULL, 0); - if (ExitPath[1] == 'a') { // ie mass: - ret = LoadModule("mc0:SYS-CONF/USBD.IRX", 0, NULL); + if (config->ExitPath[1] == 'a') { // ie mass: + ret = LoadModule("mc0:SYS-CONF/USBD.IRX", 0, NULL, 0); if (ret >= 0) - LoadModule("mc0:SYS-CONF/USBHDFSD.IRX", 0, NULL); + LoadModule("mc0:SYS-CONF/USBHDFSD.IRX", 0, NULL, 0); else { - LoadModule("mc1:SYS-CONF/USBD.IRX", 0, NULL); - LoadModule("mc1:SYS-CONF/USBHDFSD.IRX", 0, NULL); + LoadModule("mc1:SYS-CONF/USBD.IRX", 0, NULL, 0); + LoadModule("mc1:SYS-CONF/USBHDFSD.IRX", 0, NULL, 0); } delay(5); // Wait for device to be detected. } // Load exit ELF - argv[0] = ExitPath; + argv[0] = config->ExitPath; argv[1] = NULL; // Wipe everything, even the module storage. @@ -134,6 +136,7 @@ static void t_loadElf(void) // In Game Reset Thread static void IGR_Thread(void *arg) { + USE_LOCAL_EECORE_CONFIG; u32 Cop0_Perf; // Place our IGR thread in WAIT state @@ -151,7 +154,7 @@ static void IGR_Thread(void *arg) // If Pad Combo is Start + Select then Return to Home, else if Pad Combo is UP then take IGS if ((Pad_Data.combo_type == IGR_COMBO_START_SELECT) #ifdef IGS - || ((Pad_Data.combo_type == IGR_COMBO_UP) && (EnableGSMOp)) + || ((Pad_Data.combo_type == IGR_COMBO_UP) && (config->EnableGSMOp)) #endif ) { @@ -192,14 +195,14 @@ static void IGR_Thread(void *arg) " sync.p;"); } - if (EnableGSMOp) { + if (config->EnableGSMOp) { if (EnableDebug) GS_BGCOLOUR = 0x00FF00; // Green DPRINTF("Stopping GSM...\n"); DisableGSM(); } - if (EnableCheatOp) { + if (config->gCheatList) { if (EnableDebug) GS_BGCOLOUR = 0xFF0000; // Blue DPRINTF("Stopping PS2RD Cheat Engine...\n"); @@ -229,7 +232,7 @@ static void IGR_Thread(void *arg) LoadOPLModule(OPL_MODULE_ID_RESETSPU, 0, 0, NULL); #ifdef IGS - if ((Pad_Data.combo_type == IGR_COMBO_UP) && (EnableGSMOp)) + if ((Pad_Data.combo_type == IGR_COMBO_UP) && (config->EnableGSMOp)) InGameScreenshot(); #endif @@ -253,8 +256,9 @@ static void IGR_Thread(void *arg) void IGR_Exit(s32 exit_code) { + USE_LOCAL_EECORE_CONFIG; // Execute home loader - if (ExitPath[0] != '\0') + if (config->ExitPath[0] != '\0') ExecPS2(t_loadElf, &_gp, 0, NULL); // Return to PS2 Browser @@ -264,6 +268,7 @@ void IGR_Exit(s32 exit_code) // IGR VBLANK_END interrupt handler install to monitor combo trick in pad data aera static int IGR_Intc_Handler(int cause) { + USE_LOCAL_EECORE_CONFIG; int i; u8 pad_pos_state, pad_pos_frame, pad_pos_combo1, pad_pos_combo2; @@ -295,7 +300,7 @@ static int IGR_Intc_Handler(int cause) if ((pad_pos_combo2 == IGR_COMBO_START_SELECT) || // Start + Select combo, so reset (pad_pos_combo2 == IGR_COMBO_R3_L3) // R3 + L3 combo, so poweroff #ifdef IGS - || ((pad_pos_combo2 == IGR_COMBO_UP) && (EnableGSMOp)) // UP combo, so take IGS + || ((pad_pos_combo2 == IGR_COMBO_UP) && (config->EnableGSMOp)) // UP combo, so take IGS #endif ) diff --git a/ee_core/src/patches.c b/ee_core/src/patches.c index f6a1589c2..8515f9d45 100644 --- a/ee_core/src/patches.c +++ b/ee_core/src/patches.c @@ -12,6 +12,7 @@ #include "util.h" #include "modules.h" #include "modmgr.h" +#include "coreconfig.h" #define ALL_MODE -1 #define BDM_MODE -2 @@ -149,6 +150,7 @@ static const patchlist_t patch_list[] = { {"SLPS_732.22", ALL_MODE, {PATCH_HARVEST_MOON_AWL, 0x00000000, 0x00000000}}, // Harvest Moon: A Wonderful Life (NTSC-J) (PlayStation 2 The Best) {"SLUS_211.71", ALL_MODE, {PATCH_HARVEST_MOON_AWL, 0x00000001, 0x00000000}}, // Harvest Moon: A Wonderful Life (NTSC-U/C) {"SLES_534.80", ALL_MODE, {PATCH_HARVEST_MOON_AWL, 0x00000002, 0x00000000}}, // Harvest Moon: A Wonderful Life (NTSC-PAL) + {"SLPS_254.78", ALL_MODE, {0x00365BC0, 0x1040FFFD, 0x1440FFFD}}, // Kidou Senshi Gundam Ichinen Sensou sceSifSyncIop() != 0 to == 0 return check fix. {NULL, 0, {0x00000000, 0x00000000, 0x00000000}} // terminator }; @@ -157,7 +159,7 @@ static const patchlist_t patch_list[] = { #define FNADDR(jal) (((jal)&0x03ffffff) << 2) #define NIBBLE2CHAR(n) ((n) <= 9 ? '0' + (n) : 'a' + (n)) -static int (*cdRead)(u32 lsn, u32 nsectors, void *buf, int *mode); +static int (*cdReadPtr)(u32 lsn, u32 nsectors, void *buf, int *mode); static unsigned int g_delay_cycles; static int g_mode; // Patch may use this for anything. @@ -232,7 +234,7 @@ static int delayed_cdRead(u32 lsn, u32 nsectors, void *buf, int *mode) int r; unsigned int count; - r = cdRead(lsn, nsectors, buf, mode); + r = cdReadPtr(lsn, nsectors, buf, mode); count = g_delay_cycles; while (count--) asm("nop\nnop\nnop\nnop"); @@ -245,8 +247,8 @@ static void generic_delayed_cdRead_patches(u32 patch_addr, u32 delay_cycles) // set configureable delay cycles g_delay_cycles = delay_cycles; - // get original cdRead() pointer - cdRead = (void *)FNADDR(_lw(patch_addr)); + // get original cdReadPtr() pointer + cdReadPtr = (void *)FNADDR(_lw(patch_addr)); // overwrite with a JAL to our delayed_cdRead function _sw(JAL((u32)delayed_cdRead), patch_addr); @@ -324,6 +326,7 @@ void RnC3_AlwaysAllocMem(void); static void RnC3_UYA_patches(void *address) { + USE_LOCAL_EECORE_CONFIG; unsigned int word1, word2; /* Preserve the pointer to the allocated IOP RAM. @@ -358,7 +361,7 @@ static void RnC3_UYA_patches(void *address) For retail units, there are 2 libcdvd modules. Therefore the pointer should be left-shifted by 2. */ word1 = JAL((unsigned int)&RnC3_AlwaysAllocMem); - switch (GameMode) { + switch (config->GameMode) { default: #ifdef _DTL_T10000 word2 = 0x00021903; // sra $v1, $v0, 4 For DTL-T10000. @@ -706,7 +709,9 @@ static void UltProPinballPatch(const char *path) } static void EutechnyxWakeupTIDPatch(u32 addr) -{ // Eutechnyx games have the main thread ID hardcoded for a call to WakeupThread(). +{ + USE_LOCAL_EECORE_CONFIG; + // Eutechnyx games have the main thread ID hardcoded for a call to WakeupThread(). // addiu $a0, $zero, 1 // This breaks when the thread IDs change after IGR is used. @@ -714,7 +719,7 @@ static void EutechnyxWakeupTIDPatch(u32 addr) MTV Pimp My Ride uses same serial for v1.00 and v2.00 of USA release. We need to tell which offsets to use. */ - if (_strcmp(GameID, "SLUS_215.80") == 0) { + if (_strcmp(config->GameID, "SLUS_215.80") == 0) { // Check version v1.00 by default. if (*(vu16 *)addr == 1) { *(vu16 *)addr = (u16)GetThreadId(); @@ -732,7 +737,7 @@ static void EutechnyxWakeupTIDPatch(u32 addr) Same problem with SRS: Street Racing Syndicate The patch already exists but it was for v1.03 of the game so if it was trying to boot v2.00 then it would be wrong patched. This handles both cases correctly. */ - if (_strcmp(GameID, "SLUS_205.82") == 0) { + if (_strcmp(config->GameID, "SLUS_205.82") == 0) { // Check version v1.03 by default. if (*(vu16 *)addr == 1) { *(vu16 *)addr = (u16)GetThreadId(); @@ -898,21 +903,21 @@ static void HarvestMoonAWLPatch(int region) void apply_patches(const char *path) { + USE_LOCAL_EECORE_CONFIG; const patchlist_t *p; int mode; // Some patches hack into specific ELF files // make sure the filename and gameid match for those patches // This prevents games with multiple ELF's from being corrupted by the patch - int file_eq_gameid = !_strncmp(&path[8], GameID, 11); // starting after 'cdrom0:\' - - if ((GameMode == HDD_MODE) || (GameMode == ETH_MODE)) - mode = GameMode; + int file_eq_gameid = !_strncmp(&path[8], config->GameID, 11); // starting after 'cdrom0:\' + if ((config->GameMode == HDD_MODE) || (config->GameMode == ETH_MODE)) + mode = config->GameMode; else mode = BDM_MODE; // if there are patches matching game name/mode then fill the patch table for (p = patch_list; p->game; p++) { - if ((!_strcmp(GameID, p->game)) && ((p->mode == ALL_MODE) || (mode == p->mode))) { + if ((!_strcmp(config->GameID, p->game)) && ((p->mode == ALL_MODE) || (mode == p->mode))) { switch (p->patch.addr) { case PATCH_GENERIC_NIS: NIS_generic_patches(); diff --git a/ee_core/src/syshook.c b/ee_core/src/syshook.c index 645815960..6cc315672 100644 --- a/ee_core/src/syshook.c +++ b/ee_core/src/syshook.c @@ -15,13 +15,12 @@ #include "patches.h" #include "padhook.h" #include "syshook.h" +#include "coreconfig.h" #include #include #include -ConfigParam CustomOSDConfigParam; - int set_reg_hook; int set_reg_disabled; int iop_reboot_count = 0; @@ -29,8 +28,6 @@ int iop_reboot_count = 0; int padOpen_hooked = 0; int disable_padOpen_hook = 1; -extern void *ModStorageStart, *ModStorageEnd; -extern void *eeloadCopy, *initUserMemory; extern void *_end; // Global data @@ -39,8 +36,8 @@ int (*Old_SifSetReg)(u32 register_num, int register_value); int (*Old_ExecPS2)(void *entry, void *gp, int num_args, char *args[]); int (*Old_CreateThread)(ee_thread_t *thread_param); void (*Old_Exit)(s32 exit_code); -void (*Old_SetOsdConfigParam)(ConfigParam *config); -void (*Old_GetOsdConfigParam)(ConfigParam *config); +void (*Old_SetOsdConfigParam)(ConfigParam *osdconfig); +void (*Old_GetOsdConfigParam)(ConfigParam *osdconfig); /*----------------------------------------------------------------------------------------*/ /* This function is called when SifSetDma catches a reboot request. */ @@ -68,6 +65,7 @@ u32 New_SifSetDma(SifDmaTransfer_t *sdd, s32 len) // ------------------------------------------------------------------------ void sysLoadElf(char *filename, int argc, char **argv) { + USE_LOCAL_EECORE_CONFIG; int r; t_ExecData elf; @@ -94,7 +92,7 @@ void sysLoadElf(char *filename, int argc, char **argv) DPRINTF("t_loadElf: cleaning user memory..."); // wipe user memory - WipeUserMemory((void *)&_end, (void *)ModStorageStart); + WipeUserMemory((void *)&_end, (void *)config->ModStorageStart); // The upper half (from ModStorageEnd to GetMemorySize()) is taken care of by LoadExecPS2(). // WipeUserMemory((void *)ModStorageEnd, (void *)GetMemorySize()); @@ -136,7 +134,8 @@ void sysLoadElf(char *filename, int argc, char **argv) static void unpatchEELOADCopy(void) { - vu32 *p = (vu32 *)eeloadCopy; + USE_LOCAL_EECORE_CONFIG; + vu32 *p = (vu32 *)config->eeloadCopy; p[1] = 0x0240302D; /* daddu a2, s2, zero */ p[2] = 0x8FA50014; /* lw a1, 0x0014(sp) */ @@ -145,7 +144,8 @@ static void unpatchEELOADCopy(void) static void unpatchInitUserMemory(void) { - vu16 *p = (vu16 *)initUserMemory; + USE_LOCAL_EECORE_CONFIG; + vu16 *p = (vu16 *)config->initUserMemory; /* * Reset the start of user memory to 0x00082000, by changing the immediate value being loaded into $a0. @@ -163,30 +163,34 @@ void sysExit(s32 exit_code) IGR_Exit(exit_code); } -void hook_SetOsdConfigParam(ConfigParam *config) +void hook_SetOsdConfigParam(ConfigParam *osdconfig) { + USE_LOCAL_EECORE_CONFIG; + DPRINTF("%s: called\n", __func__); - CustomOSDConfigParam.spdifMode = config->spdifMode; - CustomOSDConfigParam.screenType = config->screenType; - CustomOSDConfigParam.videoOutput = config->videoOutput; - CustomOSDConfigParam.japLanguage = config->japLanguage; - CustomOSDConfigParam.ps1drvConfig = config->ps1drvConfig; - CustomOSDConfigParam.version = config->version; - CustomOSDConfigParam.language = config->language; - CustomOSDConfigParam.timezoneOffset = config->timezoneOffset; + config->CustomOSDConfigParam.spdifMode = osdconfig->spdifMode; + config->CustomOSDConfigParam.screenType = osdconfig->screenType; + config->CustomOSDConfigParam.videoOutput = osdconfig->videoOutput; + config->CustomOSDConfigParam.japLanguage = osdconfig->japLanguage; + config->CustomOSDConfigParam.ps1drvConfig = osdconfig->ps1drvConfig; + config->CustomOSDConfigParam.version = osdconfig->version; + config->CustomOSDConfigParam.language = osdconfig->language; + config->CustomOSDConfigParam.timezoneOffset = osdconfig->timezoneOffset; } -void hook_GetOsdConfigParam(ConfigParam *config) +void hook_GetOsdConfigParam(ConfigParam *osdconfig) { + USE_LOCAL_EECORE_CONFIG; + DPRINTF("%s: called\n", __func__); - config->spdifMode = CustomOSDConfigParam.spdifMode; - config->screenType = CustomOSDConfigParam.screenType; - config->videoOutput = CustomOSDConfigParam.videoOutput; - config->japLanguage = CustomOSDConfigParam.japLanguage; - config->ps1drvConfig = CustomOSDConfigParam.ps1drvConfig; - config->version = CustomOSDConfigParam.version; - config->language = CustomOSDConfigParam.language; - config->timezoneOffset = CustomOSDConfigParam.timezoneOffset; + osdconfig->spdifMode = config->CustomOSDConfigParam.spdifMode; + osdconfig->screenType = config->CustomOSDConfigParam.screenType; + osdconfig->videoOutput = config->CustomOSDConfigParam.videoOutput; + osdconfig->japLanguage = config->CustomOSDConfigParam.japLanguage; + osdconfig->ps1drvConfig = config->CustomOSDConfigParam.ps1drvConfig; + osdconfig->version = config->CustomOSDConfigParam.version; + osdconfig->language = config->CustomOSDConfigParam.language; + osdconfig->timezoneOffset = config->CustomOSDConfigParam.timezoneOffset; } /*----------------------------------------------------------------------------------------*/ @@ -195,7 +199,8 @@ void hook_GetOsdConfigParam(ConfigParam *config) /*----------------------------------------------------------------------------------------*/ void Install_Kernel_Hooks(void) { - if (enforceLanguage) { + USE_LOCAL_EECORE_CONFIG; + if (config->enforceLanguage) { Old_SetOsdConfigParam = GetSyscallHandler(__NR_SetOsdConfigParam); SetSyscall(__NR_SetOsdConfigParam, &hook_SetOsdConfigParam); Old_GetOsdConfigParam = GetSyscallHandler(__NR_GetOsdConfigParam); @@ -227,7 +232,8 @@ void Install_Kernel_Hooks(void) /*----------------------------------------------------------------------------------------------*/ void Remove_Kernel_Hooks(void) { - if (enforceLanguage) { + USE_LOCAL_EECORE_CONFIG; + if (config->enforceLanguage) { SetSyscall(__NR_SetOsdConfigParam, Old_SetOsdConfigParam); SetSyscall(__NR_GetOsdConfigParam, Old_GetOsdConfigParam); } diff --git a/ee_core/src/util.c b/ee_core/src/util.c index fa3780cb1..696219def 100644 --- a/ee_core/src/util.c +++ b/ee_core/src/util.c @@ -10,6 +10,7 @@ #include "ee_core.h" #include "iopmgr.h" #include "util.h" +#include "coreconfig.h" extern void *cdvdman_irx; extern int size_cdvdman_irx; @@ -287,6 +288,7 @@ u64 _strtoul(const char *p) /*----------------------------------------------------------------------------------------*/ void set_ipconfig(void) { + USE_LOCAL_EECORE_CONFIG; const char *SmapLinkModeArgs[4] = { "0x100", "0x080", @@ -297,22 +299,22 @@ void set_ipconfig(void) g_ipconfig_len = 0; // add ip to g_ipconfig buf - strncpy(&g_ipconfig[g_ipconfig_len], g_ps2_ip, 16); - g_ipconfig_len += strlen(g_ps2_ip) + 1; + strncpy(&g_ipconfig[g_ipconfig_len], config->g_ps2_ip, 16); + g_ipconfig_len += strlen(config->g_ps2_ip) + 1; // add netmask to g_ipconfig buf - strncpy(&g_ipconfig[g_ipconfig_len], g_ps2_netmask, 16); - g_ipconfig_len += strlen(g_ps2_netmask) + 1; + strncpy(&g_ipconfig[g_ipconfig_len], config->g_ps2_netmask, 16); + g_ipconfig_len += strlen(config->g_ps2_netmask) + 1; // add gateway to g_ipconfig buf - strncpy(&g_ipconfig[g_ipconfig_len], g_ps2_gateway, 16); - g_ipconfig_len += strlen(g_ps2_gateway) + 1; + strncpy(&g_ipconfig[g_ipconfig_len], config->g_ps2_gateway, 16); + g_ipconfig_len += strlen(config->g_ps2_gateway) + 1; // Add Ethernet operation mode to g_ipconfig buf - if (g_ps2_ETHOpMode != ETH_OP_MODE_AUTO) { + if (config->g_ps2_ETHOpMode != ETH_OP_MODE_AUTO) { strncpy(&g_ipconfig[g_ipconfig_len], "-no_auto", 9); g_ipconfig_len += 9; - strncpy(&g_ipconfig[g_ipconfig_len], SmapLinkModeArgs[g_ps2_ETHOpMode - 1], 6); + strncpy(&g_ipconfig[g_ipconfig_len], SmapLinkModeArgs[config->g_ps2_ETHOpMode - 1], 6); g_ipconfig_len += 6; } } diff --git a/include/bdmsupport.h b/include/bdmsupport.h index 7dd7bc134..f58482805 100644 --- a/include/bdmsupport.h +++ b/include/bdmsupport.h @@ -24,4 +24,6 @@ void bdmLoadModules(void); void bdmLaunchGame(int id, config_set_t *configSet); void bdmSetPrefix(void); +void bdmInitSemaphore(); + #endif diff --git a/include/extern_irx.h b/include/extern_irx.h index 04bea09b1..21a3ae51a 100644 --- a/include/extern_irx.h +++ b/include/extern_irx.h @@ -126,8 +126,6 @@ IMPORT_BIN2C(udptty_irx); IMPORT_BIN2C(udptty_ingame_irx); -IMPORT_BIN2C(udnl_irx); - IMPORT_BIN2C(usbd_irx); IMPORT_BIN2C(usbmass_bd_irx); diff --git a/include/opl.h b/include/opl.h index d1379f768..cb8cecc08 100644 --- a/include/opl.h +++ b/include/opl.h @@ -182,7 +182,7 @@ extern int gPadMacroSettings; // 0,1,2 scrolling speed extern int gScrollSpeed; // Exit path -extern char gExitPath[32]; +extern char gExitPath[256]; // Enable Debug Colors extern int gEnableDebug; diff --git a/include/pggsm.h b/include/pggsm.h index 672789938..56b75890e 100644 --- a/include/pggsm.h +++ b/include/pggsm.h @@ -18,6 +18,7 @@ #define GSM_VERSION "0.40" #define GSM_ARGS 1 +#include "../ee_core/include/coreconfig.h" #define makeSMODE1(VHP, VCKSEL, SLCK2, NVCK, CLKSEL, PEVS, PEHS, PVS, PHS, GCONT, SPML, PCK2, XPCK, SINT, PRST, EX, CMOD, SLCK, T1248, LC, RC) \ (u64)(((u64)(VHP) << 36) | ((u64)(VCKSEL) << 34) | ((u64)(SLCK2) << 33) | \ @@ -50,6 +51,6 @@ typedef struct predef_vmode_struct void InitGSMConfig(config_set_t *configSet); int GetGSMEnabled(void); -void PrepareGSM(char *cmdline); +void PrepareGSM(char *cmdline, struct GsmConfig_t *config); #endif diff --git a/include/util.h b/include/util.h index 66baeed46..758e01372 100644 --- a/include/util.h +++ b/include/util.h @@ -9,7 +9,7 @@ void checkMCFolder(void); int openFile(char *path, int mode); void *readFile(char *path, int align, int *size); int listDir(char *path, const char *separator, int maxElem, - int (*readEntry)(int index, const char *path, const char *separator, const char *name, unsigned int mode)); + int (*readEntry)(int index, const char *path, const char *separator, const char *name, unsigned char d_type)); typedef struct { diff --git a/labs/genvmclab/Makefile b/labs/genvmclab/Makefile index 98bdf862c..282678048 100644 --- a/labs/genvmclab/Makefile +++ b/labs/genvmclab/Makefile @@ -6,7 +6,7 @@ EE_LIBS = -lfileXio -lpatches -ldebug -lc -lkernel EE_CFLAGS = -g EE_LDFLAGS = -s -BIN2S = $(PS2SDK)/bin/bin2s +BIN2C = $(PS2SDK)/bin/bin2c all: $(MAKE) $(EE_BIN) @@ -26,57 +26,57 @@ clean: rebuild: clean all -poweroff.s: - $(BIN2S) $(PS2SDK)/iop/irx/poweroff.irx poweroff.s poweroff_irx +poweroff.c: $(PS2SDK)/iop/irx/poweroff.irx + $(BIN2C) $< $@ $(*F)_irx -ps2dev9.s: +ps2dev9.c: ../../modules/dev9/ps2dev9.irx $(MAKE) -C ../../modules/dev9 - $(BIN2S) ../../modules/dev9/ps2dev9.irx ps2dev9.s ps2dev9_irx + $(BIN2C) $< $@ $(*F)_irx -smsutils.s: +smsutils.c: ../../modules/network/SMSUTILS/SMSUTILS.irx $(MAKE) -C ../../modules/network/SMSUTILS - $(BIN2S) ../../modules/network/SMSUTILS/SMSUTILS.irx smsutils.s smsutils_irx + $(BIN2C) $< $@ $(*F)_irx -smstcpip.s: +smstcpip.c: ../../modules/network/SMSTCPIP/SMSTCPIP.irx $(MAKE) -C ../../modules/network/SMSTCPIP - $(BIN2S) ../../modules/network/SMSTCPIP/SMSTCPIP.irx smstcpip.s smstcpip_irx + $(BIN2C) $< $@ $(*F)_irx -smsmap.s: +smsmap.c: ../../modules/network/SMSMAP/SMSMAP.irx $(MAKE) -C ../../modules/network/SMSMAP - $(BIN2S) ../../modules/network/SMSMAP/SMSMAP.irx smsmap.s smsmap_irx + $(BIN2C) $< $@ $(*F)_irx -iomanx.s: - $(BIN2S) $(PS2SDK)/iop/irx/iomanX.irx iomanx.s iomanx_irx +iomanx.c: $(PS2SDK)/iop/irx/iomanX.irx + $(BIN2C) $< $@ $(*F)_irx -filexio.s: - $(BIN2S) $(PS2SDK)/iop/irx/fileXio.irx filexio.s filexio_irx +filexio.c: $(PS2SDK)/iop/irx/fileXio.irx + $(BIN2C) $< $@ $(*F)_irx -usbd.s: - $(BIN2S) $(PS2SDK)/iop/irx/usbd.irx usbd.s usbd_irx +usbd.c: $(PS2SDK)/iop/irx/usbd.irx + $(BIN2C) $< $@ $(*F)_irx -usbhdfsd.s: +usbhdfsd.c: ../../modules/usb/usbhdfsd/usbhdfsd.irx $(MAKE) -C ../../modules/usb/usbhdfsd - $(BIN2S) ../../modules/usb/usbhdfsd/usbhdfsd.irx usbhdfsd.s usbhdfsd_irx + $(BIN2C) $< $@ $(*F)_irx -udptty.s: +udptty.c: ../../modules/debug/udptty/udptty.irx $(MAKE) -C ../../modules/debug/udptty - $(BIN2S) ../../modules/debug/udptty/udptty.irx udptty.s udptty_irx + $(BIN2C) $< $@ $(*F)_irx -ioptrap.s: +ioptrap.c: ../../modules/debug/ioptrap/ioptrap.irx $(MAKE) -C ../../modules/debug/ioptrap - $(BIN2S) ../../modules/debug/ioptrap/ioptrap.irx ioptrap.s ioptrap_irx + $(BIN2C) $< $@ $(*F)_irx -ps2link.s: +ps2link.c: ../../modules/debug/ps2link/ps2link.irx $(MAKE) -C ../../modules/debug/ps2link - $(BIN2S) ../../modules/debug/ps2link/ps2link.irx ps2link.s ps2link_irx + $(BIN2C) $< $@ $(*F)_irx -mcman.s: +mcman.c: ../../modules/vmc/mcman/mcman.irx $(MAKE) -C ../../modules/vmc/mcman - $(BIN2S) ../../modules/vmc/mcman/mcman.irx mcman.s mcman_irx + $(BIN2C) $< $@ $(*F)_irx -genvmc.s: +genvmc.c: ../../modules/vmc/genvmc/genvmc.irx $(MAKE) -C ../../modules/vmc/genvmc - $(BIN2S) ../../modules/vmc/genvmc/genvmc.irx genvmc.s genvmc_irx + $(BIN2C) $< $@ $(*F)_irx include $(PS2SDK)/samples/Makefile.pref include $(PS2SDK)/samples/Makefile.eeglobal diff --git a/labs/lwnbdsvr/Makefile b/labs/lwnbdsvr/Makefile index b36e17971..26e33fd4f 100644 --- a/labs/lwnbdsvr/Makefile +++ b/labs/lwnbdsvr/Makefile @@ -6,7 +6,7 @@ EE_LIBS = -lfileXio -lpatches -ldebug -lc -lkernel EE_CFLAGS = -g EE_LDFLAGS = -s -BIN2S = $(PS2SDK)/bin/bin2s +BIN2C = $(PS2SDK)/bin/bin2c all: $(MAKE) $(EE_BIN) @@ -24,46 +24,46 @@ clean: rebuild: clean all -discid.s: +discid.c: ../../modules/cdvd/discID/discID.irx $(MAKE) -C ../../modules/cdvd/discID - $(BIN2S) ../../modules/cdvd/discID/discID.irx discid.s discid_irx + $(BIN2C) $< $@ $(*F) -poweroff.s: - $(BIN2S) $(PS2SDK)/iop/irx/poweroff.irx poweroff.s poweroff_irx +poweroff.c: $(PS2SDK)/iop/irx/poweroff.irx + $(BIN2C) $< $@ $(*F) -ps2dev9.s: +ps2dev9.c: ../../modules/dev9/ps2dev9.irx $(MAKE) -C ../../modules/dev9 - $(BIN2S) ../../modules/dev9/ps2dev9.irx ps2dev9.s ps2dev9_irx + $(BIN2C) $< $@ $(*F) -smsutils.s: +smsutils.c: ../../modules/network/SMSUTILS/SMSUTILS.irx $(MAKE) -C ../../modules/network/SMSUTILS - $(BIN2S) ../../modules/network/SMSUTILS/SMSUTILS.irx smsutils.s smsutils_irx + $(BIN2C) $< $@ $(*F) -smstcpip.s: +smstcpip.c: ../../modules/network/SMSTCPIP/SMSTCPIP.irx $(MAKE) -C ../../modules/network/SMSTCPIP -f Makefile rebuild - $(BIN2S) ../../modules/network/SMSTCPIP/SMSTCPIP.irx smstcpip.s smstcpip_irx + $(BIN2C) $< $@ $(*F) -smsmap.s: +smsmap.c: ../../modules/network/SMSMAP/SMSMAP.irx $(MAKE) -C ../../modules/network/SMSMAP - $(BIN2S) ../../modules/network/SMSMAP/SMSMAP.irx smsmap.s smsmap_irx + $(BIN2C) $< $@ $(*F) -ps2atad.s: +ps2atad.c: ../../modules/hdd/atad/ps2atad.irx $(MAKE) -C ../../modules/hdd/atad - $(BIN2S) ../../modules/hdd/atad/ps2atad.irx ps2atad.s ps2atad_irx + $(BIN2C) $< $@ $(*F) -ps2hdd.s: +ps2hdd.c: ../../modules/hdd/ps2hdd/ps2hdd.irx $(MAKE) -C ../../modules/hdd/ps2hdd - $(BIN2S) ../../modules/hdd/ps2hdd/ps2hdd.irx ps2hdd.s ps2hdd_irx + $(BIN2C) $< $@ $(*F) -lwnbdsvr.s: +lwnbdsvr.c: ../../modules/network/lwNBD/lwnbdsvr.irx $(MAKE) -C ../../modules/network/lwNBD - $(BIN2S) ../../modules/network/lwNBD/lwnbdsvr.irx lwnbdsvr.s lwnbdsvr_irx + $(BIN2C) $< $@ $(*F) -iomanx.s: - $(BIN2S) $(PS2SDK)/iop/irx/iomanX.irx iomanx.s iomanx_irx +iomanx.c: $(PS2SDK)/iop/irx/iomanX.irx + $(BIN2C) $< $@ $(*F) -filexio.s: - $(BIN2S) $(PS2SDK)/iop/irx/fileXio.irx filexio.s filexio_irx +filexio.c: $(PS2SDK)/iop/irx/fileXio.irx + $(BIN2C) $< $@ $(*F) include $(PS2SDK)/samples/Makefile.pref include $(PS2SDK)/samples/Makefile.eeglobal diff --git a/labs/smblab/Makefile b/labs/smblab/Makefile index 07d78c234..790c347cd 100644 --- a/labs/smblab/Makefile +++ b/labs/smblab/Makefile @@ -6,7 +6,7 @@ EE_LIBS = -lfileXio -lpatches -ldebug -lc -lkernel EE_CFLAGS = -g EE_LDFLAGS = -s -BIN2S = $(PS2SDK)/bin/bin2s +BIN2C = $(PS2SDK)/bin/bin2c all: $(MAKE) $(EE_BIN) @@ -23,45 +23,45 @@ clean: rebuild: clean all -poweroff.s: - $(BIN2S) $(PS2SDK)/iop/irx/poweroff.irx poweroff.s poweroff_irx +poweroff.c: $(PS2SDK)/iop/irx/poweroff.irx + $(BIN2C) $< $@ $(*F) -ps2dev9.s: +ps2dev9.c: ../../modules/dev9/ps2dev9.irx $(MAKE) -C ../../modules/dev9 - $(BIN2S) ../../modules/dev9/ps2dev9.irx ps2dev9.s ps2dev9_irx + $(BIN2C) $< $@ $(*F) -smsutils.s: +smsutils.c: ../../modules/network/SMSUTILS/SMSUTILS.irx $(MAKE) -C ../../modules/network/SMSUTILS - $(BIN2S) ../../modules/network/SMSUTILS/SMSUTILS.irx smsutils.s smsutils_irx + $(BIN2C) $< $@ $(*F) -smstcpip.s: +smstcpip.c: ../../modules/network/SMSTCPIP/SMSTCPIP.irx $(MAKE) -C ../../modules/network/SMSTCPIP - $(BIN2S) ../../modules/network/SMSTCPIP/SMSTCPIP.irx smstcpip.s smstcpip_irx + $(BIN2C) $< $@ $(*F) -smsmap.s: +smsmap.c: ../../modules/network/SMSMAP/SMSMAP.irx $(MAKE) -C ../../modules/network/SMSMAP - $(BIN2S) ../../modules/network/SMSMAP/SMSMAP.irx smsmap.s smsmap_irx + $(BIN2C) $< $@ $(*F) -smbman.s: - $(BIN2S) $(PS2SDK)/iop/irx/smbman.irx smbman.s smbman_irx +smbman.c: $(PS2SDK)/iop/irx/smbman.irx + $(BIN2C) $< $@ $(*F) -udptty.s: +udptty.c: ../../modules/debug/udptty/udptty.irx $(MAKE) -C ../../modules/debug/udptty - $(BIN2S) ../../modules/debug/udptty/udptty.irx udptty.s udptty_irx + $(BIN2C) $< $@ $(*F) -ioptrap.s: +ioptrap.c: ../../modules/debug/ioptrap/ioptrap.irx $(MAKE) -C ../../modules/debug/ioptrap - $(BIN2S) ../../modules/debug/ioptrap/ioptrap.irx ioptrap.s ioptrap_irx + $(BIN2C) $< $@ $(*F) -ps2link.s: +ps2link.c: ../../modules/debug/ps2link/ps2link.irx $(MAKE) -C ../../modules/debug/ps2link - $(BIN2S) ../../modules/debug/ps2link/ps2link.irx ps2link.s ps2link_irx + $(BIN2C) $< $@ $(*F) -iomanx.s: - $(BIN2S) $(PS2SDK)/iop/irx/iomanX.irx iomanx.s iomanx_irx +iomanx.c: $(PS2SDK)/iop/irx/iomanX.irx + $(BIN2C) $< $@ $(*F) -filexio.s: - $(BIN2S) $(PS2SDK)/iop/irx/fileXio.irx filexio.s filexio_irx +filexio.c: $(PS2SDK)/iop/irx/fileXio.irx + $(BIN2C) $< $@ $(*F) include $(PS2SDK)/samples/Makefile.pref include $(PS2SDK)/samples/Makefile.eeglobal diff --git a/modules/Rules.bin.make b/modules/Rules.bin.make index f5429465c..6d09bff1a 100644 --- a/modules/Rules.bin.make +++ b/modules/Rules.bin.make @@ -1,6 +1,4 @@ BIN2C = $(PS2SDK)/bin/bin2c -BIN2S = $(PS2SDK)/bin/bin2s -BIN2O = $(PS2SDK)/bin/bin2o IOP_SRC_DIR = ./ all: $(IOP_BIN) diff --git a/modules/debug/ps2link/net_fio.c b/modules/debug/ps2link/net_fio.c index 9fccf2cb2..af2015b73 100644 --- a/modules/debug/ps2link/net_fio.c +++ b/modules/debug/ps2link/net_fio.c @@ -606,7 +606,6 @@ int pko_read_dir(int fd, void *buf) memcpy(dirent->stat.atime, dirrly->atime, 8); memcpy(dirent->stat.mtime, dirrly->mtime, 8); strncpy(dirent->name, dirrly->name, 256); - dirent->unknown = 0; return ntohl(dirrly->retval); } diff --git a/modules/hdd/xhdd/imports.lst b/modules/hdd/xhdd/imports.lst index cb4a4f8ce..1ab121081 100644 --- a/modules/hdd/xhdd/imports.lst +++ b/modules/hdd/xhdd/imports.lst @@ -1,7 +1,7 @@ atad_IMPORTS_start -I_ata_get_devinfo -I_ata_io_start -I_ata_io_finish +I_sceAtaInit +I_sceAtaExecCmd +I_sceAtaWaitResult atad_IMPORTS_end ioman_IMPORTS_start diff --git a/modules/hdd/xhdd/xatad.c b/modules/hdd/xhdd/xatad.c index fa83b1577..317fb242f 100644 --- a/modules/hdd/xhdd/xatad.c +++ b/modules/hdd/xhdd/xatad.c @@ -56,15 +56,15 @@ int ata_device_set_transfer_mode(int device, int type, int mode) { int res; - res = ata_io_start(NULL, 1, 3, (type | mode) & 0xff, 0, 0, 0, (device << 4) & 0xffff, ATA_C_SET_FEATURES); + res = sceAtaExecCmd(NULL, 1, 3, (type | mode) & 0xff, 0, 0, 0, (device << 4) & 0xffff, ATA_C_SET_FEATURES); if (res) return res; - res = ata_io_finish(); + res = sceAtaWaitResult(); if (res) return res; - // Note: PIO is not supported by ata_device_sector_io. + // Note: PIO is not supported by sceAtaDmaTransfer. switch (type) { case ATA_XFER_MODE_MDMA: ata_multiword_dma_mode(mode); diff --git a/modules/hdd/xhdd/xhdd.c b/modules/hdd/xhdd/xhdd.c index 3fb775f16..5f3e48a26 100644 --- a/modules/hdd/xhdd/xhdd.c +++ b/modules/hdd/xhdd/xhdd.c @@ -32,7 +32,7 @@ static int xhddDevctl(iop_file_t *fd, const char *name, int cmd, void *arg, unsi switch (cmd) { case ATA_DEVCTL_IS_48BIT: - return ((devinfo = ata_get_devinfo(fd->unit)) != NULL ? devinfo->lba48 : -1); + return ((devinfo = sceAtaInit(fd->unit)) != NULL ? devinfo->lba48 : -1); case ATA_DEVCTL_SET_TRANSFER_MODE: if (!isHDPro) return ata_device_set_transfer_mode(fd->unit, ((hddAtaSetMode_t *)arg)->type, ((hddAtaSetMode_t *)arg)->mode); diff --git a/modules/iopcore/cdvdfsv/scmd.c b/modules/iopcore/cdvdfsv/scmd.c index 6f79f20aa..e9f2b654a 100644 --- a/modules/iopcore/cdvdfsv/scmd.c +++ b/modules/iopcore/cdvdfsv/scmd.c @@ -109,7 +109,7 @@ static inline void rpcSCmd_cdreadModelID(void *buf) cdvdSCmd_res_t *r = (cdvdSCmd_res_t *)buf; - r->result = sceCdReadModelID(&r->param1); + r->result = sceCdReadModelID((unsigned int *)&r->param1); } //------------------------------------------------------------------------- @@ -118,7 +118,7 @@ static inline void rpcSCmd_cdreaddvddualinfo(void *buf) cdvdSCmd_res_t *r = (cdvdSCmd_res_t *)buf; - r->result = sceCdReadDvdDualInfo((int *)&r->param1, &r->param2); + r->result = sceCdReadDvdDualInfo((int *)&r->param1, (unsigned int *)&r->param2); } //------------------------------------------------------------------------- diff --git a/modules/iopcore/cdvdman/atad.c b/modules/iopcore/cdvdman/atad.c index 2bff60d60..fc69f9811 100644 --- a/modules/iopcore/cdvdman/atad.c +++ b/modules/iopcore/cdvdman/atad.c @@ -83,7 +83,7 @@ static const ata_cmd_info_t smart_cmd_table[] = { {ATA_S_SMART_ENABLE_OPERATIONS, 0x01}}; #define SMART_CMD_TABLE_SIZE (sizeof smart_cmd_table / sizeof(ata_cmd_info_t)) -/* This is the state info tracked between ata_io_start() and ata_io_finish(). */ +/* This is the state info tracked between sceAtaExecCmd() and sceAtaWaitResult(). */ typedef struct _ata_cmd_state { s32 type; /* The ata_cmd_info_t type field. */ @@ -157,14 +157,14 @@ int atad_start(void) } /* In v1.04, PIO mode 0 was set here. In late versions, it is set in ata_init_devices(). */ - dev9RegisterIntrCb(1, &ata_intr_cb); - dev9RegisterIntrCb(0, &ata_intr_cb); + SpdRegisterIntrHandler(1, &ata_intr_cb); + SpdRegisterIntrHandler(0, &ata_intr_cb); if (!ata_gamestar_workaround) { dev9RegisterPreDmaCb(0, &ata_pre_dma_cb); dev9RegisterPostDmaCb(0, &ata_post_dma_cb); } /* Register this at the last position, as it should be the last thing done before shutdown. */ - dev9RegisterShutdownCb(15, &ata_shutdown_cb); + Dev9RegisterPowerOffHandler(15, &ata_shutdown_cb); iop_sema_t smp; smp.initial = 1; @@ -182,7 +182,7 @@ int atad_start(void) static int ata_intr_cb(int flag) { if (flag != 1) { /* New card, invalidate device info. */ - dev9IntrDisable(SPD_INTR_ATA); + SpdIntrDisable(SPD_INTR_ATA); iSetEventFlag(ata_evflg, ATA_EV_COMPLETE); } @@ -196,7 +196,7 @@ static unsigned int ata_alarm_cb(void *unused) } /* Export 8 */ -int ata_get_error(void) +int sceAtaGetError(void) { USE_ATA_REGS; return ata_hwport->r_error & 0xff; @@ -276,7 +276,7 @@ static int ata_device_select(int device) 48-bit LBA just involves writing the upper 24 bits in the format above into each respective register on the first write pass, before writing the lower 24 bits in the 2nd write pass. The LBA bits within the device field are not used in either write pass. */ -int ata_io_start(void *buf, u32 blkcount, u16 feature, u16 nsector, u16 sector, u16 lcyl, u16 hcyl, u16 select, u16 command) +int sceAtaExecCmd(void *buf, u32 blkcount, u16 feature, u16 nsector, u16 sector, u16 lcyl, u16 hcyl, u16 select, u16 command) { USE_ATA_REGS; iop_sys_clock_t cmd_timeout; @@ -354,7 +354,7 @@ int ata_io_start(void *buf, u32 blkcount, u16 feature, u16 nsector, u16 sector, /* Enable the command completion interrupt. */ if ((type & 0x7F) == 1) - dev9IntrEnable(SPD_INTR_ATA0); + SpdIntrEnable(SPD_INTR_ATA0); /* Finally! We send off the ATA command with arguments. */ ata_hwport->r_control = (using_timeout == 0) << 1; @@ -376,11 +376,11 @@ int ata_io_start(void *buf, u32 blkcount, u16 feature, u16 nsector, u16 sector, ata_hwport->r_sector = sector & 0xff; ata_hwport->r_lcyl = lcyl & 0xff; ata_hwport->r_hcyl = hcyl & 0xff; - ata_hwport->r_select = (select | ATA_SEL_LBA) & 0xff; //In v1.04, LBA was enabled in the ata_device_sector_io function. + ata_hwport->r_select = (select | ATA_SEL_LBA) & 0xff; //In v1.04, LBA was enabled in the sceAtaDmaTransfer function. ata_hwport->r_command = command & 0xff; /* Turn on the LED. */ - dev9LEDCtl(1); + SpdSetLED(1); return 0; } @@ -399,7 +399,7 @@ static inline int ata_pio_transfer(ata_cmd_state_t *cmd_state) u16 status = ata_hwport->r_status & 0xff; if (status & ATA_STAT_ERR) { - M_PRINTF("Error: Command error: status 0x%02x, error 0x%02x.\n", status, ata_get_error()); + M_PRINTF("Error: Command error: status 0x%02x, error 0x%02x.\n", status, sceAtaGetError()); return ATA_RES_ERR_IO; } @@ -453,7 +453,7 @@ static inline int ata_dma_complete(void *buf, int blkcount, int dir) if (dma_stat) goto next_transfer; - dev9IntrEnable(SPD_INTR_ATA); + SpdIntrEnable(SPD_INTR_ATA); /* Wait for the previous transfer to complete or a timeout. */ WaitEventFlag(ata_evflg, ATA_EV_TIMEOUT | ATA_EV_COMPLETE, WEF_CLEAR | WEF_OR, &bits); @@ -465,12 +465,12 @@ static inline int ata_dma_complete(void *buf, int blkcount, int dir) if (!(SPD_REG16(SPD_R_INTR_STAT) & 0x02)) { if (ata_hwport->r_control & 0x01) { M_PRINTF("Error: Command error while doing DMA.\n"); - M_PRINTF("Error: Command error status 0x%02x, error 0x%02x.\n", ata_hwport->r_status, ata_get_error()); + M_PRINTF("Error: Command error status 0x%02x, error 0x%02x.\n", ata_hwport->r_status, sceAtaGetError()); #ifdef NETLOG_DEBUG - pNetlogSend("Error: Command error status 0x%02x, error 0x%02x.\n", ata_hwport->r_status, ata_get_error()); + pNetlogSend("Error: Command error status 0x%02x, error 0x%02x.\n", ata_hwport->r_status, sceAtaGetError()); #endif /* In v1.04, there was no check for ICRC. */ - return ((ata_get_error() & ATA_ERR_ICRC) ? ATA_RES_ERR_ICRC : ATA_RES_ERR_IO); + return ((sceAtaGetError() & ATA_ERR_ICRC) ? ATA_RES_ERR_ICRC : ATA_RES_ERR_IO); } else { M_PRINTF("Warning: Got command interrupt, but not an error.\n"); continue; @@ -482,7 +482,7 @@ static inline int ata_dma_complete(void *buf, int blkcount, int dir) next_transfer: count = (blkcount < dma_stat) ? blkcount : dma_stat; nbytes = count * 512; - if ((res = dev9DmaTransfer(0, buf, (nbytes << 9) | 32, dir)) < 0) + if ((res = SpdDmaTransfer(0, buf, (nbytes << 9) | 32, dir)) < 0) return res; buf = (void *)((u8 *)buf + nbytes); @@ -493,7 +493,7 @@ static inline int ata_dma_complete(void *buf, int blkcount, int dir) } /* Export 7 */ -int ata_io_finish(void) +int sceAtaWaitResult(void) { USE_SPD_REGS; USE_ATA_REGS; @@ -517,7 +517,7 @@ int ata_io_finish(void) if ((stat = SPD_REG16(SPD_R_INTR_STAT) & 0x01)) break; if (!stat) { - dev9IntrEnable(SPD_INTR_ATA0); + SpdIntrEnable(SPD_INTR_ATA0); WaitEventFlag(ata_evflg, ATA_EV_TIMEOUT | ATA_EV_COMPLETE, WEF_CLEAR | WEF_OR, &bits); if (bits & ATA_EV_TIMEOUT) { M_PRINTF("Error: ATA timeout on DMA completion.\n"); @@ -545,16 +545,16 @@ int ata_io_finish(void) if (ata_hwport->r_status & ATA_STAT_BUSY) res = ata_wait_busy(); if ((stat = ata_hwport->r_status) & ATA_STAT_ERR) { - M_PRINTF("Error: Command error: status 0x%02x, error 0x%02x.\n", stat, ata_get_error()); + M_PRINTF("Error: Command error: status 0x%02x, error 0x%02x.\n", stat, sceAtaGetError()); /* In v1.04, there was no check for ICRC. */ - res = (ata_get_error() & ATA_ERR_ICRC) ? ATA_RES_ERR_ICRC : ATA_RES_ERR_IO; + res = (sceAtaGetError() & ATA_ERR_ICRC) ? ATA_RES_ERR_ICRC : ATA_RES_ERR_IO; } finish: /* The command has completed (with an error or not), so clean things up. */ CancelAlarm(&ata_alarm_cb, NULL); /* Turn off the LED. */ - dev9LEDCtl(0); + SpdSetLED(0); if (res) M_PRINTF("error: ATA failed, %d\n", res); @@ -563,19 +563,19 @@ int ata_io_finish(void) } /* Export 17 */ -int ata_device_flush_cache(int device) +int sceAtaFlushCache(int device) { int res; - if (!(res = ata_io_start(NULL, 1, 0, 0, 0, 0, 0, (device << 4) & 0xffff, lba_48bit ? ATA_C_FLUSH_CACHE_EXT : ATA_C_FLUSH_CACHE))) - res = ata_io_finish(); + if (!(res = sceAtaExecCmd(NULL, 1, 0, 0, 0, 0, 0, (device << 4) & 0xffff, lba_48bit ? ATA_C_FLUSH_CACHE_EXT : ATA_C_FLUSH_CACHE))) + res = sceAtaWaitResult(); return res; } /* Export 9 */ /* Note: this can only support DMA modes, due to the commands issued. */ -int ata_device_sector_io(int device, void *buf, u32 lba, u32 nsectors, int dir) +int sceAtaDmaTransfer(int device, void *buf, u32 lba, u32 nsectors, int dir) { USE_SPD_REGS; int res = 0, retries; @@ -611,14 +611,14 @@ int ata_device_sector_io(int device, void *buf, u32 lba, u32 nsectors, int dir) if (ata_gamestar_workaround) ata_set_dir(dir); - if ((res = ata_io_start(buf, len, 0, len, sector, lcyl, hcyl, select, command)) != 0) + if ((res = sceAtaExecCmd(buf, len, 0, len, sector, lcyl, hcyl, select, command)) != 0) break; /* Set up (part of) the transfer here. In v1.04, this was called at the top of the outer loop. */ if (!ata_gamestar_workaround) ata_set_dir(dir); - res = ata_io_finish(); + res = sceAtaWaitResult(); /* In v1.04, this was not done. Neither was there a mechanism to retry if a non-permanent error occurs. */ SPD_REG16(SPD_R_IF_CTRL) &= ~SPD_IF_DMA_ENABLE; @@ -638,7 +638,7 @@ int ata_device_sector_io(int device, void *buf, u32 lba, u32 nsectors, int dir) } /* Export 4 */ -ata_devinfo_t *ata_get_devinfo(int device) +ata_devinfo_t *sceAtaInit(int device) { return &atad_devinfo; } @@ -659,8 +659,8 @@ static int ata_device_standby_immediate(int device) { int res; - if (!(res = ata_io_start(NULL, 1, 0, 0, 0, 0, 0, (device << 4) & 0xFFFF, ATA_C_STANDBY_IMMEDIATE))) - res = ata_io_finish(); + if (!(res = sceAtaExecCmd(NULL, 1, 0, 0, 0, 0, 0, (device << 4) & 0xFFFF, ATA_C_STANDBY_IMMEDIATE))) + res = sceAtaWaitResult(); return res; } diff --git a/modules/iopcore/cdvdman/atad.h b/modules/iopcore/cdvdman/atad.h index f28f1ca96..ff5289a5d 100644 --- a/modules/iopcore/cdvdman/atad.h +++ b/modules/iopcore/cdvdman/atad.h @@ -17,7 +17,7 @@ #include #include -/* These are used with the dir parameter of ata_device_sector_io(). */ +/* These are used with the dir parameter of sceAtaDmaTransfer(). */ #define ATA_DIR_READ 0 #define ATA_DIR_WRITE 1 @@ -48,12 +48,12 @@ typedef struct _ata_devinfo #define ATA_RES_ERR_ICRC -510 int atad_start(void); -ata_devinfo_t *ata_get_devinfo(int device); -int ata_io_start(void *buf, u32 blkcount, u16 feature, u16 nsector, u16 sector, u16 lcyl, u16 hcyl, u16 select, u16 command); -int ata_io_finish(void); -int ata_get_error(void); -int ata_device_sector_io(int device, void *buf, u32 lba, u32 nsectors, int dir); -int ata_device_flush_cache(int device); +ata_devinfo_t *sceAtaInit(int device); +int sceAtaExecCmd(void *buf, u32 blkcount, u16 feature, u16 nsector, u16 sector, u16 lcyl, u16 hcyl, u16 select, u16 command); +int sceAtaWaitResult(void); +int sceAtaGetError(void); +int sceAtaDmaTransfer(int device, void *buf, u32 lba, u32 nsectors, int dir); +int sceAtaFlushCache(int device); // APA Partition #define APA_MAGIC 0x00415041 // 'APA\0' diff --git a/modules/iopcore/cdvdman/cdvdman.c b/modules/iopcore/cdvdman/cdvdman.c index e5b79e399..ac9da4526 100644 --- a/modules/iopcore/cdvdman/cdvdman.c +++ b/modules/iopcore/cdvdman/cdvdman.c @@ -104,7 +104,7 @@ static void oplShutdown(int poff) if (poff) { DeviceStop(); #ifdef __USE_DEV9 - dev9Shutdown(); + Dev9CardStop(); #endif sceCdPowerOff(&stat); } diff --git a/modules/iopcore/cdvdman/dev9.c b/modules/iopcore/cdvdman/dev9.c index 5b90bdd56..4bcd75fbb 100644 --- a/modules/iopcore/cdvdman/dev9.c +++ b/modules/iopcore/cdvdman/dev9.c @@ -89,7 +89,7 @@ static int dev9x_devctl(iop_file_t *f, const char *name, int cmd, void *args, in return dev9type; case DDIOC_OFF: //Do not let the DEV9 interface to be switched off by other software. - //dev9Shutdown(); + //Dev9CardStop(); return 0; default: return 0; @@ -161,7 +161,7 @@ int dev9d_init(void) } /* Export 4 */ -void dev9RegisterIntrCb(int intr, dev9_intr_cb_t cb) +void SpdRegisterIntrHandler(int intr, dev9_intr_cb_t cb) { #ifdef HDD_DRIVER //Don't let anything else change the HDD interrupt handlers. @@ -221,7 +221,7 @@ static void dev9_set_stat(int stat) } /* Export 6 */ -void dev9Shutdown(void) +void Dev9CardStop(void) { int idx; USE_DEV9_REGS; @@ -244,7 +244,7 @@ void dev9Shutdown(void) } /* Export 7 */ -void dev9IntrEnable(int mask) +void SpdIntrEnable(int mask) { USE_SPD_REGS; int flags; @@ -255,7 +255,7 @@ void dev9IntrEnable(int mask) } /* Export 8 */ -void dev9IntrDisable(int mask) +void SpdIntrDisable(int mask) { USE_SPD_REGS; int flags; @@ -266,7 +266,7 @@ void dev9IntrDisable(int mask) } /* Export 5 */ -int dev9DmaTransfer(int ctrl, void *buf, int bcr, int dir) +int SpdDmaTransfer(int ctrl, void *buf, int bcr, int dir) { USE_SPD_REGS; volatile iop_dmac_chan_t *dev9_chan = (iop_dmac_chan_t *)DEV9_DMAC_BASE; @@ -383,7 +383,7 @@ static int read_eeprom_data(void) } /* Export 9 */ -int dev9GetEEPROM(u16 *buf) +int SpdGetEthernetID(u16 *buf) { int i; @@ -400,14 +400,14 @@ int dev9GetEEPROM(u16 *buf) } /* Export 10 */ -void dev9LEDCtl(int ctl) +void SpdSetLED(int ctl) { USE_SPD_REGS; SPD_REG8(SPD_R_PIO_DATA) = (ctl == 0); } /* Export 11 */ -int dev9RegisterShutdownCb(int idx, dev9_shutdown_cb_t cb) +int Dev9RegisterPowerOffHandler(int idx, dev9_shutdown_cb_t cb) { if (idx < 16) { dev9_shutdown_cbs[idx] = cb; @@ -436,7 +436,7 @@ static int dev9_init(void) dev9_set_stat(0x103); /* Disable all device interrupts. */ - dev9IntrDisable(0xffff); + SpdIntrDisable(0xffff); /* Register interrupt dispatch callback handler. */ p_dev9_intr_cb = (void *)dev9_intr_dispatch; @@ -453,7 +453,7 @@ static int dev9_init(void) /* Read in the MAC address. */ read_eeprom_data(); /* Turn the LED off. */ - dev9LEDCtl(0); + SpdSetLED(0); return 0; } diff --git a/modules/iopcore/cdvdman/dev9.h b/modules/iopcore/cdvdman/dev9.h index 58c08ce73..b0d9cd2a9 100644 --- a/modules/iopcore/cdvdman/dev9.h +++ b/modules/iopcore/cdvdman/dev9.h @@ -24,15 +24,15 @@ typedef void (*dev9_shutdown_cb_t)(void); typedef void (*dev9_dma_cb_t)(int bcr, int dir); int dev9d_init(void); -void dev9RegisterIntrCb(int intr, dev9_intr_cb_t cb); // #4 -int dev9DmaTransfer(int ctrl, void *buf, int bcr, int dir); // #5 -void dev9Shutdown(void); // #6 -void dev9IntrEnable(int mask); // #7 -void dev9IntrDisable(int mask); // #8 -int dev9GetEEPROM(u16 *buf); // #9 -void dev9LEDCtl(int ctl); // #10 -int dev9RegisterShutdownCb(int idx, dev9_shutdown_cb_t cb); // #11 -void dev9RegisterPreDmaCb(int ctrl, dev9_dma_cb_t cb); // #12 -void dev9RegisterPostDmaCb(int ctrl, dev9_dma_cb_t cb); // #13 +void SpdRegisterIntrHandler(int intr, dev9_intr_cb_t cb); // #4 +int SpdDmaTransfer(int ctrl, void *buf, int bcr, int dir); // #5 +void Dev9CardStop(void); // #6 +void SpdIntrEnable(int mask); // #7 +void SpdIntrDisable(int mask); // #8 +int SpdGetEthernetID(u16 *buf); // #9 +void SpdSetLED(int ctl); // #10 +int Dev9RegisterPowerOffHandler(int idx, dev9_shutdown_cb_t cb); // #11 +void dev9RegisterPreDmaCb(int ctrl, dev9_dma_cb_t cb); // #12 +void dev9RegisterPostDmaCb(int ctrl, dev9_dma_cb_t cb); // #13 #endif /* IOP_PS2DEV9_H */ diff --git a/modules/iopcore/cdvdman/device-hdd.c b/modules/iopcore/cdvdman/device-hdd.c index d852243c1..330b3fcba 100644 --- a/modules/iopcore/cdvdman/device-hdd.c +++ b/modules/iopcore/cdvdman/device-hdd.c @@ -60,14 +60,14 @@ void DeviceInit(void) DPRINTF("DeviceInit: apa header LBA = %lu\n", cdvdman_settings.lba_start); #ifdef HD_PRO - // For HDPro, as its custom ATAD module does not export ata_io_start() and ata_io_finish(). And it also resets the ATA bus. + // For HDPro, as its custom ATAD module does not export sceAtaExecCmd() and sceAtaWaitResult(). And it also resets the ATA bus. if (cdvdman_settings.common.flags & IOPCORE_ENABLE_POFF) { // If IGR is enabled (the poweroff function here is disabled), we can tell when to flush the cache. Hence if IGR is disabled, then we should disable the write cache. ata_device_set_write_cache(0, 0); } #endif - while ((r = ata_device_sector_io(0, &apaHeader, cdvdman_settings.lba_start, 2, ATA_DIR_READ)) != 0) { + while ((r = sceAtaDmaTransfer(0, &apaHeader, cdvdman_settings.lba_start, 2, ATA_DIR_READ)) != 0) { DPRINTF("DeviceInit: failed to read apa header %d\n", r); DelayThread(2000); } @@ -100,7 +100,7 @@ void DeviceLock(void) void DeviceUnmount(void) { - ata_device_flush_cache(0); + sceAtaFlushCache(0); } void DeviceStop(void) @@ -121,7 +121,7 @@ int DeviceReadSectors(u32 lsn, void *buffer, unsigned int sectors) nsectors = sectors; u32 lba = cdvdman_partspecs[CurrentPart].data_start + ((lsn - cdvdman_partspecs[CurrentPart].part_offset) << 2); - if (ata_device_sector_io(0, (void *)((u8 *)buffer + offset), lba, nsectors << 2, ATA_DIR_READ) != 0) { + if (sceAtaDmaTransfer(0, (void *)((u8 *)buffer + offset), lba, nsectors << 2, ATA_DIR_READ) != 0) { return SCECdErREAD; } offset += nsectors * 2048; diff --git a/modules/iopcore/cdvdman/exports.tab b/modules/iopcore/cdvdman/exports.tab index b23b0c3e9..4701c7eb6 100644 --- a/modules/iopcore/cdvdman/exports.tab +++ b/modules/iopcore/cdvdman/exports.tab @@ -158,7 +158,7 @@ DECLARE_EXPORT_TABLE(atad, 1, 3) DECLARE_EXPORT(_retonly) DECLARE_EXPORT(_ret0) DECLARE_EXPORT(_retonly) - DECLARE_EXPORT(ata_get_devinfo) + DECLARE_EXPORT(sceAtaInit) DECLARE_EXPORT(_dummy) DECLARE_EXPORT(_dummy) DECLARE_EXPORT(_dummy) @@ -183,14 +183,14 @@ DECLARE_EXPORT_TABLE(dev9, 1, 9) DECLARE_EXPORT(_retonly) DECLARE_EXPORT(_ret0) DECLARE_EXPORT(_retonly) - DECLARE_EXPORT(dev9RegisterIntrCb) - DECLARE_EXPORT(dev9DmaTransfer) + DECLARE_EXPORT(SpdRegisterIntrHandler) + DECLARE_EXPORT(SpdDmaTransfer) DECLARE_EXPORT(_retonly) - DECLARE_EXPORT(dev9IntrEnable) - DECLARE_EXPORT(dev9IntrDisable) - DECLARE_EXPORT(dev9GetEEPROM) - DECLARE_EXPORT(dev9LEDCtl) - DECLARE_EXPORT(dev9RegisterShutdownCb) + DECLARE_EXPORT(SpdIntrEnable) + DECLARE_EXPORT(SpdIntrDisable) + DECLARE_EXPORT(SpdGetEthernetID) + DECLARE_EXPORT(SpdSetLED) + DECLARE_EXPORT(Dev9RegisterPowerOffHandler) DECLARE_EXPORT(dev9RegisterPreDmaCb) DECLARE_EXPORT(dev9RegisterPostDmaCb) END_EXPORT_TABLE @@ -219,7 +219,7 @@ DECLARE_EXPORT_TABLE(oplutils, 1, 2) DECLARE_EXPORT(bdm_writeSector) #endif #ifdef HDD_DRIVER - DECLARE_EXPORT(ata_device_sector_io) + DECLARE_EXPORT(sceAtaDmaTransfer) #endif #ifdef SMB_DRIVER DECLARE_EXPORT(smb_OpenAndX) diff --git a/modules/iopcore/cdvdman/hdpro_atad.c b/modules/iopcore/cdvdman/hdpro_atad.c index 00fe6a74d..736e353eb 100644 --- a/modules/iopcore/cdvdman/hdpro_atad.c +++ b/modules/iopcore/cdvdman/hdpro_atad.c @@ -108,7 +108,7 @@ static const ata_cmd_info_t smart_cmd_table[] = { {ATA_S_SMART_ENABLE_OPERATIONS, 0x01}}; #define SMART_CMD_TABLE_SIZE (sizeof smart_cmd_table / sizeof(ata_cmd_info_t)) -/* This is the state info tracked between ata_io_start() and ata_io_finish(). */ +/* This is the state info tracked between sceAtaExecCmd() and sceAtaWaitResult(). */ typedef struct _ata_cmd_state { s32 type; /* The ata_cmd_info_t type field. */ @@ -197,7 +197,7 @@ int atad_start(void) } /* Export 8 */ -int ata_get_error() +int sceAtaGetError() { return hdpro_io_read(ATAreg_ERROR_RD) & 0xff; } @@ -392,7 +392,7 @@ static int ata_device_select(int device) } /* Export 6 */ -int ata_io_start(void *buf, u32 blkcount, u16 feature, u16 nsector, u16 sector, u16 lcyl, u16 hcyl, u16 select, u16 command) +int sceAtaExecCmd(void *buf, u32 blkcount, u16 feature, u16 nsector, u16 sector, u16 lcyl, u16 hcyl, u16 select, u16 command) { iop_sys_clock_t cmd_timeout; const ata_cmd_info_t *cmd_table; @@ -492,7 +492,7 @@ int ata_io_start(void *buf, u32 blkcount, u16 feature, u16 nsector, u16 sector, hdpro_io_write(ATAreg_LCYL_WR, lcyl & 0xff); hdpro_io_write(ATAreg_HCYL_WR, hcyl & 0xff); - hdpro_io_write(ATAreg_SELECT_WR, (select | ATA_SEL_LBA) & 0xff); //In v1.04, LBA was enabled in the ata_device_sector_io function. + hdpro_io_write(ATAreg_SELECT_WR, (select | ATA_SEL_LBA) & 0xff); //In v1.04, LBA was enabled in the sceAtaDmaTransfer function. hdpro_io_write(ATAreg_COMMAND_WR, command & 0xff); return 0; @@ -508,7 +508,7 @@ static int ata_pio_transfer(ata_cmd_state_t *cmd_state) u16 status = hdpro_io_read(ATAreg_STATUS_RD); if (status & ATA_STAT_ERR) { - M_PRINTF("Error: Command error: status 0x%02x, error 0x%02x.\n", status, ata_get_error()); + M_PRINTF("Error: Command error: status 0x%02x, error 0x%02x.\n", status, sceAtaGetError()); return ATA_RES_ERR_IO; } @@ -583,7 +583,7 @@ static int ata_pio_transfer(ata_cmd_state_t *cmd_state) } /* Export 7 */ -int ata_io_finish(void) +int sceAtaWaitResult(void) { ata_cmd_state_t *cmd_state = &atad_cmd_state; u32 bits; @@ -641,7 +641,7 @@ int ata_io_finish(void) if (hdpro_io_read(ATAreg_STATUS_RD) & ATA_STAT_BUSY) res = ata_wait_busy(); if ((stat = hdpro_io_read(ATAreg_STATUS_RD)) & ATA_STAT_ERR) { - M_PRINTF("Error: Command error: status 0x%02x, error 0x%02x.\n", stat, ata_get_error()); + M_PRINTF("Error: Command error: status 0x%02x, error 0x%02x.\n", stat, sceAtaGetError()); res = ATA_RES_ERR_IO; } @@ -653,15 +653,15 @@ int ata_io_finish(void) } /* Export 17 */ -int ata_device_flush_cache(int device) +int sceAtaFlushCache(int device) { int res; if (!hdpro_io_start()) return -1; - if (!(res = ata_io_start(NULL, 1, 0, 0, 0, 0, 0, (device << 4) & 0xffff, lba_48bit ? ATA_C_FLUSH_CACHE_EXT : ATA_C_FLUSH_CACHE))) - res = ata_io_finish(); + if (!(res = sceAtaExecCmd(NULL, 1, 0, 0, 0, 0, 0, (device << 4) & 0xffff, lba_48bit ? ATA_C_FLUSH_CACHE_EXT : ATA_C_FLUSH_CACHE))) + res = sceAtaWaitResult(); if (!hdpro_io_finish()) return -2; @@ -670,7 +670,7 @@ int ata_device_flush_cache(int device) } /* Export 9 */ -int ata_device_sector_io(int device, void *buf, u32 lba, u32 nsectors, int dir) +int sceAtaDmaTransfer(int device, void *buf, u32 lba, u32 nsectors, int dir) { int res = 0; unsigned int nbytes; @@ -704,10 +704,10 @@ int ata_device_sector_io(int device, void *buf, u32 lba, u32 nsectors, int dir) } //Unlike ATAD, retry indefinitely until the I/O operation succeeds. - if ((res = ata_io_start(buf, len, 0, len, sector, lcyl, - hcyl, select, command)) != 0) + if ((res = sceAtaExecCmd(buf, len, 0, len, sector, lcyl, + hcyl, select, command)) != 0) continue; - if ((res = ata_io_finish()) != 0) + if ((res = sceAtaWaitResult()) != 0) continue; nbytes = len * 512; @@ -725,7 +725,7 @@ int ata_device_sector_io(int device, void *buf, u32 lba, u32 nsectors, int dir) } /* Export 4 */ -ata_devinfo_t *ata_get_devinfo(int device) +ata_devinfo_t *sceAtaInit(int device) { return &atad_devinfo; } @@ -738,8 +738,8 @@ int ata_device_set_write_cache(int device, int enable) if (!hdpro_io_start()) return -1; - if ((res = ata_io_start(NULL, 1, enable ? 0x02 : 0x82, 0, 0, 0, 0, (device << 4) & 0xffff, ATA_C_SET_FEATURES)) == 0) - res = ata_io_finish(); + if ((res = sceAtaExecCmd(NULL, 1, enable ? 0x02 : 0x82, 0, 0, 0, 0, (device << 4) & 0xffff, ATA_C_SET_FEATURES)) == 0) + res = sceAtaWaitResult(); if (!hdpro_io_finish()) return -2; diff --git a/modules/iopcore/cdvdman/scmd.c b/modules/iopcore/cdvdman/scmd.c index 1fd5e9040..f9fbc9827 100644 --- a/modules/iopcore/cdvdman/scmd.c +++ b/modules/iopcore/cdvdman/scmd.c @@ -172,13 +172,13 @@ int sceCdReadGUID(u64 *GUID) } //-------------------------------------------------------------- -int sceCdReadModelID(unsigned long int *ModelID) +int sceCdReadModelID(unsigned int *ModelID) { return cdvdman_readID(1, (u8 *)ModelID); } //------------------------------------------------------------------------- -int sceCdReadDvdDualInfo(int *on_dual, u32 *layer1_start) +int sceCdReadDvdDualInfo(int *on_dual, unsigned int *layer1_start) { if (cdvdman_settings.common.flags & IOPCORE_COMPAT_EMU_DVDDL) { // Make layer 1 point to layer 0. diff --git a/modules/iopcore/cdvdman/searchfile.c b/modules/iopcore/cdvdman/searchfile.c index 6f26e74f2..e409e82af 100644 --- a/modules/iopcore/cdvdman/searchfile.c +++ b/modules/iopcore/cdvdman/searchfile.c @@ -133,7 +133,7 @@ static struct dirTocEntry *cdvdman_locatefile(char *name, u32 tocLBA, int tocLen if (!(cdvdman_settings.common.flags & IOPCORE_COMPAT_EMU_DVDDL)) { int on_dual; u32 layer1_start; - sceCdReadDvdDualInfo(&on_dual, &layer1_start); + sceCdReadDvdDualInfo(&on_dual, (unsigned int *)&layer1_start); if (layer) tocLBA += layer1_start; @@ -189,7 +189,7 @@ static int cdvdman_findfile(sceCdlFILE *pcdfile, const char *name, int layer) lsn = tocEntryPointer->fileLBA; if (layer) { - sceCdReadDvdDualInfo((int *)&pcdfile->lsn, &pcdfile->size); + sceCdReadDvdDualInfo((int *)&pcdfile->lsn, (unsigned int *)&pcdfile->size); lsn += pcdfile->size; } @@ -245,7 +245,7 @@ void cdvdman_searchfile_init(void) if (!(cdvdman_settings.common.flags & IOPCORE_COMPAT_EMU_DVDDL)) { int on_dual; u32 layer1_start; - sceCdReadDvdDualInfo(&on_dual, &layer1_start); + sceCdReadDvdDualInfo(&on_dual, (unsigned int *)&layer1_start); if (on_dual) { u32 lsn0 = mediaLsnCount; // So that CdRead below can read more than first layer. diff --git a/modules/iopcore/imgdrv/imgdrv.c b/modules/iopcore/imgdrv/imgdrv.c index dbfff262d..ed6e0dc0b 100644 --- a/modules/iopcore/imgdrv/imgdrv.c +++ b/modules/iopcore/imgdrv/imgdrv.c @@ -71,7 +71,7 @@ iop_device_ops_t my_device_ops = dummy_fs,//chstat*/ }; -const char name[] = "img"; +const char name[] = "host"; iop_device_t my_device = { name, IOP_DT_FS, @@ -81,7 +81,7 @@ iop_device_t my_device = { int _start(int argc, char **argv) { - // DelDrv("img"); + DelDrv("host"); AddDrv((iop_device_t *)&my_device); return MODULE_RESIDENT_END; diff --git a/modules/iopcore/imgdrv/imports.lst b/modules/iopcore/imgdrv/imports.lst index dea5494ac..8fd7269c4 100644 --- a/modules/iopcore/imgdrv/imports.lst +++ b/modules/iopcore/imgdrv/imports.lst @@ -1,6 +1,6 @@ ioman_IMPORTS_start I_AddDrv -/*I_DelDrv*/ +I_DelDrv ioman_IMPORTS_end sysclib_IMPORTS_start diff --git a/modules/isofs/zso.c b/modules/isofs/zso.c index 556a03893..dfe835124 100644 --- a/modules/isofs/zso.c +++ b/modules/isofs/zso.c @@ -21,8 +21,9 @@ void ziso_init(ZISO_header *header, u32 first_block) // read header information ziso_align = header->align; ziso_idx_start_block = -1; - // calculate number of blocks without using uncompressed_size (avoid 64bit division) - ziso_total_block = ((((first_block & 0x7FFFFFFF) << ziso_align) - sizeof(ZISO_header)) / 4) - 1; + // calculate number of blocks without using 64bit division library + u32 *total_bytes_p = (u32 *)&(header->total_bytes); + ziso_total_block = (total_bytes_p[0] >> 11) | ((total_bytes_p[1] & 0x7ff) << 21); // allocate memory if (ziso_tmp_buf == NULL) { ziso_tmp_buf = ziso_alloc(2048 + sizeof(u32) * ZISO_IDX_MAX_ENTRIES + 64); @@ -49,6 +50,10 @@ int ziso_read_sector(u8 *addr, u32 lsn, unsigned int count) return 0; // can't seek beyond file } + if (lsn + count > ziso_total_block) { + count = ziso_total_block - lsn; // adjust oob reads + } + // refresh index table if needed if (ziso_idx_start_block < 0 || lsn < ziso_idx_start_block || lsn + count >= ziso_idx_start_block + ZISO_IDX_MAX_ENTRIES - 1) { read_raw_data((u8 *)ziso_idx_cache, ZISO_IDX_MAX_ENTRIES * sizeof(u32), lsn * 4 + sizeof(ZISO_header), 0); diff --git a/modules/isofs/zso.h b/modules/isofs/zso.h index 7e71d2732..abc6342cf 100644 --- a/modules/isofs/zso.h +++ b/modules/isofs/zso.h @@ -8,7 +8,7 @@ #define ZSO_MAGIC 0x4F53495A // ZISO -// no game should request more than 256 sectors per read +// no game should request more than 256 sectors per read (512KB of data) // should allow us to decompress all data with only 2 IO calls at most. #define ZISO_IDX_MAX_ENTRIES 257 diff --git a/modules/mcemu/device-hdd.c b/modules/mcemu/device-hdd.c index 848eea46f..80230f762 100644 --- a/modules/mcemu/device-hdd.c +++ b/modules/mcemu/device-hdd.c @@ -34,7 +34,7 @@ int DeviceWritePage(int mc_num, void *buf, u32 page_num) lba = Mcpage_to_Apasector(mc_num, page_num); DPRINTF("writing page 0x%lx at lba 0x%lx\n", page_num, lba); - return (ata_device_sector_io(0, buf, lba, 1, ATA_DIR_WRITE) == 0 ? 1 : 0); + return (sceAtaDmaTransfer(0, buf, lba, 1, ATA_DIR_WRITE) == 0 ? 1 : 0); } int DeviceReadPage(int mc_num, void *buf, u32 page_num) @@ -44,7 +44,7 @@ int DeviceReadPage(int mc_num, void *buf, u32 page_num) lba = Mcpage_to_Apasector(mc_num, page_num); DPRINTF("reading page 0x%lx at lba 0x%lx\n", page_num, lba); - return (ata_device_sector_io(0, buf, lba, 1, ATA_DIR_READ) == 0 ? 1 : 0); + return (sceAtaDmaTransfer(0, buf, lba, 1, ATA_DIR_READ) == 0 ? 1 : 0); } void DeviceShutdown(void) diff --git a/modules/mcemu/imports.lst b/modules/mcemu/imports.lst index d59d4dc60..78657a438 100644 --- a/modules/mcemu/imports.lst +++ b/modules/mcemu/imports.lst @@ -23,7 +23,7 @@ I_bdm_readSector I_bdm_writeSector #endif #ifdef HDD_DRIVER -I_ata_device_sector_io +I_sceAtaDmaTransfer #endif #ifdef SMB_DRIVER I_smb_OpenAndX diff --git a/modules/mcemu/mcemu_utils.h b/modules/mcemu/mcemu_utils.h index 306d78a91..3b946fe40 100644 --- a/modules/mcemu/mcemu_utils.h +++ b/modules/mcemu/mcemu_utils.h @@ -52,12 +52,12 @@ void bdm_writeSector(unsigned int lba, unsigned short int nsectors, const unsign /* ATAD Transfer Imports */ #ifdef HDD_DRIVER -/* These are used with the dir parameter of ata_device_dma_transfer(). */ +/* These are used with the dir parameter of sceAtaDmaTransfer(). */ #define ATA_DIR_READ 0 #define ATA_DIR_WRITE 1 -int ata_device_sector_io(unsigned int unit, void *buf, unsigned int lba, unsigned int sectors, int dir); -#define I_ata_device_sector_io DECLARE_IMPORT(6, ata_device_sector_io) +int sceAtaDmaTransfer(unsigned int unit, void *buf, unsigned int lba, unsigned int sectors, int dir); +#define I_sceAtaDmaTransfer DECLARE_IMPORT(6, sceAtaDmaTransfer) #endif diff --git a/modules/network/smap-ingame/imports.lst b/modules/network/smap-ingame/imports.lst index 27ba3a64e..22375b2e2 100644 --- a/modules/network/smap-ingame/imports.lst +++ b/modules/network/smap-ingame/imports.lst @@ -35,11 +35,11 @@ ps2ip_IMPORTS_start ps2ip_IMPORTS_end dev9_IMPORTS_start -I_dev9IntrEnable -I_dev9IntrDisable -I_dev9RegisterIntrCb +I_SpdIntrEnable +I_SpdIntrDisable +I_SpdRegisterIntrHandler I_dev9RegisterPreDmaCb I_dev9RegisterPostDmaCb -I_dev9DmaTransfer -I_dev9GetEEPROM +I_SpdDmaTransfer +I_SpdGetEthernetID dev9_IMPORTS_end diff --git a/modules/network/smap-ingame/smap.c b/modules/network/smap-ingame/smap.c index c9a0388a9..f43eb200a 100644 --- a/modules/network/smap-ingame/smap.c +++ b/modules/network/smap-ingame/smap.c @@ -431,7 +431,7 @@ int SMAPStart(void) if (!SmapDriverData.SmapIsInitialized) { emac3_regbase = SmapDriverData.emac3_regbase; - dev9IntrEnable(DEV9_SMAP_INTR_MASK2); + SpdIntrEnable(DEV9_SMAP_INTR_MASK2); // Initialize the PHY, only if there's no valid link status. It should have already been previously initialized successfully by the previous instance of SMAP. result = (!(_smap_read_phy(emac3_regbase, SMAP_DsPHYTER_BMSR) & SMAP_PHY_BMSR_LINK)) ? InitPHY(&SmapDriverData) : 0; @@ -470,7 +470,7 @@ void SMAPStop(void) if (SmapDriverData.SmapIsInitialized) { emac3_regbase = SmapDriverData.emac3_regbase; - dev9IntrDisable(DEV9_SMAP_INTR_MASK2); + SpdIntrDisable(DEV9_SMAP_INTR_MASK2); SMAP_EMAC3_SET32(SMAP_R_EMAC3_MODE0, 0); SmapDriverData.NetDevStopFlag = 0; SmapDriverData.SmapIsInitialized = 0; @@ -568,7 +568,7 @@ int smap_init(int argc, char *argv[]) if (SPD_REG16(SPD_R_REV_1) < 0x11) return -6; // Minimum: revision 17, ES2. - dev9IntrDisable(DEV9_SMAP_ALL_INTR_MASK); + SpdIntrDisable(DEV9_SMAP_ALL_INTR_MASK); /* Reset FIFOs. */ SMAP_REG8(SMAP_R_TXFIFO_CTRL) = SMAP_TXFIFO_RESET; @@ -611,7 +611,7 @@ int smap_init(int argc, char *argv[]) /* Retrieve the MAC address and verify it's integrity. */ bzero(eeprom_data, 8); - if ((result = dev9GetEEPROM(eeprom_data)) < 0) { + if ((result = SpdGetEthernetID(eeprom_data)) < 0) { return (result == -1 ? -7 : -4); } @@ -647,8 +647,8 @@ int smap_init(int argc, char *argv[]) SMAP_EMAC3_SET32(SMAP_R_EMAC3_RX_WATERMARK, 16 << SMAP_E3_RX_LO_WATER_BITSFT | 128 << SMAP_E3_RX_HI_WATER_BITSFT); // Unlike the SONY original, register the interrupt handler for only RXEND and EMAC3. - dev9RegisterIntrCb(5, &Dev9IntrCb); /* RXEND */ - dev9RegisterIntrCb(6, &Dev9IntrCb); /* EMAC3 */ + SpdRegisterIntrHandler(5, &Dev9IntrCb); /* RXEND */ + SpdRegisterIntrHandler(6, &Dev9IntrCb); /* EMAC3 */ dev9RegisterPreDmaCb(1, &Dev9PreDmaCbHandler); dev9RegisterPostDmaCb(1, &Dev9PostDmaCbHandler); diff --git a/modules/network/smap-ingame/xfer.c b/modules/network/smap-ingame/xfer.c index cc75904d7..25111a0d6 100644 --- a/modules/network/smap-ingame/xfer.c +++ b/modules/network/smap-ingame/xfer.c @@ -31,7 +31,7 @@ static inline int CopyToFIFOWithDMA(volatile u8 *smap_regbase, void *buffer, int /* Non-Sony: the original block size was (32*4 = 128) bytes. However, that resulted in slightly lower performance due to the IOP needing to copy more data. */ if ((NumBlocks = length >> 6) > 0) { - if (dev9DmaTransfer(1, buffer, NumBlocks << 16 | 0x10, DMAC_FROM_MEM) >= 0) { + if (SpdDmaTransfer(1, buffer, NumBlocks << 16 | 0x10, DMAC_FROM_MEM) >= 0) { result = NumBlocks << 6; } else result = 0; diff --git a/pc/iso2opl/src/iso2opl.c b/pc/iso2opl/src/iso2opl.c index cf07d316d..d7ceff73a 100644 --- a/pc/iso2opl/src/iso2opl.c +++ b/pc/iso2opl/src/iso2opl.c @@ -462,7 +462,6 @@ void scan_dir(int isBigEndian) char *name; char fullname[512]; char newname[512]; - struct stat buf; DIR *rep = opendir("."); if (rep != NULL) { @@ -470,7 +469,7 @@ void scan_dir(int isBigEndian) name = ent->d_name; size = strlen(name); sprintf(fullname, "./%s", name); - if (!stat(fullname, &buf) && !S_ISDIR(buf.st_mode)) { + if (ent->d_type != DT_DIR) { if (strstr(name, ".iso")) { if ((size >= 17) && (name[4] == '_') && (name[8] == '.') && (name[11] == '.')) { printf("%s seems to be correctly named\n", fullname); diff --git a/pc/ziso.py b/pc/ziso.py old mode 100644 new mode 100755 index 4e05eef56..b78d38bc5 --- a/pc/ziso.py +++ b/pc/ziso.py @@ -33,7 +33,8 @@ ZISO_MAGIC = 0x4F53495A DEFAULT_ALIGN = 0 -COMPRESS_THREHOLD = 100 +DEFAULT_BLOCK_SIZE = 0x800 +COMPRESS_THREHOLD = 95 DEFAULT_PADDING = br'X' MP = False @@ -47,11 +48,15 @@ def hexdump(data): def lz4_compress(plain, level=9): - return lz4.block.compress(plain, store_size=False) + mode = "high_compression" if level > 1 else "default" + return lz4.block.compress(plain, mode=mode, compression=level, store_size=False) def lz4_compress_mp(i): - return lz4.block.compress(i[0], store_size=False) + plain = i[0] + level = i[1] + mode = "high_compression" if level > 1 else "default" + return lz4.block.compress(plain, mode=mode, compression=level, store_size=False) def lz4_decompress(compressed, block_size): @@ -68,8 +73,9 @@ def lz4_decompress(compressed, block_size): def usage(): print("Usage: ziso [-c level] [-m] [-t percent] [-h] infile outfile") - print(" -c level: 1-9 compress ISO to ZSO, use any non-zero number it has no effect") + print(" -c level: 1-12 compress ISO to ZSO, 1 for standard compression, >1 for high compression") print(" 0 decompress ZSO to ISO") + print(" -b size: 2048-8192, specify block size (2048 by default)") print(" -m Use multiprocessing acceleration for compressing") print(" -t percent Compression Threshold (1-100)") print(" -a align Padding alignment 0=small/slow 6=fast/large") @@ -112,12 +118,13 @@ def generate_zso_header(magic, header_size, total_bytes, block_size, ver, align) return data -def show_zso_info(fname_in, fname_out, total_bytes, block_size, total_block, align): +def show_zso_info(fname_in, fname_out, total_bytes, block_size, total_block, ver, align): print("Decompress '%s' to '%s'" % (fname_in, fname_out)) print("Total File Size %ld bytes" % (total_bytes)) print("block size %d bytes" % (block_size)) print("total blocks %d blocks" % (total_block)) print("index align %d" % (align)) + print("version %d" % (ver)) def decompress_zso(fname_in, fname_out): @@ -136,7 +143,7 @@ def decompress_zso(fname_in, fname_out): index_buf.append(unpack('I', fin.read(4))[0]) show_zso_info(fname_in, fname_out, total_bytes, - block_size, total_block, align) + block_size, total_block, ver, align) block = 0 percent_period = total_block/100 @@ -189,12 +196,13 @@ def decompress_zso(fname_in, fname_out): print("ziso decompress completed") -def show_comp_info(fname_in, fname_out, total_bytes, block_size, align, level): +def show_comp_info(fname_in, fname_out, total_bytes, block_size, ver, align, level): print("Compress '%s' to '%s'" % (fname_in, fname_out)) print("Total File Size %ld bytes" % (total_bytes)) print("block size %d bytes" % (block_size)) print("index align %d" % (1 << align)) print("compress level %d" % (level)) + print("version %d" % (ver)) if MP: print("multiprocessing %s" % (MP)) @@ -208,13 +216,13 @@ def set_align(fout, write_pos, align): return write_pos -def compress_zso(fname_in, fname_out, level): +def compress_zso(fname_in, fname_out, level, bsize): fin, fout = open_input_output(fname_in, fname_out) fin.seek(0, os.SEEK_END) total_bytes = fin.tell() fin.seek(0) - magic, header_size, block_size, ver, align = ZISO_MAGIC, 0x18, 0x800, 1, DEFAULT_ALIGN + magic, header_size, block_size, ver, align = ZISO_MAGIC, 0x18, bsize, 1, DEFAULT_ALIGN # We have to use alignment on any ZSO files which > 2GB, for MSB bit of index as the plain indicator # If we don't then the index can be larger than 2GB, which its plain indicator was improperly set @@ -228,7 +236,7 @@ def compress_zso(fname_in, fname_out, level): index_buf = [0 for i in range(total_block + 1)] fout.write(b"\x00\x00\x00\x00" * len(index_buf)) - show_comp_info(fname_in, fname_out, total_bytes, block_size, align, level) + show_comp_info(fname_in, fname_out, total_bytes, block_size, ver, align, level) write_pos = fout.tell() percent_period = total_block/100 @@ -252,7 +260,7 @@ def compress_zso(fname_in, fname_out, level): block / percent_period, 0), file=sys.stderr, end='\r') else: print("compress %3d%% avarage rate %3d%%\r" % ( - block / percent_period, 100*write_pos/(block*0x800)), file=sys.stderr, end='\r') + block / percent_period, 100*write_pos/(block*block_size)), file=sys.stderr, end='\r') if MP: iso_data = [(fin.read(block_size), level) @@ -323,17 +331,20 @@ def parse_args(): sys.exit(-1) try: - optlist, args = gnu_getopt(sys.argv, "c:mt:a:p:h") + optlist, args = gnu_getopt(sys.argv, "c:b:mt:a:p:h") except GetoptError as err: print(str(err)) usage() sys.exit(-1) level = None + bsize = DEFAULT_BLOCK_SIZE for o, a in optlist: if o == '-c': level = int(a) + elif o == '-b': + bsize = int(a) elif o == '-m': MP = True elif o == '-t': @@ -352,7 +363,11 @@ def parse_args(): print("You have to specify input/output filename: %s", err) sys.exit(-1) - return level, fname_in, fname_out + if bsize%2048 != 0: + print("Error, invalid block size. Must be multiple of 2048.") + sys.exit(-1) + + return level, bsize, fname_in, fname_out def load_sector_table(sector_table_fn, total_block, default_level=9): @@ -391,12 +406,12 @@ def load_sector_table(sector_table_fn, total_block, default_level=9): def main(): print("ziso-python %s by %s" % (__version__, __author__)) - level, fname_in, fname_out = parse_args() + level, bsize, fname_in, fname_out = parse_args() if level == 0: decompress_zso(fname_in, fname_out) else: - compress_zso(fname_in, fname_out, level) + compress_zso(fname_in, fname_out, level, bsize) PROFILE = False diff --git a/src/appsupport.c b/src/appsupport.c index edfd61853..244b7b0c5 100644 --- a/src/appsupport.c +++ b/src/appsupport.c @@ -407,6 +407,8 @@ static config_set_t *appGetConfig(int id) configSetStr(config, CONFIG_ITEM_NAME, appGetELFName(cur->val)); configSetStr(config, CONFIG_ITEM_LONGNAME, cur->key); configSetStr(config, CONFIG_ITEM_STARTUP, cur->val); + configSetStr(config, CONFIG_ITEM_MEDIA, "APP"); + configSetStr(config, CONFIG_ITEM_FORMAT, "ELF"); //START of OPL_DB tweaks configSetStr(config, CONFIG_ITEM_FORMAT, "ELF"); @@ -427,6 +429,8 @@ static config_set_t *appGetConfig(int id) configSetStr(config, CONFIG_ITEM_ALTSTARTUP, appsList[id].argv1); // reuse AltStartup for argument 1 snprintf(path, sizeof(path), "%s/%s", appsList[id].path, appsList[id].boot); configSetStr(config, CONFIG_ITEM_STARTUP, path); + configSetStr(config, CONFIG_ITEM_MEDIA, "APP"); + configSetStr(config, CONFIG_ITEM_FORMAT, "ELF"); //START of OPL_DB tweaks configSetStr(config, CONFIG_ITEM_FORMAT, "ELF"); @@ -453,7 +457,10 @@ static int appGetImage(char *folder, int isRelative, char *value, char *suffix, //END of OPL_DB tweaks - return oplGetAppImage(device, folder, isRelative, startup, suffix, resultTex, psm); + if (!strcmp(folder, "ART")) + return oplGetAppImage(device, folder, isRelative, startup, suffix, resultTex, psm); + else + return oplGetAppImage(device, folder, isRelative, value, suffix, resultTex, psm); } static int appGetTextId(void) diff --git a/src/bdmsupport.c b/src/bdmsupport.c index addb6faba..3745c3e43 100644 --- a/src/bdmsupport.c +++ b/src/bdmsupport.c @@ -14,6 +14,7 @@ #include +#include #define NEWLIB_PORT_AWARE #include // fileXioIoctl, fileXioDevctl @@ -27,6 +28,7 @@ static char bdmDriver[5]; static int iLinkModLoaded = 0; static int mx4sioModLoaded = 0; +static s32 bdmLoadModuleLock = -1; // forward declaration static item_list_t bdmGameList; @@ -82,6 +84,8 @@ static void bdmEventHandler(void *packet, void *opt) static void bdmLoadBlockDeviceModules(void) { + WaitSema(bdmLoadModuleLock); + if (gEnableILK && !iLinkModLoaded) { // Load iLink Block Device drivers LOG("[ILINKMAN]:\n"); @@ -99,6 +103,8 @@ static void bdmLoadBlockDeviceModules(void) mx4sioModLoaded = 1; } + + SignalSema(bdmLoadModuleLock); } void bdmLoadModules(void) @@ -168,7 +174,8 @@ static int bdmNeedsUpdate(void) DIR *dir = opendir("mass0:/"); if (dir != NULL) { int *pBDMDriver = (int *)bdmDriver; - *pBDMDriver = fileXioIoctl(dir->dd_fd, USBMASS_IOCTL_GET_DRIVERNAME, ""); + int iop_fd = ps2sdk_get_iop_fd(dir->dd_fd); + *pBDMDriver = fileXioIoctl(iop_fd, USBMASS_IOCTL_GET_DRIVERNAME, ""); closedir(dir); } @@ -255,7 +262,7 @@ static void bdmRenameGame(int id, char *newName) void bdmLaunchGame(int id, config_set_t *configSet) { - int i, fd, index, compatmask = 0; + int i, fd, iop_fd, index, compatmask = 0; int EnablePS2Logo = 0; int result; u64 startingLBA; @@ -293,7 +300,8 @@ void bdmLaunchGame(int id, config_set_t *configSet) fd = open(vmc_path, O_RDONLY); if (fd >= 0) { - if (fileXioIoctl2(fd, USBMASS_IOCTL_GET_LBA, NULL, 0, &startingLBA, sizeof(startingLBA)) == 0 && (startCluster = (unsigned int)fileXioIoctl(fd, USBMASS_IOCTL_GET_CLUSTER, vmc_path)) != 0) { + iop_fd = ps2sdk_get_iop_fd(fd); + if (fileXioIoctl2(iop_fd, USBMASS_IOCTL_GET_LBA, NULL, 0, &startingLBA, sizeof(startingLBA)) == 0 && (startCluster = (unsigned int)fileXioIoctl(iop_fd, USBMASS_IOCTL_GET_CLUSTER, vmc_path)) != 0) { // VMC only supports 32bit LBAs at the moment, so if the starting LBA + size of the VMC crosses the 32bit boundary // just report the VMC as being fragmented to prevent file system corruption. @@ -303,7 +311,7 @@ void bdmLaunchGame(int id, config_set_t *configSet) have_error = 2; } // Check VMC cluster chain for fragmentation (write operation can cause damage to the filesystem). - else if (fileXioIoctl(fd, USBMASS_IOCTL_CHECK_CHAIN, "") == 1) { + else if (fileXioIoctl(iop_fd, USBMASS_IOCTL_CHECK_CHAIN, "") == 1) { LOG("BDMSUPPORT Cluster Chain OK\n"); have_error = 0; bdm_vmc_infos.active = 1; @@ -366,6 +374,7 @@ void bdmLaunchGame(int id, config_set_t *configSet) // Open file sbCreatePath(game, partname, bdmPrefix, "/", i); fd = open(partname, O_RDONLY); + iop_fd = ps2sdk_get_iop_fd(fd); if (fd < 0) { sbUnprepare(&settings->common); guiMsgBox(_l(_STR_ERR_FILE_INVALID), 0, NULL); @@ -374,10 +383,10 @@ void bdmLaunchGame(int id, config_set_t *configSet) // Get driver - we should only need to do this once int *pBDMDriver = (int *)bdmDriver; - *pBDMDriver = fileXioIoctl(fd, USBMASS_IOCTL_GET_DRIVERNAME, ""); + *pBDMDriver = fileXioIoctl(iop_fd, USBMASS_IOCTL_GET_DRIVERNAME, ""); // Get fragment list - int iFragCount = fileXioIoctl2(fd, USBMASS_IOCTL_GET_FRAGLIST, NULL, 0, (void *)&settings->frags[iTotalFragCount], sizeof(bd_fragment_t) * (BDM_MAX_FRAGS - iTotalFragCount)); + int iFragCount = fileXioIoctl2(iop_fd, USBMASS_IOCTL_GET_FRAGLIST, NULL, 0, (void *)&settings->frags[iTotalFragCount], sizeof(bd_fragment_t) * (BDM_MAX_FRAGS - iTotalFragCount)); if (iFragCount > BDM_MAX_FRAGS) { // Too many fragments close(fd); @@ -546,3 +555,11 @@ static item_list_t bdmGameList = { BDM_MODE, 2, 0, 0, MENU_MIN_INACTIVE_FRAMES, BDM_MODE_UPDATE_DELAY, &bdmGetTextId, &bdmGetPrefix, &bdmInit, &bdmNeedsUpdate, &bdmUpdateGameList, &bdmGetGameCount, &bdmGetGame, &bdmGetGameName, &bdmGetGameNameLength, &bdmGetGameStartup, &bdmDeleteGame, &bdmRenameGame, &bdmLaunchGame, &bdmGetConfig, &bdmGetImage, &bdmCleanUp, &bdmShutdown, &bdmCheckVMC, &bdmGetIconId}; + +void bdmInitSemaphore() +{ + // Create a semaphore so only one thread can load IOP modules at a time. + if (bdmLoadModuleLock < 0) { + bdmLoadModuleLock = sbCreateSemaphore(); + } +} diff --git a/src/ethsupport.c b/src/ethsupport.c index 305870b1e..9a28ef2df 100644 --- a/src/ethsupport.c +++ b/src/ethsupport.c @@ -651,13 +651,13 @@ static void ethLaunchGame(int id, config_set_t *configSet) switch (game->format) { case GAME_FORMAT_OLD_ISO: - sprintf(settings->filename, "%s.%s%s", game->startup, game->name, game->extension); + snprintf(settings->filename, sizeof(settings->filename), "%s.%s%s", game->startup, game->name, game->extension); break; case GAME_FORMAT_ISO: - sprintf(settings->filename, "%s%s", game->name, game->extension); + snprintf(settings->filename, sizeof(settings->filename), "%s%s", game->name, game->extension); break; default: // USBExtreme format. - sprintf(settings->filename, "ul.%08X.%s", USBA_crc32(game->name), game->startup); + snprintf(settings->filename, sizeof(settings->filename), "ul.%08X.%s", USBA_crc32(game->name), game->startup); settings->common.flags |= IOPCORE_SMB_FORMAT_USBLD; } diff --git a/src/gsm.c b/src/gsm.c index e09b51f7f..2c4bd5094 100644 --- a/src/gsm.c +++ b/src/gsm.c @@ -17,6 +17,7 @@ #include "include/system.h" #include "include/ioman.h" #include "include/renderman.h" +#include "../ee_core/include/coreconfig.h" #include "include/pggsm.h" @@ -61,7 +62,7 @@ int GetGSMEnabled(void) return gEnableGSM; } -void PrepareGSM(char *cmdline) +void PrepareGSM(char *cmdline, struct GsmConfig_t *config) { /* Preparing GSM */ LOG("Preparing GSM...\n"); @@ -138,15 +139,31 @@ void PrepareGSM(char *cmdline) FIELD_fix = gGSMFIELDFix != 0 ? 1 : 0; - sprintf(cmdline, "%hhu %hhu %hhu %llu %llu %hu %u %u %d %d %d", predef_vmode[gGSMVMode].interlace, - predef_vmode[gGSMVMode].mode, - predef_vmode[gGSMVMode].ffmd, - predef_vmode[gGSMVMode].display, - predef_vmode[gGSMVMode].syncv, - ((predef_vmode[gGSMVMode].ffmd) << 1) | (predef_vmode[gGSMVMode].interlace), - (u32)gGSMXOffset, - (u32)gGSMYOffset, - k576p_fix, - kGsDxDyOffsetSupported, - FIELD_fix); + if (cmdline) { + sprintf(cmdline, "%hhu %hhu %hhu %llu %llu %hu %u %u %d %d %d", predef_vmode[gGSMVMode].interlace, + predef_vmode[gGSMVMode].mode, + predef_vmode[gGSMVMode].ffmd, + predef_vmode[gGSMVMode].display, + predef_vmode[gGSMVMode].syncv, + ((predef_vmode[gGSMVMode].ffmd) << 1) | (predef_vmode[gGSMVMode].interlace), + (u32)gGSMXOffset, + (u32)gGSMYOffset, + k576p_fix, + kGsDxDyOffsetSupported, + FIELD_fix); + } + + if (config) { + config->interlace = predef_vmode[gGSMVMode].interlace; + config->mode = predef_vmode[gGSMVMode].mode; + config->ffmd = predef_vmode[gGSMVMode].ffmd; + config->display = predef_vmode[gGSMVMode].display; + config->syncv = predef_vmode[gGSMVMode].syncv; + config->smode2 = ((predef_vmode[gGSMVMode].ffmd) << 1) | (predef_vmode[gGSMVMode].interlace); + config->dx_offset = (u32)gGSMXOffset; + config->dy_offset = (u32)gGSMYOffset; + config->k576P_fix = k576p_fix; + config->kGsDxDyOffsetSupported = kGsDxDyOffsetSupported; + config->FIELD_fix = FIELD_fix; + } } diff --git a/src/guigame.c b/src/guigame.c index b8707d4f6..85b7dce52 100644 --- a/src/guigame.c +++ b/src/guigame.c @@ -927,8 +927,6 @@ static int guiGameSavePadMacroGameConfig(config_set_t *configSet, int result) void guiGameSavePadEmuGlobalConfig(config_set_t *configGame) { if (gPadEmuSource == SETTINGS_GLOBAL) { - diaGetInt(diaPadEmuConfig, PADCFG_PADEMU_ENABLE, &EnablePadEmu); - configSetInt(configGame, CONFIG_ITEM_ENABLEPADEMU, EnablePadEmu); configSetInt(configGame, CONFIG_ITEM_PADEMUSETTINGS, PadEmuSettings); } @@ -1427,6 +1425,8 @@ static void guiGameLoadOSDLanguageConfig(config_set_t *configSet, config_set_t * gOSDLanguageValue = 0; gOSDLanguageEnable = 0; gOSDLanguageSource = 0; + gOSDTVAspectRatio = 0; + gOSDVideOutput = 0; configGetInt(configGame, CONFIG_ITEM_OSD_SETTINGS_ENABLE, &gOSDLanguageEnable); configGetInt(configGame, CONFIG_ITEM_OSD_SETTINGS_LANGID, &gOSDLanguageValue); @@ -1450,6 +1450,8 @@ static void guiGameLoadOSDLanguageConfig(config_set_t *configSet, config_set_t * diaSetInt(diaOSDConfig, OSD_LANGUAGE_SOURCE, gOSDLanguageSource); diaSetInt(diaOSDConfig, OSD_LANGUAGE_ENABLE, gOSDLanguageEnable); diaSetInt(diaOSDConfig, OSD_LANGUAGE_VALUE, gOSDLanguageValue); + diaSetInt(diaOSDConfig, OSD_TVASPECT_VALUE, gOSDTVAspectRatio); + diaSetInt(diaOSDConfig, OSD_VMODE_VALUE, gOSDVideOutput); } //OSD Language diff --git a/src/hddsupport.c b/src/hddsupport.c index 5d173c331..fd2efcd75 100644 --- a/src/hddsupport.c +++ b/src/hddsupport.c @@ -188,13 +188,13 @@ void hddLoadModules(void) "\0" "4" "\0" - "-o" + "-o" // max open "\0" - "10" + "10" // Default value: 2 "\0" - "-n" + "-n" // Number of buffers "\0" - "40"; + "40"; // Default value: 8 | Max value: 127 //END of OPL_DB tweaks LOG("HDDSUPPORT LoadModules\n"); @@ -241,9 +241,7 @@ void hddLoadModules(void) } LOG("[PS2FS]:\n"); - //START of OPL_DB tweaks ret = sysLoadModuleBuffer(&ps2fs_irx, size_ps2fs_irx, sizeof(pfsarg), pfsarg); - //END of OPL_DB tweaks if (ret < 0) { LOG("HDD: HardDisk Drive not formatted (PFS).\n"); setErrorMessageWithCode(_STR_HDD_NOT_FORMATTED_ERROR, ERROR_HDD_MODULE_PFS_FAILURE); diff --git a/src/lang.c b/src/lang.c index ae1b863ce..24d386d96 100644 --- a/src/lang.c +++ b/src/lang.c @@ -99,9 +99,9 @@ char *lngGetValue(void) return guiLangNames[guiLangID]; } -static int lngReadEntry(int index, const char *path, const char *separator, const char *name, unsigned int mode) +static int lngReadEntry(int index, const char *path, const char *separator, const char *name, unsigned char d_type) { - if (!S_ISDIR(mode)) { + if (d_type != DT_DIR) { if (strstr(name, ".lng") || strstr(name, ".LNG")) { language_t *currLang = &languages[nLanguages + index]; diff --git a/src/menusys.c b/src/menusys.c index 5902e3823..949d0fe6d 100644 --- a/src/menusys.c +++ b/src/menusys.c @@ -76,6 +76,7 @@ static submenu_list_t *appMenu; static submenu_list_t *appMenuCurrent; static s32 menuSemaId; +static s32 menuListSemaId = -1; static ee_sema_t menuSema; static void menuRenameGame(submenu_list_t **submenu) @@ -292,6 +293,9 @@ void menuInit() menuSema.max_count = 1; menuSema.option = 0; menuSemaId = CreateSema(&menuSema); + if (menuListSemaId < 0) { + menuListSemaId = sbCreateSemaphore(); + } } void menuEnd() @@ -303,8 +307,8 @@ void menuEnd() menu_list_t *td = cur; cur = cur->next; - if (&td->item) - submenuDestroy(&td->item->submenu); + if (td->item) + submenuDestroy(&(td->item->submenu)); menuRemoveHints(td->item); @@ -321,6 +325,8 @@ void menuEnd() } DeleteSema(menuSemaId); + DeleteSema(menuListSemaId); + menuListSemaId = -1; } static menu_list_t *AllocMenuItem(menu_item_t *item) @@ -340,24 +346,27 @@ void menuAppendItem(menu_item_t *item) { assert(item); + WaitSema(menuListSemaId); + if (menu == NULL) { menu = AllocMenuItem(item); selected_item = menu; - return; - } + } else { + menu_list_t *cur = menu; - menu_list_t *cur = menu; + // traverse till the end + while (cur->next) + cur = cur->next; - // traverse till the end - while (cur->next) - cur = cur->next; + // create new item + menu_list_t *newitem = AllocMenuItem(item); - // create new item - menu_list_t *newitem = AllocMenuItem(item); + // link + cur->next = newitem; + newitem->prev = cur; + } - // link - cur->next = newitem; - newitem->prev = cur; + SignalSema(menuListSemaId); } void submenuRebuildCache(submenu_list_t *submenu) diff --git a/src/opl.c b/src/opl.c index 6610a68b2..1aa1bec10 100644 --- a/src/opl.c +++ b/src/opl.c @@ -188,7 +188,7 @@ int gPadMacroSource; int gPadMacroSettings; #endif int gScrollSpeed; -char gExitPath[32]; +char gExitPath[256]; int gEnableDebug; int gPS2Logo; int gDefaultDevice; @@ -492,7 +492,6 @@ int oplScanApps(int (*callback)(const char *path, config_set_t *appConfig, void { struct dirent *pdirent; DIR *pdir; - struct stat st; int i, count, ret; item_list_t *listSupport; config_set_t *appConfig; @@ -513,9 +512,7 @@ int oplScanApps(int (*callback)(const char *path, config_set_t *appConfig, void continue; snprintf(dir, sizeof(dir), "%s/%s", appsPath, pdirent->d_name); - if (stat(dir, &st) < 0) - continue; - if (!S_ISDIR(st.st_mode)) + if (pdirent->d_type != DT_DIR) continue; snprintf(path, sizeof(path), "%s/%s", dir, APP_TITLE_CONFIG_FILE); @@ -1773,6 +1770,8 @@ static void init(void) startPads(); + bdmInitSemaphore(); + // compatibility update handler ioRegisterHandler(IO_COMPAT_UPDATE_DEFFERED, &compatDeferredUpdate); diff --git a/src/supportbase.c b/src/supportbase.c index 5d7b5d84a..5944e1cb6 100644 --- a/src/supportbase.c +++ b/src/supportbase.c @@ -289,6 +289,7 @@ static int scanForISO(char *path, char type, struct game_list_t **glist) char fullpath[256], startup[GAME_STARTUP_MAX]; struct dirent *dirent; DIR *dir; + struct stat statbuf; cache.games = NULL; cache.count = 0; @@ -302,6 +303,8 @@ static int scanForISO(char *path, char type, struct game_list_t **glist) if (NameLen > ISO_GAME_NAME_MAX) continue; // Skip files that cannot be supported properly. + snprintf(fullpath, sizeof(fullpath), "%s/%s", path, dirent->d_name); + if (format == GAME_FORMAT_OLD_ISO) { struct game_list_t *next = (struct game_list_t *)malloc(sizeof(struct game_list_t)); @@ -324,8 +327,6 @@ static int scanForISO(char *path, char type, struct game_list_t **glist) } } else { if (queryISOGameListCache(&cache, &cachedGInfo, dirent->d_name) != 0) { - snprintf(fullpath, sizeof(fullpath), "%s/%s", path, dirent->d_name); - if ((MountFD = fileXioMount("iso:", fullpath, FIO_MT_RDONLY)) >= 0) { if (GetStartupExecName("iso:/SYSTEM.CNF;1", startup, GAME_STARTUP_MAX - 1) == 0) { struct game_list_t *next = (struct game_list_t *)malloc(sizeof(struct game_list_t)); @@ -378,7 +379,12 @@ static int scanForISO(char *path, char type, struct game_list_t **glist) game->parts = 1; game->media = type; game->format = format; - game->sizeMB = dirent->d_stat.st_size >> 20; + + if (stat(fullpath, &statbuf) == 0) { + game->sizeMB = statbuf.st_size >> 20; + } else { + game->sizeMB = 0; + } count++; } @@ -662,6 +668,12 @@ int sbPrepare(base_game_info_t *game, config_set_t *configSet, int size_cdvdman, settings->fakemodule_flags |= FAKE_MODULE_FLAG_USBD; } #endif + // sanitise the settings + gOSDLanguageSource = 0; + gOSDLanguageEnable = 0; + gOSDLanguageValue = 0; + gOSDTVAspectRatio = 0; + gOSDVideOutput = 0; if (configGetInt(configSet, CONFIG_ITEM_OSD_SETTINGS_SOURCE, &gOSDLanguageSource)) { configGetInt(configSet, CONFIG_ITEM_OSD_SETTINGS_ENABLE, &gOSDLanguageEnable); diff --git a/src/system.c b/src/system.c index 3078d101d..6f777343a 100644 --- a/src/system.c +++ b/src/system.c @@ -22,6 +22,7 @@ #include "include/renderman.h" #include "include/extern_irx.h" #include "../ee_core/include/modules.h" +#include "../ee_core/include/coreconfig.h" #include #include "include/pggsm.h" #include "include/cheatman.h" @@ -44,8 +45,8 @@ typedef struct int VMC_card_slot; } createVMCparam_t; -extern void *eecore_elf; -extern int size_eecore_elf; +extern unsigned char eecore_elf[]; +extern unsigned int size_eecore_elf; //START of OPL_DB tweaks extern void *elfldr_elf; @@ -60,6 +61,7 @@ extern unsigned int size_eesync_irx; #define MAX_MODULES 64 static void *g_sysLoadedModBuffer[MAX_MODULES]; +static s32 sysLoadModuleLock = -1; #define ELF_MAGIC 0x464c457f #define ELF_PT_LOAD 1 @@ -108,6 +110,8 @@ int sysLoadModuleBuffer(void *buffer, int size, int argc, char *argv) int i, id, ret, index = 0; + WaitSema(sysLoadModuleLock); + // check we have not reached MAX_MODULES for (i = 0; i < MAX_MODULES; i++) { if (g_sysLoadedModBuffer[i] == NULL) { @@ -117,27 +121,34 @@ int sysLoadModuleBuffer(void *buffer, int size, int argc, char *argv) } if (i == MAX_MODULES) { LOG("WARNING: REACHED MODULES LIMIT (%d)\n", MAX_MODULES); - return -1; + ret = -1; + goto exit; } // check if the module was already loaded for (i = 0; i < MAX_MODULES; i++) { if (g_sysLoadedModBuffer[i] == buffer) { LOG("MODULE ALREADY LOADED (%d)\n", i); - return 0; + ret = 0; + goto exit; } } // load the module id = SifExecModuleBuffer(buffer, size, argc, argv, &ret); LOG("\t-- ID=%d, ret=%d\n", id, ret); - if ((id < 0) || (ret)) - return -2; + if ((id < 0) || (ret)) { + ret = -2; + goto exit; + } // add the module to the list g_sysLoadedModBuffer[index] = buffer; - return 0; + ret = 0; +exit: + SignalSema(sysLoadModuleLock); + return ret; } #define OPL_SIF_CMD_BUFF_SIZE 1 @@ -214,6 +225,10 @@ void sysReset(int modload_mask) sbv_patch_enable_lmb(); sbv_patch_disable_prefix_check(); + if (sysLoadModuleLock < 0) { + sysLoadModuleLock = sbCreateSemaphore(); + } + // clears modules list memset((void *)&g_sysLoadedModBuffer[0], 0, MAX_MODULES * 4); @@ -369,7 +384,7 @@ void sysExecExit(void) { // Deinitialize without shutting down active devices. deinit(NO_EXCEPTION, IO_MODE_SELECTED_ALL); - Exit(0); + exit(0); } // Module bits @@ -478,8 +493,6 @@ static unsigned int sendIrxKernelRAM(const char *startup, const char *mode_str, modcount = 0; // Basic modules - irxptr_tab[modcount].info = size_udnl_irx | SET_OPL_MOD_ID(OPL_MODULE_ID_UDNL); - irxptr_tab[modcount++].ptr = (void *)&udnl_irx; irxptr_tab[modcount].info = size_ioprp_image | SET_OPL_MOD_ID(OPL_MODULE_ID_IOPRP); irxptr_tab[modcount++].ptr = ioprp_image; irxptr_tab[modcount].info = size_imgdrv_irx | SET_OPL_MOD_ID(OPL_MODULE_ID_IMGDRV); @@ -561,20 +574,6 @@ static unsigned int sendIrxKernelRAM(const char *startup, const char *mode_str, irxtable->modules = irxptr_tab; irxtable->count = modcount; -#ifdef __DECI2_DEBUG - // For DECI2 debugging mode, the UDNL module will have to be stored within kernel RAM because there isn't enough space below user RAM. - // total_size will hence not include the IOPRP image, but it's okay because the EE core is interested in protecting the module storage within user RAM. - irxptr = (void *)0x00033000; - LOG("SYSTEM DECI2 UDNL address start: %p end: %p\n", irxptr, (void *)((u8 *)irxptr + GET_OPL_MOD_SIZE(irxptr_tab[0].info))); - DI(); - ee_kmode_enter(); - memcpy((void *)(0x80000000 | (unsigned int)irxptr), irxptr_tab[0].ptr, GET_OPL_MOD_SIZE(irxptr_tab[0].info)); - ee_kmode_exit(); - EI(); - - irxptr_tab[0].ptr = irxptr; // UDNL is the first module. -#endif - total_size = (sizeof(irxtab_t) + sizeof(irxptr_t) * modcount + 0xF) & ~0xF; irxptr = (void *)((((unsigned int)irxptr_tab + sizeof(irxptr_t) * modcount) + 0xF) & ~0xF); @@ -739,6 +738,41 @@ static int initKernel(void *eeload, void *modStorageEnd, void **eeloadCopy, void return ((*eeloadCopy != NULL && *initUserMemory != NULL) ? 0 : -1); } +#ifdef __DEBUG +void sysPrintEECoreConfig(struct EECoreConfig_t *config) +{ + LOG("EECoreConfig Values = 0x%08X\n", (u32)config); + + LOG("Game Mode Desc = %s\n", config->GameModeDesc); + LOG("EnableDebug = %d\n", config->EnableDebug); + + LOG("Exit Path = (%s)\n", config->ExitPath); + LOG("HDD Spindown = %d\n", config->HDDSpindown); + + LOG("IP=%s NM=%s GW=%s mode: %d\n", config->g_ps2_ip, config->g_ps2_netmask, config->g_ps2_gateway, config->g_ps2_ETHOpMode); + + LOG("PS2RD Cheat Engine = %s\n", config->gCheatList == NULL ? "Disabled" : "Enabled"); + + LOG("EnforceLanguage = %s\n", config->enforceLanguage == 0 ? "Disabled" : "Enabled"); + + LOG("GSM = %s\n", config->EnableGSMOp == 0 ? "Disabled" : "Enabled"); + + LOG("PADEMU = %s\n", config->EnablePadEmuOp == 0 ? "Disabled" : "Enabled"); + + LOG("enforceLanguage = %s\n", config->enforceLanguage == 0 ? "Disabled" : "Enabled"); + + LOG("eeloadCopy = 0x%08X\n", config->eeloadCopy); + LOG("initUserMemory = 0x%08X\n", config->initUserMemory); + + LOG("ModStorageStart = 0x%08X\n", config->ModStorageStart); + LOG("ModStorageEnd = 0x%08X\n", config->ModStorageEnd); + + LOG("GameID = %s\n", config->GameID); + + LOG("Compat Mask = 0x%02x\n", config->_CompatMask); +} +#endif + void sysLaunchLoaderElf(const char *filename, const char *mode_str, int size_cdvdman_irx, void **cdvdman_irx, int size_mcemu_irx, void **mcemu_irx, int EnablePS2Logo, unsigned int compatflags) { unsigned int modules, ModuleStorageSize; @@ -750,12 +784,9 @@ void sysLaunchLoaderElf(const char *filename, const char *mode_str, int size_cdv void *pdata; int argc, i; char ElfPath[32]; - char *argv[7 + GSM_ARGS]; - char ModStorageConfig[32]; - char KernelConfig[32]; - char config_str[256]; - char gsm_config_str[256]; + char *argv[4]; void *eeloadCopy, *initUserMemory; + struct GsmConfig_t gsm_config; ethGetNetConfig(local_ip_address, local_netmask, local_gateway); #if (!defined(__DEBUG) && !defined(_DTL_T10000)) @@ -792,26 +823,12 @@ void sysLaunchLoaderElf(const char *filename, const char *mode_str, int size_cdv ModuleStorageSize = (sendIrxKernelRAM(filename, mode_str, modules, ModuleStorage, size_cdvdman_irx, cdvdman_irx, size_mcemu_irx, mcemu_irx) + 0x3F) & ~0x3F; ModuleStorageEnd = (void *)((u8 *)ModuleStorage + ModuleStorageSize); - sprintf(ModStorageConfig, "%u %u", (unsigned int)ModuleStorage, (unsigned int)ModuleStorageEnd); // NB: LOADER.ELF is embedded boot_elf = (u8 *)&eecore_elf; eh = (elf_header_t *)boot_elf; eph = (elf_pheader_t *)(boot_elf + eh->phoff); - // Scan through the ELF's program headers and copy them into RAM, then - // zero out any non-loaded regions. - for (i = 0; i < eh->phnum; i++) { - if (eph[i].type != ELF_PT_LOAD) - continue; - - pdata = (void *)((u8 *)boot_elf + eph[i].offset); - memcpy(eph[i].vaddr, pdata, eph[i].filesz); - - if (eph[i].memsz > eph[i].filesz) - memset(eph[i].vaddr + eph[i].filesz, 0, eph[i].memsz - eph[i].filesz); - } - ApplyDeckardXParam(filename); // Get the kernel to use our EELOAD module and to begin erasure after module storage. EE core will erase any memory before the module storage (if any). @@ -819,17 +836,6 @@ void sysLaunchLoaderElf(const char *filename, const char *mode_str, int size_cdv LOG("Error - kernel is unsupported.\n"); asm volatile("break\n"); } - sprintf(KernelConfig, "%u %u", (unsigned int)eeloadCopy, (unsigned int)initUserMemory); - -#ifdef PADEMU -#define PADEMU_SPECIFIER " %d %u %u" -#define PADEMU_ARGUMENT , gEnablePadEmu, (unsigned int)(gPadEmuSettings >> 8), (unsigned int)(gPadMacroSettings) -#else -#define PADEMU_SPECIFIER -#define PADEMU_ARGUMENT -#endif - -#define CONFIGPARAMDATA " %d %d %d %d %d %d %d %d %d" ConfigParam PARAM; GetOsdConfigParam(&PARAM); if (gOSDLanguageEnable) { // only patch if enabled, and only on config fields wich have not chosen "system default" @@ -847,45 +853,119 @@ void sysLaunchLoaderElf(const char *filename, const char *mode_str, int size_cdv } } -#define CONFIGPARAMDATA_ARGUMENT , PARAM.spdifMode, PARAM.screenType, PARAM.videoOutput, PARAM.japLanguage, PARAM.ps1drvConfig, PARAM.version, PARAM.language, PARAM.timezoneOffset, gOSDLanguageEnable + struct EECoreConfig_t *config = NULL; + u32 *core_ptr = (u32 *)&eecore_elf; - argc = 0; - sprintf(config_str, "%s %d %s %d %u.%u.%u.%u %u.%u.%u.%u %u.%u.%u.%u %d %u %d" PADEMU_SPECIFIER CONFIGPARAMDATA, - mode_str, gEnableDebug, gExitPath, gHDDSpindown, - local_ip_address[0], local_ip_address[1], local_ip_address[2], local_ip_address[3], - local_netmask[0], local_netmask[1], local_netmask[2], local_netmask[3], - local_gateway[0], local_gateway[1], local_gateway[2], local_gateway[3], - gETHOpMode, - GetCheatsEnabled() ? (unsigned int)GetCheatsList() : 0, - GetGSMEnabled() PADEMU_ARGUMENT - CONFIGPARAMDATA_ARGUMENT); - - argv[argc] = config_str; - argc++; + for (i = 0; i < size_eecore_elf / 4; i++) { + if (core_ptr[0] == EE_CORE_MAGIC_0 && core_ptr[1] == EE_CORE_MAGIC_1) { + config = (struct EECoreConfig_t *)core_ptr; + break; + } + core_ptr++; + } - argv[argc] = KernelConfig; - argc++; + if (config == NULL) { // Should not happen, but... + LOG("Error - EE core config MAGIC not found!\n"); + asm volatile("break\n"); + } - argv[argc] = ModStorageConfig; - argc++; + memset(config, 0, sizeof(struct EECoreConfig_t)); + + config->magic[0] = EE_CORE_MAGIC_0; + config->magic[1] = EE_CORE_MAGIC_1; + + strncpy(config->ExitPath, gExitPath, CORE_EXIT_PATH_MAX_LEN); + strncpy(config->GameModeDesc, mode_str, CORE_GAME_MODE_DESC_MAX_LEN); + + config->EnableDebug = gEnableDebug; + config->HDDSpindown = gHDDSpindown; + config->gCheatList = GetCheatsEnabled() ? (unsigned int *)GetCheatsList() : NULL; + config->g_ps2_ETHOpMode = gETHOpMode; + + sprintf(config->g_ps2_ip, "%u.%u.%u.%u", local_ip_address[0], local_ip_address[1], local_ip_address[2], local_ip_address[3]); + sprintf(config->g_ps2_netmask, "%u.%u.%u.%u", local_netmask[0], local_netmask[1], local_netmask[2], local_netmask[3]); + sprintf(config->g_ps2_gateway, "%u.%u.%u.%u", local_gateway[0], local_gateway[1], local_gateway[2], local_gateway[3]); + + // GSM now. + config->EnableGSMOp = GetGSMEnabled(); + if (config->EnableGSMOp) { + PrepareGSM(NULL, &gsm_config); + config->GsmConfig.interlace = gsm_config.interlace; + config->GsmConfig.mode = gsm_config.mode; + config->GsmConfig.ffmd = gsm_config.ffmd; + config->GsmConfig.display = gsm_config.display; + config->GsmConfig.syncv = gsm_config.syncv; + config->GsmConfig.smode2 = gsm_config.smode2; + config->GsmConfig.dx_offset = gsm_config.dx_offset; + config->GsmConfig.dy_offset = gsm_config.dy_offset; + config->GsmConfig.k576P_fix = gsm_config.k576P_fix; + config->GsmConfig.kGsDxDyOffsetSupported = gsm_config.kGsDxDyOffsetSupported; + config->GsmConfig.FIELD_fix = gsm_config.FIELD_fix; + } - argv[argc] = (char *)filename; - argc++; +#ifdef PADEMU + config->EnablePadEmuOp = gEnablePadEmu; + config->PadEmuSettings = (unsigned int)(gPadEmuSettings >> 8); + config->PadMacroSettings = (unsigned int)(gPadMacroSettings); +#endif - char cmask[10]; - snprintf(cmask, 10, "%u", compatflags); - argv[argc] = cmask; - argc++; + config->CustomOSDConfigParam.spdifMode = PARAM.spdifMode; + config->CustomOSDConfigParam.screenType = PARAM.screenType; + config->CustomOSDConfigParam.videoOutput = PARAM.videoOutput; + config->CustomOSDConfigParam.japLanguage = PARAM.japLanguage; + config->CustomOSDConfigParam.ps1drvConfig = PARAM.ps1drvConfig; + config->CustomOSDConfigParam.version = PARAM.version; + config->CustomOSDConfigParam.language = PARAM.language; + config->CustomOSDConfigParam.timezoneOffset = PARAM.timezoneOffset; - PrepareGSM(gsm_config_str); - argv[argc] = gsm_config_str; - argc++; + config->enforceLanguage = gOSDLanguageEnable; + + config->eeloadCopy = eeloadCopy; + config->initUserMemory = initUserMemory; + + config->ModStorageStart = ModuleStorage; + config->ModStorageEnd = ModuleStorageEnd; + + strncpy(config->GameID, filename, CORE_GAME_ID_MAX_LEN); + + config->_CompatMask = compatflags; + +#ifdef __DEBUG + + sysPrintEECoreConfig(config); + +#endif + // Scan through the ELF's program headers and copy them into RAM, then + // zero out any non-loaded regions. + + FlushCache(0); + FlushCache(2); + + for (i = 0; i < eh->phnum; i++) { + if (eph[i].type != ELF_PT_LOAD) + continue; + + pdata = (void *)((u8 *)boot_elf + eph[i].offset); + memcpy(eph[i].vaddr, pdata, eph[i].filesz); + LOG("EECORE PH COPY: %d 0x%08X 0x%08X 0x%08X\n", i, (u32)eph[i].vaddr, (u32)pdata, eph[i].filesz); + + if (eph[i].memsz > eph[i].filesz) { + LOG("EECORE PH CLEAR: %d 0x%08X 0x%08X\n", i, (u32)((u32)eph[i].vaddr + eph[i].filesz), eph[i].memsz - eph[i].filesz); + memset(eph[i].vaddr + eph[i].filesz, 0, eph[i].memsz - eph[i].filesz); + } + } + + argc = 0; // PS2LOGO Caller, based on l_oliveira & SP193 tips // Don't call LoadExecPS2 here because it will wipe all memory above the EE core, making it impossible to pass data via pointers. - if (EnablePS2Logo) { - argv[argc] = "rom0:PS2LOGO"; - argc++; + if (EnablePS2Logo) { // Not all roms have PS2LOGO + int fd = 0; + if ((fd = open("rom0:PS2LOGO", O_RDONLY)) >= 0) { + close(fd); + argv[argc] = "rom0:PS2LOGO"; + argc++; + } } snprintf(ElfPath, sizeof(ElfPath), "cdrom0:\\%s;1", filename); @@ -893,13 +973,13 @@ void sysLaunchLoaderElf(const char *filename, const char *mode_str, int size_cdv argc++; #ifdef __DEBUG - LOG("Starting ee_core with following arguments:\n"); + LOG("Starting ee_core with following argv arguments:\n"); for (i = 0; i < argc; i++) { LOG("[%d] %s\n", i, argv[i]); } #endif - LOG("Leaving OPL GUI, starting eecore...\n"); + LOG("Leaving OPL GUI, starting eecore = 0x%08X \n", (u32)eh->entry); // Let's go. fileXioExit(); diff --git a/src/themes.c b/src/themes.c index bc7d94663..8974c1b73 100644 --- a/src/themes.c +++ b/src/themes.c @@ -1126,9 +1126,9 @@ static void thmFree(theme_t *theme) } } -static int thmReadEntry(int index, const char *path, const char *separator, const char *name, unsigned int mode) +static int thmReadEntry(int index, const char *path, const char *separator, const char *name, unsigned char d_type) { - if (S_ISDIR(mode) && strstr(name, "thm_")) { + if (d_type == DT_DIR && strstr(name, "thm_")) { theme_file_t *currTheme = &themes[nThemes + index]; int length = strlen(name) - 4 + 1; diff --git a/src/util.c b/src/util.c index 676cfbace..1a2d51edf 100644 --- a/src/util.c +++ b/src/util.c @@ -9,6 +9,8 @@ #include "include/ioman.h" #include "include/system.h" #include +#include +#include #include #include @@ -209,10 +211,9 @@ void *readFile(char *path, int align, int *size) } int listDir(char *path, const char *separator, int maxElem, - int (*readEntry)(int index, const char *path, const char *separator, const char *name, unsigned int mode)) + int (*readEntry)(int index, const char *path, const char *separator, const char *name, unsigned char d_type)) { int index = 0; - struct stat st; char filename[128]; if (checkFile(path, O_RDONLY)) { @@ -221,8 +222,7 @@ int listDir(char *path, const char *separator, int maxElem, if (dir != NULL) { while (index < maxElem && (dirent = readdir(dir)) != NULL) { snprintf(filename, 128, "%s/%s", path, dirent->d_name); - stat(filename, &st); - index = readEntry(index, path, separator, dirent->d_name, st.st_mode); + index = readEntry(index, path, separator, dirent->d_name, dirent->d_type); } closedir(dir); @@ -458,7 +458,8 @@ int InitConsoleRegionData(void) char romver[16]; if ((result = ConsoleRegion) < 0) { - GetRomName(romver); + _io_driver driver = {open, close, (int (*)(int, void *, int))read, O_RDONLY}; + GetRomNameWithIODriver(romver, &driver); switch (romver[4]) { case 'C': @@ -589,7 +590,6 @@ int sysDeleteFolder(const char *folder) char *path; struct dirent *dirent; DIR *dir; - struct stat st; struct DirentToDelete *head, *start; result = 0; @@ -602,9 +602,8 @@ int sysDeleteFolder(const char *folder) path = malloc(strlen(folder) + strlen(dirent->d_name) + 2); sprintf(path, "%s/%s", folder, dirent->d_name); - stat(path, &st); - if (S_ISDIR(st.st_mode)) { + if (dirent->d_type == DT_DIR) { /* Recursive, delete all subfolders */ result = sysDeleteFolder(path); free(path);