Àïïàðàòíîå îáåñïå÷åíèå ïåðñîíàëüíîãî êîìïüþòåðà

       

Ïðîãðàììà CALLHMA


Ïðèâåäåì òåêñò ïðîãðàììû, ñîñòàâëåííàÿ íà ÿçûêå ïðîãðàììèðîâàíèÿ Ñè, êîòîðàÿ âûçûâàåò ôóíêöèè äðàéâåðà ðàñøèðåííîé ïàìÿòè. Ýòà ïðîãðàììà áóäåò ðàáîòàòü òîëüêî â ìîäåëÿõ ïàìÿòè Small è Compact. Äëÿ äðóãèõ ìîäåëåé ïàìÿòè òðåáóåòñÿ èçìåíèòü ñòðîêè èíòåðôåéñíîãî ìîäóëÿ hma.asm, â êîòîðûõ ïåðåäàâàåìûå ôóíêöèÿì ïàðàìåòðû èçâëåêàþòñÿ èç ñòåêà è òèï ïðîöåäóð:

Àðãóìåíòû

Small, Compact

Large, Huge

Ïåðâûé àðãóìåíò

[bp+4]



 [bp+6]

Âòîðîé àðãóìåíò

[bp+6]

 [bp+8]

Òåêñò ïðîãðàììû CALLHMA âû íàéäåòå â ëèñòèíãå 11.2, à òåêñò èíòåðôåéñíîãî ìîäóëÿ - â ëèñòèíãå 11.3.

Ëèñòèíã 11.2. Ôàéë callhma\callhma.c

// =====================================================

// Ðàáîòà ñ äðàéâåðîì HIMEM.SYS

//

// (C) Ôðîëîâ À.Â, 1997

//

// E-mail: frolov@glas.apc.org

// WWW:    http://www.glasnet.ru/~frolov

//            èëè

//         http://www.dials.ccas.ru/frolov

// =====================================================

#include <stdio.h>

#include <stdlib.h>

#include <conio.h>

#include <dos.h>

#include <string.h>

struct   XMM_Move

{

  unsigned long  Length;

  unsigned short SourceHandle;

  unsigned long  SourceOffset;

  unsigned short DestHandle;

  unsigned long  DestOffset;

};

extern long XMM_Installed(void);

extern long XMM_Version(void);

extern long XMM_RequestHMA(unsigned);

extern long XMM_ReleaseHMA(void);

extern long XMM_GlobalEnableA20(void);

extern long XMM_GlobalDisableA20(void);

extern long XMM_EnableA20(void);

extern long XMM_DisableA20(void);

extern long XMM_QueryA20(void);

extern long XMM_QueryLargestFree(void);

extern long XMM_QueryTotalFree(void);

extern long XMM_AllocateExtended(unsigned);

extern long XMM_FreeExtended(unsigned);

extern long XMM_MoveExtended(struct XMM_Move *);

extern long XMM_LockExtended(unsigned);

extern long XMM_UnLockExtended(unsigned);

extern long XMM_GetHandleLength(unsigned);

extern long XMM_GetHandleInfo(unsigned);

extern long XMM_ReallocateExtended(unsigned, unsigned);


extern long XMM_RequestUMB(unsigned);

extern long XMM_ReleaseUMB(unsigned);

void error(char *msg, long rc);

int main(void)

{

  long ver, rc, handle;

  static char testmsg[] = "Òåñòîâîå ñîîáùåíèå";

  char buf[80];

  char far *ptr;

  int i;

  struct XMM_Move move_d;

  // Ïðîâåðÿåì, óñòàíîâëåí ëè äðàéâåð HIMEM.SYS,

  // åñëè óñòàíîâëåí, âûâîäèì åãî âåðñèþ

  if (XMM_Installed())

  {

    printf("\nHIMEM.SYS installed");

    ver = XMM_Version();

    printf("\nver XMM: %4X,%4x",

      (short)ver, (short)(ver >> 16));

  }

  else

  {

    printf("\nHIMEM.SYS not found");

    exit(-1);

  }

  // Çàïðàøèâàåì óïðàâëåíèå îáëàñòüþ HMA

  rc = XMM_RequestHMA(0xffff);

  if(rc)

    error("Request HMA error",rc);

  else

  {

    // Îòêðûâàåì ëèíèþ A20

    rc = XMM_GlobalEnableA20();

    if(rc)

      error("Open A20 error",rc);

    // Êîïèðóåì òåñòîâîå ñîîáùåíèå ñíà÷àëà èç

    // ñòàíäàðòíîé ïàìÿòè â îáëàñòü HMA,

    // çàòåì îáðàòíî â ñòàíäàðòíóþ ïàìÿòü

    FP_SEG(ptr) = 0xffff;

    FP_OFF(ptr) = 0x0010;

    for(i=0; testmsg[i] != 0; i++)

      ptr[i] = testmsg[i];

    for(i=0; ptr[i] != 0; i++)

      buf[i] = ptr[i];

   

    buf[i] = 0;

    // Âûâîäèì ñîîáùåíèå äëÿ ïðîâåðêè

    printf("\n%s",buf);

    // Çàêðûâàåì ëèíèþ A20 è îòäàåì ñèñòåìå îáëàñòü HMA

    rc = XMM_GlobalDisableA20();

    if(rc)

      error("Close A20 eror",rc);

    rc = XMM_ReleaseHMA();

    if(rc)

      error("Free HMA error",rc);

  }

  // Ïîëó÷àåì áëîê EMB ðàçìåðîì â 1 Êáàéò

  handle = XMM_AllocateExtended(1);

  if(handle < 0)

    error("Request XMB error",handle);

  // Êîïèðóåì òåñòîâîå ñîîáùåíèå ñíà÷àëà èç

  // ñòàíäàðòíîé ïàìÿòè â áëîê EMB,

  // çàòåì îáðàòíî â ñòàíäàðòíóþ ïàìÿòü

  move_d.Length = strlen(testmsg) + 1;

  move_d.SourceHandle = 0;



  (char far*)move_d.SourceOffset = (char far*)testmsg;

  move_d.DestHandle = (short)handle;

  move_d.DestOffset = 0L;

  rc = XMM_MoveExtended(&move_d);

  if(rc < 0)

    error("Copy in EMB error",rc);

  move_d.Length = strlen(testmsg) + 1;

  move_d.DestHandle = 0;

  (char far*)move_d.DestOffset = (char far*)buf;

  move_d.SourceHandle = (short)handle;

  move_d.SourceOffset = 0L;

  rc = XMM_MoveExtended(&move_d);

  if(rc < 0)

    error("Copy from EMB error",rc);

  // Âûâîäèì ñîîáùåíèå äëÿ ïðîâåðêè

  printf("\n%s",buf);

  // Îñâîáîæäàåì áëîê EMB

  rc = XMM_FreeExtended((unsigned)handle);

  if(rc)

    error("Free XMB error",rc);

  return 0;

}

// Ôóíêöèÿ äëÿ âûâîäà ñîîáùåíèÿ îá îøèáêå

// è êîäà îøèáêè

void error(char *msg, long rc)

{

  rc = (unsigned char)(rc >> 24) ;

    printf("\n%s, error: %02.2X\n",

      msg, (unsigned char)rc);

  exit(-1);

}

Ëèñòèíã 11.3. Ôàéë callhma\hma.asm

; =====================================================

; Ýòî èíòåðôåéñíûé ìîäóëü äëÿ âûçîâà ôóíêöèé

; XMS èç Ñè. Òåêñò ïðîãðàììû ðàññ÷èòàí íà

; ìîäåëü ïàìÿòè Small

;

; (C) A. Frolov, 1997

;

; E-mail: frolov@glas.apc.org

; WWW:    http://www.glasnet.ru/~frolov

;            or

;         http://www.dials.ccas.ru/frolov

; =====================================================

  .model small

  .DATA

; Â ýòîì ìåñòå áóäåò õðàíèòüñÿ àäðåñ

; óïðàâëÿþùåé ôóíêöèè XMM

XMM_Control  dd   ?

          .CODE

; Ìàêðîîïðåäåëåíèÿ äëÿ âûïîëíåíèÿ ñîãëàøåíèÿ îá

; èñïîëüçîâàíèè ðåãèñòðîâ â ïðîöåäóðàõ Ñè

c_begin macro

  push bp

  mov  bp,sp

  push si

  push di

  endm

