DevHelp AllocPhys: Difference between revisions
Appearance
Created page with "This service is used by physical device drivers to allocate a block of fixed memory. ==Syntax== ===C=== <PRE> USHORT APIENTRY DevHelp_AllocPhys (ULONG lSize, ..." |
No edit summary |
||
(One intermediate revision by the same user not shown) | |||
Line 1: | Line 1: | ||
{{DISPLAYTITLE:DevHelp_AllocPhys}} | |||
This service is used by physical device drivers to allocate a block of fixed memory. | This service is used by physical device drivers to allocate a block of fixed memory. | ||
==Syntax== | ==Syntax== | ||
Line 29: | Line 30: | ||
===Assembler=== | ===Assembler=== | ||
<PRE> | <PRE> | ||
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] | |||
</PRE> | </PRE> | ||
==Paramet | |||
==Return Code== | ==Return Code== |
Latest revision as of 02:28, 4 May 2025
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)