2 * Higher level memory managment definitions
8 #define PAGE_SYSTEM (0x80000000)
10 #include <internal/linkage.h>
11 #include <internal/kernel.h>
14 typedef struct _memory_area
16 * PURPOSE: Describes an area of virtual memory
30 * Memory region length
35 * Memory type (Mapped file, mapped from an executable or private)
40 * Memory region state (committed, reserved or free)
45 * Original access protection
47 unsigned int initial_access
;
50 * Used to maintain the linked list of memory areas
52 struct _memory_area
* previous
;
53 struct _memory_area
* next
;
56 * True the region is locked
61 * FUNCTION: Decommits all the pages in the regions
63 void (*free
)(struct _memory_area
* marea
);
66 * FUNCTION: Handles a page fault by loading the required page
68 * marea = the memory area
69 * address = the relative address of the page to load
71 * TRUE = the access should be restarted
72 * FALSE = the access was illegal and an exception should
74 * NOTES: This function is guarrented to be called within the context
75 * of the thread which required a page to be loaded
77 BOOL (*load_page
)(struct _memory_area
* marea
, unsigned int address
);
82 * FUNCTION: Gets a page with a restricted max physical address (i.e.
85 * The physical address of the page if it succeeds
87 * NOTES: This is very inefficent because the list isn't sorted. On the
88 * other hand sorting the list would be quite expensive especially if dma
89 * is only used infrequently. Perhaps a special cache of dma pages should
92 unsigned int get_dma_page(unsigned int max_address
);
95 * FUNCTION: Allocate a page and return its physical address
96 * RETURNS: The physical address of the page allocated
98 asmlinkage
unsigned int get_free_page(void);
101 * FUNCTION: Adds pages to the free list
103 * physical_base = Physical address of the base of the region to
105 * nr = number of continuous pages to free
107 asmlinkage
void free_page(unsigned int physical_base
, unsigned int nr
);
110 * FUNCTION: Returns the physical address mapped by a given virtual address
112 * vaddr = virtual address to query
113 * RETURNS: The physical address if present in memory
114 * Zero if paged out or invalid
115 * NOTE: This doesn't do any synchronization
117 unsigned int get_page_physical_address(unsigned int vaddr
);
119 void mark_page_not_writable(unsigned int vaddr
);
121 void VirtualInit(boot_param
* bp
);
124 * FUNCTION: Returns the first memory area starting in the region or the last
125 * one before the start of the region
127 * list_head = Head of the list of memory areas to search
128 * base = base address of the region
129 * length = length of the region
130 * RETURNS: A pointer to the area found or
131 * NULL if the region was before the first region on the list
133 memory_area
* find_first_marea(memory_area
* list_head
, unsigned int base
,
134 unsigned int length
);
137 * Head of the list of system memory areas
139 extern memory_area
* system_memory_area_list_head
;
142 * Head of the list of user memory areas (this should be per process)
144 extern memory_area
* memory_area_list_head
;