c_end   macro

  pop  di

  pop  si

  mov  sp,bp

  pop  bp

  ret

  endm

; Âñå ïðîöåäóðû äîëæíû áûòü public

  public _XMM_Installed

  public _XMM_Version

  public _XMM_RequestHMA

  public _XMM_ReleaseHMA



  public _XMM_GlobalEnableA20

  public _XMM_GlobalDisableA20

  public _XMM_EnableA20

  public _XMM_DisableA20

  public _XMM_QueryA20

  public _XMM_QueryLargestFree

  public _XMM_QueryTotalFree

  public _XMM_AllocateExtended

  public _XMM_FreeExtended

  public _XMM_MoveExtended

  public _XMM_LockExtended

  public _XMM_UnLockExtended

  public _XMM_GetHandleLength

  public _XMM_GetHandleInfo

  public _XMM_ReallocateExtended

  public _XMM_RequestUMB

  public _XMM_ReleaseUMB

;**

;.Name         _XMM_Installed

;.Title        Ïîëó÷åíèå àäðåñà óïðàâëÿþùåé ôóíêöèè

;

;.Descr        Ýòà ôóíêöèÿ ïðîâåðÿåò íàëè÷èå äðàéâåðà

;              HIMEM.SYS è â ñëó÷àå åãî ïðèñóñòâèÿ

;              çàïîìèíàåò àäðåñ óïðàâëÿþùåé ôóíêöèè.

;

;.Proto        unsigned XMM_Installed(void);

;

;.Params       Íå èñïîëüçóþòñÿ

;

;.Return       0 - äðàéâåð HIMEM.SYS íå óñòàíîâëåí;

;              1 - äðàéâåð HIMEM.SYS óñòàíîâëåí.

;

;**

_XMM_Installed proc near

          c_begin

          mov  ax, 4300h

          int  2fh

          cmp  al, 80h

          jne  NotInstalled

          mov  ax, 4310h

          int  2fh

          mov  word ptr [XMM_Control], bx

          mov  word ptr [XMM_Control+2], es

          mov  ax,1

          jmp  Installed

NotInstalled:

          mov  ax, 0

Installed:

          c_end

_XMM_Installed endp

;**

;.Name         _XMM_Version

;.Title        Îïðåäåëåíèå âåðñèè äðàéâåðà HIMEM.SYS

;

;.Descr        Ýòà ôóíêöèÿ îïðåäåëÿåò âåðñèþ äðàéâåðà

;              HIMEM.SYS

;

;.Proto        long  XMM_Version(void);

;

;.Params       Íå èñïîëüçóþòñÿ

;

;.Return       Íîìåð âåðñèè â ìëàäøèõ 16 áèòàõ,

;              íîìåð èçìåíåíèé - â ñòàðøèõ 16 áèòàõ

;              âîçâðàùàåìîãî çíà÷åíèÿ

;

;**

_XMM_Version proc near

          push si

          push di

          xor  ah, ah

          call [XMM_Control]

          mov  dx, bx

          pop  di

          pop  si

          ret



_XMM_Version endp

;**

;.Name         _XMM_RequestHMA

;.Title        Çàïðîñèòü îáëàñòü HMA

;

;.Descr        Ýòà ôóíêöèÿ ïûòàåòñÿ çàðåçåðâèðîâàòü äëÿ

;              ïðîãðàììû îáëàñòü HMA

;

;.Proto        long  XMM_RequestHMA(unsigned space);

;

;.Params       space - ðàçìåð òðåáóåìîé îáëàñòè äëÿ

;                      TSR-ïðîãðàììû èëè äðàéâåðà,

;                      0xffff äëÿ ïðèêëàäíîé ïðîãðàììû;

;

;.Return       < 0 - îáëàñòü HMA íå íàçíà÷åíà ïðîãðàììå,

;                    êîä îøèáêè íàõîäèòñÿ â ñòàðøåì áàéòå.

;              0L  - îáëàñòü HMA íàçíà÷åíà ïðîãðàììå.

;

;**

_XMM_RequestHMA proc near

          c_begin

          mov  ah, 1

          mov  dx, [bp+4]

          call [XMM_Control]

          xor  dx, dx

          dec  ax

          jz   @success

          mov  dh, bl

@success:

          c_end

_XMM_RequestHMA endp

;**

;.Name         _XMM_ReleaseHMA

;.Title        Îñâîáîäèòü îáëàñòü HMA

;

;.Descr        Ýòà ôóíêöèÿ ïûòàåòñÿ îñâîáîäèòü

;              îáëàñòü HMA

;

;.Proto        long  XMM_ReleaseHMA(void);

;

;.Params       Íå èñïîëüçóþòñÿ

;

;.Return       < 0 - îáëàñòü HMA íå îñâîáîæäåíà,

;                    êîä îøèáêè íàõîäèòñÿ â ñòàðøåì áàéòå.

;              0L - îáëàñòü HMA îñâîáîæäåíà.

;

;**

_XMM_ReleaseHMA proc near

          c_begin

          mov  ah, 2

          call [XMM_Control]

          xor  dx, dx

          dec  ax

          jz   @success1

          mov  dh, bl

@success1:

          c_end

_XMM_ReleaseHMA endp

;**

;.Name         _XMM_GlobalEnableA20

;.Title        Ãëîáàëüíîå ðàçðåøåíèå ëèíèè A20

;

;.Descr        Ýòà ôóíêöèÿ ðàçðåøàåò ïðîãðàììå, ïîëó÷èâøåé

;              äîñòóï ê îáëàñòè HMA èñïîëüçîâàòü ëèíèþ A20

;

;.Proto        long  XMM_GlobalEnableA20(void);

;

;.Params       Íå èñïîëüçóþòñÿ

;

;.Return       < 0 - ëèíèÿ A20 íå âêëþ÷åíà,

;                    êîä îøèáêè íàõîäèòñÿ â ñòàðøåì áàéòå.

;              0L  - ëèíèÿ A20 âêëþ÷åíà.



;

;**

_XMM_GlobalEnableA20 proc near

          c_begin

          mov  ah, 3

          call [XMM_Control]

          xor  dx, dx

          dec  ax

          jz   @success2

          mov  dh, bl

@success2:

          c_end

_XMM_GlobalEnableA20 endp

;**

;.Name         _XMM_GlobalDisableA20

;.Title        Ãëîáàëüíîå çàïðåùåíèå ëèíèè A20

;

;.Descr        Ýòà ôóíêöèÿ çàïðåùàåò ïðîãðàììå, ïîëó÷èâøåé

;              äîñòóï ê îáëàñòè HMA èñïîëüçîâàòü ëèíèþ A20

;

;.Proto        long  XMM_GlobalDisableA20(void);

;

;.Params       Íå èñïîëüçóþòñÿ

;

;.Return       < 0 - ëèíèÿ A20 íå âûêëþ÷åíà,

;                    êîä îøèáêè íàõîäèòñÿ â ñòàðøåì áàéòå.

;              0L  - ëèíèÿ A20 âûêëþ÷åíà.

;

;**

_XMM_GlobalDisableA20 proc near

          c_begin

          mov  ah, 4

          call [XMM_Control]

          xor  dx, dx

          dec  ax

          jz   @success3

          mov  dh, bl

@success3:

          c_end

_XMM_GlobalDisableA20 endp

;**

;.Name         _XMM_EnableA20

;.Title        Ëîêàëüíîå ðàçðåøåíèå ëèíèè A20

;

;.Descr        Ýòà ôóíêöèÿ ðàçðåøàåò ïðîãðàììå óïðàâëÿòü

;              îáëàñòüþ ðàñøèðåííîé ïàìÿòè.

;

;.Proto        long  XMM_EnableA20(void);

;

;.Params       Íå èñïîëüçóþòñÿ

;

;.Return       < 0 - ëèíèÿ A20 íå âêëþ÷åíà,

;                    êîä îøèáêè íàõîäèòñÿ â ñòàðøåì áàéòå.

;              0L  - ëèíèÿ A20 âêëþ÷åíà.

;

;**

_XMM_EnableA20 proc near

          c_begin

          mov  ah, 5

          call [XMM_Control]

          xor  dx, dx

          dec  ax

          jz   @success4

          mov  dh, bl

@success4:

          c_end

_XMM_EnableA20 endp

;**

;.Name         _XMM_DisableA20

;.Title        Ëîêàëüíîå çàïðåùåíèå ëèíèè A20

;

;.Descr        Ýòà ôóíêöèÿ çàïðåùàåò ïðîãðàììå óïðàâëÿòü

;              îáëàñòüþ ðàñøèðåííîé ïàìÿòè.

;

;.Proto        long  XMM_DisableA20(void);

;

;.Params       Íå èñïîëüçóþòñÿ

;

;.Return       < 0 - ëèíèÿ A20 íå âûêëþ÷åíà,



;                    êîä îøèáêè íàõîäèòñÿ â ñòàðøåì áàéòå.

;              0L  - ëèíèÿ A20 âûêëþ÷åíà.

;

;**

_XMM_DisableA20 proc near

          c_begin

          mov  ah, 6

          call [XMM_Control]

          xor  dx, dx

          dec  ax

          jz   @success5

          mov  dh, bl

@success5:

          c_end

_XMM_DisableA20 endp

;**

;.Name         _XMM_QueryA20

;.Title        Ïðîâåðèòü ñîñòîÿíèå ëèíèè A20

;

;.Descr        Ýòà ôóíêöèÿ ïðîâåðÿåò äîñòóïíîñòü

;              ëèíèè A20

;

;.Proto        long  XMM_QueryA20(void);

;

;.Params       Íå èñïîëüçóþòñÿ

;

;.Return       < 0 - îøèáêà,

;                    êîä îøèáêè íàõîäèòñÿ â ñòàðøåì áàéòå.

;              0L  - ëèíèÿ A20 âûêëþ÷åíà,

;              1L  - ëèíèÿ A20 âêëþ÷åíà.

;

;**

_XMM_QueryA20 proc near

          c_begin

          mov  ah, 7

          call [XMM_Control]

          xor  dx, dx

          or   ax, ax

          jnz  @success6

          mov  dh, bl

@success6:

          c_end

_XMM_QueryA20 endp

;**

;.Name         _XMM_QueryLargestFree

;.Title        Îïðåäåëèòü ìàêñèìàëüíûé ðàçìåð áëîêà

;

;.Descr        Ýòà ôóíêöèÿ âîçâðàùàåò ðàçìåð ìàêñèìàëüíîãî

;              íåïðåðûâíîãî áëîêà ðàñøèðåííîé ïàìÿòè,

;              êîòîðûé äîñòóïåí ïðîãðàììå.

;

;.Proto        long  XMM_QueryLargestFree(void);

;

;.Params       Íå èñïîëüçóþòñÿ

;

;.Return       < 0 - îøèáêà,

;                    êîä îøèáêè íàõîäèòñÿ â ñòàðøåì áàéòå.

;              >= 0 - ðàçìåð áëîêà.

;

;**

_XMM_QueryLargestFree proc near

          c_begin

          mov  ah, 8

          call [XMM_Control]

          xor  dx, dx

          or   ax, ax

          jnz  @success7

          mov  dh, bl

@success7:

          c_end

_XMM_QueryLargestFree endp

;**

;.Name         _XMM_QueryTotalFree

;.Title        Îïðåäåëèòü ðàçìåð ðàñøèðåííîé ïàìÿòè

;

;.Descr        Ýòà ôóíêöèÿ âîçâðàùàåò ðàçìåð

;              âñåé èìåþùåéñÿ ðàñøèðåííîé ïàìÿòè.



;

;.Proto        long  XMM_QueryTotalFree(void);

;

;.Params       Íå èñïîëüçóþòñÿ

;

;.Return       < 0 - îøèáêà,

;                    êîä îøèáêè íàõîäèòñÿ â ñòàðøåì áàéòå.

;              >= 0 - ðàçìåð ðàñøèðåííîé ïàìÿòè.

;

;**

_XMM_QueryTotalFree proc near

          c_begin

          mov  ah, 8

          call [XMM_Control]

          or   ax, ax

          mov  ax, dx

          mov  dx, 0

          jnz  @success8

          mov  dh, bl

@success8:

          c_end

_XMM_QueryTotalFree endp

;**

;.Name         _XMM_AllocateExtended

;.Title        Çàïðîñèòü áëîê ðàñøèðåííîé ïàìÿòè

;

;.Descr        Ýòà ôóíêöèÿ âûäåëÿåò ïðîãðàììå áëîê

;              ðàñøèðåííîé ïàìÿòè, â ñëó÷àå óñïåõà

;              âîçâðàùàåò èíäåêñ ïîëó÷åííîãî áëîêà.

;

;.Proto        long XMM_AllocateExtended(unsigned space);

;

;.Params       space - ðàçìåð òðåáóåìîãî áëîêà ïàìÿòè

;                      â êèëîáàéòàõ;

;

;.Return       < 0 - áëîê íå ðàñïðåäåëåí,

;                    êîä îøèáêè íàõîäèòñÿ â ñòàðøåì áàéòå.

;              > 0L  - ìëàäøèé áàéò ñîäåðæèò èíäåêñ

;                      ïîëó÷åííîãî áëîêà ïàìÿòè.

;

;**

_XMM_AllocateExtended proc near

          c_begin

          mov  ah, 9

          mov  dx,  [bp+4]

          call [XMM_Control]

          or   ax, ax

          mov  ax, dx

          mov  dx, 0

          jnz  @success9

          mov  dh, bl

@success9:

          c_end

_XMM_AllocateExtended endp

;**

;.Name         _XMM_FreeExtended

;.Title        Îñâîáîäèòü áëîê ðàñøèðåííîé ïàìÿòè

;

;.Descr        Ýòà ôóíêöèÿ îñâîáîæäàåò áëîê

;              ðàñøèðåííîé ïàìÿòè, ïîëó÷åííûé ôóíêöèåé

;              XMM_AllocateExtended().

;

;.Proto        long XMM_FreeExtended(unsigned handle);

;

;.Params       handle - èíäåêñ îñâîáîæäàåìîãî áëîêà ïàìÿòè;

;

;.Return       < 0 - áëîê íå ðàñïðåäåëåí,

;                    êîä îøèáêè íàõîäèòñÿ â ñòàðøåì áàéòå.

;              0L  - áëîê îñâîáîæäåí.

;

;**



_XMM_FreeExtended proc near

          c_begin

          mov  ah, 0Ah

          mov  dx, [bp+4]

          call [XMM_Control]

          xor  dx, dx

          dec  ax

          jz   @successA

          mov  dh, bl

@successA:

          c_end

_XMM_FreeExtended endp

;**

;.Name         _XMM_MoveExtended

;.Title        Êîïèðîâàòü áëîê ðàñøèðåííîé ïàìÿòè

;

;.Descr        Ýòà ôóíêöèÿ êîïèðóåò áëîê

;              ðàñøèðåííîé ïàìÿòè, èñïîëüçóÿ ñòðóêòóðó

;              struct XMM_Move:

;

;                 struct   XMM_Move {

;                    unsigned long  Length;

;                    unsigned short SourceHandle;

;                    unsigned long  SourceOffset;

;                    unsigned short DestHandle;

;                    unsigned long  DestOffset;

;                 };

;

;.Proto        long  XMM_MoveExtended(struct

;                       XMM_Move *move_descr);

;

;.Params       struct XMM_Move *move_descr -

;                 óêàçàòåëü íà ñòðóêòóðó, îïèñûâàþùóþ

;                 ÷òî, îòêóäà è êóäà íàäî êîïèðîâàòü.

;

;.Return       < 0 - îøèáêà ïðè êîïèðîâàíèè,

;                    êîä îøèáêè íàõîäèòñÿ â ñòàðøåì áàéòå.

;              0L  - áëîê ñêîïèðîâàí óñïåøíî.

;

;**

_XMM_MoveExtended proc near

          c_begin

          mov  ah, 0Bh

          mov  si, [bp+4];

          call [XMM_Control]

          xor  dx, dx

          dec  ax

          jz   @successB

          mov  dh, bl

@successB:

          c_end

_XMM_MoveExtended endp

;**

;.Name         _XMM_LockExtended

;.Title        Çàáëîêèðîâàòü áëîê ðàñøèðåííîé ïàìÿòè

;

;.Descr        Ýòà ôóíêöèÿ áëîêèðóåò áëîê ðàñøèðåííîé

;              ïàìÿòè è âîçâðàùàåò 31 ðàçðÿä åãî

;              ôèçè÷åñêîãî àäðåñà.

;

;.Proto        long XMM_LockExtended(unsigned handle);

;

;.Params       handle - èíäåêñ áëîêèðóåìîãî áëîêà ïàìÿòè;

;

;.Return       < 0 - áëîê íå çàáëîêèðîâàí,

;                    êîä îøèáêè íàõîäèòñÿ â ñòàðøåì áàéòå.



;              > 0L  - áëîê çàáëîêèðîâàí, ôóíêöèÿ

;                      âîçâðàùàåò ôèçè÷åñêèé àäðåñ áëîêà

;                      ïàìÿòè.

;

;**

_XMM_LockExtended proc near

          c_begin

          mov  ah, 0Ch

          mov  dx, [bp+4]

          call [XMM_Control]

          xchg ax, bx

          dec  bx

          jz   XMML_Success

          mov  dh, al

XMML_Success:

                c_end

_XMM_LockExtended endp

;**

;.Name         _XMM_UnLockExtended

;.Title        Ðàçáëîêèðîâàòü áëîê ðàñøèðåííîé ïàìÿòè

;

;.Descr        Ýòà ôóíêöèÿ ðàçáëîêèðóåò áëîê ðàñøèðåííîé

;              ïàìÿòè.

;

;.Proto        long XMM_UnLockExtended(unsigned handle);

;

;.Params       handle - èíäåêñ áëîêà ïàìÿòè;

;

;.Return       < 0 - áëîê íå ðàçáëîêèðîâàí,

;                    êîä îøèáêè íàõîäèòñÿ â ñòàðøåì áàéòå.

;              0L  - áëîê ðàçáëîêèðîâàí.

;

;**

_XMM_UnLockExtended proc near

          c_begin

          mov  ah, 0Dh

          mov  dx, [bp+4]

          call [XMM_Control]

          xor  dx, dx

          dec  ax

          jz   @successC

          mov  dh, bl

@successC:

          c_end

_XMM_UnLockExtended endp

;**

;.Name         _XMM_GetHandleLength

;.Title        Ïîëó÷èòü äëèíó áëîêà ðàñøèðåííîé ïàìÿòè

;

;.Descr        Ýòà ôóíêöèÿ âîçâðàùàåò äëèíó áëîêà

;              ðàñøèðåííîé ïàìÿòè ïî åãî èíäåêñó.

;

;.Proto        long XMM_GetHandleLength(unsigned handle);

;

;.Params       handle - èíäåêñ áëîêà ïàìÿòè;

;

;.Return       < 0 - ïðîèçîøëà îøèáêà,

;                    êîä îøèáêè íàõîäèòñÿ â ñòàðøåì áàéòå.

;              > 0L  - äëèíà áëîêà â êèëîáàéòàõ.

;

;**

_XMM_GetHandleLength proc near

          c_begin

          mov  ah, 0Eh

          mov  dx, [bp+4]

          call [XMM_Control]

          or   ax, ax

          mov  ax, dx

          mov  dx, 0

          jnz  @successD

          mov  dh, bl

@successD:

          c_end

_XMM_GetHandleLength endp



;**

;.Name         _XMM_GetHandleInfo

;.Title        Ïîëó÷èòü èíôîðìàöèþ î áëîêå ðàñøèðåííîé ïàìÿòè

;

;.Descr        Ýòà ôóíêöèÿ âîçâðàùàåò îáùåå

;              êîëè÷åñòâî èíäåêñîâ â ñèñòåìå è

;              ñîäåðæèìîå ñ÷åò÷èêà áëîêèðîâàíèÿ äëÿ

;              çàäàííîãî èíäåêñà.

;

;.Proto        long XMM_GetHandleInfo(unsigned handle);

;

;.Params       handle - èíäåêñ áëîêà ïàìÿòè;

;

;.Return       < 0 - ïðîèçîøëà îøèáêà,

;                    êîä îøèáêè íàõîäèòñÿ â ñòàðøåì áàéòå.

;              > 0L  - ìëàäøèé áàéò - îáùåå êîëè÷åñòâî

;                      èíäåêñîâ â ñèñòåìå;

;                      ñòàðøèé áàéò - ñ÷åò÷èê áëîêèðîâàíèÿ.

;

;**

