using System::Mem::AccessFlags;
union PTEFlags {
+ enum {
+ valid = 0x001,
+ writeable = 0x002,
+ readable = 0x004,
+ executable = 0x008,
+ user = 0x010,
+ accessed = 0x020,
+ dirty = 0x040,
+ uncached = 0x080,
+ faultonwrite = 0x100,
+ addressonly = 0x200,
+ protectedmap = 0x400,
+ };
+
struct {
// This must be kept in sync with include/kern/generic-pte.h
ulong User:1;
ulong Accessed:1;
ulong Dirty:1;
+ ulong Uncached:1;
// If set, then on a write access, the page is copied and this
// address space gets the new, anonymous version. The rmap list
ulong FaultOnWrite:1;
+ // The address itself is being mapped, not the page located
+ // there. Do not manipulate page reference counts. This bit
+ // does not get propagated during copy-on-write.
+
+ ulong AddressOnly:1;
+
// VArea Only:
// Do not allow the user to unmap or modify flags.
// Used for the shared user/kernel mappings.
ulong Protected:1;
#elif defined(BITFIELD_BE)
- ulong pad:_LL_LONG_BYTES * 8 - 9;
+ ulong pad:_LL_LONG_BYTES * 8 - 11;
ulong Protected:1;
+ ulong AddressOnly:1;
ulong FaultOnWrite:1;
+ ulong Uncached:1;
ulong Dirty:1;
ulong Accessed:1;
ulong User:1;
struct BadPageFault {
+ MemoryFault_ns::Cause cause;
+
+ BadPageFault(MemoryFault_ns::Cause CAUSE) : cause(CAUSE)
+ {
+ }
};
class ASpaceMappable : public Mappable {
AddrSpace(PageTable *ptbl = NULL);
- // Returns true if the fault was "good"; otherwise, the caller
- // should dump regs. exec should only be used if the CPU
- // implements per-page exec protection; otherwise, treat it
- // as a read.
+ // Returns negative if the fault was "good"; otherwise, a fault
+ // code corresponding to MemoryFault.Cause is returned. exec
+ // should only be set if the CPU implements per-page exec
+ // protection; otherwise, treat it as a read.
- bool handle_fault(ulong addr, bool write, bool exec, bool user);
+ int handle_fault(ulong addr, bool write, bool exec, bool user);
void get_mappable(IMappable *ma);
void clone(IAddrSpace *addrspace, u8 clone_is_real);
- enum {
- map_user,
- map_protected,
- map_kernel
- };
-
void map(IMappable ma, Region region, u64 *vstart, MapFlags mflags,
- int map_type = map_user);
+ PTEFlags set = 0, PTEFlags clear = 0);
void unmap(Region region, bool from_kernel = false);
void set_mapflags(Region region, MapFlags mflags);