diff --git a/src/libraries/initrd/include/initrd/headers.h b/src/libraries/initrd/include/initrd/headers.h deleted file mode 100644 index 0845275..0000000 --- a/src/libraries/initrd/include/initrd/headers.h +++ /dev/null @@ -1,39 +0,0 @@ -#pragma once -#include -#include "kutil/enum_bitfields.h" - -namespace initrd { - - -enum class disk_flags : uint16_t -{ -}; - -struct disk_header -{ - uint16_t file_count; - disk_flags flags; - uint32_t length; - uint8_t checksum; - uint8_t reserved[3]; -} __attribute__ ((packed)); - - -enum class file_flags : uint16_t -{ - executable = 0x01, - symbols = 0x02 -}; - -struct file_header -{ - uint32_t offset; - uint32_t length; - uint16_t name_offset; - file_flags flags; -} __attribute__ ((packed)); - -} // namepsace initrd - -IS_BITFIELD(initrd::disk_flags); -IS_BITFIELD(initrd::file_flags); diff --git a/src/libraries/initrd/include/initrd/initrd.h b/src/libraries/initrd/include/initrd/initrd.h deleted file mode 100644 index c313947..0000000 --- a/src/libraries/initrd/include/initrd/initrd.h +++ /dev/null @@ -1,64 +0,0 @@ -#pragma once -/// \file initrd.h -/// Definitions defining the simple inital ramdisk file format used by the -/// jsix kernel. - -#include -#include "kutil/vector.h" - -// File format: -// 1x disk_header -// Nx file_header -// filename string data -// file data - -namespace initrd { - -struct disk_header; -struct file_header; - - -/// Encasulates methods for a file on the ramdisk -class file -{ -public: - file(const file_header *header, const void *start); - - /// Get the filename - const char * name() const; - - /// Get the file size - const size_t size() const; - - /// Get a pointer to the file data - const void * data() const; - - /// Whether this file is an executable - bool executable() const; - - /// Whether this file is a symbol table - bool symbols() const; - -private: - const file_header *m_header; - void const *m_data; - char const *m_name; -}; - - -/// Encasulates access methods for the ramdisk -class disk -{ -public: - /// Constructor. - /// \arg start The start of the initrd in memory - disk(const void *start); - - /// Get the vector of files on the disk - const kutil::vector & files() const { return m_files; } - -private: - kutil::vector m_files; -}; - -} // namespace initrd diff --git a/src/libraries/initrd/initrd.cpp b/src/libraries/initrd/initrd.cpp deleted file mode 100644 index 38d77f2..0000000 --- a/src/libraries/initrd/initrd.cpp +++ /dev/null @@ -1,46 +0,0 @@ -#include "initrd/headers.h" -#include "initrd/initrd.h" -#include "kutil/assert.h" -#include "kutil/enum_bitfields.h" - -namespace initrd { - -file::file(const file_header *header, const void *start) : - m_header(header) -{ - m_data = kutil::offset_pointer(start, m_header->offset); - auto *name = kutil::offset_pointer(start, m_header->name_offset); - m_name = reinterpret_cast(name); -} - -const char * file::name() const { return m_name; } -const size_t file::size() const { return m_header->length; } -const void * file::data() const { return m_data; } - -bool -file::executable() const { - return bitfield_has(m_header->flags, file_flags::executable); -} - -bool -file::symbols() const { - return bitfield_has(m_header->flags, file_flags::symbols); -} - - -disk::disk(const void *start) -{ - auto *header = reinterpret_cast(start); - size_t length = header->length; - uint8_t sum = kutil::checksum(start, length); - kassert(sum == 0, "initrd checksum failed"); - - auto *files = reinterpret_cast(header + 1); - - m_files.ensure_capacity(header->file_count); - for (int i = 0; i < header->file_count; ++i) { - m_files.emplace(&files[i], start); - } -} - -} // namespace initrd