Back to home page

DOS ain't dead

Forum index page

Log in | Register

Back to the forum
Board view  Mix view

VESAMTTR (recovered from Google) (DOSX)

posted by RayeR Homepage, CZ, 04.09.2007, 12:59

I dopn't need anything extra, just if here someone knows AT&T inline ASM for DJGPP:

My ring0 code is this shor function:

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


and callgate is called:

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
    );


If I have pushal/popal around the call, then DJGPP crashes (but mingw32 not) so i commented it. Is it really needed? Or can I ommit it? Or any idea to improve this inline asm?

EDIT by rr: added {code} tags

---
DOS gives me freedom to unlimited HW access.

 

Complete thread:

Back to the forum
Board view  Mix view
22049 Postings in 2034 Threads, 396 registered users, 249 users online (0 registered, 249 guests)
DOS ain't dead | Admin contact
RSS Feed
powered by my little forum