|
Revision 330, 1.9 kB
(checked in by mwhitworth, 6 months ago)
|
|
Add mmap function for Zero.
|
| Line | |
|---|
| 1 | |
|---|
| 2 | |
|---|
| 3 | |
|---|
| 4 | |
|---|
| 5 | |
|---|
| 6 | |
|---|
| 7 | |
|---|
| 8 | |
|---|
| 9 | |
|---|
| 10 | |
|---|
| 11 | |
|---|
| 12 | |
|---|
| 13 | |
|---|
| 14 | |
|---|
| 15 | |
|---|
| 16 | |
|---|
| 17 | |
|---|
| 18 | |
|---|
| 19 | #include <fs/vfs.h> |
|---|
| 20 | #include <fs/devfs.h> |
|---|
| 21 | #include <typedefs.h> |
|---|
| 22 | #include <init.h> |
|---|
| 23 | #include <i386/i386.h> |
|---|
| 24 | #include <i386/virtual.h> |
|---|
| 25 | |
|---|
| 26 | #define MISC_MAJOR 2 |
|---|
| 27 | |
|---|
| 28 | static int ZeroRead(struct File* file,BYTE* data,DWORD size) |
|---|
| 29 | { |
|---|
| 30 | ZeroMemory(data,size); |
|---|
| 31 | return size; |
|---|
| 32 | } |
|---|
| 33 | |
|---|
| 34 | static int ZeroMemoryMap(struct VNode* vNode, DWORD address, DWORD offset) |
|---|
| 35 | { |
|---|
| 36 | ZeroMemory(address, PAGE_SIZE); |
|---|
| 37 | return 0; |
|---|
| 38 | } |
|---|
| 39 | |
|---|
| 40 | static int NullWrite(struct File* file,BYTE* data,DWORD size) |
|---|
| 41 | { |
|---|
| 42 | return size; |
|---|
| 43 | } |
|---|
| 44 | |
|---|
| 45 | static int MemMemoryMap(struct VNode* vNode, DWORD address, DWORD offset) |
|---|
| 46 | { |
|---|
| 47 | |
|---|
| 48 | VirtMemMapPage(address, offset, PAGE_USER | PAGE_RW | PAGE_PRESENT); |
|---|
| 49 | return 0; |
|---|
| 50 | } |
|---|
| 51 | |
|---|
| 52 | struct FileOps nullOps={ |
|---|
| 53 | .write = NullWrite, |
|---|
| 54 | }; |
|---|
| 55 | |
|---|
| 56 | struct FileOps zeroOps={ |
|---|
| 57 | .read = ZeroRead, |
|---|
| 58 | .mMap = ZeroMemoryMap, |
|---|
| 59 | }; |
|---|
| 60 | |
|---|
| 61 | struct FileOps memOps={ |
|---|
| 62 | .mMap = MemMemoryMap, |
|---|
| 63 | }; |
|---|
| 64 | |
|---|
| 65 | int MiscInit() |
|---|
| 66 | { |
|---|
| 67 | DevAddDevice("Special/Null",MISC_MAJOR,0,DEVICE_CHAR,&nullOps); |
|---|
| 68 | DevAddDevice("Special/Zero",MISC_MAJOR,1,DEVICE_CHAR,&zeroOps); |
|---|
| 69 | DevAddDevice("Special/Memory",MISC_MAJOR,2,DEVICE_CHAR,&memOps); |
|---|
| 70 | |
|---|
| 71 | return 0; |
|---|
| 72 | } |
|---|
| 73 | |
|---|
| 74 | DeviceInit(MiscInit); |
|---|