1 INTERFACE [ia32 || amd64 || ux]:
3 EXTENSION class Mem_layout
6 enum { Io_port_max = (1UL << 16) };
8 static Address _io_map_ptr;
11 IMPLEMENTATION [ia32 || amd64 || ux]:
13 #include "static_assert.h"
15 Address Mem_layout::_io_map_ptr = Mem_layout::Io_map_area_end;
19 Mem_layout::alloc_io_vmem(unsigned long bytes)
21 bytes = (bytes + Config::PAGE_SIZE - 1) & ~(Config::PAGE_SIZE - 1);
22 if (_io_map_ptr - bytes < Io_map_area_start)
29 PUBLIC static inline NEEDS["static_assert.h"]
30 template< typename V >
32 Mem_layout::read_special_safe(V const *address, V &v)
34 static_assert(sizeof(v) <= sizeof(Mword), "wrong sized argument");
37 asm volatile ("clc; mov (%[adr]), %[val]; setnc %b[ex] \n"
38 : [val] "=acd" (value), [ex] "=r" (res)
39 : [adr] "acdbSD" (address)
45 PUBLIC static inline NEEDS["static_assert.h"]
46 template< typename T >
48 Mem_layout::read_special_safe(T const *a)
50 static_assert(sizeof(T) <= sizeof(Mword), "wrong sized return type");
52 asm volatile ("mov (%1), %0 \n\t"
53 : "=acd" (res) : "acdbSD" (a) : "cc");
60 Mem_layout::is_special_mapped(void const *a)
62 // Touch the state to page in the TCB. If we get a pagefault here,
63 // the handler doesn't handle it but returns immediatly after
64 // setting eax to 0xffffffff
67 "clc; mov (%2), %0 \n\t"
69 : "=acd" (pagefault_if_0)
70 : "0"(0UL), "acdbSD"(a)
72 return pagefault_if_0;