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

Last change on this file since 46 was 46, checked in by sandervl, 26 years ago

* empty log message *

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