[Front] [Prev Chapter]
[Next Chapter]
Generally, all functions preserve all registers unless they are used to
return values. If AX is not used to return a value, then it is not set to zero or modified at all if the function is successful. If any 16-bit register can be modified, then the whole 32-bit register can also be modified even if it is not used to return a value. For example, the high word of EAX may be modified even if only AX is used for the return value.
Selectors passed by clients as parameters should correspond to writable data segments.
· The inter-mode call functions always take CX and never ECX as the number of words to be copied from stack to stack, because real or virtual-8086 mode stacks are limited to 32768 words.
Unloading DPMS Clients
TSRs are usually unloaded by running a second copy of the program with an appropriate command line switch. This second copy can also release DPMS resources. The server identifies clients from their API code and therefore, the second copy of the program must use the same API code as the original. This is easily done by copying the API code from the original program to the second copy, as if the second copy had registered as a client itself. 32-bit Return Values
32-bit values that are returned in two 16-bit registers are also returned in 32-bit registers where possible. If the server reports that the CPU is a 386 or later, then any register which returns the low word of a 32-bit value also returns the high word. For example, if a 32-bit value is returned in BX and CX (high word in BX, low word in CX), then the high word is returned in the high word of ECX as well as BX, that is, the ECX contains the entire 32-bit value, so a client with 386-specific code can choose to use BX and CX, or ECX. Summary of DPMS Functions
This section summarizes the DPMS calls by function. The include file DPMS.INC lists the following function names and numbers:
|
General function
|
|
|
|---|---|---|
|
DPMS_DEREGISTER
|
0000h
|
Deregister from the DPMS server as a DPMS client.
|
|
Miscellaneous function
| ||
|---|---|---|
|
DPMS_M_RELOC
|
0400h
|
Relocates a segment to extended memory.
|
The following sections describe each DPMS function call.
DPMS_PRESENCE (043E0h)
Function
This function checks for the presence of a DPMS server. It is called by issuing an INT 02Fh request. Entry Parameters
|
Register
|
Value
|
|---|---|
|
AX
|
DPMS_PRESENCE
|
|
BX
|
0000h
|
|
CX
|
04450h (`DP')
|
|
DX
|
04D53h (`MS')
|
|
Register
|
Value
|
|---|---|
|
If the function is successful
| |
|
CF
|
Clear
|
|
AX
|
0000h
|
|
ES:DI
|
Pointer to the DPMS server structure
|
|
If the function is unsuccessful
| |
|
AX
|
Non-zero
|
If either CF is set, or AX is non-zero, then a DPMS server is not present.
Explanation
This function may modify (E)AX, (E)CX, (E)DX, (E)BP, (E)SI, (E)DI, ES, FS, and GS. If a DPMS server is present, then the function returns ES:DI pointing to the DPMS server structure, which is defined in DPMS.INC as follows:
DPMS_Server_Flags
Normally programs have to reset the 80286 to switch from protected to real mode, which is relatively slow. Some PCs have hardware to speed up this process. The fast reset bit is set to inform you if such hardware is used by the DPMS server.
|
DPMS_SERVER_CPU_286
|
0002h
|
80286 processor
|
|
DPMS_SERVER_CPU_386
|
0003h
|
80386 or later processors
|
DPMS functions are passed a function number in the register AX. These numbers are defined in the include file DPMS.INC as equates to the function name that heads each function description in this chapter. For instance, to call DPMS_M_FREESIZE (see page 2-53) from real mode, use:
|
mov
|
ax, DPMS_M_FREESIZE
|
|
call
|
real_entry
|
You can call most DPMS functions from either real or protected mode, except DPMS_M_RELOC (see page 2-66), which you must call from real mode, and the real and protected mode call-up and call-down functions, which can be called only when in the appropriate mode.
DPMS_REGISTER (043E1h)
Register As A DPMS Client Function
This function registers a new DPMS client, and is called by issuing an INT 02Fh. Entry Parameters
|
Register
|
Value
|
|---|---|
|
AX
|
DPMS_REGISTER
|
|
CX
|
Default protected mode stack size. This is zero if no default protected mode stack is required.
|
|
ES:DI
|
Pointer to the DPMS client interface structure.
|
|
Register
|
Value
|
|---|---|
|
If the function is successful
| |
|
CF
|
Clear
|
|
AX
|
0000h
|
|
ES:DI
|
Unmodified, DPMS client interface structure filled in
|
|
If the function is unsuccessful
| |
|
CF
|
Set
|
|
AX
|
Error code (see "Error Codes" on page A-1), including DPMS_E_NOT_SUPP (DPMS is disabled) DPMS_E_RESOURCE_NA (Resource unavailable) DPMS_E_DESC_NA (Descriptor unavailable) DPMS_E_LIN_NA (Linear memory unavailable) DPMS_E_PHYS_NA (Physical memory unavailable)
|
Explanation
The DPMS client interface structure is defined as follows:
The version and flags (DPMS_IF_Version) and client name (DPMS_IF_Name) fields must be filled in by the client before making the call. The version and flags field is for upward compatibility; for the current version it must be zero. The name field is available to statistical and diagnostic programs to assist in identifying resource ownership, and must be padded with spaces.
When DPMS is disabled, this function is disabled so that clients cannot register.
DPMS_ENABLE_DISABLE (043E2h)
Enable or Disable DPMS
Function
This function enables or disables DPMS. It is called via INT 02Fh. Entry Parameters
|
Register
|
Value
|
|---|---|
|
AX
|
DPMS_ENABLE_DISABLE
|
|
BX
|
0 to disable DPMS, 1 to enable it
|
|
Register
|
Value
|
|---|---|
|
If the function is successful
| |
|
CF
|
Clear
|
|
AX
|
0
|
Explanation
This function is optional and should normally only be used by system software. When DPMS is disabled, the register function is disabled so that clients cannot register, although all other functions work normally. DPMS_STARTUP (043E3h)
DPMS Server Startup Broadcast
Function
On startup but before installation, a potential DPMS server issues an INT 02Fh, as follows: Entry Parameters
|
Register
|
Value
|
|---|---|
|
AX
|
DPMS_STARTUP
|
|
BX
|
0
|
|
CX
|
04450h (`DP')
|
|
DX
|
04D53h (`MS')
|
|
ES:DI
|
Pointer to the DPMS server structure
|
|
Register
|
Value
|
|---|---|
|
If it is alright for the server to load
| |
|
BX
|
Unmodified
|
|
If it is not alright for the server to load
| |
|
BX
|
Bit 0 set
|
Explanation
A potential server issues the startup broadcast when running as a normal DOS program, so resident programs intercepting the broadcast can make normal DOS and BIOS calls without considering re-entrancy. Refer to the explanation of the function DPMS_PRESENCE on page 2-6 for a description of the DPMS server structure.
The startup broadcast has three main uses.
DPMS_EXIT (043E4h)
DPMS Server Exit Broadcast
Function
Before unloading, a DPMS server issues an INT 02Fh, as follows: Entry Parameters
|
Register
|
Value
|
|---|---|
|
AX
|
DPMS_EXIT
|
|
BX
|
0
|
|
CX
|
04450h (`DP')
|
|
DX
|
04D53h (`MS')
|
|
ES:DI
|
Pointer to the DPMS server structure
|
|
Register
|
Value
|
|---|---|
|
If it is alright for the server to unload
| |
|
BX
|
Unmodified
|
|
If it is not alright for the server to unload
| |
|
BX
|
Bit 0 set
|
Explanation
Servers never unload while any client is registered. Refer to the explanation of the function DPMS_PRESENCE on page 2-6 for a description of the DPMS server structure.
DPMS_DEREGISTER (0000h)
Deregister As A DPMS Client
Function
This function complements the register function DPMS_REGISTER (see page 2-9), and must be called by any client that no longer needs any DPMS resources. The function enables the server to free any resources that were allocated to that client when it registered. It is called via the real mode API code.
|
Register
|
Value
|
|---|---|
|
AX
|
DPMS_DEREGISTER
|
|
Register
|
Value
|
|---|---|
|
If the function is successful
| |
|
CF
|
Clear
|
|
AX
|
Unmodified
|
|
If the function is unsuccessful
| |
|
CF
|
Set
|
|
AX
|
Error code (see "Error Codes" on page A-1), including DPMS_E_UNKNOWN_CLIENT (Unknown client)
|
Explanation
This call does not free any descriptors, memory, and so forth, allocated by the client via the DPMS API. These must be freed explicitly using the appropriate DPMS calls before making the deregister call. Once deregistered, the API code copied to the client interface structure by the server when the client registered must not be used. No further DPMS calls must be made by the client after deregistering unless the client registers with the server again and gets new API code. DPMS_CALL_PROT (0100h)
Protected Mode Call-up
Function
This function calls a protected mode procedure. It is called via real mode API code. Entry Parameters
|
Register
|
Value
|
|---|---|
|
AX
|
DPMS_CALL_PROT
|
|
CX
|
Number of words to copy from real mode to protected mode stack
|
|
ES:DI
|
Pointer to the register structure (see Figure 2-1)
|
|
Register
|
Value
|
|---|---|
|
If the function is successful
| |
|
CF
|
Clear
|
|
AX
|
Unmodified
|
|
If the function is unsuccessful
| |
|
CF
|
Set
|
|
AX
|
Error code (see "Error Codes" on page A-1), including, DPMS_E_PROTECTED (Cannot switch to protected mode) DPMS_E_RESOURCE_NA (Resource unavailable)
|
The register structure values are updated.
Explanation
The register structure is a parameter block in real mode memory. Its structure is shown in Figure 2-1.
The address of the protected mode procedure to be called, and the values to be loaded into the registers on entry to that procedure, are passed to the DPMS server in a register structure. On return from the protected mode procedure, the (E)AX, (E)BX, (E)CX, (E)DX, (E)BP, (E)SI, (E)DI, DS, ES, FS, GS, and (E)FLAGS registers are copied back into the register structure. A far call is made to the procedure, and therefore it must execute a far return. Any words copied to the protected mode stack from the real mode stack appear on the stack above the far return address. The calling procedure must remove any parameters passed on the stack, and therefore, the protected mode procedure should not clean up the stack on exit because the DPMS server does this. However, any parameters placed on the real mode stack before calling the DPMS_CALL_PROT function (see page 2-18) are still there on return from the server and the client must clean them up.
Make sure all selector values are valid. DPMS has functions you can call while in real mode to create valid selectors. Segment registers that are unused must be set to zero.
Register Structure
|
Offset
|
Register
|
|---|---|
|
000h
|
EDI
|
|
004h
|
ESI
|
|
008h
|
EBP
|
|
00Ch
|
Reserved, may be used by DPMS server.
|
|
010h
|
EBX
|
|
014h
|
EDX
|
|
018h
|
ECX
|
|
01Ch
|
EAX
|
|
020h
|
EIP
|
|
024h
|
CS
|
|
028h
|
EFLAGS
|
|
02Ch
|
ESP
|
|
030h
|
SS
|
|
034h
|
ES
|
|
038h
|
DS
|
|
03Ch
|
FS
|
|
040h
|
GS
|
DPMS.INC also provides definitions for the 8-bit and 16-bit register within it symbolically. These definitions include, for example, DPMS_AL, DPMS_AH, and DPMS_AX.
DPMS_CALL_REAL_RETF (0101h)
Real Mode Call-down
Function
This function calls a real mode procedure with a RETF stack frame. It is called via protected mode API code. Entry Parameters
|
Register
|
Value
|
|---|---|
|
AX
|
DPMS_CALL_REAL_RETF
|
|
CX
|
Number of words to copy from protected mode to real mode stack
|
|
ES:(E)DI
|
Pointer to a register structure
|
|
Register
|
Value
|
|---|---|
|
If the function is successful
| |
|
CF
|
Clear
|
|
AX
|
Unmodified
|
|
If the function is unsuccessful
| |
|
CF
|
Set
|
|
AX
|
Error code (see "Error Codes" on page A-1), including DPMS_E_RESOURCE_NA (Resource unavailable)
|
The values in the register structure are updated.
· All segment values in the register structure are real mode paragraphs, not protected mode selectors.
DPMS_CALL_REAL_IRET (0102h)
Real Mode Call-down
Function
This function calls a real mode procedure with an IRET stack frame. It is called via protected mode API code. Entry Parameters
|
Register
|
Value
|
|---|---|
|
AX
|
DPMS_CALL_REAL_IRET
|
|
CX
|
Number of words to copy from protected mode to real mode stack
|
|
ES:(E)DI
|
Pointer to a register structure
|
|
Register
|
Value
|
|---|---|
|
If the function is successful
| |
|
CF
|
Clear
|
|
AX
|
Unmodified
|
|
If the function is unsuccessful
| |
|
CF
|
Set
|
|
AX
|
Error code (see "Error Codes" on page A-1), including DPMS_E_RESOURCE_NA (Resource unavailable)
|
The values in the register structure are updated.
Explanation
Refer to the explanation of DPMS_CALL_REAL_RETF on page 2-24 for a more detailed description.
DPMS_CALL_REAL_INT (0103h)
Real Mode Call-down
Function
This function calls a real mode interrupt routine with an IRET stack frame. It is called via protected mode API code. Entry Parameters
|
Register
|
Value
|
|---|---|
|
AX
|
DPMS_CALL_REAL_INT
|
|
CX
|
Number of words to copy from protected mode to real mode stack
|
|
BL
|
Interrupt number
|
|
ES:(E)DI
|
Pointer to a register structure
|
|
Register
|
Value
|
|---|---|
|
If the function is successful
| |
|
CF
|
Clear
|
|
AX
|
Unmodified
|
|
If the function is unsuccessful
| |
|
CF
|
Set
|
|
AX
|
Error code (see "Error Codes" on page A-1), including DPMS_E_RESOURCE_NA (Resource unavailable)
|
The values in the register structure are updated.
Explanation
DPMS_CALL_REAL_INT operates similarly to DPMS_CALL_REAL_IRET (see page 2-26), except that it ignores the CS:IP values in the register structure, and instead uses the real mode interrupt vector whose number is passed in BL.
Because of the overheads involved in building and executing a real mode INT instruction, the DPMS server may emulate the instruction by pushing the FLAGS and calling the interrupt service routine, rather than executing an actual INT.
DPMS_REG_DEF_PROT (0104h)
Register Default Protected Mode Procedure
Function
This function registers a default protected mode procedure. It is called via the real or protected mode API code. Entry Parameters
|
Register
|
Value
|
|---|---|
|
AX
|
DPMS_REG_DEF_PROT
|
|
ES:(E)DI
|
Pointer to the DPMS default register structure
|
|
Register
|
Value
|
|---|---|
|
If the function is successful
| |
|
CF
|
Clear
|
|
AX
|
Unmodified
|
|
If the function is unsuccessful
| |
|
CF
|
Set
|
|
AX
|
Error code (see "Error Codes" on page A-1), including DPMS_E_BAD_SEL (Invalid selector)
|
Explanation
Most calls from real or virtual-8086 to protected mode, and from protected to real or virtual-8086 mode, are to addresses determined at initialization time. Many calls require parameters to be passed in registers that have to be stored in a DPMS register structure, if calling via the call-up or call-down functions DPMS_CALL_PROT (see page 2-18), DPMS_CALL_REAL_IRET (see page 2-26), DPMS_CALL_REAL_RETF (see page 2-24), and DPMS_CALL_REAL_INT (see page 2-27). The following is an alternative way of making inter-mode calls, in addition to the functions mentioned previously.
Using the alternative method, the client registers a default procedure to be called, together with default values for certain registers, including the segment registers. This is done by passing the address of a default register structure to the server. The server fills in part of the structure with the code necessary to make the inter-mode call. This code also contains a client ID. The client can register almost any number of default procedures in this way; each procedure is called via the code in the corresponding default register structure.
Unlike the client interface structure, the API code in the default register structure is not followed by a defined return instruction field. This is because the API code can be followed by any code that the client wishes to execute after the call, and if the return instruction field was defined, then that would make the structure less useful. In general, the API code must be followed by return code defined by the client.
If speed is important, the client should not load DPMS_SEG_ALIAS if the segment is always going to be the same.
DPMS_REG_DEF_REAL_RETF_16 (0105h)
Register Default Real or Virtual-8086 Mode Procedure
Function
This function registers a default real or virtual-8086 mode procedure when the procedure is to be called from 16-bit protected mode with a RETF stack frame. It is called via real or protected mode API code.Entry Parameters
|
Register
|
Value
|
|---|---|
|
AX
|
DPMS_REG_DEF_REAL_RETF_16
|
|
ES:(E)DI
|
Pointer to the DPMS default register structure
|
|
Register
|
Value
|
|---|---|
|
If the function is successful
| |
|
CF
|
Clear
|
|
AX
|
Unmodified
|
|
If the function is unsuccessful
| |
|
CF
|
Set
|
|
AX
|
Error code (see "Error Codes" on page A-1)
|
Explanation
Refer to the description of the function DPMS_REG_DEF_PROT on page 2-29 for more information about default call-up and call-down procedures.
DPMS_REG_DEF_REAL_IRET_16 (0106h)
Register Default Real or Virtual-8086 Mode Procedure
Function
This function registers a default real or virtual-8086 mode procedure when the procedure is to be called from 16-bit protected mode with an IRET stack frame. It is called via real or protected mode API code.Entry Parameters
|
Register
|
Value
|
|---|---|
|
AX
|
DPMS_REG_DEF_REAL_IRET_16
|
|
ES:(E)DI
|
Pointer to the DPMS default register structure
|
|
Register
|
Value
|
|---|---|
|
If the function is successful
| |
|
CF
|
Clear
|
|
AX
|
Unmodified
|
|
If the function is unsuccessful
| |
|
CF
|
Set
|
|
AX
|
Error code (see "Error Codes" on page A-1)
|
Explanation
Refer to the description of the function DPMS_REG_DEF_PROT on page 2-29 for more information about default call-up and call-down procedures.
DPMS_REG_DEF_REAL_INT_16 (0107h)
Register Default Real or Virtual-8086 Mode Procedure
Function
This function registers a default real or virtual mode 8086 procedure when the interrupt handler is to be called from 16-bit protected mode. It is called via real or protected mode API code.Entry Parameters
|
Register
|
Value
|
|---|---|
|
AX
|
DPMS_REG_DEF_REAL_INT_16
|
|
BL
|
Interrupt number
|
|
ES:(E)DI
|
Pointer to the DPMS default register structure
|
|
Register
|
Value
|
|---|---|
|
If the function is successful
| |
|
CF
|
Clear
|
|
AX
|
Unmodified
|
|
If the function is unsuccessful
| |
|
CF
|
Set
|
|
AX
|
Error code (see "Error Codes" on page A-1)
|
Explanation
Refer to the description of the function DPMS_REG_DEF_PROT on page 2-29 for more information about default call-up and call-down procedures.
DPMS_REG_DEF_REAL_RETF_32 (0108h)
Register Default Real or Virtual-8086 Mode Procedure
Function
This function registers a default real or virtual-8086 mode procedure when the procedure is to be called from 32-bit protected mode with a RETF stack frame. It is called via real or protected mode API code.Entry Parameters
|
Register
|
Value
|
|---|---|
|
AX
|
DPMS_REG_DEF_REAL_RETF_32
|
|
ES:(E)DI
|
Pointer to the DPMS default register structure
|
|
Register
|
Value
|
|---|---|
|
If the function is successful
| |
|
CF
|
Clear
|
|
AX
|
Unmodified
|
|
If the function is unsuccessful
| |
|
CF
|
Set
|
|
AX
|
Error code (see "Error Codes" on page A-1)
|
Explanation
Refer to the description of the function DPMS_REG_DEF_PROT on page 2-29 for more information about default call-up and call-down procedures.
DPMS_REG_DEF_REAL_IRET_32 (0109h)
Register Default Real or Virtual-8086 Mode Procedure
Function
This function registers a default real or virtual-8086 mode procedure when the procedure is to be called from 32-bit protected mode with an IRET stack frame. It is called via real or protected mode API code.Entry Parameters
|
Register
|
Value
|
|---|---|
|
AX
|
DPMS_REG_DEF_REAL_IRET_32
|
|
ES:(E)DI
|
Pointer to the DPMS default register structure
|
|
Register
|
Value
|
|---|---|
|
If the function is successful
| |
|
CF
|
Clear
|
|
AX
|
Unmodified
|
|
If the function is unsuccessful
| |
|
CF
|
Set
|
|
AX
|
Error code (see "Error Codes" on page A-1)
|
Explanation
Refer to the description of the function DPMS_REG_DEF_PROT on page 2-29 for more information about default call-up and call-down procedures.
DPMS_REG_DEF_REAL_INT_32 (010Ah)
Register Default Real or Virtual-8086 Mode Procedure
Function
This function registers a default real or virtual-8086 mode procedure when the interrupt handler is to be called from 32-bit protected mode. It is called via real or protected mode API code.Entry Parameters
|
Register
|
Value
|
|---|---|
|
AX
|
DPMS_REG_DEF_REAL_INT_32
|
|
BL
|
Interrupt number
|
|
ES:(E)DI
|
Pointer to the DPMS default register structure
|
|
Register
|
Value
|
|---|---|
|
If the function is successful
| |
|
CF
|
Clear
|
|
AX
|
Unmodified
|
|
If the function is unsuccessful
| |
|
CF
|
Set
|
|
AX
|
Error code (see "Error Codes" on page A-1)
|
Explanation
Refer to the description of the function DPMS_REG_DEF_PROT on page 2-29 for more information about default call-up and call-down procedures.
DPMS_D_ALLOC (0200h)
Allocate Descriptor
Function
This function allocates one or more contiguous protected mode descriptors. It is called via protected or real mode API code.Entry Parameters
|
Register
|
Value
|
|---|---|
|
AX
|
DPMS_D_ALLOC
|
|
CX
|
Number of descriptors required
|
|
Register
|
Value
|
|---|---|
|
If the function is successful
| |
|
CF
|
Clear
|
|
AX
|
Selector for the (first) new descriptor
|
|
If the function is unsuccessful
| |
|
CF
|
Set
|
|
AX
|
Error code (see "Error Codes" on page A-1,) including DPMS_E_DESC_NA (Descriptor unavailable)
|
Explanation
This call allocates new descriptors and initializes each to be a data segment descriptor with a limit of 64 KB. DPMS sets the privilege level; the client cannot modify it. The descriptors can be in either the GDT or the LDT.
Remember to call DPMS_D_FREE (see page 2-41) to free all descriptors that are no longer required, because descriptors are a limited resource.
DPMS_D_FREE (0201h)
Free Descriptor
Function
This function frees the descriptors allocated by DPMS_D_ALLOC (see page 2-39), DPMS_D_ALIAS (see page 2-43), and DPMS_M_RELOC (see page 2-66). It is called via protected or real mode API code.
|
Register
|
Value
|
|---|---|
|
AX
|
DPMS_D_FREE
|
|
BX
|
Selector to free
|
|
Register
|
Value
|
|---|---|
|
If the function is successful
| |
|
CF
|
Clear
|
|
AX
|
Unmodified
|
|
If the function is successful
| |
|
CF
|
Set
|
|
AX
|
Error code (see "Error Codes" on page A-1) including DPMS_E_BAD_SEL (Invalid selector)
|
Explanation
After this call, do not use the selector, because an exception is raised if it is loaded into a segment register.
Each call to DPMS_D_FREE frees only one descriptor. If you allocated several contiguous descriptors with DPMS_D_ALLOC (see page 2-39), you must call DPMS_D_FREE for each of them.
DPMS_D_ALIAS (0202h)
Allocate Alias Descriptor
Function
This function allocates a descriptor that is an alias to an existing descriptor to a segment. It is called via protected or real mode API code.Entry Parameters
|
Register
|
Value
|
|---|---|
|
AX
|
DPMS_D_ALIAS
|
|
BX
|
Selector for the existing descriptor
|
|
Register
|
Value
|
|---|---|
|
If the function is successful
| |
|
CF
|
Clear
|
|
AX
|
Selector for the alias descriptor
|
|
If the function is unsuccessful
| |
|
CF
|
Set
|
|
AX
|
Error code (see "Error Codes" on page A-1) including DPMS_E_DESC_NA (Descriptor unavailable) DPMS_E_BAD_SEL (Invalid selector)
|
Explanation
The new descriptor describes a data segment that otherwise matches the limit and base of the existing descriptor. You can use this feature to get write access to a code segment. Instead of writing via the code segment's selector, which is illegal in protected mode, simply write via the alias descriptor instead. DPMS_D_ALIAS_REAL (0203h)
Build Alias to Real Mode Segment
Function
This function builds a descriptor that is an alias to a real or
virtual-8086 mode segment. It is called via real or protected mode API code.Entry Parameters
|
Register
|
Value
|
|---|---|
|
AX
|
DPMS_D_ALIAS_REAL
|
|
BX
|
Selector for the descriptor
|
|
CX
|
Real mode segment (paragraph) value
|
|
Register
|
Value
|
|---|---|
|
If the function is successful
| |
|
CF
|
Clear
|
|
AX
|
Unmodified
|
|
If the function is unsuccessful
| |
|
CF
|
Set
|
|
AX
|
Error code (see "Error Codes" on page A-1) including DPMS_E_BAD_SEL (Invalid selector)
|
Explanation
This function converts the descriptor into a data segment with a limit of 0FFFFH and a base of 16* (real mode segment). DPMS_D_SET_BASE (0204h)
Set Descriptor Base Address
Function
This function sets the base of a descriptor to a given linear address value. It is called via protected or real mode API code.Entry Parameters
|
Register
|
Value
|
|---|---|
|
AX
|
DPMS_D_SET_BASE
|
|
BX
|
Selector for the descriptor
|
|
CX,DX
|
Linear address
|
|
Register
|
Value
|
|---|---|
|
If the function is successful
| |
|
CF
|
Clear
|
|
AX
|
Unmodified
|
|
If the function is unsuccessful
| |
|
CF
|
Set
|
|
AX
|
Error code (see "Error Codes" on page A-1) including DPMS_E_BAD_SEL (Invalid selector) DPMS_E_BAD_LIN_ADDR (Invalid linear memory address)
|
Explanation
The linear address is 32 bits. The high word is passed in CX, the low word in DX. DPMS_D_SET_LIMIT (0205h)
Set Descriptor Limit
Function
This function sets the limit of a descriptor. It is called via real or protected mode API code.Entry Parameters
|
Register
|
Value
|
|---|---|
|
AX
|
DPMS_D_SET_LIMIT
|
|
BX
|
Selector for the descriptor
|
|
CX,DX
|
New limit (size-1)
|
|
Register
|
Value
|
|---|---|
|
If the function is successful
| |
|
CF
|
Clear
|
|
AX
|
Unmodified
|
|
If the function is unsuccessful
| |
|
CF
|
Set
|
|
AX
|
Error code (see "Error Codes" on page A-1) including DPMS_E_BAD_VALUE (Invalid value) DPMS_E_BAD_SEL (Invalid selector)
|
Explanation
The limit is the number of bytes minus one. The granularity of the descriptor is automatically set as required by the DPMS server depending on the limit required. Clients running on an 80286 are limited to 64 KB segments, so do not set the limit to greater than 0FFFFh. DPMS_D_SET_TYPE (0206h)
Set Descriptor Type or Attributes
Function
This function sets a descriptor's type and attributes. It is called via real or protected mode API code.Entry Parameters
|
Register
|
Value
|
|---|---|
|
AX
|
DPMS_D_SET_TYPE
|
|
BX
|
Selector for the descriptor
|
|
CL
|
Type or attributes to be set (byte 5 of the descriptor)
|
|
CH
|
386 extended type or attributes to be set (byte 6 of the descriptor)
|
|
Register
|
Value
|
|---|---|
|
If the function is successful
| |
|
CF
|
Clear
|
|
AX
|
Unmodified
|
|
If the function is unsuccessful
| |
|
CF
|
Set
|
|
AX
|
Error code (see "Error Codes" on page A-1) including DPMS_E_BAD_VALUE (Invalid value) DPMS_E_BAD_SEL (Invalid selector)
|
Explanation
Refer to the Intel* 80286 and 386 programmer's reference documentation for a description of the type and attribute fields in descriptors. DPMS_D_GET_BASE (0207h)
Get Descriptor Base
Function
This function gets the base of a descriptor. It is called via real or protected mode API code.Entry Parameters
|
Register
|
Value
|
|---|---|
|
AX
|
DPMS_D_GET_BASE
|
|
BX
|
Selector for the descriptor
|
|
Register
|
Value
|
|---|---|
|
If the function is successful
| |
|
CF
|
Clear
|
|
CX,DX
|
Linear address of the base of the segment
|
|
AX
|
Unmodified
|
|
If function is unsuccessful
| |
|
CF
|
Set
|
|
AX
|
Error code (see "Error Codes" on page A-1) including DPMS_E_BAD_SEL (invalid selector)
|
Explanation
The returned value is 32 bits. The high word is returned in CX, the low word in DX. DPMS_M_FREESIZE (0300h)
Get Size of Largest Free Block
Function
This function gets the size of the largest free block in linear memory. It is called via real or protected mode API code.Entry Parameters
|
Register
|
Value
|
|---|---|
|
AX
|
DPMS_M_FREESIZE
|
|
Register
|
Value
|
|---|---|
|
If the function is successful
| |
|
CF
|
Clear
|
|
AX
|
Unmodified
|
|
BX,CX
|
Number of bytes in the largest free block
|
|
If the function is unsuccessful
| |
|
CF
|
Set
|
|
AX
|
Error code (see "Error Codes" on page A-1) including DPMS_E_LIN_NA (Linear memory unavailable) DPMS_E_PHYS_NA (Physical memory unavailable)
|
Explanation
The returned value is 32 bits. The high word is returned in BX, the low word in CX.
DPMS_M_ALLOC (0301h)
Allocate Linear Memory
Function
This function allocates a block of linear memory. It is called via real or protected mode API code.Entry Parameters
|
Register
|
Value
|
|---|---|
|
AX
|
DPMS_M_ALLOC
|
|
BX,CX
|
Number of bytes required
|
|
Register
|
Value
|
|---|---|
|
If the function is successful
| |
|
CF
|
Clear
|
|
BX,CX
|
Linear base address of the allocated block
|
|
SI,DI
|
Handle of the allocated block
|
|
AX
|
Unmodified
|
|
If the function is unsuccessful
| |
|
CF
|
Clear
|
|
AX
|
Error code (see "Error Codes" on page A-1) including DPMS_E_RESOURCE_NA (Resource unavailable) DPMS_E_LIN_NA (Linear memory unavailable) DPMS_E_PHYS_NA (Physical memory unavailable)
|
Explanation
The returned values are 32 bits. The high order words are returned in BX and SI, and the low words are returned in CX and DI.
Memory allocated using this method is obtained directly from the underlying memory manager. No method exists to allow this memory to be shared with other applications, for example, MS Windows. Allocate memory directly from the underlying memory manager, if you want to share this memory with normal DOS programs.
DPMS_M_FREE (0302h)
Free Linear Memory
Function
This function frees a linear memory block. It is called via real or protected mode API code.Entry Parameters
|
Register
|
Value
|
|---|---|
|
AX
|
DPMS_M_FREE
|
|
SI,DI
|
Handle of the block
|
|
Register
|
Value
|
|---|---|
|
If the function is successful
| |
|
CF
|
Clear
|
|
AX
|
Unmodified
|
|
If the function is unsuccessful
| |
|
CF
|
Set
|
|
AX
|
Error code (see "Error Codes" on page A-1) including DPMS_E_BAD_HANDLE (Invalid handle)
|
Explanation
This call frees physical memory allocated via DPMS_M_ALLOC (see page 2-54) or DPMS_M_RELOC (see page 2-66). If you try to access linear addresses within that block after it has been freed, a page fault may result. This call does not free any descriptors that might still refer to this memory block. Do not reference memory pointed to by such descriptors after this function call.
DPMS_M_MAP (0303h)
Map as Linear Memory
Function
This optional function maps physical memory into contiguous linear DPMS address space. This function is called via real or protected mode API code.Entry Parameters
|
Register
|
Value
|
|---|---|
|
AX
|
DPMS_M_MAP
|
|
ES:(E)DI
|
Pointer to Virtual DMA Services (VDS) DMA Descriptor Structure (DDS)
|
|
Register
|
Value
|
|---|---|
|
If the function is successful
| |
|
CF
|
Clear
|
|
BX,CX
|
Linear address
|
|
SI,DI
|
Handle
|
|
AX
|
Unmodified
|
|
If the function is unsuccessful
| |
|
CF
|
Set
|
|
AX
|
Error code (see "Error Codes" on page A-1) including DPMS_E_NOT_SUPP (Unsupported function) DPMS_E_RESOURCE_NA (Resource unavailable) DPMS_E_LIN_NA (Linear memory unavailable)
|
Explanation
This function is useful for making memory allocated via XMS, or memory-mapped devices, or physical memory returned via the VDS, addressable for protected mode DPMS clients. On some implementations, 80286 for example, this function is not supported. Ignore the error code "Unsupported function" that is returned in these cases, because the physical and linear addresses are identical.
The DDS_Physical_Address and DDS_Physical_Size fields are duplicated as many times as necessary to describe all the physical blocks. The client does not usually know the actual number of physical blocks and must allow for several. The number it allows for is passed to VDS in the DDS_Entries_Available field.
scatter/gather lock function. This is done by executing an INT 04Bh with AX set to 08105h, DX set to 0 and ES:DI pointing to the DDS, although clients should first verify that VDS is present by ensuring that bit 5 of 040:07Bh is set. VDS fills in the DDS_Entries_Used, DDS_Physical_Address and DDS_Physical_Size fields, or returns an error if there are more physical blocks than the DDS allows for.
DPMS_M_UNMAP (0304h)
Unmap As Linear Memory
Function
This optional function unmaps physical memory mapped via DPMS_M_MAP (see page 2-57). It is called via real or protected mode API code.
|
Register
|
Value
|
|---|---|
|
AX
|
DPMS_M_UNMAP
|
|
SI,DI
|
Handle
|
|
Register
|
Value
|
|---|---|
|
If the function is successful
| |
|
CF
|
Clear
|
|
AX
|
Unmodified
|
|
If the function is unsuccessful
| |
|
CF
|
Set
|
|
AX
|
Error code (see "Error Codes" on page A-1) including DPMS_E_NOT_SUPP (Unsupported function) DPMS_E_BAD_HANDLE (Invalid handle)
|
Explanation
In some implementations of DPMS this function is not supported. Ignore the error code "Unsupported function" that is returned in these cases. DPMS_M_GET_PAGE_TABLE (0305h)
Get Page Table Entries
Function
This optional function gets page table entries. It is called via protected or real mode API code. This function is only supported on 386 and later processors.Entry Parameters
|
Register
|
Value
|
|---|---|
|
AX
|
DPMS_M_GET_PAGE_TABLE
|
|
ESI
|
Linear memory address
|
|
(E)CX
|
Number of page table entries
|
|
ES: (E)DI
|
Pointer to buffer
|
|
Register
|
Value
|
|---|---|
|
If the function is successful
| |
|
CF
|
Clear
|
|
AX
|
Unmodified
|
|
ES: (E)DI
|
Buffer filled in with required page table entries
|
|
If the function is unsuccessful
| |
|
CF
|
Set
|
|
AX
|
Error code (see "Error Codes" on page A-1) including DPMS_E_NOT_SUPP (Unsupported function) DPMS_E_BAD_LIN_ADDR (Invalid linear address)
|
The available bits in each page table entry are reserved for use by the server and may contain any values when copied to the client.
DPMS_M_SET_PAGE_TABLE (0306h)
Set Page Table Entries
Function
This optional function sets page table entries. It is called via protected or real mode API code. This function is only supported on 386 and later processors.Entry Parameters
|
Register
|
Value
|
|---|---|
|
AX
|
DPMS_M_SET_PAGE_TABLE
|
|
EBX
|
Linear memory handle
|
|
(E)CX
|
Number of page table entries
|
|
ESI
|
Linear address
|
|
ES: (E)DI
|
Pointer to page table entries
|
|
Register
|
Value
|
|---|---|
|
If the function is successful
| |
|
CF
|
Clear
|
|
AX
|
Unmodified
|
|
If the function is unsuccessful
| |
|
CF
|
Set
|
|
AX
|
Error code (see "Error Codes" on page A-1) including DPMS_E_NOT_SUPP (Unsupported function) DPMS_E_BAD_LIN_ADDR (Invalid linear address) DPMS_E_BAD_HANDLE (Invalid handle)
|
The available bits in each page table entry are reserved for use by the server and will be ignored when this function is called.
DPMS_M_MAP_SIZE (0307h)
Get Largest Mappable Block Size
Function
This optional function gets the size of the largest block of linear memory that can be mapped into DPMS linear address space. It is called via real or protected mode API code.Entry Parameters
|
Register
|
Value
|
|---|---|
|
AX
|
DPMS_M_MAP_SIZE
|
|
Register
|
Value
|
|---|---|
|
If the function was successful
| |
|
CF
|
Clear
|
|
AX
|
Unmodified
|
|
BX CX
|
Size in bytes of largest block that can be mapped
|
|
If the function was unsuccessful
| |
|
CF
|
Set
|
|
AX
|
Error code (see "Error Codes" on page A-1) including DPMS_E_NOT_SUPP (Unsupported function) DPMS_E_LIN_NA (Linear memory unavailable)
|
Explanation
The returned value is 32 bits. The high word is returned in BX, the low word is returned in CX.
DPMS_M_RELOC (0400h)
Relocate Segment to Extended Memory
Function
This function allocates extended memory and relocates a real mode segment to it. It is called via real mode API code.Entry Parameters
|
Register
|
Value
|
|---|---|
|
If the function is successful
| |
|
CF
|
Clear
|
|
AX
|
Selector
|
|
BX,CX
|
Linear address of the protected mode segment
|
|
SI,DI
|
Handle for the linear memory allocated
|
|
If the function is unsuccessful
| |
|
CF
|
Set
|
|
AX
|
Error code (see "Error Codes" on page A-1) including DPMS_E_DESC_NA (Descriptor unavailable) DPMS_E_LIN_NA (Linear memory unavailable) DPMS_E_PHYS_NA (Physical memory unavailable) DPMS_E_BAD_VALUE (Invalid value) DPMS_E_BAD_SEL (Invalid selector)
|
Explanation
The returned address and handle are 32 bits. The high words are returned in BX and SI, and the low words are returned in CX and DI.
You can pass a selector obtained via DPMS_D_ALLOC (see page 2-39) to this function, or a value of zero to allocate automatically a new descriptor pointing to the new memory block.
Memory allocated via the DPMS_M_RELOC function should be freed before freeing the descriptor.