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

📄 physmem.hxx

📁 C++ 编写的EROS RTOS
💻 HXX
字号:
#ifndef __PHYSMEM_HXX__#define __PHYSMEM_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 <kerninc/kernel.hxx>/* Descriptor for a physical memory allocation constraint. Actually, * this needs to be more detailed, because it also needs to describe * boundary crossing issues, but at the moment I'm not trying to deal * with that. *  * The current kernel implements only two general memory constraints: * word aligned at any address and page aligned at any address. The * general alignment and crossing constraint mechanism is currently * unimplemented, but the notion of a constraint structure is included * in anticipation of future ports that may require it. *//* FIX: bound should be inclusive limit, for representability! */struct PmemConstraint {  kpa_t base;  kpa_t bound;  unsigned align;} ;typedef struct PmemConstraint PmemConstraint;struct ObjectHeader;struct PmemInfo {  kpa_t     base;  kpa_t     bound;  uint32_t  type;		/* address type of this range */  uint32_t  readOnly;		/* are pages in region read-only? */  kpa_t     allocBase;		/* how much has kernel allocated? */  kpa_t     allocBound;		/* how much has kernel allocated? */#if 0  uint32_t  flags;		/* flags to be used by kernel */#endif  uint32_t  nPages;		/* number of pages allocated to the				 * object cache */  uint32_t  basepa;		/* base pa of that page range */  ObjectHeader *firstObHdr;	/* obHdr corresponding to baseva */} ;class PhysMem {  static kpsize_t MemAvailable(PmemConstraint *, unsigned unitSize, 			       bool needContiguous);public:  static PmemConstraint pages;  static PmemConstraint any;  static void Init();    static PmemInfo * ChooseRegion(kpsize_t sz, PmemConstraint *);  static PmemInfo *AddRegion(kpa_t base, kpa_t bound, uint32_t type, 			     bool readOnly);  static kpa_t Alloc(kpsize_t sz, PmemConstraint *);  /* FIX: This is called from the x86 code that builds the kernel   * virtual map, and it is wrong that it should be so. The kernel   * will soon need to support machines where there are more physical   * pages than there are virtual pages.  The solution is to adopt a   * bounded kernel heap, set up virtual mapping space for that, and   * then use kmem_alloc to populate it.   */  static kpsize_t TotalPhysicalPages();  static inline kpsize_t ContiguousBytes(PmemConstraint *mc)  {     return MemAvailable(mc, sizeof(uint8_t), true);   }  static kpsize_t ContiguousPages(PmemConstraint *mc)  {     return MemAvailable(mc, EROS_PAGE_SIZE, true);   }  static kpsize_t AvailBytes(PmemConstraint *mc)  {     return MemAvailable(mc, sizeof(uint8_t), false);   }  static kpsize_t AvailPages(PmemConstraint *mc)  {     return MemAvailable(mc, EROS_PAGE_SIZE, false);   }    static void PrintStatus();#ifdef OPTION_DDB  static void ddb_dump();#endif  static PmemInfo *pmemInfo;  static unsigned long nPmemInfo;  static kpa_t PhysicalPageBound;};#endif /* __PHYSMEM_HXX__ */

⌨️ 快捷键说明

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