]> rtime.felk.cvut.cz Git - l4.git/blob - kernel/fiasco/src/kern/arm/mem_layout-arm.cpp
1da21916764c6d6650ce4a0fe5b6222046542f57
[l4.git] / kernel / fiasco / src / kern / arm / mem_layout-arm.cpp
1 INTERFACE [arm && !kern_start_0xd]:
2
3 EXTENSION class Mem_layout
4 {
5 public:
6   enum Virt_layout_umax : Address {
7     User_max             = 0xc0000000,
8   };
9 };
10
11
12 //---------------------------------------------------------------------------
13 INTERFACE [arm && kern_start_0xd]:
14
15 EXTENSION class Mem_layout
16 {
17 public:
18   enum Virt_layout_umax : Address {
19     User_max             = 0xd0000000,
20   };
21 };
22
23
24 //---------------------------------------------------------------------------
25 INTERFACE [arm]:
26
27 #include "template_math.h"
28
29 EXTENSION class Mem_layout
30 {
31 public:
32   enum Virt_layout : Address {
33     Utcb_addr            = User_max - 0x10000,
34     Service_page         = 0xeac00000,
35     Tbuf_status_page     = Service_page + 0x5000,
36     Tbuf_ustatus_page    = Tbuf_status_page,
37     Tbuf_buffer_area     = Service_page + 0x200000,
38     Tbuf_ubuffer_area    = Tbuf_buffer_area,
39     Jdb_tmp_map_area     = Service_page + 0x400000,
40     __free_1_start       = 0xee000000,
41     __free_1_end         = 0xef000000,
42     Cache_flush_area     = 0xef000000,
43     Cache_flush_area_end = 0xef100000,
44     Registers_map_start  = 0xef100000,
45     Registers_map_end    = 0xeff00000,
46     Map_base             = 0xf0000000,
47     Map_end              = 0xf5000000,
48     Caps_start           = 0xf5000000,
49     Caps_end             = 0xfd000000,
50     Utcb_ptr_page        = 0xffffd000,
51     // don't care about caches here, because arm uses a register on MP
52     utcb_ptr_align       = Tl_math::Ld<sizeof(void*)>::Res,
53     Kern_lib_base        = 0xffffe000,
54     Ivt_base             = 0xffff0000,
55     Syscalls             = 0xfffff000,
56
57     Kernel_max           = 0x00000000,
58
59     Devices0_map_base    = Registers_map_start + 0x00000000,
60     Devices1_map_base    = Registers_map_start + 0x00100000,
61     Devices2_map_base    = Registers_map_start + 0x00200000,
62     Devices3_map_base    = Registers_map_start + 0x00300000,
63     Devices4_map_base    = Registers_map_start + 0x00400000,
64     Devices5_map_base    = Registers_map_start + 0x00500000,
65     Devices6_map_base    = Registers_map_start + 0x00600000,
66     Devices7_map_base    = Registers_map_start + 0x00700000,
67     Devices8_map_base    = Registers_map_start + 0x00800000,
68     Devices9_map_base    = Registers_map_start + 0x00900000,
69   };
70 };
71
72 // -------------------------------------------------------------------------
73 IMPLEMENTATION [arm]:
74
75 //---------------------------------
76 // Workaround GCC BUG 33661
77 // Do not use register asm ("r") in a template function, it will be ignored
78 //---------------------------------
79 PUBLIC static inline
80 bool
81 Mem_layout::_read_special_safe(Mword const *address, Mword &v)
82 {
83   register Mword a asm("r14") = (Mword)address;
84   Mword ret;
85   asm volatile ("msr cpsr_f, #0    \n" // clear flags
86                 "ldr %[a], [%[a]]  \n"
87                 "movne %[ret], #1      \n"
88                 "moveq %[ret], #0      \n"
89
90                 : [a] "=r" (a), [ret] "=r" (ret)
91                 : "0" (a)
92                 : "cc");
93   v = a;
94   return ret;
95 }
96
97 PUBLIC static inline
98 template< typename V >
99 bool
100 Mem_layout::read_special_safe(V const *address, V &v)
101 {
102   Mword _v;
103   bool ret = _read_special_safe(reinterpret_cast<Mword const*>(address), _v);
104   v = V(_v);
105   return ret;
106 }
107
108 //---------------------------------
109 // Workaround GCC BUG 33661
110 // Do not use register asm ("r") in a template function, it will be ignored
111 //---------------------------------
112 PUBLIC static inline
113 Mword
114 Mem_layout::_read_special_safe(Mword const *a)
115 {
116   register Mword const *res __asm__ ("r14") = a;
117   __asm__ __volatile__ ("ldr %0, [%0]\n" : "=r" (res) : "r" (res) : "cc" );
118   return Mword(res);
119 }
120
121 PUBLIC static inline
122 template< typename T >
123 T
124 Mem_layout::read_special_safe(T const *a)
125 {
126   return T(_read_special_safe((Mword const *)a));
127 #if 0
128   Mword res;
129   asm volatile ("msr cpsr_f, #0; ldr %0, [%1]; moveq %0, #0\n"
130                 : "=r" (res) : "r" (a) : "cc");
131   return T(res);
132 #endif
133 }
134
135 PUBLIC static inline
136 bool
137 Mem_layout::is_special_mapped(void const *a)
138 {
139   register Mword pagefault_if_0 asm("r14");
140   asm volatile ("msr cpsr_f, #0 \n" // clear flags
141                 "ldr %0, [%0]   \n"
142                 "movne %0, #1   \n"
143                 "moveq %0, #0   \n"
144                 : "=r" (pagefault_if_0) : "0" (a) : "cc");
145   return pagefault_if_0;
146 }