[Zion] Add an argument to memory align a mapping.

This commit is contained in:
Drew Galbraith 2023-11-23 18:49:01 -08:00
parent c8931a01c8
commit d44be91099
11 changed files with 30 additions and 22 deletions

View file

@ -13,9 +13,9 @@ class NaiveAllocator {
uint64_t vmmo_cap;
uint64_t err = ZMemoryObjectCreate(kSize, &vmmo_cap);
if (err != 0) {
ZProcessExit(err);
(void)ZProcessExit(err);
}
err = ZAddressSpaceMap(gSelfVmasCap, 0, vmmo_cap, &next_addr_);
err = ZAddressSpaceMap(gSelfVmasCap, 0, vmmo_cap, 0, &next_addr_);
max_addr_ = next_addr_ + kSize;
}
@ -23,7 +23,7 @@ class NaiveAllocator {
uint64_t addr = next_addr_;
next_addr_ += size;
if (next_addr_ >= max_addr_) {
ZProcessExit(0xBEEF);
(void)ZProcessExit(0xBEEF);
return 0;
}
return reinterpret_cast<void*>(addr);

View file

@ -81,7 +81,7 @@ uint64_t LoadElfProgram(uint64_t base, uint64_t as_cap) {
dbgln("Map Local");
#endif
uint64_t vaddr;
check(ZAddressSpaceMap(gSelfVmasCap, 0, mem_cap, &vaddr));
check(ZAddressSpaceMap(gSelfVmasCap, 0, mem_cap, 0, &vaddr));
uint8_t* offset = reinterpret_cast<uint8_t*>(vaddr);
for (uint64_t j = 0; j < size; j++) {
offset[j] = 0;
@ -95,8 +95,8 @@ uint64_t LoadElfProgram(uint64_t base, uint64_t as_cap) {
#if MAM_PROC_DEBUG
dbgln("Map Foreign");
#endif
check(
ZAddressSpaceMap(as_cap, program.vaddr - page_offset, mem_cap, &vaddr));
check(ZAddressSpaceMap(as_cap, program.vaddr - page_offset, mem_cap, 0,
&vaddr));
}
return header->entry;
}

View file

@ -3,7 +3,9 @@
#include <glacier/status/error.h>
#include <zcall.h>
void dbgln(const glcr::String& string) { (void)ZDebug(string.cstr()); }
void dbgln(glcr::StringView string) {
(void)ZDebug(string.data(), string.size());
}
void check(uint64_t code) {
switch (code) {

View file

@ -6,7 +6,7 @@
#include <ztypes.h>
// TODO: Take StringView here instead.
void dbgln(const glcr::String& string);
void dbgln(glcr::StringView string);
template <typename... Args>
void dbgln(const glcr::StringView& fmt, Args... args) {

View file

@ -36,7 +36,7 @@ OwnedMemoryRegion::~OwnedMemoryRegion() {
OwnedMemoryRegion OwnedMemoryRegion::FromCapability(z_cap_t vmmo_cap) {
uint64_t vaddr;
check(ZAddressSpaceMap(gSelfVmasCap, 0, vmmo_cap, &vaddr));
check(ZAddressSpaceMap(gSelfVmasCap, 0, vmmo_cap, 0, &vaddr));
uint64_t size;
check(ZMemoryObjectInspect(vmmo_cap, &size));
@ -50,7 +50,7 @@ OwnedMemoryRegion OwnedMemoryRegion::ContiguousPhysical(uint64_t size,
check(ZMemoryObjectCreateContiguous(size, &vmmo_cap, paddr));
uint64_t vaddr;
check(ZAddressSpaceMap(gSelfVmasCap, 0, vmmo_cap, &vaddr));
check(ZAddressSpaceMap(gSelfVmasCap, 0, vmmo_cap, 0, &vaddr));
return OwnedMemoryRegion(vmmo_cap, vaddr, size);
}
@ -61,7 +61,7 @@ OwnedMemoryRegion OwnedMemoryRegion::DirectPhysical(uint64_t paddr,
check(ZMemoryObjectCreatePhysical(paddr, size, &vmmo_cap));
uint64_t vaddr;
check(ZAddressSpaceMap(gSelfVmasCap, 0, vmmo_cap, &vaddr));
check(ZAddressSpaceMap(gSelfVmasCap, 0, vmmo_cap, 0, &vaddr));
return OwnedMemoryRegion(vmmo_cap, vaddr, size);
}