UbixOS V2 2.0

Macros | Functions | Variables
paging.h File Reference
`#include <sys/types.h>`
`#include <sys/sysproto_posix.h>`
`#include <sys/thread.h>`
Include dependency graph for paging.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

## Macros
#define | btoc(x) (((vm_offset_t)(x)+PAGE_MASK)>>PAGE_SHIFT)
#define | ctob(x) ((x)<<PAGE_SHIFT)
#define | KERNEL_PAGE_DEFAULT (PAGE_PRESENT|PAGE_WRITE)
#define | PAGE_ 0x00000100
#define | PAGE_ACCESSED 0x00000020
#define | PAGE_CACHE_DISABLED 0x00000010
#define | PAGE_COW 0x00000200
#define | PAGE_DEFAULT (PAGE_PRESENT|PAGE_WRITE|PAGE_USER)
#define | PAGE_DIRTY 0x00000040
#define | PAGE_GLOBAL 0x00000080
#define | PAGE_MASK (PAGE_SIZE-1)
#define | PAGE_PRESENT 0x00000001
#define | PAGE_SHIFT 12
#define | PAGE_SIZE 0x1000
#define | PAGE_STACK 0x00000400
#define | PAGE_USER 0x00000004
#define | PAGE_WIRED 0x00000800
#define | PAGE_WRITE 0x00000002
#define | PAGE_WRITE_THROUGH 0x00000008
#define | PD_BASE_ADDR 0xC0400000
#define | PD_BASE_ADDR2 ((PAGE_SIZE << 0xA) + VMM_KERN_START)
#define | PD_ENTRIES (PAGE_SIZE/4)
#define | PD_INDEX(v_addr) (v_addr >> 22)
#define | PD_OFFSET(v_addr) (v_addr >> 0xA)
#define | PT_BASE_ADDR 0xC0000000
#define | PT_ENTRIES (PAGE_SIZE/4)
#define | PT_INDEX(v_addr) ((v_addr >> 12) & 0x03FF)
#define | round_page(x) (((x) + PAGE_MASK) & ~PAGE_MASK)
#define | trunc_page(x) ((x) & ~PAGE_MASK)
#define | VM_TASK 1
#define | VM_THRD 0

## Functions
void | _vmm_pageFault ()
int | mmap (struct thread *, struct sys_mmap_args *)
int | munmap (struct thread *, struct sys_munmap_args *)
int | obreak (struct thread *, struct obreak_args *)
int | vmm_cleanVirtualSpace (uint32_t)
void * | vmm_copyVirtualSpace (pidType)
void * | vmm_createVirtualSpace (pidType)
void * | vmm_getFreeKernelPage (pidType pid, uint16_t count)
void * | vmm_getFreeMallocPage (uint16_t count)
void * | vmm_getFreePage (pidType)
void * | vmm_getFreeVirtualPage (pidType, int, int)
uint32_t | vmm_getPhysicalAddr (uint32_t)
uint32_t | vmm_getRealAddr (uint32_t)
void * | vmm_mapFromTask (pidType, void *, uint32_t)
void | vmm_pageFault (struct trapframe *, uint32_t)
int | vmm_pagingInit ()
int | vmm_remapPage (uint32_t, uint32_t, uint16_t, pidType, int haveLock)
int | vmm_setPageAttributes (uint32_t, uint16_t)
int | vmmClearVirtualPage (uint32_t pageAddr)

## Variables
uint32_t * | kernelPageDirectory

## Macro Definition Documentation

## ◆ btoc

#define btoc | ( |  | x | ) | (((vm_offset_t)(x)+PAGE_MASK)>>PAGE_SHIFT)

Definition at line 75 of file paging.h.

## ◆ ctob

#define ctob | ( |  | x | ) | ((x)<<PAGE_SHIFT)

Definition at line 74 of file paging.h.

## ◆ KERNEL_PAGE_DEFAULT

#define KERNEL_PAGE_DEFAULT (PAGE_PRESENT|PAGE_WRITE)

Definition at line 69 of file paging.h.

## ◆ PAGE_

#define PAGE_ 0x00000100

Definition at line 63 of file paging.h.

## ◆ PAGE_ACCESSED

#define PAGE_ACCESSED 0x00000020

Definition at line 60 of file paging.h.

## ◆ PAGE_CACHE_DISABLED

#define PAGE_CACHE_DISABLED 0x00000010

Definition at line 59 of file paging.h.

## ◆ PAGE_COW

#define PAGE_COW 0x00000200

Definition at line 64 of file paging.h.

## ◆ PAGE_DEFAULT

#define PAGE_DEFAULT (PAGE_PRESENT|PAGE_WRITE|PAGE_USER)

Definition at line 68 of file paging.h.

## ◆ PAGE_DIRTY

