Rewrote physical memory allocator
The physical memory allocator now uses a buddy allocator instead of a stack. Also moved some of the platform-independent context code to kernel.c.
This commit is contained in:
@@ -1,19 +1,35 @@
|
||||
#pragma once
|
||||
#ifndef _QUARK_CONTEXT_H
|
||||
#define _QUARK_CONTEXT_H
|
||||
|
||||
struct process_context_t;
|
||||
#include <stdint.h>
|
||||
|
||||
#if defined __i386__ || defined __x86_64__
|
||||
#define DEFAULT_FLAGS 0x3200
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Allocates a new process context and initializes it with the given
|
||||
* program counter.
|
||||
* @brief Stores the context of a particular process. The contents of this
|
||||
* struct are platform-specific.
|
||||
*
|
||||
* @param task_entry
|
||||
* @return void*
|
||||
*/
|
||||
void *initialize_context(void *pc);
|
||||
struct process_context_t
|
||||
{
|
||||
|
||||
void destroy_context(void *ctx);
|
||||
#if defined __i386__
|
||||
uint32_t gp_registers[8];
|
||||
uint32_t ss;
|
||||
uint32_t cs;
|
||||
uint32_t eip;
|
||||
uint32_t flags;
|
||||
#elif defined __x86_64__
|
||||
uint64_t gp_registers[16];
|
||||
uint64_t ss;
|
||||
uint64_t cs;
|
||||
uint64_t rip;
|
||||
uint64_t flags;
|
||||
#endif
|
||||
|
||||
void save_context(struct process_context_t *context);
|
||||
};
|
||||
|
||||
void load_context(struct process_context_t *context);
|
||||
|
||||
@@ -24,3 +40,5 @@ void set_context_stack(struct process_context_t *context, void *stack);
|
||||
void set_context_flags(struct process_context_t *context, unsigned long flags);
|
||||
|
||||
void set_context_return(struct process_context_t *context, unsigned long value);
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user