2 |
|
* vm_alloc.h - Wrapper to various virtual memory allocation schemes |
3 |
|
* (supports mmap, vm_allocate or fallbacks to malloc) |
4 |
|
* |
5 |
< |
* Basilisk II (C) 1997-2001 Christian Bauer |
5 |
> |
* Basilisk II (C) 1997-2004 Christian Bauer |
6 |
|
* |
7 |
|
* This program is free software; you can redistribute it and/or modify |
8 |
|
* it under the terms of the GNU General Public License as published by |
25 |
|
|
26 |
|
#ifdef HAVE_UNISTD_H |
27 |
|
#include <unistd.h> |
28 |
+ |
#include <sys/types.h> |
29 |
|
#endif |
30 |
|
#ifdef HAVE_SYS_MMAN_H |
31 |
|
#include <sys/mman.h> |
32 |
|
#endif |
33 |
+ |
#ifdef HAVE_MACH_VM |
34 |
+ |
extern "C" { |
35 |
+ |
#include <mach/mach.h> |
36 |
+ |
} |
37 |
+ |
#endif |
38 |
|
|
39 |
|
/* Return value of `vm_acquire' in case of an error. */ |
40 |
|
#ifdef HAVE_MACH_VM |
47 |
|
#endif |
48 |
|
#endif |
49 |
|
|
50 |
+ |
/* Mapping options. */ |
51 |
+ |
#define VM_MAP_SHARED 0x01 |
52 |
+ |
#define VM_MAP_PRIVATE 0x02 |
53 |
+ |
#define VM_MAP_FIXED 0x04 |
54 |
+ |
#define VM_MAP_32BIT 0x08 |
55 |
+ |
#define VM_MAP_33BIT 0x10 |
56 |
+ |
|
57 |
+ |
/* Default mapping options. */ |
58 |
+ |
#define VM_MAP_DEFAULT (VM_MAP_PRIVATE) |
59 |
+ |
|
60 |
|
/* Protection bits. */ |
61 |
|
#ifdef HAVE_MACH_VM |
62 |
|
#define VM_PAGE_NOACCESS VM_PROT_NONE |
92 |
|
and default protection bits are read / write. The return value |
93 |
|
is the actual mapping address chosen or VM_MAP_FAILED for errors. */ |
94 |
|
|
95 |
< |
extern void * vm_acquire(size_t size); |
95 |
> |
extern void * vm_acquire(size_t size, int options = VM_MAP_DEFAULT); |
96 |
|
|
97 |
|
/* Allocate zero-filled memory at exactly ADDR (which must be page-aligned). |
98 |
|
Returns 0 if successful, -1 on errors. */ |
99 |
|
|
100 |
< |
extern int vm_acquire_fixed(void * addr, size_t size); |
100 |
> |
extern int vm_acquire_fixed(void * addr, size_t size, int options = VM_MAP_DEFAULT); |
101 |
|
|
102 |
|
/* Deallocate any mapping for the region starting at ADDR and extending |
103 |
|
LEN bytes. Returns 0 if successful, -1 on errors. */ |
109 |
|
|
110 |
|
extern int vm_protect(void * addr, size_t size, int prot); |
111 |
|
|
112 |
+ |
/* Returns the size of a page. */ |
113 |
+ |
|
114 |
+ |
extern int vm_get_page_size(void); |
115 |
+ |
|
116 |
|
#endif /* VM_ALLOC_H */ |