From f38dc09c801b182424bfe31395afcf144050a1c9 Mon Sep 17 00:00:00 2001 From: Ziemas Date: Tue, 1 Oct 2024 14:46:41 +0200 Subject: [PATCH 01/21] Start cmake port --- CMakeLists.txt | 18 +++ ee/CMakeLists.txt | 5 + ee/kernel/CMakeLists.txt | 230 ++++++++++++++++++++++++++++++++ iop/CMakeLists.txt | 0 tools/CMakeLists.txt | 9 ++ tools/adpenc/CMakeLists.txt | 2 + tools/bin2c/CMakeLists.txt | 2 + tools/gensymtab/CMakeLists.txt | 2 + tools/ps2-irxgen/CMakeLists.txt | 2 + tools/ps2adpcm/CMakeLists.txt | 2 + tools/romimg/CMakeLists.txt | 2 + 11 files changed, 274 insertions(+) create mode 100644 CMakeLists.txt create mode 100644 ee/CMakeLists.txt create mode 100644 ee/kernel/CMakeLists.txt create mode 100644 iop/CMakeLists.txt create mode 100644 tools/CMakeLists.txt create mode 100644 tools/adpenc/CMakeLists.txt create mode 100644 tools/bin2c/CMakeLists.txt create mode 100644 tools/gensymtab/CMakeLists.txt create mode 100644 tools/ps2-irxgen/CMakeLists.txt create mode 100644 tools/ps2adpcm/CMakeLists.txt create mode 100644 tools/romimg/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 00000000000..586ab724099 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,18 @@ +cmake_minimum_required(VERSION 3.10) +project(ps2sdk) +include(ExternalProject) + +ExternalProject_Add(tools + SOURCE_DIR ${PROJECT_SOURCE_DIR}/tools + CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${CMAKE_CURRENT_BINARY_DIR}/tools + BUILD_ALWAYS true) + +ExternalProject_Add(ee + SOURCE_DIR ${PROJECT_SOURCE_DIR}/ee + CMAKE_ARGS -DCMAKE_TOOLCHAIN_FILE=${PROJECT_SOURCE_DIR}/cmake/ee_toolchain.cmake -DCMAKE_INSTALL_PREFIX=${CMAKE_CURRENT_BINARY_DIR}/ee + BUILD_ALWAYS true) + +#ExternalProject_Add(iop +# SOURCE_DIR ${PROJECT_SOURCE_DIR}/iop +# CMAKE_ARGS -DCMAKE_TOOLCHAIN_FILE=${PROJECT_SOURCE_DIR}/cmake/iop_toolchain.cmake -DCMAKE_INSTALL_PREFIX=${CMAKE_CURRENT_BINARY_DIR}/iop +# BUILD_ALWAYS true) \ No newline at end of file diff --git a/ee/CMakeLists.txt b/ee/CMakeLists.txt new file mode 100644 index 00000000000..e41fd4b74f4 --- /dev/null +++ b/ee/CMakeLists.txt @@ -0,0 +1,5 @@ +cmake_minimum_required(VERSION 3.10) +project(ps2sdk-ee) + + +add_subdirectory(kernel) \ No newline at end of file diff --git a/ee/kernel/CMakeLists.txt b/ee/kernel/CMakeLists.txt new file mode 100644 index 00000000000..b027b0d18a1 --- /dev/null +++ b/ee/kernel/CMakeLists.txt @@ -0,0 +1,230 @@ +cmake_minimum_required(VERSION 3.10) + +set(EXEC_SYSCALLS KExit.o _LoadExecPS2.o _ExecPS2.o) +set(EXECOSD_SYSCALL _ExecOSD.o) +set(ALARM_SYSCALLS _SetAlarm.o SetAlarm.o _ReleaseAlarm.o ReleaseAlarm.o) +set(ALARM_INTR_SYSCALLS _iSetAlarm.o iSetAlarm.o _iReleaseAlarm.o iReleaseAlarm.o) +set(ROTATE_THREAD_READY_QUEUE_SYSCALL _iRotateThreadReadyQueue.o) +set(IWAKEUP_THREAD_SYSCALL _iWakeupThread.o) +set(ISUSPEND_THREAD_SYSCALL _iSuspendThread.o) +set(TLB_SYSCALLS PutTLBEntry.o iPutTLBEntry.o _SetTLBEntry.o iSetTLBEntry.o GetTLBEntry.o iGetTLBEntry.o ProbeTLBEntry.o iProbeTLBEntry.o ExpandScratchPad.o) + +set(SIFCMD_OBJ + sif_cmd_send.o _sif_cmd_int_handler.o sif_cmd_main.o + sif_cmd_client.o sif_cmd_remove_cmdhandler.o sif_sreg_get.o +) + +set(SIFRPC_OBJ + SifBindRpc.o SifCallRpc.o SifRpcGetOtherData.o + SifRegisterRpc.o SifRemoveRpc.o SifSetRpcQueue.o SifRemoveRpcQueue.o SifGetNextRequest.o + SifExecRequest.o SifRpcLoop.o SifRpcMain.o _rpc_get_packet.o + _rpc_get_fpacket.o SifCheckStatRpc.o +) + +set(FILEIO_OBJ + __fio_internals.o fio_init.o _fio_intr.o fio_sync.o fio_setblockmode.o + fio_exit.o fio_open.o fio_close.o fio_read.o + fio_write.o fio_lseek.o fio_mkdir.o _fio_read_intr.o fio_getc.o fio_putc.o + fio_ioctl.o fio_dopen.o fio_dclose.o fio_dread.o fio_getstat.o fio_chstat.o + fio_remove.o fio_format.o fio_rmdir.o fio_gets.o +) + +set(LOADFILE_OBJ + SifLoadFileInit.o SifLoadFileExit.o _SifLoadModule.o SifLoadModule.o + SifLoadStartModule.o SifLoadModuleEncrypted.o SifStopModule.o SifUnloadModule.o + SifSearchModuleByName.o SifSearchModuleByAddress.o _SifLoadElfPart.o SifLoadElfPart.o + SifLoadElf.o SifLoadElfEncrypted.o SifIopSetVal.o SifIopGetVal.o + _SifLoadModuleBuffer.o SifLoadModuleBuffer.o SifLoadStartModuleBuffer.o + SifExecModuleBuffer.o SifExecModuleFile.o +) + +set(IOPHEAP_OBJ + SifInitIopHeap.o SifExitIopHeap.o SifAllocIopHeap.o + SifFreeIopHeap.o SifLoadIopHeap.o +) + +set(IOPCONTROL_OBJ + SifIopReboot.o SifIopReset.o SifIopIsAlive.o SifIopSync.o __iop_control_internals.o +) + +set(GLUE_OBJ + DIntr.o EIntr.o EnableIntc.o DisableIntc.o EnableDmac.o DisableDmac.o + iEnableIntc.o iDisableIntc.o iEnableDmac.o iDisableDmac.o + SyncDCache.o iSyncDCache.o InvalidDCache.o iInvalidDCache.o +) + +set(SIO_OBJ + sio_init.o sio_putc.o sio_getc.o sio_write.o sio_read.o sio_puts.o + sio_gets.o sio_getc_block.o sio_flush.o sio_putsn.o +) + +set(ROM0_OBJ + _info_internals.o GetRomNameWithIODriver.o GetRomName.o IsDESRMachineWithIODriver.o IsDESRMachine.o IsT10KWithIODriver.o IsT10K.0 +) + +set(CONFIG_OBJ + _config_internals.o converttobcd.o convertfrombcd.o __adjustTime.o IsEarlyJap.o + configGetLanguageWithIODriver.o configGetLanguage.o + configSetLanguageWithIODriver.o configSetLanguage.o + configGetTvScreenTypeWithIODriver.o configGetTvScreenType.o + configSetTvScreenTypeWithIODriver.o configSetTvScreenType.o + configGetDateFormatWithIODriver.o configGetDateFormat.o + configSetDateFormatWithIODriver.o configSetDateFormat.o + configGetTimeFormatWithIODriver.o configGetTimeFormat.o + configSetTimeFormatWithIODriver.o configSetTimeFormat.o + configGetTimezoneWithIODriver.o configGetTimezone.o + configSetTimezoneWithIODriver.o configSetTimezone.o + configIsSpdifEnabledWithIODriver.o configIsSpdifEnabled.o + configSetSpdifEnabledWithIODriver.o configSetSpdifEnabled.o + configIsDaylightSavingEnabledWithIODriver.o configIsDaylightSavingEnabled.o + configSetDaylightSavingEnabledWithIODriver.o configSetDaylightSavingEnabled.o + configConvertToGmtTime.o configConvertToLocalTimeWithIODriver.o configConvertToLocalTime.o +) + +# bin2c osdsrc_bin.o +set(LIBOSD_OBJ libosd.o libosd_full.o libosd_common.o) + +# bin2c tlbsrc_bin.o +set(TLBFUNC_OBJ tlbfunc.o) + +# bin2c srcfile_bin.o, eenull_bin.o +set(ALARM_OBJ alarm.o) + +set(THREAD_OBJ _thread_internals.o iWakeupThread.o iRotateThreadReadyQueue.o iSuspendThread.o) + +set(SETUP_OBJ kCopy.o kCopyBytes.o) + +set(EXIT_OBJ _exit_internals.o SetArg.o Exit.o ExecPS2.o LoadExecPS2.o ExecOSD.o) + +set(TIMER_OBJ + timer_data.o + SetT2.o + SetT2_COUNT.o + SetT2_MODE.o + SetT2_COMP.o + InitTimer.o + EndTimer.o + GetTimerPreScaleFactor.o + StartTimerSystemTime.o + StopTimerSystemTime.o + SetNextComp.o + InsertAlarm_ForTimer.o + UnlinkAlarm_ForTimer.o + TimerHandler_callback.o + iGetTimerSystemTime.o + GetTimerSystemTime.o + iAllocTimerCounter.o + AllocTimerCounter.o + iFreeTimerCounter.o + FreeTimerCounter.o + iGetTimerUsedUnusedCounters.o + GetTimerUsedUnusedCounters.o + iStartTimerCounter.o + StartTimerCounter.o + iStopTimerCounter.o + StopTimerCounter.o + SetTimerCount.o + iGetTimerBaseTime.o + GetTimerBaseTime.o + iGetTimerCount.o + GetTimerCount.o + iSetTimerHandler.o + SetTimerHandler.o + TimerBusClock2USec.o + TimerUSec2BusClock.o + TimerBusClock2Freq.o + TimerFreq2BusClock.o + cpu_ticks.o +) + +set(TIMER_ALARM_OBJ + alarm_data.o + ForTimer_InitAlarm.o + AlarmHandler.o + iSetTimerAlarm.o + SetTimerAlarm.o + iReleaseTimerAlarm.o + ReleaseTimerAlarm.o +) + +set(DELAYTHREAD_OBJ + DelayThread.o +) + +set(GETKERNEL_OBJ GetSyscallHandler.o GetSyscall.o GetExceptionHandler.o GetInterruptHandler.o) + +set(INITSYS_OBJ _InitSys.o TerminateLibrary.o) + +set(KERNEL_UTIL_OBJS WaitSemaEx.o) + +set(KERNEL_OBJ ResetEE.o SetGsCrt.o ${EXEC_SYSCALLS} + RFU009.o AddSbusIntcHandler.o RemoveSbusIntcHandler.o Interrupt2Iop.o + SetVTLBRefillHandler.o SetVCommonHandler.o SetVInterruptHandler.o + AddIntcHandler.o AddIntcHandler2.o RemoveIntcHandler.o AddDmacHandler.o AddDmacHandler2.o + RemoveDmacHandler.o _EnableIntc.o _DisableIntc.o _EnableDmac.o _DisableDmac.o + ${ALARM_SYSCALLS} _iEnableIntc.o _iDisableIntc.o _iEnableDmac.o + _iDisableDmac.o ${ALARM_INTR_SYSCALLS} CreateThread.o DeleteThread.o + StartThread.o ExitThread.o ExitDeleteThread.o TerminateThread.o + iTerminateThread.o DisableDispatchThread.o EnableDispatchThread.o + ChangeThreadPriority.o iChangeThreadPriority.o RotateThreadReadyQueue.o + ${ROTATE_THREAD_READY_QUEUE_SYSCALL} ReleaseWaitThread.o iReleaseWaitThread.o + GetThreadId.o _iGetThreadId.o ReferThreadStatus.o iReferThreadStatus.o SleepThread.o + WakeupThread.o ${IWAKEUP_THREAD_SYSCALL} CancelWakeupThread.o iCancelWakeupThread.o + SuspendThread.o ${ISUSPEND_THREAD_SYSCALL} ResumeThread.o iResumeThread.o + RFU059.o RFU060.o SetupThread.o RFU061.o SetupHeap.o EndOfHeap.o CreateSema.o DeleteSema.o + iSignalSema.o SignalSema.o WaitSema.o PollSema.o iPollSema.o + ReferSemaStatus.o iReferSemaStatus.o iDeleteSema.o SetOsdConfigParam.o + GetOsdConfigParam.o GetGsHParam.o GetGsVParam.o SetGsHParam.o + SetGsVParam.o CreateEventFlag.o DeleteEventFlag.o SetEventFlag.o + iSetEventFlag.o ${TLB_SYSCALLS} + EnableIntcHandler.o iEnableIntcHandler.o DisableIntcHandler.o iDisableIntcHandler.o + EnableDmacHandler.o iEnableDmacHandler.o DisableDmacHandler.o iDisableDmacHandler.o + KSeg0.o EnableCache.o DisableCache.o GetCop0.o FlushCache.o CpuConfig.o + iGetCop0.o iFlushCache.o RFU105.o iCpuConfig.o SifStopDma.o + SetCPUTimerHandler.o SetCPUTimer.o SetOsdConfigParam2.o + GetOsdConfigParam2.o GsGetIMR.o iGsGetIMR.o GsPutIMR.o iGsPutIMR.o + SetPgifHandler.o SetVSyncFlag.o SetSyscall.o SifDmaStat.o iSifDmaStat.o + SifSetDma.o iSifSetDma.o SifSetDChain.o iSifSetDChain.o SifSetReg.o + SifGetReg.o ${EXECOSD_SYSCALL} Deci2Call.o PSMode.o MachineType.o GetMemorySize.o _GetGsDxDyOffset.o + _InitTLB.o SetMemoryMode.o + SifWriteBackDCache.o _SyncDCache.o _InvalidDCache.o __errno.o errno.o + strncpy.o strlen.o memcpy.o memset.o __syscall.o GPfuncs.o _print.o +) + +function(compile_multiple target objects srcfile) + foreach(obj ${objects}) + add_library(${obj} OBJECT ${srcfile}) + set_target_properties(${obj} PROPERTIES LINKER_LANGUAGE C) + get_filename_component(def ${obj} NAME_WLE) + target_compile_definitions(${obj} PUBLIC "F_${def}") + target_link_libraries(${target} private ${obj}) + endforeach() +endfunction() + +add_library(kernel) +compile_multiple(kernel "${SIFCMD_OBJ}" src/sifcmd.c) +compile_multiple(kernel "${SIFRPC_OBJ}" src/sifrpc.c) +compile_multiple(kernel "${FILEIO_OBJ}" src/fileio.c) +compile_multiple(kernel "${LOADFILE_OBJ}" src/loadfile.c) +compile_multiple(kernel "${IOPHEAP_OBJ}" src/iopheap.c) +compile_multiple(kernel "${IOPCONTROL_OBJ}" src/iopcontrol.c) +compile_multiple(kernel "${GLUE_OBJ}" src/glue.c) +compile_multiple(kernel "${SIO_OBJ}" src/sio.c) +compile_multiple(kernel "${ROM0_OBJ}" src/rom0_info.c) +compile_multiple(kernel "${CONFIG_OBJ}" src/osd_config.c) +compile_multiple(kernel "${LIBOSD_OBJ}" src/libosd.c) +compile_multiple(kernel "${TLBFUNC_OBJ}" src/tlbfunc.c) +compile_multiple(kernel "${ALARM_OBJ}" src/alarm.c) +compile_multiple(kernel "${THREAD_OBJ}" src/thread.c) +compile_multiple(kernel "${SETUP_OBJ}" src/setup.c) +compile_multiple(kernel "${EXIT_OBJ}" src/exit.c) +compile_multiple(kernel "${TIMER_OBJ}" src/timer.c) +compile_multiple(kernel "${TIMER_ALARM_OBJ}" src/timer_alarm.c) +compile_multiple(kernel "${DELAYTHREAD_OBJ}" src/delaythread.c) +compile_multiple(kernel "${GETKERNEL_OBJ}" src/getkernel.c) +compile_multiple(kernel "${INITSYS_OBJ}" src/initsys.c) +compile_multiple(kernel "${KERNEL_UTIL_OBJ}" src/kernel_util.c) +compile_multiple(kernel "${KERNEL_OBJ}" src/kernel.S) +target_sources(kernel PRIVATE src/setup_syscalls.S src/debug.c) + +install(TARGETS kernel) \ No newline at end of file diff --git a/iop/CMakeLists.txt b/iop/CMakeLists.txt new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt new file mode 100644 index 00000000000..5a85e4a956a --- /dev/null +++ b/tools/CMakeLists.txt @@ -0,0 +1,9 @@ +cmake_minimum_required(VERSION 3.10) +project(ps2sdk-tools) + +add_subdirectory(adpenc) +add_subdirectory(bin2c) +add_subdirectory(gensymtab) +add_subdirectory(ps2-irxgen) +add_subdirectory(ps2adpcm) +add_subdirectory(romimg) \ No newline at end of file diff --git a/tools/adpenc/CMakeLists.txt b/tools/adpenc/CMakeLists.txt new file mode 100644 index 00000000000..876635c5f23 --- /dev/null +++ b/tools/adpenc/CMakeLists.txt @@ -0,0 +1,2 @@ +add_executable(adpenc src/adpcm.c src/main.c) +install(TARGETS adpenc) \ No newline at end of file diff --git a/tools/bin2c/CMakeLists.txt b/tools/bin2c/CMakeLists.txt new file mode 100644 index 00000000000..b231c8b7c93 --- /dev/null +++ b/tools/bin2c/CMakeLists.txt @@ -0,0 +1,2 @@ +add_executable(bin2c src/bin2c.c) +install(TARGETS bin2c) \ No newline at end of file diff --git a/tools/gensymtab/CMakeLists.txt b/tools/gensymtab/CMakeLists.txt new file mode 100644 index 00000000000..26a1ee0060d --- /dev/null +++ b/tools/gensymtab/CMakeLists.txt @@ -0,0 +1,2 @@ +add_executable(gensymtab src/main.c) +install(TARGETS gensymtab) \ No newline at end of file diff --git a/tools/ps2-irxgen/CMakeLists.txt b/tools/ps2-irxgen/CMakeLists.txt new file mode 100644 index 00000000000..b082928663e --- /dev/null +++ b/tools/ps2-irxgen/CMakeLists.txt @@ -0,0 +1,2 @@ +add_executable(ps2-irxgen src/ps2-irxgen.c) +install(TARGETS ps2-irxgen) \ No newline at end of file diff --git a/tools/ps2adpcm/CMakeLists.txt b/tools/ps2adpcm/CMakeLists.txt new file mode 100644 index 00000000000..5cbc6a3f559 --- /dev/null +++ b/tools/ps2adpcm/CMakeLists.txt @@ -0,0 +1,2 @@ +add_executable(ps2adpcm src/adpcm.c src/main.c) +install(TARGETS ps2adpcm) \ No newline at end of file diff --git a/tools/romimg/CMakeLists.txt b/tools/romimg/CMakeLists.txt new file mode 100644 index 00000000000..bcda68fb086 --- /dev/null +++ b/tools/romimg/CMakeLists.txt @@ -0,0 +1,2 @@ +add_executable(romimg src/main.c src/platform.c src/romimg.c src/SonyRX.c) +install(TARGETS romimg) \ No newline at end of file From 6a3ec840969dc8ec0cc0d771750be7c1fb40944d Mon Sep 17 00:00:00 2001 From: Ziemas Date: Tue, 1 Oct 2024 21:43:09 +0200 Subject: [PATCH 02/21] Enable and build assembly language --- ee/CMakeLists.txt | 2 +- ee/kernel/CMakeLists.txt | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/ee/CMakeLists.txt b/ee/CMakeLists.txt index e41fd4b74f4..483b0d80889 100644 --- a/ee/CMakeLists.txt +++ b/ee/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.10) -project(ps2sdk-ee) +project(ps2sdk-ee C ASM) add_subdirectory(kernel) \ No newline at end of file diff --git a/ee/kernel/CMakeLists.txt b/ee/kernel/CMakeLists.txt index b027b0d18a1..bd1a28cd3bf 100644 --- a/ee/kernel/CMakeLists.txt +++ b/ee/kernel/CMakeLists.txt @@ -197,11 +197,13 @@ function(compile_multiple target objects srcfile) set_target_properties(${obj} PROPERTIES LINKER_LANGUAGE C) get_filename_component(def ${obj} NAME_WLE) target_compile_definitions(${obj} PUBLIC "F_${def}") + target_include_directories(${obj} PRIVATE include) target_link_libraries(${target} private ${obj}) endforeach() endfunction() add_library(kernel) +target_include_directories(kernel PRIVATE include) compile_multiple(kernel "${SIFCMD_OBJ}" src/sifcmd.c) compile_multiple(kernel "${SIFRPC_OBJ}" src/sifrpc.c) compile_multiple(kernel "${FILEIO_OBJ}" src/fileio.c) From 09fe5e7c0e7a95c594852ef7c42b35e53996654a Mon Sep 17 00:00:00 2001 From: Ziemas Date: Tue, 1 Oct 2024 21:43:45 +0200 Subject: [PATCH 03/21] toolchain files --- cmake/ee_toolchain.cmake | 54 +++++++++++++++++++++++++++++++++++++++ cmake/iop_toolchain.cmake | 53 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 107 insertions(+) create mode 100644 cmake/ee_toolchain.cmake create mode 100644 cmake/iop_toolchain.cmake diff --git a/cmake/ee_toolchain.cmake b/cmake/ee_toolchain.cmake new file mode 100644 index 00000000000..dd41512f749 --- /dev/null +++ b/cmake/ee_toolchain.cmake @@ -0,0 +1,54 @@ +# +# CMake platform file for PS2 EE processor +# +# Copyright (C) 2009-2010 Mathias Lafeldt +# Copyright (C) 2023 Francisco Javier Trujillo Mata +# Copyright (C) 2024 André Guilherme +# Copyright (C) 2024-Present PS2DEV Team +# + +cmake_minimum_required(VERSION 3.10) + +INCLUDE(CMakeForceCompiler) +if(DEFINED ENV{PS2SDK}) + SET(PS2SDK $ENV{PS2SDK}) +else() + message(FATAL_ERROR "The environment variable PS2SDK needs to be defined.") +endif() + +if(DEFINED ENV{PS2DEV}) + SET(PS2DEV $ENV{PS2DEV}) +else() + message(FATAL_ERROR "The environment variable PS2DEV needs to be defined.") +endif() + +SET(CMAKE_SYSTEM_NAME Generic) +SET(CMAKE_SYSTEM_VERSION 1) +SET(CMAKE_SYSTEM_PROCESSOR mips) + +SET(CMAKE_ASM_COMPILER mips64r5900el-ps2-elf-gcc) +SET(CMAKE_C_COMPILER mips64r5900el-ps2-elf-gcc) +SET(CMAKE_CXX_COMPILER mips64r5900el-ps2-elf-g++) + +SET(EE_CFLAGS "-I$ENV{PS2SDK}/ee/include -I$ENV{PS2SDK}/common/include -I$ENV{PS2SDK}/ports/include -D_EE -DPS2 -D__PS2__ -O2 -G0" CACHE STRING "EE C compiler flags" FORCE) +SET(EE_LDFLAGS "-L$ENV{PS2SDK}/ee/lib -L$ENV{PS2DEV}/gsKit/lib -L$ENV{PS2SDK}/ports/lib -Wl,-zmax-page-size=128 -T$ENV{PS2SDK}/ee/startup/linkfile" CACHE STRING "EE linker flags" FORCE) + +SET(CMAKE_TARGET_INSTALL_PREFIX $ENV{PS2DEV}/ports) + +SET(CMAKE_FIND_ROOT_PATH $ENV{PS2DEV} $ENV{PS2DEV}/ee $ENV{PS2DEV}/ee/ee $ENV{PS2SDK} $ENV{PS2SDK}/ports) +SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) +SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) +SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) + +SET_PROPERTY(GLOBAL PROPERTY TARGET_SUPPORTS_SHARED_LIBS TRUE) + +SET(CMAKE_C_FLAGS_INIT ${EE_CFLAGS}) +SET(CMAKE_CXX_FLAGS_INIT ${EE_CFLAGS}) +SET(CMAKE_EXE_LINKER_FLAGS_INIT ${EE_LDFLAGS}) + + +SET(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-nostartfiles -Wl,-r -Wl,-d") + +SET(PS2 TRUE) +SET(PLATFORM_PS2 TRUE) +SET(EE TRUE) diff --git a/cmake/iop_toolchain.cmake b/cmake/iop_toolchain.cmake new file mode 100644 index 00000000000..6791a1c3b1f --- /dev/null +++ b/cmake/iop_toolchain.cmake @@ -0,0 +1,53 @@ +# +# CMake platform file for PS2 EE processor +# +# Copyright (C) 2009-2010 Mathias Lafeldt +# Copyright (C) 2023 Francisco Javier Trujillo Mata +# Copyright (C) 2024 André Guilherme +# Copyright (C) 2024-Present PS2DEV Team +# + +cmake_minimum_required(VERSION 3.0) + +INCLUDE(CMakeForceCompiler) +if(DEFINED ENV{PS2SDK}) + SET(PS2SDK $ENV{PS2SDK}) +else() + message(FATAL_ERROR "The environment variable PS2SDK needs to be defined.") +endif() + +if(DEFINED ENV{PS2DEV}) + SET(PS2DEV $ENV{PS2DEV}) +else() + message(FATAL_ERROR "The environment variable PS2DEV needs to be defined.") +endif() + +SET(CMAKE_SYSTEM_NAME Generic) +SET(CMAKE_SYSTEM_VERSION 1) +SET(CMAKE_SYSTEM_PROCESSOR mips) + +SET(CMAKE_C_COMPILER mips64r5900el-ps2-elf-gcc) +SET(CMAKE_CXX_COMPILER mips64r5900el-ps2-elf-g++) + +SET(EE_CFLAGS "-I$ENV{PS2SDK}/ee/include -I$ENV{PS2SDK}/common/include -I$ENV{PS2SDK}/ports/include -D_EE -DPS2 -D__PS2__ -O2 -G0" CACHE STRING "EE C compiler flags" FORCE) +SET(EE_LDFLAGS "-L$ENV{PS2SDK}/ee/lib -L$ENV{PS2DEV}/gsKit/lib -L$ENV{PS2SDK}/ports/lib -Wl,-zmax-page-size=128 -T$ENV{PS2SDK}/ee/startup/linkfile" CACHE STRING "EE linker flags" FORCE) + +SET(CMAKE_TARGET_INSTALL_PREFIX $ENV{PS2DEV}/ports) + +SET(CMAKE_FIND_ROOT_PATH $ENV{PS2DEV} $ENV{PS2DEV}/ee $ENV{PS2DEV}/ee/ee $ENV{PS2SDK} $ENV{PS2SDK}/ports) +SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) +SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) +SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) + +SET_PROPERTY(GLOBAL PROPERTY TARGET_SUPPORTS_SHARED_LIBS TRUE) + +SET(CMAKE_C_FLAGS_INIT ${EE_CFLAGS}) +SET(CMAKE_CXX_FLAGS_INIT ${EE_CFLAGS}) +SET(CMAKE_EXE_LINKER_FLAGS_INIT ${EE_LDFLAGS}) + + +SET(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-nostartfiles -Wl,-r -Wl,-d") + +SET(PS2 TRUE) +SET(PLATFORM_PS2 TRUE) +SET(EE TRUE) From eaad1fd63e64b0db9a0fab104917359d26a5a868 Mon Sep 17 00:00:00 2001 From: Ziemas Date: Tue, 1 Oct 2024 21:59:11 +0200 Subject: [PATCH 04/21] New utils cmake file, and install kernel headers --- cmake/utils.cmake | 10 ++++++++++ ee/CMakeLists.txt | 2 +- ee/kernel/CMakeLists.txt | 17 +++++------------ 3 files changed, 16 insertions(+), 13 deletions(-) create mode 100644 cmake/utils.cmake diff --git a/cmake/utils.cmake b/cmake/utils.cmake new file mode 100644 index 00000000000..0135dc06dfc --- /dev/null +++ b/cmake/utils.cmake @@ -0,0 +1,10 @@ +function(compile_multiple target objects srcfile) + foreach(obj ${objects}) + add_library(${obj} OBJECT ${srcfile}) + set_target_properties(${obj} PROPERTIES LINKER_LANGUAGE C) + get_filename_component(def ${obj} NAME_WLE) + target_compile_definitions(${obj} PUBLIC "F_${def}") + target_include_directories(${obj} PRIVATE include) + target_link_libraries(${target} private ${obj}) + endforeach() +endfunction() diff --git a/ee/CMakeLists.txt b/ee/CMakeLists.txt index 483b0d80889..80dbd13f8c4 100644 --- a/ee/CMakeLists.txt +++ b/ee/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.10) project(ps2sdk-ee C ASM) - +file(REAL_PATH ../ PS2SDKSRC_ROOT) add_subdirectory(kernel) \ No newline at end of file diff --git a/ee/kernel/CMakeLists.txt b/ee/kernel/CMakeLists.txt index bd1a28cd3bf..91a009adbff 100644 --- a/ee/kernel/CMakeLists.txt +++ b/ee/kernel/CMakeLists.txt @@ -1,4 +1,5 @@ cmake_minimum_required(VERSION 3.10) +include(${PS2SDKSRC_ROOT}/cmake/utils.cmake) set(EXEC_SYSCALLS KExit.o _LoadExecPS2.o _ExecPS2.o) set(EXECOSD_SYSCALL _ExecOSD.o) @@ -191,19 +192,8 @@ set(KERNEL_OBJ ResetEE.o SetGsCrt.o ${EXEC_SYSCALLS} strncpy.o strlen.o memcpy.o memset.o __syscall.o GPfuncs.o _print.o ) -function(compile_multiple target objects srcfile) - foreach(obj ${objects}) - add_library(${obj} OBJECT ${srcfile}) - set_target_properties(${obj} PROPERTIES LINKER_LANGUAGE C) - get_filename_component(def ${obj} NAME_WLE) - target_compile_definitions(${obj} PUBLIC "F_${def}") - target_include_directories(${obj} PRIVATE include) - target_link_libraries(${target} private ${obj}) - endforeach() -endfunction() - add_library(kernel) -target_include_directories(kernel PRIVATE include) +target_include_directories(kernel PUBLIC include) compile_multiple(kernel "${SIFCMD_OBJ}" src/sifcmd.c) compile_multiple(kernel "${SIFRPC_OBJ}" src/sifrpc.c) compile_multiple(kernel "${FILEIO_OBJ}" src/fileio.c) @@ -229,4 +219,7 @@ compile_multiple(kernel "${KERNEL_UTIL_OBJ}" src/kernel_util.c) compile_multiple(kernel "${KERNEL_OBJ}" src/kernel.S) target_sources(kernel PRIVATE src/setup_syscalls.S src/debug.c) +file(GLOB KERNEL_INCLUDE_FILES "include/*.h*") +set_target_properties(kernel PROPERTIES PUBLIC_HEADER "${KERNEL_INCLUDE_FILES}") + install(TARGETS kernel) \ No newline at end of file From ce0c64522db8431d019a558327ddab0c98899288 Mon Sep 17 00:00:00 2001 From: Ziemas Date: Tue, 1 Oct 2024 22:01:23 +0200 Subject: [PATCH 05/21] This wasn't necessary after all --- cmake/utils.cmake | 1 - 1 file changed, 1 deletion(-) diff --git a/cmake/utils.cmake b/cmake/utils.cmake index 0135dc06dfc..db079029b8b 100644 --- a/cmake/utils.cmake +++ b/cmake/utils.cmake @@ -1,7 +1,6 @@ function(compile_multiple target objects srcfile) foreach(obj ${objects}) add_library(${obj} OBJECT ${srcfile}) - set_target_properties(${obj} PROPERTIES LINKER_LANGUAGE C) get_filename_component(def ${obj} NAME_WLE) target_compile_definitions(${obj} PUBLIC "F_${def}") target_include_directories(${obj} PRIVATE include) From e52aab3cf64978bd33249672bce845bc8e9c33e0 Mon Sep 17 00:00:00 2001 From: Ziemas Date: Tue, 1 Oct 2024 22:10:22 +0200 Subject: [PATCH 06/21] build debug library --- ee/debug/CMakeLists.txt | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 ee/debug/CMakeLists.txt diff --git a/ee/debug/CMakeLists.txt b/ee/debug/CMakeLists.txt new file mode 100644 index 00000000000..b65d1909383 --- /dev/null +++ b/ee/debug/CMakeLists.txt @@ -0,0 +1,17 @@ +add_library(debug) +target_include_directories(debug PRIVATE ${PS2SDKSRC_ROOT}/common/include) +target_sources(debug PRIVATE + src/callstack.c + src/callstackget.S + src/erl-support.c + src/font.c + src/hwbp.S + src/scr_printf.c + src/screenshot.c +) + +file(GLOB DEBUG_INCLUDE_FILES "include/*.h*") +set_target_properties(debug PROPERTIES PUBLIC_HEADER "${DEBUG_INCLUDE_FILES}") +target_link_libraries(kernel) + +install(TARGETS debug) From f5b0d72b8a83aece9b97b2a65193a916fc16911e Mon Sep 17 00:00:00 2001 From: Ziemas Date: Wed, 2 Oct 2024 06:28:17 +0200 Subject: [PATCH 07/21] Avoid separate list var for compile_multiple --- cmake/utils.cmake | 8 +-- ee/CMakeLists.txt | 3 +- ee/kernel/CMakeLists.txt | 107 ++++++++++++++++++--------------------- 3 files changed, 56 insertions(+), 62 deletions(-) diff --git a/cmake/utils.cmake b/cmake/utils.cmake index db079029b8b..4406f9c8eaf 100644 --- a/cmake/utils.cmake +++ b/cmake/utils.cmake @@ -1,8 +1,10 @@ -function(compile_multiple target objects srcfile) - foreach(obj ${objects}) +function(compile_multiple target srcfile) + cmake_parse_arguments(PARSE_ARGV 2 "arg" "" "" "OBJECTS") + + foreach(obj ${arg_OBJECTS}) add_library(${obj} OBJECT ${srcfile}) get_filename_component(def ${obj} NAME_WLE) - target_compile_definitions(${obj} PUBLIC "F_${def}") + target_compile_definitions(${obj} PRIVATE "F_${def}") target_include_directories(${obj} PRIVATE include) target_link_libraries(${target} private ${obj}) endforeach() diff --git a/ee/CMakeLists.txt b/ee/CMakeLists.txt index 80dbd13f8c4..6a9f6ce5043 100644 --- a/ee/CMakeLists.txt +++ b/ee/CMakeLists.txt @@ -2,4 +2,5 @@ cmake_minimum_required(VERSION 3.10) project(ps2sdk-ee C ASM) file(REAL_PATH ../ PS2SDKSRC_ROOT) -add_subdirectory(kernel) \ No newline at end of file +add_subdirectory(kernel) +add_subdirectory(debug) \ No newline at end of file diff --git a/ee/kernel/CMakeLists.txt b/ee/kernel/CMakeLists.txt index 91a009adbff..f4dd9f17351 100644 --- a/ee/kernel/CMakeLists.txt +++ b/ee/kernel/CMakeLists.txt @@ -1,28 +1,23 @@ cmake_minimum_required(VERSION 3.10) + include(${PS2SDKSRC_ROOT}/cmake/utils.cmake) -set(EXEC_SYSCALLS KExit.o _LoadExecPS2.o _ExecPS2.o) -set(EXECOSD_SYSCALL _ExecOSD.o) -set(ALARM_SYSCALLS _SetAlarm.o SetAlarm.o _ReleaseAlarm.o ReleaseAlarm.o) -set(ALARM_INTR_SYSCALLS _iSetAlarm.o iSetAlarm.o _iReleaseAlarm.o iReleaseAlarm.o) -set(ROTATE_THREAD_READY_QUEUE_SYSCALL _iRotateThreadReadyQueue.o) -set(IWAKEUP_THREAD_SYSCALL _iWakeupThread.o) -set(ISUSPEND_THREAD_SYSCALL _iSuspendThread.o) -set(TLB_SYSCALLS PutTLBEntry.o iPutTLBEntry.o _SetTLBEntry.o iSetTLBEntry.o GetTLBEntry.o iGetTLBEntry.o ProbeTLBEntry.o iProbeTLBEntry.o ExpandScratchPad.o) +add_library(kernel) -set(SIFCMD_OBJ +compile_multiple(kernel src/sifcmd.c OBJECTS sif_cmd_send.o _sif_cmd_int_handler.o sif_cmd_main.o sif_cmd_client.o sif_cmd_remove_cmdhandler.o sif_sreg_get.o ) -set(SIFRPC_OBJ +compile_multiple(kernel src/sifrpc.c OBJECTS SifBindRpc.o SifCallRpc.o SifRpcGetOtherData.o SifRegisterRpc.o SifRemoveRpc.o SifSetRpcQueue.o SifRemoveRpcQueue.o SifGetNextRequest.o SifExecRequest.o SifRpcLoop.o SifRpcMain.o _rpc_get_packet.o _rpc_get_fpacket.o SifCheckStatRpc.o ) -set(FILEIO_OBJ + +compile_multiple(kernel src/fileio.c OBJECTS __fio_internals.o fio_init.o _fio_intr.o fio_sync.o fio_setblockmode.o fio_exit.o fio_open.o fio_close.o fio_read.o fio_write.o fio_lseek.o fio_mkdir.o _fio_read_intr.o fio_getc.o fio_putc.o @@ -30,7 +25,7 @@ set(FILEIO_OBJ fio_remove.o fio_format.o fio_rmdir.o fio_gets.o ) -set(LOADFILE_OBJ +compile_multiple(kernel src/loadfile.c OBJECTS SifLoadFileInit.o SifLoadFileExit.o _SifLoadModule.o SifLoadModule.o SifLoadStartModule.o SifLoadModuleEncrypted.o SifStopModule.o SifUnloadModule.o SifSearchModuleByName.o SifSearchModuleByAddress.o _SifLoadElfPart.o SifLoadElfPart.o @@ -39,31 +34,35 @@ set(LOADFILE_OBJ SifExecModuleBuffer.o SifExecModuleFile.o ) -set(IOPHEAP_OBJ + +compile_multiple(kernel src/iopheap.c OBJECTS SifInitIopHeap.o SifExitIopHeap.o SifAllocIopHeap.o SifFreeIopHeap.o SifLoadIopHeap.o ) -set(IOPCONTROL_OBJ +compile_multiple(kernel src/iopcontrol.c OBJECTS SifIopReboot.o SifIopReset.o SifIopIsAlive.o SifIopSync.o __iop_control_internals.o ) -set(GLUE_OBJ + +compile_multiple(kernel src/glue.c OBJECTS DIntr.o EIntr.o EnableIntc.o DisableIntc.o EnableDmac.o DisableDmac.o iEnableIntc.o iDisableIntc.o iEnableDmac.o iDisableDmac.o SyncDCache.o iSyncDCache.o InvalidDCache.o iInvalidDCache.o ) -set(SIO_OBJ + +compile_multiple(kernel src/sio.c OBJECTS sio_init.o sio_putc.o sio_getc.o sio_write.o sio_read.o sio_puts.o sio_gets.o sio_getc_block.o sio_flush.o sio_putsn.o ) -set(ROM0_OBJ + +compile_multiple(kernel src/rom0_info.c OBJECTS _info_internals.o GetRomNameWithIODriver.o GetRomName.o IsDESRMachineWithIODriver.o IsDESRMachine.o IsT10KWithIODriver.o IsT10K.0 ) -set(CONFIG_OBJ +compile_multiple(kernel src/osd_config.c OBJECTS _config_internals.o converttobcd.o convertfrombcd.o __adjustTime.o IsEarlyJap.o configGetLanguageWithIODriver.o configGetLanguage.o configSetLanguageWithIODriver.o configSetLanguage.o @@ -83,21 +82,29 @@ set(CONFIG_OBJ ) # bin2c osdsrc_bin.o -set(LIBOSD_OBJ libosd.o libosd_full.o libosd_common.o) + +compile_multiple(kernel src/libosd.c OBJECTS + libosd.o libosd_full.o libosd_common.o +) + # bin2c tlbsrc_bin.o -set(TLBFUNC_OBJ tlbfunc.o) +compile_multiple(kernel src/tlbfunc.c OBJECTS tlbfunc.o) # bin2c srcfile_bin.o, eenull_bin.o -set(ALARM_OBJ alarm.o) +compile_multiple(kernel src/alarm.c OBJECTS alarm.o) + +compile_multiple(kernel src/thread.c OBJECTS + _thread_internals.o iWakeupThread.o iRotateThreadReadyQueue.o iSuspendThread.o) + -set(THREAD_OBJ _thread_internals.o iWakeupThread.o iRotateThreadReadyQueue.o iSuspendThread.o) +compile_multiple(kernel src/setup.c OBJECTS kCopy.o kCopyBytes.o) -set(SETUP_OBJ kCopy.o kCopyBytes.o) +compile_multiple(kernel src/exit.c OBJECTS + _exit_internals.o SetArg.o Exit.o ExecPS2.o LoadExecPS2.o ExecOSD.o) -set(EXIT_OBJ _exit_internals.o SetArg.o Exit.o ExecPS2.o LoadExecPS2.o ExecOSD.o) -set(TIMER_OBJ +compile_multiple(kernel src/timer.c OBJECTS timer_data.o SetT2.o SetT2_COUNT.o @@ -138,7 +145,7 @@ set(TIMER_OBJ cpu_ticks.o ) -set(TIMER_ALARM_OBJ +compile_multiple(kernel src/timer_alarm.c OBJECTS alarm_data.o ForTimer_InitAlarm.o AlarmHandler.o @@ -148,17 +155,26 @@ set(TIMER_ALARM_OBJ ReleaseTimerAlarm.o ) -set(DELAYTHREAD_OBJ - DelayThread.o -) +compile_multiple(kernel src/delaythread.c OBJECTS DelayThread.o) -set(GETKERNEL_OBJ GetSyscallHandler.o GetSyscall.o GetExceptionHandler.o GetInterruptHandler.o) +compile_multiple(kernel src/getkernel.c OBJECTS + GetSyscallHandler.o GetSyscall.o GetExceptionHandler.o GetInterruptHandler.o) -set(INITSYS_OBJ _InitSys.o TerminateLibrary.o) +compile_multiple(kernel src/initsys.c OBJECTS _InitSys.o TerminateLibrary.o) -set(KERNEL_UTIL_OBJS WaitSemaEx.o) +compile_multiple(kernel src/kernel_util.c OBJECTS WaitSemaEx.o) -set(KERNEL_OBJ ResetEE.o SetGsCrt.o ${EXEC_SYSCALLS} +set(EXEC_SYSCALLS KExit.o _LoadExecPS2.o _ExecPS2.o) +set(EXECOSD_SYSCALL _ExecOSD.o) +set(ALARM_SYSCALLS _SetAlarm.o SetAlarm.o _ReleaseAlarm.o ReleaseAlarm.o) +set(ALARM_INTR_SYSCALLS _iSetAlarm.o iSetAlarm.o _iReleaseAlarm.o iReleaseAlarm.o) +set(ROTATE_THREAD_READY_QUEUE_SYSCALL _iRotateThreadReadyQueue.o) +set(IWAKEUP_THREAD_SYSCALL _iWakeupThread.o) +set(ISUSPEND_THREAD_SYSCALL _iSuspendThread.o) +set(TLB_SYSCALLS PutTLBEntry.o iPutTLBEntry.o _SetTLBEntry.o iSetTLBEntry.o GetTLBEntry.o iGetTLBEntry.o ProbeTLBEntry.o iProbeTLBEntry.o ExpandScratchPad.o) + +compile_multiple(kernel src/kernel.S OBJECTS + ResetEE.o SetGsCrt.o ${EXEC_SYSCALLS} RFU009.o AddSbusIntcHandler.o RemoveSbusIntcHandler.o Interrupt2Iop.o SetVTLBRefillHandler.o SetVCommonHandler.o SetVInterruptHandler.o AddIntcHandler.o AddIntcHandler2.o RemoveIntcHandler.o AddDmacHandler.o AddDmacHandler2.o @@ -192,31 +208,6 @@ set(KERNEL_OBJ ResetEE.o SetGsCrt.o ${EXEC_SYSCALLS} strncpy.o strlen.o memcpy.o memset.o __syscall.o GPfuncs.o _print.o ) -add_library(kernel) -target_include_directories(kernel PUBLIC include) -compile_multiple(kernel "${SIFCMD_OBJ}" src/sifcmd.c) -compile_multiple(kernel "${SIFRPC_OBJ}" src/sifrpc.c) -compile_multiple(kernel "${FILEIO_OBJ}" src/fileio.c) -compile_multiple(kernel "${LOADFILE_OBJ}" src/loadfile.c) -compile_multiple(kernel "${IOPHEAP_OBJ}" src/iopheap.c) -compile_multiple(kernel "${IOPCONTROL_OBJ}" src/iopcontrol.c) -compile_multiple(kernel "${GLUE_OBJ}" src/glue.c) -compile_multiple(kernel "${SIO_OBJ}" src/sio.c) -compile_multiple(kernel "${ROM0_OBJ}" src/rom0_info.c) -compile_multiple(kernel "${CONFIG_OBJ}" src/osd_config.c) -compile_multiple(kernel "${LIBOSD_OBJ}" src/libosd.c) -compile_multiple(kernel "${TLBFUNC_OBJ}" src/tlbfunc.c) -compile_multiple(kernel "${ALARM_OBJ}" src/alarm.c) -compile_multiple(kernel "${THREAD_OBJ}" src/thread.c) -compile_multiple(kernel "${SETUP_OBJ}" src/setup.c) -compile_multiple(kernel "${EXIT_OBJ}" src/exit.c) -compile_multiple(kernel "${TIMER_OBJ}" src/timer.c) -compile_multiple(kernel "${TIMER_ALARM_OBJ}" src/timer_alarm.c) -compile_multiple(kernel "${DELAYTHREAD_OBJ}" src/delaythread.c) -compile_multiple(kernel "${GETKERNEL_OBJ}" src/getkernel.c) -compile_multiple(kernel "${INITSYS_OBJ}" src/initsys.c) -compile_multiple(kernel "${KERNEL_UTIL_OBJ}" src/kernel_util.c) -compile_multiple(kernel "${KERNEL_OBJ}" src/kernel.S) target_sources(kernel PRIVATE src/setup_syscalls.S src/debug.c) file(GLOB KERNEL_INCLUDE_FILES "include/*.h*") From ddd31a6f3b4a4ab34ba5a4ac24ca343186faa61d Mon Sep 17 00:00:00 2001 From: Ziemas Date: Wed, 2 Oct 2024 10:12:54 +0200 Subject: [PATCH 08/21] Don't use installed header files from outside the repo --- cmake/ee_toolchain.cmake | 11 ++++------- cmake/utils.cmake | 3 ++- ee/CMakeLists.txt | 2 ++ ee/debug/CMakeLists.txt | 6 +++--- ee/kernel/CMakeLists.txt | 32 +++++++++++++++++++------------- 5 files changed, 30 insertions(+), 24 deletions(-) diff --git a/cmake/ee_toolchain.cmake b/cmake/ee_toolchain.cmake index dd41512f749..b3fa194a3e4 100644 --- a/cmake/ee_toolchain.cmake +++ b/cmake/ee_toolchain.cmake @@ -30,15 +30,12 @@ SET(CMAKE_ASM_COMPILER mips64r5900el-ps2-elf-gcc) SET(CMAKE_C_COMPILER mips64r5900el-ps2-elf-gcc) SET(CMAKE_CXX_COMPILER mips64r5900el-ps2-elf-g++) -SET(EE_CFLAGS "-I$ENV{PS2SDK}/ee/include -I$ENV{PS2SDK}/common/include -I$ENV{PS2SDK}/ports/include -D_EE -DPS2 -D__PS2__ -O2 -G0" CACHE STRING "EE C compiler flags" FORCE) -SET(EE_LDFLAGS "-L$ENV{PS2SDK}/ee/lib -L$ENV{PS2DEV}/gsKit/lib -L$ENV{PS2SDK}/ports/lib -Wl,-zmax-page-size=128 -T$ENV{PS2SDK}/ee/startup/linkfile" CACHE STRING "EE linker flags" FORCE) +find_program(CMAKE_OBJCOPY mips64r5900el-ps2-elf-objcopy) -SET(CMAKE_TARGET_INSTALL_PREFIX $ENV{PS2DEV}/ports) +SET(EE_CFLAGS "-D_EE -DPS2 -D__PS2__ -O2 -G0" CACHE STRING "EE C compiler flags" FORCE) +SET(EE_LDFLAGS "-Wl,-zmax-page-size=128 -T$ENV{PS2SDK}/ee/startup/linkfile" CACHE STRING "EE linker flags" FORCE) -SET(CMAKE_FIND_ROOT_PATH $ENV{PS2DEV} $ENV{PS2DEV}/ee $ENV{PS2DEV}/ee/ee $ENV{PS2SDK} $ENV{PS2SDK}/ports) -SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) -SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) -SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) +SET(CMAKE_TARGET_INSTALL_PREFIX $ENV{PS2DEV}/ports) SET_PROPERTY(GLOBAL PROPERTY TARGET_SUPPORTS_SHARED_LIBS TRUE) diff --git a/cmake/utils.cmake b/cmake/utils.cmake index 4406f9c8eaf..e1c630cc299 100644 --- a/cmake/utils.cmake +++ b/cmake/utils.cmake @@ -5,7 +5,8 @@ function(compile_multiple target srcfile) add_library(${obj} OBJECT ${srcfile}) get_filename_component(def ${obj} NAME_WLE) target_compile_definitions(${obj} PRIVATE "F_${def}") - target_include_directories(${obj} PRIVATE include) + target_include_directories(${obj} PRIVATE ${EE_INC}) target_link_libraries(${target} private ${obj}) endforeach() endfunction() + diff --git a/ee/CMakeLists.txt b/ee/CMakeLists.txt index 6a9f6ce5043..f7d9d891eb3 100644 --- a/ee/CMakeLists.txt +++ b/ee/CMakeLists.txt @@ -2,5 +2,7 @@ cmake_minimum_required(VERSION 3.10) project(ps2sdk-ee C ASM) file(REAL_PATH ../ PS2SDKSRC_ROOT) +set(EE_INC ${PS2SDKSRC_ROOT}/common/include ${PROJECT_SOURCE_DIR}/kernel/include ${PROJECT_SOURCE_DIR}/rpc/cdvd/include) + add_subdirectory(kernel) add_subdirectory(debug) \ No newline at end of file diff --git a/ee/debug/CMakeLists.txt b/ee/debug/CMakeLists.txt index b65d1909383..71c1e3058ed 100644 --- a/ee/debug/CMakeLists.txt +++ b/ee/debug/CMakeLists.txt @@ -1,17 +1,17 @@ add_library(debug) +target_include_directories(debug PUBLIC include) target_include_directories(debug PRIVATE ${PS2SDKSRC_ROOT}/common/include) +target_link_libraries(debug PRIVATE kernel) target_sources(debug PRIVATE src/callstack.c src/callstackget.S - src/erl-support.c + #src/erl-support.c TODO src/font.c src/hwbp.S src/scr_printf.c src/screenshot.c ) - file(GLOB DEBUG_INCLUDE_FILES "include/*.h*") set_target_properties(debug PROPERTIES PUBLIC_HEADER "${DEBUG_INCLUDE_FILES}") -target_link_libraries(kernel) install(TARGETS debug) diff --git a/ee/kernel/CMakeLists.txt b/ee/kernel/CMakeLists.txt index f4dd9f17351..d9fe47db91a 100644 --- a/ee/kernel/CMakeLists.txt +++ b/ee/kernel/CMakeLists.txt @@ -2,7 +2,11 @@ cmake_minimum_required(VERSION 3.10) include(${PS2SDKSRC_ROOT}/cmake/utils.cmake) +add_subdirectory(src/eenull) +#add_subdirectory(src/osdsrc) + add_library(kernel) +target_include_directories(kernel PUBLIC include) compile_multiple(kernel src/sifcmd.c OBJECTS sif_cmd_send.o _sif_cmd_int_handler.o sif_cmd_main.o @@ -16,7 +20,6 @@ compile_multiple(kernel src/sifrpc.c OBJECTS _rpc_get_fpacket.o SifCheckStatRpc.o ) - compile_multiple(kernel src/fileio.c OBJECTS __fio_internals.o fio_init.o _fio_intr.o fio_sync.o fio_setblockmode.o fio_exit.o fio_open.o fio_close.o fio_read.o @@ -34,7 +37,6 @@ compile_multiple(kernel src/loadfile.c OBJECTS SifExecModuleBuffer.o SifExecModuleFile.o ) - compile_multiple(kernel src/iopheap.c OBJECTS SifInitIopHeap.o SifExitIopHeap.o SifAllocIopHeap.o SifFreeIopHeap.o SifLoadIopHeap.o @@ -44,20 +46,17 @@ compile_multiple(kernel src/iopcontrol.c OBJECTS SifIopReboot.o SifIopReset.o SifIopIsAlive.o SifIopSync.o __iop_control_internals.o ) - compile_multiple(kernel src/glue.c OBJECTS DIntr.o EIntr.o EnableIntc.o DisableIntc.o EnableDmac.o DisableDmac.o iEnableIntc.o iDisableIntc.o iEnableDmac.o iDisableDmac.o SyncDCache.o iSyncDCache.o InvalidDCache.o iInvalidDCache.o ) - compile_multiple(kernel src/sio.c OBJECTS sio_init.o sio_putc.o sio_getc.o sio_write.o sio_read.o sio_puts.o sio_gets.o sio_getc_block.o sio_flush.o sio_putsn.o ) - compile_multiple(kernel src/rom0_info.c OBJECTS _info_internals.o GetRomNameWithIODriver.o GetRomName.o IsDESRMachineWithIODriver.o IsDESRMachine.o IsT10KWithIODriver.o IsT10K.0 ) @@ -81,29 +80,34 @@ compile_multiple(kernel src/osd_config.c OBJECTS configConvertToGmtTime.o configConvertToLocalTimeWithIODriver.o configConvertToLocalTime.o ) -# bin2c osdsrc_bin.o - -compile_multiple(kernel src/libosd.c OBJECTS - libosd.o libosd_full.o libosd_common.o +macro(bin_include from_target output_name) +add_custom_command(OUTPUT "${output_name}.c" + COMMAND ${CMAKE_OBJCOPY} -Obinary $ "${output_name}.bin" + COMMAND bin2c "${output_name}.bin" "${output_name}.c" eenull + BYPRODUCTS "${output_name}.bin" + DEPENDS ${from_target} ) +endmacro() +# bin2c osdsrc_bin.o +#bin_include(osdsrc osdsrc_bin) +target_sources(kernel PRIVATE src/libosd.c src/libosd_full.c src/libosd_common.c) # bin2c tlbsrc_bin.o -compile_multiple(kernel src/tlbfunc.c OBJECTS tlbfunc.o) +target_sources(kernel PRIVATE src/tlbfunc.c) # bin2c srcfile_bin.o, eenull_bin.o -compile_multiple(kernel src/alarm.c OBJECTS alarm.o) +bin_include(eenull eenull_bin) +target_sources(kernel PRIVATE src/alarm.c eenull_bin.c) compile_multiple(kernel src/thread.c OBJECTS _thread_internals.o iWakeupThread.o iRotateThreadReadyQueue.o iSuspendThread.o) - compile_multiple(kernel src/setup.c OBJECTS kCopy.o kCopyBytes.o) compile_multiple(kernel src/exit.c OBJECTS _exit_internals.o SetArg.o Exit.o ExecPS2.o LoadExecPS2.o ExecOSD.o) - compile_multiple(kernel src/timer.c OBJECTS timer_data.o SetT2.o @@ -164,6 +168,7 @@ compile_multiple(kernel src/initsys.c OBJECTS _InitSys.o TerminateLibrary.o) compile_multiple(kernel src/kernel_util.c OBJECTS WaitSemaEx.o) +# IDK why these were on their own in the makefile, keep it for now set(EXEC_SYSCALLS KExit.o _LoadExecPS2.o _ExecPS2.o) set(EXECOSD_SYSCALL _ExecOSD.o) set(ALARM_SYSCALLS _SetAlarm.o SetAlarm.o _ReleaseAlarm.o ReleaseAlarm.o) @@ -208,6 +213,7 @@ compile_multiple(kernel src/kernel.S OBJECTS strncpy.o strlen.o memcpy.o memset.o __syscall.o GPfuncs.o _print.o ) +target_include_directories(kernel PRIVATE ${EE_INC}) target_sources(kernel PRIVATE src/setup_syscalls.S src/debug.c) file(GLOB KERNEL_INCLUDE_FILES "include/*.h*") From e61f391b7cab2d8496deef39b6fadd2d2eb26dd1 Mon Sep 17 00:00:00 2001 From: Ziemas Date: Thu, 3 Oct 2024 07:23:48 +0200 Subject: [PATCH 09/21] Build libkernel binary includes --- cmake/ee_toolchain.cmake | 4 ++-- cmake/utils.cmake | 8 ++++++-- ee/kernel/CMakeLists.txt | 23 +++++++++++++---------- ee/kernel/src/eenull/CMakeLists.txt | 4 ++++ ee/kernel/src/osdsrc/CMakeLists.txt | 7 +++++++ ee/kernel/src/srcfile/CMakeLists.txt | 5 +++++ ee/kernel/src/tlbsrc/CMakeLists.txt | 5 +++++ 7 files changed, 42 insertions(+), 14 deletions(-) create mode 100644 ee/kernel/src/eenull/CMakeLists.txt create mode 100644 ee/kernel/src/osdsrc/CMakeLists.txt create mode 100644 ee/kernel/src/srcfile/CMakeLists.txt create mode 100644 ee/kernel/src/tlbsrc/CMakeLists.txt diff --git a/cmake/ee_toolchain.cmake b/cmake/ee_toolchain.cmake index b3fa194a3e4..a165bf7ee1f 100644 --- a/cmake/ee_toolchain.cmake +++ b/cmake/ee_toolchain.cmake @@ -32,8 +32,8 @@ SET(CMAKE_CXX_COMPILER mips64r5900el-ps2-elf-g++) find_program(CMAKE_OBJCOPY mips64r5900el-ps2-elf-objcopy) -SET(EE_CFLAGS "-D_EE -DPS2 -D__PS2__ -O2 -G0" CACHE STRING "EE C compiler flags" FORCE) -SET(EE_LDFLAGS "-Wl,-zmax-page-size=128 -T$ENV{PS2SDK}/ee/startup/linkfile" CACHE STRING "EE linker flags" FORCE) +SET(EE_CFLAGS "-D_EE -G0 -O2 -Wall -Werror -gdwarf-2 -gz" CACHE STRING "EE C compiler flags" FORCE) +SET(EE_LDFLAGS "-Wl,-zmax-page-size=128" CACHE STRING "EE linker flags" FORCE) SET(CMAKE_TARGET_INSTALL_PREFIX $ENV{PS2DEV}/ports) diff --git a/cmake/utils.cmake b/cmake/utils.cmake index e1c630cc299..0faebf3e159 100644 --- a/cmake/utils.cmake +++ b/cmake/utils.cmake @@ -1,3 +1,4 @@ +# Compiles the same source file multiple times with different defines function(compile_multiple target srcfile) cmake_parse_arguments(PARSE_ARGV 2 "arg" "" "" "OBJECTS") @@ -5,8 +6,11 @@ function(compile_multiple target srcfile) add_library(${obj} OBJECT ${srcfile}) get_filename_component(def ${obj} NAME_WLE) target_compile_definitions(${obj} PRIVATE "F_${def}") - target_include_directories(${obj} PRIVATE ${EE_INC}) - target_link_libraries(${target} private ${obj}) + + get_target_property(target_id ${target} INCLUDE_DIRECTORIES) + target_include_directories(${obj} PRIVATE ${target_id}) + + target_link_libraries(${target} PRIVATE ${obj}) endforeach() endfunction() diff --git a/ee/kernel/CMakeLists.txt b/ee/kernel/CMakeLists.txt index d9fe47db91a..17d13964fba 100644 --- a/ee/kernel/CMakeLists.txt +++ b/ee/kernel/CMakeLists.txt @@ -3,10 +3,13 @@ cmake_minimum_required(VERSION 3.10) include(${PS2SDKSRC_ROOT}/cmake/utils.cmake) add_subdirectory(src/eenull) -#add_subdirectory(src/osdsrc) +add_subdirectory(src/osdsrc) +add_subdirectory(src/srcfile) +add_subdirectory(src/tlbsrc) add_library(kernel) target_include_directories(kernel PUBLIC include) +target_include_directories(kernel PRIVATE ${EE_INC}) compile_multiple(kernel src/sifcmd.c OBJECTS sif_cmd_send.o _sif_cmd_int_handler.o sif_cmd_main.o @@ -80,25 +83,26 @@ compile_multiple(kernel src/osd_config.c OBJECTS configConvertToGmtTime.o configConvertToLocalTimeWithIODriver.o configConvertToLocalTime.o ) +# Generates a C array of the binary output of a target +# objcopy -Obinary && bin2c macro(bin_include from_target output_name) add_custom_command(OUTPUT "${output_name}.c" COMMAND ${CMAKE_OBJCOPY} -Obinary $ "${output_name}.bin" - COMMAND bin2c "${output_name}.bin" "${output_name}.c" eenull + COMMAND bin2c "${output_name}.bin" "${output_name}.c" "${from_target}" BYPRODUCTS "${output_name}.bin" DEPENDS ${from_target} ) endmacro() -# bin2c osdsrc_bin.o -#bin_include(osdsrc osdsrc_bin) -target_sources(kernel PRIVATE src/libosd.c src/libosd_full.c src/libosd_common.c) +bin_include(osdsrc osdsrc_bin) +target_sources(kernel PRIVATE src/libosd.c src/libosd_full.c src/libosd_common.c osdsrc_bin.c) -# bin2c tlbsrc_bin.o -target_sources(kernel PRIVATE src/tlbfunc.c) +bin_include(tlbsrc tlbsrc_bin) +target_sources(kernel PRIVATE src/tlbfunc.c tlbsrc_bin.c) -# bin2c srcfile_bin.o, eenull_bin.o bin_include(eenull eenull_bin) -target_sources(kernel PRIVATE src/alarm.c eenull_bin.c) +bin_include(srcfile srcfile_bin) +target_sources(kernel PRIVATE src/alarm.c srcfile_bin.c) compile_multiple(kernel src/thread.c OBJECTS _thread_internals.o iWakeupThread.o iRotateThreadReadyQueue.o iSuspendThread.o) @@ -213,7 +217,6 @@ compile_multiple(kernel src/kernel.S OBJECTS strncpy.o strlen.o memcpy.o memset.o __syscall.o GPfuncs.o _print.o ) -target_include_directories(kernel PRIVATE ${EE_INC}) target_sources(kernel PRIVATE src/setup_syscalls.S src/debug.c) file(GLOB KERNEL_INCLUDE_FILES "include/*.h*") diff --git a/ee/kernel/src/eenull/CMakeLists.txt b/ee/kernel/src/eenull/CMakeLists.txt new file mode 100644 index 00000000000..44ae69d24f7 --- /dev/null +++ b/ee/kernel/src/eenull/CMakeLists.txt @@ -0,0 +1,4 @@ +add_executable(eenull) +target_sources(eenull PRIVATE src/eenull.s) +target_compile_options(eenull PRIVATE -mno-gpopt) +target_link_options(eenull PRIVATE -nostdlib -nostartfiles -T${CMAKE_CURRENT_SOURCE_DIR}/linkfile -s) \ No newline at end of file diff --git a/ee/kernel/src/osdsrc/CMakeLists.txt b/ee/kernel/src/osdsrc/CMakeLists.txt new file mode 100644 index 00000000000..164832e1dd4 --- /dev/null +++ b/ee/kernel/src/osdsrc/CMakeLists.txt @@ -0,0 +1,7 @@ +add_executable(osdsrc) + +target_sources(osdsrc PRIVATE src/ExecPS2.c src/osd.c src/osdsrc.c) +target_compile_definitions(osdsrc PRIVATE -DREUSE_EXECPS2) +target_compile_options(osdsrc PRIVATE -fno-tree-loop-distribute-patterns -mno-gpopt) +target_include_directories(osdsrc PRIVATE ${EE_INC}) +target_link_options(osdsrc PRIVATE -nostdlib -nostartfiles -T${CMAKE_CURRENT_SOURCE_DIR}/linkfile -s) \ No newline at end of file diff --git a/ee/kernel/src/srcfile/CMakeLists.txt b/ee/kernel/src/srcfile/CMakeLists.txt new file mode 100644 index 00000000000..269f5b32513 --- /dev/null +++ b/ee/kernel/src/srcfile/CMakeLists.txt @@ -0,0 +1,5 @@ +add_executable(srcfile) +target_sources(srcfile PRIVATE src/srcfile.c src/alarm.c src/dispatch.s) +target_compile_options(srcfile PRIVATE -mno-gpopt -fno-tree-loop-distribute-patterns) +target_include_directories(srcfile PRIVATE ${EE_INC}) +target_link_options(srcfile PRIVATE -nostdlib -nostartfiles -T${CMAKE_CURRENT_SOURCE_DIR}/linkfile -s) \ No newline at end of file diff --git a/ee/kernel/src/tlbsrc/CMakeLists.txt b/ee/kernel/src/tlbsrc/CMakeLists.txt new file mode 100644 index 00000000000..451f041040f --- /dev/null +++ b/ee/kernel/src/tlbsrc/CMakeLists.txt @@ -0,0 +1,5 @@ +add_executable(tlbsrc) +target_sources(tlbsrc PRIVATE src/tlbsrc.c) +target_compile_options(tlbsrc PRIVATE -mno-gpopt) +target_include_directories(tlbsrc PRIVATE ${EE_INC}) +target_link_options(tlbsrc PRIVATE -nostdlib -nostartfiles -T${CMAKE_CURRENT_SOURCE_DIR}/linkfile -s) \ No newline at end of file From 36661d921cfeef4ac5aeccd3c3c7ad80c1ca7cdc Mon Sep 17 00:00:00 2001 From: Ziemas Date: Thu, 3 Oct 2024 07:42:38 +0200 Subject: [PATCH 10/21] cmake: build libcglue --- cmake/ee_toolchain.cmake | 12 +-- ee/CMakeLists.txt | 1 + ee/libcglue/CMakeLists.txt | 207 +++++++++++++++++++++++++++++++++++++ 3 files changed, 209 insertions(+), 11 deletions(-) create mode 100644 ee/libcglue/CMakeLists.txt diff --git a/cmake/ee_toolchain.cmake b/cmake/ee_toolchain.cmake index a165bf7ee1f..d219de4ad88 100644 --- a/cmake/ee_toolchain.cmake +++ b/cmake/ee_toolchain.cmake @@ -10,17 +10,7 @@ cmake_minimum_required(VERSION 3.10) INCLUDE(CMakeForceCompiler) -if(DEFINED ENV{PS2SDK}) - SET(PS2SDK $ENV{PS2SDK}) -else() - message(FATAL_ERROR "The environment variable PS2SDK needs to be defined.") -endif() - -if(DEFINED ENV{PS2DEV}) - SET(PS2DEV $ENV{PS2DEV}) -else() - message(FATAL_ERROR "The environment variable PS2DEV needs to be defined.") -endif() + SET(CMAKE_SYSTEM_NAME Generic) SET(CMAKE_SYSTEM_VERSION 1) diff --git a/ee/CMakeLists.txt b/ee/CMakeLists.txt index f7d9d891eb3..b7ba17aacca 100644 --- a/ee/CMakeLists.txt +++ b/ee/CMakeLists.txt @@ -5,4 +5,5 @@ file(REAL_PATH ../ PS2SDKSRC_ROOT) set(EE_INC ${PS2SDKSRC_ROOT}/common/include ${PROJECT_SOURCE_DIR}/kernel/include ${PROJECT_SOURCE_DIR}/rpc/cdvd/include) add_subdirectory(kernel) +add_subdirectory(libcglue) add_subdirectory(debug) \ No newline at end of file diff --git a/ee/libcglue/CMakeLists.txt b/ee/libcglue/CMakeLists.txt new file mode 100644 index 00000000000..e45457b1f6f --- /dev/null +++ b/ee/libcglue/CMakeLists.txt @@ -0,0 +1,207 @@ +include(${PS2SDKSRC_ROOT}/cmake/utils.cmake) + +add_library(cglue) +target_include_directories(cglue PUBLIC ${EE_INC} include) +target_sources(cglue PRIVATE src/rtc.c) +target_link_libraries(cglue PRIVATE kernel) + +compile_multiple(cglue src/timezone.c OBJECTS + _libcglue_timezone_update.o ps2sdk_setTimezone.o ps2sdk_setDaylightSaving.o +) + +compile_multiple(cglue src/fdman.c OBJECTS + __fdman_sema.o + __descriptor_data_pool.o + __descriptormap.o + __fdman_init.o + __fdman_deinit.o + __fdman_get_new_descriptor.o + __fdman_get_dup_descriptor.o + __fdman_get_dup2_descriptor.o + __fdman_release_descriptor.o +) + +compile_multiple(cglue src/init.c OBJECTS + __gprof_init.o + __gprof_cleanup.o + __libpthreadglue_init.o + __libpthreadglue_deinit.o + _libcglue_init.o + _libcglue_deinit.o + _libcglue_args_parse.o +) + +compile_multiple(cglue src/sleep.c OBJECTS + nanosleep.o +) + +compile_multiple(cglue src/sjis.c OBJECTS + isSpecialSJIS.o isSpecialASCII.o strcpy_ascii.o strcpy_sjis.o +) + +compile_multiple(cglue src/cwd.c OBJECTS + __cwd.o __cwd_len.o __get_drive.o getcwd.o __path_absolute.o __init_cwd.o +) + +compile_multiple(cglue src/ps2sdkapi.c OBJECTS + __fioOpsInitialize.o + __fioOpenHelper.o + __fioGetFdHelper.o + __fioGetFilenameHelper.o + __fioCloseHelper.o + __fioDcloseHelper.o + __fioReadHelper.o + __fioLseekHelper.o + __fioWriteHelper.o + __fioIoctlHelper.o + __fioDreadHelper.o + __fioLseekDirHelper.o + __libcglue_init_stdio.o + __fioMkdirHelper.o + __fioGetstatHelper.o + __fioOpsInitializeImpl.o + _libcglue_fdman_path_ops.o + _libcglue_fdman_socket_ops.o + _libcglue_fdman_inet_ops.o +) + +compile_multiple(cglue src/glue.c OBJECTS + __dummy_passwd.o + __transform_errno.o + __transform64_errno.o + compile_time_check.o + _open.o + _close.o + _read.o + _write.o + _stat.o + lstat.o + _fstat.o + access.o + _fcntl.o + getdents.o + _lseek.o + lseek64.o + chdir.o + mkdir.o + rmdir.o + _link.o + _unlink.o + _rename.o + _getpid.o + _kill.o + _fork.o + _wait.o + _execve.o + _sbrk.o + _gettimeofday.o + _times.o + ftime.o + clock_getres.o + clock_gettime.o + clock_settime.o + truncate.o + symlink.o + readlink.o + utime.o + fchown.o + getrandom.o + _getentropy.o + _isatty.o + chmod.o + fchmod.o + pathconf.o + fsync.o + getuid.o + geteuid.o + getpwuid.o + getpwnam.o + libcglue_get_fd_info.o + ps2sdk_get_iop_fd.o + ps2sdk_get_iop_filename.o + _ps2sdk_close.o + _ps2sdk_dclose.o + _ps2sdk_read.o + _ps2sdk_lseek.o + _ps2sdk_lseek64.o + _ps2sdk_write.o + _ps2sdk_ioctl.o + _ps2sdk_ioctl2.o + _ps2sdk_dread.o + openat.o + renameat.o + fchmodat.o + fstatat.o + mkdirat.o + faccessat.o + fchownat.o + linkat.o + readlinkat.o + unlinkat.o + dup.o + dup2.o +) + +compile_multiple(cglue src/lock.c OBJECTS + __lock___sfp_recursive_mutex.o + __lock___atexit_recursive_mutex.o + __lock___at_quick_exit_mutex.o + __lock___malloc_recursive_mutex.o + __lock___env_recursive_mutex.o + __lock___tz_mutex.o + __lock___dd_hash_mutex.o + __lock___arc4random_mutex.o + __retarget_lock_init.o + __retarget_lock_init_recursive.o + __retarget_lock_close.o + __retarget_lock_close_recursive.o + __retarget_lock_acquire.o + __retarget_lock_acquire_recursive.o + __retarget_lock_try_acquire.o + __retarget_lock_try_acquire_recursive.o + __retarget_lock_release.o + __retarget_lock_release_recursive.o + __locks_init.o + __locks_deinit.o +) + +compile_multiple(cglue src/netdb.c OBJECTS + gethostbyaddr.o + gethostbyname.o + gethostbyname_r.o + freeaddrinfo.o + getaddrinfo.o +) + +compile_multiple(cglue src/select.c OBJECTS + select.o +) + +compile_multiple(cglue src/socket.c OBJECTS + socket.o + accept.o + bind.o + connect.o + listen.o + recv.o + recvfrom.o + recvmsg.o + send.o + sendto.o + sendmsg.o + getsockopt.o + setsockopt.o + shutdown.o + getpeername.o + getsockname.o + libcglue_inet_addr.o + libcglue_inet_ntoa.o + libcglue_inet_ntoa_r.o + libcglue_inet_aton.o + libcglue_ps2ip_setconfig.o + libcglue_ps2ip_getconfig.o + libcglue_dns_setserver.o + libcglue_dns_getserver.o +) + +install(TARGETS cglue) \ No newline at end of file From 942e43c610f9b3bf0c9a26ff98aff2f08a38deaf Mon Sep 17 00:00:00 2001 From: Ziemas Date: Thu, 3 Oct 2024 08:04:15 +0200 Subject: [PATCH 11/21] cmake: build libpatches --- ee/CMakeLists.txt | 3 ++- ee/sbv/CMakeLists.txt | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 ee/sbv/CMakeLists.txt diff --git a/ee/CMakeLists.txt b/ee/CMakeLists.txt index b7ba17aacca..443973ec604 100644 --- a/ee/CMakeLists.txt +++ b/ee/CMakeLists.txt @@ -6,4 +6,5 @@ set(EE_INC ${PS2SDKSRC_ROOT}/common/include ${PROJECT_SOURCE_DIR}/kernel/include add_subdirectory(kernel) add_subdirectory(libcglue) -add_subdirectory(debug) \ No newline at end of file +add_subdirectory(debug) +add_subdirectory(sbv) \ No newline at end of file diff --git a/ee/sbv/CMakeLists.txt b/ee/sbv/CMakeLists.txt new file mode 100644 index 00000000000..0d8ed223ab5 --- /dev/null +++ b/ee/sbv/CMakeLists.txt @@ -0,0 +1,14 @@ +add_library(patches) +target_include_directories(patches PUBLIC include) +target_include_directories(patches PRIVATE ${EE_INC}) +target_sources(patches PRIVATE src/smem.c src/smod.c src/slib.c + src/patch_enable_lmb.c src/patch_disable_prefix_check.c + src/patch_user_mem_clear.c src/patch_fileio.c src/common.c + #src/erl-support.c TODO +) + +file(GLOB PATCHES_INCLUDE_FILES "include/*.h*") +set_target_properties(patches PROPERTIES PUBLIC_HEADER "${PATCHES_INCLUDE_FILES}") + +install(TARGETS patches) + From 8a26992fa1ee14b1f6eb6ca276531de642ed87c7 Mon Sep 17 00:00:00 2001 From: Ziemas Date: Sat, 5 Oct 2024 10:51:42 +0200 Subject: [PATCH 12/21] Add erl, and build erl for patches --- cmake/utils.cmake | 16 ++++++++++++++++ ee/CMakeLists.txt | 3 ++- ee/erl/CMakeLists.txt | 4 ++++ ee/kernel/CMakeLists.txt | 2 +- ee/sbv/CMakeLists.txt | 4 ++-- 5 files changed, 25 insertions(+), 4 deletions(-) create mode 100644 ee/erl/CMakeLists.txt diff --git a/cmake/utils.cmake b/cmake/utils.cmake index 0faebf3e159..0631c98e09d 100644 --- a/cmake/utils.cmake +++ b/cmake/utils.cmake @@ -14,3 +14,19 @@ function(compile_multiple target srcfile) endforeach() endfunction() +# Add an erl output for a given target +function(target_add_erl target) + add_custom_command(OUTPUT "lib${target}.erl" + COMMAND ${CMAKE_C_COMPILER} -nostdlib -Wl,-r -Wl,-d -o "lib${target}.erl" $ + COMMAND ${CMAKE_STRIP} --strip-unneeded -R .mdebug.eabi64 -R .reginfo -R .comment lib${target}.erl + DEPENDS ${target} + COMMAND_EXPAND_LISTS + ) + add_custom_target(${target}_erl ALL + DEPENDS lib${target}.erl + ) + install(FILES ${CMAKE_CURRENT_BINARY_DIR}/lib${target}.erl + DESTINATION lib + ) +endfunction() + diff --git a/ee/CMakeLists.txt b/ee/CMakeLists.txt index 443973ec604..a80ed563bac 100644 --- a/ee/CMakeLists.txt +++ b/ee/CMakeLists.txt @@ -2,7 +2,8 @@ cmake_minimum_required(VERSION 3.10) project(ps2sdk-ee C ASM) file(REAL_PATH ../ PS2SDKSRC_ROOT) -set(EE_INC ${PS2SDKSRC_ROOT}/common/include ${PROJECT_SOURCE_DIR}/kernel/include ${PROJECT_SOURCE_DIR}/rpc/cdvd/include) +set(EE_INC ${PS2SDKSRC_ROOT}/common/include ${PROJECT_SOURCE_DIR}/kernel/include ${PROJECT_SOURCE_DIR}/rpc/cdvd/include + ${PROJECT_SOURCE_DIR}/erl/include) add_subdirectory(kernel) add_subdirectory(libcglue) diff --git a/ee/erl/CMakeLists.txt b/ee/erl/CMakeLists.txt new file mode 100644 index 00000000000..369ea9c7e54 --- /dev/null +++ b/ee/erl/CMakeLists.txt @@ -0,0 +1,4 @@ +add_library(erl) +target_include_directories(erl PUBLIC include) +target_include_directories(erl PRIVATE ${EE_INC}) +target_sources(erl PRIVATE src/erl.c src/hashtab.c src/lookupa.c src/recycle.c) \ No newline at end of file diff --git a/ee/kernel/CMakeLists.txt b/ee/kernel/CMakeLists.txt index 17d13964fba..8ddb612d90d 100644 --- a/ee/kernel/CMakeLists.txt +++ b/ee/kernel/CMakeLists.txt @@ -217,7 +217,7 @@ compile_multiple(kernel src/kernel.S OBJECTS strncpy.o strlen.o memcpy.o memset.o __syscall.o GPfuncs.o _print.o ) -target_sources(kernel PRIVATE src/setup_syscalls.S src/debug.c) +target_sources(kernel PRIVATE src/setup_syscalls.S src/debug.c src/erl-support.c) file(GLOB KERNEL_INCLUDE_FILES "include/*.h*") set_target_properties(kernel PROPERTIES PUBLIC_HEADER "${KERNEL_INCLUDE_FILES}") diff --git a/ee/sbv/CMakeLists.txt b/ee/sbv/CMakeLists.txt index 0d8ed223ab5..4aee7fd0b01 100644 --- a/ee/sbv/CMakeLists.txt +++ b/ee/sbv/CMakeLists.txt @@ -4,11 +4,11 @@ target_include_directories(patches PRIVATE ${EE_INC}) target_sources(patches PRIVATE src/smem.c src/smod.c src/slib.c src/patch_enable_lmb.c src/patch_disable_prefix_check.c src/patch_user_mem_clear.c src/patch_fileio.c src/common.c - #src/erl-support.c TODO + src/erl-support.c ) file(GLOB PATCHES_INCLUDE_FILES "include/*.h*") set_target_properties(patches PROPERTIES PUBLIC_HEADER "${PATCHES_INCLUDE_FILES}") - install(TARGETS patches) +target_add_erl(patches) \ No newline at end of file From 96082f5450f607e9d5c483b85b8014b91cf276b0 Mon Sep 17 00:00:00 2001 From: Ziemas Date: Sat, 5 Oct 2024 10:54:14 +0200 Subject: [PATCH 13/21] build and install crt0/linkfile --- ee/CMakeLists.txt | 4 +++- ee/startup/CMakeLists.txt | 5 +++++ 2 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 ee/startup/CMakeLists.txt diff --git a/ee/CMakeLists.txt b/ee/CMakeLists.txt index a80ed563bac..e0623792f58 100644 --- a/ee/CMakeLists.txt +++ b/ee/CMakeLists.txt @@ -6,6 +6,8 @@ set(EE_INC ${PS2SDKSRC_ROOT}/common/include ${PROJECT_SOURCE_DIR}/kernel/include ${PROJECT_SOURCE_DIR}/erl/include) add_subdirectory(kernel) +add_subdirectory(erl) add_subdirectory(libcglue) add_subdirectory(debug) -add_subdirectory(sbv) \ No newline at end of file +add_subdirectory(sbv) +add_subdirectory(startup) diff --git a/ee/startup/CMakeLists.txt b/ee/startup/CMakeLists.txt new file mode 100644 index 00000000000..6da5b3aa757 --- /dev/null +++ b/ee/startup/CMakeLists.txt @@ -0,0 +1,5 @@ +add_library(crt0 OBJECT src/crt0.c) +target_include_directories(crt0 PUBLIC include) +target_include_directories(crt0 PRIVATE ${EE_INC}) +install(FILES ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/crt0.dir/src/crt0.c.obj DESTINATION lib RENAME "crt0.o") +install(FILES src/linkfile DESTINATION startup) From 4addaf46b7dca8ade0f54cd1a232e9f4f6e90bcf Mon Sep 17 00:00:00 2001 From: Ziemas Date: Sat, 5 Oct 2024 13:07:15 +0200 Subject: [PATCH 14/21] cmake: build more libraries --- ee/CMakeLists.txt | 15 ++++++++++++--- ee/dma/CMakeLists.txt | 8 ++++++++ ee/draw/CMakeLists.txt | 21 +++++++++++++++++++++ ee/eedebug/CMakeLists.txt | 18 ++++++++++++++++++ ee/elf-loader/CMakeLists.txt | 16 ++++++++++++++++ ee/kernel/CMakeLists.txt | 7 ++++--- ee/kernel/src/osdsrc/CMakeLists.txt | 5 ++++- ee/libcglue/CMakeLists.txt | 2 -- 8 files changed, 83 insertions(+), 9 deletions(-) create mode 100644 ee/dma/CMakeLists.txt create mode 100644 ee/draw/CMakeLists.txt create mode 100644 ee/eedebug/CMakeLists.txt create mode 100644 ee/elf-loader/CMakeLists.txt diff --git a/ee/CMakeLists.txt b/ee/CMakeLists.txt index e0623792f58..d8847193df6 100644 --- a/ee/CMakeLists.txt +++ b/ee/CMakeLists.txt @@ -2,12 +2,21 @@ cmake_minimum_required(VERSION 3.10) project(ps2sdk-ee C ASM) file(REAL_PATH ../ PS2SDKSRC_ROOT) -set(EE_INC ${PS2SDKSRC_ROOT}/common/include ${PROJECT_SOURCE_DIR}/kernel/include ${PROJECT_SOURCE_DIR}/rpc/cdvd/include - ${PROJECT_SOURCE_DIR}/erl/include) +set(EE_INC + ${PS2SDKSRC_ROOT}/common/include + ${PROJECT_SOURCE_DIR}/kernel/include + ${PROJECT_SOURCE_DIR}/erl/include +) +include(${PS2SDKSRC_ROOT}/cmake/utils.cmake) + +add_subdirectory(debug) +add_subdirectory(dma) +add_subdirectory(draw) +add_subdirectory(eedebug) +add_subdirectory(elf-loader) add_subdirectory(kernel) add_subdirectory(erl) add_subdirectory(libcglue) -add_subdirectory(debug) add_subdirectory(sbv) add_subdirectory(startup) diff --git a/ee/dma/CMakeLists.txt b/ee/dma/CMakeLists.txt new file mode 100644 index 00000000000..c8b38942664 --- /dev/null +++ b/ee/dma/CMakeLists.txt @@ -0,0 +1,8 @@ +add_library(dma) +target_include_directories(dma PUBLIC include) +target_include_directories(dma PRIVATE ${EE_INC} ${PROJECT_SOURCE_DIR}/packet2/include) +target_sources(dma PRIVATE src/dma.c src/erl-support.c) +file(GLOB DMA_INCLUDE_FILES "include/*.h*") +set_target_properties(dma PROPERTIES PUBLIC_HEADER "${DMA_INCLUDE_FILES}") +install(TARGETS dma) +target_add_erl(dma) diff --git a/ee/draw/CMakeLists.txt b/ee/draw/CMakeLists.txt new file mode 100644 index 00000000000..fde7eaf5117 --- /dev/null +++ b/ee/draw/CMakeLists.txt @@ -0,0 +1,21 @@ +add_library(draw) +target_include_directories(draw PUBLIC include) +target_include_directories(draw PRIVATE + ${EE_INC} + ${PROJECT_SOURCE_DIR}/math3d/include + ${PROJECT_SOURCE_DIR}/dma/include +) + +target_sources(draw PRIVATE + src/draw_environment.c + src/draw.c + src/draw2d.c + src/draw3d.c + src/erl-support.c +) + +file(GLOB DRAW_INCLUDE_FILES "include/*.h*") +set_target_properties(draw PROPERTIES PUBLIC_HEADER "${DRAW_INCLUDE_FILES}") +install(TARGETS draw) + +target_add_erl(draw) \ No newline at end of file diff --git a/ee/eedebug/CMakeLists.txt b/ee/eedebug/CMakeLists.txt new file mode 100644 index 00000000000..c60c3ffb6e6 --- /dev/null +++ b/ee/eedebug/CMakeLists.txt @@ -0,0 +1,18 @@ +add_library(eedebug) +target_include_directories(eedebug PUBLIC include) +target_include_directories(eedebug PRIVATE + ${EE_INC} +) + +target_sources(eedebug PRIVATE + src/ee_dbg_low.S + src/ee_debug.c + src/ee_exceptions.S + src/erl-support.c +) + +file(GLOB eedebug_INCLUDE_FILES "include/*.h*") +set_target_properties(eedebug PROPERTIES PUBLIC_HEADER "${eedebug_INCLUDE_FILES}") +install(TARGETS eedebug) + +target_add_erl(eedebug) \ No newline at end of file diff --git a/ee/elf-loader/CMakeLists.txt b/ee/elf-loader/CMakeLists.txt new file mode 100644 index 00000000000..5381b937976 --- /dev/null +++ b/ee/elf-loader/CMakeLists.txt @@ -0,0 +1,16 @@ +# TODO subfolder binary include +add_library(elf-loader) +target_include_directories(elf-loader PUBLIC include) +target_include_directories(elf-loader PRIVATE + ${EE_INC} +) + +target_sources(elf-loader PRIVATE + src/elf.c +) + +file(GLOB elf-loader_INCLUDE_FILES "include/*.h*") +set_target_properties(elf-loader PROPERTIES PUBLIC_HEADER "${elf-loader_INCLUDE_FILES}") +install(TARGETS elf-loader) + +target_add_erl(elf-loader) \ No newline at end of file diff --git a/ee/kernel/CMakeLists.txt b/ee/kernel/CMakeLists.txt index 8ddb612d90d..d5cbac12426 100644 --- a/ee/kernel/CMakeLists.txt +++ b/ee/kernel/CMakeLists.txt @@ -1,7 +1,5 @@ cmake_minimum_required(VERSION 3.10) -include(${PS2SDKSRC_ROOT}/cmake/utils.cmake) - add_subdirectory(src/eenull) add_subdirectory(src/osdsrc) add_subdirectory(src/srcfile) @@ -9,7 +7,10 @@ add_subdirectory(src/tlbsrc) add_library(kernel) target_include_directories(kernel PUBLIC include) -target_include_directories(kernel PRIVATE ${EE_INC}) +target_include_directories(kernel PRIVATE + ${EE_INC} + ${PROJECT_SOURCE_DIR}/rpc/cdvd/include +) compile_multiple(kernel src/sifcmd.c OBJECTS sif_cmd_send.o _sif_cmd_int_handler.o sif_cmd_main.o diff --git a/ee/kernel/src/osdsrc/CMakeLists.txt b/ee/kernel/src/osdsrc/CMakeLists.txt index 164832e1dd4..de4b2eaf9ff 100644 --- a/ee/kernel/src/osdsrc/CMakeLists.txt +++ b/ee/kernel/src/osdsrc/CMakeLists.txt @@ -3,5 +3,8 @@ add_executable(osdsrc) target_sources(osdsrc PRIVATE src/ExecPS2.c src/osd.c src/osdsrc.c) target_compile_definitions(osdsrc PRIVATE -DREUSE_EXECPS2) target_compile_options(osdsrc PRIVATE -fno-tree-loop-distribute-patterns -mno-gpopt) -target_include_directories(osdsrc PRIVATE ${EE_INC}) +target_include_directories(osdsrc PRIVATE + ${EE_INC} + ${PROJECT_SOURCE_DIR}/rpc/cdvd/include +) target_link_options(osdsrc PRIVATE -nostdlib -nostartfiles -T${CMAKE_CURRENT_SOURCE_DIR}/linkfile -s) \ No newline at end of file diff --git a/ee/libcglue/CMakeLists.txt b/ee/libcglue/CMakeLists.txt index e45457b1f6f..9ed864e4245 100644 --- a/ee/libcglue/CMakeLists.txt +++ b/ee/libcglue/CMakeLists.txt @@ -1,5 +1,3 @@ -include(${PS2SDKSRC_ROOT}/cmake/utils.cmake) - add_library(cglue) target_include_directories(cglue PUBLIC ${EE_INC} include) target_sources(cglue PRIVATE src/rtc.c) From d17b022dc244b9c0c3f1fc1c4bd41e9cd4c30c20 Mon Sep 17 00:00:00 2001 From: Ziemas Date: Mon, 7 Oct 2024 09:54:21 +0200 Subject: [PATCH 15/21] cmake: add most rpc libs --- cmake/utils.cmake | 10 +++++++ ee/CMakeLists.txt | 1 + ee/elf-loader/CMakeLists.txt | 5 +++- ee/elf-loader/src/loader/CMakeLists.txt | 5 ++++ ee/kernel/CMakeLists.txt | 11 -------- ee/rpc/CMakeLists.txt | 17 ++++++++++++ ee/rpc/ahx/CMakeLists.txt | 6 +++++ ee/rpc/audsrv/CMakeLists.txt | 6 +++++ ee/rpc/camera/CMakeLists.txt | 6 +++++ ee/rpc/cdvd/CMakeLists.txt | 33 +++++++++++++++++++++++ ee/rpc/filexio/CMakeLists.txt | 35 +++++++++++++++++++++++++ ee/rpc/hdd/CMakeLists.txt | 7 +++++ ee/rpc/keyboard/CMakeLists.txt | 7 +++++ ee/rpc/memorycard/CMakeLists.txt | 6 +++++ ee/rpc/mouse/CMakeLists.txt | 6 +++++ ee/rpc/multitap/CMakeLists.txt | 6 +++++ ee/rpc/pad/CMakeLists.txt | 14 ++++++++++ ee/rpc/poweroff/CMakeLists.txt | 6 +++++ ee/rpc/ps2snd/CMakeLists.txt | 6 +++++ ee/rpc/remote/CMakeLists.txt | 6 +++++ ee/rpc/secr/CMakeLists.txt | 6 +++++ ee/rpc/sior/CMakeLists.txt | 6 +++++ ee/rpc/tcpips/CMakeLists.txt | 7 +++++ 23 files changed, 206 insertions(+), 12 deletions(-) create mode 100644 ee/elf-loader/src/loader/CMakeLists.txt create mode 100644 ee/rpc/CMakeLists.txt create mode 100644 ee/rpc/ahx/CMakeLists.txt create mode 100644 ee/rpc/audsrv/CMakeLists.txt create mode 100644 ee/rpc/camera/CMakeLists.txt create mode 100644 ee/rpc/cdvd/CMakeLists.txt create mode 100644 ee/rpc/filexio/CMakeLists.txt create mode 100644 ee/rpc/hdd/CMakeLists.txt create mode 100644 ee/rpc/keyboard/CMakeLists.txt create mode 100644 ee/rpc/memorycard/CMakeLists.txt create mode 100644 ee/rpc/mouse/CMakeLists.txt create mode 100644 ee/rpc/multitap/CMakeLists.txt create mode 100644 ee/rpc/pad/CMakeLists.txt create mode 100644 ee/rpc/poweroff/CMakeLists.txt create mode 100644 ee/rpc/ps2snd/CMakeLists.txt create mode 100644 ee/rpc/remote/CMakeLists.txt create mode 100644 ee/rpc/secr/CMakeLists.txt create mode 100644 ee/rpc/sior/CMakeLists.txt create mode 100644 ee/rpc/tcpips/CMakeLists.txt diff --git a/cmake/utils.cmake b/cmake/utils.cmake index 0631c98e09d..5a0eafe282e 100644 --- a/cmake/utils.cmake +++ b/cmake/utils.cmake @@ -30,3 +30,13 @@ function(target_add_erl target) ) endfunction() +# Generates a C array of the binary output of a target +# objcopy -Obinary && bin2c +macro(bin_include from_target output_name) +add_custom_command(OUTPUT "${output_name}.c" + COMMAND ${CMAKE_OBJCOPY} -Obinary $ "${output_name}.bin" + COMMAND bin2c "${output_name}.bin" "${output_name}.c" "${from_target}" + BYPRODUCTS "${output_name}.bin" + DEPENDS ${from_target} +) +endmacro() diff --git a/ee/CMakeLists.txt b/ee/CMakeLists.txt index d8847193df6..7bbc0db1de9 100644 --- a/ee/CMakeLists.txt +++ b/ee/CMakeLists.txt @@ -18,5 +18,6 @@ add_subdirectory(elf-loader) add_subdirectory(kernel) add_subdirectory(erl) add_subdirectory(libcglue) +add_subdirectory(rpc) add_subdirectory(sbv) add_subdirectory(startup) diff --git a/ee/elf-loader/CMakeLists.txt b/ee/elf-loader/CMakeLists.txt index 5381b937976..86f9b80f415 100644 --- a/ee/elf-loader/CMakeLists.txt +++ b/ee/elf-loader/CMakeLists.txt @@ -1,12 +1,15 @@ -# TODO subfolder binary include +add_subdirectory(src/loader) + add_library(elf-loader) target_include_directories(elf-loader PUBLIC include) target_include_directories(elf-loader PRIVATE ${EE_INC} ) +bin_include(loader loader_bin) target_sources(elf-loader PRIVATE src/elf.c + loader_bin.c ) file(GLOB elf-loader_INCLUDE_FILES "include/*.h*") diff --git a/ee/elf-loader/src/loader/CMakeLists.txt b/ee/elf-loader/src/loader/CMakeLists.txt new file mode 100644 index 00000000000..a07e26a294c --- /dev/null +++ b/ee/elf-loader/src/loader/CMakeLists.txt @@ -0,0 +1,5 @@ +add_executable(loader) +target_sources(loader PRIVATE src/loader.c) +target_include_directories(loader PRIVATE ${EE_INC}) +target_link_libraries(loader PRIVATE kernel cglue) +target_link_options(loader PRIVATE -T${CMAKE_CURRENT_SOURCE_DIR}/linkfile) \ No newline at end of file diff --git a/ee/kernel/CMakeLists.txt b/ee/kernel/CMakeLists.txt index d5cbac12426..f14fd3df55c 100644 --- a/ee/kernel/CMakeLists.txt +++ b/ee/kernel/CMakeLists.txt @@ -84,17 +84,6 @@ compile_multiple(kernel src/osd_config.c OBJECTS configConvertToGmtTime.o configConvertToLocalTimeWithIODriver.o configConvertToLocalTime.o ) -# Generates a C array of the binary output of a target -# objcopy -Obinary && bin2c -macro(bin_include from_target output_name) -add_custom_command(OUTPUT "${output_name}.c" - COMMAND ${CMAKE_OBJCOPY} -Obinary $ "${output_name}.bin" - COMMAND bin2c "${output_name}.bin" "${output_name}.c" "${from_target}" - BYPRODUCTS "${output_name}.bin" - DEPENDS ${from_target} -) -endmacro() - bin_include(osdsrc osdsrc_bin) target_sources(kernel PRIVATE src/libosd.c src/libosd_full.c src/libosd_common.c osdsrc_bin.c) diff --git a/ee/rpc/CMakeLists.txt b/ee/rpc/CMakeLists.txt new file mode 100644 index 00000000000..f2933e998b7 --- /dev/null +++ b/ee/rpc/CMakeLists.txt @@ -0,0 +1,17 @@ +add_subdirectory(ahx) +add_subdirectory(audsrv) +add_subdirectory(camera) +add_subdirectory(cdvd) +add_subdirectory(filexio) +add_subdirectory(hdd) +add_subdirectory(keyboard) +add_subdirectory(memorycard) +add_subdirectory(mouse) +add_subdirectory(multitap) +add_subdirectory(pad) +add_subdirectory(poweroff) +add_subdirectory(ps2snd) +add_subdirectory(remote) +add_subdirectory(secr) +add_subdirectory(sior) +add_subdirectory(tcpips) \ No newline at end of file diff --git a/ee/rpc/ahx/CMakeLists.txt b/ee/rpc/ahx/CMakeLists.txt new file mode 100644 index 00000000000..1148e24c3fa --- /dev/null +++ b/ee/rpc/ahx/CMakeLists.txt @@ -0,0 +1,6 @@ +add_library(ahx) +target_include_directories(ahx PUBLIC include) +target_include_directories(ahx PRIVATE ${EE_INC}) +target_sources(ahx PRIVATE src/ahx_rpc.c src/erl-support.c) +install(TARGETS ahx) +target_add_erl(ahx) \ No newline at end of file diff --git a/ee/rpc/audsrv/CMakeLists.txt b/ee/rpc/audsrv/CMakeLists.txt new file mode 100644 index 00000000000..7a12c97833c --- /dev/null +++ b/ee/rpc/audsrv/CMakeLists.txt @@ -0,0 +1,6 @@ +add_library(audsrv) +target_include_directories(audsrv PUBLIC include) +target_include_directories(audsrv PRIVATE ${EE_INC}) +target_sources(audsrv PRIVATE src/audsrv_rpc.c src/erl-support.c) +install(TARGETS audsrv) +target_add_erl(audsrv) \ No newline at end of file diff --git a/ee/rpc/camera/CMakeLists.txt b/ee/rpc/camera/CMakeLists.txt new file mode 100644 index 00000000000..f6ea37ae4ec --- /dev/null +++ b/ee/rpc/camera/CMakeLists.txt @@ -0,0 +1,6 @@ +add_library(camera) +target_include_directories(camera PUBLIC include) +target_include_directories(camera PRIVATE ${EE_INC}) +target_sources(camera PRIVATE src/ps2cam_rpc.c src/erl-support.c) +install(TARGETS camera) +target_add_erl(camera) \ No newline at end of file diff --git a/ee/rpc/cdvd/CMakeLists.txt b/ee/rpc/cdvd/CMakeLists.txt new file mode 100644 index 00000000000..61e463b1bf5 --- /dev/null +++ b/ee/rpc/cdvd/CMakeLists.txt @@ -0,0 +1,33 @@ +add_library(cdvd) +target_include_directories(cdvd PUBLIC include) +target_include_directories(cdvd PRIVATE ${EE_INC}) + +compile_multiple(cdvd src/libcdvd.c OBJECTS + _libcdvd_internals.o sceCdInit.o sceCdIntToPos.o sceCdPosToInt.o + sceCdSearchFile.o sceCdDiskReady.o _CdSemaInit.o _CdSemaExit.o + sceCdInitEeCB.o sceCdCallback.o _CdGenericCallbackFunction.o +) + +compile_multiple(cdvd src/ncmd.c OBJECTS + _ncmd_internals.o _CdAlignReadBuffer.o sceCdRead.o sceCdReadDVDV.o + sceCdReadCDDA.o sceCdGetToc.o sceCdSeek.o sceCdStandby.o sceCdStop.o sceCdPause.o + sceCdApplyNCmd.o sceCdReadIOPMem.o sceCdNCmdDiskReady.o + sceCdGetReadPos.o sceCdStStart.o sceCdStRead.o sceCdStStop.o sceCdStSeek.o sceCdStInit.o + sceCdStStat.o sceCdStPause.o sceCdStResume.o sceCdStream.o sceCdCddaStream.o sceCdSync.o + _CdCheckNCmd.o sceCdReadKey.o +) + +compile_multiple(cdvd src/scmd.c OBJECTS + _scmd_internals.o sceCdReadClock.o ps2time.o sceCdWriteClock.o sceCdGetDiskType.o + sceCdGetError.o sceCdTrayReq.o sceCdApplySCmd.o sceCdStatus.o sceCdBreak.o + _CdCheckSCmd.o sceCdCtrlADout.o sceCdMV.o sceCdReadSUBQ.o + sceCdForbidDVDP.o sceCdAutoAdjustCtrl.o sceCdDecSet.o sceCdSetHDMode.o sceCdOpenConfig.o sceCdCloseConfig.o + sceCdReadConfig.o sceCdWriteConfig.o + sceCdReadNVM.o sceCdWriteNVM.o sceCdRI.o sceCdWI.o sceCdReadConsoleID.o sceCdWriteConsoleID.o + sceCdNoticeGameStart.o + _CdSyncS.o +) + +target_sources(cdvd PRIVATE src/erl-support.c) +install(TARGETS cdvd) +#target_add_erl(cdvd) TODO doesn't work with the object libraries \ No newline at end of file diff --git a/ee/rpc/filexio/CMakeLists.txt b/ee/rpc/filexio/CMakeLists.txt new file mode 100644 index 00000000000..a76a91c6759 --- /dev/null +++ b/ee/rpc/filexio/CMakeLists.txt @@ -0,0 +1,35 @@ +add_library(fileXio) +target_include_directories(fileXio PUBLIC include) +target_include_directories(fileXio PRIVATE ${EE_INC} ${PROJECT_SOURCE_DIR}/libcglue/include) + +compile_multiple(fileXio src/fileXio_rpc.c OBJECTS + __cd0.o __sbuff.o __intr_data.o __fileXioInited.o __fileXioBlockMode.o __fileXioCompletionSema.o __lock_sema_id.o + fileXioInit.o fileXioExit.o fileXioStop.o fileXioGetDeviceList.o fileXioGetdir.o fileXioMount.o fileXioUmount.o + fileXioCopyfile.o fileXioMkdir.o fileXioRmdir.o fileXioRemove.o fileXioRename.o fileXioSymlink.o fileXioReadlink.o + fileXioChdir.o fileXioOpen.o fileXioClose.o fileXioRead.o fileXioWrite.o fileXioLseek.o fileXioLseek64.o fileXioChStat.o + fileXioGetStat.o fileXioFormat.o fileXioSync.o fileXioDopen.o fileXioDclose.o fileXioDread.o fileXioDevctl.o + fileXioIoctl.o fileXioIoctl2.o fileXioWaitAsync.o fileXioSetBlockMode.o fileXioSetRWBufferSize.o +) + +compile_multiple(fileXio src/fileXio_ps2sdk.c OBJECTS + __fileXioOpsInitialize.o + __fileXioOpenHelper.o + __fileXioGetFdHelper.o + __fileXioGetFilenameHelper.o + __fileXioGetstatHelper.o + __fileXioCloseHelper.o + __fileXioDcloseHelper.o + __fileXioReadHelper.o + __fileXioLseekHelper.o + __fileXioLseek64Helper.o + __fileXioWriteHelper.o + __fileXioIoctlHelper.o + __fileXioIoctl2Helper.o + __fileXioDreadHelper.o + __fileXioLseekDirHelper.o + __fileXioOpsInitializeImpl.o + _ps2sdk_fileXio_init_deinit.o +) + +target_sources(fileXio PRIVATE src/erl-support.c) +install(TARGETS fileXio) \ No newline at end of file diff --git a/ee/rpc/hdd/CMakeLists.txt b/ee/rpc/hdd/CMakeLists.txt new file mode 100644 index 00000000000..529c106b83f --- /dev/null +++ b/ee/rpc/hdd/CMakeLists.txt @@ -0,0 +1,7 @@ +add_library(hdd) +target_include_directories(hdd PUBLIC include) +target_include_directories(hdd PRIVATE ${EE_INC}) +target_link_libraries(hdd PRIVATE poweroff fileXio) +target_sources(hdd PRIVATE src/libhdd.c src/erl-support.c) +install(TARGETS hdd) +target_add_erl(hdd) \ No newline at end of file diff --git a/ee/rpc/keyboard/CMakeLists.txt b/ee/rpc/keyboard/CMakeLists.txt new file mode 100644 index 00000000000..3835037a737 --- /dev/null +++ b/ee/rpc/keyboard/CMakeLists.txt @@ -0,0 +1,7 @@ +add_library(keyboard) +target_include_directories(keyboard PUBLIC include) +target_include_directories(keyboard PRIVATE ${EE_INC}) +target_sources(keyboard PRIVATE src/libkbd.c src/erl-support.c) +target_link_libraries(keyboard PRIVATE cglue) +install(TARGETS keyboard) +target_add_erl(keyboard) \ No newline at end of file diff --git a/ee/rpc/memorycard/CMakeLists.txt b/ee/rpc/memorycard/CMakeLists.txt new file mode 100644 index 00000000000..69d921d4dbd --- /dev/null +++ b/ee/rpc/memorycard/CMakeLists.txt @@ -0,0 +1,6 @@ +add_library(memorycard) +target_include_directories(memorycard PUBLIC include) +target_include_directories(memorycard PRIVATE ${EE_INC}) +target_sources(memorycard PRIVATE src/libmc.c src/erl-support.c) +install(TARGETS memorycard) +target_add_erl(memorycard) \ No newline at end of file diff --git a/ee/rpc/mouse/CMakeLists.txt b/ee/rpc/mouse/CMakeLists.txt new file mode 100644 index 00000000000..f6304537176 --- /dev/null +++ b/ee/rpc/mouse/CMakeLists.txt @@ -0,0 +1,6 @@ +add_library(mouse) +target_include_directories(mouse PUBLIC include) +target_include_directories(mouse PRIVATE ${EE_INC}) +target_sources(mouse PRIVATE src/libmouse.c src/erl-support.c) +install(TARGETS mouse) +target_add_erl(mouse) \ No newline at end of file diff --git a/ee/rpc/multitap/CMakeLists.txt b/ee/rpc/multitap/CMakeLists.txt new file mode 100644 index 00000000000..f4bd24120ae --- /dev/null +++ b/ee/rpc/multitap/CMakeLists.txt @@ -0,0 +1,6 @@ +add_library(multitap) +target_include_directories(multitap PUBLIC include) +target_include_directories(multitap PRIVATE ${EE_INC}) +target_sources(multitap PRIVATE src/libmtap.c src/erl-support.c) +install(TARGETS multitap) +target_add_erl(multitap) \ No newline at end of file diff --git a/ee/rpc/pad/CMakeLists.txt b/ee/rpc/pad/CMakeLists.txt new file mode 100644 index 00000000000..c904b67b99b --- /dev/null +++ b/ee/rpc/pad/CMakeLists.txt @@ -0,0 +1,14 @@ +add_library(pad) +target_include_directories(pad PUBLIC include) +target_include_directories(pad PRIVATE ${EE_INC}) +target_sources(pad PRIVATE src/libpad.c src/erl-support.c) +install(TARGETS pad) +target_add_erl(pad) + +add_library(padx) +target_include_directories(padx PUBLIC include) +target_include_directories(padx PRIVATE ${EE_INC}) +target_compile_definitions(padx PRIVATE _XPAD) +target_sources(padx PRIVATE src/libpad.c src/erl-support.c) +install(TARGETS padx) +target_add_erl(padx) \ No newline at end of file diff --git a/ee/rpc/poweroff/CMakeLists.txt b/ee/rpc/poweroff/CMakeLists.txt new file mode 100644 index 00000000000..ac1d9543e93 --- /dev/null +++ b/ee/rpc/poweroff/CMakeLists.txt @@ -0,0 +1,6 @@ +add_library(poweroff) +target_include_directories(poweroff PUBLIC include) +target_include_directories(poweroff PRIVATE ${EE_INC}) +target_sources(poweroff PRIVATE src/poweroff.c src/erl-support.c) +install(TARGETS poweroff) +target_add_erl(poweroff) \ No newline at end of file diff --git a/ee/rpc/ps2snd/CMakeLists.txt b/ee/rpc/ps2snd/CMakeLists.txt new file mode 100644 index 00000000000..99ef5d3851c --- /dev/null +++ b/ee/rpc/ps2snd/CMakeLists.txt @@ -0,0 +1,6 @@ +add_library(ps2snd) +target_include_directories(ps2snd PUBLIC include) +target_include_directories(ps2snd PRIVATE ${EE_INC}) +target_sources(ps2snd PRIVATE src/ps2snd.c src/erl-support.c) +install(TARGETS ps2snd) +target_add_erl(ps2snd) \ No newline at end of file diff --git a/ee/rpc/remote/CMakeLists.txt b/ee/rpc/remote/CMakeLists.txt new file mode 100644 index 00000000000..6fb6413477c --- /dev/null +++ b/ee/rpc/remote/CMakeLists.txt @@ -0,0 +1,6 @@ +add_library(remote) +target_include_directories(remote PUBLIC include) +target_include_directories(remote PRIVATE ${EE_INC}) +target_sources(remote PRIVATE src/librm.c src/erl-support.c) +install(TARGETS remote) +target_add_erl(remote) \ No newline at end of file diff --git a/ee/rpc/secr/CMakeLists.txt b/ee/rpc/secr/CMakeLists.txt new file mode 100644 index 00000000000..e9424278b42 --- /dev/null +++ b/ee/rpc/secr/CMakeLists.txt @@ -0,0 +1,6 @@ +add_library(secr) +target_include_directories(secr PUBLIC include) +target_include_directories(secr PRIVATE ${EE_INC}) +target_sources(secr PRIVATE src/libsecr.c src/erl-support.c) +install(TARGETS secr) +target_add_erl(secr) \ No newline at end of file diff --git a/ee/rpc/sior/CMakeLists.txt b/ee/rpc/sior/CMakeLists.txt new file mode 100644 index 00000000000..c624e27ed24 --- /dev/null +++ b/ee/rpc/sior/CMakeLists.txt @@ -0,0 +1,6 @@ +add_library(sior) +target_include_directories(sior PUBLIC include) +target_include_directories(sior PRIVATE ${EE_INC}) +target_sources(sior PRIVATE src/sior_rpc.c src/erl-support.c) +install(TARGETS sior) +target_add_erl(sior) \ No newline at end of file diff --git a/ee/rpc/tcpips/CMakeLists.txt b/ee/rpc/tcpips/CMakeLists.txt new file mode 100644 index 00000000000..83e9c30a049 --- /dev/null +++ b/ee/rpc/tcpips/CMakeLists.txt @@ -0,0 +1,7 @@ +add_library(ps2ips) +target_include_directories(ps2ips PUBLIC include) +target_include_directories(ps2ips PRIVATE ${EE_INC} src) +target_sources(ps2ips PRIVATE src/ps2ipc.c src/ps2ipc_ps2sdk.c src/erl-support.c) +target_link_libraries(ps2ips PRIVATE cglue) +install(TARGETS ps2ips) +target_add_erl(ps2ips) \ No newline at end of file From b8f02d85dc22bbca1b4bd9c8bef55f45559e344a Mon Sep 17 00:00:00 2001 From: Ziemas Date: Wed, 9 Oct 2024 09:24:12 +0200 Subject: [PATCH 16/21] cmake: build more libraries --- cmake/utils.cmake | 1 + ee/CMakeLists.txt | 6 +++++- ee/draw/CMakeLists.txt | 4 +--- ee/font/CMakeLists.txt | 17 +++++++++++++++++ ee/graph/CMakeLists.txt | 19 +++++++++++++++++++ ee/input/CMakeLists.txt | 36 ++++++++++++++++++++++++++++++++++++ ee/math3d/CMakeLists.txt | 16 ++++++++++++++++ 7 files changed, 95 insertions(+), 4 deletions(-) create mode 100644 ee/font/CMakeLists.txt create mode 100644 ee/graph/CMakeLists.txt create mode 100644 ee/input/CMakeLists.txt create mode 100644 ee/math3d/CMakeLists.txt diff --git a/cmake/utils.cmake b/cmake/utils.cmake index 5a0eafe282e..ab9af8b3dd0 100644 --- a/cmake/utils.cmake +++ b/cmake/utils.cmake @@ -1,3 +1,4 @@ +# TODO investigate using interface libraries, will help with erl generation # Compiles the same source file multiple times with different defines function(compile_multiple target srcfile) cmake_parse_arguments(PARSE_ARGV 2 "arg" "" "" "OBJECTS") diff --git a/ee/CMakeLists.txt b/ee/CMakeLists.txt index 7bbc0db1de9..c4962f40e8b 100644 --- a/ee/CMakeLists.txt +++ b/ee/CMakeLists.txt @@ -15,9 +15,13 @@ add_subdirectory(dma) add_subdirectory(draw) add_subdirectory(eedebug) add_subdirectory(elf-loader) -add_subdirectory(kernel) add_subdirectory(erl) +add_subdirectory(font) +add_subdirectory(graph) +add_subdirectory(input) +add_subdirectory(kernel) add_subdirectory(libcglue) +add_subdirectory(math3d) add_subdirectory(rpc) add_subdirectory(sbv) add_subdirectory(startup) diff --git a/ee/draw/CMakeLists.txt b/ee/draw/CMakeLists.txt index fde7eaf5117..5b75612bdc3 100644 --- a/ee/draw/CMakeLists.txt +++ b/ee/draw/CMakeLists.txt @@ -2,10 +2,8 @@ add_library(draw) target_include_directories(draw PUBLIC include) target_include_directories(draw PRIVATE ${EE_INC} - ${PROJECT_SOURCE_DIR}/math3d/include - ${PROJECT_SOURCE_DIR}/dma/include ) - +target_link_libraries(draw PRIVATE math3d dma) target_sources(draw PRIVATE src/draw_environment.c src/draw.c diff --git a/ee/font/CMakeLists.txt b/ee/font/CMakeLists.txt new file mode 100644 index 00000000000..dfe0f61d31a --- /dev/null +++ b/ee/font/CMakeLists.txt @@ -0,0 +1,17 @@ +add_library(font) +target_include_directories(font PUBLIC include) +target_include_directories(font PRIVATE + ${EE_INC} +) +target_link_libraries(font PRIVATE draw math3d) +target_sources(font PRIVATE + src/fontx.c + src/fsfont.c + src/erl-support.c +) + +file(GLOB FONT_INCLUDE_FILES "include/*.h*") +set_target_properties(font PROPERTIES PUBLIC_HEADER "${FONT_INCLUDE_FILES}") +install(TARGETS font) + +target_add_erl(font) \ No newline at end of file diff --git a/ee/graph/CMakeLists.txt b/ee/graph/CMakeLists.txt new file mode 100644 index 00000000000..e972b349764 --- /dev/null +++ b/ee/graph/CMakeLists.txt @@ -0,0 +1,19 @@ +add_library(graph) +target_include_directories(graph PUBLIC include) +target_include_directories(graph PRIVATE + ${EE_INC} +) +target_link_libraries(graph PRIVATE cdvd) +target_sources(graph PRIVATE + src/graph_config.c + src/graph_mode.c + src/graph_vram.c + src/graph.c + src/erl-support.c +) + +file(GLOB GRAPH_INCLUDE_FILES "include/*.h*") +set_target_properties(graph PROPERTIES PUBLIC_HEADER "${GRAPH_INCLUDE_FILES}") +install(TARGETS graph) + +target_add_erl(graph) \ No newline at end of file diff --git a/ee/input/CMakeLists.txt b/ee/input/CMakeLists.txt new file mode 100644 index 00000000000..6edf9c8eb6a --- /dev/null +++ b/ee/input/CMakeLists.txt @@ -0,0 +1,36 @@ +add_library(input) +target_include_directories(input PUBLIC include) +target_include_directories(input PRIVATE + ${EE_INC} +) + +target_link_libraries(input PRIVATE pad) + +target_sources(input PRIVATE + src/input.c + src/erl-support.c +) + +file(GLOB INPUT_INCLUDE_FILES "include/*.h*") +set_target_properties(input PROPERTIES PUBLIC_HEADER "${INPUT_INCLUDE_FILES}") +install(TARGETS input) + +target_add_erl(input) + +# inputx +add_library(inputx) +target_include_directories(inputx PUBLIC include) +target_include_directories(inputx PRIVATE + ${EE_INC} +) +target_compile_definitions(inputx PRIVATE _XINPUT) + +target_link_libraries(inputx PRIVATE pad multitap) + +target_sources(inputx PRIVATE + src/input.c + src/erl-support.c +) + +install(TARGETS inputx) +target_add_erl(inputx) \ No newline at end of file diff --git a/ee/math3d/CMakeLists.txt b/ee/math3d/CMakeLists.txt new file mode 100644 index 00000000000..3b4be279df3 --- /dev/null +++ b/ee/math3d/CMakeLists.txt @@ -0,0 +1,16 @@ +add_library(math3d) +target_include_directories(math3d PUBLIC include) +target_include_directories(math3d PRIVATE + ${EE_INC} +) +target_link_libraries(math3d PRIVATE graph) +target_sources(math3d PRIVATE + src/math3d.c + src/erl-support.c +) + +file(GLOB MATH3D_INCLUDE_FILES "include/*.h*") +set_target_properties(math3d PROPERTIES PUBLIC_HEADER "${MATH3D_INCLUDE_FILES}") +install(TARGETS math3d) + +target_add_erl(math3d) \ No newline at end of file From 10356390dec5c025cc0a6473a18ea05b174281b6 Mon Sep 17 00:00:00 2001 From: Ziemas Date: Wed, 23 Oct 2024 20:56:01 +0200 Subject: [PATCH 17/21] more libs --- ee/CMakeLists.txt | 7 +++++++ ee/iopreboot/CMakeLists.txt | 0 ee/libgs/CMakeLists.txt | 25 +++++++++++++++++++++++++ ee/libprofglue/CMakeLists.txt | 13 +++++++++++++ ee/libvux/CMakeLists.txt | 9 +++++++++ ee/mpeg/CMakeLists.txt | 9 +++++++++ ee/network/CMakeLists.txt | 2 ++ ee/packet/CMakeLists.txt | 9 +++++++++ ee/packet2/CMakeLists.txt | 9 +++++++++ 9 files changed, 83 insertions(+) create mode 100644 ee/iopreboot/CMakeLists.txt create mode 100644 ee/libgs/CMakeLists.txt create mode 100644 ee/libprofglue/CMakeLists.txt create mode 100644 ee/libvux/CMakeLists.txt create mode 100644 ee/mpeg/CMakeLists.txt create mode 100644 ee/network/CMakeLists.txt create mode 100644 ee/packet/CMakeLists.txt create mode 100644 ee/packet2/CMakeLists.txt diff --git a/ee/CMakeLists.txt b/ee/CMakeLists.txt index c4962f40e8b..a8179bf235e 100644 --- a/ee/CMakeLists.txt +++ b/ee/CMakeLists.txt @@ -21,7 +21,14 @@ add_subdirectory(graph) add_subdirectory(input) add_subdirectory(kernel) add_subdirectory(libcglue) +add_subdirectory(libgs) +add_subdirectory(libprofglue) +add_subdirectory(libvux) add_subdirectory(math3d) +add_subdirectory(mpeg) +add_subdirectory(network) +add_subdirectory(packet) +add_subdirectory(packet2) add_subdirectory(rpc) add_subdirectory(sbv) add_subdirectory(startup) diff --git a/ee/iopreboot/CMakeLists.txt b/ee/iopreboot/CMakeLists.txt new file mode 100644 index 00000000000..e69de29bb2d diff --git a/ee/libgs/CMakeLists.txt b/ee/libgs/CMakeLists.txt new file mode 100644 index 00000000000..37772c00161 --- /dev/null +++ b/ee/libgs/CMakeLists.txt @@ -0,0 +1,25 @@ +add_library(gs) +target_include_directories(gs PUBLIC include) +target_include_directories(gs PRIVATE + ${EE_INC} +) +target_sources(gs PRIVATE + src/dma.c + src/DoubleBuff.c + src/draw.c + src/libgs.c + src/lowlevel.c + src/packets.c + src/primitives.c + src/ResetPath.s + src/sync.c + src/texture.c + src/Zbuffer.c + src/erl-support.c +) + +file(GLOB GS_INCLUDE_FILES "include/*.h*") +set_target_properties(gs PROPERTIES PUBLIC_HEADER "${GS_INCLUDE_FILES}") +install(TARGETS gs) + +target_add_erl(gs) \ No newline at end of file diff --git a/ee/libprofglue/CMakeLists.txt b/ee/libprofglue/CMakeLists.txt new file mode 100644 index 00000000000..bc70856be5a --- /dev/null +++ b/ee/libprofglue/CMakeLists.txt @@ -0,0 +1,13 @@ +add_library(profglue) +target_include_directories(profglue PUBLIC include) +target_include_directories(profglue PRIVATE + ${EE_INC} +) +target_sources(profglue PRIVATE + src/mcount.S + src/prof.c +) + +file(GLOB PROFGLUE_INCLUDE_FILES "include/*.h*") +set_target_properties(profglue PROPERTIES PUBLIC_HEADER "${PROFGLUE_INCLUDE_FILES}") +install(TARGETS profglue) \ No newline at end of file diff --git a/ee/libvux/CMakeLists.txt b/ee/libvux/CMakeLists.txt new file mode 100644 index 00000000000..cf84d8aa3e5 --- /dev/null +++ b/ee/libvux/CMakeLists.txt @@ -0,0 +1,9 @@ +add_library(vux) +target_include_directories(vux PUBLIC include) +target_include_directories(vux PRIVATE ${EE_INC}) +target_sources(vux PRIVATE src/vuhw.c src/vusw.c src/vux.c src/erl-support.c) + +file(GLOB VUX_INCLUDE_FILES "include/*.h*") +set_target_properties(vux PROPERTIES PUBLIC_HEADER "${VUX_INCLUDE_FILES}") +install(TARGETS vux) +target_add_erl(vux) \ No newline at end of file diff --git a/ee/mpeg/CMakeLists.txt b/ee/mpeg/CMakeLists.txt new file mode 100644 index 00000000000..5f461caa1e0 --- /dev/null +++ b/ee/mpeg/CMakeLists.txt @@ -0,0 +1,9 @@ +add_library(mpeg) +target_include_directories(mpeg PUBLIC include) +target_include_directories(mpeg PRIVATE ${EE_INC}) +target_sources(mpeg PRIVATE src/libmpeg.c src/libmpeg_core_c.c src/erl-support.c) + +file(GLOB MPEG_INCLUDE_FILES "include/*.h*") +set_target_properties(mpeg PROPERTIES PUBLIC_HEADER "${MPEG_INCLUDE_FILES}") +install(TARGETS mpeg) +target_add_erl(mpeg) \ No newline at end of file diff --git a/ee/network/CMakeLists.txt b/ee/network/CMakeLists.txt new file mode 100644 index 00000000000..ad85a6abd68 --- /dev/null +++ b/ee/network/CMakeLists.txt @@ -0,0 +1,2 @@ +#add_subdirectory(netman) +#add_subdirectory(tcpip) \ No newline at end of file diff --git a/ee/packet/CMakeLists.txt b/ee/packet/CMakeLists.txt new file mode 100644 index 00000000000..e03a1fe305f --- /dev/null +++ b/ee/packet/CMakeLists.txt @@ -0,0 +1,9 @@ +add_library(packet) +target_include_directories(packet PUBLIC include) +target_include_directories(packet PRIVATE ${EE_INC}) +target_sources(packet PRIVATE src/packet.c src/erl-support.c) + +file(GLOB PACKET_INCLUDE_FILES "include/*.h*") +set_target_properties(packet PROPERTIES PUBLIC_HEADER "${PACKET_INCLUDE_FILES}") +install(TARGETS packet) +target_add_erl(packet) \ No newline at end of file diff --git a/ee/packet2/CMakeLists.txt b/ee/packet2/CMakeLists.txt new file mode 100644 index 00000000000..e5262f2aaa4 --- /dev/null +++ b/ee/packet2/CMakeLists.txt @@ -0,0 +1,9 @@ +add_library(packet2) +target_include_directories(packet2 PUBLIC include) +target_include_directories(packet2 PRIVATE ${EE_INC}) +target_sources(packet2 PRIVATE src/packet2.c src/packet2_vif.c src/erl-support.c) + +file(GLOB PACKET2_INCLUDE_FILES "include/*.h*") +set_target_properties(packet2 PROPERTIES PUBLIC_HEADER "${PACKET2_INCLUDE_FILES}") +install(TARGETS packet2) +target_add_erl(packet2) \ No newline at end of file From c238f352cc12c08eeeb96bd3aac8a1ae41ef3b02 Mon Sep 17 00:00:00 2001 From: Ziemas Date: Mon, 27 Jan 2025 00:24:52 +0100 Subject: [PATCH 18/21] cmake: build srxfixup --- tools/CMakeLists.txt | 3 ++- tools/srxfixup/CMakeLists.txt | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 tools/srxfixup/CMakeLists.txt diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt index 5a85e4a956a..44d52b9c4b5 100644 --- a/tools/CMakeLists.txt +++ b/tools/CMakeLists.txt @@ -6,4 +6,5 @@ add_subdirectory(bin2c) add_subdirectory(gensymtab) add_subdirectory(ps2-irxgen) add_subdirectory(ps2adpcm) -add_subdirectory(romimg) \ No newline at end of file +add_subdirectory(romimg) +add_subdirectory(srxfixup) diff --git a/tools/srxfixup/CMakeLists.txt b/tools/srxfixup/CMakeLists.txt new file mode 100644 index 00000000000..ec0a73fd23b --- /dev/null +++ b/tools/srxfixup/CMakeLists.txt @@ -0,0 +1,19 @@ +add_executable( + srxfixup + src/srxfixup.c + src/anaarg.c + src/ring.c + src/swapmem.c + src/elflib.c + src/elfdump.c + src/mipsdis.c + src/srxgen.c + src/readconf.c + src/iopfixconf.c + src/eefixconf.c) + +target_include_directories(srxfixup PRIVATE ./include) + + +# TODO make multiple copies and install +set(SRX_ADDITONAL_BIN eefixup erx-strip iopfixup irx-strip) From 5a4c388f41593c8d5bf6e5ab150d1b352140c641 Mon Sep 17 00:00:00 2001 From: Ziemas Date: Mon, 27 Jan 2025 06:27:02 +0100 Subject: [PATCH 19/21] cmake: build netman --- ee/network/CMakeLists.txt | 4 ++-- ee/network/netman/CMakeLists.txt | 7 +++++++ 2 files changed, 9 insertions(+), 2 deletions(-) create mode 100644 ee/network/netman/CMakeLists.txt diff --git a/ee/network/CMakeLists.txt b/ee/network/CMakeLists.txt index ad85a6abd68..bcbf944772c 100644 --- a/ee/network/CMakeLists.txt +++ b/ee/network/CMakeLists.txt @@ -1,2 +1,2 @@ -#add_subdirectory(netman) -#add_subdirectory(tcpip) \ No newline at end of file +add_subdirectory(netman) +#add_subdirectory(tcpip) diff --git a/ee/network/netman/CMakeLists.txt b/ee/network/netman/CMakeLists.txt new file mode 100644 index 00000000000..ec83a138dfe --- /dev/null +++ b/ee/network/netman/CMakeLists.txt @@ -0,0 +1,7 @@ +add_library(netman) +target_include_directories(netman PRIVATE ${EE_INC} src/include) +target_sources(netman PRIVATE src/netman.c src/rpc_server.c src/rpc_client.c + src/erl-support.c) + +install(TARGETS netman) +target_add_erl(netman) From 24a83596bb7aac35946dc6e6163d35a1cf6a223a Mon Sep 17 00:00:00 2001 From: Ziemas Date: Mon, 27 Jan 2025 06:28:12 +0100 Subject: [PATCH 20/21] cmake: improve compile_multiple --- cmake/utils.cmake | 12 ++-- ee/kernel/CMakeLists.txt | 118 ++++++++++++++++++++-------------- ee/libcglue/CMakeLists.txt | 38 ++++++----- ee/rpc/cdvd/CMakeLists.txt | 18 ++++-- ee/rpc/filexio/CMakeLists.txt | 16 +++-- 5 files changed, 117 insertions(+), 85 deletions(-) diff --git a/cmake/utils.cmake b/cmake/utils.cmake index ab9af8b3dd0..30a55832cb3 100644 --- a/cmake/utils.cmake +++ b/cmake/utils.cmake @@ -1,21 +1,19 @@ -# TODO investigate using interface libraries, will help with erl generation # Compiles the same source file multiple times with different defines -function(compile_multiple target srcfile) +function(compile_multiple objlist iface srcfile) cmake_parse_arguments(PARSE_ARGV 2 "arg" "" "" "OBJECTS") foreach(obj ${arg_OBJECTS}) add_library(${obj} OBJECT ${srcfile}) get_filename_component(def ${obj} NAME_WLE) target_compile_definitions(${obj} PRIVATE "F_${def}") - - get_target_property(target_id ${target} INCLUDE_DIRECTORIES) - target_include_directories(${obj} PRIVATE ${target_id}) - - target_link_libraries(${target} PRIVATE ${obj}) + target_link_libraries(${obj} PUBLIC ${iface}) + list(APPEND ${objlist} $) endforeach() + set(${objlist} "${${objlist}}" PARENT_SCOPE) endfunction() # Add an erl output for a given target +# TODO doesn't work with targets using compile_multiple function(target_add_erl target) add_custom_command(OUTPUT "lib${target}.erl" COMMAND ${CMAKE_C_COMPILER} -nostdlib -Wl,-r -Wl,-d -o "lib${target}.erl" $ diff --git a/ee/kernel/CMakeLists.txt b/ee/kernel/CMakeLists.txt index f14fd3df55c..4060048d7c2 100644 --- a/ee/kernel/CMakeLists.txt +++ b/ee/kernel/CMakeLists.txt @@ -5,35 +5,53 @@ add_subdirectory(src/osdsrc) add_subdirectory(src/srcfile) add_subdirectory(src/tlbsrc) -add_library(kernel) -target_include_directories(kernel PUBLIC include) -target_include_directories(kernel PRIVATE +add_library(kernel_iface INTERFACE) +target_include_directories(kernel_iface INTERFACE ${EE_INC} ${PROJECT_SOURCE_DIR}/rpc/cdvd/include ) -compile_multiple(kernel src/sifcmd.c OBJECTS - sif_cmd_send.o _sif_cmd_int_handler.o sif_cmd_main.o - sif_cmd_client.o sif_cmd_remove_cmdhandler.o sif_sreg_get.o +compile_multiple(KERNEL_OBJECTS kernel_iface src/sifcmd.c OBJECTS + _SifSendCmd.o + sceSifSendCmd.o + isceSifSendCmd.o + _SifCmdIntHandler.o + sif_cmd_main.o + sceSifSetCmdBuffer.o + sceSifSetSysCmdBuffer.o + sceSifAddCmdHandler.o + sceSifRemoveCmdHandler.o + sceSifGetSreg.o + sceSifSetSreg.o ) -compile_multiple(kernel src/sifrpc.c OBJECTS - SifBindRpc.o SifCallRpc.o SifRpcGetOtherData.o - SifRegisterRpc.o SifRemoveRpc.o SifSetRpcQueue.o SifRemoveRpcQueue.o SifGetNextRequest.o - SifExecRequest.o SifRpcLoop.o SifRpcMain.o _rpc_get_packet.o - _rpc_get_fpacket.o SifCheckStatRpc.o +compile_multiple(KERNEL_OBJECTS kernel_iface src/sifrpc.c OBJECTS + _rpc_get_packet.o + _rpc_get_fpacket.o + sceSifBindRpc.o + sceSifCallRpc.o + sceSifGetOtherData.o + SifRpcMain.o + sceSifRegisterRpc.o + sceSifRemoveRpc.o + sceSifSetRpcQueue.o + sceSifRemoveRpcQueue.o + sceSifGetNextRequest.o + sceSifExecRequest.o + sceSifRpcLoop.o + sceSifCheckStatRpc.o ) -compile_multiple(kernel src/fileio.c OBJECTS +compile_multiple(KERNEL_OBJECTS kernel_iface src/fileio.c OBJECTS __fio_internals.o fio_init.o _fio_intr.o fio_sync.o fio_setblockmode.o - fio_exit.o fio_open.o fio_close.o fio_read.o + fio_exit.o fio_open.o fio_close.o fio_read.o fio_write.o fio_lseek.o fio_mkdir.o _fio_read_intr.o fio_getc.o fio_putc.o fio_ioctl.o fio_dopen.o fio_dclose.o fio_dread.o fio_getstat.o fio_chstat.o fio_remove.o fio_format.o fio_rmdir.o fio_gets.o ) -compile_multiple(kernel src/loadfile.c OBJECTS - SifLoadFileInit.o SifLoadFileExit.o _SifLoadModule.o SifLoadModule.o +compile_multiple(KERNEL_OBJECTS kernel_iface src/loadfile.c OBJECTS + SifLoadFileInit.o SifLoadFileExit.o _SifLoadModule.o SifLoadModule.o SifLoadStartModule.o SifLoadModuleEncrypted.o SifStopModule.o SifUnloadModule.o SifSearchModuleByName.o SifSearchModuleByAddress.o _SifLoadElfPart.o SifLoadElfPart.o SifLoadElf.o SifLoadElfEncrypted.o SifIopSetVal.o SifIopGetVal.o @@ -41,31 +59,31 @@ compile_multiple(kernel src/loadfile.c OBJECTS SifExecModuleBuffer.o SifExecModuleFile.o ) -compile_multiple(kernel src/iopheap.c OBJECTS +compile_multiple(KERNEL_OBJECTS kernel_iface src/iopheap.c OBJECTS SifInitIopHeap.o SifExitIopHeap.o SifAllocIopHeap.o SifFreeIopHeap.o SifLoadIopHeap.o ) -compile_multiple(kernel src/iopcontrol.c OBJECTS +compile_multiple(KERNEL_OBJECTS kernel_iface src/iopcontrol.c OBJECTS SifIopReboot.o SifIopReset.o SifIopIsAlive.o SifIopSync.o __iop_control_internals.o ) -compile_multiple(kernel src/glue.c OBJECTS +compile_multiple(KERNEL_OBJECTS kernel_iface src/glue.c OBJECTS DIntr.o EIntr.o EnableIntc.o DisableIntc.o EnableDmac.o DisableDmac.o iEnableIntc.o iDisableIntc.o iEnableDmac.o iDisableDmac.o SyncDCache.o iSyncDCache.o InvalidDCache.o iInvalidDCache.o ) -compile_multiple(kernel src/sio.c OBJECTS +compile_multiple(KERNEL_OBJECTS kernel_iface src/sio.c OBJECTS sio_init.o sio_putc.o sio_getc.o sio_write.o sio_read.o sio_puts.o sio_gets.o sio_getc_block.o sio_flush.o sio_putsn.o ) -compile_multiple(kernel src/rom0_info.c OBJECTS +compile_multiple(KERNEL_OBJECTS kernel_iface src/rom0_info.c OBJECTS _info_internals.o GetRomNameWithIODriver.o GetRomName.o IsDESRMachineWithIODriver.o IsDESRMachine.o IsT10KWithIODriver.o IsT10K.0 ) -compile_multiple(kernel src/osd_config.c OBJECTS +compile_multiple(KERNEL_OBJECTS kernel_iface src/osd_config.c OBJECTS _config_internals.o converttobcd.o convertfrombcd.o __adjustTime.o IsEarlyJap.o configGetLanguageWithIODriver.o configGetLanguage.o configSetLanguageWithIODriver.o configSetLanguage.o @@ -84,25 +102,15 @@ compile_multiple(kernel src/osd_config.c OBJECTS configConvertToGmtTime.o configConvertToLocalTimeWithIODriver.o configConvertToLocalTime.o ) -bin_include(osdsrc osdsrc_bin) -target_sources(kernel PRIVATE src/libosd.c src/libosd_full.c src/libosd_common.c osdsrc_bin.c) - -bin_include(tlbsrc tlbsrc_bin) -target_sources(kernel PRIVATE src/tlbfunc.c tlbsrc_bin.c) - -bin_include(eenull eenull_bin) -bin_include(srcfile srcfile_bin) -target_sources(kernel PRIVATE src/alarm.c srcfile_bin.c) - -compile_multiple(kernel src/thread.c OBJECTS +compile_multiple(KERNEL_OBJECTS kernel_iface src/thread.c OBJECTS _thread_internals.o iWakeupThread.o iRotateThreadReadyQueue.o iSuspendThread.o) -compile_multiple(kernel src/setup.c OBJECTS kCopy.o kCopyBytes.o) +compile_multiple(KERNEL_OBJECTS kernel_iface src/setup.c OBJECTS kCopy.o kCopyBytes.o) -compile_multiple(kernel src/exit.c OBJECTS +compile_multiple(KERNEL_OBJECTS kernel_iface src/exit.c OBJECTS _exit_internals.o SetArg.o Exit.o ExecPS2.o LoadExecPS2.o ExecOSD.o) -compile_multiple(kernel src/timer.c OBJECTS +compile_multiple(KERNEL_OBJECTS kernel_iface src/timer.c OBJECTS timer_data.o SetT2.o SetT2_COUNT.o @@ -143,7 +151,7 @@ compile_multiple(kernel src/timer.c OBJECTS cpu_ticks.o ) -compile_multiple(kernel src/timer_alarm.c OBJECTS +compile_multiple(KERNEL_OBJECTS kernel_iface src/timer_alarm.c OBJECTS alarm_data.o ForTimer_InitAlarm.o AlarmHandler.o @@ -153,14 +161,14 @@ compile_multiple(kernel src/timer_alarm.c OBJECTS ReleaseTimerAlarm.o ) -compile_multiple(kernel src/delaythread.c OBJECTS DelayThread.o) +compile_multiple(KERNEL_OBJECTS kernel_iface src/delaythread.c OBJECTS DelayThread.o) -compile_multiple(kernel src/getkernel.c OBJECTS +compile_multiple(KERNEL_OBJECTS kernel_iface src/getkernel.c OBJECTS GetSyscallHandler.o GetSyscall.o GetExceptionHandler.o GetInterruptHandler.o) -compile_multiple(kernel src/initsys.c OBJECTS _InitSys.o TerminateLibrary.o) +compile_multiple(KERNEL_OBJECTS kernel_iface src/initsys.c OBJECTS _InitSys.o TerminateLibrary.o) -compile_multiple(kernel src/kernel_util.c OBJECTS WaitSemaEx.o) +compile_multiple(KERNEL_OBJECTS kernel_iface src/kernel_util.c OBJECTS WaitSemaEx.o) # IDK why these were on their own in the makefile, keep it for now set(EXEC_SYSCALLS KExit.o _LoadExecPS2.o _ExecPS2.o) @@ -172,7 +180,7 @@ set(IWAKEUP_THREAD_SYSCALL _iWakeupThread.o) set(ISUSPEND_THREAD_SYSCALL _iSuspendThread.o) set(TLB_SYSCALLS PutTLBEntry.o iPutTLBEntry.o _SetTLBEntry.o iSetTLBEntry.o GetTLBEntry.o iGetTLBEntry.o ProbeTLBEntry.o iProbeTLBEntry.o ExpandScratchPad.o) -compile_multiple(kernel src/kernel.S OBJECTS +compile_multiple(KERNEL_OBJECTS kernel_iface src/kernel.S OBJECTS ResetEE.o SetGsCrt.o ${EXEC_SYSCALLS} RFU009.o AddSbusIntcHandler.o RemoveSbusIntcHandler.o Interrupt2Iop.o SetVTLBRefillHandler.o SetVCommonHandler.o SetVInterruptHandler.o @@ -196,20 +204,34 @@ compile_multiple(kernel src/kernel.S OBJECTS EnableIntcHandler.o iEnableIntcHandler.o DisableIntcHandler.o iDisableIntcHandler.o EnableDmacHandler.o iEnableDmacHandler.o DisableDmacHandler.o iDisableDmacHandler.o KSeg0.o EnableCache.o DisableCache.o GetCop0.o FlushCache.o CpuConfig.o - iGetCop0.o iFlushCache.o RFU105.o iCpuConfig.o SifStopDma.o + iGetCop0.o iFlushCache.o RFU105.o iCpuConfig.o sceSifStopDma.o SetCPUTimerHandler.o SetCPUTimer.o SetOsdConfigParam2.o GetOsdConfigParam2.o GsGetIMR.o iGsGetIMR.o GsPutIMR.o iGsPutIMR.o - SetPgifHandler.o SetVSyncFlag.o SetSyscall.o SifDmaStat.o iSifDmaStat.o - SifSetDma.o iSifSetDma.o SifSetDChain.o iSifSetDChain.o SifSetReg.o - SifGetReg.o ${EXECOSD_SYSCALL} Deci2Call.o PSMode.o MachineType.o GetMemorySize.o _GetGsDxDyOffset.o - _InitTLB.o SetMemoryMode.o - SifWriteBackDCache.o _SyncDCache.o _InvalidDCache.o __errno.o errno.o + SetPgifHandler.o SetVSyncFlag.o SetSyscall.o sceSifDmaStat.o isceSifDmaStat.o + sceSifSetDma.o isceSifSetDma.o sceSifSetDChain.o isceSifSetDChain.o sceSifSetReg.o + sceSifGetReg.o ${EXECOSD_SYSCALL} Deci2Call.o PSMode.o MachineType.o GetMemorySize.o _GetGsDxDyOffset.o + _InitTLB.o SetMemoryMode.o GetMemoryMode.o + sceSifWriteBackDCache.o _SyncDCache.o _InvalidDCache.o __errno.o errno.o strncpy.o strlen.o memcpy.o memset.o __syscall.o GPfuncs.o _print.o ) +add_library(kernel ${KERNEL_OBJECTS}) +target_link_libraries(kernel PRIVATE kernel_iface) + +bin_include(osdsrc osdsrc_bin) +target_sources(kernel PRIVATE src/libosd.c src/libosd_full.c src/libosd_common.c osdsrc_bin.c) + +bin_include(tlbsrc tlbsrc_bin) +target_sources(kernel PRIVATE src/tlbfunc.c tlbsrc_bin.c) + +bin_include(eenull eenull_bin) +bin_include(srcfile srcfile_bin) +target_sources(kernel PRIVATE src/alarm.c srcfile_bin.c) + target_sources(kernel PRIVATE src/setup_syscalls.S src/debug.c src/erl-support.c) +target_include_directories(kernel PUBLIC include) file(GLOB KERNEL_INCLUDE_FILES "include/*.h*") set_target_properties(kernel PROPERTIES PUBLIC_HEADER "${KERNEL_INCLUDE_FILES}") -install(TARGETS kernel) \ No newline at end of file +install(TARGETS kernel) diff --git a/ee/libcglue/CMakeLists.txt b/ee/libcglue/CMakeLists.txt index 9ed864e4245..12092f5a23a 100644 --- a/ee/libcglue/CMakeLists.txt +++ b/ee/libcglue/CMakeLists.txt @@ -1,13 +1,11 @@ -add_library(cglue) -target_include_directories(cglue PUBLIC ${EE_INC} include) -target_sources(cglue PRIVATE src/rtc.c) -target_link_libraries(cglue PRIVATE kernel) +add_library(cglue_iface INTERFACE) +target_include_directories(cglue_iface INTERFACE ${EE_INC} include) -compile_multiple(cglue src/timezone.c OBJECTS +compile_multiple(CGLUE_OBJECTS cglue_iface src/timezone.c OBJECTS _libcglue_timezone_update.o ps2sdk_setTimezone.o ps2sdk_setDaylightSaving.o ) -compile_multiple(cglue src/fdman.c OBJECTS +compile_multiple(CGLUE_OBJECTS cglue_iface src/fdman.c OBJECTS __fdman_sema.o __descriptor_data_pool.o __descriptormap.o @@ -19,7 +17,7 @@ compile_multiple(cglue src/fdman.c OBJECTS __fdman_release_descriptor.o ) -compile_multiple(cglue src/init.c OBJECTS +compile_multiple(CGLUE_OBJECTS cglue_iface src/init.c OBJECTS __gprof_init.o __gprof_cleanup.o __libpthreadglue_init.o @@ -29,19 +27,19 @@ compile_multiple(cglue src/init.c OBJECTS _libcglue_args_parse.o ) -compile_multiple(cglue src/sleep.c OBJECTS +compile_multiple(CGLUE_OBJECTS cglue_iface src/sleep.c OBJECTS nanosleep.o ) -compile_multiple(cglue src/sjis.c OBJECTS +compile_multiple(CGLUE_OBJECTS cglue_iface src/sjis.c OBJECTS isSpecialSJIS.o isSpecialASCII.o strcpy_ascii.o strcpy_sjis.o ) -compile_multiple(cglue src/cwd.c OBJECTS +compile_multiple(CGLUE_OBJECTS cglue_iface src/cwd.c OBJECTS __cwd.o __cwd_len.o __get_drive.o getcwd.o __path_absolute.o __init_cwd.o ) -compile_multiple(cglue src/ps2sdkapi.c OBJECTS +compile_multiple(CGLUE_OBJECTS cglue_iface src/ps2sdkapi.c OBJECTS __fioOpsInitialize.o __fioOpenHelper.o __fioGetFdHelper.o @@ -63,7 +61,7 @@ compile_multiple(cglue src/ps2sdkapi.c OBJECTS _libcglue_fdman_inet_ops.o ) -compile_multiple(cglue src/glue.c OBJECTS +compile_multiple(CGLUE_OBJECTS cglue_iface src/glue.c OBJECTS __dummy_passwd.o __transform_errno.o __transform64_errno.o @@ -140,7 +138,7 @@ compile_multiple(cglue src/glue.c OBJECTS dup2.o ) -compile_multiple(cglue src/lock.c OBJECTS +compile_multiple(CGLUE_OBJECTS cglue_iface src/lock.c OBJECTS __lock___sfp_recursive_mutex.o __lock___atexit_recursive_mutex.o __lock___at_quick_exit_mutex.o @@ -163,7 +161,7 @@ compile_multiple(cglue src/lock.c OBJECTS __locks_deinit.o ) -compile_multiple(cglue src/netdb.c OBJECTS +compile_multiple(CGLUE_OBJECTS cglue_iface src/netdb.c OBJECTS gethostbyaddr.o gethostbyname.o gethostbyname_r.o @@ -171,11 +169,11 @@ compile_multiple(cglue src/netdb.c OBJECTS getaddrinfo.o ) -compile_multiple(cglue src/select.c OBJECTS +compile_multiple(CGLUE_OBJECTS cglue_iface src/select.c OBJECTS select.o ) -compile_multiple(cglue src/socket.c OBJECTS +compile_multiple(CGLUE_OBJECTS cglue_iface src/socket.c OBJECTS socket.o accept.o bind.o @@ -202,4 +200,10 @@ compile_multiple(cglue src/socket.c OBJECTS libcglue_dns_getserver.o ) -install(TARGETS cglue) \ No newline at end of file + +add_library(cglue ${CGLUE_OBJECTS}) +target_include_directories(cglue PUBLIC include) +target_sources(cglue PRIVATE src/rtc.c) +target_link_libraries(cglue PRIVATE kernel cglue_iface) + +install(TARGETS cglue) diff --git a/ee/rpc/cdvd/CMakeLists.txt b/ee/rpc/cdvd/CMakeLists.txt index 61e463b1bf5..b8b44ea9b7e 100644 --- a/ee/rpc/cdvd/CMakeLists.txt +++ b/ee/rpc/cdvd/CMakeLists.txt @@ -1,14 +1,14 @@ -add_library(cdvd) -target_include_directories(cdvd PUBLIC include) -target_include_directories(cdvd PRIVATE ${EE_INC}) +add_library(cdvd_iface INTERFACE) +target_include_directories(cdvd_iface INTERFACE include) +target_include_directories(cdvd_iface INTERFACE ${EE_INC}) -compile_multiple(cdvd src/libcdvd.c OBJECTS +compile_multiple(CDVD_OBJECTS cdvd_iface src/libcdvd.c OBJECTS _libcdvd_internals.o sceCdInit.o sceCdIntToPos.o sceCdPosToInt.o sceCdSearchFile.o sceCdDiskReady.o _CdSemaInit.o _CdSemaExit.o sceCdInitEeCB.o sceCdCallback.o _CdGenericCallbackFunction.o ) -compile_multiple(cdvd src/ncmd.c OBJECTS +compile_multiple(CDVD_OBJECTS cdvd_iface src/ncmd.c OBJECTS _ncmd_internals.o _CdAlignReadBuffer.o sceCdRead.o sceCdReadDVDV.o sceCdReadCDDA.o sceCdGetToc.o sceCdSeek.o sceCdStandby.o sceCdStop.o sceCdPause.o sceCdApplyNCmd.o sceCdReadIOPMem.o sceCdNCmdDiskReady.o @@ -17,7 +17,7 @@ compile_multiple(cdvd src/ncmd.c OBJECTS _CdCheckNCmd.o sceCdReadKey.o ) -compile_multiple(cdvd src/scmd.c OBJECTS +compile_multiple(CDVD_OBJECTS cdvd_iface src/scmd.c OBJECTS _scmd_internals.o sceCdReadClock.o ps2time.o sceCdWriteClock.o sceCdGetDiskType.o sceCdGetError.o sceCdTrayReq.o sceCdApplySCmd.o sceCdStatus.o sceCdBreak.o _CdCheckSCmd.o sceCdCtrlADout.o sceCdMV.o sceCdReadSUBQ.o @@ -28,6 +28,10 @@ compile_multiple(cdvd src/scmd.c OBJECTS _CdSyncS.o ) +add_library(cdvd ${CDVD_OBJECTS}) +target_link_libraries(cdvd PRIVATE cdvd_iface) +target_include_directories(cdvd PUBLIC include) + target_sources(cdvd PRIVATE src/erl-support.c) install(TARGETS cdvd) -#target_add_erl(cdvd) TODO doesn't work with the object libraries \ No newline at end of file +#target_add_erl(cdvd) TODO doesn't work with the object libraries diff --git a/ee/rpc/filexio/CMakeLists.txt b/ee/rpc/filexio/CMakeLists.txt index a76a91c6759..c1f1bede606 100644 --- a/ee/rpc/filexio/CMakeLists.txt +++ b/ee/rpc/filexio/CMakeLists.txt @@ -1,8 +1,8 @@ -add_library(fileXio) -target_include_directories(fileXio PUBLIC include) -target_include_directories(fileXio PRIVATE ${EE_INC} ${PROJECT_SOURCE_DIR}/libcglue/include) +add_library(fileXio_iface INTERFACE) +target_include_directories(fileXio_iface INTERFACE include) +target_include_directories(fileXio_iface INTERFACE ${EE_INC} ${PROJECT_SOURCE_DIR}/libcglue/include) -compile_multiple(fileXio src/fileXio_rpc.c OBJECTS +compile_multiple(FILEXIO_OBJECTS fileXio_iface src/fileXio_rpc.c OBJECTS __cd0.o __sbuff.o __intr_data.o __fileXioInited.o __fileXioBlockMode.o __fileXioCompletionSema.o __lock_sema_id.o fileXioInit.o fileXioExit.o fileXioStop.o fileXioGetDeviceList.o fileXioGetdir.o fileXioMount.o fileXioUmount.o fileXioCopyfile.o fileXioMkdir.o fileXioRmdir.o fileXioRemove.o fileXioRename.o fileXioSymlink.o fileXioReadlink.o @@ -11,7 +11,7 @@ compile_multiple(fileXio src/fileXio_rpc.c OBJECTS fileXioIoctl.o fileXioIoctl2.o fileXioWaitAsync.o fileXioSetBlockMode.o fileXioSetRWBufferSize.o ) -compile_multiple(fileXio src/fileXio_ps2sdk.c OBJECTS +compile_multiple(FILEXIO_OBJECTS fileXio_iface src/fileXio_ps2sdk.c OBJECTS __fileXioOpsInitialize.o __fileXioOpenHelper.o __fileXioGetFdHelper.o @@ -31,5 +31,9 @@ compile_multiple(fileXio src/fileXio_ps2sdk.c OBJECTS _ps2sdk_fileXio_init_deinit.o ) +add_library(fileXio ${FILEXIO_OBJECTS}) +target_link_libraries(fileXio PRIVATE fileXio_iface) +target_include_directories(fileXio PUBLIC include) + target_sources(fileXio PRIVATE src/erl-support.c) -install(TARGETS fileXio) \ No newline at end of file +install(TARGETS fileXio) From 70f2141224f8ae78b38be35791789ce69d8292aa Mon Sep 17 00:00:00 2001 From: Ziemas Date: Mon, 27 Jan 2025 06:28:42 +0100 Subject: [PATCH 21/21] cmake: fix elf-loader --- ee/elf-loader/CMakeLists.txt | 2 +- ee/elf-loader/src/loader/CMakeLists.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ee/elf-loader/CMakeLists.txt b/ee/elf-loader/CMakeLists.txt index 86f9b80f415..0bff60d1d1b 100644 --- a/ee/elf-loader/CMakeLists.txt +++ b/ee/elf-loader/CMakeLists.txt @@ -16,4 +16,4 @@ file(GLOB elf-loader_INCLUDE_FILES "include/*.h*") set_target_properties(elf-loader PROPERTIES PUBLIC_HEADER "${elf-loader_INCLUDE_FILES}") install(TARGETS elf-loader) -target_add_erl(elf-loader) \ No newline at end of file +target_add_erl(elf-loader) diff --git a/ee/elf-loader/src/loader/CMakeLists.txt b/ee/elf-loader/src/loader/CMakeLists.txt index a07e26a294c..92268be8bb3 100644 --- a/ee/elf-loader/src/loader/CMakeLists.txt +++ b/ee/elf-loader/src/loader/CMakeLists.txt @@ -2,4 +2,4 @@ add_executable(loader) target_sources(loader PRIVATE src/loader.c) target_include_directories(loader PRIVATE ${EE_INC}) target_link_libraries(loader PRIVATE kernel cglue) -target_link_options(loader PRIVATE -T${CMAKE_CURRENT_SOURCE_DIR}/linkfile) \ No newline at end of file +target_link_options(loader PRIVATE -nodefaultlibs -lc_nano -lgcc -lm_nano -T${CMAKE_CURRENT_SOURCE_DIR}/linkfile)