Loading [MathJax]/extensions/tex2jax.js
CS350 COS
COS
All Data Structures Files Functions Variables Typedefs Macros
mman.h File Reference

Go to the source code of this file.

Macros

#define PROT_NONE   0x00
 
#define PROT_READ   0x01
 
#define PROT_WRITE   0x02
 
#define PROT_EXEC   0x04
 
#define MAP_FILE   0x0010
 
#define MAP_ANON   0x0020
 
#define MAP_FIXED   0x0040
 

Functions

int getpagesizes (size_t *pagesize, int nlem)
 
void * mmap (void *addr, size_t len, int prot, int flags, int fd, off_t offset)
 
int munmap (void *addr, size_t len)
 
int mprotect (void *addr, size_t len, int prot)
 
int madvise (void *addr, size_t len, int behav)
 

Macro Definition Documentation

◆ MAP_ANON

#define MAP_ANON   0x0020

Definition at line 11 of file mman.h.

◆ MAP_FILE

#define MAP_FILE   0x0010

Definition at line 10 of file mman.h.

◆ MAP_FIXED

#define MAP_FIXED   0x0040

Definition at line 12 of file mman.h.

◆ PROT_EXEC

#define PROT_EXEC   0x04

Definition at line 8 of file mman.h.

◆ PROT_NONE

#define PROT_NONE   0x00

Definition at line 5 of file mman.h.

◆ PROT_READ

#define PROT_READ   0x01

Definition at line 6 of file mman.h.

◆ PROT_WRITE

#define PROT_WRITE   0x02

Definition at line 7 of file mman.h.

Function Documentation

◆ getpagesizes()

int getpagesizes ( size_t pagesize,
int  nlem 
)

Definition at line 16 of file mman.c.

17{
18#if defined(__x86_64__)
19 if (pagesize) {
20 if (nelem >= 1)
21 pagesize[0] = PGSIZE;
22 if (nelem >= 2)
23 pagesize[1] = LARGE_PGSIZE;
24 if (nelem >= 3)
25 pagesize[2] = HUGE_PGSIZE;
26 return (nelem > 3 ? 3 : nelem);
27 }
28 return 3;
29#else
30#error "Unsupported Architecture!"
31#endif
32}
#define HUGE_PGSIZE
Definition: amd64.h:29
#define LARGE_PGSIZE
Definition: amd64.h:25
#define PGSIZE
Definition: malloc.c:21

◆ madvise()

int madvise ( void *  addr,
size_t  len,
int  behav 
)

Definition at line 71 of file mman.c.

72{
73 return 0;
74}

◆ mmap()

void * mmap ( void *  addr,
size_t  len,
int  prot,
int  flags,
int  fd,
off_t  offset 
)

Definition at line 35 of file mman.c.

36{
37 void *realAddr;
38
39 if (!(flags & MAP_FIXED)) {
40 // Find an address
41 }
42
43 if (flags & MAP_ANON) {
44 realAddr = OSMemMap(addr, len, prot | flags);
45 } else {
46 abort();
47 }
48
49 // XXX: Update mapping
50
51 return realAddr;
52}
void * OSMemMap(void *addr, uint64_t len, int flags)
Definition: syscall.c:41
#define MAP_ANON
Definition: mman.h:11
#define MAP_FIXED
Definition: mman.h:12
uint64_t addr
Definition: multiboot.h:1
uint64_t len
Definition: multiboot.h:2
_Noreturn void abort(void)
Definition: abort.c:9
Here is the call graph for this function:
Here is the caller graph for this function:

◆ mprotect()

int mprotect ( void *  addr,
size_t  len,
int  prot 
)

Definition at line 63 of file mman.c.

64{
65 // XXX: Update mappings
66
67 return OSMemProtect(addr, len, prot);
68}
int OSMemProtect(void *addr, uint64_t len, int flags)
Definition: syscall.c:53
Here is the call graph for this function:

◆ munmap()

int munmap ( void *  addr,
size_t  len 
)

Definition at line 55 of file mman.c.

56{
57 // XXX: Update mappings
58
59 return OSMemUnmap(addr, len);
60}
int OSMemUnmap(void *addr, uint64_t len)
Definition: syscall.c:47
Here is the call graph for this function:
Here is the caller graph for this function: