Example #1
0
        public void InitializeFileSystemServer(FileSystemCreators fsCreators, IDeviceOperator deviceOperator)
        {
            if (FileSystemServer != null)
            {
                return;
            }

            lock (_initLocker)
            {
                if (FileSystemServer != null)
                {
                    return;
                }

                var config = new FileSystemServerConfig();
                config.FsCreators     = fsCreators;
                config.DeviceOperator = deviceOperator;

                FileSystemServer = new FileSystemServer(config);
            }
        }
Example #2
0
        public void Reload()
        {
            ReloadKeySet();

            LocalFileSystem serverBaseFs = new LocalFileSystem(GetBasePath());

            DefaultFsServerObjects fsServerObjects = DefaultFsServerObjects.GetDefaultEmulatedCreators(serverBaseFs, KeySet);

            GameCard = fsServerObjects.GameCard;
            SdCard   = fsServerObjects.SdCard;

            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 static Horizon CreateWithDefaultFsConfig(HorizonConfiguration config, IFileSystem rootFileSystem, KeySet keySet)
        {
            var horizon = new Horizon(config);

            var defaultObjects = DefaultFsServerObjects.GetDefaultEmulatedCreators(rootFileSystem, keySet);

            HorizonClient fsServerClient = horizon.CreatePrivilegedHorizonClient();
            var           fsServer       = new FileSystemServer(fsServerClient);

            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 static FileSystemClient CreateClient(out IFileSystem rootFs)
        {
            FileSystemServer fsServer = CreateServer(false, out rootFs);

            return(fsServer.CreateFileSystemClient());
        }
        public static FileSystemClient CreateClient(bool sdCardInserted)
        {
            FileSystemServer fsServer = CreateServer(sdCardInserted, out _);

            return(fsServer.CreateFileSystemClient());
        }
Example #7
0
 public Horizon(ITimeSpanGenerator timer, FileSystemServer fsServer)
 {
     Time             = timer ?? new StopWatchTimeSpanGenerator();
     FileSystemServer = fsServer;
     ServiceManager   = new ServiceManager(this);
 }
Example #8
0
 internal FileSystemClient(FileSystemServer fsServer, IFileSystemProxy fsProxy, ITimeSpanGenerator timer)
 {
     FsSrv   = fsServer;
     FsProxy = fsProxy;
     Time    = timer ?? new StopWatchTimeSpanGenerator();
 }
Example #9
0
 public FileSystemClient(FileSystemServer fsServer, ITimeSpanGenerator timer)
 {
     FsSrv = fsServer;
     Time  = timer ?? new StopWatchTimeSpanGenerator();
 }
Example #10
0
        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();
        }
Example #11
0
 public ProgramRegistryManager(FileSystemServer fsServer)
 {
     ProgramInfoList = new LinkedList <ProgramInfo>();
     FsServer        = fsServer;
 }
Example #12
0
 internal static ProgramInfo CreateProgramInfoForInitialProcess(FileSystemServer fsServer)
 {
     return(new ProgramInfo(fsServer, InitialProcessAccessControlDataHeader,
                            InitialProcessAccessControlDescriptor));
 }
Example #13
0
 public LocationResolverSet(FileSystemServer fsServer)
 {
     _resolvers = new LocationResolver[LocationResolverCount];
     _mutex.Initialize();
     _fsServer = fsServer;
 }