// IfsDDMgrRes.bcpl -- Trident DiskDescriptor manager - resident
// Copyright Xerox Corporation 1979

// Last modified April 19, 1980  12:20 PM by Taft

get "IfsDDMgr.decl"

external
[
// Outgoing procedures
DDPageType; DDDOPAGEIO
DDPageGroupSize; DDPageGroupBase; DDPageGroupAlign

// Incoming procedures
ActOnDiskPages; CallProc
]


// Procedures called by VMem through the DDVMD object

//----------------------------------------------------------------------------
let DDPageType(vmd, vPage) = 1
//----------------------------------------------------------------------------

//----------------------------------------------------------------------------
and DDPageGroupSize(vmd, vPage) = -1 lshift logDDPageGroupSize
//----------------------------------------------------------------------------

//----------------------------------------------------------------------------
and DDPageGroupBase(vmd, vPage) = vPage & (-1 lshift logDDPageGroupSize)
//----------------------------------------------------------------------------

//----------------------------------------------------------------------------
and DDPageGroupAlign(vmd, vPage) = 1 lshift logDDPageGroupSize -1
//----------------------------------------------------------------------------

//----------------------------------------------------------------------------
and DDDOPAGEIO(vmd, vPage, core, np, wFlag) be
//----------------------------------------------------------------------------
[
let disk = vmd>>DDVMD.disk
let page = (vPage-vmd>>VMD.base) rshift logDDPageGroupSize
let lastPage = page + np rshift logDDPageGroupSize -1
let CAs = vec maxDDDiskPages
for p = page to lastPage do
   [ CAs!p = core; core = core+TFSwordsPerPage ]
// Must let the CallProc process execute the disk operation, due to
// an ugly recursion problem in IndexedPageIO/MorePageIO.
CallProc(ActOnDiskPages, disk, CAs, (lv disk>>TFSDSK.VDAdiskDD)-1,
 disk>>TFSDSK.fpDiskDescriptor, page, lastPage, (wFlag? DCwriteD, DCreadD))
]