UbixOS V2 2.0

vmm.h
Go to the documentation of this file.
1 /*-
2 * Copyright (c) 2002-2018 The UbixOS Project.
3 * All rights reserved.
4 *
5 * This was developed by Christopher W. Olsen for the UbixOS Project.
6 *
7 * Redistribution and use in source and binary forms, with or without modification, are permitted
8 * provided that the following conditions are met:
9 *
10 * 1) Redistributions of source code must retain the above copyright notice, this list of
11 * conditions, the following disclaimer and the list of authors.
12 * 2) Redistributions in binary form must reproduce the above copyright notice, this list of
13 * conditions, the following disclaimer and the list of authors in the documentation and/or
14 * other materials provided with the distribution.
15 * 3) Neither the name of the UbixOS Project nor the names of its contributors may be used to
16 * endorse or promote products derived from this software without specific prior written
17 * permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
20 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
21 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
22 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
24 * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
26 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29 #ifndef _VMM_VMM_H
30 #define _VMM_VMM_H
31
32 #include <sys/types.h>
33 #include <vmm/paging.h>
34
35 #ifdef __cplusplus
36 extern "C" {
37 #endif
38
39 #define STACK_ADDR 0xBFFFFFFF//0xC800000 // Default App Stack Address
40
41 #define memAvail 1
42 #define memNotavail 2
43 #define vmmID -3
44
45 /*
46 #define vmmMemoryMapAddr 0xE6667000
47 #define VMM_MMAP_ADDR_PMODE2 0xE6667000
48 */
49
50 #define VMM_MMAP_ADDR_PMODE VMM_KERN_START /* (PD_BASE_ADDR + PAGE_SIZE) */
51 #define VMM_MMAP_ADDR_RMODE 0x101000
52
53 #define VMM_KERN_CODE_START 0x00000000
54 #define VMM_KERN_CODE_END 0x007FEFFF
55
56 #define VMM_USER_LDT 0x007FF000
57
58 #define VMM_USER_START 0x00800000
59 #define VMM_USER_END 0xBFFFFFFF
60
61 #define VMM_PAGE_DIRS 0xC0000000
62 #define VMM_PAGE_DIR 0xC0400000
63
64 #define VMM_KERN_START 0xC0800000 //TMP ADDED 1000
65 #define VMM_KERN_END 0xFDFFFFFF
66
67 #define VMM_KERN_STACK_START 0xFE000000
68 #define VMM_KERN_STACK_END 0xFFFFFFFF
69
70 extern struct spinLock pdSpinLock;
71
72
73 struct freebsd6_mmap_args {
74 char addr_l_[PADL_(caddr_t)];
75 caddr_t addr;
76 char addr_r_[PADR_(caddr_t)];
77
78 char len_l_[PADL_(size_t)];
79 size_t len;
80 char len_r_[PADR_(size_t)];
81
82 char prot_l_[PADL_(int)];
83 int prot;
84 char prot_r_[PADR_(int)];
85 char flags_l_[PADL_(int)];
86
87 int flags;
88 char flags_r_[PADR_(int)];
89 char fd_l_[PADL_(int)];
90 int fd;
91 char fd_r_[PADR_(int)];
92
93 char pad_l_[PADL_(int)];
94 int pad;
95 char pad_r_[PADR_(int)];
96
97 char pos_l_[PADL_(off_t)];
98 off_t pos;
99 char pos_r_[PADR_(off_t)];
100 };
101
102 typedef struct {
103 uint32_t pageAddr;
104 u_int16_t status;
105 u_int16_t reserved;
106 pid_t pid;
107 int cowCounter;
108 } mMap;
109
110 typedef enum {
111 VMM_FREE = 0, VMM_KEEP = 1
112 } unmapFlags_t;
113
114 extern int numPages;
115 extern mMap *vmmMemoryMap;
116
117 int vmm_init();
118 int vmm_memMapInit();
119 int countMemory();
120 uint32_t vmm_findFreePage(pidType pid);
121 int freePage(uint32_t pageAddr);
122 int adjustCowCounter(uint32_t baseAddr, int adjustment);
123 void vmm_freeProcessPages(pidType pid);
124
125 int vmm_allocPageTable(uint32_t, pidType);
126 void vmm_unmapPage(uint32_t, unmapFlags_t);
127 void vmm_unmapPages(void *, uint32_t, unmapFlags_t);
128
129 #ifdef __cplusplus
130 }
131 #endif
132
133 #endif // _VMM_VMM_H
freebsd6_mmap_args::len
size_t len
Definition: vmm.h:79
vmm_memMapInit
int vmm_memMapInit()
Definition: vmm_memory.c:57
PADL_
#define PADL_(t)
Definition: sysproto.h:39
mMap::pid
pid_t pid
Definition: vmm.h:106
freebsd6_mmap_args::addr_r_
char addr_r_[PADR_(caddr_t)]
Definition: vmm.h:76
vmmMemoryMap
mMap * vmmMemoryMap
Definition: vmm_memory.c:47
freePage
int freePage(uint32_t pageAddr)
Definition: vmm_memory.c:262
freebsd6_mmap_args::addr
caddr_t addr
Definition: vmm.h:75
freebsd6_mmap_args::pos
off_t pos
Definition: vmm.h:98
freebsd6_mmap_args::pad_r_
char pad_r_[PADR_(int)]
Definition: vmm.h:95
freebsd6_mmap_args::fd
int fd
Definition: vmm.h:90
freebsd6_mmap_args::addr_l_
char addr_l_[PADL_(caddr_t)]
Definition: vmm.h:74
freebsd6_mmap_args::pad_l_
char pad_l_[PADL_(int)]
Definition: vmm.h:93
vmm_freeProcessPages
void vmm_freeProcessPages(pidType pid)
Definition: vmm_memory.c:342
mMap::cowCounter
int cowCounter
Definition: vmm.h:107
pid_t
int pid_t
Definition: types.h:77
mMap::pageAddr
uint32_t pageAddr
Definition: vmm.h:103
adjustCowCounter
int adjustCowCounter(uint32_t baseAddr, int adjustment)
freebsd6_mmap_args::pos_r_
char pos_r_[PADR_(off_t)]
Definition: vmm.h:99
types.h
mMap
Definition: vmm.h:102
vmm_unmapPage
void vmm_unmapPage(uint32_t, unmapFlags_t)
Definition: unmappage.c:47
u_int16_t
__uint16_t u_int16_t
Definition: types.h:52
vmm_findFreePage
uint32_t vmm_findFreePage(pidType pid)
Definition: vmm_memory.c:221
freebsd6_mmap_args::fd_l_
char fd_l_[PADL_(int)]
Definition: vmm.h:89
freebsd6_mmap_args::fd_r_
char fd_r_[PADR_(int)]
Definition: vmm.h:91
freebsd6_mmap_args::len_r_
char len_r_[PADR_(size_t)]
Definition: vmm.h:80
mMap::reserved
u_int16_t reserved
Definition: vmm.h:105
countMemory
int countMemory()
Definition: vmm_memory.c:109
mMap::status
u_int16_t status
Definition: vmm.h:104
freebsd6_mmap_args::prot_r_
char prot_r_[PADR_(int)]
Definition: vmm.h:84
unmapFlags_t
unmapFlags_t
Definition: vmm.h:110
pdSpinLock
struct spinLock pdSpinLock
Definition: vmm_init.c:33
paging.h
uint32_t
__uint32_t uint32_t
Definition: types.h:46
vmm_init
int vmm_init()
Definition: vmm_init.c:43
freebsd6_mmap_args
Definition: vmm.h:73
caddr_t
char * caddr_t
Definition: types.h:41
pidType
int pidType
Definition: types.h:75
PADR_
#define PADR_(t)
Definition: sysproto.h:40
vmm_unmapPages
void vmm_unmapPages(void *, uint32_t, unmapFlags_t)
Definition: unmappage.c:99
VMM_KEEP
Definition: vmm.h:111
freebsd6_mmap_args::flags_r_
char flags_r_[PADR_(int)]
Definition: vmm.h:88
spinLock
Definition: spinlock.h:41
VMM_FREE
Definition: vmm.h:111
freebsd6_mmap_args::flags
int flags
Definition: vmm.h:87
numPages
int numPages
Definition: vmm_memory.c:45
freebsd6_mmap_args::prot_l_
char prot_l_[PADL_(int)]
Definition: vmm.h:82
off_t
__int64_t off_t
Definition: types.h:119
freebsd6_mmap_args::flags_l_
char flags_l_[PADL_(int)]
Definition: vmm.h:85
freebsd6_mmap_args::len_l_
char len_l_[PADL_(size_t)]
Definition: vmm.h:78
freebsd6_mmap_args::prot
int prot
Definition: vmm.h:83
freebsd6_mmap_args::pos_l_
char pos_l_[PADL_(off_t)]
Definition: vmm.h:97
freebsd6_mmap_args::pad
int pad
Definition: vmm.h:94
vmm_allocPageTable
int vmm_allocPageTable(uint32_t, pidType)
Definition: vmm_allocpagetable.c:7