#define PAGE_DIRTY 0x00000040

Definition at line 61 of file paging.h.

## ◆ PAGE_GLOBAL

#define PAGE_GLOBAL 0x00000080

Definition at line 62 of file paging.h.

## ◆ PAGE_MASK

#define PAGE_MASK (PAGE_SIZE-1)

Definition at line 38 of file paging.h.

## ◆ PAGE_PRESENT

#define PAGE_PRESENT 0x00000001

Definition at line 55 of file paging.h.

## ◆ PAGE_SHIFT

#define PAGE_SHIFT 12

Definition at line 36 of file paging.h.

## ◆ PAGE_SIZE

#define PAGE_SIZE 0x1000

Definition at line 37 of file paging.h.

## ◆ PAGE_STACK

#define PAGE_STACK 0x00000400

Definition at line 65 of file paging.h.

## ◆ PAGE_USER

#define PAGE_USER 0x00000004

Definition at line 57 of file paging.h.

## ◆ PAGE_WIRED

#define PAGE_WIRED 0x00000800

Definition at line 66 of file paging.h.

## ◆ PAGE_WRITE

#define PAGE_WRITE 0x00000002

Definition at line 56 of file paging.h.

## ◆ PAGE_WRITE_THROUGH

#define PAGE_WRITE_THROUGH 0x00000008

Definition at line 58 of file paging.h.

## ◆ PD_BASE_ADDR

#define PD_BASE_ADDR 0xC0400000

Definition at line 45 of file paging.h.

## ◆ PD_BASE_ADDR2

#define PD_BASE_ADDR2 ((PAGE_SIZE << 0xA) + VMM_KERN_START)

Definition at line 43 of file paging.h.

## ◆ PD_ENTRIES

#define PD_ENTRIES (PAGE_SIZE/4)

Definition at line 48 of file paging.h.

## ◆ PD_INDEX

#define PD_INDEX | ( |  | v_addr | ) | (v_addr >> 22)

Definition at line 40 of file paging.h.

## ◆ PD_OFFSET

#define PD_OFFSET | ( |  | v_addr | ) | (v_addr >> 0xA)

Definition at line 41 of file paging.h.

## ◆ PT_BASE_ADDR

#define PT_BASE_ADDR 0xC0000000

Definition at line 46 of file paging.h.

## ◆ PT_ENTRIES

#define PT_ENTRIES (PAGE_SIZE/4)

Definition at line 49 of file paging.h.

## ◆ PT_INDEX

#define PT_INDEX | ( |  | v_addr | ) | ((v_addr >> 12) & 0x03FF)

Definition at line 42 of file paging.h.

## ◆ round_page

#define round_page | ( |  | x | ) | (((x) + PAGE_MASK) & ~PAGE_MASK)

Definition at line 72 of file paging.h.

## ◆ trunc_page

#define trunc_page | ( |  | x | ) | ((x) & ~PAGE_MASK)

Definition at line 71 of file paging.h.

## ◆ VM_TASK

#define VM_TASK 1

Definition at line 52 of file paging.h.

## ◆ VM_THRD

#define VM_THRD 0

Definition at line 51 of file paging.h.

## Function Documentation

## ◆ _vmm_pageFault()

void _vmm_pageFault | ( |  | ) |

Referenced by vmm_pagingInit().

## ◆ mmap()

int mmap | ( | struct thread * | ,
|  | struct sys_mmap_args * |
| ) |  |

## ◆ munmap()

int munmap | ( | struct thread * | ,
|  | struct sys_munmap_args * |
| ) |  |

## ◆ obreak()

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

Definition at line 546 of file paging.c.

## ◆ vmm_cleanVirtualSpace()

int vmm_cleanVirtualSpace | ( | uint32_t |  | ) |

Definition at line 587 of file paging.c.

Referenced by sysExec().

## ◆ vmm_copyVirtualSpace()

void* vmm_copyVirtualSpace | ( | pidType |  | ) |

Definition at line 51 of file copyvirtualspace.c.

References spinLock().

Referenced by fork_copyProcess(), and sys_fork().

Here is the call graph for this function:

## ◆ vmm_createVirtualSpace()

void* vmm_createVirtualSpace | ( | pidType |  | ) |

Definition at line 53 of file createvirtualspace.c.

References adjustCowCounter(), bzero, KERNEL_PAGE_DEFAULT, PAGE_COW, PAGE_PRESENT, PAGE_SIZE, PD_BASE_ADDR, PD_ENTRIES, PD_INDEX, PT_BASE_ADDR, PT_ENTRIES, vmm_getFreePage(), vmm_getPhysicalAddr(), VMM_KERN_START, and vmm_unmapPage().

Here is the call graph for this function:

## ◆ vmm_getFreeKernelPage()

void* vmm_getFreeKernelPage | ( | pidType | pid,
|  | uint16_t | count
| ) |  |

Definition at line 291 of file paging.c.

References K_PANIC, KERNEL_PAGE_DEFAULT, kpanic(), PAGE_PRESENT, PAGE_SIZE, PD_BASE_ADDR, PD_ENTRIES, PD_INDEX, pdSpinLock, PT_BASE_ADDR, PT_ENTRIES, spinLock(), spinUnlock(), vmm_allocPageTable(), vmm_clearVirtualPage(), vmm_findFreePage(), VMM_KERN_END, VMM_KERN_START, and vmm_remapPage().

Referenced by biosCall(), and execThread().

Here is the call graph for this function:

## ◆ vmm_getFreeMallocPage()

void* vmm_getFreeMallocPage | ( | uint16_t | count | ) |

## ◆ vmm_getFreePage()

void* vmm_getFreePage | ( | pidType |  | ) |

Definition at line 45 of file getfreepage.c.

References spinLock().

Referenced by vmm_createVirtualSpace().

Here is the call graph for this function:

## ◆ vmm_getFreeVirtualPage()

void * vmm_getFreeVirtualPage | ( | pidType | ,
|  | int | ,
|  | int |
| ) |  |

Definition at line 47 of file getfreevirtualpage.c.

References spinLock().

Referenced by sys_mmap(), and sysGetFreePage().

Here is the call graph for this function:

## ◆ vmm_getPhysicalAddr()

uint32_t vmm_getPhysicalAddr | ( | uint32_t | pageAddr | ) |

Function: void *vmm_getPhysicalAddr(); Description: Returns The Physical Address Of The Virtual Page Notes:

Definition at line 38 of file getphysicaladdr.c.

References PT_BASE_ADDR.

Referenced by vmm_createVirtualSpace().

## ◆ vmm_getRealAddr()

uint32_t vmm_getRealAddr | ( | uint32_t |  | ) |

Definition at line 56 of file getphysicaladdr.c.

References PT_BASE_ADDR.

Referenced by initLNC(), and lncAttach().

## ◆ vmm_mapFromTask()

void* vmm_mapFromTask | ( | pidType | ,
|  | void * | ,
|  | uint32_t |
| ) |  |

Definition at line 372 of file paging.c.

Referenced by sdeThread().

## ◆ vmm_pageFault()

void vmm_pageFault | ( | struct trapframe * | ,
|  | uint32_t |
| ) |  |

Definition at line 53 of file pagefault.c.

References _current, taskStruct::id, kprintf(), spinLock(), trapframe::tf_eip, trapframe::tf_err, and trapframe::tf_esp.

Here is the call graph for this function:

## ◆ vmm_pagingInit()

int vmm_pagingInit | ( |  | ) |

Definition at line 58 of file paging.c.

References _vmm_pageFault(), bzero, K_PANIC, KERNEL_PAGE_DEFAULT, kernelPageDirectory, kprintf(), numPages, PAGE_DEFAULT, PAGE_GLOBAL, PAGE_SIZE, PAGE_STACK, PD_BASE_ADDR, PD_ENTRIES, PD_INDEX, PT_BASE_ADDR, sysID, vmm_findFreePage(), VMM_KERN_END, VMM_KERN_START, VMM_MMAP_ADDR_PMODE, VMM_MMAP_ADDR_RMODE, vmm_remapPage(), and vmmMemoryMap.

Referenced by vmm_init().

Here is the call graph for this function:

## ◆ vmm_remapPage()

int vmm_remapPage | ( | uint32_t | ,
|  | uint32_t | ,
|  | uint16_t | ,
|  | pidType | ,
|  | int | haveLock
| ) |  |

Definition at line 199 of file paging.c.

References K_PANIC, kpanic(), spinLock(), sysID, VMM_USER_END, and VMM_USER_START.

Referenced by elf_load_file(), execFile(), freebsd6_mmap(), kmod_load(), ldEnable(), ogDisplay_UbixOS::SetMode(), sys_mmap(), sysExec(), vmm_getFreeKernelPage(), and vmm_pagingInit().

Here is the call graph for this function:

## ◆ vmm_setPageAttributes()

int vmm_setPageAttributes | ( | uint32_t | ,
|  | uint16_t |
| ) |  |

Definition at line 39 of file setpageattributes.c.

References kpanic(), and PT_BASE_ADDR.

Referenced by elf_load_file(), execFile(), and sysExec().

Here is the call graph for this function:

## ◆ vmmClearVirtualPage()

int vmmClearVirtualPage | ( | uint32_t | pageAddr | ) |

## Variable Documentation

## ◆ kernelPageDirectory

uint32_t* kernelPageDirectory

Definition at line 41 of file paging.c.

Referenced by biosCall(), execFile(), execThread(), and vmm_pagingInit().