[Zion] Add an argument to memory align a mapping.
This commit is contained in:
parent
c8931a01c8
commit
d44be91099
11 changed files with 30 additions and 22 deletions
|
|
@ -26,11 +26,17 @@ void AddressSpace::FreeUserStack(uint64_t rsp) {
|
|||
return user_stacks_.FreeUserStack(rsp);
|
||||
}
|
||||
|
||||
uint64_t AddressSpace::GetNextMemMapAddr(uint64_t size) {
|
||||
uint64_t AddressSpace::GetNextMemMapAddr(uint64_t size, uint64_t align) {
|
||||
if (size == 0) {
|
||||
panic("Zero size memmap");
|
||||
}
|
||||
size = ((size - 1) & ~0xFFF) + 0x1000;
|
||||
// FIXME: We need to validate that align is a power of 2;
|
||||
if (align > 0) {
|
||||
while ((next_memmap_addr_ & (align - 1)) != 0) {
|
||||
next_memmap_addr_ += kPageSize;
|
||||
}
|
||||
}
|
||||
uint64_t addr = next_memmap_addr_;
|
||||
next_memmap_addr_ += size;
|
||||
if (next_memmap_addr_ >= 0x30'00000000) {
|
||||
|
|
@ -45,8 +51,8 @@ glcr::ErrorCode AddressSpace::MapInMemoryObject(
|
|||
}
|
||||
|
||||
glcr::ErrorOr<uint64_t> AddressSpace::MapInMemoryObject(
|
||||
const glcr::RefPtr<MemoryObject>& mem_obj) {
|
||||
uint64_t vaddr = GetNextMemMapAddr(mem_obj->size());
|
||||
const glcr::RefPtr<MemoryObject>& mem_obj, uint64_t align) {
|
||||
uint64_t vaddr = GetNextMemMapAddr(mem_obj->size(), align);
|
||||
RET_ERR(mapping_tree_.AddInMemoryObject(vaddr, mem_obj));
|
||||
return vaddr;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ class AddressSpace : public KernelObject {
|
|||
// User Mappings.
|
||||
uint64_t AllocateUserStack();
|
||||
void FreeUserStack(uint64_t);
|
||||
uint64_t GetNextMemMapAddr(uint64_t size);
|
||||
uint64_t GetNextMemMapAddr(uint64_t size, uint64_t align);
|
||||
|
||||
// Maps in a memory object at a specific address.
|
||||
// Note this is unsafe for now as it may clobber other mappings.
|
||||
|
|
@ -75,7 +75,7 @@ class AddressSpace : public KernelObject {
|
|||
uint64_t vaddr, const glcr::RefPtr<MemoryObject>& mem_obj);
|
||||
|
||||
[[nodiscard]] glcr::ErrorOr<uint64_t> MapInMemoryObject(
|
||||
const glcr::RefPtr<MemoryObject>& mem_obj);
|
||||
const glcr::RefPtr<MemoryObject>& mem_obj, uint64_t align);
|
||||
|
||||
[[nodiscard]] glcr::ErrorCode FreeAddressRange(uint64_t vaddr_base,
|
||||
uint64_t vaddr_limit) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue