[zion] Dynamically check Capability type.
Instead of passing an enum with the capability when creating it, relying on polymorphism and a template struct tag to determine the object type at runtime. This is cleaner and avoids errors where we pass the wrong capability type with the cap and do a bad cast at runtime.
This commit is contained in:
parent
b4902a79ef
commit
a47bac9966
13 changed files with 113 additions and 106 deletions
|
|
@ -6,6 +6,13 @@
|
|||
#include "memory/user_stack_manager.h"
|
||||
#include "object/memory_object.h"
|
||||
|
||||
class AddressSpace;
|
||||
|
||||
template <>
|
||||
struct KernelObjectTag<AddressSpace> {
|
||||
static const uint64_t type = KernelObject::ADDRESS_SPACE;
|
||||
};
|
||||
|
||||
// VirtualMemory class holds a memory space for an individual process.
|
||||
//
|
||||
// Memory Regions are predefined for simplicity for now. However, in general
|
||||
|
|
@ -26,6 +33,8 @@
|
|||
// 0xFFFFFFFF 90000000 - 0xFFFFFFFF 9FFFFFFF : KERNEL_STACK (256 MiB)
|
||||
class AddressSpace : public KernelObject {
|
||||
public:
|
||||
uint64_t TypeTag() override { return KernelObject::ADDRESS_SPACE; }
|
||||
|
||||
enum MemoryType {
|
||||
UNSPECIFIED,
|
||||
UNMAPPED,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue