Annotation of gcl520h/_defs386.h, revision 1.1

1.1     ! root        1: /*
        !             2:  * _DEFS386.H       5.20A  June 8, 1995
        !             3:  *
        !             4:  * The Greenleaf Comm Library
        !             5:  *
        !             6:  * Copyright (C) 1985-1995 Greenleaf Software Inc.  All Rights Reserved.
        !             7:  *
        !             8:  * NOTES
        !             9:  *
        !            10:  *  This header file contains prototypes and miscellaneous definitions
        !            11:  *  for use with all 32 bit DOS Extenders.  The functions and macros
        !            12:  *  in this file are intended to provide a transparent and uniform
        !            13:  *  set of functions that can be used with any 386 DOS Extender.
        !            14:  *
        !            15:  * Things we need to define in order to support a 386 DOS Extender.
        !            16:  * These can be macros, typedefs, functions, or whatever.  It
        !            17:  * all depends on what DOS Extender and compiler you are using.
        !            18:  *
        !            19:  * Functions defined in all caps might be defined as Macros.
        !            20:  *
        !            21:  *  Defined by the compiler    Defined by the DOS Extender
        !            22:  *
        !            23:  *  GF_FARPTR32               _GetDosSelector
        !            24:  *  GF_SEL32                  _AllocateDosMemory
        !            25:  *  GF_OFF32                  _LockMemory
        !            26:  *  GF_POKEC32                _SetVector
        !            27:  *  GF_POKEVID32              _GetRealAddress
        !            28:  *  GF_PEEKC32                _GetOldProtHandler
        !            29:  *  GF_FARPTR16               _GetOldRealHandler
        !            30:  *  GF_SEL16                  _SetHandlers
        !            31:  *  GF_OFF16                  _LockRegion
        !            32:  *  _GetCs()
        !            33:  *  _GetDs()
        !            34:  *  _FarMemSet()
        !            35:  *  _CopyFromFarMem()
        !            36:  *  _CopyToFarMem()
        !            37:  *
        !            38:  *  Always defined: GF_X32
        !            39:  *
        !            40:  * CONTENTS
        !            41:  *
        !            42:  * MODIFICATIONS
        !            43:  *
        !            44:  *  December 1, 1994   5.10A :  Initial release.
        !            45:  */
        !            46: 
        !            47: #if !defined( _DOS32BIT_H )
        !            48: #define _DOS32BIT_H
        !            49: 
        !            50: #include "compiler.h"
        !            51: #include <dos.h>
        !            52: 
        !            53: 
        !            54: /*
        !            55:  * Identify the DOS Extender.
        !            56:  */
        !            57: 
        !            58: #if defined( DOSX386 )
        !            59: #  if defined( GF_WATCOM_C )
        !            60: #    undef _M_IX86
        !            61: #  endif
        !            62: #  define GF_X32
        !            63: #elif defined( DOS4G )
        !            64: #  define GF_DPMI32
        !            65: #  define GF_X32
        !            66: #elif defined( GF_BORLAND_CPP ) && defined( __DPMI32__ )
        !            67: #  define GF_DPMI32
        !            68: #  define GF_X32
        !            69: #elif defined( DOS4G )
        !            70: #  define GF_DPMI32
        !            71: #  define GF_X32
        !            72: #endif
        !            73: 
        !            74: #if defined( GF_X32 )
        !            75: 
        !            76: 
        !            77: /*
        !            78:  * Fortunately, the definitions for real pointers are the same for
        !            79:  * every compiler.
        !            80:  */
        !            81: 
        !            82: /*
        !            83:  * Under 32 bit DOS extenders, we will have to manipulate 16:16
        !            84:  * real pointers from time to time.  This structure definition and
        !            85:  * associated macros make that a little easier to do.
        !            86:  */
        !            87: 
        !            88: #pragma pack( 1 )
        !            89: typedef struct _tag_realptr {
        !            90:     unsigned short int offset;
        !            91:     unsigned short int segment;
        !            92: } GF_FARPTR16;
        !            93: #pragma pack()
        !            94: 
        !            95: #define GF_SEG16( x ) (x).segment  /* Tag: Misc private */
        !            96: #define GF_OFF16( x ) (x).offset   /* Tag: Misc private */
        !            97: 
        !            98: /*
        !            99:  * Watcom definitions
        !           100:  */
        !           101: #if defined( GF_WATCOM_C_386 )
        !           102: 
        !           103: #include <i86.h>
        !           104: 
        !           105: /*
        !           106:  * Watcom is the one compiler we use right now that actually supports
        !           107:  * far pointers.  This means that we can use efficient code in some
        !           108:  * places by simply dereferencing a far pointer instead of performing
        !           109:  * a far copy.  However, I still create a structure so that I have
        !           110:  * easy access to the selector and offset parts of the pointer.
        !           111:  */
        !           112: #pragma pack( 1 )
        !           113: typedef union { char _far * p;
        !           114:                     struct _tag_farptr {
        !           115:                         unsigned int offset;
        !           116:                         unsigned short selector;
        !           117:                     } s;
        !           118:                } GF_FARPTR32;
        !           119: #pragma pack()
        !           120: 
        !           121: #define GF_SEL32( x ) (x).s.selector         /* Tag: Extender private */
        !           122: #define GF_OFF32( x ) (x).s.offset           /* Tag: Extender private */
        !           123: #define GF_POKEC32( x, c ) (*((x).p) = (c))  /* Tag: Extender private */
        !           124: #define GF_POKEVID32( x, c, att ) *(short int _far *) ((x).p) = ( (c) + ( (att) << 8 ) )  /* Tag: Extender private */
        !           125: #define GF_PEEKC32( c, x ) (c = *((x).p))     /* Tag: Extender private */
        !           126: 
        !           127: #endif
        !           128: 
        !           129: /*
        !           130:  * Symantec definitions
        !           131:  */
        !           132: #if defined( GF_SYMANTEC_CPP )
        !           133: 
        !           134: /*
        !           135:  * Symantec actually supports far pointers.  This means that we can use
        !           136:  * efficient code in some places by simply dereferencing a far pointer
        !           137:  * instead of performing a far copy.  However, I still create a structure
        !           138:  * so that I have easy access to the selector and offset parts of the
        !           139:  *  pointer.
        !           140:  */
        !           141: 
        !           142: #pragma pack( 1 )
        !           143: typedef union { char _far * p;
        !           144:                     struct _tag_farptr {
        !           145:                         unsigned int offset;
        !           146:                         unsigned short selector;
        !           147:                     } s;
        !           148:                } GF_FARPTR32;
        !           149: #pragma pack()
        !           150: 
        !           151: #define GF_SEL32( x ) (x).s.selector         /* Tag: Extender private */
        !           152: #define GF_OFF32( x ) (x).s.offset           /* Tag: Extender private */
        !           153: #define GF_POKEC32( x, c ) (*((x).p) = (c))  /* Tag: Extender private */
        !           154: #define GF_POKEVID32( x, c, att ) *(short int _far *) ((x).p) = ( (c) + ( (att) << 8 ) )  /* Tag: Extender private */
        !           155: #define GF_PEEKC32( c, x ) (c = *((x).p))    /* Tag: Extender private */
        !           156: 
        !           157: #endif
        !           158: 
        !           159: /*
        !           160:  * Visual C++ definitions
        !           161:  */
        !           162: 
        !           163: #if defined( GF_VISUAL_CPP )
        !           164: 
        !           165: #pragma pack( 1 )
        !           166: typedef struct _tag_farptr {
        !           167:     unsigned int offset;
        !           168:     unsigned short selector;
        !           169: } GF_FARPTR32;
        !           170: #pragma pack()
        !           171: 
        !           172: #define GF_SEL32( x ) (x).selector                  /* Tag: Extender private */
        !           173: #define GF_OFF32( x ) (x).offset                    /* Tag: Extender private */
        !           174: #define GF_POKEC32( x, c ) _gf_pokec32( (x), (c) )  /* Tag: Extender private */
        !           175: #define GF_POKEVID32( x, c, att ) _gf_pokevid32( (x), (c), (att) )  /* Tag: Extender private */
        !           176: #define GF_PEEKC32( c, x ) c = _gf_peekc32( (x) )   /* Tag: Extender private */
        !           177: 
        !           178: void GF_CONV _gf_pokec32( GF_FARPTR32 x, unsigned char c );
        !           179: void GF_CONV _gf_pokevid32( GF_FARPTR32 x, unsigned char c, unsigned char att );
        !           180: unsigned char GF_CONV _gf_peekc32( GF_FARPTR32 x );
        !           181: 
        !           182: #endif /* #if defined( GF_VISUAL_CPP ) */
        !           183: 
        !           184: /*
        !           185:  * Borland definitions.
        !           186:  */
        !           187: 
        !           188: #if defined( GF_BORLAND_CPP )
        !           189: 
        !           190: #pragma pack( 1 )
        !           191: typedef struct _tag_farptr {
        !           192:     unsigned int offset;
        !           193:     unsigned short selector;
        !           194: } GF_FARPTR32;
        !           195: #pragma pack()
        !           196: 
        !           197: #define GF_SEL32( x ) (x).selector                  /* Tag: Extender private */
        !           198: #define GF_OFF32( x ) (x).offset                    /* Tag: Extender private */
        !           199: #define GF_POKEC32( x, c ) _gf_pokec32( (x), (c) )  /* Tag: Extender private */
        !           200: #define GF_POKEVID32( x, c, att ) _gf_pokevid32( (x), (c), (att) )  /* Tag: Extender private */
        !           201: #define GF_PEEKC32( c, x ) c = _gf_peekc32( (x) )   /* Tag: Extender private */
        !           202: 
        !           203: void GF_CONV _gf_pokec32( GF_FARPTR32 x, unsigned char c );
        !           204: void GF_CONV _gf_pokevid32( GF_FARPTR32 x, unsigned char c, unsigned char att );
        !           205: unsigned char GF_CONV _gf_peekc32( GF_FARPTR32 x );
        !           206: 
        !           207: #endif
        !           208: 
        !           209: /*
        !           210:  * The following functions are prototyped for every DOS Extender and
        !           211:  * compiler.  The prototypes are identical regardeless of the tool,
        !           212:  * so you won't see any ifdefs here.
        !           213:  */
        !           214: 
        !           215: #ifdef __cplusplus
        !           216: extern "C" {
        !           217: #endif
        !           218: 
        !           219: unsigned short int GF_CONV _GetDosSelector( void );
        !           220: GF_FARPTR32 GF_CONV _AllocateDosMemory( int size );
        !           221: int GF_CONV _FreeDosMemory( GF_FARPTR32 p );
        !           222: void GF_CONV _FarMemSet( GF_FARPTR32 add, unsigned char val, int length );
        !           223: void GF_CONV _CopyToFarMem( GF_FARPTR32 destination, void *source, int length );
        !           224: void GF_CONV _CopyFromFarMem( void *destination, GF_FARPTR32 source, int length );
        !           225: GF_FARPTR16 GF_CONV _GetRealAddress( GF_FARPTR32 protected_address );
        !           226: GF_FARPTR32 GF_CONV _GetOldProtHandler( int interrupt_number );
        !           227: GF_FARPTR16 GF_CONV _GetOldRealHandler( int interrupt_number );
        !           228: int GF_CONV _SetHandlers( int interrupt_number, GF_FARPTR32 port_handler, GF_FARPTR16 real_handler );
        !           229: int GF_CONV _LockRegion( GF_FARPTR32 base, int size );
        !           230: unsigned short int GF_CONV _GetCs( void );
        !           231: unsigned short int GF_CONV _GetDs( void );
        !           232: 
        !           233: #ifdef __cplusplus
        !           234: }
        !           235: #endif
        !           236: 
        !           237: /*
        !           238:  * If you don't have REGS or int386 defined, we can make do with the
        !           239:  * Phar Lap TNT versions.  However, there are some naming problems,
        !           240:  * so we have to create a new structure.  This means that this code
        !           241:  * can be broken by a new release of TNT.
        !           242:  */
        !           243: #if defined( DOSX386 )
        !           244: 
        !           245: 
        !           246: #if defined( GF_BORLAND_CPP ) || defined( GF_VISUAL_CPP ) || defined( GF_SYMANTEC_CPP )
        !           247: 
        !           248: #include <pldos32.h>
        !           249: 
        !           250: #pragma pack( 1 )
        !           251: #undef REGS
        !           252: union REGS {
        !           253:     struct _DWORDREGS x;
        !           254:     struct _WORDREGS w;
        !           255:     struct _BYTEREGS h;
        !           256: };
        !           257: #pragma pack()
        !           258: 
        !           259: #define SREGS _SREGS
        !           260: #define int386( i, r1, r2 )    /* Tag: Extender private */ \
        !           261:                                _int86( (i),                \
        !           262:                                (union _REGS *)( r1 ),      \
        !           263:                                (union _REGS *)( r2 ) )
        !           264: 
        !           265: #define int386x( i, r1, r2, s )   /* Tag: Extender private */ \
        !           266:                                   _int86x( (i),               \
        !           267:                                   (union _REGS *)( r1 ),      \
        !           268:                                   (union _REGS *)( r2 ),      \
        !           269:                                          (s) )
        !           270: #endif /* #if defined( GF_BORLAND_CPP ) || defined( GF_VISUAL_CPP ) */
        !           271: #endif /* #if defined( DOSX386 ) */
        !           272: 
        !           273: #endif /* #if defined( GF_X32 )       */
        !           274: 
        !           275: #endif /* #if !defined( _DOS32BIT_H ) */

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.