// Vita3K emulator project
// Copyright (C) 2026 Vita3K team
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License along
// with this program; if not, write to the Free Software Foundation, Inc.,
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

#include <module/module.h>

#include <kernel/state.h>

#include "../SceDisplay/SceDisplay.h"

TRACY_MODULE_NAME(SceVshBridge);

EXPORT(int, _vshAppMgrAcInstGetAcdirParam) {
    return UNIMPLEMENTED();
}

EXPORT(int, _vshAppMgrBgdlSetQueueStatus) {
    return UNIMPLEMENTED();
}

EXPORT(int, _vshAppMgrCheckPfsMounted) {
    return UNIMPLEMENTED();
}

EXPORT(int, _vshAppMgrCloudDataCreateHeader) {
    return UNIMPLEMENTED();
}

EXPORT(int, _vshAppMgrCloudDataDstCreateMount) {
    return UNIMPLEMENTED();
}

EXPORT(int, _vshAppMgrCloudDataGetMcId) {
    return UNIMPLEMENTED();
}

EXPORT(int, _vshAppMgrCloudDataSetMcId) {
    return UNIMPLEMENTED();
}

EXPORT(int, _vshAppMgrCloudDataSetupKey) {
    return UNIMPLEMENTED();
}

EXPORT(int, _vshAppMgrCloudDataSrcMount) {
    return UNIMPLEMENTED();
}

EXPORT(int, _vshAppMgrCloudDataVerifyHeader) {
    return UNIMPLEMENTED();
}

EXPORT(int, _vshAppMgrFakeSaveDataCreateMount) {
    return UNIMPLEMENTED();
}

EXPORT(int, _vshAppMgrIsExclusiveProcessRunning) {
    return UNIMPLEMENTED();
}

EXPORT(int, _vshAppMgrLocalBackupGetOfflineId) {
    return UNIMPLEMENTED();
}

EXPORT(int, _vshAppMgrLocalBackupVerifyOfflineHeader) {
    return UNIMPLEMENTED();
}

EXPORT(int, _vshAppMgrRegisterPath) {
    return UNIMPLEMENTED();
}

EXPORT(int, _vshAppMgrSaveDataLocalBackupTargetGetList) {
    return UNIMPLEMENTED();
}

EXPORT(int, _vshAppMgrSaveDataLocalBackupTargetRemoveItem) {
    return UNIMPLEMENTED();
}

EXPORT(int, _vshAppMgrSaveDataNotifyBackupFinished) {
    return UNIMPLEMENTED();
}

EXPORT(int, _vshAppMgrSystemParamDateTimeSetConf) {
    return UNIMPLEMENTED();
}

EXPORT(int, _vshAppMgrUpdateRifInfo) {
    return UNIMPLEMENTED();
}

EXPORT(int, _vshCoredumpCafCreateIv) {
    return UNIMPLEMENTED();
}

EXPORT(int, _vshCoredumpCafHeaderFinal) {
    return UNIMPLEMENTED();
}

EXPORT(int, _vshCoredumpCafHeaderTransform) {
    return UNIMPLEMENTED();
}

EXPORT(int, _vshCoredumpCafSegmentFinal) {
    return UNIMPLEMENTED();
}

EXPORT(int, _vshCoredumpCafSegmentInit) {
    return UNIMPLEMENTED();
}

EXPORT(int, _vshCoredumpCafSegmentTransform) {
    return UNIMPLEMENTED();
}

EXPORT(int, _vshCoredumpCreateDump) {
    return UNIMPLEMENTED();
}

EXPORT(int, _vshDisplayGetActualViewportConf) {
    return UNIMPLEMENTED();
}

EXPORT(int, _vshDisplaySetViewportConf) {
    return UNIMPLEMENTED();
}

EXPORT(int, _vshEventLogPut) {
    return UNIMPLEMENTED();
}

EXPORT(int, _vshIdStorageCreateAtomicLeaves) {
    return UNIMPLEMENTED();
}

