]> git.buserror.net Git - polintos/scott/priv.git/blobdiff - kernel/include/kern/mem.h
update
[polintos/scott/priv.git] / kernel / include / kern / mem.h
index 6020a9053ba848ccd3d0b7f2671417b092fc2313..a143dfb7dcaa209f23085e13bf72f914697db246 100644 (file)
@@ -44,6 +44,20 @@ namespace Mem {
        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
                
@@ -58,6 +72,7 @@ namespace Mem {
                        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
@@ -70,6 +85,12 @@ namespace Mem {
 
                        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. 
@@ -77,9 +98,11 @@ namespace Mem {
                        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;
@@ -201,6 +224,11 @@ namespace Mem {
        
        
        struct BadPageFault {
+               MemoryFault_ns::Cause cause;
+               
+               BadPageFault(MemoryFault_ns::Cause CAUSE) : cause(CAUSE)
+               {
+               }
        };
        
        class ASpaceMappable : public Mappable {
@@ -293,24 +321,18 @@ namespace Mem {
                
                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);