📄 objectsource.hxx
字号:
#ifndef __OBJECTSOURCE_HXX__#define __OBJECTSOURCE_HXX__/* * Copyright (C) 2001, Jonathan S. Shapiro. * * This file is part of the EROS Operating System. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2, * or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *//* The ObjectRange class is a pure virtual base class that * encapsulates a producer/consumer of objects in a given OID * range. Objects in this range are produced by the corresponding * ObjectRange instance. */#include <kerninc/kernel.hxx>struct ObjectSource { const char *name; OID start; OID end; /* Fetch page (node) from the backing implementation for this range. On success, return an ObjectHeader (Node) pointer for the requested object, which has been brought into memory (if needed). On failure, return null pointer. It is entirely up to the range provider whether the presenting the object will cause some existing entry in the object cache to be evicted. For example, a ROM range may leave the object in ROM until a copy on write is performed. In the event that an object needs to be evicted, it is the responsibility of the range provider to choose a frame and tell the object cache manager to evict the current resident. This is often done by allowing the object cache ager to choose the frame. Note that the object cache evictor will very likely implement eviction by turning around and calling ObjectRange::Evict() for some range. Therefore, executing an inbound path (the GetPage/GetNode cases) must not preclude calling the outbound path on the same ObjectRange (the Evict procedure) prior to completion of the inbound path. The GetPage()/GetNode() implementation is free to yield. */ ObjectSource(const char *nm, OID first, OID last); virtual bool Detach() = 0; virtual ObjectHeader * GetObject(OID oid, ObType::Type obType, ObCount count, bool useCount) = 0; virtual bool IsRemovable(ObjectHeader *); /* Write a page to backing store. Note that the "responsible" * ObjectSource can refuse, in which case the page will not be * cleanable and will stay in memory. WritePage() is free to yield. */ virtual bool WriteBack(ObjectHeader *, bool inBackground = false) = 0; /* Unconditionally remove an object from the object cache. */ virtual bool Invalidate(ObjectHeader *) = 0; /* All ObjectSources are disjoint, but not all object sources * actually "implement" the entire range that they claim, so we need * to be able to inquire of them what ranges actually exist. */ virtual void FindFirstSubrange(OID curStart, OID curEnd, OID& subStart, OID& subEnd);#ifdef OPTION_DDB static void ddb_Dump();#endif};/********************************************************************** * * The in-memory object cache is an object source (at least for the * moment) * **********************************************************************/struct ObCacheSource : public ObjectSource { ObCacheSource(); bool Detach(); ObjectHeader * GetObject(OID oid, ObType::Type obType, ObCount count, bool useCount); bool WriteBack(ObjectHeader *, bool); bool Invalidate(ObjectHeader *);};struct DivisionInfo;/********************************************************************** * * Any preloaded ram regions are object sources * **********************************************************************/struct PreloadObSource : public ObjectSource { kva_t base; uint32_t nsecs; PreloadObSource(DivisionInfo *); bool Detach(); ObjectHeader * GetObject(OID oid, ObType::Type obType, ObCount count, bool useCount); bool WriteBack(ObjectHeader *, bool); bool Invalidate(ObjectHeader *);};/********************************************************************** * * The "Physical Page Range" is an object source * **********************************************************************/struct PmemInfo;struct PhysPageSource : public ObjectSource { PmemInfo *pmi; ObjectHeader *obHdrs; PhysPageSource(PmemInfo *); bool Detach(); ObjectHeader * GetObject(OID oid, ObType::Type obType, ObCount count, bool useCount); bool WriteBack(ObjectHeader *, bool); bool Invalidate(ObjectHeader *);};#endif /* __OBJECTSOURCE_HXX__ */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -