Skip to content

Commit fa6308e

Browse files
committed
prefer explicit namespaces
1 parent bfd89ce commit fa6308e

File tree

1 file changed

+20
-23
lines changed

1 file changed

+20
-23
lines changed

src/arch/x86_64/paging.cpp

Lines changed: 20 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,8 @@ const size_t x86::paging::Map::any_size { supported_page_sizes() };
3333
template<>
3434
const size_t os::mem::Map::any_size { supported_page_sizes() };
3535

36-
using namespace os::mem;
3736
using namespace util;
3837

39-
using Flags = x86::paging::Flags;
40-
using Pml4 = x86::paging::Pml4;
41-
4238
static void allow_executable();
4339

4440
// TODO: -Wunused-function
@@ -84,13 +80,14 @@ extern uintptr_t __exec_end;
8480
**/
8581

8682
// The main page directory pointer
87-
Pml4* __pml4;
83+
x86::paging::Pml4* __pml4;
8884

8985
__attribute__((weak))
9086
void __arch_init_paging() {
9187
INFO("x86_64", "Initializing paging");
88+
using Flags = x86::paging::Flags;
9289
auto default_fl = Flags::present | Flags::writable | Flags::huge | Flags::no_exec;
93-
__pml4 = new Pml4(0);
90+
__pml4 = new x86::paging::Pml4(0);
9491
Expects(__pml4 != nullptr);
9592
Expects(!__pml4->has_flag(0, Flags::present));
9693

@@ -137,23 +134,23 @@ void __arch_init_paging() {
137134
namespace x86 {
138135
namespace paging {
139136

140-
Access to_memflags(Flags f)
137+
os::mem::Access to_memflags(Flags f)
141138
{
142-
Access prot = Access::none;
139+
os::mem::Access prot = os::mem::Access::none;
143140

144141
if (! has_flag(f, Flags::present)) {
145-
prot |= Access::none;
142+
prot |= os::mem::Access::none;
146143
return prot;
147144
}
148145

149-
prot |= Access::read;
146+
prot |= os::mem::Access::read;
150147

151148
if (has_flag(f, Flags::writable)) {
152-
prot |= Access::write;
149+
prot |= os::mem::Access::write;
153150
}
154151

155152
if (! has_flag(f, Flags::no_exec)) {
156-
prot |= Access::execute;
153+
prot |= os::mem::Access::execute;
157154
}
158155

159156
return prot;
@@ -162,17 +159,17 @@ Access to_memflags(Flags f)
162159
Flags to_x86(os::mem::Access prot)
163160
{
164161
Flags flags = Flags::none;
165-
if (prot != Access::none) {
162+
if (prot != os::mem::Access::none) {
166163
flags |= Flags::present;
167164
} else {
168165
return Flags::none;
169166
}
170167

171-
if (has_flag(prot, Access::write)) {
168+
if (has_flag(prot, os::mem::Access::write)) {
172169
flags |= Flags::writable;
173170
}
174171

175-
if (not has_flag(prot, Access::execute)) {
172+
if (not has_flag(prot, os::mem::Access::execute)) {
176173
flags |= Flags::no_exec;
177174
}
178175

@@ -225,11 +222,11 @@ bool mem::supported_page_size(uintptr_t size)
225222
return bits::is_pow2(size) and (size & supported_page_sizes()) != 0;
226223
}
227224

228-
Map to_mmap(Map_x86 map){
225+
os::mem::Map to_mmap(os::mem::Map_x86 map){
229226
return {map.lin, map.phys, to_memflags(map.flags), map.size, map.page_sizes};
230227
}
231228

232-
Map_x86 to_x86(Map map){
229+
os::mem::Map_x86 to_x86(os::mem::Map map){
233230
return {map.lin, map.phys, x86::paging::to_x86(map.flags), map.size, map.page_sizes};
234231
}
235232

@@ -240,7 +237,7 @@ uintptr_t mem::virt_to_phys(uintptr_t linear)
240237
return __pml4->addr_of(*ent);
241238
}
242239

243-
Access mem::protect_page(uintptr_t linear, Access flags)
240+
os::mem::Access mem::protect_page(uintptr_t linear, Access flags)
244241
{
245242
MEM_PRINT("::protect_page 0x%lx\n", linear);
246243
x86::paging::Flags xflags = x86::paging::to_x86(flags);
@@ -249,7 +246,7 @@ Access mem::protect_page(uintptr_t linear, Access flags)
249246
return to_memflags(f);
250247
};
251248

252-
Access mem::protect_range(uintptr_t linear, Access flags)
249+
os::mem::Access mem::protect_range(uintptr_t linear, Access flags)
253250
{
254251
MEM_PRINT("::protect 0x%lx \n", linear);
255252
x86::paging::Flags xflags = x86::paging::to_x86(flags);
@@ -276,7 +273,7 @@ Access mem::protect_range(uintptr_t linear, Access flags)
276273
return to_memflags(fl);
277274
};
278275

279-
Map mem::protect(uintptr_t linear, size_t len, Access flags)
276+
os::mem::Map mem::protect(uintptr_t linear, size_t len, Access flags)
280277
{
281278
if (UNLIKELY(len < min_psize()))
282279
mem_fail_fast("Can't map less than a page\n");
@@ -300,13 +297,13 @@ Map mem::protect(uintptr_t linear, size_t len, Access flags)
300297
return to_mmap(res);
301298
}
302299

303-
Access mem::flags(uintptr_t addr)
300+
os::mem::Access mem::flags(uintptr_t addr)
304301
{
305302
return to_memflags(__pml4->flags_r(addr));
306303
}
307304

308305
__attribute__((weak))
309-
Map mem::map(Map m, const char* name)
306+
os::mem::Map mem::map(Map m, const char* name)
310307
{
311308
using namespace x86::paging;
312309
using namespace util;
@@ -349,7 +346,7 @@ Map mem::map(Map m, const char* name)
349346
return to_mmap(new_map);
350347
};
351348

352-
Map mem::unmap(uintptr_t lin){
349+
os::mem::Map mem::unmap(uintptr_t lin){
353350
auto key = os::mem::vmmap().in_range(lin);
354351
Map_x86 m;
355352
if (key) {

0 commit comments

Comments
 (0)