Newer
Older
tree-os / src / include / alloc.h
@lukas lukas on 25 Aug 2021 581 bytes :refactor terminal
#ifndef ALLOC_H
#define ALLOC_H

#include <stdint.h>
#include <task.h>

typedef enum MemoryState { FREE = 0, IN_USE = 1 } MemoryState;

typedef struct MemoryBlock {
  struct MemoryBlock *last;
  struct MemoryBlock *next;
  MemoryState state;
  uint32_t size;
  Task *task;
} MemoryBlock;

extern void initMemoryAllocation(uint32_t kernelEnd);
extern void *malloc(uint32_t size);
extern void *mallocTask(uint32_t size, Task *task);
extern void free(void *location);
extern void printMemoryStack();
extern void freeTaskAllocations(Task *task);
extern Task *getCurrentTask();

#endif