[Mammoth] Move most classes to the mmth namespace.
This commit is contained in:
parent
5f8d577948
commit
8d730c67c1
|
@ -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
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
#include <stdint.h>
|
||||
#include <zcall.h>
|
||||
|
||||
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
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
#include "ipc/endpoint_server.h"
|
||||
|
||||
namespace mmth {
|
||||
|
||||
glcr::UniquePtr<EndpointClient> EndpointClient::AdoptEndpoint(z_cap_t cap) {
|
||||
return glcr::UniquePtr<EndpointClient>(new EndpointClient(cap));
|
||||
}
|
||||
|
||||
} // namespace mmth
|
||||
|
|
|
@ -6,6 +6,8 @@
|
|||
#include <zcall.h>
|
||||
#include <ztypes.h>
|
||||
|
||||
namespace mmth {
|
||||
|
||||
class EndpointClient {
|
||||
public:
|
||||
EndpointClient() = delete;
|
||||
|
@ -63,3 +65,5 @@ glcr::ErrorOr<Resp> EndpointClient::CallEndpoint(const Req& req) {
|
|||
|
||||
return resp;
|
||||
}
|
||||
|
||||
} // namespace mmth
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
#include "util/debug.h"
|
||||
|
||||
namespace mmth {
|
||||
// Declared as friend in EndpointServer.
|
||||
void EndpointServerThreadBootstrap(void* endpoint_server) {
|
||||
reinterpret_cast<EndpointServer*>(endpoint_server)->ServerThread();
|
||||
|
@ -40,3 +41,5 @@ void EndpointServer::ServerThread() {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace mmth
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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<glcr::ErrorCode>(
|
||||
ZPortSend(port_cap_, str.length() + 1, str.cstr(), 1, &cap));
|
||||
}
|
||||
|
||||
} // namespace mmth
|
||||
|
|
|
@ -5,6 +5,8 @@
|
|||
#include <stdint.h>
|
||||
#include <zcall.h>
|
||||
|
||||
namespace mmth {
|
||||
|
||||
class PortClient {
|
||||
public:
|
||||
PortClient() {}
|
||||
|
@ -29,3 +31,5 @@ template <typename T>
|
|||
z_err_t PortClient::WriteMessage(const T& obj, z_cap_t cap) {
|
||||
return ZPortSend(port_cap_, sizeof(obj), &obj, 1, &cap);
|
||||
}
|
||||
|
||||
} // namespace mmth
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
#include <zcall.h>
|
||||
|
||||
namespace mmth {
|
||||
|
||||
glcr::ErrorOr<PortServer> 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
|
||||
|
|
|
@ -5,6 +5,8 @@
|
|||
|
||||
#include "mammoth/ipc/port_client.h"
|
||||
|
||||
namespace mmth {
|
||||
|
||||
class PortServer {
|
||||
public:
|
||||
static glcr::ErrorOr<PortServer> Create();
|
||||
|
@ -22,3 +24,5 @@ class PortServer {
|
|||
|
||||
PortServer(z_cap_t cap);
|
||||
};
|
||||
|
||||
} // namespace mmth
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -4,5 +4,9 @@
|
|||
#include <stdint.h>
|
||||
#include <ztypes.h>
|
||||
|
||||
namespace mmth {
|
||||
|
||||
glcr::ErrorCode SpawnProcessFromElfRegion(uint64_t program,
|
||||
z_cap_t yellowstone_client);
|
||||
|
||||
} // namespace mmth
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
#include <zcall.h>
|
||||
|
||||
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<glcr::ErrorCode>(ZMutexRelease(mutex_cap_));
|
||||
}
|
||||
|
||||
} // namespace mmth
|
||||
|
|
|
@ -3,6 +3,8 @@
|
|||
#include <glacier/status/error_or.h>
|
||||
#include <ztypes.h>
|
||||
|
||||
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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
#include <ztypes.h>
|
||||
|
||||
namespace mmth {
|
||||
|
||||
class Semaphore {
|
||||
public:
|
||||
Semaphore();
|
||||
|
@ -13,3 +15,5 @@ class Semaphore {
|
|||
private:
|
||||
z_cap_t semaphore_cap_;
|
||||
};
|
||||
|
||||
} // namespace mmth
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
#include <stdint.h>
|
||||
#include <ztypes.h>
|
||||
|
||||
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
|
||||
|
|
|
@ -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<CommandList*>(command_structures_.vaddr());
|
||||
port_struct_->command_list_base = paddr;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -21,7 +21,7 @@ void interrupt_thread(void* void_driver) {
|
|||
} // namespace
|
||||
|
||||
glcr::ErrorOr<glcr::UniquePtr<AhciDriver>> AhciDriver::Init(
|
||||
OwnedMemoryRegion&& pci_region) {
|
||||
mmth::OwnedMemoryRegion&& pci_region) {
|
||||
glcr::UniquePtr<AhciDriver> 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<AhciHba*>(ahci_region_.vaddr());
|
||||
num_ports_ = (ahci_hba_->capabilities & 0x1F) + 1;
|
||||
num_commands_ = ((ahci_hba_->capabilities & 0x1F00) >> 8) + 1;
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
class AhciDriver {
|
||||
public:
|
||||
static glcr::ErrorOr<glcr::UniquePtr<AhciDriver>> 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<PciDeviceHeader*>(pci_region_.vaddr())) {}
|
||||
|
|
|
@ -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_;
|
||||
};
|
||||
|
|
|
@ -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<DenaliServer> server,
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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<uint32_t*>(fb_memory_.vaddr());
|
||||
}
|
||||
|
||||
|
|
|
@ -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_;
|
||||
};
|
||||
|
|
|
@ -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<PsfHeader*>(psf_file_.vaddr())) {
|
||||
EnsureValid();
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -13,8 +13,8 @@ glcr::ErrorOr<glcr::SharedPtr<Ext2BlockReader>> 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<Ext2BlockReader>(
|
||||
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<OwnedMemoryRegion> Ext2BlockReader::ReadBlock(
|
||||
glcr::ErrorOr<mmth::OwnedMemoryRegion> Ext2BlockReader::ReadBlock(
|
||||
uint64_t block_number) {
|
||||
return ReadBlocks(block_number, 1);
|
||||
}
|
||||
glcr::ErrorOr<OwnedMemoryRegion> Ext2BlockReader::ReadBlocks(
|
||||
glcr::ErrorOr<mmth::OwnedMemoryRegion> Ext2BlockReader::ReadBlocks(
|
||||
uint64_t block_number, uint64_t num_blocks) {
|
||||
ReadRequest req;
|
||||
req.set_device_id(device_id_);
|
||||
|
@ -71,10 +71,10 @@ glcr::ErrorOr<OwnedMemoryRegion> 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<OwnedMemoryRegion> Ext2BlockReader::ReadBlocks(
|
||||
glcr::ErrorOr<mmth::OwnedMemoryRegion> Ext2BlockReader::ReadBlocks(
|
||||
const glcr::Vector<uint64_t>& block_list) {
|
||||
ReadManyRequest req;
|
||||
req.set_device_id(device_id_);
|
||||
|
@ -93,12 +93,12 @@ glcr::ErrorOr<OwnedMemoryRegion> 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),
|
||||
|
|
|
@ -29,21 +29,21 @@ class Ext2BlockReader {
|
|||
// because the last table will likely be smaller.
|
||||
uint64_t InodeTableBlockSize();
|
||||
|
||||
glcr::ErrorOr<OwnedMemoryRegion> ReadBlock(uint64_t block_number);
|
||||
glcr::ErrorOr<OwnedMemoryRegion> ReadBlocks(uint64_t block_number,
|
||||
uint64_t num_blocks);
|
||||
glcr::ErrorOr<mmth::OwnedMemoryRegion> ReadBlock(uint64_t block_number);
|
||||
glcr::ErrorOr<mmth::OwnedMemoryRegion> ReadBlocks(uint64_t block_number,
|
||||
uint64_t num_blocks);
|
||||
|
||||
glcr::ErrorOr<OwnedMemoryRegion> ReadBlocks(
|
||||
glcr::ErrorOr<mmth::OwnedMemoryRegion> ReadBlocks(
|
||||
const glcr::Vector<uint64_t>& 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();
|
||||
};
|
||||
|
|
|
@ -8,7 +8,7 @@ glcr::ErrorOr<Ext2Driver> 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<InodeTable> inode_table(
|
||||
new InodeTable(reader, glcr::Move(bgdt)));
|
||||
|
@ -63,7 +63,7 @@ glcr::ErrorOr<glcr::Vector<DirEntry>> Ext2Driver::ReadDirectory(
|
|||
glcr::Vector<DirEntry> 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<glcr::Vector<DirEntry>> Ext2Driver::ReadDirectory(
|
|||
return directory;
|
||||
}
|
||||
|
||||
glcr::ErrorOr<OwnedMemoryRegion> Ext2Driver::ReadFile(uint64_t inode_number) {
|
||||
glcr::ErrorOr<mmth::OwnedMemoryRegion> 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<OwnedMemoryRegion> 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]));
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ class Ext2Driver {
|
|||
|
||||
glcr::ErrorOr<glcr::Vector<DirEntry>> ReadDirectory(uint32_t inode_number);
|
||||
|
||||
glcr::ErrorOr<OwnedMemoryRegion> ReadFile(uint64_t inode_number);
|
||||
glcr::ErrorOr<mmth::OwnedMemoryRegion> ReadFile(uint64_t inode_number);
|
||||
|
||||
private:
|
||||
glcr::SharedPtr<Ext2BlockReader> ext2_reader_;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#include "fs/ext2/inode_table.h"
|
||||
|
||||
InodeTable::InodeTable(const glcr::SharedPtr<Ext2BlockReader>& reader,
|
||||
OwnedMemoryRegion&& bgdt_region)
|
||||
mmth::OwnedMemoryRegion&& bgdt_region)
|
||||
: ext2_reader_(reader),
|
||||
bgdt_region_(glcr::Move(bgdt_region)),
|
||||
bgdt_(reinterpret_cast<BlockGroupDescriptor*>(bgdt_region_.vaddr())) {
|
||||
|
|
|
@ -9,16 +9,16 @@
|
|||
class InodeTable {
|
||||
public:
|
||||
InodeTable(const glcr::SharedPtr<Ext2BlockReader>& driver,
|
||||
OwnedMemoryRegion&& bgdt_region);
|
||||
mmth::OwnedMemoryRegion&& bgdt_region);
|
||||
|
||||
glcr::ErrorOr<Inode*> GetInode(uint32_t inode_num);
|
||||
|
||||
private:
|
||||
glcr::SharedPtr<Ext2BlockReader> ext2_reader_;
|
||||
OwnedMemoryRegion bgdt_region_;
|
||||
mmth::OwnedMemoryRegion bgdt_region_;
|
||||
BlockGroupDescriptor* bgdt_;
|
||||
|
||||
glcr::Vector<OwnedMemoryRegion> inode_tables_;
|
||||
glcr::Vector<mmth::OwnedMemoryRegion> inode_tables_;
|
||||
|
||||
glcr::ErrorOr<Inode*> GetRootOfInodeTable(uint64_t block_group_num);
|
||||
};
|
||||
|
|
|
@ -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)) {
|
||||
|
|
|
@ -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<uint16_t*>(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<PartitionEntry*>(
|
||||
part_table.vaddr() + (i * entry_size));
|
||||
|
|
|
@ -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<const char*>(filemem.vaddr()),
|
||||
response.size());
|
||||
|
||||
|
|
|
@ -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<ZFramebufferInfo*>(region.vaddr());
|
||||
|
||||
info.set_address_phys(fb->address_phys);
|
||||
|
|
|
@ -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);
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue