source: trunk/src/kernel32/mapos2.h@ 99

Last change on this file since 99 was 99, checked in by phaller, 26 years ago

Add: added cvs variable $Id$ to source files.

File size: 4.4 KB
Line 
1/* $Id: mapos2.h,v 1.3 1999-06-10 19:11:30 phaller Exp $ */
2
3/* Copyright (C) 1995 by Holger Veit (Holger.Veit@gmd.de) */
4/* Use at your own risk! No Warranty! The author is not responsible for
5 * any damage or loss of data caused by proper or improper use of this
6 * device driver.
7 */
8
9#ifndef _MAPOS2_H_
10#define _MAPOS2_H_
11
12/* This driver provides a (non-1-to-1!) replacement for SMVDD.SYS
13 * function 0x81/0x42, which allows to map physical memory into user
14 * address space.
15 *
16 * THE DRIVER WAS SPECIFICALLY CREATE FOR SUPPORT OF XFREE86/OS2.
17 *
18 * Usage:
19 *
20 * 1. Open the device "PMAP$".
21 * rc = DosOpen("PMAP$", &hf, &action, 0, FILE_NORMAL,
22 * OPEN_ACCESS_READWRITE|OPEN_SHARE_DENYNONE, (PEAOP2)NULL);
23 *
24 * 2. To map a memory area:
25 * ParamPkt p;
26 * ULONG len;
27 * DataPkt d;
28 * void* paddr;
29 * p.u.physaddr = 0xb8000; // e.g. video memory
30 * p.size = 2048; // e.g. 2KB
31 * rc = DosDevIOCtl(hf, XFREE86_PMAP, PMAP_MAP,
32 * (PULONG)&p, sizeof(p), &len,
33 * (PULONG)&d, sizeof(d), &len);
34 * paddr = (void*)d.addr;
35 *
36 * 3. To unmap the *same* area, return the virtual address you got from
37 * the data packet of the PMAP_MAP ioctl. Don't return the physical
38 * address!
39 *
40 * ParamPkt p;
41 * ULONG len;
42 * void* vmaddr;
43 * p.u.vmaddr = (ULONG)paddr;
44 * p.size = 0;
45 * rc = DosDevIOCtl(hf, XFREE86_PMAP, PMAP_UNMAP,
46 * (PULONG)&p, sizeof(p), &len,
47 * NULL,0,NULL);
48 * paddr = (void*)d.addr;
49 *
50 * 4. Close the driver
51 * rc = DosClose(hf);
52 *
53 * Notes:
54 * 1. Unlike SMVDD.SYS, PMAP$ will automatically unmap all allocated
55 * memory of a process, if the driver is closed. Thus the pointers
56 * obtained from the driver become immediately invalid (Segmentation
57 * violation when used).
58 * 2. Unlike SMVDD.SYS, PMAP$ can allocate more than 64K at a time, thus
59 * the interface changed.
60 * 3. You can only unmap the whole memory allocated by a single call, not
61 * parts, e.g. allocate 1000-1FFF will give you a pointer to 1000. If
62 * you now return a pointer to 1800 (made by pointer arithmetics) to
63 * the unmap ioctl, in the hope of retaining 1000-17FF, this will fail.
64 * you could however map the 1000-1FFF in two parts of 2K each.
65 * You must submit *the same* pointer to the unmap ioctl, and this pointer
66 * must have been obtained by the same open file (opening PMAP$ twice and
67 * mapping the same memory will return different and incompatible pointers).
68 * 4. This driver operates only with 32 bit code, and the pointer returned is
69 * a flat 32 bit pointer.
70 * 5. The driver maintains a systemwide table of 64 mapped adresses at a time.
71 * Attempting to map more than 64 regions will fail.
72 * 6. Finally a word of warning: Using this function to access memory you
73 * don't know exactly whom it belongs to - by default OS/2 is the owner of
74 * all memory - WILL LIKELY CRASH THE SYSTEM! The author of the driver
75 * is not responsible for any damage or loss of data caused by using this
76 * driver once it is written in CONFIG.SYS.
77 */
78
79/* The parameter packet */
80struct xf86_pmap_param {
81 union {
82 ULONG physaddr; /* used for MAP, UNMAP2 */
83 ULONG vmaddr; /* used for UNMAP */
84 } u;
85 ULONG size;
86};
87
88/* The data packet */
89struct xf86_pmap_data {
90 ULONG addr;
91 USHORT sel;
92};
93
94/* The device driver category */
95#define XFREE86_PMAP 0x76 /* 'v' */
96
97/* The device driver functions */
98#define PMAP_RESERVED0 0x40 /* don't use */
99#define PMAP_RESERVED1 0x41 /* don't use */
100#define PMAP_RESERVED2 0x42 /* don't use */
101#define PMAP_RESERVED3 0x43 /* don't use */
102
103#define PMAP_MAP 0x44 /* map by physical addr */
104#define PMAP_UNMAP 0x45 /* unmap by virtual addr */
105#define PMAP_UNMAP2 0x46 /* unmap by physical addr */
106
107#define PMAP_NAME 0x60 /* return my name (pass 13 byte buffer) */
108#define PMAP_DRVID 0x61 /* return (struct xf86_pmap_drvid) */
109#define PMAP_RESERVED4 0x62 /* don't use */
110#define PMAP_RESERVED5 0x63 /* don't use */
111
112#define PMAP_READROM 0x64 /* testcfg.sys replacement get adapter memory */
113
114struct xf86_pmap_readrom {
115 ULONG command; /* must be 0 */
116 ULONG physaddr; /* 0xc0000 to 0xfffff */
117 USHORT numbytes; /* 0-64K */
118};
119/* data packet must be an array of `numbytesï chars */
120
121#define PMAPDRV_MAGIC 0x36384f58 /* 'XF86' */
122#define PMAPDRV_ID 4
123
124struct xf86_pmap_drvid {
125 ULONG magic;
126 ULONG drvtype;
127 ULONG version;
128};
129
130#endif
Note: See TracBrowser for help on using the repository browser.