1 #ifndef ROS_INC_MEMLAYOUT_H
2 #define ROS_INC_MEMLAYOUT_H
5 #include <ros/common.h>
6 #endif /* not __ASSEMBLER__ */
8 #include <ros/arch/mmu.h>
11 * This file contains definitions for memory management in our OS,
12 * which are relevant to both the kernel and user-mode software.
15 /* TODO: sort out multiboot being in src/ (depends on this) */
17 #define EXTPHYSMEM 0x100000
20 #define KSTKSHIFT (PGSHIFT) /* KSTKSIZE == PGSIZE */
21 #define KSTKSIZE (1 << KSTKSHIFT) /* size of a static kernel stack */
24 * User read-only mappings! Anything below here til UWLIM are readonly to user.
25 * They are global pages mapped in at env allocation time.
28 // Same as VPT but read-only for users
29 #define UVPT (ULIM - PTSIZE)
32 * Top of user VM. User can manipulate VA from UWLIM-1 and down!
35 // Top of user-accessible VM
36 #define UWLIM (UVPT - PTSIZE)
37 // Read-only, per-process shared info structures
40 // Read-write, per-process shared page for sending asynchronous
41 // syscalls to the kernel
42 #define UDATA (UWLIM - PTSIZE)
44 // Read-write, global page. Shared by all processes. Can't be trusted.
45 #define UGDATA (UDATA - PGSIZE)
47 // Top of one-page user exception stack
48 #define UXSTACKTOP UGDATA
49 /* Limit of what is mmap()/munmap()-able */
50 #define UMAPTOP UXSTACKTOP
51 // Next page left invalid to guard against exception stack overflow; then:
52 // Top of normal user stack
53 #define USTACKTOP (UXSTACKTOP - 2*PGSIZE)
54 // Maximum stack depth preallocated to 1MB
55 #define USTACK_NUM_PAGES 256
56 // Next page left invalid to guard against stack overflow
57 // Maximum bottom of normal user stack
58 #define USTACKBOT (USTACKTOP - (USTACK_NUM_PAGES+1)*PGSIZE)
60 // Arbitrary boundary between the break and the start of
61 // memory returned by calls to mmap with addr = 0
62 #define BRK_END 0x40000000
64 // Where user programs generally begin
65 #define UTEXT (2*PTSIZE)
67 // Used for temporary page mappings. Typed 'void*' for convenience
68 #define UTEMP ((void*) PTSIZE)
69 // Used for temporary page mappings for the user page-fault handler
70 // (should not conflict with other temporary page mappings)
71 #define PFTEMP (UTEMP + PTSIZE - PGSIZE)
72 // The location of the user-level STABS data structure
73 #define USTABDATA (PTSIZE / 2)
79 * The page directory entry corresponding to the virtual address range
80 * [VPT, VPT + PTSIZE) points to the page directory itself. Thus, the page
81 * directory is treated as a page table as well as a page directory.
83 * One result of treating the page directory as a page table is that all PTEs
84 * can be accessed through a "virtual page table" at virtual address VPT (to
85 * which vpt is set in entry.S). The PTE for page number N is stored in
86 * vpt[N]. (It's worth drawing a diagram of this!)
88 * A second consequence is that the contents of the current page directory
89 * will always be available at virtual address (VPT + (VPT >> PGSHIFT)), to
90 * which vpd is set in entry.S.
93 extern volatile pte_t *vpt; // VA of "virtual page table"
94 extern volatile pde_t *vpd; // VA of current page directory
96 #endif /* !__ASSEMBLER__ */
97 #endif /* !ROS_INC_MEMLAYOUT_H */