-
Notifications
You must be signed in to change notification settings - Fork 0
/
memory.c.old
133 lines (125 loc) · 3.29 KB
/
memory.c.old
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
/* SPDX-License-Identifier: ISC */
/* Copyright (c) 2015, IBM
* (c) 2020, NEC Laboratories Europe GmbH, NEC Corporation.
* Author(s): Dan Williams <[email protected]>
* Simon Kuenzer <[email protected]>
* Santiago Pagani <[email protected]>
*
* Permission to use, copy, modify, and/or distribute this software
* for any purpose with or without fee is hereby granted, provided
* that the above copyright notice and this permission notice appear
* in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
* WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
* AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
* NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#include <uk/plat/memory.h>
#include <uk/plat/common/sections.h>
#include <uk/essentials.h>
#include <raspi/sysregs.h>
int ukplat_memregion_count(void)
{
return 7;
}
int ukplat_memregion_get(int i, struct ukplat_memregion_desc *m)
{
int ret;
UK_ASSERT(m);
switch (i) {
case 0: /* stack */
m->base = (void *) 0;
m->len = (size_t) __TEXT;
m->flags = (UKPLAT_MEMRF_RESERVED
| UKPLAT_MEMRF_READABLE
| UKPLAT_MEMRF_WRITABLE);
ret = 0;
#if CONFIG_UKPLAT_MEMRNAME
m->name = "stack";
#endif
break;
case 1: /* text */
m->base = (void *) __TEXT;
m->len = (size_t) __ETEXT - (size_t) __TEXT;
m->flags = (UKPLAT_MEMRF_RESERVED
| UKPLAT_MEMRF_READABLE);
#if CONFIG_UKPLAT_MEMRNAME
m->name = "text";
#endif
ret = 0;
break;
case 2: /* rodata */
m->base = (void *) __RODATA;
m->len = (size_t) __ERODATA - (size_t) __RODATA;
m->flags = (UKPLAT_MEMRF_RESERVED
| UKPLAT_MEMRF_READABLE);
#if CONFIG_UKPLAT_MEMRNAME
m->name = "rodata";
#endif
ret = 0;
break;
case 3: /* ctors */
m->base = (void *) __CTORS;
m->len = (size_t) __ECTORS - (size_t) __CTORS;
m->flags = (UKPLAT_MEMRF_RESERVED
| UKPLAT_MEMRF_READABLE);
#if CONFIG_UKPLAT_MEMRNAME
m->name = "ctors";
#endif
ret = 0;
break;
case 4: /* data */
m->base = (void *) __DATA;
m->len = (size_t) __EDATA - (size_t) __DATA;
m->flags = (UKPLAT_MEMRF_RESERVED
| UKPLAT_MEMRF_READABLE
| UKPLAT_MEMRF_WRITABLE);
#if CONFIG_UKPLAT_MEMRNAME
m->name = "data";
#endif
ret = 0;
break;
case 5: /* bss */
m->base = (void *) __BSS_START;
m->len = (size_t) __END - (size_t) __BSS_START;
m->flags = (UKPLAT_MEMRF_RESERVED
| UKPLAT_MEMRF_READABLE
| UKPLAT_MEMRF_WRITABLE);
#if CONFIG_UKPLAT_MEMRNAME
m->name = "bss";
#endif
ret = 0;
break;
case 6: /* heap */
m->base = (void *) __END;
m->len = (size_t) (MMIO_BASE/2 - 1) - (size_t) __END;
m->flags = UKPLAT_MEMRF_ALLOCATABLE;
#if CONFIG_UKPLAT_MEMRNAME
m->name = "heap";
#endif
ret = 0;
break;
default:
m->base = __NULL;
m->len = 0;
m->flags = 0x0;
#if CONFIG_UKPLAT_MEMRNAME
m->name = __NULL;
#endif
ret = -1;
break;
}
return ret;
}
int _ukplat_mem_mappings_init(void)
{
return 0;
}
void ukplat_stack_set_current_thread(void *thread_addr __unused)
{
}