Create a MemoryObject class and use it to load programs.
This commit is contained in:
parent
1fda0f3fae
commit
b06c76e477
9 changed files with 209 additions and 49 deletions
30
zion/object/memory_object.h
Normal file
30
zion/object/memory_object.h
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
#pragma once
|
||||
|
||||
#include "lib/linked_list.h"
|
||||
#include "object/kernel_object.h"
|
||||
|
||||
/*
|
||||
* MemoryObject is a page-aligned set of memory that corresponds
|
||||
* to physical pages.
|
||||
*
|
||||
* It can be mapped in to one or more address spaces.
|
||||
* */
|
||||
class MemoryObject : public KernelObject {
|
||||
public:
|
||||
MemoryObject(uint64_t size);
|
||||
|
||||
uint64_t size() { return size_; }
|
||||
uint64_t num_pages() { return size_ / 0x1000; }
|
||||
|
||||
uint64_t PhysicalPageAtOffset(uint64_t offset);
|
||||
|
||||
void CopyBytesToObject(uint64_t source, uint64_t length);
|
||||
|
||||
private:
|
||||
// Always stores the full page-aligned size.
|
||||
uint64_t size_;
|
||||
|
||||
uint64_t PageNumberToPhysAddr(uint64_t page_num);
|
||||
|
||||
LinkedList<uint64_t> phys_page_list_;
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue