root/Whitix/trunk/include/vmm.h

Revision 2000, 2.7 KB (checked in by mwhitworth, 3 years ago)

Add define that may be used in GC.

Line 
1/*  This file is part of Whitix.
2 *
3 *  Whitix is free software; you can redistribute it and/or modify
4 *  it under the terms of the GNU General Public License as published by
5 *  the Free Software Foundation; either version 2 of the License, or
6 *  (at your option) any later version.
7 *
8 *  Whitix is distributed in the hope that it will be useful,
9 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
10 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11 *  GNU General Public License for more details.
12 *
13 *  You should have received a copy of the GNU General Public License
14 *  along with Whitix; if not, write to the Free Software
15 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
16 *
17 */
18
19/* FIXME: Rework VmAreaOps struct and design. */
20
21#ifndef VMM_H
22#define VMM_H
23
24#include <typedefs.h>
25#include <task.h>
26#include <wait.h>
27#include <locks.h>
28
29struct File;
30struct VmAreaOps;
31
32struct VMArea
33{
34        DWORD start,length,offset;
35        int flags;
36        int protection;
37        struct VNode* vNode;
38        struct VmAreaOps* areaOps;
39        struct ListHead list;
40        struct Process* process;
41};
42
43struct VMMapPage
44{
45        DWORD offset;
46        int flags;
47        struct ListHead list;
48        struct PhysPage* page;
49};
50
51/* Will be useful in paging. */
52struct VmAreaOps
53{
54        int (*handleNoPage)(struct VMArea* area, DWORD address, DWORD offset);
55        int (*addPage)(struct VMArea* area, DWORD address);
56};
57
58DWORD MMapDo(struct Process* process,struct VNode* vNode,DWORD address,DWORD length,int protection,DWORD offset,int flags, struct VmAreaOps* ops);
59int MmapHandleFault(struct Process* process,DWORD address,int error);
60void MmapProcessRemove(struct Process* process);
61struct VMArea* VmLookupAddress(struct Process* process,DWORD address);
62DWORD MMapFindAddress(struct Process* process,DWORD length);
63int MMapInit();
64
65/* Area management. */
66struct VMMapPage* VmLookupPage(struct VNode* vNode, DWORD offset);
67struct VMMapPage* VmCreateMappedPage(DWORD offset, struct PhysPage* page);
68void VmLockPage(struct VMMapPage* page);
69void VmUnlockPage(struct VMMapPage* page);
70void VmWaitOnPage(struct VMMapPage* page);
71void VmWaitForPage(struct VMMapPage* page);
72int VmFreeMappedPage(struct VNode* vNode, DWORD physAddr);
73
74/* General page fault errors */
75
76#define VM_PROTECTION 0x00000001
77#define VM_WRITE          0x00000002
78#define VM_USER           0x00000004
79
80/* MMapDo flags */
81#define MMAP_PRIVATE    0x00000000
82#define MMAP_SHARED             0x00000001
83#define MMAP_FIXED              0x00000002
84#define MMAP_GROWDOWN   0x00000004
85#define MMAP_ANON               0x00000008
86
87/* If the kernel garbage collector is enabled, we can add ranges by
88 * memory mapping. */
89#define MMAP_GC                 0x00000010
90
91#define PAGE_LOCKED 0x0
92
93#define PageLocked(page) (BitTest(&page->flags, PAGE_LOCKED))
94
95/* General mmap defines */
96#define MMAP_BASE       (0x800000)
97#define MMAP_END        (0xC0000000)
98
99#endif
Note: See TracBrowser for help on using the browser.