DosMapPhysMem() dynalink library, public release 1.0.1

Copyright 2001 Takayuki 'January June' Suwa / Beliefia Productions.


0. Table of Contents



1. Welcome

This software is a dynalink library that maps specified physical memory region to 32bit process address space and unmaps it.
Before, all OS/2 32bit processes can access physical memory only via tightly-limited way such as DIVE / GRADD video framebuffer.
This DLL internally issues mighty DevHlp_VMAlloc() to realize such memory mapping via common device driver SCREEN0x.SYS, thus, now you can access to any position of physical memory freely.

It can be used any 32bit development suites that can issue OS/2 APIs such as emx/gcc, VisualAge C/C++ or Watcom C/C++.
Free to use, under the GNU LGPL.

1.1. Copyright and Disclaimer

  1. 'THIS SOFTWARE AND WHOLE SET OF DOCUMENTS' (CALLED 'THE PACKAGE') ARE ENTIRELY COPYRIGHTED BY TAKAYUKI 'JANUARY JUNE' SUWA / BELIEFIA PRODUCTIONS, AUTHOR / HOLDER OF THE PRODUCT.
  2. THIS PACKAGE IS DISTRIBUTED UNDER THE "GNU LESSER PUBLIC LICENSE" (LGPL). IT CLAIMS: SEE "COPYING" FOR DETAIL.
  3. THE PACKAGE IS PROVIDED 'AS IS' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  4. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY DAMAGES, WHETHER IN CONTRACT OR TORT (INCLUDED NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THE PRODUCT, EVEN THOUGH SUCH HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF ANY DAMAGE.

1.2. System Requirements

This program will be functioned in environment such as:

1.3. Contact Author

Email to Takayuki 'January June' Suwa:

1.4. Revision History



2. Reference


2.1. DosMapPhysMem()

Syntax Maps specified physical memory region to 32bit process private address space.
#define INCL_BASE
#include <os2.h>
#include "MAPHYMEM.h"
 
APIRET ulrc = DosMapPhysMem(PPVOID ppb,
                            ULONG cb,
                            ULONG ulPhysAddr);
Parameters
ppb (PPVOID) - output
Pointer to variable that, pointer to mapped memory region will be set to.
cb (ULONG) - input
Size of memory region to map, in bytes.
ulPhysAddr (ULONG) - input
Physical memory address to be mapped.
Returns
ulrc (APIRET) - return
Return codes.
ERROR_INVALID_FUNCTION
Not supported.
ERROR_INVALID_PARAMETER
One or more paramaters are invalid.
NO_ERROR
Successful completion.
Remarks

This function maps specified physical memory region to 32bit process private address space. If successful, returned pointer (*ppb) points valid process linear address as "peeping window" to physical memory region, and its memory pages are all readable, writeable, committed and of course allocated to physical entity.

All mappings are page-basis, thus ulPhysAddr is aligned to 4kB boundary and cb is rounded up to next 4kB granule.

Be with great care when writing to any physical memory region. It can destroy system structures easily and may cause kernel-level crashes.


2.2. DosMapSharedPhysMem()

Syntax Maps specified physical memory region to 32bit process shared address space.
#define INCL_BASE
#include <os2.h>
#include "MAPHYMEM.h"
 
APIRET ulrc = DosMapSharedPhysMem(PPVOID ppb,
                                  ULONG cb,
                                  ULONG ulPhysAddr);
Parameters
ppb (PPVOID) - output
Pointer to variable that, pointer to mapped memory region will be set to.
cb (ULONG) - input
Size of memory region to map, in bytes.
ulPhysAddr (ULONG) - input
Physical memory address to be mapped.
Returns
ulrc (APIRET) - return
Return codes.
ERROR_INVALID_FUNCTION
Not supported.
ERROR_INVALID_PARAMETER
One or more paramaters are invalid.
NO_ERROR
Successful completion.
Remarks

This function maps specified physical memory region to 32bit process shared address space. See DosMapPhysMem() also.


2.3. DosUnmapPhysMem()

Syntax Unmaps physical memory region mapped by DosMap*PhysMem() from 32bit process address space.
#define INCL_BASE
#include <os2.h>
#include "MAPHYMEM.h"
 
APIRET ulrc = DosUnmapPhysMem(PVOID pb);
Parameters
pb (PVOID) - input
Pointer to mapped memory region to be unmapped.
Returns
ulrc (APIRET) - return
Return codes.
ERROR_INVALID_FUNCTION
Not supported.
ERROR_INVALID_PARAMETER
One or more paramaters are invalid.
NO_ERROR
Successful completion.
Remarks

This function unmaps physical memory region mapped by DosMapPhysMem() or DosMapSharedPhysMem() from 32bit process address space.

Do not unmap any memory regions not mapped by DosMapPhysMem() or DosMapSharedPhysMem(). Such attempts may bring unpredictable results including kernel-level crashes.



Copyright 2001 Takayuki 'January June' Suwa / Beliefia Productions. All rights reserved.
Beliefia Productions and its logo design are trademarks of Beliefia Productions. All rights reserved.
Other copyrighted works (images, musics, programs, and so on), trademarks and servicemarks in this document are owned by their respective owners.

[This document is HTML3.2(Wilbur)-compliant.]