MyOS Kernel
pmem.c File Reference
#include "cpu/arch_consts.h"
#include "cpu/halt.h"
#include "vga_err.h"
#include <grub/multiboot2.h>
#include <stdint.h>
#include <stdlib.h>

Macros

#define BMAP_LEN   (NUM_FRAMES/8)
 The size of the physical memory manager's bitmap.
 

Functions

static char get_bmap_bit (int index)
 
static void set_bmap_bit (int index)
 
static void clear_bmap_bit (int index)
 
void pmem_init (struct multiboot_boot_header_tag *tags)
 
void * pmem_alloc (int num_pages)
 
void pmem_free (void *start, int num_pages)
 

Variables

static char bmap [BMAP_LEN]
 Bitmap of allocated/non-present page frames.
 

Function Documentation

◆ clear_bmap_bit()

static void clear_bmap_bit ( int  index)
static

Clear a bit in the heap bitmap

Parameters
indexThe bit to clear

◆ get_bmap_bit()

static char get_bmap_bit ( int  index)
static

Get a bit in the bitmap

Parameters
indexThe bit to get
Returns
the bit

◆ pmem_alloc()

void* pmem_alloc ( int  num_pages)

Allocate physical frames

Parameters
num_pagesThe number of frames to allocate
Returns
the physical address of the allocated frames

◆ pmem_free()

void pmem_free ( void *  start,
int  num_pages 
)

Free allocated physical frames

Parameters
startThe address to start freeing at.
num_pagesThe number of frames to free

◆ pmem_init()

void pmem_init ( struct multiboot_boot_header_tag *  tags)

Initialize the physical memory manager

Parameters
tagsThe multiboot header

◆ set_bmap_bit()

static void set_bmap_bit ( int  index)
static

Set a bit in the heap bitmap

Parameters
indexThe bit to set