# paging.c File Reference

`#include <vmm/vmm.h>`
`#include <lib/kprintf.h>`
`#include <lib/kmalloc.h>`
`#include <ubixos/types.h>`
`#include <ubixos/kpanic.h>`
`#include <ubixos/sched.h>`
`#include <ubixos/spinlock.h>`
`#include <string.h>`
`#include <assert.h>`

Include dependency graph for paging.c:

Go to the source code of this file.

## Functions

int | mmap (struct thread *td, struct mmap_args *uap)
int | munmap (struct thread *td, struct munmap_args *uap)
int | obreak (struct thread *td, struct obreak_args *uap)
int | vmm_cleanVirtualSpace (u_int32_t addr)
void * | vmm_getFreeMallocPage (uInt16 count)
int | vmm_pagingInit ()
int | vmm_remapPage (uInt32 source, uInt32 dest, uInt16 perms)
int | vmmClearVirtualPage (uInt32 pageAddr)
void * | vmmGetFreeKernelPage (pidType pid, uInt16 count)
void * | vmmMapFromTask (pidType pid, void *ptr, uInt32 size)

## Variables

static spinLock_t | fkpSpinLock = SPIN_LOCK_INITIALIZER
uInt32 * | kernelPageDirectory = 0x0
static spinLock_t | rmpSpinLock = SPIN_LOCK_INITIALIZER

## Function Documentation

int mmap | ( | struct thread * | td,
|  | struct mmap_args * | uap |
| ) |  |  |

Definition at line 453 of file paging.c.

References _current, mmap_args::addr, mmap_args::fd, mmap_args::flags, taskStruct::id, kprintf(), mmap_args::len, mmap_args::pad, mmap_args::pos, mmap_args::prot, thread::td_retval, VM_TASK, vmmGetFreeVirtualPage(), and x1000.

Here is the call graph for this function:

int munmap | ( | struct thread * | td,
|  | struct munmap_args * | uap |
| ) |  |  |

Definition at line 516 of file paging.c.

References kprintf().

Here is the call graph for this function:

int obreak | ( | struct thread * | td,
|  | struct obreak_args * | uap |
| ) |  |  |

Definition at line 478 of file paging.c.

References _current, btoc, ctob, taskStruct::id, K_PANIC, kprintf(), obreak_args::nsize, PAGE_DEFAULT, round_page, thread::vm_daddr, thread::vm_dsize, vmm_remapPage(), and vmmFindFreePage().

Here is the call graph for this function:

int vmm_cleanVirtualSpace | ( | u_int32_t | addr | ) |

Definition at line 522 of file paging.c.

References kprintf(), PAGE_COW, PAGE_PRESENT, PAGE_STACK, parentPageDirAddr, tablesBaseAddress, and x1000.

Referenced by sysExec().

Here is the call graph for this function:

void* vmm_getFreeMallocPage | ( | uInt16 | count | ) |

Definition at line 401 of file paging.c.

References fkpSpinLock, K_PANIC, KERNEL_PAGE_DEFAULT, spinLock(), spinUnlock(), sysID, tablesBaseAddress, vmm_remapPage(), vmmClearVirtualPage(), vmmFindFreePage(), and x1000.

Referenced by getEmptyDesc().

Here is the call graph for this function:

int vmm_pagingInit | ( |  | ) |

Definition at line 59 of file paging.c.

References _vmm_pageFault, K_PANIC, KERNEL_PAGE_DEFAULT, kernelPageDirectory, kprintf(), memset(), numPages, pageEntries, sysID, vmm_remapPage(), vmmFindFreePage(), vmmMemoryMap, vmmMemoryMapAddr, x1, and x1000.

Referenced by vmm_init().

Here is the call graph for this function:

int vmm_remapPage | ( | uInt32 | source,
|  | uInt32 | dest,
|  | uInt16 | perms |
| ) |  |  |

Definition at line 160 of file paging.c.

References _current, freePage(), taskStruct::id, K_PANIC, KERNEL_PAGE_DEFAULT, kprintf(), PAGE_COW, PAGE_DEFAULT, PAGE_PRESENT, PAGE_STACK, pageEntries, parentPageDirAddr, rmpSpinLock, spinLock(), spinUnlock(), tablesBaseAddress, vmmFindFreePage(), and x1000.

Referenced by elf_loadfile(), execFile(), kmod_load(), ldEnable(), obreak(), sys_exec(), sysExec(), vmm_getFreeMallocPage(), vmm_pagingInit(), vmmGetFreeKernelPage(), vmmGetFreePage(), vmmGetFreeVirtualPage(), and vmmMapFromTask().

Here is the call graph for this function:

int vmmClearVirtualPage | ( | uInt32 | pageAddr | ) |

Definition at line 314 of file paging.c.

References pageEntries.

Referenced by vmm_getFreeMallocPage(), vmmGetFreeKernelPage(), vmmGetFreePage(), and vmmGetFreeVirtualPage().

void* vmmGetFreeKernelPage | ( | pidType | pid,
|  | uInt16 | count |
| ) |  |  |

Definition at line 253 of file paging.c.

References fkpSpinLock, K_PANIC, KERNEL_PAGE_DEFAULT, spinLock(), spinUnlock(), tablesBaseAddress, vmm_remapPage(), vmmClearVirtualPage(), and vmmFindFreePage().

Referenced by vmmCopyVirtualSpace().

Here is the call graph for this function:

void* vmmMapFromTask | ( | pidType | pid,
|  | void * | ptr,
|  | uInt32 | size |
| ) |  |  |

Definition at line 332 of file paging.c.

References _current, tssStruct::cr3, K_PANIC, KERNEL_PAGE_DEFAULT, taskStruct::oInfo, schedFindTask(), tablesBaseAddress, taskStruct::tss, vmm_remapPage(), vmmUnmapPage(), osInfo::vmStart, and x1000.

Here is the call graph for this function:

## Variable Documentation

spinLock_t fkpSpinLock = SPIN_LOCK_INITIALIZER`[static]`

Definition at line 43 of file paging.c.

Referenced by vmm_getFreeMallocPage(), and vmmGetFreeKernelPage().

uInt32* kernelPageDirectory = 0x0

Definition at line 40 of file paging.c.

Referenced by _int8(), execFile(), execThread(), idt_init(), and vmm_pagingInit().

spinLock_t rmpSpinLock = SPIN_LOCK_INITIALIZER`[static]`

Definition at line 44 of file paging.c.

Referenced by vmm_remapPage().