_XMM_GetHandleInfo proc near

          c_begin

          mov  ah, 0Eh

          mov  dx, [bp+4]

          call [XMM_Control]

          mov  dx, bx

          or   ax, ax

          mov  ax, dx

          mov  dx, 0

          jnz  @successE

          mov  dh, bl

@successE:

          c_end

_XMM_GetHandleInfo endp

;**

;.Name         _XMM_ReallocateExtended

;.Title        Èçìåíèòü ðàçìåð áëîêà ðàñøèðåííîé ïàìÿòè

;

;.Descr        Ýòà ôóíêöèÿ èçìåíÿåò ðàçìåð âûäåëåííîãî

;              áëîêà ðàñøèðåííîé ïàìÿòè.

;

;.Proto        long XMM_ReallocateExtended(unsigned handle,

;                 unsigned new_size);

;

;.Params       handle - èíäåêñ áëîêà ïàìÿòè;

;              new_size - íîâûé ðàçìåð áëîêà ïàìÿòè

;                      â êèëîáàéòàõ;

;

;.Return       < 0 - áëîê íå ðàñïðåäåëåí,

;                    êîä îøèáêè íàõîäèòñÿ â ñòàðøåì áàéòå.

;              > 0L  - ìëàäøèé áàéò ñîäåðæèò èíäåêñ

;                      ïîëó÷åííîãî áëîêà ïàìÿòè.

;

;**

_XMM_ReallocateExtended proc near

          c_begin

          mov  ah, 0Fh

          mov  dx, [bp+4]

          mov  bx, [bp+6]

          call [XMM_Control]

          xor  dx, dx

          dec  ax

          jz   @successF

          mov  dh, bl

@successF:

          c_end

_XMM_ReallocateExtended endp



;**

;.Name         _XMM_RequestUMB

;.Title        Çàïðîñèòü îáëàñòü UMB

;

;.Descr        Ýòà ôóíêöèÿ ïûòàåòñÿ çàðåçåðâèðîâàòü äëÿ

;              ïðîãðàììû îáëàñòü UMB

;

;.Proto        long  XMM_RequestUMB(unsigned space);

;

;.Params       space - ðàçìåð òðåáóåìîé îáëàñòè

;                      â ïàðàãðàôàõ;

;

;.Return       < 0 - îáëàñòü UMB íå íàçíà÷åíà ïðîãðàììå,

;                    êîä îøèáêè íàõîäèòñÿ â ñòàðøåì áàéòå;

;                    ìàêñèìàëüíûé ðàçìåð äîñòóïíîãî áëîêà

;                    â ìëàäøåì ñëîâå (16 ðàçðÿäîâ);

;              > 0L  - îáëàñòü UMB íàçíà÷åíà ïðîãðàììå,

;                    ìëàäøåå ñëîâî ñîäåðæèò ñåãìåíò áëîêà

;                    UMB, ñòàðøèé - ðàçìåð âûäåëåííîãî

;                    áëîêà UMB.

;

;**

_XMM_RequestUMB proc near

          c_begin

          mov  ah, 10h

          mov  dx, [bp+4]

          call [XMM_Control]

          xchg bx, ax

          dec  bx

          jz   RUMB_Success

          xchg ax, dx

          mov  dh, dl

RUMB_Success:

          c_end

_XMM_RequestUMB endp

;**

;.Name         _XMM_ReleaseUMB

;.Title        Îñâîáîäèòü îáëàñòü UMB

;

;.Descr        Ýòà ôóíêöèÿ ïûòàåòñÿ îñâîáîäèòü

;              îáëàñòü UMB

;

;.Proto        long  XMM_ReleaseUMB(unsigned segment);

;

;.Params       segment - ñåãìåíò îñâîáîæäàåìîãî áëîêà UMB*

;

;.Return       < 0 - îáëàñòü UMB íå îñâîáîæäåíà,

;                    êîä îøèáêè íàõîäèòñÿ â ñòàðøåì áàéòå.

;              0L - îáëàñòü UMB îñâîáîæäåíà.

;

;**

_XMM_ReleaseUMB proc near

          c_begin

          mov  ah, 11h

          mov  dx, [bp+4]

          call [XMM_Control]

          xor  dx, dx

          dec  ax

          jz   @success10

          mov  dh, bl

@success10:

          c_end

_XMM_ReleaseUMB endp

  END


Ñîäåðæàíèå ðàçäåëà