[glacier] Move LinkedList to glacier.
This commit is contained in:
parent
08abe776a4
commit
64d355b20d
|
@ -2,7 +2,7 @@
|
|||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "debug/debug.h"
|
||||
namespace glcr {
|
||||
|
||||
template <typename T>
|
||||
class LinkedList {
|
||||
|
@ -32,10 +32,6 @@ class LinkedList {
|
|||
}
|
||||
|
||||
T PopFront() {
|
||||
if (size_ == 0 || front_ == nullptr) {
|
||||
panic("Popping from empty list");
|
||||
}
|
||||
|
||||
size_--;
|
||||
|
||||
ListItem* old_front = front_;
|
||||
|
@ -45,33 +41,6 @@ class LinkedList {
|
|||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns the front item in the list and pushes the passed item to the back.
|
||||
*
|
||||
* Done in one function to avoid a memory alloc/dealloc during scheduling.
|
||||
**/
|
||||
T CycleFront(const T& new_item) {
|
||||
if (size_ == 0 || front_ == nullptr) {
|
||||
panic("Cycling empty list");
|
||||
}
|
||||
|
||||
T ret = front_->item;
|
||||
front_->item = new_item;
|
||||
if (size_ == 1) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
ListItem* old_front = front_;
|
||||
ListItem* iter = front_;
|
||||
front_ = front_->next;
|
||||
while (iter->next != nullptr) {
|
||||
iter = iter->next;
|
||||
}
|
||||
iter->next = old_front;
|
||||
old_front->next = nullptr;
|
||||
return ret;
|
||||
}
|
||||
|
||||
T PeekFront() const { return front_->item; }
|
||||
|
||||
struct ListItem {
|
||||
|
@ -105,3 +74,5 @@ class LinkedList {
|
|||
|
||||
ListItem* front_ = nullptr;
|
||||
};
|
||||
|
||||
} // namespace glcr
|
|
@ -1,5 +1,7 @@
|
|||
#include "capability/capability_table.h"
|
||||
|
||||
#include "debug/debug.h"
|
||||
|
||||
CapabilityTable::CapabilityTable() {}
|
||||
|
||||
uint64_t CapabilityTable::AddExistingCapability(
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
#pragma once
|
||||
|
||||
#include <glacier/container/linked_list.h>
|
||||
#include <glacier/memory/ref_ptr.h>
|
||||
|
||||
#include "capability/capability.h"
|
||||
#include "lib/linked_list.h"
|
||||
#include "lib/mutex.h"
|
||||
|
||||
class CapabilityTable {
|
||||
|
@ -30,7 +30,7 @@ class CapabilityTable {
|
|||
uint64_t id;
|
||||
glcr::RefPtr<Capability> cap;
|
||||
};
|
||||
LinkedList<CapEntry> capabilities_;
|
||||
glcr::LinkedList<CapEntry> capabilities_;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#include "lib/message_queue.h"
|
||||
|
||||
#include "debug/debug.h"
|
||||
#include "scheduler/scheduler.h"
|
||||
|
||||
z_err_t UnboundedMessageQueue::PushBack(uint64_t num_bytes, const void* bytes,
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
#pragma once
|
||||
|
||||
#include <glacier/container/intrusive_list.h>
|
||||
#include <glacier/container/linked_list.h>
|
||||
#include <glacier/memory/ref_ptr.h>
|
||||
#include <glacier/memory/shared_ptr.h>
|
||||
#include <glacier/status/error.h>
|
||||
|
||||
#include "capability/capability.h"
|
||||
#include "include/ztypes.h"
|
||||
#include "lib/linked_list.h"
|
||||
#include "lib/mutex.h"
|
||||
|
||||
class MessageQueue {
|
||||
|
@ -51,10 +51,10 @@ class UnboundedMessageQueue : public MessageQueue {
|
|||
uint64_t num_bytes;
|
||||
uint8_t* bytes;
|
||||
|
||||
LinkedList<glcr::RefPtr<Capability>> caps;
|
||||
glcr::LinkedList<glcr::RefPtr<Capability>> caps;
|
||||
};
|
||||
|
||||
LinkedList<glcr::SharedPtr<Message>> pending_messages_;
|
||||
glcr::LinkedList<glcr::SharedPtr<Message>> pending_messages_;
|
||||
};
|
||||
|
||||
class SingleMessageQueue : public MessageQueue {
|
||||
|
@ -79,5 +79,5 @@ class SingleMessageQueue : public MessageQueue {
|
|||
bool has_read_ = false;
|
||||
uint64_t num_bytes_;
|
||||
uint8_t* bytes_;
|
||||
LinkedList<glcr::RefPtr<Capability>> caps_;
|
||||
glcr::LinkedList<glcr::RefPtr<Capability>> caps_;
|
||||
};
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#include "object/address_space.h"
|
||||
|
||||
#include "debug/debug.h"
|
||||
#include "memory/kernel_stack_manager.h"
|
||||
#include "memory/paging_util.h"
|
||||
#include "memory/physical_memory.h"
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#pragma once
|
||||
|
||||
#include <glacier/container/linked_list.h>
|
||||
#include <glacier/memory/ref_ptr.h>
|
||||
#include <stdint.h>
|
||||
|
||||
|
@ -86,7 +87,7 @@ class AddressSpace : public KernelObject {
|
|||
uint64_t vaddr;
|
||||
glcr::RefPtr<MemoryObject> mem_obj;
|
||||
};
|
||||
LinkedList<MemoryMapping> memory_mappings_;
|
||||
glcr::LinkedList<MemoryMapping> memory_mappings_;
|
||||
|
||||
MemoryMapping* GetMemoryMappingForAddr(uint64_t vaddr);
|
||||
};
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#include "lib/linked_list.h"
|
||||
#include <glacier/container/linked_list.h>
|
||||
|
||||
#include "object/kernel_object.h"
|
||||
|
||||
class MemoryObject;
|
||||
|
@ -37,7 +38,7 @@ class MemoryObject : public KernelObject {
|
|||
|
||||
virtual uint64_t PageNumberToPhysAddr(uint64_t page_num);
|
||||
|
||||
LinkedList<uint64_t> phys_page_list_;
|
||||
glcr::LinkedList<uint64_t> phys_page_list_;
|
||||
};
|
||||
|
||||
class FixedMemoryObject : public MemoryObject {
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
#pragma once
|
||||
|
||||
#include <glacier/container/linked_list.h>
|
||||
#include <glacier/memory/ref_ptr.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "capability/capability.h"
|
||||
#include "capability/capability_table.h"
|
||||
#include "lib/linked_list.h"
|
||||
#include "lib/mutex.h"
|
||||
#include "object/address_space.h"
|
||||
#include "object/channel.h"
|
||||
|
@ -66,6 +66,6 @@ class Process : public KernelObject {
|
|||
uint64_t next_thread_id_ = 0;
|
||||
uint64_t next_cap_id_ = 0x100;
|
||||
|
||||
LinkedList<glcr::RefPtr<Thread>> threads_;
|
||||
glcr::LinkedList<glcr::RefPtr<Thread>> threads_;
|
||||
CapabilityTable caps_;
|
||||
};
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
#include "scheduler/process_manager.h"
|
||||
|
||||
#include "debug/debug.h"
|
||||
|
||||
ProcessManager* gProcMan = nullptr;
|
||||
|
||||
void ProcessManager::Init() {
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
#pragma once
|
||||
|
||||
#include <glacier/container/linked_list.h>
|
||||
#include <glacier/memory/ref_ptr.h>
|
||||
|
||||
#include "lib/linked_list.h"
|
||||
#include "object/process.h"
|
||||
|
||||
class ProcessManager {
|
||||
|
@ -18,7 +18,7 @@ class ProcessManager {
|
|||
|
||||
private:
|
||||
// TODO: This should be a hashmap.
|
||||
LinkedList<glcr::RefPtr<Process>> proc_list_;
|
||||
glcr::LinkedList<glcr::RefPtr<Process>> proc_list_;
|
||||
};
|
||||
|
||||
extern ProcessManager* gProcMan;
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
#include "common/gdt.h"
|
||||
#include "debug/debug.h"
|
||||
#include "lib/linked_list.h"
|
||||
#include "scheduler/process_manager.h"
|
||||
|
||||
namespace {
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#include "syscall/process.h"
|
||||
|
||||
#include "capability/capability.h"
|
||||
#include "debug/debug.h"
|
||||
#include "scheduler/process_manager.h"
|
||||
#include "scheduler/scheduler.h"
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
#include <stdint.h>
|
||||
|
||||
#include "common/msr.h"
|
||||
#include "debug/debug.h"
|
||||
#include "scheduler/scheduler.h"
|
||||
#include "syscall/address_space.h"
|
||||
#include "syscall/capability.h"
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#include "syscall/thread.h"
|
||||
|
||||
#include "capability/capability.h"
|
||||
#include "debug/debug.h"
|
||||
#include "scheduler/scheduler.h"
|
||||
|
||||
glcr::ErrorCode ThreadCreate(ZThreadCreateReq* req) {
|
||||
|
@ -29,6 +30,7 @@ glcr::ErrorCode ThreadExit(ZThreadExitReq*) {
|
|||
auto curr_thread = gScheduler->CurrentThread();
|
||||
curr_thread->Exit();
|
||||
panic("Returned from thread exit");
|
||||
UNREACHABLE
|
||||
}
|
||||
|
||||
glcr::ErrorCode ThreadWait(ZThreadWaitReq* req) {
|
||||
|
|
Loading…
Reference in New Issue