source: trunk/src/win32k/mmf/mmf.cpp@ 4546

Last change on this file since 4546 was 4546, checked in by bird, 25 years ago

Initial thoughts

File size: 3.9 KB
Line 
1/* $Id: mmf.cpp,v 1.1 2000-10-31 17:35:00 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
13Support for Memory Mapped Files (MMF) is an excellent feature missing in OS/2.
14Several Ring-3 implementations exists. Most of them have problems when calling
15OS/2 APIs. APIs like DosRead, DosWrite will at Ring-0 check if the buffer
16passed in is valid (all pages commited), and will fail if the pages aren't
17commited. And AFAIK the Ring-3 MMF implementations exploits the commit/decommit
18feature of DosSetMem.<p>
19
20So, the only way to get this right and fast is to implement it at Ring-0 level.
21This is what I (knut) aim to do some day. These are my current thoughts on
22the subject. (Oct 31 2000 5:39pm)<p>
23
24What I am think about is to create a Ring-0 class for MMF which maintains all
25of the MMF handling. There will be a Ring-3 DLL which provides APIs which
26uses IOCtls to communicate with the Ring-0 class. These APIs will be presented
27in 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
37The Ring-0 part will overload the handling of the Ring-3 DLL, that's the
38reason why I will insist on having a separate MMF DLL. When the first call to
39the MMF is issued we'll find the MMF DLL and "hook" it's handle. This
40"hooking" will enable us to make speciall processing in LDRGetPage,
41LDRFreeTask and maybe ldrAllocateObjects. All of these LDR functions will have
42to be overloaded with my own functions - LDRGetPage will be written in
43assembly to minimize latency.<p>
44
45
46@subsubsection LDRGetPage
47
48As you will see somewhere else (when this text is completed) we'll allocate
49objects my self and give the hMTE of the MMF DLL. The block number will be
50relative to the start of each mapping if there is a filebacking of the
51object.<p>
52
53So, what we'll actually do is 1st to check that the call isn't for the real
54LX objects of the MMF DLL. Since we're overloading the processing of the
55MMF DLL we will have to distiguish between calls related to the processing
56of the DLL and the processing of our memorymapped objects. Then, if this
57is a request for a page in the one of the objects of the MMF DLL we'll simply
58call(/jump) to the original LDRGetPage.<p>
59
60If this is a request for a page in one of the memory mapped objects, we'll
61have to get that page. Starts out by finding the mapping this is for. If it's
62a mapping without filebacking we'll simply return a zero'ed page. Else, we'll
63have to read it from the disk. And that's about all we'll have to do.
64
65
66@subsubsection LDRFreeTask
67
68Here we'll clean up all our resources associated with this process. I am not
69quite sure what this will be; flushing mappings, decreasing usage counts,
70eventually releasing objects, closing files.
71
72
73@subsubsection ldrAllocObjects
74
75Here we could attach inherited mappings. Not really needed.
76
77
78
79@subsection Interface Ring-0 to Ring-3
80
81An interface between Ring-0 and Ring-3 will have to be as simple as possible,
82and yet the Ring-0 would not trust the Ring-3 very much since someone may
83call the DosIOCtls them selves. These are the proposed interfaces:
84<ul>
85 <li>MMFCreating - Create a mapping handle.
86 <li>MMFDuplicate - Duplicates an mapping handle.
87 <li>MMFOpen - Open an existing mapping.
88 <li>MMFViewMap - Creates a view for a part of the file.
89 <li>MMFViewUnmap - Flushes and destroys a view.
90 <li>MMFViewSync - Flush a view.
91</ul>
92This will roughly be the exported "native" APIs too.
93
94@subsubsection MMFCreating
95@subsubsection MMFDuplicate
96@subsubsection MMFOpen
97@subsubsection MMFViewMap
98@subsubsection MMFViewUnmap
99@subsubsection MMFViewSync
100
101
102@subsection Innerworkings of the Ring-0 MMF class(es)
103
104To be written some other day.
105
106 */
Note: See TracBrowser for help on using the repository browser.