EXPORT(int, _vshIoChstat) {
    return UNIMPLEMENTED();
}

EXPORT(int, _vshIoDread) {
    return UNIMPLEMENTED();
}

EXPORT(int, _vshIoGetstat) {
    return UNIMPLEMENTED();
}

EXPORT(int, _vshIoMount) {
    return UNIMPLEMENTED();
}

EXPORT(int, _vshKernelGetCompiledSdkVersionByPid) {
    return UNIMPLEMENTED();
}

EXPORT(SceUID, _vshKernelSearchModuleByName, const char *module_name, const void *buffer) {
    TRACY_FUNC(_vshKernelSearchModuleByName, module_name, buffer);
    if (!module_name)
        return RET_ERROR(SCE_KERNEL_ERROR_ILLEGAL_ADDR);

    const std::lock_guard<std::mutex> lock(emuenv.kernel.mutex);
    for (const auto &[uid, mod] : emuenv.kernel.loaded_modules) {
        if (strcmp(mod->info.module_name, module_name) == 0)
            return uid;
    }
    return RET_ERROR(SCE_KERNEL_ERROR_MODULEMGR_NO_MOD);
}

EXPORT(int, _vshKernelShutdownSystem) {
    return UNIMPLEMENTED();
}

EXPORT(int, _vshLedSetMode) {
    return UNIMPLEMENTED();
}

EXPORT(int, _vshNpDrmEbootSigConvert) {
    return UNIMPLEMENTED();
}

EXPORT(int, _vshNpDrmEbootSigGenMultiDisc) {
    return UNIMPLEMENTED();
}

EXPORT(int, _vshNpDrmEbootSigGenPs1) {
    return UNIMPLEMENTED();
}

EXPORT(int, _vshNpDrmEbootSigGenPsp) {
    return UNIMPLEMENTED();
}

EXPORT(int, _vshNpDrmEbootSigVerify) {
    return UNIMPLEMENTED();
}

EXPORT(int, _vshNpDrmGetLegacyDocKey) {
    return UNIMPLEMENTED();
}

EXPORT(int, _vshNpDrmPspEbootSigGen) {
    return UNIMPLEMENTED();
}

EXPORT(int, _vshNpDrmPspEbootVerify) {
    return UNIMPLEMENTED();
}

EXPORT(int, _vshPowerSetBatteryFakeStatus) {
    return UNIMPLEMENTED();
}

EXPORT(int, _vshRtcGetAlarmTick) {
    return UNIMPLEMENTED();
}

EXPORT(int, _vshRtcGetCurrentSecureTick) {
    return UNIMPLEMENTED();
}

EXPORT(int, _vshRtcGetSecureAlarmTick) {
    return UNIMPLEMENTED();
}

EXPORT(int, _vshRtcSetAlarmTick) {
    return UNIMPLEMENTED();
}

EXPORT(int, _vshRtcSetCurrentDebugNetworkTick) {
    return UNIMPLEMENTED();
}

EXPORT(int, _vshRtcSetCurrentNetworkTick) {
    return UNIMPLEMENTED();
}

EXPORT(int, _vshRtcSetCurrentSecureTick) {
    return UNIMPLEMENTED();
}

EXPORT(int, _vshRtcSetCurrentTick) {
    return UNIMPLEMENTED();
}

EXPORT(int, _vshRtcSetSecureAlarmTick) {
    return UNIMPLEMENTED();
}

EXPORT(int, _vshSDfCtlSetBootParameter) {
    return UNIMPLEMENTED();
}

EXPORT(int, _vshSblAimgrGetConsoleId) {
    return UNIMPLEMENTED();
}

EXPORT(int, _vshSblAimgrGetPscode) {
    return UNIMPLEMENTED();
}

EXPORT(int, _vshSblAimgrGetPscode2) {
    return UNIMPLEMENTED();
}

EXPORT(int, _vshSblAimgrGetSMI) {
    return UNIMPLEMENTED();
}

