Jump to content

DevHelp VMProcessToGlobal: Difference between revisions

From EDM2
Created page with "This service converts an address in the current process address space to an address in the system region of the global address space. ==Syntax== ===C=== <PRE> USHORT APIENTR..."
 
Ak120 (talk | contribs)
Line 76: Line 76:


The following figure shows Mapping Performed by VMProcessToGlobal.
The following figure shows Mapping Performed by VMProcessToGlobal.
<PRE>
<PRE>
           Before                                      After
           Before                                      After
  ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ 4 Gigabytes ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
  ┌───────────────────────┐ 4 Gigabytes ┌───────────────────────┐
  ³                       ³             ³                       ³
                                                         
  ³                       ³             ³                       ³
                                                         
  ³     System Region    ³             ³     System Region    ³
      System Region                    System Region   
  ³                       ³             ³                       ³
                                                         
  ³                       ³             ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
                                    ├───────────────────────┤
  ³                       ³             ³       Object A        ³
                                          Object A       
  ³                       ³             ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
                                    ├───────────────────────┤
  ³                       ³             ³                       ³
                                                         
  ÃÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄ´             ÃÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄ´
  ├───────┬───────┬───────┤             ├───────┬───────┬───────┤
  ³       ³       ³       ³             ³       ³       ³       ³
                                                 
  ³Process³Process³Process³             ³Process³Process³Process³
  │Process│Process│Process│             │Process│Process│Process│
  ³   A  ³   B  ³   C  ³             ³   A  ³   B  ³   C  ³
    A    B    C                A    B    C 
  ³Address³Address³Address³             ³Address³Address³Address³
  │Address│Address│Address│             │Address│Address│Address│
  ³ Space ³ Space ³ Space ³             ³ Space ³ Space ³ Space ³
  Space Space Space             Space Space Space
  ÃÄÄÄÄÄÄÄ´       ³       ³             ÃÄÄÄÄÄÄÄ´       ³       ³
  ├───────┤                         ├───────┤            
  ³ Obj A ³       ³       ³             ³ Obj A ³       ³       ³
  Obj A                         Obj A            
  ÃÄÄÄÄÄÄÄ´       ³       ³             ÃÄÄÄÄÄÄÄ´       ³       ³
  ├───────┤                         ├───────┤            
  ³       ³       ³       ³             ³       ³       ³       ³
                                                 
  ÀÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÙ     0      ÀÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÙ
  └───────┴───────┴───────┘     0      └───────┴───────┴───────┘
</PRE>
</PRE>
Mapping Performed by VMProcessToGlobal
Mapping Performed by VMProcessToGlobal


The following steps show to use the DevHlp services to gain interrupt time access to the buffer of a process:
The following steps show to use the DevHlp services to gain interrupt time access to the buffer of a process:
* If the user's buffer was allocated in the Local Descriptor Table (LDT) tiled region, use the SelToFlat macro to convert the address to a linear address.
* If the user's buffer was allocated in the Local Descriptor Table (LDT) tiled region, use the SelToFlat macro to convert the address to a linear address.
* Call VMLock to verify the address and to lock the range of memory needed into physical memory.
* Call VMLock to verify the address and to lock the range of memory needed into physical memory.

Revision as of 20:18, 10 April 2019

This service converts an address in the current process address space to an address in the system region of the global address space.

Syntax

C

USHORT APIENTRY DevHelp_VMProcessToGlobal( ULONG Flags,
                                           LIN   LinearAddr,
                                           ULONG Length,
                                           PLIN  GlobalLinearAddr)

Assembler

MOV   EBX,LinearAddress     ; Linear Address within process address space
                            ;    that is to be mapped into a global context;
                            ;    must be on a page boundary
MOV   ECX,Length            ; Length of request in bytes
MOV   EAX,ActionFlags       ; Action to perform
                            ; If bit 0 (00001B) is set, the mapping created will
                            ;    be writable.  If this bit is clear, the mapping
                            ;    will be read only
                            ;   (Note:  Some hardware may not support read only
                            ;    mapping).
                            ; All other bits must be clear.

