delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/02/11/11:10:01

Date: Tue, 11 Feb 1997 10:04:49 -0600
Message-Id: <1.5.4.16.19970211100420.225f9ac4@bugs.skipstone.com>
Mime-Version: 1.0
To: djgpp AT delorie DOT com
From: Phil Christensen <pjc AT skipstone DOT com>
Subject: dpmi_error setting

Hi folks,
What I am trying to do is clean up after the program has been completed.
I allocate a selector, set the base and limit, and run successfully using
farptr accesses.
When complete, I want to free the selector. I am using cwsdpmi for a dpmi
server. I get a non-zero return code and invalid errors (according to the 
almighty dpmi 1.0 spec). Is this a difference between .9 and 1.0?

#include <stdlib.h>
#include <stdio.h>
#include <dos.h>
#include <dpmi.h>


int find_it(*MemS)
    short MemSelector,rc;
    __dpmi_meminfo card_info;

    card_info.address = 0x08000000;
    card_info.size = 0x100000;

    MemSelector = __dpmi_allocate_ldt_descriptors(1);
/* DPMI 0.9 AX=0000 */
    if ( MemSelector != -1 )
        {
            if ((rc = __dpmi_physical_address_mapping(&card_info)) != 0) {
                dprintf("unable to map physical address\n");
                __dpmi_free_physical_address_mapping(&card_info);
                return DPMI_ADDR_MAPPING_ERROR;
            }
  /* set base and limit also.... */
        }
    else {
        dprintf("unable to allocate selector\n");
        return DPMI_SELECTOR_ERROR;
    }

    return ;
}

/*----------------------------------------------------------------------------
 * Function:    void free_dpmi( short MemSelector)
 *
 * Action:      Free up dpmi resources
 *
 * Returns:     none
 *
 * Description: This routine frees up the LDT selector and the linear address
 *--------------------------------------------------------------------------*/
void free_dpmi(short MemSelector, __dpmi_meminfo *card_info) {
    int rc;

    rc = __dpmi_free_physical_address_mapping(card_info);
    if (rc != 0) printf("free physical mapping rc = %0x, error =
%0x\n",rc,__dpmi_error);
    rc = __dpmi_free_ldt_descriptor(MemSelector);
    if (rc != 0) printf("free ldt selector rc = %0x, error =
%0x\n",rc,__dpmi_error);
    return ;
}

When executed, the following is reported.

    free physical mapping rc = ffffffff, error = 801
    free ldt selector rc = ffffffff, error = 1

0x801 is the dpmi value for free_physical mapping
0x1 is 0x1...

Phil Christensen
pjc AT skipstone DOT com         (512)305-0218
Skipstone, Inc.
3925 West Braker Lane, Suite 425
Austin, TX 78759

- Raw text -


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