00001 /***************************************************************************************** 00002 Copyright (c) 2002-2004 The UbixOS Project 00003 All rights reserved. 00004 00005 Redistribution and use in source and binary forms, with or without modification, are 00006 permitted provided that the following conditions are met: 00007 00008 Redistributions of source code must retain the above copyright notice, this list of 00009 conditions, the following disclaimer and the list of authors. Redistributions in binary 00010 form must reproduce the above copyright notice, this list of conditions, the following 00011 disclaimer and the list of authors in the documentation and/or other materials provided 00012 with the distribution. Neither the name of the UbixOS Project nor the names of its 00013 contributors may be used to endorse or promote products derived from this software 00014 without specific prior written permission. 00015 00016 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY 00017 EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 00018 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL 00019 THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 00020 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 00021 OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 00022 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR 00023 TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 00024 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00025 00026 $Id: unmappage_8c-source.html 88 2016-01-12 00:11:29Z reddawg $ 00027 00028 *****************************************************************************************/ 00029 00030 #include <vmm/vmm.h> 00031 00032 /************************************************************************ 00033 00034 Function: void vmmUnmapPage(uInt32 pageAddr,int flags); 00035 Description: This Function Will Unmap A Page From The Kernel VM Space 00036 The Flags Variable Decides If Its To Free The Page Or Not 00037 A Flag Of 0 Will Free It And A Flag Of 1 Will Keep It 00038 Notes: 00039 00040 07/30/02 - I Have Decided That This Should Free The Physical Page There 00041 Is No Reason To Keep It Marked As Not Available 00042 00043 07/30/02 - Ok A Found A Reason To Keep It Marked As Available I Admit 00044 Even I Am Not Perfect Ok The Case Where You Wouldn't Want To 00045 Free It Would Be On Something Like Where I Allocated A Page 00046 To Create A New Virtual Space So Now It Has A Flag 00047 00048 ************************************************************************/ 00049 void 00050 vmmUnmapPage(uInt32 pageAddr, int flags) 00051 { 00052 int pageDirectoryIndex = 0, pageTableIndex = 0; 00053 uInt32 *pageTable = 0x0; 00054 00055 /* Get The Index To The Page Directory */ 00056 pageDirectoryIndex = (pageAddr >> 22); 00057 00058 //Calculate The Page Table Index 00059 pageTableIndex = ((pageAddr >> 12) & 0x3FF); 00060 00061 /* Set pageTable To The Virtual Address Of Table */ 00062 pageTable = (uInt32 *) (tablesBaseAddress + (0x1000 * pageDirectoryIndex)); 00063 /* Free The Physical Page If Flags Is 0 */ 00064 if (flags == 0) { 00065 00066 /* 00067 * This is temp i think its still an issue clearVirtualPage(pageAddr); 00068 * freePage((uInt32)(pageTable[pageTableIndex] & 0xFFFFF000)); 00069 */ 00070 } 00071 /* Unmap The Page */ 00072 pageTable[pageTableIndex] = 0x0; 00073 /* Rehash The Page Directory */ 00074 asm volatile( 00075 "movl %cr3,%eax\n" 00076 "movl %eax,%cr3\n" 00077 ); 00078 /* Return */ 00079 return; 00080 } 00081 00082 00083 00084 /************************************************************************ 00085 00086 Function: void vmmUnmapPages(uInt32 pageAddr,int flags); 00087 Description: This Function Will Unmap A Page From The Kernel VM Space 00088 The Flags Variable Decides If Its To Free The Page Or Not 00089 A Flag Of 0 Will Free It And A Flag Of 1 Will Keep It 00090 Notes: 00091 00092 07/30/02 - I Have Decided That This Should Free The Physical Page There 00093 Is No Reason To Keep It Marked As Not Available 00094 00095 07/30/02 - Ok A Found A Reason To Keep It Marked As Available I Admit 00096 Even I Am Not Perfect Ok The Case Where You Wouldn't Want To 00097 Free It Would Be On Something Like Where I Allocated A Page 00098 To Create A New Virtual Space So Now It Has A Flag 00099 00100 ************************************************************************/ 00101 void vmmUnmapPages(void *ptr,uInt32 size) { 00102 uInt32 baseAddr = (uInt32)ptr & 0xFFFFF000; 00103 uInt32 dI = 0x0,tI = 0x0; 00104 uInt32 y = 0x0; 00105 uInt32 *pageTable = 0x0; 00106 00107 dI = (baseAddr/(1024*4096)); 00108 tI = ((baseAddr-(dI*(1024*4096)))/4096); 00109 pageTable = (uInt32 *)(tablesBaseAddress + (4096*dI)); 00110 for (y=tI;y<(tI+((size+4095)/4096));y++) { 00111 pageTable[y] = 0x0; 00112 } 00113 return; 00114 } 00115 00116 /*** 00117 $Log: unmappage_8c-source.html,v $ 00117 Revision 1.7 2006/12/15 17:47:08 reddawg 00117 Updates 00117 00118 Revision 1.1.1.1 2006/06/01 12:46:13 reddawg 00119 ubix2 00120 00121 Revision 1.2 2005/10/12 00:13:38 reddawg 00122 Removed 00123 00124 Revision 1.1.1.1 2005/09/26 17:24:54 reddawg 00125 no message 00126 00127 Revision 1.4 2004/07/26 19:15:49 reddawg 00128 test code, fixes and the like 00129 00130 Revision 1.3 2004/06/15 12:35:05 reddawg 00131 Cleaned Up 00132 00133 Revision 1.2 2004/06/10 22:23:56 reddawg 00134 Volatiles 00135 00136 Revision 1.1.1.1 2004/04/15 12:06:53 reddawg 00137 UbixOS v1.0 00138 00139 Revision 1.7 2004/04/13 16:36:34 reddawg 00140 Changed our copyright, it is all now under a BSD-Style license 00141 00142 END 00143 ***/