www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1995/08/17/02:20:50

Xref: news-dnh.mv.net comp.os.msdos.djgpp:1595
Newsgroups: comp.os.msdos.djgpp
Path: news-dnh.mv.net!mv!news.sprintlink.net!in2.uu.net!pipeline!psinntp!psinntp!psinntp!netrixgw.netrix.com!news
From: ld AT jasmine DOT netrix DOT com (Long Doan)
Subject: Re: DPMI stuff
Lines: 48
Sender: news AT netrix DOT com
Organization: Netrix Corporation
References: <DDC44A DOT 8sx AT jade DOT mv DOT net>
Date: Tue, 15 Aug 1995 13:21:59 GMT
To: djgpp AT sun DOT soe DOT clarkson DOT edu
Dj-Gateway: from newsgroup comp.os.msdos.djgpp

In article <DDC44A DOT 8sx AT jade DOT mv DOT net> Cuthalion / Sliced Bread <enrico AT max DOT tiac DOT net> writes:

> 	Hi.  I'm trying to write an IRQ handler under DJGPP. (I'm using 
> int86(0x31,....), because of skimpy docs on many of the DPMI 
> functions..)  But some of the dpmi functions (lock linear region, for 
> instance) take linear addresses.  I don't know what a linear addres is!  
> What I'm doing to get these addresses is adding &myvar to the selector 
> base for _my_cs(), but that ends me up with something absurd for my 
> selector base (for _my_cs()) ranging from 0x1000000 to 0xda62bc02 or 
> something huge like that depending on which DPMI server I use.  (The 
> weird number is with Windows.  I get 0x80003000 under QDPMI.)  It seems 
> to me that these values are quite obviously not right (I don't have 2 GIG 
> of ram, even WITH Swapping!) and sure enough, the second lock linear 
> memory I try to do fails.  (Oddly enough, the first one works..)  
> (Fails:  Has regs.x.cflag set on exit.  (Is this a valid way to check 
> success?)

  1. The value that _my_cs () returns is a 16 bits SELECTOR, not a 32
     bits base address. To get the correct value of the selector, mask
     off the higher 16 bits (e.g. _my_cs () & 0x0ffff).
  2. To be able to use a selector, you must have access to the
     GDT or LDT (more likely), depends on the DPMI provider. To get
     the value of the GDTR (or LDTR) (48 bits), use the sgdt instruction.
     The 32 bits base address to the G/LDT and the 16 bits limit are
     included in the value of the G/LDTR register. If paging is enabled
     (extremely likely), you'll have to go through the page directory
     and page table(s) to find the coresponding physical address for
     the G/LDT.
     *Note: The instructions to access the page directory/tables are
     priviledged instructions.
  3. Once you have the 16 bits selector and 32 bits GDT/LDT physical base
     address, use the selector as an index to an 8-byte-entry table
     based at the G/LDT base address to get the descriptor for the
     corresponding selector.
  4. Once you have the descriptor, putting together the high (8 bits),
     middle (8 bits) and low (16 bits) bases will give you the linear
     base address for that selector. Add that to the offset and you'll
     have the linear address.

Hope that helps,
Long.
-- 
==============================================================
Long Doan                                        ld AT netrix DOT com     
Netrix Corporation                         ldoan1 AT osf1 DOT gmu DOT edu
13595 Dulles Technology Drive                               
Herndon Va 22071
==============================================================

- Raw text -


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