00001 /***************************************************************************************** 00002 Copyright (c) 2002 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: setpageattributes_8c-source.html 88 2016-01-12 00:11:29Z reddawg $ 00027 00028 *****************************************************************************************/ 00029 00030 #include <vmm/vmm.h> 00031 #include <ubixos/kpanic.h> 00032 00033 /************************************************************************ 00034 00035 Function: void vmmSetPageAttributes(uInt32 pageAddr,int attributes; 00036 Description: This Function Will Set The Page Attributes Such As 00037 A Read Only Page, Stack Page, COW Page, ETC. 00038 Notes: 00039 00040 ************************************************************************/ 00041 int vmm_setPageAttributes(uInt32 memAddr,uInt16 attributes) { 00042 uInt16 directoryIndex = 0x0, tableIndex = 0x0; 00043 uInt32 *pageTable = 0x0; 00044 00045 /* Calculate The Page Directory Index */ 00046 directoryIndex = (memAddr >> 22); 00047 00048 /* Calculate The Page Table Index */ 00049 tableIndex = ((memAddr >> 12) & 0x3FF); 00050 00051 /* Set Table Pointer */ 00052 if ((pageTable = (uInt32 *) (tablesBaseAddress + (0x1000 * directoryIndex))) == 0x0) 00053 kpanic("Error: pageTable == NULL, File: %s, Line: %i\n",__FILE__,__LINE__); 00054 00055 /* Set Attribute If Page Is Mapped */ 00056 if (pageTable[tableIndex] != 0x0) 00057 pageTable[tableIndex] = ((pageTable[tableIndex] & 0xFFFFF000) | attributes); 00058 00059 /* Reload The Page Table; */ 00060 asm volatile( 00061 "push %eax \n" 00062 "movl %cr3,%eax\n" 00063 "movl %eax,%cr3\n" 00064 "pop %eax \n" 00065 ); 00066 /* Return */ 00067 return(0x0); 00068 } 00069 00070 /*** 00071 $Log: setpageattributes_8c-source.html,v $ 00071 Revision 1.7 2006/12/15 17:47:07 reddawg 00071 Updates 00071 00072 Revision 1.1.1.1 2006/06/01 12:46:13 reddawg 00073 ubix2 00074 00075 Revision 1.2 2005/10/12 00:13:38 reddawg 00076 Removed 00077 00078 Revision 1.1.1.1 2005/09/26 17:24:53 reddawg 00079 no message 00080 00081 Revision 1.4 2004/07/28 15:05:43 reddawg 00082 Major: 00083 Pages now have strict security enforcement. 00084 Many null dereferences have been resolved. 00085 When apps loaded permissions set for pages rw and ro 00086 00087 Revision 1.3 2004/07/20 22:29:55 reddawg 00088 assert: remade assert 00089 00090 Revision 1.2 2004/06/10 22:23:56 reddawg 00091 Volatiles 00092 00093 Revision 1.1.1.1 2004/04/15 12:06:53 reddawg 00094 UbixOS v1.0 00095 00096 Revision 1.6 2004/04/13 16:36:34 reddawg 00097 Changed our copyright, it is all now under a BSD-Style license 00098 00099 END 00100 ***/ 00101