1 /* $Id: u_dpmi.h,v 1.2 2003-11-26 12:26:28 btb Exp $ */
3 THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
4 SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO
5 END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A
6 ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS
7 IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
8 SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
9 FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
10 CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS
11 AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.
12 COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
17 * Prototypes for DPMI services.
20 * Revision 1.9 1995/01/14 19:20:14 john
21 * Added function to set a selector's base address.
23 * Revision 1.8 1994/11/28 20:22:03 john
24 * Added some variables that return the amount of available
27 * Revision 1.7 1994/11/15 18:26:38 john
30 * Revision 1.6 1994/11/07 11:35:05 john
31 * Added prototype for real_free
33 * Revision 1.5 1994/10/27 19:54:48 john
34 * Added unlock region function,.
36 * Revision 1.4 1994/09/27 18:27:56 john
37 * Added pragma to make inp,outp,enable,disable intrinsic
39 * Revision 1.3 1994/09/27 11:54:45 john
40 * Added DPMI init function.
42 * Revision 1.2 1994/08/24 18:53:51 john
43 * Made Cyberman read like normal mouse; added dpmi module; moved
44 * mouse from assembly to c. Made mouse buttons return time_down.
46 * Revision 1.1 1994/08/24 10:22:48 john
57 typedef struct dpmi_real_regs {
61 uint reserved_by_system;
67 ushort es,ds,fs,gs,ip,cs,sp,ss;
71 #pragma intrinsic( inp );
72 #pragma intrinsic( outp );
73 #pragma intrinsic( _enable );
74 #pragma intrinsic( _disable );
77 /* inp & outp are functions in DJGPP, while inportb & outportb are inlined */
78 #define inp(port) inportb(port)
79 #define outp(port,value) outportb(port,value)
80 #if 0 /* only causes problems */
83 #define _enable() __asm__ __volatile__ ("sti")
84 #define _disable() __asm__ __volatile__ ("cli")
89 #include "sys/nearptr.h"
90 #define DPMI_real_segment(P) ((((uint)(P)-(uint)(__djgpp_conventional_base)) >> 4) & 0xffff)
91 #define DPMI_real_offset(P) (((uint)(P)-(uint)(__djgpp_conventional_base)) & 0xf)
93 #define DPMI_real_segment(P) ((((uint) (P)) >> 4) & 0xFFFF)
94 #define DPMI_real_offset(P) (((uint) (P)) & 0xF)
97 // Initializes dpmi. Returns zero if failed.
98 extern int dpmi_init(int verbose);
99 // Returns a pointer to a temporary dos memory block. Size must be < 1024 bytes.
100 extern void *dpmi_get_temp_low_buffer( int size );
101 extern void *dpmi_real_malloc( int size, ushort *selector );
102 extern void dpmi_real_free( ushort selector );
103 extern void dpmi_real_int386x( ubyte intno, dpmi_real_regs * rregs );
104 extern void dpmi_real_call(dpmi_real_regs * rregs);
105 extern int dpmi_lock_region(void *address, unsigned length);
106 extern int dpmi_unlock_region(void *address, unsigned length);
107 // returns 0 if failed...
108 extern int dpmi_allocate_selector( void * address, int size, ushort * selector );
109 extern int dpmi_modify_selector_base( ushort selector, void * address );
110 extern int dpmi_modify_selector_limit( ushort selector, int size );
113 #if defined(__GNUC__) || defined(_MSC_VER)
118 // Sets the PM handler. Returns 0 if succssful
119 extern int dpmi_set_pm_handler(unsigned intnum, void _far * isr );
121 extern unsigned int dpmi_virtual_memory;
122 extern unsigned int dpmi_available_memory;
123 extern unsigned int dpmi_physical_memory;
124 extern unsigned int dpmi_dos_memory;