Jump to content

DevHelp PhysToUVirt: Difference between revisions

From EDM2
No edit summary
 
Line 1: Line 1:
{{DISPLAYTITLE:DevHelp_PhysToUVirt}}
This service converts a 32-bit physical address to a valid selector:offset pair addressable out of the current Local Descriptor Table (LDT). Additional information about the selector can be retained by the memory manager, if special processing, based on the tag type, is required.  
This service converts a 32-bit physical address to a valid selector:offset pair addressable out of the current Local Descriptor Table (LDT). Additional information about the selector can be retained by the memory manager, if special processing, based on the tag type, is required.  



Latest revision as of 03:24, 23 May 2025

This service converts a 32-bit physical address to a valid selector:offset pair addressable out of the current Local Descriptor Table (LDT). Additional information about the selector can be retained by the memory manager, if special processing, based on the tag type, is required.

Syntax

C

USHORT APIENTRY DevHelp_PhysToUVirt( ULONG  PhysAddr,
                                     USHORT Length,
                                     USHORT Flags,
                                     USHORT TagType,
                                     PVOID  SelOffset)

Assembler

MOV   AX,address_high  ; 32-bit physical address (or selector, if request type 2)
MOV   BX,address_low   ;
MOV   CX,length        ; Length of area (less than or equal to 65535, 0 = 65536)
MOV   DH,request_type  ; Type of Request
                       ; 0 = get virtual address, make segment
                       ;     readable/executable, with Application
                       ;     Program Privilege
                       ; 1 = get virtual address, make segment readable/writable,
                       ;     with Application Program Privilege
                       ; 2 = free virtual address (OS/2 mode only)
                       ; 3 = get virtual address, make segment
                       ;     readable/executable, with I/O Privilege
                       ; 4 = get virtual address, make segment readable/writable,
                       ;     with I/O Privilege
                       ; 5 = get virtual address, make segment readable/writable,
                       ;     with Application Program Privilege and assign it
                       ;     with a tag
MOV   SI,tag type      ; Type of tag (used only on request type 5, preserved on
                       ;     all others)
                       ; 0 = foreground only video selector
MOV   DL,DevHlp_PhysToUVirt

CALL  [Device_Help]

Parameters

C

PhysAddr (ULONG)
32-bit physical address (or selector if request type2).
Length (USHORT)
Length of area (less than or equal to 65535, 0=65536).
Flags (USHORT)
Type of request:
SELTYPE_R3CODE
get virtual address, make segment readable/executable with application program privilege.
SELTYPE_R3DATA
get virtual address, make segment readable writable with application program privilege.
SELTYPE_FREE
free virtual address (OS/2 mode only)
SELTYPE_R2CODE
get virtual address, make segment readable/executable with I/O privilege.
SELTYPE_R2DATA
get virtual address, make segment readable/writable with I/O privilege.
SELTYPE_R3VIDEO
get virtual address, make segment readable/writable with Application Program Privilege and assign it with a tag.
TagType (USHORT
Type of tag (used only on request type 5, preserved on all others).
0 = foreground only video selector.
SelOffset (PVOID)
Segment/selector:offset pair to be returned for request types 0, 1, 3, and 4.

Assembler

MOV   AX,address_high  ; 32-bit physical address (or selector, if request type 2)
MOV   BX,address_low   ;
MOV   CX,length        ; Length of area (less than or equal to 65535, 0 = 65536)
MOV   DH,request_type  ; Type of Request
                       ; 0 = get virtual address, make segment
                       ;     readable/executable, with Application
                       ;     Program Privilege
                       ; 1 = get virtual address, make segment readable/writable,
                       ;     with Application Program Privilege
                       ; 2 = free virtual address (OS/2 mode only)
                       ; 3 = get virtual address, make segment
                       ;     readable/executable, with I/O Privilege
                       ; 4 = get virtual address, make segment readable/writable,
                       ;     with I/O Privilege
                       ; 5 = get virtual address, make segment readable/writable,
                       ;     with Application Program Privilege and assign it
                       ;     with a tag
MOV   SI,tag type      ; Type of tag (used only on request type 5, preserved on
                       ;     all others)
                       ; 0 = foreground only video selector

Return Code

C

Success Indicator: 0 - returns segment/selector:offset.

Assembler

   'C' Clear if successful.
       ES:BX = segment/selector:offset pair
               (for request types 0, 1, 3, and 4).

   'C' Set if error.

Remarks

This service is typically used to provide a caller of a physical device driver with addressability to a fixed memory area, such as ROM code and data. The physical device driver must know the physical address of the memory area to be addressed. PhysToUVirt leaves its result in ES:BX. This service also can be used to free a selector returned on a prior call to PhysToUVirt. For request type 2, AX contains a selector on entry to PhysToUVirt. BX and CX are ignored.

Note: If the input physical address is not on a 4KB boundary, then the length of the result segment will be limited to 64KB minus the offset from 4KB of the input physical address.

PhysToUVirt creates selector:offset LDT addressability for a 32-bit physical address. This function is provided so a physical device driver can give an application process addressability to a fixed memory area, such as in the BIOS-reserved range from 640KB to 1MB. It can also be used to give a client application addressability to a data segment of the physical device driver. The selector created, however, does not represent a normal memory segment such as those usually managed by the operating system, and is more of a fabricated segment for private use between a physical device driver and an application. Data within such a segment cannot be passed on system calls, and can be used by the receiving application only to return data variables.

Example Code

C

#include  "dhcalls.h"

USHORT APIENTRY DevHelp_PhysToUVirt( ULONG  PhysAddr,
                                     USHORT Length,
                                     USHORT Flags,
                                     USHORT TagType,
                                     PVOID  SelOffset)

Related Functions