Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

virtmem.h

Go to the documentation of this file.
00001 // See the end of this file for license information.
00002 
00003 #ifndef TORSION_VIRTMEM_H
00004 #define TORSION_VIRTMEM_H
00005 
00006 #include "asm.h"
00007 #include "slaballoc.h"
00008 #include "physmem.h"
00009 #include "pagealloc.h"
00010 
00011 class Virtual_memory;
00012 extern Virtual_memory* virtual_mem;
00013 
00019 
00020 class Virtual_memory {
00021 protected:
00023   static const unsigned MAX_PAGE_SPAN_ALIGNMENT = 16;
00025   Slab_allocator allocators[PAGE_ALIGNMENT];
00026   bool enabled;       
00027 
00028 public:
00029   Page_allocator virtual_pages;   
00030 
00036   static Virtual_memory*
00037   create(unsigned& last_available_address, bool map_memory = false);
00038 
00040   void
00041   init(unsigned& last_available_address);
00042 
00044   void*
00045   alloc(Size request_size);
00046 
00048   void*
00049   resize(void* memory, Size new_size);
00050 
00052   void
00053   free(void* memory);
00054   
00056   inline void
00057   enable() {
00058     enabled = true;
00059   }
00060 
00062   inline bool
00063   is_enabled() {
00064     return enabled;
00065   }
00066 
00068   inline bool
00069   manages(void* virtual_page) {
00070     if (enabled && virtual_pages.manages(virtual_page))
00071       return true;
00072     return false;
00073   }
00074 
00076   void
00077   print();
00078 };
00079 
00081 void* operator
00082 new(Size request_size);
00083 
00085 void operator
00086 delete(void* memory);
00087 
00088 #endif
00089 
00090 /* Torsion Operating System, Copyright (C) 2000-2004 Dan Helfman
00091  *
00092  * This program is free software; you can redistribute it and/or modify it
00093  * under the terms of the GNU General Public License as published by the
00094  * Free Software Foundation; either version 2 of the License, or (at your
00095  * option) any later version.
00096  * 
00097  * This program is distributed in the hope that it will be useful, but
00098  * WITHOUT ANY WARRANTY; without even the implied warranty of
00099  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00100  * General Public License for more details (in the COPYING file).
00101  * 
00102  * You should have received a copy of the GNU General Public License along
00103  * with this program; if not, write to the Free Software Foundation, Inc.,
00104  * 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00105  */

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