⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 objectheader.hxx

📁 C++ 编写的EROS RTOS
💻 HXX
📖 第 1 页 / 共 2 页
字号:
#ifndef __OBJECTHEADER_HXX__#define __OBJECTHEADER_HXX__/* * Copyright (C) 1998, 1999, 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. */#include <disk/ErosTypes.h>#include <disk/KeyRing.hxx>#include <arch-kerninc/KernTune.hxx>#ifndef __STDKEYTYPE_H__#include <eros/StdKeyType.h>#endif/* Enable the option OB_MOD_CHECK **in your configuration file** if * you are debugging the kernel, and want to verify that modified bits * are getting properly set.  Note that this option causes the * ObjectHeader structure to grow by a word, which requires that a * constant be suitably adjusted in the fast path implementation.  You * therefore should NOT simply #define the value here. *//* "Object Type" field values.  These capture simultaneously whether * the object is a page or a node and how the object is currently * being interpreted.  Note that the interpretation is a runtime * artifact, and is never stored to the disk. */struct ObType {  enum Type {    NtUnprepared,		/* unprepared vanilla node */    NtSegment,    NtProcessRoot,    NtKeyRegs,    NtRegAnnex,    NtFreeFrame,		/* unallocated */    NtLAST_NODE_TYPE = NtFreeFrame,    PtDataPage,			/* page holding a user data Page */    PtNewAlloc,			/* newly allocated frame, not yet typed */    PtKernelHeap,		/* in use as kernel heap */#ifdef USES_MAPPING_PAGES    PtMappingPage,		/* used in a virtual mapping table */#endif    PtDevicePage,		/* data page, but device memory */    PtFreeFrame			/* unallocated */  };#ifdef OPTION_DDB  static const char *ddb_name(uint8_t);#endif};/* OBJECT AGING POLICY: *  * Objects are brought in as NewBorn objects, and age until they reach * the Invalidate generation.  At that point all outstanding keys are * deprepared.  If they make it to the PageOut generation we kick them * out of memory (writing if necessary). *  * When an object is prepared, we conclude that it is an important * object, and promote it back to the NewBorn generation. *  * PROJECT: Some student should examine the issues associated with * aging policy management. */struct Age {  enum {    NewBorn = 0,		/* just loaded into memory */    LiveProc = 1,		/* node age for live processes */    NewLogPg = 2,		/* not as important as user pages. */    Invalidate = 6,		/* time to invalidate to see if active */    PageOut = 7,		/* time to page out if dirty */  };};struct KeyRing;struct SegWalk;struct ObjectTable;struct Process;struct Node;#define OHAZARD_NONE      0x1u#define OHAZARD_WRITE     0x1u#define OHAZARD_READ      0x2u#define OHAZARD_READWRITE 0x2u#define OFLG_DIRTY	0x01u	/* object has been modified */#define OFLG_REDIRTY	0x02u	/* object has been modified since */				/* write initiated */#if 0#define OFLG_PIN	0x04u	/* object pinned in memory */#endif#define OFLG_CURRENT	0x08u	/* current version */#define OFLG_CKPT	0x10u	/* checkpoint version */#define OFLG_IO		0x20u	/* object has active I/O in progress */#define OFLG_DISKCAPS	0x40u	/* capabilities to this version exist */				/* on disk *//* Note that the first three words of this structure must overlay * properly with the KeyRing structure defined in KeyType.hxx */struct ObjectHeader {  union {    KeyRing	kr;    /* Special relationship pointers if prepared node or mapping page */    ObjectHeader  *producer;	/* if mapping page */    ObjectHeader  *products;	/* if segment or page */    Process	  *context;	/* if prepared as Domain */    /*    ObjectHeader  *prevFree; */    void          *freeList;	/* used by malloc */#if 0    DuplexedIO    *ioReq;	/* if actively inbound */#endif  };  kva_t   pageAddr;		/* speed up ObHdrToPage! */    ObjectHeader   *next;		/* used by various chains */  #ifdef OPTION_OB_MOD_CHECK  uint32_t		CalcCheck() const;#endif  union {    struct {      ObCount	allocCount;      OID   	oid;#ifdef OPTION_OB_MOD_CHECK      uint32_t		check;		/* check field */#endif      /* Note: when I do background keys they should be unioned with the       * allocation count, since they only apply to mapping pages.       */      uint32_t	ioCount;	/* for object frames */#if 0      uint32_t	refCount;	/* for mapping pages */#endif    } ob;    struct {      struct Node *redSeg;	/* pointer to slot of keeper that				 * dominated this mapping frame */      uint64_t     redSpanBlss;	/* blss of seg spanned by redSeg */#ifdef KT_Wrapper      bool         wrapperProducer;#else      bool         redProducer;#endif    } mp;        /* The structure above is relevant to nodes also.  The structures     * below are only relevant to page-sized frames.     */    struct {      int32_t  sz;		/* object size.  -1 means encoded internally */      uint32_t mtype;		/* malloc type */    } malloc;    struct {      /* NOTE THIS IS NOT YET USED, AND REPRESENTS VERY TENTATIVE IDEAS */      ObjectHeader *first;	/* first frame in physical range */      uint32_t npage;		/* number of pages in physical range */    } p_range;  };    uint8_t		flags;  inline void SetFlags(uint32_t w)  {    flags |= w;  }  inline uint32_t GetFlags(uint32_t w) const  {    return (flags & w);  }  inline void ClearFlags(uint32_t w)  {    flags &= ~w;  }  inline void SetDirtyFlag()  {    flags |= (OFLG_DIRTY|OFLG_REDIRTY);  }  inline uint32_t IsDirty() const  {    return GetFlags(OFLG_DIRTY|OFLG_REDIRTY);  }    uint8_t	obType;		/* page type or node prepcode */  uint8_t	age;  /* FIX: producerNdx isn't really big enough given 32-slot nodes; on     machines that need this, it must hold log2(ndsz). */  uint8_t	producerNdx : 3; /* deal with map tbl/node non-congruence. */  uint8_t       producerBlss : 5; /* biased lss of map tbl producer. NOTE				     not the key, the object. */  uint8_t	rwProduct : 1;	/* indicates mapping image is RW version */  uint8_t	caProduct : 1;	/* indicates mapping image is callable version */  bool IsFree() const    {      return (obType == ObType::NtFreeFrame || obType == ObType::PtFreeFrame);    }    /* Object pin counts.  For the moment, there are several in order to   * let me debug the logic.  Eventually they should all be mergeable.   *    *   userPin -- pins held by the user thread.  Automatically   *              released whenever the thread yields or leaves the   * 		  kernel.   *    *   kernPin -- pins held by a kernel thread.  Must be released   *              explicitly.   *    * userPin and kernPin are acquired and released via the same   * interface -- Pin/Unpin.  Unpin is a no-op if the caller is a user

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -