1/*
2 * Copyright 2016, Data61
3 * Commonwealth Scientific and Industrial Research Organisation (CSIRO)
4 * ABN 41 687 119 230.
5 *
6 * This software may be distributed and modified according to the terms of
7 * the BSD 2-Clause license. Note that NO WARRANTY is provided.
8 * See "LICENSE_BSD2.txt" for details.
9 *
10 * @TAG(D61_BSD)
11 */
12
13#ifndef _REFOS_VIRTUAL_MEMORY_LAYOUT_H_
14#define _REFOS_VIRTUAL_MEMORY_LAYOUT_H_
15
16/* Include Kconfig variables. */
17#include <autoconf.h>
18
19/*! @file
20    @brief RefOS client virtual memory layout.
21
22    Virtual memory layout definitions, also including space layout. This design is very loosely
23    based off the linux VM space, in which there is an expanding heap growing upwards, and MMap
24    region growing downwards.
25
26    @image html vmlayout.png
27 */
28
29#define PROCESS_MAX_THREADS 1024
30#define PROCESS_MAX_SESSIONS 1024
31#define PROCESS_MAX_WINDOWS 8192
32
33/*
34    Reference: http://duartes.org/gustavo/blog/post/anatomy-of-a-program-in-memory
35*/
36
37// ---------------------------------- RefOS OS VSpace ---------------------------
38
39#define PROCESS_KERNEL_RESERVED 0xE0000000 /*!< seL4 kernel restriction. */
40
41#define PROCESS_STATICPARAM_ADDR 0xDFF30000
42#define PROCESS_STATICPARAM_SIZE 0x1000
43#define PROCESS_STATICPARAM_PROCINFO_ADDR (PROCESS_STATICPARAM_ADDR + 0x800)
44
45#define PROCESS_PARAM_DEFAULTSIZE 0x8000
46#define PROCESS_PARAM_DEFAULTSIZE_NPAGES 8
47
48#define PROCESS_SELFLOADER_RESERVED_READELF 0xDFE00000
49#define PROCESS_SELFLOADER_RESERVED_READELF_SIZE 0x20000
50#define PROCESS_SELFLOADER_RESERVED 0xDF000000 /* For the selfloader process to live in. */
51
52#define PROCESS_WALLOC_END 0xD0000000
53#define PROCESS_WALLOC_START 0xC0001000
54
55// ---------------------------------- User Executable region ---------------------------
56
57#define PROCESS_TASK_SIZE 0xC0000000 /* Max. user executable region. */
58
59#define PROCESS_STACK_TOP 0xBFFF0000 /* Stack. */
60#define PROCESS_RLIMIT_STACK 0x20000 /* 32 x 4096 = 128kb stack. */
61#define PROCESS_STACK_BOT (PROCESS_STACK_TOP - PROCESS_RLIMIT_STACK)
62
63/* MMap region. */
64#define PROCESS_MMAP_TOP 0xBF000000  /* MMAP region. */
65#define PROCESS_MMAP_LIMIT_SIZE (1UL << 31UL)  /* 2 GB of available virtual memory. */
66#define PROCESS_MMAP_BOT (PROCESS_MMAP_TOP - PROCESS_MMAP_LIMIT_SIZE)
67
68/* Heap region. */
69#define PROCESS_HEAP_INITIAL_SIZE 0x1000 /* 4kb of initial heap region. */
70
71// ---------------------------------- RefOS OS CSpace ---------------------------
72
73/* Selfloader special CSpace reserves. */
74#define PROCCSPACE_SELFLOADER_RESERVED 35
75#define PROCCSPACE_SELFLOADER_CSPACE_START 16
76#define PROCCSPACE_SELFLOADER_CSPACE_END 34
77
78/* Device Server special capabilities. Note that these overlap with selfloader...because no one
79   likely needs a selfloader to act as a device server. */
80#define PROCCSPACE_DEVICE_SERV_RESERVED 35
81
82#define PROCCSPACE_ALLOC_REGION_START 61000
83#define PROCCSPACE_ALLOC_REGION_END 65000
84#define PROCCSPACE_ALLOC_REGION_SIZE (PROCCSPACE_ALLOC_REGION_END - PROCCSPACE_ALLOC_REGION_START)
85
86
87#endif /* _REFOS_VIRTUAL_MEMORY_LAYOUT_H_ */
88