mirror of
https://github.com/RPCSX/rpcsx.git
synced 2026-04-06 06:55:09 +00:00
[orbis-kernel] Implement kfree
Incomplete implementation.
This commit is contained in:
parent
5f6647540c
commit
9744c41ebb
3 changed files with 61 additions and 26 deletions
|
|
@ -1,11 +1,12 @@
|
|||
#pragma once
|
||||
#include "evf.hpp"
|
||||
#include "utils/LinkedNode.hpp"
|
||||
#include "utils/SharedMutex.hpp"
|
||||
#include "evf.hpp"
|
||||
|
||||
#include "orbis/thread/types.hpp"
|
||||
#include "KernelAllocator.hpp"
|
||||
#include "orbis/thread/types.hpp"
|
||||
#include <algorithm>
|
||||
#include <pthread.h>
|
||||
#include <utility>
|
||||
|
||||
namespace orbis {
|
||||
|
|
@ -20,13 +21,15 @@ public:
|
|||
void deleteProcess(Process *proc);
|
||||
Process *findProcessById(pid_t pid) const;
|
||||
|
||||
static void *kalloc(std::size_t size,
|
||||
std::size_t align = __STDCPP_DEFAULT_NEW_ALIGNMENT__);
|
||||
static void kfree(void *ptr, std::size_t size);
|
||||
void *kalloc(std::size_t size,
|
||||
std::size_t align = __STDCPP_DEFAULT_NEW_ALIGNMENT__);
|
||||
void kfree(void *ptr, std::size_t size);
|
||||
|
||||
std::pair<EventFlag *, bool> createEventFlag(utils::kstring name, std::int32_t flags) {
|
||||
auto [it, inserted] = m_event_flags.try_emplace(std::move(name), knew<EventFlag>(flags));
|
||||
return { it->second.get(), inserted };
|
||||
std::pair<EventFlag *, bool> createEventFlag(utils::kstring name,
|
||||
std::int32_t flags) {
|
||||
auto [it, inserted] =
|
||||
m_event_flags.try_emplace(std::move(name), knew<EventFlag>(flags));
|
||||
return {it->second.get(), inserted};
|
||||
}
|
||||
|
||||
Ref<EventFlag> findEventFlag(std::string_view name) {
|
||||
|
|
@ -34,22 +37,19 @@ public:
|
|||
return it->second;
|
||||
}
|
||||
|
||||
return{};
|
||||
return {};
|
||||
}
|
||||
|
||||
private:
|
||||
mutable pthread_mutex_t m_heap_mtx;
|
||||
void *m_heap_next = this + 1;
|
||||
bool m_heap_is_freeing = false;
|
||||
utils::kmultimap<std::size_t, void *> m_free_heap;
|
||||
utils::kmultimap<std::size_t, void *> m_used_node;
|
||||
|
||||
mutable shared_mutex m_proc_mtx;
|
||||
utils::LinkedNode<Process> *m_processes = nullptr;
|
||||
utils::kmap<utils::kstring, Ref<EventFlag>> m_event_flags;
|
||||
|
||||
struct node {
|
||||
std::size_t size;
|
||||
node *next;
|
||||
};
|
||||
|
||||
mutable shared_mutex m_heap_mtx;
|
||||
void *m_heap_next = this + 1;
|
||||
node *m_free_list = nullptr;
|
||||
};
|
||||
|
||||
extern KernelContext &g_context;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue