00001 /*********************************************************** 00002 *PANALIX 0.06, (c) Adrian Panasiuk 2002-4 * 00003 *adek336[at]o2.pl, panalix.prv.pl * 00004 *under GPLv3 license * 00005 * * 00006 *panalix - small osdev project * 00007 ************************************************************ 00008 * wp.cpp, version 1.0 * 00009 ************************************************************ 00010 * * 00011 *enable the WriteProtect bit in cr0 * 00012 * * 00013 *23'08'04- first revision (1.0) * 00014 * * 00015 ***********************************************************/ 00016 00017 #include "src/common/shared.hpp" 00018 #include "src/memory/memset.hpp" 00019 #include "src/memory/align.hpp" 00020 #include "src/memory/heap.hpp" 00021 #include "src/arch/x86/cpuid.hpp" 00022 #include "src/arch/x86/wp.hpp" 00023 00024 namespace Arch { 00025 namespace x86 { 00026 namespace WProtect { 00027 00028 /*setup the cr0.wp bit*/ 00029 void init() 00030 { 00031 if (cpuid_success!=1) 00032 sysfail("WProtect::init()- cpuid not invoked earlier"); 00033 00034 asm volatile(" mov %cr0, %eax\norl $0x10000,%eax\nmov %eax, %cr0 "); //cr0.wp=1 a.k.a enable write protect 00035 } 00036 00037 00038 }; /*namespace WProtect*/ 00039 }; /*namespace x86*/ 00040 }; /*namespace Arch*/ 00041 00042 00043 /*********************************************************** 00044 * * 00045 *panalix 0.06 (c) Adrian Panasiuk 2002-4 * 00046 *adek336[at]o2.pl, panalix.prv.pl * 00047 * * 00048 ***********************************************************/