1 | /* $Id: mmf.cpp,v 1.2 2001-02-24 04:37:15 bird Exp $
|
---|
2 | *
|
---|
3 | * Memory Mapped Files.
|
---|
4 | *
|
---|
5 | * Copyright (c) 2000 knut st. osmundsen (knut.stange.osmundsen@mynd.no)
|
---|
6 | *
|
---|
7 | * Project Odin Software License can be found in LICENSE.TXT
|
---|
8 | *
|
---|
9 | */
|
---|
10 |
|
---|
11 | /** @design Memory Mapped Files - Ring 0
|
---|
12 |
|
---|
13 | Support for Memory Mapped Files (MMF) is an excellent feature missing in OS/2.
|
---|
14 | Several Ring-3 implementations exists. Most of them have problems when calling
|
---|
15 | OS/2 APIs. APIs like DosRead, DosWrite will at Ring-0 check if the buffer
|
---|
16 | passed in is valid (all pages commited), and will fail if the pages aren't
|
---|
17 | commited. And AFAIK the Ring-3 MMF implementations exploits the commit/decommit
|
---|
18 | feature of DosSetMem.<p>
|
---|
19 |
|
---|
20 | So, the only way to get this right and fast is to implement it at Ring-0 level.
|
---|
21 | This is what I (knut) aim to do some day. These are my current thoughts on
|
---|
22 | the subject. (Oct 31 2000 5:39pm)<p>
|
---|
23 |
|
---|
24 | What I am think about is to create a Ring-0 class for MMF which maintains all
|
---|
25 | of the MMF handling. There will be a Ring-3 DLL which provides APIs which
|
---|
26 | uses IOCtls to communicate with the Ring-0 class. These APIs will be presented
|
---|
27 | in these forms:
|
---|
28 | <ul>
|
---|
29 | <li>My own "native" APIs.
|
---|
30 | <li>UNIX mmap, munmap, msync APIs
|
---|
31 | <li>Win32 styled APIs. (if needed)
|
---|
32 | </ul><p>
|
---|
33 |
|
---|
34 |
|
---|
35 | @subsection Loader Exploits (Overloads)
|
---|
36 |
|
---|
37 | The Ring-0 part will create pseudo MTEs for each file handle given in the
|
---|
38 | openmapping call. These MTEs will not be linked into the mte list, but will
|
---|
39 | be linked into a private MMF list. By doing it this way we'll be able to use
|
---|
40 | the LDRGetPage function without overloading it. We just have to feed the
|
---|
41 | loader with valid pagelists.<p>
|
---|
42 |
|
---|
43 | We'll have to do cleanups of this internal MTEs by overloading LDRFreeTask.<p>
|
---|
44 |
|
---|
45 | Objects are allocated by us self using ldrAllocObjects and ldrSetVMFlags will
|
---|
46 | be overloaded to set the correct flags.
|
---|
47 |
|
---|
48 |
|
---|
49 | @subsubsection LDRFreeTask
|
---|
50 |
|
---|
51 | Here we'll clean up all our resources associated with this process. I am not
|
---|
52 | quite sure what this will be; flushing mappings, decreasing usage counts,
|
---|
53 | eventually releasing objects, closing files.
|
---|
54 |
|
---|
55 |
|
---|
56 | @subsubsection ldrAllocObjects
|
---|
57 |
|
---|
58 | Here we could attach inherited mappings. Not really needed.
|
---|
59 |
|
---|
60 |
|
---|
61 |
|
---|
62 | @subsection Interface Ring-0 to Ring-3
|
---|
63 |
|
---|
64 | An interface between Ring-0 and Ring-3 will have to be as simple as possible,
|
---|
65 | and yet the Ring-0 would not trust the Ring-3 very much since someone may
|
---|
66 | call the DosIOCtls them selves. These are the proposed interfaces:
|
---|
67 | <ul>
|
---|
68 | <li>MMFCreating - Create a mapping handle.
|
---|
69 | <li>MMFDuplicate - Duplicates a mapping handle.
|
---|
70 | <li>MMFOpen - Open an existing mapping.
|
---|
71 | <li>MMFViewMap - Creates a view for a part of the file.
|
---|
72 | <li>MMFViewUnmap - Flushes and destroys a view.
|
---|
73 | <li>MMFViewSync - Flush a view.
|
---|
74 | </ul>
|
---|
75 | This will roughly be the exported "native" APIs too.
|
---|
76 |
|
---|
77 | @subsubsection MMFCreating
|
---|
78 | @subsubsection MMFDuplicate
|
---|
79 | @subsubsection MMFOpen
|
---|
80 | @subsubsection MMFViewMap
|
---|
81 | @subsubsection MMFViewUnmap
|
---|
82 | @subsubsection MMFViewSync
|
---|
83 |
|
---|
84 |
|
---|
85 | @subsection Innerworkings of the Ring-0 MMF class(es)
|
---|
86 |
|
---|
87 | To be written some other day.
|
---|
88 |
|
---|
89 | */
|
---|
90 |
|
---|
91 |
|
---|