Jump to content

DevHelp AllocPhys

From EDM2
Revision as of 22:04, 23 August 2017 by Martini (talk | contribs)

This service is used by physical device drivers to allocate a block of fixed memory.

Syntax

C

USHORT APIENTRY DevHelp_AllocPhys (ULONG  lSize,
                                   USHORT MemType,
                                   PULONG PhysAddr)

Assembler

MOV   BX,size_low             ; Size in bytes
MOV   AX,size_high            ;
MOV   DH,high_or_low          ; Relative position to 1MB
                              ; 0 = above 1MB
                              ; 1 = below 1MB
MOV   DL,DevHlp_AllocPhys

CALL  [Device_Help]

Parameters

C

lSize (ULONG)
input - memory size in bytes
MemType (USHORT)
input
MEMTYPE_ABOVE_1MB 0
MEMTYPE_BELOW_1MB 1
PhysAddr (PULONG)
pointer to 32 bit address of the physical memory to be returned

Assembler

MOV   BX,size_low             ; Size in bytes
MOV   AX,size_high            ;
MOV   DH,high_or_low          ; Relative position to 1MB
                              ; 0 = above 1MB
                              ; 1 = below 1MB
MOV   DL,DevHlp_AllocPhys

CALL  [Device_Help]

==Paramet

Return Code

C

  • Success Indicator: 0 if memory was allocated - the 32 bit pointer to the allocated memory is returned.

Possible errors:

ERROR_INVALID_PARAMETER (87)
(Memory not allocated)

Assembler

   'C' Clear if the memory was allocated.
       AX:BX = 32-bit physical address.

   'C' Set if the memory was not allocated.
       AX = Error code.
            Possible errors:
               ERROR_INVALID_PARAMETER (87)
               (Memory not allocated)

Remarks

The memory allocated by this function is fixed memory and cannot be unfixed through the call to the DevHlp Unlock. If the memory requested is to be allocated high (above 1MB) but no memory above 1MB is available, an error is returned. The physical device driver could then attempt to allocate low memory.

Conversely, if the memory requested is to be allocated low (below 1MB) but no memory below 1MB is available, an error is returned. The physical device driver could try allocating high memory, if appropriate.

Example Code

C

#include  "dhcalls.h"

USHORT APIENTRY DevHelp_AllocPhys (ULONG  lSize,
                                   USHORT MemType,
                                   PULONG PhysAddr)

Related Functions