EXPORT(int, _vshSblAimgrGetVisibleId) {
    return UNIMPLEMENTED();
}

EXPORT(int, _vshSblAuthMgrVerifySpsfo) {
    return UNIMPLEMENTED();
}

EXPORT(int, _vshSblGcAuthMgrMlnpsnlAuth1) {
    return UNIMPLEMENTED();
}

EXPORT(int, _vshSblGcAuthMgrMlnpsnlAuth2) {
    return UNIMPLEMENTED();
}

EXPORT(int, _vshSblGetSystemSwVersion) {
    return UNIMPLEMENTED();
}

EXPORT(int, _vshSblSsCreatePassPhrase) {
    return UNIMPLEMENTED();
}

EXPORT(int, _vshSblSsDecryptWithPortability) {
    return UNIMPLEMENTED();
}

EXPORT(int, _vshSblSsEncryptWithPortability) {
    return UNIMPLEMENTED();
}

EXPORT(int, _vshSblSsGenerateAppKey) {
    return UNIMPLEMENTED();
}

EXPORT(int, _vshSblSsGetNvsData) {
    return UNIMPLEMENTED();
}

EXPORT(int, _vshSblSsSetNvsData) {
    return UNIMPLEMENTED();
}

EXPORT(int, _vshSysconCtrlManualChargeMode) {
    return UNIMPLEMENTED();
}

EXPORT(int, _vshSysconGetHardwareInfo) {
    return UNIMPLEMENTED();
}

EXPORT(int, _vshSysconGetHardwareInfo2) {
    return UNIMPLEMENTED();
}

EXPORT(int, _vshSysconGetManualChargeMode) {
    return UNIMPLEMENTED();
}

EXPORT(int, _vshSysconGetManufacturesStatus) {
    return UNIMPLEMENTED();
}

EXPORT(int, _vshSysconGetTemperatureLog) {
    return UNIMPLEMENTED();
}

EXPORT(int, _vshSysconGetUsbDetStatus) {
    return UNIMPLEMENTED();
}

EXPORT(int, _vshSysconLogReadData) {
    return UNIMPLEMENTED();
}

EXPORT(int, _vshTouchSetTouchEmulationData) {
    return UNIMPLEMENTED();
}

EXPORT(int, vshAppMgrCheckContentInstallPeriod) {
    return UNIMPLEMENTED();
}

EXPORT(int, vshAppMgrCloudDataClearMcId) {
    return UNIMPLEMENTED();
}

EXPORT(int, vshAppMgrDebugSettingNotifyUpdate) {
    return UNIMPLEMENTED();
}

EXPORT(int, vshAppMgrGetPfsProcessStatus) {
    return UNIMPLEMENTED();
}

EXPORT(int, vshCoredumpCafContextCreate) {
    return UNIMPLEMENTED();
}

EXPORT(int, vshCoredumpCafContextDestroy) {
    return UNIMPLEMENTED();
}

EXPORT(int, vshCoredumpCafFinal) {
    return UNIMPLEMENTED();
}

EXPORT(int, vshCoredumpCafHeaderInit) {
    return UNIMPLEMENTED();
}

EXPORT(int, vshCoredumpCafInit) {
    return UNIMPLEMENTED();
}

EXPORT(int, vshCoredumpDeleteCrashReportCaf) {
    return UNIMPLEMENTED();
}

EXPORT(int, vshCtrlChangePortAssign) {
    return UNIMPLEMENTED();
}

EXPORT(int, vshCtrlGetActiveControllerPort) {
    return UNIMPLEMENTED();
}

EXPORT(int, vshCtrlIsBdRemoconConnected) {
    return UNIMPLEMENTED();
}

EXPORT(int, vshCtrlRegisterNotifyCallBack) {
    return UNIMPLEMENTED();
}

EXPORT(int, vshCtrlSetIdleCancelKey) {
    return UNIMPLEMENTED();
}

EXPORT(int, vshCtrlSetIdleCancelThreshold) {
    return UNIMPLEMENTED();
}

