Main Page   Class Hierarchy   Compound List   File List   Compound Members   File Members  

pagemap.h

Go to the documentation of this file.
00001 // See the end of this file for license information.
00002 
00003 #ifndef TORSION_PAGE_H
00004 #define TORSION_PAGE_H
00005 
00006 #include "array.h"
00007 #include "addrmap.h"
00008 #include "irq.h"
00009 
00011 
00012 class Page_map : public Address_map {
00013 protected:
00014   void* direct_mapped_end;              
00015   unsigned int* temp_mapping_cache;     
00016 
00017 public:
00018   static const unsigned int PTE_USER = 0x4;
00019   static const unsigned int PTE_ACCESSED = 0x20;
00020   static const unsigned int PTE_PAGE_FRAME_ADDRESS = 0xfffff000;
00021   static const unsigned int CR0_PAGING = 0x80000000;
00023   static const unsigned int PAGE_TABLE_CACHE_SIZE = 1;
00024 
00026   void
00027   init();
00028 
00031   void map_page(void* virtual_page, void* physical_page); 
00032 
00037   unsigned int*
00038   make_temp_mapping(unsigned int* physical_page);
00039 
00041   void
00042   unmap_page(void* virtual_page);
00043 
00046   static inline unsigned int*
00047   table_entry_to_phys(unsigned int* page_entry) {
00048     return (unsigned int*)(*page_entry & PTE_PAGE_FRAME_ADDRESS);
00049   }
00050 
00052   void
00053   get_pages_to_checkpoint(Array<void*>& pages_to_log);
00054 
00056   void
00057   handle_page_fault(unsigned int error_flags);
00058 };
00059 
00061 inline void
00062 page_fault_handler(volatile Handler_registers& registers);
00063 
00064 // TODO:
00065 // upon evicting a page to disk (swapping):
00066 // log the page to disk
00067 // (note that if the page to swap is copy-on-write, maybe log the original
00068 //  instead of the copy so as to ensure snapshot consistency?)
00069 // unset dirty bit in pte
00070 // add the page to the block map (in memory)
00071 
00072 // Page table entry for virtual page in memory:
00073 // 
00074 //  31                                   12     9 8 7 6 5 4 3 2 1 0
00075 // +---------------------------------------------------------------+
00076 // |                                       |                  U R  |
00077 // |       page frame address 31..12       |0 0 0 X X D A X X / / P|
00078 // |                                       |                  S W  |
00079 // +---------------------------------------------------------------+
00080 //
00081 //   P : present = 1
00082 // R/W : read/write
00083 // U/S : user/supervisor = 0
00084 //   D : dirty
00085 //   X : Intel reserved
00086 //   0 : unused
00087 //
00088 // Page table entry for unused virtual page:
00089 // 
00090 //  31                                                            0
00091 // +---------------------------------------------------------------+
00092 // |                                                               |
00093 // |0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0|
00094 // |                                                               |
00095 // +---------------------------------------------------------------+
00096 
00097 #endif
00098 
00099 /* Torsion Operating System, Copyright (C) 2000-2002 Dan Helfman
00100  *
00101  * This program is free software; you can redistribute it and/or modify it
00102  * under the terms of the GNU General Public License as published by the
00103  * Free Software Foundation; either version 2 of the License, or (at your
00104  * option) any later version.
00105  * 
00106  * This program is distributed in the hope that it will be useful, but
00107  * WITHOUT ANY WARRANTY; without even the implied warranty of
00108  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00109  * General Public License for more details (in the COPYING file).
00110  * 
00111  * You should have received a copy of the GNU General Public License along
00112  * with this program; if not, write to the Free Software Foundation, Inc.,
00113  * 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00114  */

Torsion Operating System, Copyright (C) 2000-2002 Dan Helfman