My Kernel v0.1.0
vm_segment_driver Struct Reference

Segment driver. More...

#include <vm.h>

Data Fields

struct vm_segment *(* vm_alloc )(struct address_space *, vaddr_t, size_t, vm_flags_t)
 Allocate a segment of virtual memory. More...
 
struct vm_segment *(* vm_alloc_at )(struct address_space *, paddr_t, size_t, vm_flags_t)
 Allocate a segment of virtual memory mapped to a physical address. More...
 
void(* vm_free )(struct address_space *, struct vm_segment *)
 Free a contiguous virtual memory segment. More...
 
error_t(* vm_resize )(struct address_space *, struct vm_segment *, size_t)
 Resize a virtual memory segment. More...
 
error_t(* vm_fault )(struct address_space *, struct vm_segment *)
 Handle a page fault exception on a known segment. More...
 

Detailed Description

There exists different types of memory segments. A segment driver defines the operations that can be performed on a segment (allocating, freeing).

Field Documentation

◆ vm_alloc

struct vm_segment *(* vm_segment_driver::vm_alloc) (struct address_space *, vaddr_t, size_t, vm_flags_t)
Parameters
asThe address space this segment belongs to
startIf specified, the segment should start at this address
sizeThe size of the segment
Returns
The segment or a pointer encoded error
See also
vm_alloc

◆ vm_alloc_at

struct vm_segment *(* vm_segment_driver::vm_alloc_at) (struct address_space *, paddr_t, size_t, vm_flags_t)
Parameters
asThe address space this segment belongs to
startStart of the physical address range
sizeThe size of the segment
Note
This function assumes that the physical address range is contiguous and large enough to contain size bytes.
Returns
The segment or a pointer encoded error
See also
vm_alloc_at

◆ vm_fault

error_t(* vm_segment_driver::vm_fault) (struct address_space *, struct vm_segment *)
Parameters
asThe address space the segment belongs to
segmentThe memory segment inside which the faulty address is located.

◆ vm_free

void(* vm_segment_driver::vm_free) (struct address_space *, struct vm_segment *)

This function is also responsible for freeing the physical backing storage (pmm_free), and removing any eventual MMU entries.

◆ vm_resize

error_t(* vm_segment_driver::vm_resize) (struct address_space *, struct vm_segment *, size_t)

When expanding, if the required virtual memory range has already been allocated, this function returns E_NOMEM.

Calling this function with a size of 0 is equivalent to vm_free().

Parameters
sizeThe new size of the segment

The documentation for this struct was generated from the following file: