Basic KObject implementation

This commit is contained in:
Ryan Teal 2019-07-05 13:33:58 +01:00
parent c7fafd3f72
commit e44f7f8feb
No known key found for this signature in database
GPG Key ID: 8DBEE0F12C7E2D23
2 changed files with 35 additions and 0 deletions

View File

@ -0,0 +1,16 @@
#include <unordered_map>
#include <syslog.h>
#include "kernel.h"
namespace core::kernel
{
std::unordered_map<uint32_t, KObjectPtr> handles;
uint32_t handleIndex = 0xd001;
uint32_t NewHandle(KObjectPtr obj)
{
handles.insert({handleIndex, obj});
syslog(LOG_DEBUG, "Creating new handle 0x%x", handleIndex);
return handleIndex++;
}
}

View File

@ -0,0 +1,19 @@
#pragma once
#include <cstdint>
#include <memory>
namespace core::kernel
{
class KObject
{
public:
KObject(uint32_t handle) : handle(handle) {}
uint32_t Handle() { return handle; }
private:
uint32_t handle;
};
typedef std::shared_ptr<KObject> KObjectPtr;
uint32_t NewHandle(KObjectPtr obj);
}