EXPORT(int, vshCtrlSetTurnOffInterval) {
    return UNIMPLEMENTED();
}

EXPORT(int, vshCtrlSetVibrationSetting) {
    return UNIMPLEMENTED();
}

EXPORT(int, vshCtrlUnregisterNotifyCallBack) {
    return UNIMPLEMENTED();
}

EXPORT(SceInt32, vshDisplayRegisterFrameBufCallback, SceUID uid) {
    return CALL_EXPORT(sceDisplayRegisterVblankStartCallback, uid);
}

EXPORT(int, vshDisplaySetInvertColors) {
    return UNIMPLEMENTED();
}

EXPORT(int, vshHdmiCecCmdForcedPollingMsg) {
    return UNIMPLEMENTED();
}

EXPORT(int, vshHdmiDisableCec) {
    return UNIMPLEMENTED();
}

EXPORT(int, vshHdmiEnableCec) {
    return UNIMPLEMENTED();
}

EXPORT(int, vshIdStorageCreateLeaf) {
    return UNIMPLEMENTED();
}

EXPORT(int, vshIdStorageDeleteLeaf) {
    return UNIMPLEMENTED();
}

EXPORT(int, vshIdStorageFlush) {
    return UNIMPLEMENTED();
}

EXPORT(int, vshIdStorageFormat) {
    return UNIMPLEMENTED();
}

EXPORT(int, vshIdStorageGetFreeLeaves) {
    return UNIMPLEMENTED();
}

EXPORT(int, vshIdStorageGetLeafSize) {
    return UNIMPLEMENTED();
}

EXPORT(int, vshIdStorageIsDirty) {
    return UNIMPLEMENTED();
}

EXPORT(int, vshIdStorageIsFormatted) {
    return UNIMPLEMENTED();
}

EXPORT(int, vshIdStorageIsReadOnly) {
    return UNIMPLEMENTED();
}

EXPORT(int, vshIdStorageLookup) {
    return UNIMPLEMENTED();
}

EXPORT(int, vshIdStorageReadLeaf) {
    return UNIMPLEMENTED();
}

EXPORT(int, vshIdStorageRestart) {
    return UNIMPLEMENTED();
}

EXPORT(int, vshIdStorageUnformat) {
    return UNIMPLEMENTED();
}

EXPORT(int, vshIdStorageUpdate) {
    return UNIMPLEMENTED();
}

EXPORT(int, vshIdStorageWriteLeaf) {
    return UNIMPLEMENTED();
}

EXPORT(int, vshIoClearErrorEvent) {
    return UNIMPLEMENTED();
}

EXPORT(int, vshIoCreateErrorEvent) {
    return UNIMPLEMENTED();
}

EXPORT(int, vshIoCreateMountEvent) {
    return UNIMPLEMENTED();
}

EXPORT(int, vshIoDeleteErrorEvent) {
    return UNIMPLEMENTED();
}

EXPORT(int, vshIoDeleteMountEvent) {
    return UNIMPLEMENTED();
}

EXPORT(int, vshIoFlock) {
    return UNIMPLEMENTED();
}

EXPORT(int, vshIoGetProcessDefaultPriorityForSystem) {
    return UNIMPLEMENTED();
}

EXPORT(int, vshIoSetProcessDefaultPriorityForSystem) {
    return UNIMPLEMENTED();
}

EXPORT(int, vshIoUmount) {
    return UNIMPLEMENTED();
}

EXPORT(int, vshKernelCheckModelCapability) {
    return UNIMPLEMENTED();
}

EXPORT(int, vshKernelDisableAutoClockDown) {
    return UNIMPLEMENTED();
}

EXPORT(int, vshKernelEnableAutoClockDown) {
    return UNIMPLEMENTED();
}

EXPORT(int, vshKernelSendSysEvent) {
    return UNIMPLEMENTED();
}

EXPORT(int, vshMemoryCardEnableSlowMode) {
    return UNIMPLEMENTED();
}

EXPORT(int, vshMemoryCardGetCardInsertState) {
    return UNIMPLEMENTED();
}

EXPORT(int, vshMotionNoiseFilterIsAvailable) {
    return UNIMPLEMENTED();
}

EXPORT(int, vshMsifGetMsInfo) {
    return UNIMPLEMENTED();
}

EXPORT(int, vshNpDrmIsLooseAccountBind) {
    return UNIMPLEMENTED();
}

EXPORT(int, vshNpDrmUpdateAccountId) {
    return UNIMPLEMENTED();
}

EXPORT(int, vshNpDrmUpdateDebugSettings) {
    return UNIMPLEMENTED();
}

EXPORT(int, vshPowerGetWakeupFactor) {
    return UNIMPLEMENTED();
}

EXPORT(int, vshPowerRequestColdReset) {
    return UNIMPLEMENTED();
}

EXPORT(int, vshPowerRequestHibernate) {
    return UNIMPLEMENTED();
}

EXPORT(int, vshPowerSetPowerSwMode) {
    return UNIMPLEMENTED();
}

EXPORT(int, vshPowerSetPsButtonPushTime) {
    return UNIMPLEMENTED();
}

EXPORT(int, vshPowerSetStandbyButtonPushTime) {
    return UNIMPLEMENTED();
}

EXPORT(int, vshRemovableMemoryGetCardInsertState) {
    return UNIMPLEMENTED();
}

EXPORT(int, vshRtcIsAlarmed) {
    return UNIMPLEMENTED();
}

EXPORT(int, vshRtcIsSecureAlarmed) {
    return UNIMPLEMENTED();
}

EXPORT(int, vshRtcRegisterCallback) {
    return UNIMPLEMENTED();
}

EXPORT(int, vshRtcRegisterSecureAlarmCallback) {
    return UNIMPLEMENTED();
}

EXPORT(int, vshRtcSetConf) {
    return UNIMPLEMENTED();
}

EXPORT(int, vshRtcUnregisterCallback) {
    return UNIMPLEMENTED();
}

EXPORT(int, vshRtcUnregisterSecureAlarmCallback) {
    return UNIMPLEMENTED();
}

EXPORT(int, vshSblACMgrHasCapability) {
    return UNIMPLEMENTED();
}

EXPORT(int, vshSblAimgrIsCEX) {
    return UNIMPLEMENTED();
}

EXPORT(int, vshSblAimgrIsDEX) {
    return UNIMPLEMENTED();
}

EXPORT(int, vshSblAimgrIsDolce) {
    return UNIMPLEMENTED();
}

EXPORT(int, vshSblAimgrIsGenuineDolce) {
    return UNIMPLEMENTED();
}

EXPORT(int, vshSblAimgrIsGenuineVITA) {
    return UNIMPLEMENTED();
}

EXPORT(int, vshSblAimgrIsTest) {
    return UNIMPLEMENTED();
}

EXPORT(int, vshSblAimgrIsTool) {
    return UNIMPLEMENTED();
}

EXPORT(int, vshSblAimgrIsVITA) {
    return UNIMPLEMENTED();
}

EXPORT(int, vshSblPmMgrSetSdModeOff) {
    return UNIMPLEMENTED();
}

EXPORT(int, vshSblQafMgrIsAllowControlIduAutoUpdate) {
    return UNIMPLEMENTED();
}

EXPORT(int, vshSblQafMgrIsAllowDtcpIpReset) {
    return UNIMPLEMENTED();
}

EXPORT(int, vshSblQafMgrIsAllowFakeACInstall) {
    return UNIMPLEMENTED();
}

EXPORT(int, vshSblQafMgrIsAllowKeepCoreFile) {
    return UNIMPLEMENTED();
}

EXPORT(int, vshSblQafMgrIsAllowLiblocationChangeModel) {
    return UNIMPLEMENTED();
}

EXPORT(int, vshSblQafMgrIsAllowLoadMagicGate) {
    return UNIMPLEMENTED();
}

EXPORT(int, vshSblQafMgrIsAllowLoadPSPEmuWhiteList) {
    return UNIMPLEMENTED();
}

EXPORT(int, vshSblQafMgrIsAllowMarlinTest) {
    return UNIMPLEMENTED();
}

EXPORT(int, vshSblQafMgrIsAllowNearTest) {
    return UNIMPLEMENTED();
}

EXPORT(int, vshSblQafMgrIsAllowPSPEmuDeleteParameter) {
    return UNIMPLEMENTED();
}

EXPORT(int, vshSblQafMgrIsAllowPSPEmuScreenShot) {
    return UNIMPLEMENTED();
}

EXPORT(int, vshSblQafMgrIsAllowPSPEmuSelectNPEnv) {
    return UNIMPLEMENTED();
}

EXPORT(int, vshSblQafMgrIsAllowPSPEmuShowQAInfo) {
    return UNIMPLEMENTED();
}

EXPORT(int, vshSblQafMgrIsAllowRemotePlayDebug) {
    return UNIMPLEMENTED();
}

EXPORT(int, vshSblQafMgrIsAllowShowTitleUpgradeInfo) {
    return UNIMPLEMENTED();
}

EXPORT(int, vshSblQafMgrIsAllowSystemAppDebug) {
    return UNIMPLEMENTED();
}

EXPORT(int, vshSblSsIsDevelopmentMode) {
    return UNIMPLEMENTED();
}

EXPORT(int, vshSblUtMgrHasComTestFlag) {
    return UNIMPLEMENTED();
}

EXPORT(int, vshSblUtMgrHasNpTestFlag) {
    return UNIMPLEMENTED();
}

EXPORT(int, vshSblUtMgrHasStoreFlag) {
    return UNIMPLEMENTED();
}

EXPORT(int, vshSdGetCardInfo) {
    return UNIMPLEMENTED();
}

EXPORT(int, vshSysconBeginConfigstorageTransaction) {
    return UNIMPLEMENTED();
}

EXPORT(int, vshSysconClearTemperatureLog) {
    return UNIMPLEMENTED();
}

EXPORT(int, vshSysconCommitConfigstorageTransaction) {
    return UNIMPLEMENTED();
}

EXPORT(int, vshSysconEnableHibernateIO) {
    return UNIMPLEMENTED();
}

EXPORT(int, vshSysconEndConfigstorageTransaction) {
    return UNIMPLEMENTED();
}

EXPORT(int, vshSysconGetBatteryCalibData) {
    return UNIMPLEMENTED();
}

EXPORT(int, vshSysconGetLogInfo) {
    return UNIMPLEMENTED();
}

EXPORT(int, vshSysconHasWWAN) {
    return UNIMPLEMENTED();
}

EXPORT(int, vshSysconIduModeClear) {
    return UNIMPLEMENTED();
}

EXPORT(int, vshSysconIduModeSet) {
    return UNIMPLEMENTED();
}

EXPORT(int, vshSysconIsDownLoaderMode) {
    return UNIMPLEMENTED();
}

EXPORT(int, vshSysconIsIduMode) {
    return emuenv.cfg.demo_mode ? 1 : 0;
}

EXPORT(int, vshSysconIsMCEmuCapable) {
    return UNIMPLEMENTED();
}

EXPORT(int, vshSysconIsShowMode) {
    return emuenv.cfg.show_mode ? 1 : 0;
}

EXPORT(int, vshSysconLoadConfigstorageScript) {
    return UNIMPLEMENTED();
}

EXPORT(int, vshSysconLogStart) {
    return UNIMPLEMENTED();
}

EXPORT(int, vshSysconLogStartWaiting) {
    return UNIMPLEMENTED();
}

EXPORT(int, vshSysconShowModeClear) {
    return UNIMPLEMENTED();
}

EXPORT(int, vshSysconShowModeSet) {
    return UNIMPLEMENTED();
}

EXPORT(int, vshSysconVerifyConfigstorageScript) {
    return UNIMPLEMENTED();
}
