diff options
Diffstat (limited to 'public/tools')
| -rw-r--r-- | public/tools/make_fs/make_fs.cc | 31 | ||||
| -rw-r--r-- | public/tools/make_fs/make_fs.json | 5 |
2 files changed, 34 insertions, 2 deletions
diff --git a/public/tools/make_fs/make_fs.cc b/public/tools/make_fs/make_fs.cc index e114113b..f75527b1 100644 --- a/public/tools/make_fs/make_fs.cc +++ b/public/tools/make_fs/make_fs.cc @@ -7,10 +7,41 @@ ------------------------------------------- */ +#include <iostream> +#include <fstream> +#include <FirmwareKit/EPM.h> #include <FSKit/NeFS.h> +#include <uuid/uuid.h> +static const char* kDiskName = "Disk"; +static const int kDiskSectorSz = 512; +static const int kDiskBlockCnt = 1; + +/// @brief Filesystem tool entrypoint. int main(int argc, char** argv) { + std::cout << "make_fs: EPM image creator.\n"; + struct EPM_PART_BLOCK block{0}; + + block.NumBlocks = kDiskBlockCnt; + block.SectorSz = kDiskSectorSz; + block.Version = kEPMRevisionBcd; + block.LbaStart = sizeof(struct EPM_PART_BLOCK); + block.LbaEnd = 0; + block.FsVersion = kNeFSVersionInteger; + + ::memcpy(block.Name, kDiskName, strlen(kDiskName)); + ::memcpy(block.Magic, kEPMMagic86, strlen(kEPMMagic86)); + + uuid_generate_random((NeOS::UInt8*)&block.Guid); + + std::ofstream output_epm("disk.eimg"); + output_epm.write((NeOS::Char*)&block, sizeof(struct EPM_PART_BLOCK)); + + output_epm.close(); + + std::cout << "make_fs: EPM image has been written to disk.eimg.\n"; + return 0; }
\ No newline at end of file diff --git a/public/tools/make_fs/make_fs.json b/public/tools/make_fs/make_fs.json index 8134bab3..13c66dbb 100644 --- a/public/tools/make_fs/make_fs.json +++ b/public/tools/make_fs/make_fs.json @@ -1,12 +1,13 @@ { "compiler_path": "g++", "compiler_std": "c++20", - "headers_path": ["./"], + "headers_path": ["./", "../../../dev/Kernel", "../../../dev/"], "sources_path": ["make_fs.cc"], "output_name": "./dist/make_fs", "cpp_macros": [ "kMKFSVersion=0x0100", "kMKFSVersionHighest=0x0100", - "kMKFSVersionLowest=0x0100" + "kMKFSVersionLowest=0x0100", + "__NE_SDK__" ] } |
