[prev in list] [next in list] [prev in thread] [next in thread] 

List:       freedos-dev
Subject:    Re: [fd-dev] Detecting Real Mode
From:       Lawrence W <qwoir () yahoo ! com>
Date:       2003-08-02 0:42:57
[Download RAW message or body]

Alain,

SMSW AX (0Fh, 01h, E0h).  If BIT 0 is set, you're in
protected mode (or Virtual 8086, as with EMM386). 
SMSW is not a privileged instruction and will work in
a DOS box.

RDTSC can be used at any protection level, even with
EMM386 installed _if_ CR4, bit 2, is 0.  Of course,
you can only set CR4 if you're in ring 0, so that's
the catch.  So unless EMM386 is fixed to do so, you'll
just have to not use RDTSC.

By the way, the TSC (Time Stamp Counter) can randomly
reset at any time, for example, if the machine enters
and exists a CPU-off suspend due to power management,
which might occur unbeknowns to you.  It can also
change the rate at which it runs, due to CPU
throttling.  Disabling power management is always a
great idea for health and happiness.

--- Alain <alainm@pobox.com> wrote:
> Hi all,
> 
> I have a problem, maybe someone here can halp me ;-)
> 
> I need to detect if I am in real mode or if EMM386
> has been loaded.
> 
> The problem is that I want to use the RDTSC
> instruction and in 
> early Pentium (i586) it can only be used if emm386
> has not been 
> loaded. With newer Pentiums (i686) it works ok.
> I am running a 16bit mode program (or I am in a
> 16bit mode ISR).
> Ah..! I need to know if any kind of memory manager
> is loaded, so
> I cannot use an instalation check, because I will
> never finf them all.
> I have seen some code to test it, using C++
> error-trapping, but I
> BC31 doen't have that...
> 
> thanks for any help,
> 
> Alain
> 
> ----------
> list options/archives/etc.:
> http://www.topica.com/lists/fd-dev
> unsubscribe: send blank email to:
> fd-dev-unsubscribe@topica.com
> 
>
> 


__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com

----------
list options/archives/etc.: http://www.topica.com/lists/fd-dev
unsubscribe: send blank email to: fd-dev-unsubscribe@topica.com

--^----------------------------------------------------------------
This email was sent to: freedos-dev@progressive-comp.com

EASY UNSUBSCRIBE click here: http://topica.com/u/?bz8Rv5.bbTs7X.ZnJlZWRv
Or send an email to: fd-dev-unsubscribe@topica.com

TOPICA - Start your own email discussion group. FREE!
http://www.topica.com/partner/tag02/create/index2.html
--^----------------------------------------------------------------

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic