// PupMiscInit.bcpl -- Miscellaneous Services server

// Last modified January 13, 1979  2:20 PM by Boggs

get "Pup0.decl"
get "Pup1.decl"
get "PupMiscServ.decl"

external
[
// outgoing procedures
CreateMiscServ; DestroyMiscServ

// incoming procedures
MiscServCtx
CreateNameServ; CreateBootServ; CreateTimeServ
DestroyNameServ; DestroyBootServ; DestroyTimeServ
OpenLevel1Socket; CloseLevel1Socket
Allocate; Free; Enqueue; Unqueue
InitializeContext; Zero

// incoming statics
@ms
]

manifest msss = alto? 700, 200  //Misc serv stack size

//----------------------------------------------------------------------------
let CreateMiscServ(zone, ctxQ) be
//----------------------------------------------------------------------------
[
ms = Allocate(zone, lenMS); Zero(ms, lenMS)
ms>>MS.zone = zone
ms>>MS.ctxQ = ctxQ
ms>>MS.soc = Allocate(zone, lenPupSoc)
OpenLevel1Socket(ms>>MS.soc, table [ 0; 0; psMiscServ ])
ms>>MS.ctx = InitializeContext(Allocate(zone, msss), msss, MiscServCtx)
Enqueue(ctxQ, ms>>MS.ctx)

CreateNameServ()
CreateTimeServ()
CreateBootServ()
]

//----------------------------------------------------------------------------
and DestroyMiscServ() be
//----------------------------------------------------------------------------
[
CloseLevel1Socket(ms>>MS.soc)
Unqueue(ms>>MS.ctxQ, ms>>MS.ctx)
Free(ms>>MS.zone, ms>>MS.ctx)
DestroyNameServ()
DestroyTimeServ()
DestroyBootServ()
Free(ms>>MS.zone, ms)
]