MOV   DL,DevHlp_VMProcessToGlobal

CALL  [Device_Help]

Parameters

C

Flags (ULONG)
Action to perform:
MDHPG_READONLY - If bit 0 is clear, its mapping will be read only.
VMDHPG_WRITEV - If bit 0 is set, the mapping created will be writable.
All other bits must be clear.
LinearAddr (LIN)
Linearaddress within process space that is to be mapped into a global context; must be on a page boundary.
Length (ULONG)
Length of address space to be mapped.
GlobalLinearAddr (PLIN)
Global offset to region of memory returned.

Assembler

MOV   EBX,LinearAddress     ; Linear Address within process address space
                            ;    that is to be mapped into a global context;
                            ;    must be on a page boundary
MOV   ECX,Length            ; Length of request in bytes
MOV   EAX,ActionFlags       ; Action to perform
                            ; If bit 0 (00001B) is set, the mapping created will
                            ;    be writable.  If this bit is clear, the mapping
                            ;    will be read only
                            ;   (Note:  Some hardware may not support read only
                            ;    mapping).
                            ; All other bits must be clear.

Return Code

C

Success Indicator: Clear if conversion is performed - returns GlobalLinearAddr.

Possible errors: EAX = Error code - ERROR_INVALID_PARAMETER (87)

Assembler

   'C' Clear if conversion performed.
       EAX = Global offset to region of memory.

   'C' Set if conversion not performed.
       EAX = Error code - ERROR_INVALID_PARAMETER (87)

Remarks

The address range must be on a page boundary and must not cross object boundaries. This call copies the linear mapping from the process's address space to the system-shared address space. This allows the physical device driver to access the data independent of the context of the current process. The following figure shows the mapping that is performed when a physical device driver calls VMProcessToGlobal.

The following figure shows Mapping Performed by VMProcessToGlobal.

          Before                                       After
 ┌───────────────────────┐ 4 Gigabytes ┌───────────────────────┐
 │                       │             │                       │
 │                       │             │                       │
 │     System Region     │             │     System Region     │
 │                       │             │                       │
 │                       │             ├───────────────────────┤
 │                       │             │       Object A        │
 │                       │             ├───────────────────────┤
 │                       │             │                       │
 ├───────┬───────┬───────┤             ├───────┬───────┬───────┤
 │       │       │       │             │       │       │       │
 │Process│Process│Process│             │Process│Process│Process│
 │   A   │   B   │   C   │             │   A   │   B   │   C   │
 │Address│Address│Address│             │Address│Address│Address│
 │ Space │ Space │ Space │             │ Space │ Space │ Space │
 ├───────┤       │       │             ├───────┤       │       │
 │ Obj A │       │       │             │ Obj A │       │       │
 ├───────┤       │       │             ├───────┤       │       │
 │       │       │       │             │       │       │       │
 └───────┴───────┴───────┘      0      └───────┴───────┴───────┘

Mapping Performed by VMProcessToGlobal

The following steps show to use the DevHlp services to gain interrupt time access to the buffer of a process:

  • If the user's buffer was allocated in the Local Descriptor Table (LDT) tiled region, use the SelToFlat macro to convert the address to a linear address.
  • Call VMLock to verify the address and to lock the range of memory needed into physical memory.
  • Call VMProcessToGlobal to map the private address of a process into global address space. See the previous figure for more details on the mapping performed.
  • If the physical device driver requests it, an array of physical addresses corresponding to the locked region is returned.
  • Access the memory using the FLAT selector and its linear address as returned by VMProcessToGlobal.
  • Call VMFree to remove global mapping to process address space.
  • Call VMUnLock to unlock the object.

Example Code

C

#include  "dhcalls.h"

USHORT APIENTRY DevHelp_VMProcessToGlobal( ULONG Flags,
                                           LIN   LinearAddr,
                                           ULONG Length,
                                           PLIN  GlobalLinearAddr)

Related Functions