Lab 5
Data Structures | Functions | Variables
lmlib

Data Structures

struct  mmap_t
 

Functions

void * lm_init (void)
 Initializes the low memory area, the region up to the 1 MByte physical address, by mapping it on the process' physical memory address. More...
 
void * lm_alloc (unsigned long size, mmap_t *map)
 Allocates a memory block in low memory area with the specified size. More...
 
void lm_free (mmap_t *map)
 Frees a memory block in the low memory area, previously allocated using lm_alloc() More...
 

Variables

phys_bytes phys
 physical address
 
void * virtual
 virtual address
 
unsigned long size
 size of memory region
 

Detailed Description

Functions related to low memory (first 1 MB of physical memory), required for BIOS

Function Documentation

◆ lm_alloc()

void* lm_alloc ( unsigned long  size,
mmap_t map 
)

Allocates a memory block in low memory area with the specified size.

Allocates a memory block in the region up to the 1 MByte physical address with the input size. Initializes the input mmap_t struct with the maping information, which can be read but must not be modified.

Parameters
sizesize of the memory block to allocate
mappointer to mmap_t data structure, which represents the memory map
Returns
the virtual address of the memory block on success, NULL otherwise

◆ lm_free()

void lm_free ( mmap_t map)

Frees a memory block in the low memory area, previously allocated using lm_alloc()

Frees a memory block in the region up to the 1 MByte physical addess, previously allocated using lm_alloc(). Takes as input the address of the mmap_t structure that was passed to lm_alloc(), and that must have not been modified since.

Parameters
mappointer to mmap_t data structure of the block being freed

◆ lm_init()

void* lm_init ( void  )

Initializes the low memory area, the region up to the 1 MByte physical address, by mapping it on the process' physical memory address.

Returns
virtual address on which the first 1 MiB was mapped, NULL upon failure