1 // Copyright 2018 yuzu emulator team
2 // Licensed under GPLv2 or any later version
3 // Refer to the license.txt file included.
4 
5 #pragma once
6 
7 #include <memory>
8 
9 #include "common/common_types.h"
10 #include "core/file_sys/vfs_types.h"
11 
12 namespace FileSys {
13 
14 enum class BisPartitionId : u32 {
15     UserDataRoot = 20,
16     CalibrationBinary = 27,
17     CalibrationFile = 28,
18     BootConfigAndPackage2Part1 = 21,
19     BootConfigAndPackage2Part2 = 22,
20     BootConfigAndPackage2Part3 = 23,
21     BootConfigAndPackage2Part4 = 24,
22     BootConfigAndPackage2Part5 = 25,
23     BootConfigAndPackage2Part6 = 26,
24     SafeMode = 29,
25     System = 31,
26     SystemProperEncryption = 32,
27     SystemProperPartition = 33,
28     User = 30,
29 };
30 
31 class RegisteredCache;
32 class PlaceholderCache;
33 
34 /// File system interface to the Built-In Storage
35 /// This is currently missing accessors to BIS partitions, but seemed like a good place for the NAND
36 /// registered caches.
37 class BISFactory {
38 public:
39     explicit BISFactory(VirtualDir nand_root, VirtualDir load_root, VirtualDir dump_root);
40     ~BISFactory();
41 
42     VirtualDir GetSystemNANDContentDirectory() const;
43     VirtualDir GetUserNANDContentDirectory() const;
44 
45     RegisteredCache* GetSystemNANDContents() const;
46     RegisteredCache* GetUserNANDContents() const;
47 
48     PlaceholderCache* GetSystemNANDPlaceholder() const;
49     PlaceholderCache* GetUserNANDPlaceholder() const;
50 
51     VirtualDir GetModificationLoadRoot(u64 title_id) const;
52     VirtualDir GetModificationDumpRoot(u64 title_id) const;
53 
54     VirtualDir OpenPartition(BisPartitionId id) const;
55     VirtualFile OpenPartitionStorage(BisPartitionId id, VirtualFilesystem file_system) const;
56 
57     VirtualDir GetImageDirectory() const;
58 
59     u64 GetSystemNANDFreeSpace() const;
60     u64 GetSystemNANDTotalSpace() const;
61     u64 GetUserNANDFreeSpace() const;
62     u64 GetUserNANDTotalSpace() const;
63     u64 GetFullNANDTotalSpace() const;
64 
65     VirtualDir GetBCATDirectory(u64 title_id) const;
66 
67 private:
68     VirtualDir nand_root;
69     VirtualDir load_root;
70     VirtualDir dump_root;
71 
72     std::unique_ptr<RegisteredCache> sysnand_cache;
73     std::unique_ptr<RegisteredCache> usrnand_cache;
74 
75     std::unique_ptr<PlaceholderCache> sysnand_placeholder;
76     std::unique_ptr<PlaceholderCache> usrnand_placeholder;
77 };
78 
79 } // namespace FileSys
80