mirror of
https://github.com/justinian/jsix.git
synced 2025-12-10 00:14:32 -08:00
[kernel] Fix frame allocation for multiple pages
There was an inverted boolean logic in determining how many consecutive pages were available. Also adding some memory debugging tools I added to track down the recent memory bugs: - A direct debugcon::write call, for logging to the debugcon without the possible page faults with the logger. - A new vm_space::lock call, to make a page not fillable in memory debugging mode - A mode in heap_allocator to always alloc new pages, and lock freed pages to cause page faults for use-after-free bugs. - Logging in kobject on creation and deletion - Page table cache structs are now page-sized for easy pointer math
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
#include <j6/types.h>
|
||||
|
||||
#include "assert.h"
|
||||
#include "logger.h"
|
||||
#include "objects/kobject.h"
|
||||
#include "objects/thread.h"
|
||||
|
||||
@@ -14,6 +15,13 @@ static uint32_t next_oids [types_count] = { 0 };
|
||||
static_assert(types_count <= (1 << kobject::koid_type_bits),
|
||||
"kobject::koid_type_bits cannot represent all kobject types");
|
||||
|
||||
static const char *type_names[] = {
|
||||
#define OBJECT_TYPE( name, val ) #name ,
|
||||
#include <j6/tables/object_types.inc>
|
||||
#undef OBJECT_TYPE
|
||||
nullptr
|
||||
};
|
||||
|
||||
static uint32_t
|
||||
oid_generate(kobject::type t)
|
||||
{
|
||||
@@ -26,13 +34,25 @@ kobject::kobject(type t) :
|
||||
m_handle_count {0},
|
||||
m_type {t},
|
||||
m_obj_id {oid_generate(t)}
|
||||
{}
|
||||
{
|
||||
log::spam(logs::objs, "%s[%02lx] created @ 0x%lx", type_name(m_type), m_obj_id, this);
|
||||
}
|
||||
|
||||
kobject::~kobject() {}
|
||||
kobject::~kobject()
|
||||
{
|
||||
log::spam(logs::objs, "%s[%02lx] deleted", type_name(m_type), m_obj_id);
|
||||
}
|
||||
|
||||
const char *
|
||||
kobject::type_name(type t)
|
||||
{
|
||||
return type_names[static_cast<int>(t)];
|
||||
}
|
||||
|
||||
void
|
||||
kobject::on_no_handles()
|
||||
{
|
||||
log::verbose(logs::objs, "Deleting %s[%02lx] on no handles", type_name(m_type), m_obj_id);
|
||||
delete this;
|
||||
}
|
||||
|
||||
|
||||
@@ -38,6 +38,8 @@ public:
|
||||
return static_cast<type>((koid >> koid_type_shift) & koid_type_mask);
|
||||
}
|
||||
|
||||
static const char * type_name(type t);
|
||||
|
||||
/// Get this object's type
|
||||
inline type get_type() const { return m_type; }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user