/ * Xms.inc * /
INT xms_init () / * Detects the expansion memory service program * / {UNION Regs R; RxAx = 0x4300; INT86 (0x2f, & r, & r); if (rhal! = 0x80) Return (Error); / * No Himem. SYS * / if ((xms_2_basemem_buffer = malloc (XMS_BUF)) == NULL) return (ERROR); return (OK);} int end_xms () {free (xms_2_basemem_buffer);} int xms_free (int xms_handle) / * released by the handle Extension memory * / {UNION Regs r; RHAH = 0x0a; rxdx = xms_handle; xms_interface (& r, & r); if (RXAX == 0) Return (Error); Return (OK);} int XMS_MOVEDATA Struct XMS_MOVE * M) / * Transfer data between the expansion between the extension * / {UNION Regs R; / * Need to transfer the XMS_Move structure over * / RHAH = 0x0b; RxSI = (unsigned) m; XMS_INTERFACE & r, & r); if (RXAX == 0) Return (Error); RETURN (OK);} INT XMS_Malloc (Uint MEMKB) / * Allocated with Kb Measured Involved Memory, if not Error, return the handle * / {Union Regs R; RHAH = 9; RXDX = MEMKB; / * MUST KB * / XMS_INTERFACE (& R, & R); if (RxAx == 0) Return (Error); Return (RXDX); / * Return MEM fp * /} void xms_interface (union regs * outregs) {UNION regs in, out; / * Provides an interface function for expanded memory services * / Struct Sregs S Regs; Void Far (* xms) (Void); In.x = 0x4310; INT86X (0x2F, & IN, & OUT, & SREGS); XMS = (Void Far *) ((longs.es) << 16) out.x.bx); _ax = INREGS-> X.AX; _CX = INREGS-> x.cx; _dx = INREGS-> x.dx; _si = INREGS-> x.si; _di = INREGS- > x.di; _bx = INREGS-> x.bx; xms (); outregs-> x.ax = _ax; outregs-> x.bx = _bx; outregs-> x.cx = _cx; outregs-> x. DX = _dx; outregs-> x.si = _si; outregs-> x.di = _di;