[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:
Drew Galbraith 2023-06-16 14:53:57 -07:00
parent b4902a79ef
commit a47bac9966
13 changed files with 113 additions and 106 deletions

View file

@ -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,