public static Horizon CreateBasicHorizon() { IFileSystem rootFs = new InMemoryFileSystem(); var keySet = new KeySet(); var horizon = new Horizon(new HorizonConfiguration()); HorizonClient fsServerClient = horizon.CreatePrivilegedHorizonClient(); var fsServer = new FileSystemServer(fsServerClient); var defaultObjects = DefaultFsServerObjects.GetDefaultEmulatedCreators(rootFs, keySet, fsServer); var config = new FileSystemServerConfig(); config.FsCreators = defaultObjects.FsCreators; config.DeviceOperator = defaultObjects.DeviceOperator; config.ExternalKeySet = new ExternalKeySet(); FileSystemServerInitializer.InitializeWithConfig(fsServerClient, fsServer, config); HorizonClient bcatServerClient = horizon.CreateHorizonClient(); _ = new BcatServer(bcatServerClient); return(horizon); }
public static Horizon CreateWithDefaultFsConfig(HorizonConfiguration config, IFileSystem rootFileSystem, KeySet keySet) { var horizon = new Horizon(config); HorizonClient fsServerClient = horizon.CreatePrivilegedHorizonClient(); var fsServer = new FileSystemServer(fsServerClient); var defaultObjects = DefaultFsServerObjects.GetDefaultEmulatedCreators(rootFileSystem, keySet, fsServer); var fsServerConfig = new FileSystemServerConfig { DeviceOperator = defaultObjects.DeviceOperator, ExternalKeySet = keySet.ExternalKeySet, FsCreators = defaultObjects.FsCreators, }; FileSystemServerInitializer.InitializeWithConfig(fsServerClient, fsServer, fsServerConfig); HorizonClient bcatServerClient = horizon.CreateHorizonClient(); _ = new BcatServer(bcatServerClient); return(horizon); }
public void InitializeFsServer(LibHac.Horizon horizon, out HorizonClient fsServerClient) { LocalFileSystem serverBaseFs = new LocalFileSystem(AppDataManager.BaseDirPath); fsServerClient = horizon.CreatePrivilegedHorizonClient(); var fsServer = new FileSystemServer(fsServerClient); DefaultFsServerObjects fsServerObjects = DefaultFsServerObjects.GetDefaultEmulatedCreators(serverBaseFs, KeySet, fsServer); // Use our own encrypted fs creator that always uses all-zero keys fsServerObjects.FsCreators.EncryptedFileSystemCreator = new EncryptedFileSystemCreator(); GameCard = fsServerObjects.GameCard; SdCard = fsServerObjects.SdCard; SdCard.SetSdCardInsertionStatus(true); var fsServerConfig = new FileSystemServerConfig { DeviceOperator = fsServerObjects.DeviceOperator, ExternalKeySet = KeySet.ExternalKeySet, FsCreators = fsServerObjects.FsCreators }; FileSystemServerInitializer.InitializeWithConfig(fsServerClient, fsServer, fsServerConfig); }
public static Horizon CreateBasicHorizon() { IFileSystem rootFs = new InMemoryFileSystem(); var defaultObjects = DefaultFsServerObjects.GetDefaultEmulatedCreators(rootFs, new KeySet()); var config = new FileSystemServerConfig(); config.FsCreators = defaultObjects.FsCreators; config.DeviceOperator = defaultObjects.DeviceOperator; config.ExternalKeySet = new ExternalKeySet(); Horizon horizon = LibHac.HorizonFactory.CreateWithFsConfig(new HorizonConfiguration(), config); return(horizon); }
public static Horizon CreateBasicHorizon() { IFileSystem rootFs = new InMemoryFileSystem(); var defaultObjects = DefaultFsServerObjects.GetDefaultEmulatedCreators(rootFs, new Keyset()); var config = new FileSystemServerConfig(); config.FsCreators = defaultObjects.FsCreators; config.DeviceOperator = defaultObjects.DeviceOperator; config.ExternalKeySet = new ExternalKeySet(); var horizon = new Horizon(new StopWatchTimeSpanGenerator(), config); return(horizon); }
public static FileSystemServer CreateServer(bool sdCardInserted, out IFileSystem rootFs) { rootFs = new InMemoryFileSystem(); var defaultObjects = DefaultFsServerObjects.GetDefaultEmulatedCreators(rootFs, new Keyset()); defaultObjects.SdCard.SetSdCardInsertionStatus(sdCardInserted); var config = new FileSystemServerConfig(); config.FsCreators = defaultObjects.FsCreators; config.DeviceOperator = defaultObjects.DeviceOperator; config.ExternalKeySet = new ExternalKeySet(); var fsServer = new FileSystemServer(config); return(fsServer); }
private static FileSystemClient CreateClientImpl(bool sdCardInserted, out IFileSystem rootFs) { rootFs = new InMemoryFileSystem(); var defaultObjects = DefaultFsServerObjects.GetDefaultEmulatedCreators(rootFs, new KeySet()); defaultObjects.SdCard.SetSdCardInsertionStatus(sdCardInserted); var config = new FileSystemServerConfig(); config.FsCreators = defaultObjects.FsCreators; config.DeviceOperator = defaultObjects.DeviceOperator; config.ExternalKeySet = new ExternalKeySet(); Horizon horizon = LibHac.HorizonFactory.CreateWithFsConfig(new HorizonConfiguration(), config); HorizonClient horizonClient = horizon.CreatePrivilegedHorizonClient(); return(horizonClient.Fs); }
public void Reload() { ReloadKeySet(); LocalFileSystem serverBaseFs = new LocalFileSystem(GetBasePath()); DefaultFsServerObjects fsServerObjects = DefaultFsServerObjects.GetDefaultEmulatedCreators(serverBaseFs, KeySet); GameCard = fsServerObjects.GameCard; FileSystemServerConfig fsServerConfig = new FileSystemServerConfig { FsCreators = fsServerObjects.FsCreators, DeviceOperator = fsServerObjects.DeviceOperator, ExternalKeySet = KeySet.ExternalKeySet }; FsServer = new FileSystemServer(fsServerConfig); FsClient = FsServer.CreateFileSystemClient(); }
private static Horizon CreateHorizonImpl(bool sdCardInserted, out IFileSystem rootFs) { rootFs = new InMemoryFileSystem(); var keySet = new KeySet(); var horizon = new Horizon(new HorizonConfiguration()); HorizonClient fsServerClient = horizon.CreatePrivilegedHorizonClient(); var fsServer = new FileSystemServer(fsServerClient); var defaultObjects = DefaultFsServerObjects.GetDefaultEmulatedCreators(rootFs, keySet, fsServer); defaultObjects.SdCard.SetSdCardInsertionStatus(sdCardInserted); var config = new FileSystemServerConfig(); config.FsCreators = defaultObjects.FsCreators; config.DeviceOperator = defaultObjects.DeviceOperator; config.ExternalKeySet = new ExternalKeySet(); FileSystemServerInitializer.InitializeWithConfig(fsServerClient, fsServer, config); return(horizon); }
public Horizon(Switch device) { ControlData = new BlitStruct <ApplicationControlProperty>(1); Device = device; State = new SystemStateMgr(); ResourceLimit = new KResourceLimit(this); KernelInit.InitializeResourceLimit(ResourceLimit); MemoryRegions = KernelInit.GetMemoryRegions(); LargeMemoryBlockAllocator = new KMemoryBlockAllocator(MemoryBlockAllocatorSize * 2); SmallMemoryBlockAllocator = new KMemoryBlockAllocator(MemoryBlockAllocatorSize); UserSlabHeapPages = new KSlabHeap( UserSlabHeapBase, UserSlabHeapItemSize, UserSlabHeapSize); CriticalSection = new KCriticalSection(this); Scheduler = new KScheduler(this); TimeManager = new KTimeManager(); Synchronization = new KSynchronization(this); ContextIdManager = new KContextIdManager(); _kipId = InitialKipId; _processId = InitialProcessId; Scheduler.StartAutoPreemptionThread(); KernelInitialized = true; ThreadCounter = new CountdownEvent(1); Processes = new SortedDictionary <long, KProcess>(); AutoObjectNames = new ConcurrentDictionary <string, KAutoObject>(); // Note: This is not really correct, but with HLE of services, the only memory // region used that is used is Application, so we can use the other ones for anything. KMemoryRegionManager region = MemoryRegions[(int)MemoryRegion.NvServices]; ulong hidPa = region.Address; ulong fontPa = region.Address + HidSize; ulong iirsPa = region.Address + HidSize + FontSize; ulong timePa = region.Address + HidSize + FontSize + IirsSize; HidBaseAddress = (long)(hidPa - DramMemoryMap.DramBase); KPageList hidPageList = new KPageList(); KPageList fontPageList = new KPageList(); KPageList iirsPageList = new KPageList(); KPageList timePageList = new KPageList(); hidPageList.AddRange(hidPa, HidSize / KMemoryManager.PageSize); fontPageList.AddRange(fontPa, FontSize / KMemoryManager.PageSize); iirsPageList.AddRange(iirsPa, IirsSize / KMemoryManager.PageSize); timePageList.AddRange(timePa, TimeSize / KMemoryManager.PageSize); HidSharedMem = new KSharedMemory(this, hidPageList, 0, 0, MemoryPermission.Read); FontSharedMem = new KSharedMemory(this, fontPageList, 0, 0, MemoryPermission.Read); IirsSharedMem = new KSharedMemory(this, iirsPageList, 0, 0, MemoryPermission.Read); KSharedMemory timeSharedMemory = new KSharedMemory(this, timePageList, 0, 0, MemoryPermission.Read); TimeServiceManager.Instance.Initialize(device, this, timeSharedMemory, (long)(timePa - DramMemoryMap.DramBase), TimeSize); AppletState = new AppletStateMgr(this); AppletState.SetFocus(true); Font = new SharedFontManager(device, (long)(fontPa - DramMemoryMap.DramBase)); IUserInterface.InitializePort(this); VsyncEvent = new KEvent(this); LoadKeySet(); ContentManager = new ContentManager(device); // TODO: use set:sys (and get external clock source id from settings) // TODO: use "time!standard_steady_clock_rtc_update_interval_minutes" and implement a worker thread to be accurate. UInt128 clockSourceId = new UInt128(Guid.NewGuid().ToByteArray()); IRtcManager.GetExternalRtcValue(out ulong rtcValue); // We assume the rtc is system time. TimeSpanType systemTime = TimeSpanType.FromSeconds((long)rtcValue); // First init the standard steady clock TimeServiceManager.Instance.SetupStandardSteadyClock(null, clockSourceId, systemTime, TimeSpanType.Zero, TimeSpanType.Zero, false); TimeServiceManager.Instance.SetupStandardLocalSystemClock(null, new SystemClockContext(), systemTime.ToSeconds()); if (NxSettings.Settings.TryGetValue("time!standard_network_clock_sufficient_accuracy_minutes", out object standardNetworkClockSufficientAccuracyMinutes)) { TimeSpanType standardNetworkClockSufficientAccuracy = new TimeSpanType((int)standardNetworkClockSufficientAccuracyMinutes * 60000000000); TimeServiceManager.Instance.SetupStandardNetworkSystemClock(new SystemClockContext(), standardNetworkClockSufficientAccuracy); } TimeServiceManager.Instance.SetupStandardUserSystemClock(null, false, SteadyClockTimePoint.GetRandom()); // FIXME: TimeZone shoud be init here but it's actually done in ContentManager TimeServiceManager.Instance.SetupEphemeralNetworkSystemClock(); LocalFileSystem serverBaseFs = new LocalFileSystem(device.FileSystem.GetBasePath()); DefaultFsServerObjects fsServerObjects = DefaultFsServerObjects.GetDefaultEmulatedCreators(serverBaseFs, KeySet); GameCard = fsServerObjects.GameCard; FileSystemServerConfig fsServerConfig = new FileSystemServerConfig { FsCreators = fsServerObjects.FsCreators, DeviceOperator = fsServerObjects.DeviceOperator, ExternalKeySet = KeySet.ExternalKeySet }; FsServer = new FileSystemServer(fsServerConfig); FsClient = FsServer.CreateFileSystemClient(); }