Much more progress, still doesn't compile.
This commit is contained in:
parent
1ce9fbda77
commit
60921be3d4
25 changed files with 326 additions and 89 deletions
|
|
@ -7,20 +7,41 @@
|
|||
* Licensed under GPL version 2.0, or, at your option, any later version.
|
||||
*/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "memory/memory.h"
|
||||
#include "memory/node.h"
|
||||
#include "memory/pointer.h"
|
||||
|
||||
/**
|
||||
* @brief Freelists for each size class.
|
||||
*
|
||||
* TODO: I don't know if that +1 is needed, my mind gets confused by arrays
|
||||
* indexed from zero. But it does little harm.
|
||||
*/
|
||||
struct pso_pointer freelists[MAX_SIZE_CLASS + 1];
|
||||
struct pso_pointer freelists[MAX_SIZE_CLASS];
|
||||
|
||||
/**
|
||||
* @brief Flag to prevent re-initialisation.
|
||||
*/
|
||||
bool memory_initialised = false;
|
||||
|
||||
int initialise_memory( int node ) {
|
||||
for (uint8_t i = 0; i <= MAX_SIZE_CLASS; i++) {
|
||||
freelists[i] = nil;
|
||||
/**
|
||||
* @brief Initialise the memory allocation system.
|
||||
*
|
||||
* Essentially, just set up the freelists; allocating pages will then happen
|
||||
* automatically as objects are requested.
|
||||
*
|
||||
* @param node the index number of the node we are initialising.
|
||||
* @return int
|
||||
*/
|
||||
struct pso_pointer initialise_memory( uint32_t node ) {
|
||||
if (memory_initialised) {
|
||||
// TODO: throw an exception
|
||||
} else {
|
||||
for (uint8_t i = 0; i <= MAX_SIZE_CLASS; i++) {
|
||||
freelists[i] = nil;
|
||||
}
|
||||
memory_initialised = true;
|
||||
}
|
||||
|
||||
|
||||
return t;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue