www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2001/09/24/05:21:35

Date: Mon, 24 Sep 2001 12:16:01 +0200 (IST)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
X-Sender: eliz AT is
To: djgpp AT delorie DOT com
Subject: Re: Handle software interrupts with DPMI
In-Reply-To: <3baea508$0$1521$272ea4a1@news.execpc.com>
Message-ID: <Pine.SUN.3.91.1010924121539.25254L-100000@is>
MIME-Version: 1.0
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

On Mon, 24 Sep 2001, Chris Giese wrote:

> Suppose I want to write a DOS (DPMI) program to run Linux apps.
> This program must handle the Linux syscalls (INT 80h).

You might wish to think again.  You will need to emulate those system
calls with the functionality available to DJGPP programs on DOS or
Windows.  However, some (many?) of the important calls have no
equivalent, and cannot be emulated.  For example, page-level
protection, signals, threading, and other important components of a
Linux executable--all these need system calls you have no hope
emulating.

IMHO, it's much easier to build a DJGPP version of the program you
want to run from the original sources (since most programs on
GNU/Linux systems have their sources freely available).  That way, you
could replace the code which issues unsupported system calls with
something that will work in the DJGPP enviroment, or even comment that
code out if no equivalent functionality exists.  And you will be
spared the need to set up the interrupt handlers, messing with
reentrancy, write syscall emulation code, etc.

> I can write a DJGPP program that issues and handles software
> interrupts, but how do I get the values of the registers
> when the INT instruction occured?

The way to do this with DJGPP programs is to install a handler for
protected-mode software Int 80h.  See the documentation of the library
function __dpmi_set_protected_mode_interrupt_vector, and the related
sections of the DPMI Spec.

The problem with this is that an interrupt handler might be limited in
what it can and cannot do, including in the (DOS/Windows) system calls
it can safely invoke, and the amount of stack it can depend upon.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019