delorie.com/archives/browse.cgi | search |
X-Authentication-Warning: | delorie.com: mail set sender to djgpp-bounces using -f |
From: | RayeR <glaux AT centrum DOT cz> |
Newsgroups: | comp.os.msdos.djgpp |
Subject: | Re: running ring0 code under DJGPP |
Date: | Sun, 02 Sep 2007 12:53:54 -0700 |
Organization: | http://groups.google.com |
Lines: | 46 |
Message-ID: | <1188762834.850612.158320@r29g2000hsg.googlegroups.com> |
References: | <1188419914 DOT 751897 DOT 124870 AT k79g2000hse DOT googlegroups DOT com> |
<46dadebd$0$7704$9b4e6d93 AT newsspool2 DOT arcor-online DOT net> | |
<1188753598 DOT 507918 DOT 144880 AT k79g2000hse DOT googlegroups DOT com> | |
<1188760922 DOT 901124 DOT 38270 AT r29g2000hsg DOT googlegroups DOT com> | |
NNTP-Posting-Host: | 89.176.103.156 |
Mime-Version: | 1.0 |
X-Trace: | posting.google.com 1188762835 32716 127.0.0.1 (2 Sep 2007 19:53:55 GMT) |
X-Complaints-To: | groups-abuse AT google DOT com |
NNTP-Posting-Date: | Sun, 2 Sep 2007 19:53:55 +0000 (UTC) |
In-Reply-To: | <1188760922.901124.38270@r29g2000hsg.googlegroups.com> |
User-Agent: | G2/1.0 |
X-HTTP-UserAgent: | Mozilla/5.0 (Windows; U; Win98; en-US; rv:1.8.1.6) Gecko/20070802 SeaMonkey/1.1.4,gzip(gfe),gzip(gfe) |
Complaints-To: | groups-abuse AT google DOT com |
Injection-Info: | r29g2000hsg.googlegroups.com; posting-host=89.176.103.156; |
posting-account=ps2QrAMAAAA6_jCuRt2JEIpn5Otqf_w0 | |
To: | djgpp AT delorie DOT com |
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp |
Reply-To: | djgpp AT delorie DOT com |
Errors-To: | nobody AT delorie DOT com |
X-Mailing-List: | djgpp AT delorie DOT com |
X-Unsubscribes-To: | listserv AT delorie DOT com |
Yeaaa! it's definitely working! I can read/write MSRs even under stupid EMM386 and Windows98SE. Breaking the wall :) The problem above was caused by pushal-popal pair in asm code: I'm not sure if it's really needed, plase inline-asm-skilled guys let me know how to improve it asm __volatile__ ( // volani CallGate // "pushal\n" // store all registers to stack "cli\n" // disable interrupts "movl %0,%%ebx\n" // store pointer to low DWord "movl %1,%%edi\n" // store pointer to high DWord "movl %2,%%ecx\n" // store MSR index "lcall *%3\n" // far call the CallGate to enter ring 0, require code far return "sti\n" // enable interrupts // "popal\n" // restore all registers from stack : // no outputs (readed data overwrites input arguments) : "g" (eax), "g" (edx), "g" (ecx), "m" (ldt_callgate_ptr) // inputs ); (rdmsr/wrmsr affects only EDX:EAX, using ECX as input param) //***************** kod s opravnenim ring 0 - precte MSR dle ECX do promennych na adresach [EBX], [EDI] (Win9x) void ring0_rdmsr(void) // GCC bohuzel nepodporuje __attribute__ ((naked)) na x86 { // takze misto pointeru na funkci pouzijeme ASM label asm __volatile__ ( "rdmsr_label:\n" // label at start of pure code behind C-function prologue "rdmsr\n" // read CPU MSR register value to EDX:EAX "movl %eax,(%ebx)\n" // mov dword ptr [ebx],eax "movl %edx,(%edi)\n" // mov dword ptr [edi],edx "lret\n" // far return from ring 0 ); // C-function epilogue will be never reached }
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |