MOS Source Code
Loading...
Searching...
No Matches
mm.c File Reference
#include "mos/mm/mm.h"
#include "mos/filesystem/sysfs/sysfs.h"
#include "mos/interrupt/ipi.h"
#include "mos/mm/paging/paging.h"
#include "mos/mm/paging/pmlx/pml5.h"
#include "mos/mm/paging/table_ops.h"
#include "mos/mm/physical/pmm.h"
#include "mos/mm/slab_autoinit.h"
#include "mos/platform/platform.h"
#include "mos/platform/platform_defs.h"
#include "mos/syslog/printk.h"
#include "mos/tasks/signal.h"
#include "mos/tasks/task_types.h"
#include <mos/lib/structures/list.h>
#include <mos/lib/sync/spinlock.h>
#include <mos/mos_global.h>
#include <mos_stdlib.h>
#include <mos_string.h>
+ Include dependency graph for mm.c:

Go to the source code of this file.

Functions

 SLAB_AUTOINIT ("vmap", vmap_cache, vmap_t)
 
 SLAB_AUTOINIT ("mm_context", mm_context_cache, mm_context_t)
 
phyframe_tmm_get_free_page_raw (void)
 
phyframe_tmm_get_free_page (void)
 
phyframe_tmm_get_free_pages (size_t npages)
 
mm_context_tmm_create_context (void)
 Create a user-mode platform-dependent page table.
 
void mm_destroy_context (mm_context_t *mmctx)
 Destroy a user-mode platform-dependent page table.
 
void mm_lock_ctx_pair (mm_context_t *ctx1, mm_context_t *ctx2)
 Lock and unlock a pair of mm_context_t objects.
 
void mm_unlock_ctx_pair (mm_context_t *ctx1, mm_context_t *ctx2)
 
mm_context_tmm_switch_context (mm_context_t *new_ctx)
 
static void do_attach_vmap (mm_context_t *mmctx, vmap_t *vmap)
 
vmap_tvmap_create (mm_context_t *mmctx, ptr_t vaddr, size_t npages)
 Create a vmap object and insert it into the address space.
 
void vmap_destroy (vmap_t *vmap)
 Destroy a vmap object, and unmmap the region.
 
vmap_tvmap_obtain (mm_context_t *mmctx, ptr_t vaddr, size_t *out_offset)
 Get the vmap object for a virtual address.
 
vmap_tvmap_split (vmap_t *first, size_t split)
 Split a vmap object into two, at the specified offset.
 
vmap_tvmap_split_for_range (vmap_t *vmap, size_t rstart_pgoff, size_t rend_pgoff)
 Split a vmap to get a vmap object for a range of pages.
 
void vmap_finalise_init (vmap_t *vmap, vmap_content_t content, vmap_type_t type)
 Finalize the initialization of a vmap object.
 
void mm_copy_page (const phyframe_t *src, const phyframe_t *dst)
 
vmfault_result_t mm_resolve_cow_fault (vmap_t *vmap, ptr_t fault_addr, pagefault_t *info)
 Helper function to resolve a copy-on-write fault.
 
static void invalid_page_fault (ptr_t fault_addr, vmap_t *faulting_vmap, vmap_t *ip_vmap, pagefault_t *info, const char *unhandled_reason)
 
void mm_handle_fault (ptr_t fault_addr, pagefault_t *info)
 Handle a page fault.
 
static bool sys_mem_mmap (sysfs_file_t *f, vmap_t *vmap, off_t offset)
 
static bool sys_mem_munmap (sysfs_file_t *f, vmap_t *vmap, bool *unmapped)
 
static void mm_sysfs_init ()
 
 MOS_INIT (SYSFS, mm_sysfs_init)
 

Variables

static slab_tvmap_cache = NULL
 
static slab_tmm_context_cache = NULL
 
static sysfs_item_t sys_mem_item = SYSFS_MEM_ITEM("mem", sys_mem_mmap, sys_mem_munmap)
 

Function Documentation

◆ SLAB_AUTOINIT() [1/2]

SLAB_AUTOINIT ( "vmap" ,
vmap_cache ,
vmap_t  )

◆ SLAB_AUTOINIT() [2/2]

SLAB_AUTOINIT ( "mm_context" ,
mm_context_cache ,
mm_context_t  )

◆ do_attach_vmap()

static void do_attach_vmap ( mm_context_t * mmctx,
vmap_t * vmap )
static

Definition at line 138 of file mm.c.

Referenced by vmap_create(), and vmap_split().

+ Here is the call graph for this function:

◆ mm_copy_page()

void mm_copy_page ( const phyframe_t * src,
const phyframe_t * dst )

Definition at line 268 of file mm.c.

Referenced by mm_handle_fault(), and mm_resolve_cow_fault().

+ Here is the call graph for this function:

◆ invalid_page_fault()

static void invalid_page_fault ( ptr_t fault_addr,
vmap_t * faulting_vmap,
vmap_t * ip_vmap,
pagefault_t * info,
const char * unhandled_reason )
static

Definition at line 286 of file mm.c.

Referenced by mm_handle_fault().

+ Here is the call graph for this function:

◆ sys_mem_mmap()

static bool sys_mem_mmap ( sysfs_file_t * f,
vmap_t * vmap,
off_t offset )
static

Definition at line 502 of file mm.c.

+ Here is the call graph for this function:

◆ sys_mem_munmap()

static bool sys_mem_munmap ( sysfs_file_t * f,
vmap_t * vmap,
bool * unmapped )
static

Definition at line 510 of file mm.c.

+ Here is the call graph for this function:

◆ mm_sysfs_init()

static void mm_sysfs_init ( )
static

Definition at line 520 of file mm.c.

+ Here is the call graph for this function:

◆ MOS_INIT()

MOS_INIT ( SYSFS ,
mm_sysfs_init  )

Variable Documentation

◆ vmap_cache

slab_t* vmap_cache = NULL
static

Definition at line 28 of file mm.c.

Referenced by vmap_create(), and vmap_split().

◆ mm_context_cache

slab_t* mm_context_cache = NULL
static

Definition at line 31 of file mm.c.

Referenced by mm_create_context().

◆ sys_mem_item

sysfs_item_t sys_mem_item = SYSFS_MEM_ITEM("mem", sys_mem_mmap, sys_mem_munmap)
static

Definition at line 518 of file mm.c.

Referenced by mm_sysfs_init().