Ignore:
Timestamp:
Mar 27, 2003, 3:13:11 PM (22 years ago)
Author:
sandervl
Message:

memory map updates

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kernel32/mmap.h

    r9911 r9946  
    1 /* $Id: mmap.h,v 1.26 2003-03-06 10:44:34 sandervl Exp $ */
     1/* $Id: mmap.h,v 1.27 2003-03-27 14:13:11 sandervl Exp $ */
    22
    33/*
    44 * Memory mapped class
    55 *
    6  * Copyright 1999 Sander van Leeuwen (sandervl@xs4all.nl)
     6 * Copyright 1999-2003 Sander van Leeuwen (sandervl@xs4all.nl)
    77 *
    88 *
     
    1515#include <vmutex.h>
    1616#include "heapshared.h"
     17#include "asmutil.h"
     18
    1719
    1820#ifndef PAGE_SIZE
     
    2527#define MEMMAP_CRITSECTION_NAME "\\SEM32\\ODIN_MMAP.SEM"
    2628
    27 //commit 4 pages at once when the app accesses it
     29//commit 16 pages at once when the app accesses it
    2830#define NRPAGES_TOCOMMIT        16
    2931
     
    3638#define MMAP_FLUSHVIEW_ALL              0xFFFFFFFF
    3739
     40typedef enum
     41{
     42    PAGEVIEW_READONLY,
     43    PAGEVIEW_VIEW,
     44    PAGEVIEW_GUARD
     45} PAGEVIEW;
     46
    3847class Win32MemMapView;
    3948class Win32PeLdrImage;
    4049
    4150//******************************************************************************
     51//Memory mapping class
    4252//******************************************************************************
    4353class Win32MemMap
     
    4757   //Use by PE loader image class only:
    4858   Win32MemMap(Win32PeLdrImage *pImage, ULONG lpImageMem, ULONG size);
    49   ~Win32MemMap();
     59virtual ~Win32MemMap();
    5060
    5161virtual BOOL   Init(DWORD aMSize=0);
     
    5464virtual BOOL   unmapViewOfFile(LPVOID addr);
    5565
     66        BOOL   updateViewPages(ULONG offset, ULONG size, PAGEVIEW flags);
     67        BOOL   allocateMap();
     68
    5669   HFILE  getFileHandle()                { return hMemFile; };
    5770   LPSTR  getMemName()                   { return lpszMapName; };
     71   DWORD  getMapSize()                   { return mSize; };
    5872   DWORD  getProtFlags()                 { return mProtFlags; };
    59    BOOL   setProtFlags(DWORD dwNewProtect);
     73   void   setProtFlags(DWORD dwNewFlags) { mProtFlags = dwNewFlags; };
    6074   LPVOID getMappingAddr()               { return pMapping; };
    6175   DWORD  getProcessId()                 { return mProcessId;};
     
    6579
    6680   void   AddRef()                       { ++referenced; };
    67    void   Release();
     81   int    Release();
     82
     83   void   AddView()                      { ++nrMappings; };
     84   void   RemoveView()                   { --nrMappings; };
     85
     86
     87   void   markDirtyPages(int startpage, int nrpages);
     88   void   clearDirtyPages(int startpage, int nrpages);
     89   BOOL   isDirtyPage(int pagenr)        { return test_bit(pagenr, pWriteBitmap) != 0; };
    6890
    6991virtual BOOL   invalidatePages(ULONG offset, ULONG size);
     
    109131   void  *pMapping;
    110132
     133   char  *pWriteBitmap;
     134
    111135   ULONG  nrMappings;
    112136
     
    116140
    117141   Win32PeLdrImage *image;
     142
     143   Win32MemMapView *views;
    118144
    119145private:
     
    122148};
    123149//******************************************************************************
     150//Duplicate memory mapping class (duplicate map with different protection flags
     151//associated with an existing memory map)
     152//******************************************************************************
     153class Win32MemMapDup : public Win32MemMap
     154{
     155public:
     156            Win32MemMapDup(Win32MemMap *parent, HFILE hFile, ULONG size, ULONG fdwProtect, LPSTR lpszName);
     157   virtual ~Win32MemMapDup();
     158
     159virtual BOOL   Init(DWORD aMSize=0);
     160virtual BOOL   flushView(ULONG viewaddr, ULONG offset, ULONG cbFlush);
     161virtual LPVOID mapViewOfFile(ULONG size, ULONG offset, ULONG fdwAccess);
     162virtual BOOL   unmapViewOfFile(LPVOID addr);
     163
     164virtual BOOL   invalidatePages(ULONG offset, ULONG size);
     165virtual BOOL   commitGuardPage(ULONG ulFaultAddr, ULONG offset, BOOL fWriteAccess);
     166virtual BOOL   commitPage(ULONG ulFaultAddr, ULONG offset, BOOL fWriteAccess, int nrpages = NRPAGES_TOCOMMIT);
     167
     168protected:
     169            Win32MemMap *parent;
     170
     171private:
     172};
     173//******************************************************************************
    124174//Memory mapped file View Class
    125175//******************************************************************************
     
    127177{
    128178public:
    129    Win32MemMapView(Win32MemMap *map, ULONG offset, ULONG size, ULONG fdwAccess);
     179   Win32MemMapView(Win32MemMap *parent, ULONG offset, ULONG size, ULONG fdwAccess, Win32MemMap *owner = NULL);
    130180  ~Win32MemMapView();
     181
     182   BOOL   changePageFlags(ULONG offset, ULONG size, PAGEVIEW flags);
    131183
    132184   DWORD  getAccessFlags()               { return mfAccess; };
     
    138190
    139191Win32MemMap *getParentMap()              { return mParentMap;};
     192Win32MemMap *getOwnerMap()               { return mOwnerMap; };
     193
    140194   DWORD  getProcessId()                 { return mProcessId;};
     195
     196   void   markCOWPages(int startpage, int nrpages);
     197   BOOL   isCOWPage(int pagenr)          { return (pCOWBitmap) ? (test_bit(pagenr, pCOWBitmap) != 0) : FALSE; };
    141198
    142199static void             deleteViews(Win32MemMap *map);
    143200static Win32MemMap     *findMapByView(ULONG address, ULONG *offset = NULL,
    144201                                      ULONG accessType = MEMMAP_ACCESS_READ);
     202static int              findViews(Win32MemMap *map, int nrViews, Win32MemMapView *viewarray[]);
    145203static Win32MemMapView *findView(ULONG address);
    146204
     
    171229   void  *pMapView, *pShareViewAddr;
    172230
     231   char  *pCOWBitmap;
     232
     233   //parent map object; memory map that contains the original memory map
    173234   Win32MemMap *mParentMap;
     235   //owner map object (can be NULL); duplicate memory map that created this view
     236   Win32MemMap *mOwnerMap;
    174237
    175238private:
     
    182245//******************************************************************************
    183246
     247#pragma data_seg(_GLOBALDATA)
     248extern CRITICAL_SECTION_OS2 globalmapcritsect;
     249#pragma data_seg()
     250
    184251void InitializeMemMaps();
    185252
Note: See TracChangeset for help on using the changeset viewer.