Migration Tutorial: Demand Paging and Internal MMC Cards

Explains how to change the MMC media driver for when demand paging is used.

Demand paging is a change made from Symbian platform v9.3 to how the Kernel uses RAM and storage media. This topic

For general information on migrating media drivers, see Migration Tutorial: Demand Paging and Media Drivers.

PSL changes

ROM and code paging can be enabled for a Multi Media Card (MMC) provided the card is non-removable. Removing a card would result in a kernel fault whenever the next page-in request is issued.

As the MMC media driver is entirely generic, a way of returning the paging related information contained in variantmedia.def to the generic part of the MMC stack is required. This is achieved by modifying the Platform Specific Layer (PSL) of the MMC stack to implement the DMMCStack::MDemandPagingInfo interface method:

class DMMCStack : public Dbase
    {
public:
    // etc…
    };

/** 
Demand paging support 
@see KInterfaceDemandPagingInfo
*/

class TDemandPagingInfo
    {
public:
    const TInt* iPagingDriveList;
    TInt  iDriveCount;
    TUint iPagingType;
    TInt  iReadShift;
    TUint iNumPages;
    TBool iWriteProtected;
    TUint iSpare[3];
    };

class MDemandPagingInfo
    {
public:
    virtual TInt DemandPagingInfo(TDemandPagingInfo& aInfo) = 0;
    // etc…
    };

This example is taken from the H4 HRP VariantMedia.def changes:

// Variant parameters for the MMC Controller (EPBUSMMC.DLL)
#define MMC_DRIVECOUNT 1
#define MMC_DRIVELIST 1
#define MMC_NUMMEDIA 1
#define MMC_DRIVENAME "MultiMediaCard0" 

#define MMC_PAGING_TYPE    DPagingDevice::ERom | DPagingDevice::ECode
#define MMC_PAGEDRIVELIST    1            // code paging from User Data
#define    MMC_PAGEDRIVECOUNT     1
#define MMC_NUM_PAGES        8

This example is from H4 MMC stack class definition:

class DDemandPagingInfo : public DMMCStack::MDemandPagingInfo
    {
public:
    virtual TInt DemandPagingInfo(DMMCStack::TDemandPagingInfo& aInfo);
    };


class DOmapMMCStack : public DCardStack
    {
public:
    virtual void GetInterface(TInterfaceId aInterfaceId, MInterface*& aInterfacePtr);
    // etc…
private:
    DDemandPagingInfo* iDemandPagingInfo;
    // etc…
    };

This example is from H4 MMC stack class implementation:

TInt DOmapMMCStack::Init()
    {
    if((iDemandPagingInfo = new DDemandPagingInfo()) == NULL)
        return KErrNoMemory;
    // etc…
    }

void DOmapMMCStack::GetInterface(TInterfaceId aInterfaceId, MInterface*& aInterfacePtr)
    {
    if (aInterfaceId == KInterfaceDemandPagingInfo)
        aInterfacePtr = (DMMCStack::MInterface*) iDemandPagingInfo;    
    // etc…
    }

TInt DDemandPagingInfo::DemandPagingInfo(DMMCStack::TDemandPagingInfo& aDemandPagingInfo)    
    {
    static const TInt pagingDriveNumbers[MMC_PAGEDRIVECOUNT] = {MMC_PAGEDRIVELIST};

    aDemandPagingInfo.iPagingDriveList = pagingDriveNumbers;
    aDemandPagingInfo.iDriveCount = MMC_PAGEDRIVECOUNT;
    aDemandPagingInfo.iPagingType = MMC_PAGING_TYPE;
    aDemandPagingInfo.iReadShift = 9;
    aDemandPagingInfo.iNumPages = MMC_NUM_PAGES;
    return KErrNone;
    }

Preparing an internal MMC card for ROM paging - MMCLoader

To support ROM paging from an internal card, the MMCLoader utility is used to write the ROM image to the card. MMCLoader can be found in e32utils/mmcloader.

The paged image is written as a normal file under the FAT file system. For paging to work however, the images file’s clusters must all be contiguous so, before doing anything else, MMCLoader formats the card. It then writes the paged part of the ROM to a file and checks that the file’s clusters are contiguous, which is normally the case as the card has just been formatted. A pointer to the image file is stored in the boot sector. When the board is rebooted the MMC/SD media driver reads the boot sector and uses this pointer to determine where the image file starts so that it can begin to satisfy paging requests.

MMCLoader takes the filename of the original ROM image file as an input. It then splits the given file into unpaged and paged files. The following code fragment shows the syntax:

Syntax: mmcloader <RomSrcFileName> <UnPagedRomDstFileName> <PagedRomDstFileName>
Eg:     mmcloader z:\\core.img d:\\sys$rom.bin d:\\sys$rom.pag