diff --git a/lib/mammoth/ipc/channel.cpp b/lib/mammoth/ipc/channel.cpp index efd62a4..a014bfd 100644 --- a/lib/mammoth/ipc/channel.cpp +++ b/lib/mammoth/ipc/channel.cpp @@ -4,6 +4,7 @@ #include "util/debug.h" +namespace mmth { namespace { uint64_t strlen(const char* ptr) { @@ -55,3 +56,5 @@ z_err_t CreateChannels(Channel& c1, Channel& c2) { c2.adopt_cap(chan2); return glcr::OK; } + +} // namespace mmth diff --git a/lib/mammoth/ipc/channel.h b/lib/mammoth/ipc/channel.h index bb2a8df..f290d92 100644 --- a/lib/mammoth/ipc/channel.h +++ b/lib/mammoth/ipc/channel.h @@ -4,6 +4,8 @@ #include #include +namespace mmth { + class Channel { public: Channel() {} @@ -45,3 +47,5 @@ z_err_t Channel::ReadStructAndCap(T* obj, uint64_t* cap) { } return glcr::OK; } + +} // namespace mmth diff --git a/lib/mammoth/ipc/endpoint_client.cpp b/lib/mammoth/ipc/endpoint_client.cpp index 2b20b46..33c50cf 100644 --- a/lib/mammoth/ipc/endpoint_client.cpp +++ b/lib/mammoth/ipc/endpoint_client.cpp @@ -1,5 +1,9 @@ #include "ipc/endpoint_server.h" +namespace mmth { + glcr::UniquePtr EndpointClient::AdoptEndpoint(z_cap_t cap) { return glcr::UniquePtr(new EndpointClient(cap)); } + +} // namespace mmth diff --git a/lib/mammoth/ipc/endpoint_client.h b/lib/mammoth/ipc/endpoint_client.h index 42ed0f9..41227b1 100644 --- a/lib/mammoth/ipc/endpoint_client.h +++ b/lib/mammoth/ipc/endpoint_client.h @@ -6,6 +6,8 @@ #include #include +namespace mmth { + class EndpointClient { public: EndpointClient() = delete; @@ -63,3 +65,5 @@ glcr::ErrorOr EndpointClient::CallEndpoint(const Req& req) { return resp; } + +} // namespace mmth diff --git a/lib/mammoth/ipc/endpoint_server.cpp b/lib/mammoth/ipc/endpoint_server.cpp index e35e1fb..823c5f0 100644 --- a/lib/mammoth/ipc/endpoint_server.cpp +++ b/lib/mammoth/ipc/endpoint_server.cpp @@ -2,6 +2,7 @@ #include "util/debug.h" +namespace mmth { // Declared as friend in EndpointServer. void EndpointServerThreadBootstrap(void* endpoint_server) { reinterpret_cast(endpoint_server)->ServerThread(); @@ -40,3 +41,5 @@ void EndpointServer::ServerThread() { } } } + +} // namespace mmth diff --git a/lib/mammoth/ipc/endpoint_server.h b/lib/mammoth/ipc/endpoint_server.h index ca054c6..7ce438d 100644 --- a/lib/mammoth/ipc/endpoint_server.h +++ b/lib/mammoth/ipc/endpoint_server.h @@ -9,6 +9,7 @@ #include "mammoth/ipc/response_context.h" #include "mammoth/proc/thread.h" +namespace mmth { class EndpointServer { public: EndpointServer() = delete; @@ -34,3 +35,5 @@ class EndpointServer { friend void EndpointServerThreadBootstrap(void* endpoint_server); void ServerThread(); }; + +} // namespace mmth diff --git a/lib/mammoth/ipc/port_client.cpp b/lib/mammoth/ipc/port_client.cpp index 7d6b774..9bb5525 100644 --- a/lib/mammoth/ipc/port_client.cpp +++ b/lib/mammoth/ipc/port_client.cpp @@ -5,6 +5,8 @@ #include "util/debug.h" +namespace mmth { + PortClient PortClient::AdoptPort(z_cap_t cap) { return PortClient(cap); } PortClient::PortClient(z_cap_t port_cap) : port_cap_(port_cap) {} @@ -12,3 +14,5 @@ glcr::ErrorCode PortClient::WriteString(glcr::String str, z_cap_t cap) { return static_cast( ZPortSend(port_cap_, str.length() + 1, str.cstr(), 1, &cap)); } + +} // namespace mmth diff --git a/lib/mammoth/ipc/port_client.h b/lib/mammoth/ipc/port_client.h index 95683b6..3a38ee6 100644 --- a/lib/mammoth/ipc/port_client.h +++ b/lib/mammoth/ipc/port_client.h @@ -5,6 +5,8 @@ #include #include +namespace mmth { + class PortClient { public: PortClient() {} @@ -29,3 +31,5 @@ template z_err_t PortClient::WriteMessage(const T& obj, z_cap_t cap) { return ZPortSend(port_cap_, sizeof(obj), &obj, 1, &cap); } + +} // namespace mmth diff --git a/lib/mammoth/ipc/port_server.cpp b/lib/mammoth/ipc/port_server.cpp index 490a146..6208c85 100644 --- a/lib/mammoth/ipc/port_server.cpp +++ b/lib/mammoth/ipc/port_server.cpp @@ -2,6 +2,8 @@ #include +namespace mmth { + glcr::ErrorOr PortServer::Create() { z_cap_t port; RET_ERR(ZPortCreate(&port)); @@ -44,3 +46,5 @@ glcr::ErrorCode PortServer::PollForIntCap(uint64_t *msg, uint64_t *cap) { } return glcr::OK; } + +} // namespace mmth diff --git a/lib/mammoth/ipc/port_server.h b/lib/mammoth/ipc/port_server.h index ccb9c46..e49642a 100644 --- a/lib/mammoth/ipc/port_server.h +++ b/lib/mammoth/ipc/port_server.h @@ -5,6 +5,8 @@ #include "mammoth/ipc/port_client.h" +namespace mmth { + class PortServer { public: static glcr::ErrorOr Create(); @@ -22,3 +24,5 @@ class PortServer { PortServer(z_cap_t cap); }; + +} // namespace mmth diff --git a/lib/mammoth/proc/process.cpp b/lib/mammoth/proc/process.cpp index de7a71b..c4622d0 100644 --- a/lib/mammoth/proc/process.cpp +++ b/lib/mammoth/proc/process.cpp @@ -11,6 +11,7 @@ #define MAM_PROC_DEBUG 0 +namespace mmth { namespace { typedef struct { @@ -140,3 +141,5 @@ glcr::ErrorCode SpawnProcessFromElfRegion(uint64_t program, return glcr::OK; } + +} // namespace mmth diff --git a/lib/mammoth/proc/process.h b/lib/mammoth/proc/process.h index b2acb7a..1506f4f 100644 --- a/lib/mammoth/proc/process.h +++ b/lib/mammoth/proc/process.h @@ -4,5 +4,9 @@ #include #include +namespace mmth { + glcr::ErrorCode SpawnProcessFromElfRegion(uint64_t program, z_cap_t yellowstone_client); + +} // namespace mmth diff --git a/lib/mammoth/sync/mutex.cpp b/lib/mammoth/sync/mutex.cpp index 8ae04c0..9b134ed 100644 --- a/lib/mammoth/sync/mutex.cpp +++ b/lib/mammoth/sync/mutex.cpp @@ -2,6 +2,8 @@ #include +namespace mmth { + Mutex::Mutex(Mutex&& other) : mutex_cap_(other.mutex_cap_) { other.mutex_cap_ = 0; } @@ -25,3 +27,5 @@ glcr::ErrorCode Mutex::Lock() { glcr::ErrorCode Mutex::Release() { return static_cast(ZMutexRelease(mutex_cap_)); } + +} // namespace mmth diff --git a/lib/mammoth/sync/mutex.h b/lib/mammoth/sync/mutex.h index 1c21efd..ee77394 100644 --- a/lib/mammoth/sync/mutex.h +++ b/lib/mammoth/sync/mutex.h @@ -3,6 +3,8 @@ #include #include +namespace mmth { + class Mutex { public: Mutex(const Mutex&) = delete; @@ -19,3 +21,5 @@ class Mutex { Mutex(z_cap_t mutex_cap) : mutex_cap_(mutex_cap) {} }; + +} // namespace mmth diff --git a/lib/mammoth/sync/semaphore.cpp b/lib/mammoth/sync/semaphore.cpp index 1a9dbad..7cead08 100644 --- a/lib/mammoth/sync/semaphore.cpp +++ b/lib/mammoth/sync/semaphore.cpp @@ -4,8 +4,12 @@ #include "util/debug.h" +namespace mmth { + Semaphore::Semaphore() { check(ZSemaphoreCreate(&semaphore_cap_)); } Semaphore::~Semaphore() { check(ZCapRelease(semaphore_cap_)); } void Semaphore::Wait() { check(ZSemaphoreWait(semaphore_cap_)); } void Semaphore::Signal() { check(ZSemaphoreSignal(semaphore_cap_)); } + +} // namespace mmth diff --git a/lib/mammoth/sync/semaphore.h b/lib/mammoth/sync/semaphore.h index b22c124..8eff28f 100644 --- a/lib/mammoth/sync/semaphore.h +++ b/lib/mammoth/sync/semaphore.h @@ -2,6 +2,8 @@ #include +namespace mmth { + class Semaphore { public: Semaphore(); @@ -13,3 +15,5 @@ class Semaphore { private: z_cap_t semaphore_cap_; }; + +} // namespace mmth diff --git a/lib/mammoth/util/init.cpp b/lib/mammoth/util/init.cpp index c103e91..34418e4 100644 --- a/lib/mammoth/util/init.cpp +++ b/lib/mammoth/util/init.cpp @@ -17,7 +17,7 @@ uint64_t gBootPciVmmoCap = 0; uint64_t gBootFramebufferVmmoCap = 0; z_err_t ParseInitPort(uint64_t init_port_cap) { - PortServer port = PortServer::AdoptCap(init_port_cap); + mmth::PortServer port = mmth::PortServer::AdoptCap(init_port_cap); z_err_t ret; uint64_t init_sig, init_cap; while ((ret = port.PollForIntCap(&init_sig, &init_cap)) != glcr::EMPTY) { diff --git a/lib/mammoth/util/memory_region.cpp b/lib/mammoth/util/memory_region.cpp index 067160f..7675227 100644 --- a/lib/mammoth/util/memory_region.cpp +++ b/lib/mammoth/util/memory_region.cpp @@ -5,6 +5,8 @@ #include "util/debug.h" #include "util/init.h" +namespace mmth { + OwnedMemoryRegion::OwnedMemoryRegion(OwnedMemoryRegion&& other) : OwnedMemoryRegion(other.vmmo_cap_, other.vaddr_, other.size_) { other.vmmo_cap_ = 0; @@ -68,3 +70,5 @@ z_cap_t OwnedMemoryRegion::DuplicateCap() { check(ZCapDuplicate(vmmo_cap_, kZionPerm_All, &cap)); return cap; } + +} // namespace mmth diff --git a/lib/mammoth/util/memory_region.h b/lib/mammoth/util/memory_region.h index 1ce79b7..97d1cf6 100644 --- a/lib/mammoth/util/memory_region.h +++ b/lib/mammoth/util/memory_region.h @@ -3,6 +3,7 @@ #include #include +namespace mmth { /* * Memory Region class that unmaps its memory and releases its * capability when it goes out of scope. @@ -41,3 +42,5 @@ class OwnedMemoryRegion { // TODO: We may want to differentiate between VMMO size and mapped size? uint64_t size_ = 0; }; + +} // namespace mmth diff --git a/sys/denali/ahci/ahci_device.cpp b/sys/denali/ahci/ahci_device.cpp index d2b1f82..8b81427 100644 --- a/sys/denali/ahci/ahci_device.cpp +++ b/sys/denali/ahci/ahci_device.cpp @@ -14,7 +14,8 @@ AhciDevice::AhciDevice(AhciPort* port) : port_struct_(port) { // 0x400-0x500 -> Received FIS // 0x500-0x2500 -> Command Tables (0x100 each) (Max PRDT Length is 8 for now) uint64_t paddr; - command_structures_ = OwnedMemoryRegion::ContiguousPhysical(0x2500, &paddr); + command_structures_ = + mmth::OwnedMemoryRegion::ContiguousPhysical(0x2500, &paddr); command_list_ = reinterpret_cast(command_structures_.vaddr()); port_struct_->command_list_base = paddr; diff --git a/sys/denali/ahci/ahci_device.h b/sys/denali/ahci/ahci_device.h index 2d35da6..bc4fc94 100644 --- a/sys/denali/ahci/ahci_device.h +++ b/sys/denali/ahci/ahci_device.h @@ -26,7 +26,7 @@ class AhciDevice { private: AhciPort* port_struct_ = nullptr; - OwnedMemoryRegion command_structures_; + mmth::OwnedMemoryRegion command_structures_; CommandList* command_list_ = nullptr; ReceivedFis* received_fis_ = nullptr; diff --git a/sys/denali/ahci/ahci_driver.cpp b/sys/denali/ahci/ahci_driver.cpp index 626d92b..28d0de5 100644 --- a/sys/denali/ahci/ahci_driver.cpp +++ b/sys/denali/ahci/ahci_driver.cpp @@ -21,7 +21,7 @@ void interrupt_thread(void* void_driver) { } // namespace glcr::ErrorOr> AhciDriver::Init( - OwnedMemoryRegion&& pci_region) { + mmth::OwnedMemoryRegion&& pci_region) { glcr::UniquePtr driver(new AhciDriver(glcr::Move(pci_region))); // RET_ERR(driver->LoadCapabilities()); RET_ERR(driver->LoadHbaRegisters()); @@ -191,8 +191,8 @@ glcr::ErrorCode AhciDriver::RegisterIrq() { } glcr::ErrorCode AhciDriver::LoadHbaRegisters() { - ahci_region_ = - OwnedMemoryRegion ::DirectPhysical(pci_device_header_->abar, 0x1100); + ahci_region_ = mmth::OwnedMemoryRegion ::DirectPhysical( + pci_device_header_->abar, 0x1100); ahci_hba_ = reinterpret_cast(ahci_region_.vaddr()); num_ports_ = (ahci_hba_->capabilities & 0x1F) + 1; num_commands_ = ((ahci_hba_->capabilities & 0x1F00) >> 8) + 1; diff --git a/sys/denali/ahci/ahci_driver.h b/sys/denali/ahci/ahci_driver.h index e79bd14..0713861 100644 --- a/sys/denali/ahci/ahci_driver.h +++ b/sys/denali/ahci/ahci_driver.h @@ -11,7 +11,7 @@ class AhciDriver { public: static glcr::ErrorOr> Init( - OwnedMemoryRegion&& ahci_phys); + mmth::OwnedMemoryRegion&& ahci_phys); glcr::ErrorCode RegisterIrq(); void InterruptLoop(); @@ -22,9 +22,9 @@ class AhciDriver { void DumpPorts(); private: - OwnedMemoryRegion pci_region_; + mmth::OwnedMemoryRegion pci_region_; PciDeviceHeader* pci_device_header_ = nullptr; - OwnedMemoryRegion ahci_region_; + mmth::OwnedMemoryRegion ahci_region_; AhciHba* ahci_hba_ = nullptr; // TODO: Allocate these dynamically. @@ -40,7 +40,7 @@ class AhciDriver { glcr::ErrorCode LoadHbaRegisters(); glcr::ErrorCode LoadDevices(); - AhciDriver(OwnedMemoryRegion&& pci_region) + AhciDriver(mmth::OwnedMemoryRegion&& pci_region) : pci_region_(glcr::Move(pci_region)), pci_device_header_( reinterpret_cast(pci_region_.vaddr())) {} diff --git a/sys/denali/ahci/command.h b/sys/denali/ahci/command.h index 8cb4b9c..61fef58 100644 --- a/sys/denali/ahci/command.h +++ b/sys/denali/ahci/command.h @@ -32,5 +32,5 @@ class DmaReadCommand : public Command { uint64_t paddr_; // TODO: Make this owned by the device so that we don't have to create a new // one with the kernel every time a command is issued. - Semaphore callback_semaphore_; + mmth::Semaphore callback_semaphore_; }; diff --git a/sys/denali/denali.cpp b/sys/denali/denali.cpp index 3f1eeb3..8baa337 100644 --- a/sys/denali/denali.cpp +++ b/sys/denali/denali.cpp @@ -14,8 +14,8 @@ uint64_t main(uint64_t init_port_cap) { Empty empty; AhciInfo ahci; RET_ERR(stub.GetAhciInfo(empty, ahci)); - OwnedMemoryRegion ahci_region = - OwnedMemoryRegion::FromCapability(ahci.ahci_region()); + mmth::OwnedMemoryRegion ahci_region = + mmth::OwnedMemoryRegion::FromCapability(ahci.ahci_region()); ASSIGN_OR_RETURN(auto driver, AhciDriver::Init(glcr::Move(ahci_region))); ASSIGN_OR_RETURN(glcr::UniquePtr server, diff --git a/sys/denali/denali_server.cpp b/sys/denali/denali_server.cpp index 37494ca..330fdc7 100644 --- a/sys/denali/denali_server.cpp +++ b/sys/denali/denali_server.cpp @@ -17,8 +17,8 @@ glcr::ErrorCode DenaliServer::HandleRead(const ReadRequest& req, ASSIGN_OR_RETURN(AhciDevice * device, driver_.GetDevice(req.device_id())); uint64_t paddr; - OwnedMemoryRegion region = - OwnedMemoryRegion::ContiguousPhysical(req.size() * 512, &paddr); + mmth::OwnedMemoryRegion region = + mmth::OwnedMemoryRegion::ContiguousPhysical(req.size() * 512, &paddr); DmaReadCommand command(req.lba(), req.size(), paddr); device->IssueCommand(&command); @@ -44,8 +44,8 @@ glcr::ErrorCode DenaliServer::HandleReadMany(const ReadManyRequest& req, sector_cnt += req.sector_cnt().at(i); } uint64_t region_paddr; - OwnedMemoryRegion region = - OwnedMemoryRegion::ContiguousPhysical(sector_cnt * 512, ®ion_paddr); + mmth::OwnedMemoryRegion region = mmth::OwnedMemoryRegion::ContiguousPhysical( + sector_cnt * 512, ®ion_paddr); for (uint64_t i = 0; i < req.lba().size(); i++) { uint64_t lba = req.lba().at(i); diff --git a/sys/teton/framebuffer/framebuffer.cpp b/sys/teton/framebuffer/framebuffer.cpp index 817f1e0..1c80441 100644 --- a/sys/teton/framebuffer/framebuffer.cpp +++ b/sys/teton/framebuffer/framebuffer.cpp @@ -3,8 +3,8 @@ Framebuffer::Framebuffer(const FramebufferInfo& info) : fb_info_(info), cursor_pos_(0) { uint64_t buff_size_bytes = fb_info_.height() * fb_info_.pitch(); - fb_memory_ = OwnedMemoryRegion::DirectPhysical(fb_info_.address_phys(), - buff_size_bytes); + fb_memory_ = mmth::OwnedMemoryRegion::DirectPhysical(fb_info_.address_phys(), + buff_size_bytes); fb_ = reinterpret_cast(fb_memory_.vaddr()); } diff --git a/sys/teton/framebuffer/framebuffer.h b/sys/teton/framebuffer/framebuffer.h index 0edfa39..8c8253c 100644 --- a/sys/teton/framebuffer/framebuffer.h +++ b/sys/teton/framebuffer/framebuffer.h @@ -19,7 +19,7 @@ class Framebuffer { // don't have to store a reference here. const FramebufferInfo& fb_info_; - OwnedMemoryRegion fb_memory_; + mmth::OwnedMemoryRegion fb_memory_; uint32_t* fb_; uint32_t cursor_pos_; }; diff --git a/sys/teton/framebuffer/psf.cpp b/sys/teton/framebuffer/psf.cpp index 8f381c2..6c9770e 100644 --- a/sys/teton/framebuffer/psf.cpp +++ b/sys/teton/framebuffer/psf.cpp @@ -9,7 +9,7 @@ const uint32_t kMagic = 0x864AB572; } -Psf::Psf(OwnedMemoryRegion&& psf_file) +Psf::Psf(mmth::OwnedMemoryRegion&& psf_file) : psf_file_(glcr::Move(psf_file)), header_(reinterpret_cast(psf_file_.vaddr())) { EnsureValid(); diff --git a/sys/teton/framebuffer/psf.h b/sys/teton/framebuffer/psf.h index f330984..944d406 100644 --- a/sys/teton/framebuffer/psf.h +++ b/sys/teton/framebuffer/psf.h @@ -15,7 +15,7 @@ struct PsfHeader { class Psf { public: - Psf(OwnedMemoryRegion&& psf_file); + Psf(mmth::OwnedMemoryRegion&& psf_file); void DumpHeader(); @@ -29,7 +29,7 @@ class Psf { } private: - OwnedMemoryRegion psf_file_; + mmth::OwnedMemoryRegion psf_file_; PsfHeader* header_; void EnsureValid(); diff --git a/sys/teton/teton.cpp b/sys/teton/teton.cpp index f3e3853..e530b09 100644 --- a/sys/teton/teton.cpp +++ b/sys/teton/teton.cpp @@ -37,7 +37,7 @@ uint64_t main(uint64_t init_port) { OpenFileResponse fresp; check(vfs.OpenFile(freq, fresp)); - Psf psf(OwnedMemoryRegion::FromCapability(fresp.memory())); + Psf psf(mmth::OwnedMemoryRegion::FromCapability(fresp.memory())); psf.DumpHeader(); Console console(fbuf, psf); diff --git a/sys/victoriafalls/fs/ext2/ext2_block_reader.cpp b/sys/victoriafalls/fs/ext2/ext2_block_reader.cpp index 287e8e7..42d417f 100644 --- a/sys/victoriafalls/fs/ext2/ext2_block_reader.cpp +++ b/sys/victoriafalls/fs/ext2/ext2_block_reader.cpp @@ -13,8 +13,8 @@ glcr::ErrorOr> Ext2BlockReader::Init( req.set_size(2); ReadResponse resp; RET_ERR(client.Read(req, resp)); - OwnedMemoryRegion superblock = - OwnedMemoryRegion::FromCapability(resp.memory()); + mmth::OwnedMemoryRegion superblock = + mmth::OwnedMemoryRegion::FromCapability(resp.memory()); return glcr::SharedPtr( new Ext2BlockReader(glcr::Move(client), denali_info.device_id(), @@ -59,11 +59,11 @@ uint64_t Ext2BlockReader::InodeTableBlockSize() { return (InodeSize() * GetSuperblock()->inodes_per_group) / BlockSize(); } -glcr::ErrorOr Ext2BlockReader::ReadBlock( +glcr::ErrorOr Ext2BlockReader::ReadBlock( uint64_t block_number) { return ReadBlocks(block_number, 1); } -glcr::ErrorOr Ext2BlockReader::ReadBlocks( +glcr::ErrorOr Ext2BlockReader::ReadBlocks( uint64_t block_number, uint64_t num_blocks) { ReadRequest req; req.set_device_id(device_id_); @@ -71,10 +71,10 @@ glcr::ErrorOr Ext2BlockReader::ReadBlocks( req.set_size(num_blocks * SectorsPerBlock()); ReadResponse resp; RET_ERR(denali_.Read(req, resp)); - return OwnedMemoryRegion::FromCapability(resp.memory()); + return mmth::OwnedMemoryRegion::FromCapability(resp.memory()); } -glcr::ErrorOr Ext2BlockReader::ReadBlocks( +glcr::ErrorOr Ext2BlockReader::ReadBlocks( const glcr::Vector& block_list) { ReadManyRequest req; req.set_device_id(device_id_); @@ -93,12 +93,12 @@ glcr::ErrorOr Ext2BlockReader::ReadBlocks( dbgln("Read many: {x}", req.lba().size()); ReadResponse resp; RET_ERR(denali_.ReadMany(req, resp)); - return OwnedMemoryRegion::FromCapability(resp.memory()); + return mmth::OwnedMemoryRegion::FromCapability(resp.memory()); } Ext2BlockReader::Ext2BlockReader(DenaliClient&& denali, uint64_t device_id, uint64_t lba_offset, - OwnedMemoryRegion&& super_block) + mmth::OwnedMemoryRegion&& super_block) : denali_(glcr::Move(denali)), device_id_(device_id), lba_offset_(lba_offset), diff --git a/sys/victoriafalls/fs/ext2/ext2_block_reader.h b/sys/victoriafalls/fs/ext2/ext2_block_reader.h index f2da664..c7e0959 100644 --- a/sys/victoriafalls/fs/ext2/ext2_block_reader.h +++ b/sys/victoriafalls/fs/ext2/ext2_block_reader.h @@ -29,21 +29,21 @@ class Ext2BlockReader { // because the last table will likely be smaller. uint64_t InodeTableBlockSize(); - glcr::ErrorOr ReadBlock(uint64_t block_number); - glcr::ErrorOr ReadBlocks(uint64_t block_number, - uint64_t num_blocks); + glcr::ErrorOr ReadBlock(uint64_t block_number); + glcr::ErrorOr ReadBlocks(uint64_t block_number, + uint64_t num_blocks); - glcr::ErrorOr ReadBlocks( + glcr::ErrorOr ReadBlocks( const glcr::Vector& block_list); private: DenaliClient denali_; uint64_t device_id_; uint64_t lba_offset_; - OwnedMemoryRegion super_block_region_; + mmth::OwnedMemoryRegion super_block_region_; Ext2BlockReader(DenaliClient&& denali, uint64_t device_id, - uint64_t lba_offset, OwnedMemoryRegion&& super_block); + uint64_t lba_offset, mmth::OwnedMemoryRegion&& super_block); uint64_t SectorsPerBlock(); }; diff --git a/sys/victoriafalls/fs/ext2/ext2_driver.cpp b/sys/victoriafalls/fs/ext2/ext2_driver.cpp index beb4b5b..eb18e40 100644 --- a/sys/victoriafalls/fs/ext2/ext2_driver.cpp +++ b/sys/victoriafalls/fs/ext2/ext2_driver.cpp @@ -8,7 +8,7 @@ glcr::ErrorOr Ext2Driver::Init(const DenaliInfo& denali_info) { Ext2BlockReader::Init(glcr::Move(denali_info))); ASSIGN_OR_RETURN( - OwnedMemoryRegion bgdt, + mmth::OwnedMemoryRegion bgdt, reader->ReadBlocks(reader->BgdtBlockNum(), reader->BgdtBlockSize())); glcr::UniquePtr inode_table( new InodeTable(reader, glcr::Move(bgdt))); @@ -63,7 +63,7 @@ glcr::ErrorOr> Ext2Driver::ReadDirectory( glcr::Vector directory; for (uint64_t i = 0; i < real_block_cnt; i++) { dbgln("Getting block {x}", inode->block[i]); - ASSIGN_OR_RETURN(OwnedMemoryRegion block, + ASSIGN_OR_RETURN(mmth::OwnedMemoryRegion block, ext2_reader_->ReadBlock(inode->block[i])); uint64_t addr = block.vaddr(); while (addr < block.vaddr() + ext2_reader_->BlockSize()) { @@ -86,7 +86,8 @@ glcr::ErrorOr> Ext2Driver::ReadDirectory( return directory; } -glcr::ErrorOr Ext2Driver::ReadFile(uint64_t inode_number) { +glcr::ErrorOr Ext2Driver::ReadFile( + uint64_t inode_number) { ASSIGN_OR_RETURN(Inode * inode, inode_table_->GetInode(inode_number)); if (!(inode->mode & 0x8000)) { @@ -108,7 +109,7 @@ glcr::ErrorOr Ext2Driver::ReadFile(uint64_t inode_number) { return glcr::UNIMPLEMENTED; } - OwnedMemoryRegion indirect_block; + mmth::OwnedMemoryRegion indirect_block; if (inode->block[12]) { ASSIGN_OR_RETURN(indirect_block, ext2_reader_->ReadBlock(inode->block[12])); } diff --git a/sys/victoriafalls/fs/ext2/ext2_driver.h b/sys/victoriafalls/fs/ext2/ext2_driver.h index 7be3b29..b8546bc 100644 --- a/sys/victoriafalls/fs/ext2/ext2_driver.h +++ b/sys/victoriafalls/fs/ext2/ext2_driver.h @@ -18,7 +18,7 @@ class Ext2Driver { glcr::ErrorOr> ReadDirectory(uint32_t inode_number); - glcr::ErrorOr ReadFile(uint64_t inode_number); + glcr::ErrorOr ReadFile(uint64_t inode_number); private: glcr::SharedPtr ext2_reader_; diff --git a/sys/victoriafalls/fs/ext2/inode_table.cpp b/sys/victoriafalls/fs/ext2/inode_table.cpp index 521b635..12bab0f 100644 --- a/sys/victoriafalls/fs/ext2/inode_table.cpp +++ b/sys/victoriafalls/fs/ext2/inode_table.cpp @@ -1,7 +1,7 @@ #include "fs/ext2/inode_table.h" InodeTable::InodeTable(const glcr::SharedPtr& reader, - OwnedMemoryRegion&& bgdt_region) + mmth::OwnedMemoryRegion&& bgdt_region) : ext2_reader_(reader), bgdt_region_(glcr::Move(bgdt_region)), bgdt_(reinterpret_cast(bgdt_region_.vaddr())) { diff --git a/sys/victoriafalls/fs/ext2/inode_table.h b/sys/victoriafalls/fs/ext2/inode_table.h index 5efc0f7..18bb36d 100644 --- a/sys/victoriafalls/fs/ext2/inode_table.h +++ b/sys/victoriafalls/fs/ext2/inode_table.h @@ -9,16 +9,16 @@ class InodeTable { public: InodeTable(const glcr::SharedPtr& driver, - OwnedMemoryRegion&& bgdt_region); + mmth::OwnedMemoryRegion&& bgdt_region); glcr::ErrorOr GetInode(uint32_t inode_num); private: glcr::SharedPtr ext2_reader_; - OwnedMemoryRegion bgdt_region_; + mmth::OwnedMemoryRegion bgdt_region_; BlockGroupDescriptor* bgdt_; - glcr::Vector inode_tables_; + glcr::Vector inode_tables_; glcr::ErrorOr GetRootOfInodeTable(uint64_t block_group_num); }; diff --git a/sys/victoriafalls/victoriafalls_server.cpp b/sys/victoriafalls/victoriafalls_server.cpp index e885464..36628bc 100644 --- a/sys/victoriafalls/victoriafalls_server.cpp +++ b/sys/victoriafalls/victoriafalls_server.cpp @@ -38,7 +38,7 @@ glcr::ErrorCode VFSServer::HandleOpenFile(const OpenFileRequest& request, } uint64_t inode_num; - OwnedMemoryRegion region; + mmth::OwnedMemoryRegion region; for (uint64_t j = 0; j < files.size(); j++) { if (path_tokens.at(path_tokens.size() - 1) == glcr::StringView(files.at(j).name, files.at(j).name_len)) { diff --git a/sys/yellowstone/hw/gpt.cpp b/sys/yellowstone/hw/gpt.cpp index 52e526b..b2f2d35 100644 --- a/sys/yellowstone/hw/gpt.cpp +++ b/sys/yellowstone/hw/gpt.cpp @@ -64,8 +64,8 @@ glcr::ErrorCode GptReader::ParsePartitionTables() { req.set_size(2); ReadResponse resp; RET_ERR(denali_->Read(req, resp)); - OwnedMemoryRegion lba_1_and_2 = - OwnedMemoryRegion::FromCapability(resp.memory()); + mmth::OwnedMemoryRegion lba_1_and_2 = + mmth::OwnedMemoryRegion::FromCapability(resp.memory()); uint16_t* mbr_sig = reinterpret_cast(lba_1_and_2.vaddr() + 0x1FE); if (*mbr_sig != 0xAA55) { dbgln("Invalid MBR Sig: {x}", *mbr_sig); @@ -106,8 +106,8 @@ glcr::ErrorCode GptReader::ParsePartitionTables() { req.set_lba(header->lba_partition_entries); req.set_size(num_blocks); RET_ERR(denali_->Read(req, resp)); - OwnedMemoryRegion part_table = - OwnedMemoryRegion::FromCapability(resp.memory()); + mmth::OwnedMemoryRegion part_table = + mmth::OwnedMemoryRegion::FromCapability(resp.memory()); for (uint64_t i = 0; i < num_partitions; i++) { PartitionEntry* entry = reinterpret_cast( part_table.vaddr() + (i * entry_size)); diff --git a/sys/yellowstone/yellowstone.cpp b/sys/yellowstone/yellowstone.cpp index c4d2ef3..2711283 100644 --- a/sys/yellowstone/yellowstone.cpp +++ b/sys/yellowstone/yellowstone.cpp @@ -12,8 +12,9 @@ #include "yellowstone_server.h" glcr::ErrorCode SpawnProcess(z_cap_t vmmo_cap, z_cap_t yellowstone_cap) { - OwnedMemoryRegion region = OwnedMemoryRegion::FromCapability(vmmo_cap); - return SpawnProcessFromElfRegion(region.vaddr(), yellowstone_cap); + mmth::OwnedMemoryRegion region = + mmth::OwnedMemoryRegion::FromCapability(vmmo_cap); + return mmth::SpawnProcessFromElfRegion(region.vaddr(), yellowstone_cap); } uint64_t main(uint64_t port_cap) { @@ -41,8 +42,8 @@ uint64_t main(uint64_t port_cap) { OpenFileResponse response; check(vfs_client->OpenFile(request, response)); - OwnedMemoryRegion filemem = - OwnedMemoryRegion::FromCapability(response.memory()); + mmth::OwnedMemoryRegion filemem = + mmth::OwnedMemoryRegion::FromCapability(response.memory()); glcr::String file(reinterpret_cast(filemem.vaddr()), response.size()); diff --git a/sys/yellowstone/yellowstone_server.cpp b/sys/yellowstone/yellowstone_server.cpp index db55998..e164b63 100644 --- a/sys/yellowstone/yellowstone_server.cpp +++ b/sys/yellowstone/yellowstone_server.cpp @@ -51,8 +51,8 @@ glcr::ErrorCode YellowstoneServer::HandleGetAhciInfo(const Empty&, glcr::ErrorCode YellowstoneServer::HandleGetFramebufferInfo( const Empty&, FramebufferInfo& info) { // FIXME: Don't do this for each request. - OwnedMemoryRegion region = - OwnedMemoryRegion::FromCapability(gBootFramebufferVmmoCap); + mmth::OwnedMemoryRegion region = + mmth::OwnedMemoryRegion::FromCapability(gBootFramebufferVmmoCap); ZFramebufferInfo* fb = reinterpret_cast(region.vaddr()); info.set_address_phys(fb->address_phys); diff --git a/sys/yellowstone/yellowstone_server.h b/sys/yellowstone/yellowstone_server.h index 9d23c8f..b1de827 100644 --- a/sys/yellowstone/yellowstone_server.h +++ b/sys/yellowstone/yellowstone_server.h @@ -37,8 +37,8 @@ class YellowstoneServer : public YellowstoneServerBase { PciReader pci_reader_; - Semaphore has_denali_semaphore_; - Semaphore has_victoriafalls_semaphore_; + mmth::Semaphore has_denali_semaphore_; + mmth::Semaphore has_victoriafalls_semaphore_; YellowstoneServer(z_cap_t endpoint_cap); };