Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

registers.h

Go to the documentation of this file.
00001 
00006 /*
00007  *  Copyright (C) 2003,2004 Bregmasoft
00008  * 
00009  * This program is free software; you can redistribute it and/or modify it under
00010  * the terms of the GNU General Public License as published by the Free Software
00011  * Foundation; either version 2 of the License, or (at your option) any later
00012  * version.
00013  * 
00014  * This program is distributed in the hope that it will be useful, but WITHOUT ANY
00015  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
00016  * PARTICULAR PURPOSE. See the GNU General Public License for more details.
00017  * 
00018  * You should have received a copy of the GNU General Public License along with
00019  * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
00020  * Place, Suite 330, Boston, MA 02111-1307 USA
00021  */
00022 #ifndef ZYGOMA_X86_REGISTERS_H_ 
00023 #define ZYGOMA_X86_REGISTERS_H_ 
00024 
00025 #include <arch/types.h>
00026 
00027 namespace Zygoma
00028 {
00096   static inline u32 __attribute__((__unused__))
00097   getCR2()
00098   {
00099     register u32 faultAddress;
00100 
00101     __asm__ __volatile__("mov %%cr2, %[faultAddress]"
00102                          : [faultAddress] "=r" (faultAddress)
00103                          :);
00104     return faultAddress;
00105   }
00106 
00113   static inline void __attribute__((__unused__))
00114   setCR3(u32 pagedir)
00115   {
00116      __asm__ __volatile__("mov %[pagedir], %%cr3"
00117                           :
00118                           : [pagedir] "r" (pagedir));
00119   }
00120 
00127   static inline u32 __attribute__((__unused__))
00128   getCR3()
00129   {
00130     u32 pagedir;
00131 
00132     __asm__ __volatile__("mov %%cr3, %[pagedir]"
00133                          : [pagedir] "=r" (pagedir));
00134     return pagedir;
00135   }
00136 
00138 } // namespace Zygoma
00139 
00140 #endif // ZYGOMA_X86_REGISTERS_H_ 

Generated on Fri Sep 2 10:44:36 2005 for zygoma by doxygen 1.4.2