Compare commits
10 Commits
41bf78cf98
...
8ceab2ad23
Author | SHA1 | Date |
---|---|---|
|
8ceab2ad23 | |
|
86ce0a68a3 | |
|
4fd17a59ea | |
|
8d730c67c1 | |
|
5f8d577948 | |
|
c42fb858ba | |
|
99a75a4a76 | |
|
f1cbfd18b7 | |
|
ad5b55bf37 | |
|
19e394ae7b |
|
@ -1,27 +1,33 @@
|
|||
add_library(mammoth STATIC
|
||||
src/channel.cpp
|
||||
src/debug.cpp
|
||||
src/endpoint_client.cpp
|
||||
src/endpoint_server.cpp
|
||||
src/init.cpp
|
||||
src/memory_region.cpp
|
||||
src/mutex.cpp
|
||||
src/new.cpp
|
||||
src/process.cpp
|
||||
src/port_client.cpp
|
||||
src/port_server.cpp
|
||||
src/semaphore.cpp
|
||||
src/thread.cpp
|
||||
file/file.cpp
|
||||
ipc/channel.cpp
|
||||
ipc/endpoint_client.cpp
|
||||
ipc/endpoint_server.cpp
|
||||
ipc/port_client.cpp
|
||||
ipc/port_server.cpp
|
||||
proc/process.cpp
|
||||
proc/thread.cpp
|
||||
sync/mutex.cpp
|
||||
sync/semaphore.cpp
|
||||
util/debug.cpp
|
||||
util/init.cpp
|
||||
util/memory_region.cpp
|
||||
util/new.cpp
|
||||
)
|
||||
|
||||
target_include_directories(mammoth
|
||||
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include)
|
||||
PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/.."
|
||||
)
|
||||
|
||||
target_link_libraries(mammoth
|
||||
glacier
|
||||
c
|
||||
zion_stub)
|
||||
victoriafalls_yunq
|
||||
yellowstone_yunq
|
||||
zion_stub
|
||||
)
|
||||
|
||||
set_target_properties(mammoth PROPERTIES
|
||||
COMPILE_FLAGS "${CMAKE_CXX_FLAGS} ${BASE_COMPILE_FLAGS}"
|
||||
|
|
|
@ -0,0 +1,47 @@
|
|||
#include "file/file.h"
|
||||
|
||||
#include <victoriafalls/victoriafalls.yunq.client.h>
|
||||
#include <yellowstone/yellowstone.yunq.client.h>
|
||||
#include <zglobal.h>
|
||||
|
||||
#include "util/debug.h"
|
||||
|
||||
namespace mmth {
|
||||
namespace {
|
||||
|
||||
VFSClient* gVfsClient = nullptr;
|
||||
|
||||
} // namespace
|
||||
|
||||
void SetVfsCap(z_cap_t vfs_cap) { gVfsClient = new VFSClient(vfs_cap); }
|
||||
|
||||
File File::Open(glcr::StringView path) {
|
||||
if (gVfsClient == 0) {
|
||||
YellowstoneClient client(gInitEndpointCap);
|
||||
|
||||
GetEndpointRequest yreq;
|
||||
yreq.set_endpoint_name("victoriafalls");
|
||||
Endpoint yresp;
|
||||
check(client.GetEndpoint(yreq, yresp));
|
||||
|
||||
gVfsClient = new VFSClient(yresp.endpoint());
|
||||
}
|
||||
|
||||
OpenFileRequest req;
|
||||
req.set_path(path);
|
||||
OpenFileResponse resp;
|
||||
check(gVfsClient->OpenFile(req, resp));
|
||||
|
||||
return File(OwnedMemoryRegion::FromCapability(resp.memory()), resp.size());
|
||||
}
|
||||
|
||||
glcr::StringView File::as_str() {
|
||||
return glcr::StringView((char*)raw_ptr(), size_);
|
||||
}
|
||||
|
||||
void* File::raw_ptr() { return reinterpret_cast<void*>(file_data_.vaddr()); }
|
||||
uint8_t* File::byte_ptr() {
|
||||
return reinterpret_cast<uint8_t*>(file_data_.vaddr());
|
||||
}
|
||||
|
||||
} // namespace mmth
|
|
@ -0,0 +1,32 @@
|
|||
#pragma once
|
||||
|
||||
#include <glacier/memory/move.h>
|
||||
#include <glacier/string/string_view.h>
|
||||
|
||||
#include "mammoth/util/memory_region.h"
|
||||
|
||||
namespace mmth {
|
||||
|
||||
// Intended for use in yellowstone since it already has the VFS cap.
|
||||
void SetVfsCap(z_cap_t vfs_cap);
|
||||
|
||||
class File {
|
||||
public:
|
||||
static File Open(glcr::StringView path);
|
||||
|
||||
uint64_t size() { return size_; }
|
||||
|
||||
glcr::StringView as_str();
|
||||
|
||||
void* raw_ptr();
|
||||
uint8_t* byte_ptr();
|
||||
|
||||
private:
|
||||
OwnedMemoryRegion file_data_;
|
||||
uint64_t size_;
|
||||
|
||||
File(OwnedMemoryRegion&& file, uint64_t size)
|
||||
: file_data_(glcr::Move(file)), size_(size) {}
|
||||
};
|
||||
|
||||
} // namespace mmth
|
|
@ -1,9 +1,10 @@
|
|||
#include "mammoth/channel.h"
|
||||
#include "ipc/channel.h"
|
||||
|
||||
#include <zcall.h>
|
||||
|
||||
#include "mammoth/debug.h"
|
||||
#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 "mammoth/endpoint_server.h"
|
||||
#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
|
|
@ -1,7 +1,8 @@
|
|||
#include "mammoth/endpoint_server.h"
|
||||
#include "ipc/endpoint_server.h"
|
||||
|
||||
#include "mammoth/debug.h"
|
||||
#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
|
|
@ -4,11 +4,12 @@
|
|||
#include <glacier/status/error_or.h>
|
||||
#include <ztypes.h>
|
||||
|
||||
#include "mammoth/endpoint_client.h"
|
||||
#include "mammoth/request_context.h"
|
||||
#include "mammoth/response_context.h"
|
||||
#include "mammoth/thread.h"
|
||||
#include "mammoth/ipc/endpoint_client.h"
|
||||
#include "mammoth/ipc/request_context.h"
|
||||
#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
|
|
@ -1,9 +1,11 @@
|
|||
#include "mammoth/port_client.h"
|
||||
#include "ipc/port_client.h"
|
||||
|
||||
#include <glacier/status/error.h>
|
||||
#include <zcall.h>
|
||||
|
||||
#include "mammoth/debug.h"
|
||||
#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
|
|
@ -1,7 +1,9 @@
|
|||
#include "mammoth/port_server.h"
|
||||
#include "ipc/port_server.h"
|
||||
|
||||
#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
|
|
@ -3,7 +3,9 @@
|
|||
#include <glacier/status/error_or.h>
|
||||
#include <ztypes.h>
|
||||
|
||||
#include "mammoth/port_client.h"
|
||||
#include "mammoth/ipc/port_client.h"
|
||||
|
||||
namespace mmth {
|
||||
|
||||
class PortServer {
|
||||
public:
|
||||
|
@ -22,3 +24,5 @@ class PortServer {
|
|||
|
||||
PortServer(z_cap_t cap);
|
||||
};
|
||||
|
||||
} // namespace mmth
|
|
@ -1,16 +1,17 @@
|
|||
#include "mammoth/process.h"
|
||||
#include "proc/process.h"
|
||||
|
||||
#include <glacier/status/error.h>
|
||||
#include <zcall.h>
|
||||
|
||||
#include "mammoth/debug.h"
|
||||
#include "mammoth/endpoint_server.h"
|
||||
#include "mammoth/init.h"
|
||||
#include "mammoth/port_client.h"
|
||||
#include "mammoth/port_server.h"
|
||||
#include "ipc/endpoint_server.h"
|
||||
#include "ipc/port_client.h"
|
||||
#include "ipc/port_server.h"
|
||||
#include "util/debug.h"
|
||||
#include "util/init.h"
|
||||
|
||||
#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
|
|
@ -2,8 +2,11 @@
|
|||
|
||||
#include <glacier/status/error.h>
|
||||
#include <stdint.h>
|
||||
#include <ztypes.h>
|
||||
|
||||
#include "mammoth/endpoint_client.h"
|
||||
namespace mmth {
|
||||
|
||||
glcr::ErrorCode SpawnProcessFromElfRegion(uint64_t program,
|
||||
z_cap_t yellowstone_client);
|
||||
|
||||
} // namespace mmth
|
|
@ -1,9 +1,9 @@
|
|||
#include "mammoth/thread.h"
|
||||
#include "proc/thread.h"
|
||||
|
||||
#include <zcall.h>
|
||||
|
||||
#include "mammoth/debug.h"
|
||||
#include "mammoth/init.h"
|
||||
#include "util/debug.h"
|
||||
#include "util/init.h"
|
||||
|
||||
namespace {
|
||||
|
|
@ -1,7 +1,9 @@
|
|||
#include "mammoth/mutex.h"
|
||||
#include "sync/mutex.h"
|
||||
|
||||
#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
|
|
@ -1,11 +1,15 @@
|
|||
#include "mammoth/semaphore.h"
|
||||
#include "sync/semaphore.h"
|
||||
|
||||
#include <zcall.h>
|
||||
|
||||
#include "mammoth/debug.h"
|
||||
#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
|
|
@ -1,4 +1,4 @@
|
|||
#include "include/mammoth/debug.h"
|
||||
#include "util/debug.h"
|
||||
|
||||
#include <glacier/status/error.h>
|
||||
#include <zcall.h>
|
|
@ -1,10 +1,10 @@
|
|||
#include "mammoth/init.h"
|
||||
#include "util/init.h"
|
||||
|
||||
#include <glacier/status/error.h>
|
||||
#include <ztypes.h>
|
||||
|
||||
#include "mammoth/debug.h"
|
||||
#include "mammoth/port_server.h"
|
||||
#include "ipc/port_server.h"
|
||||
#include "util/debug.h"
|
||||
|
||||
uint64_t gSelfProcCap = 0;
|
||||
uint64_t gSelfVmasCap = 0;
|
||||
|
@ -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) {
|
|
@ -1,9 +1,11 @@
|
|||
#include "mammoth/memory_region.h"
|
||||
#include "util/memory_region.h"
|
||||
|
||||
#include <zcall.h>
|
||||
|
||||
#include "mammoth/debug.h"
|
||||
#include "mammoth/init.h"
|
||||
#include "util/debug.h"
|
||||
#include "util/init.h"
|
||||
|
||||
namespace mmth {
|
||||
|
||||
OwnedMemoryRegion::OwnedMemoryRegion(OwnedMemoryRegion&& other)
|
||||
: OwnedMemoryRegion(other.vmmo_cap_, other.vaddr_, other.size_) {
|
||||
|
@ -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
|
|
@ -1,7 +1,7 @@
|
|||
#include "ahci/ahci_device.h"
|
||||
|
||||
#include <glacier/status/error.h>
|
||||
#include <mammoth/debug.h>
|
||||
#include <mammoth/util/debug.h>
|
||||
#include <string.h>
|
||||
#include <zcall.h>
|
||||
|
||||
|
@ -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;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <glacier/status/error.h>
|
||||
#include <mammoth/memory_region.h>
|
||||
#include <mammoth/util/memory_region.h>
|
||||
#include <ztypes.h>
|
||||
|
||||
#include "ahci/ahci.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;
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
#include <glacier/status/error.h>
|
||||
#include <glacier/status/error_or.h>
|
||||
#include <mammoth/debug.h>
|
||||
#include <mammoth/util/debug.h>
|
||||
#include <stdint.h>
|
||||
#include <zcall.h>
|
||||
|
||||
|
@ -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;
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
#include <glacier/memory/unique_ptr.h>
|
||||
#include <glacier/status/error_or.h>
|
||||
#include <mammoth/thread.h>
|
||||
#include <mammoth/proc/thread.h>
|
||||
#include <ztypes.h>
|
||||
|
||||
#include "ahci/ahci.h"
|
||||
|
@ -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())) {}
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
#pragma once
|
||||
|
||||
#include <mammoth/memory_region.h>
|
||||
#include <mammoth/response_context.h>
|
||||
#include <mammoth/semaphore.h>
|
||||
#include <mammoth/sync/semaphore.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "ahci/ahci.h"
|
||||
|
@ -34,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_;
|
||||
};
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
|
||||
#include <mammoth/debug.h>
|
||||
#include <mammoth/endpoint_server.h>
|
||||
#include <mammoth/init.h>
|
||||
#include <mammoth/port_client.h>
|
||||
#include <mammoth/util/debug.h>
|
||||
#include <mammoth/util/init.h>
|
||||
#include <stdint.h>
|
||||
#include <yellowstone/yellowstone.yunq.client.h>
|
||||
|
||||
|
@ -11,15 +9,13 @@
|
|||
|
||||
uint64_t main(uint64_t init_port_cap) {
|
||||
check(ParseInitPort(init_port_cap));
|
||||
glcr::UniquePtr<EndpointClient> yellowstone =
|
||||
EndpointClient::AdoptEndpoint(gInitEndpointCap);
|
||||
|
||||
YellowstoneClient stub(gInitEndpointCap);
|
||||
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,
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
#include <glacier/memory/move.h>
|
||||
#include <glacier/status/error.h>
|
||||
#include <mammoth/debug.h>
|
||||
#include <mammoth/util/debug.h>
|
||||
#include <zcall.h>
|
||||
|
||||
glcr::ErrorOr<glcr::UniquePtr<DenaliServer>> DenaliServer::Create(
|
||||
|
@ -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);
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
#pragma once
|
||||
|
||||
#include <glacier/status/error.h>
|
||||
#include <mammoth/endpoint_server.h>
|
||||
|
||||
#include "ahci/ahci_driver.h"
|
||||
#include "lib/denali/denali.yunq.server.h"
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
// Generated file -- DO NOT MODIFY.
|
||||
#include "denali.yunq.server.h"
|
||||
|
||||
#include <mammoth/debug.h>
|
||||
#include <mammoth/util/debug.h>
|
||||
#include <zcall.h>
|
||||
|
||||
namespace {
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <glacier/status/error_or.h>
|
||||
#include <mammoth/thread.h>
|
||||
#include <mammoth/proc/thread.h>
|
||||
#include <ztypes.h>
|
||||
|
||||
#include "denali.yunq.h"
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include "framebuffer/console.h"
|
||||
|
||||
#include <mammoth/debug.h>
|
||||
#include <mammoth/util/debug.h>
|
||||
|
||||
void Console::WriteChar(char c) {
|
||||
if (c == '\n') {
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#pragma once
|
||||
|
||||
#include <mammoth/memory_region.h>
|
||||
#include <mammoth/util/memory_region.h>
|
||||
#include <yellowstone/yellowstone.yunq.h>
|
||||
|
||||
class Framebuffer {
|
||||
|
@ -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_;
|
||||
};
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#include "framebuffer/psf.h"
|
||||
|
||||
#include <glacier/memory/move.h>
|
||||
#include <mammoth/debug.h>
|
||||
#include <mammoth/util/debug.h>
|
||||
|
||||
namespace {
|
||||
|
||||
|
@ -9,9 +9,9 @@ const uint32_t kMagic = 0x864AB572;
|
|||
|
||||
}
|
||||
|
||||
Psf::Psf(OwnedMemoryRegion&& psf_file)
|
||||
: psf_file_(glcr::Move(psf_file)),
|
||||
header_(reinterpret_cast<PsfHeader*>(psf_file_.vaddr())) {
|
||||
Psf::Psf(glcr::StringView path)
|
||||
: psf_file_(mmth::File::Open(path)),
|
||||
header_(reinterpret_cast<PsfHeader*>(psf_file_.raw_ptr())) {
|
||||
EnsureValid();
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#pragma once
|
||||
|
||||
#include <mammoth/memory_region.h>
|
||||
#include <mammoth/file/file.h>
|
||||
|
||||
struct PsfHeader {
|
||||
uint32_t magic; /* magic bytes to identify PSF */
|
||||
|
@ -15,7 +15,7 @@ struct PsfHeader {
|
|||
|
||||
class Psf {
|
||||
public:
|
||||
Psf(OwnedMemoryRegion&& psf_file);
|
||||
Psf(glcr::StringView path);
|
||||
|
||||
void DumpHeader();
|
||||
|
||||
|
@ -24,12 +24,13 @@ class Psf {
|
|||
uint32_t height() { return header_->height; }
|
||||
|
||||
uint8_t* glyph(uint32_t index) {
|
||||
return reinterpret_cast<uint8_t*>(psf_file_.vaddr() + header_->headersize +
|
||||
return reinterpret_cast<uint8_t*>(psf_file_.byte_ptr() +
|
||||
header_->headersize +
|
||||
(index * header_->bytesperglyph));
|
||||
}
|
||||
|
||||
private:
|
||||
OwnedMemoryRegion psf_file_;
|
||||
mmth::File psf_file_;
|
||||
PsfHeader* header_;
|
||||
|
||||
void EnsureValid();
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include <mammoth/debug.h>
|
||||
#include <mammoth/init.h>
|
||||
#include <mammoth/util/debug.h>
|
||||
#include <mammoth/util/init.h>
|
||||
#include <victoriafalls/victoriafalls.yunq.client.h>
|
||||
#include <yellowstone/yellowstone.yunq.client.h>
|
||||
|
||||
|
@ -25,19 +25,7 @@ uint64_t main(uint64_t init_port) {
|
|||
|
||||
// 2. Parse a font file.
|
||||
|
||||
GetEndpointRequest req;
|
||||
req.set_endpoint_name("victoriafalls");
|
||||
Endpoint resp;
|
||||
check(client.GetEndpoint(req, resp));
|
||||
|
||||
VFSClient vfs(resp.endpoint());
|
||||
|
||||
OpenFileRequest freq;
|
||||
freq.set_path("/default8x16.psfu");
|
||||
OpenFileResponse fresp;
|
||||
check(vfs.OpenFile(freq, fresp));
|
||||
|
||||
Psf psf(OwnedMemoryRegion::FromCapability(fresp.memory()));
|
||||
Psf psf("/default8x16.psfu");
|
||||
psf.DumpHeader();
|
||||
|
||||
Console console(fbuf, psf);
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include "fs/ext2/ext2_block_reader.h"
|
||||
|
||||
#include "mammoth/debug.h"
|
||||
#include <mammoth/util/debug.h>
|
||||
|
||||
glcr::ErrorOr<glcr::SharedPtr<Ext2BlockReader>> Ext2BlockReader::Init(
|
||||
const DenaliInfo& denali_info) {
|
||||
|
@ -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),
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#include <denali/denali.yunq.client.h>
|
||||
#include <glacier/memory/shared_ptr.h>
|
||||
#include <glacier/status/error_or.h>
|
||||
#include <mammoth/memory_region.h>
|
||||
#include <mammoth/util/memory_region.h>
|
||||
#include <yellowstone/yellowstone.yunq.h>
|
||||
|
||||
#include "fs/ext2/ext2.h"
|
||||
|
@ -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();
|
||||
};
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
#include "fs/ext2/ext2_driver.h"
|
||||
|
||||
#include <glacier/string/string.h>
|
||||
#include <mammoth/debug.h>
|
||||
#include <mammoth/util/debug.h>
|
||||
|
||||
glcr::ErrorOr<Ext2Driver> Ext2Driver::Init(const DenaliInfo& denali_info) {
|
||||
ASSIGN_OR_RETURN(glcr::SharedPtr<Ext2BlockReader> reader,
|
||||
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)) {
|
||||
|
@ -103,12 +104,13 @@ glcr::ErrorOr<OwnedMemoryRegion> Ext2Driver::ReadFile(uint64_t inode_number) {
|
|||
return glcr::UNIMPLEMENTED;
|
||||
}
|
||||
|
||||
mmth::OwnedMemoryRegion double_indirect_block;
|
||||
if (inode->block[13]) {
|
||||
dbgln("Can't handle doubly-indirect blocks yet.");
|
||||
return glcr::UNIMPLEMENTED;
|
||||
ASSIGN_OR_RETURN(double_indirect_block,
|
||||
ext2_reader_->ReadBlock(inode->block[13]));
|
||||
}
|
||||
|
||||
OwnedMemoryRegion indirect_block;
|
||||
mmth::OwnedMemoryRegion indirect_block;
|
||||
if (inode->block[12]) {
|
||||
ASSIGN_OR_RETURN(indirect_block, ext2_reader_->ReadBlock(inode->block[12]));
|
||||
}
|
||||
|
@ -118,10 +120,31 @@ glcr::ErrorOr<OwnedMemoryRegion> Ext2Driver::ReadFile(uint64_t inode_number) {
|
|||
blocks_to_read.PushBack(inode->block[i]);
|
||||
}
|
||||
|
||||
uint32_t* indr_block_array =
|
||||
reinterpret_cast<uint32_t*>(indirect_block.vaddr());
|
||||
for (uint64_t i = 12; i < 268 && i < real_block_cnt; i++) {
|
||||
uint32_t* block_array = reinterpret_cast<uint32_t*>(indirect_block.vaddr());
|
||||
uint64_t offset = i - 12;
|
||||
blocks_to_read.PushBack(block_array[offset]);
|
||||
blocks_to_read.PushBack(indr_block_array[offset]);
|
||||
}
|
||||
|
||||
uint32_t* dbl_indr_block_array =
|
||||
reinterpret_cast<uint32_t*>(double_indirect_block.vaddr());
|
||||
for (uint64_t i = 0; i < 256; i++) {
|
||||
uint64_t block = 268 + (256 * i);
|
||||
if (block >= real_block_cnt) {
|
||||
break;
|
||||
}
|
||||
ASSIGN_OR_RETURN(mmth::OwnedMemoryRegion single_indr_block,
|
||||
ext2_reader_->ReadBlock(dbl_indr_block_array[i]));
|
||||
uint32_t* single_indr_block_array =
|
||||
reinterpret_cast<uint32_t*>(single_indr_block.vaddr());
|
||||
for (uint64_t j = 0; j < 256; j++) {
|
||||
uint64_t block_inner = block + j;
|
||||
if (block_inner >= real_block_cnt) {
|
||||
break;
|
||||
}
|
||||
blocks_to_read.PushBack(single_indr_block_array[j]);
|
||||
}
|
||||
}
|
||||
|
||||
return ext2_reader_->ReadBlocks(blocks_to_read);
|
||||
|
|
|
@ -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,9 +1,7 @@
|
|||
#include "fs/ext2/inode_table.h"
|
||||
|
||||
#include <mammoth/debug.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())) {
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <glacier/container/vector.h>
|
||||
#include <mammoth/util/memory_region.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "fs/ext2/ext2_block_reader.h"
|
||||
|
@ -8,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);
|
||||
};
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
// Generated file -- DO NOT MODIFY.
|
||||
#include "victoriafalls.yunq.server.h"
|
||||
|
||||
#include <mammoth/debug.h>
|
||||
#include <mammoth/util/debug.h>
|
||||
#include <zcall.h>
|
||||
|
||||
namespace {
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <glacier/status/error_or.h>
|
||||
#include <mammoth/thread.h>
|
||||
#include <mammoth/proc/thread.h>
|
||||
#include <ztypes.h>
|
||||
|
||||
#include "victoriafalls.yunq.h"
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include <mammoth/debug.h>
|
||||
#include <mammoth/init.h>
|
||||
#include <mammoth/util/debug.h>
|
||||
#include <mammoth/util/init.h>
|
||||
#include <yellowstone/yellowstone.yunq.client.h>
|
||||
|
||||
#include "fs/ext2/ext2_driver.h"
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#include "victoriafalls_server.h"
|
||||
|
||||
#include <glacier/string/str_split.h>
|
||||
#include <mammoth/debug.h>
|
||||
#include <mammoth/util/debug.h>
|
||||
#include <zcall.h>
|
||||
|
||||
glcr::ErrorOr<glcr::UniquePtr<VFSServer>> VFSServer::Create(
|
||||
|
@ -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)) {
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
|
||||
#include <glacier/memory/move.h>
|
||||
#include <glacier/status/error.h>
|
||||
#include <mammoth/debug.h>
|
||||
#include <mammoth/memory_region.h>
|
||||
#include <mammoth/util/debug.h>
|
||||
#include <mammoth/util/memory_region.h>
|
||||
#include <zcall.h>
|
||||
#include <zglobal.h>
|
||||
|
||||
|
@ -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));
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#include "hw/pcie.h"
|
||||
|
||||
#include <mammoth/debug.h>
|
||||
#include <mammoth/init.h>
|
||||
#include <mammoth/util/debug.h>
|
||||
#include <mammoth/util/init.h>
|
||||
#include <zcall.h>
|
||||
|
||||
#define PCI_DEBUG 0
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
// Generated file -- DO NOT MODIFY.
|
||||
#include "yellowstone.yunq.server.h"
|
||||
|
||||
#include <mammoth/debug.h>
|
||||
#include <mammoth/util/debug.h>
|
||||
#include <zcall.h>
|
||||
|
||||
namespace {
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <glacier/status/error_or.h>
|
||||
#include <mammoth/thread.h>
|
||||
#include <mammoth/proc/thread.h>
|
||||
#include <ztypes.h>
|
||||
|
||||
#include "yellowstone.yunq.h"
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
#include <glacier/string/str_format.h>
|
||||
#include <glacier/string/str_split.h>
|
||||
#include <mammoth/debug.h>
|
||||
#include <mammoth/endpoint_client.h>
|
||||
#include <mammoth/init.h>
|
||||
#include <mammoth/memory_region.h>
|
||||
#include <mammoth/process.h>
|
||||
#include <mammoth/file/file.h>
|
||||
#include <mammoth/proc/process.h>
|
||||
#include <mammoth/util/debug.h>
|
||||
#include <mammoth/util/init.h>
|
||||
#include <mammoth/util/memory_region.h>
|
||||
#include <zcall.h>
|
||||
#include <ztypes.h>
|
||||
|
||||
|
@ -13,8 +13,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) {
|
||||
|
@ -27,38 +28,28 @@ uint64_t main(uint64_t port_cap) {
|
|||
ASSIGN_OR_RETURN(YellowstoneClient client1, server->CreateClient());
|
||||
check(SpawnProcess(gBootDenaliVmmoCap, client1.Capability()));
|
||||
|
||||
check(server->WaitDenaliRegistered());
|
||||
server->WaitDenaliRegistered();
|
||||
|
||||
ASSIGN_OR_RETURN(YellowstoneClient client2, server->CreateClient());
|
||||
check(SpawnProcess(gBootVictoriaFallsVmmoCap, client2.Capability()));
|
||||
|
||||
check(server->WaitVictoriaFallsRegistered());
|
||||
server->WaitVictoriaFallsRegistered();
|
||||
|
||||
dbgln("VFS Available.");
|
||||
|
||||
auto vfs_client = server->GetVFSClient();
|
||||
OpenFileRequest request;
|
||||
request.set_path("/init.txt");
|
||||
OpenFileResponse response;
|
||||
check(vfs_client->OpenFile(request, response));
|
||||
mmth::File init_file = mmth::File::Open("/init.txt");
|
||||
|
||||
OwnedMemoryRegion filemem =
|
||||
OwnedMemoryRegion::FromCapability(response.memory());
|
||||
glcr::String file(reinterpret_cast<const char*>(filemem.vaddr()),
|
||||
response.size());
|
||||
|
||||
glcr::Vector<glcr::StringView> files = glcr::StrSplit(file, '\n');
|
||||
glcr::Vector<glcr::StringView> files =
|
||||
glcr::StrSplit(init_file.as_str(), '\n');
|
||||
|
||||
for (uint64_t i = 0; i < files.size(); i++) {
|
||||
if (!files[i].empty()) {
|
||||
dbgln("Starting {}", files[i]);
|
||||
OpenFileRequest req;
|
||||
req.set_path(glcr::StrFormat("/bin/{}", files[i]));
|
||||
OpenFileResponse resp;
|
||||
check(vfs_client->OpenFile(req, resp));
|
||||
mmth::File binary =
|
||||
mmth::File::Open(glcr::StrFormat("/bin/{}", files[i]));
|
||||
|
||||
ASSIGN_OR_RETURN(YellowstoneClient client3, server->CreateClient());
|
||||
check(SpawnProcess(resp.memory(), client3.Capability()));
|
||||
check(mmth::SpawnProcessFromElfRegion((uint64_t)binary.raw_ptr(),
|
||||
client3.Capability()));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2,11 +2,12 @@
|
|||
|
||||
#include <denali/denali.yunq.client.h>
|
||||
#include <glacier/string/string.h>
|
||||
#include <mammoth/debug.h>
|
||||
#include <mammoth/init.h>
|
||||
#include <mammoth/memory_region.h>
|
||||
#include <mammoth/process.h>
|
||||
#include <mammoth/file/file.h>
|
||||
#include <mammoth/util/debug.h>
|
||||
#include <mammoth/util/init.h>
|
||||
#include <mammoth/util/memory_region.h>
|
||||
#include <stdlib.h>
|
||||
#include <zcall.h>
|
||||
|
||||
#include "hw/gpt.h"
|
||||
#include "hw/pcie.h"
|
||||
|
@ -34,21 +35,12 @@ glcr::ErrorOr<glcr::UniquePtr<YellowstoneServer>> YellowstoneServer::Create() {
|
|||
z_cap_t endpoint_cap;
|
||||
RET_ERR(ZEndpointCreate(&endpoint_cap));
|
||||
|
||||
ASSIGN_OR_RETURN(Mutex denali_mut, Mutex::Create());
|
||||
RET_ERR(denali_mut.Lock());
|
||||
|
||||
ASSIGN_OR_RETURN(Mutex victoriafalls_mut, Mutex::Create());
|
||||
RET_ERR(victoriafalls_mut.Lock());
|
||||
|
||||
return glcr::UniquePtr<YellowstoneServer>(new YellowstoneServer(
|
||||
endpoint_cap, glcr::Move(denali_mut), glcr::Move(victoriafalls_mut)));
|
||||
return glcr::UniquePtr<YellowstoneServer>(
|
||||
new YellowstoneServer(endpoint_cap));
|
||||
}
|
||||
|
||||
YellowstoneServer::YellowstoneServer(z_cap_t endpoint_cap, Mutex&& denali_mutex,
|
||||
Mutex&& victoriafalls_mutex)
|
||||
: YellowstoneServerBase(endpoint_cap),
|
||||
has_denali_mutex_(glcr::Move(denali_mutex)),
|
||||
has_victoriafalls_mutex_(glcr::Move(victoriafalls_mutex)) {}
|
||||
YellowstoneServer::YellowstoneServer(z_cap_t endpoint_cap)
|
||||
: YellowstoneServerBase(endpoint_cap) {}
|
||||
|
||||
glcr::ErrorCode YellowstoneServer::HandleGetAhciInfo(const Empty&,
|
||||
AhciInfo& info) {
|
||||
|
@ -60,8 +52,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);
|
||||
|
@ -105,12 +97,12 @@ glcr::ErrorCode YellowstoneServer::HandleRegisterEndpoint(
|
|||
device_id_ = part_info_or.value().device_id;
|
||||
lba_offset_ = part_info_or.value().partition_lba;
|
||||
|
||||
check(has_denali_mutex_.Release());
|
||||
has_denali_semaphore_.Signal();
|
||||
} else if (req.endpoint_name() == "victoriafalls") {
|
||||
// FIXME: Probably make a separate copy for use within yellowstone vs
|
||||
// transmit to other processes.
|
||||
vfs_client_ = glcr::MakeShared<VFSClient>(req.endpoint_capability());
|
||||
check(has_victoriafalls_mutex_.Release());
|
||||
mmth::SetVfsCap(req.endpoint_capability());
|
||||
has_victoriafalls_semaphore_.Signal();
|
||||
} else {
|
||||
dbgln("[WARN] Got endpoint cap type: {}", req.endpoint_name().cstr());
|
||||
}
|
||||
|
@ -129,16 +121,8 @@ glcr::ErrorCode YellowstoneServer::HandleGetEndpoint(
|
|||
return glcr::OK;
|
||||
}
|
||||
|
||||
glcr::ErrorCode YellowstoneServer::WaitDenaliRegistered() {
|
||||
RET_ERR(has_denali_mutex_.Lock());
|
||||
return has_denali_mutex_.Release();
|
||||
}
|
||||
void YellowstoneServer::WaitDenaliRegistered() { has_denali_semaphore_.Wait(); }
|
||||
|
||||
glcr::ErrorCode YellowstoneServer::WaitVictoriaFallsRegistered() {
|
||||
RET_ERR(has_victoriafalls_mutex_.Lock());
|
||||
return has_victoriafalls_mutex_.Release();
|
||||
}
|
||||
|
||||
glcr::SharedPtr<VFSClient> YellowstoneServer::GetVFSClient() {
|
||||
return vfs_client_;
|
||||
void YellowstoneServer::WaitVictoriaFallsRegistered() {
|
||||
has_victoriafalls_semaphore_.Wait();
|
||||
}
|
||||
|
|
|
@ -4,10 +4,7 @@
|
|||
#include <glacier/memory/shared_ptr.h>
|
||||
#include <glacier/memory/unique_ptr.h>
|
||||
#include <glacier/status/error_or.h>
|
||||
#include <mammoth/endpoint_server.h>
|
||||
#include <mammoth/mutex.h>
|
||||
#include <mammoth/port_server.h>
|
||||
#include <mammoth/thread.h>
|
||||
#include <mammoth/sync/semaphore.h>
|
||||
#include <victoriafalls/victoriafalls.yunq.client.h>
|
||||
|
||||
#include "hw/pcie.h"
|
||||
|
@ -26,10 +23,8 @@ class YellowstoneServer : public YellowstoneServerBase {
|
|||
glcr::ErrorCode HandleGetEndpoint(const GetEndpointRequest&,
|
||||
Endpoint&) override;
|
||||
|
||||
glcr::ErrorCode WaitDenaliRegistered();
|
||||
glcr::ErrorCode WaitVictoriaFallsRegistered();
|
||||
|
||||
glcr::SharedPtr<VFSClient> GetVFSClient();
|
||||
void WaitDenaliRegistered();
|
||||
void WaitVictoriaFallsRegistered();
|
||||
|
||||
private:
|
||||
glcr::HashMap<glcr::String, z_cap_t> endpoint_map_;
|
||||
|
@ -40,9 +35,8 @@ class YellowstoneServer : public YellowstoneServerBase {
|
|||
|
||||
PciReader pci_reader_;
|
||||
|
||||
Mutex has_denali_mutex_;
|
||||
Mutex has_victoriafalls_mutex_;
|
||||
mmth::Semaphore has_denali_semaphore_;
|
||||
mmth::Semaphore has_victoriafalls_semaphore_;
|
||||
|
||||
YellowstoneServer(z_cap_t endpoint_cap, Mutex&& denali_mutex,
|
||||
Mutex&& victoriafalls_mutex);
|
||||
YellowstoneServer(z_cap_t endpoint_cap);
|
||||
};
|
||||
|
|
|
@ -1 +1,2 @@
|
|||
teton
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
// Generated file -- DO NOT MODIFY.
|
||||
#include "{{file}}.server.h"
|
||||
|
||||
#include <mammoth/debug.h>
|
||||
#include <mammoth/util/debug.h>
|
||||
#include <zcall.h>
|
||||
|
||||
namespace {
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <glacier/status/error_or.h>
|
||||
#include <mammoth/thread.h>
|
||||
#include <mammoth/proc/thread.h>
|
||||
#include <ztypes.h>
|
||||
|
||||
#include "{{file}}.h"
|
||||
|
|
Loading…
Reference in New Issue