[eros-cvs] cvs commit: eros/src/base/sys/libkey lk_devprivs_publishmem.c
shap@eros.cs.jhu.edu
shap@eros.cs.jhu.edu
Wed, 25 Jul 2001 00:50:08 -0400
shap 01/07/25 00:50:08
Modified: src/base/sys/arch/i486/boot memory.c
src/base/sys/arch/i486/kernel PageFault.cxx
src/base/sys/console cons_TextMode.cxx
src/base/sys/eros DevicePrivs.h
src/base/sys/kernel kern_Check.cxx kern_CoreObHash.cxx
kern_ObjectCache.cxx kern_ObjectHeader.cxx
kern_PhysMem.cxx kern_PhysPageSource.cxx
kern_heap.cxx
src/base/sys/kerninc BootInfo.h ObjectCache.hxx
ObjectHeader.hxx PhysMem.hxx
src/base/sys/key mk_DevicePrivs.cxx
Added: src/base/sys/libkey lk_devprivs_publishmem.c
Log:
We now have a mostly complete implementation for device memory.
Physical memory publish is implemented and works.
Kernel heap (malloc) is now tested and works.
Actual *use* of physical page keys seems to work.
Stub and order code added for publishmem
Test/sample coming momentarily.
Revision Changes Path
1.4 +6 -2 eros/src/base/sys/arch/i486/boot/memory.c
Index: memory.c
===================================================================
RCS file: /cvs/eros/src/base/sys/arch/i486/boot/memory.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- memory.c 2001/07/24 03:59:30 1.3
+++ memory.c 2001/07/25 04:50:07 1.4
@@ -53,6 +53,10 @@
* (hypothetically) exist, but they aren't worth the bother until
* somebody complains. I haven't actually seen one used for anything
* besides a boat anchor in quite some time.
+ *
+ * Hmm. No sooner did I add that then somebody discovered a boat
+ * anchor that was alive and well, and I had to re-introduce the
+ * memory forgery thing.
*/
static MemInfo *mallocSourceRegion;
@@ -365,8 +369,8 @@
case MI_RAMDISK:
addrType = "RamDisk: ";
break;
- case MI_VIDEO:
- addrType = "Video: ";
+ case MI_DEVICEMEM:
+ addrType = "Device: ";
break;
case MI_UNKNOWN:
addrType = "Unknown: ";
1.179 +2 -1 eros/src/base/sys/arch/i486/kernel/PageFault.cxx
Index: PageFault.cxx
===================================================================
RCS file: /cvs/eros/src/base/sys/arch/i486/kernel/PageFault.cxx,v
retrieving revision 1.178
retrieving revision 1.179
diff -u -r1.178 -r1.179
--- PageFault.cxx 2001/06/28 02:11:48 1.178
+++ PageFault.cxx 2001/07/25 04:50:07 1.179
@@ -868,7 +868,8 @@
thePTE.w_value = PTE_ZAPPED;
assert(wi.segObj);
- assert(wi.segObj->obType == ObType::PtDataPage);
+ assert(wi.segObj->obType == ObType::PtDataPage ||
+ wi.segObj->obType == ObType::PtDevicePage);
kpa_t pageAddr = 0;
1.2 +1 -1 eros/src/base/sys/console/cons_TextMode.cxx
Index: cons_TextMode.cxx
===================================================================
RCS file: /cvs/eros/src/base/sys/console/cons_TextMode.cxx,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- cons_TextMode.cxx 2001/07/24 03:59:30 1.1
+++ cons_TextMode.cxx 2001/07/25 04:50:07 1.2
@@ -97,7 +97,7 @@
static void
SetPosition(uint32_t pos, uint8_t c, Attr::Type attr)
{
- uint32_t vgaAttrs = WhiteOnBlack << 8;
+ uint16_t vgaAttrs = WhiteOnBlack << 8;
switch (attr) {
default:
1.4 +5 -0 eros/src/base/sys/eros/DevicePrivs.h
Index: DevicePrivs.h
===================================================================
RCS file: /cvs/eros/src/base/sys/eros/DevicePrivs.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- DevicePrivs.h 2001/06/18 18:51:09 1.3
+++ DevicePrivs.h 2001/07/25 04:50:08 1.4
@@ -31,6 +31,8 @@
#define OC_DevPrivs_DisableIRQ 4
#define OC_DevPrivs_WaitIRQ 5
+#define OC_DevPrivs_PublishMem 6
+
#define RC_DevPrivs_AllocFail 1
#ifndef __ASSEMBLER__
@@ -41,6 +43,9 @@
uint32_t devprivs_waitIRQ(uint32_t krDevPrivs, uint32_t irq);
uint32_t devprivs_enableIRQ(uint32_t krDevPrivs, uint32_t irq);
uint32_t devprivs_disableIRQ(uint32_t krDevPrivs, uint32_t irq);
+
+uint32_t devprivs_publishMem(uint32_t krDevPrivs, uint32_t begin,
+ uint32_t end);
#endif /* __ASSEMBLER__ */
1.29 +1 -1 eros/src/base/sys/kernel/kern_Check.cxx
Index: kern_Check.cxx
===================================================================
RCS file: /cvs/eros/src/base/sys/kernel/kern_Check.cxx,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -r1.28 -r1.29
--- kern_Check.cxx 2001/06/10 19:41:50 1.28
+++ kern_Check.cxx 2001/07/25 04:50:08 1.29
@@ -146,7 +146,7 @@
uint32_t chk = pPage->CalcCheck();
if (pPage->GetFlags(OFLG_DIRTY) != 0)
- MsgLog::printf("Frame %d Chk=0x%x CalcCheck=0x%x flgs=0x%02x ty=%d on pg 0x%08x\n",
+ MsgLog::printf("Frame %d Chk=0x%x CalcCheck=0x%x flgs=0x%02x ty=%d on pgHdr 0x%08x\n",
pg, pPage->ob.check, chk, pPage->flags,
pPage->obType, pPage);
1.44 +3 -1 eros/src/base/sys/kernel/kern_CoreObHash.cxx
Index: kern_CoreObHash.cxx
===================================================================
RCS file: /cvs/eros/src/base/sys/kernel/kern_CoreObHash.cxx,v
retrieving revision 1.43
retrieving revision 1.44
diff -u -r1.43 -r1.44
--- kern_CoreObHash.cxx 2001/06/10 19:41:50 1.43
+++ kern_CoreObHash.cxx 2001/07/25 04:50:08 1.44
@@ -167,7 +167,9 @@
if (obType <= ObType::NtLAST_NODE_TYPE)
obType = ObType::NtUnprepared;
-
+
+ if (obType == ObType::PtDevicePage)
+ obType = ObType::PtDataPage;
if (obType == ty) {
#if 0
1.126 +37 -23 eros/src/base/sys/kernel/kern_ObjectCache.cxx
Index: kern_ObjectCache.cxx
===================================================================
RCS file: /cvs/eros/src/base/sys/kernel/kern_ObjectCache.cxx,v
retrieving revision 1.125
retrieving revision 1.126
diff -u -r1.125 -r1.126
--- kern_ObjectCache.cxx 2001/07/03 03:54:08 1.125
+++ kern_ObjectCache.cxx 2001/07/25 04:50:08 1.126
@@ -157,16 +157,8 @@
* fix it.
*/
-#if 0
nPages = PhysMem::AvailPages(&PhysMem::pages);
- Depend_InitPageDependTable(nPages);
-#endif
-
- /* That took some, so recalculate: */
-
- nPages = PhysMem::AvailPages(&PhysMem::pages);
-
coreTable = new (0) ObjectHeader[nPages];
assert(coreTable);
@@ -174,16 +166,6 @@
MsgLog::printf("Allocated Page Headers: 0x%x at 0x%08x\n",
sizeof(ObjectHeader[nPages]), coreTable);
-#if 0
- /* Allocating the core table ate some of the available pages.
- * As a result, there will be a small number of core table entries
- * that are never used.
- */
-
- nPages = PhysMem::AvailPages(&PhysMem::pages);
-
- MsgLog::printf("alleged nPages = %d (0x%x)\n", nPages, nPages);
-#endif
/* Block the pages by class, allocate them, and recompute nPages.
* Link all pages onto the appropriate free list:
*/
@@ -266,6 +248,28 @@
firstFreePage = &coreTable[0];
}
+void
+ObjectCache::AddDevicePages(PmemInfo *pmi)
+{
+ pmi->nPages = (pmi->bound - pmi->base) / EROS_PAGE_SIZE;
+ pmi->basepa = pmi->base;
+
+ /* About to call operator new(): */
+ pmi->firstObHdr = new ((void *)1) ObjectHeader[pmi->nPages];
+
+ kpa_t framePa = pmi->basepa;
+ ObjectHeader *pObHdr = pmi->firstObHdr;
+
+ for (uint32_t pg = 0; pg < pmi->nPages; pg++) {
+ pObHdr->pageAddr = PTOV(framePa);
+ framePa += EROS_PAGE_SIZE;
+ pObHdr++;
+ }
+
+ /* Note that these pages do NOT go on the free list! */
+}
+
+
ObjectHeader*
ObjectCache::OIDtoObHdr(uint32_t /*cdaLo*/, uint16_t /*cdaHi*/)
{
@@ -303,7 +307,7 @@
for (unsigned rgn = 0; rgn < PhysMem::nPmemInfo; rgn++) {
PmemInfo *pmi= &PhysMem::pmemInfo[rgn];
- if (pmi->type != MI_MEMORY)
+ if (pmi->type != MI_MEMORY && pmi->type != MI_DEVICEMEM)
continue;
kva_t startpa = pmi->basepa;
@@ -332,7 +336,7 @@
for (unsigned rgn = 0; rgn < PhysMem::nPmemInfo; rgn++) {
PmemInfo *pmi= &PhysMem::pmemInfo[rgn];
- if (pmi->type != MI_MEMORY)
+ if (pmi->type != MI_MEMORY && pmi->type != MI_DEVICEMEM)
continue;
uint32_t wbase = (uint32_t) pmi->firstObHdr;
@@ -473,11 +477,11 @@
if (pObj->producer == 0) {
producerType = '?';
}
- else if (pObj->producer->obType == ObType::PtDataPage) {
- producerType = 'p';
+ else if (pObj->producer->obType <= ObType::NtLAST_NODE_TYPE) {
+ producerType = 'n';
}
else {
- producerType = 'n';
+ producerType = 'p';
}
}
@@ -761,6 +765,8 @@
pObj->TransLock();
+ assert( pObj->obType != ObType::PtDevicePage );
+
if (pObj->obType == ObType::PtDataPage) {
/* Object is now free of encumberance, but it wasn't an evictable
* object, and it may be dirty. We need to find another location
@@ -980,6 +986,14 @@
/* Some page types do not get aged: */
if (pObj->obType == ObType::PtNewAlloc) {
+ nStuck++;
+ continue;
+ }
+ if (pObj->obType == ObType::PtDevicePage) {
+ nStuck++;
+ continue;
+ }
+ if (pObj->obType == ObType::PtKernelHeap) {
nStuck++;
continue;
}
1.123 +13 -8 eros/src/base/sys/kernel/kern_ObjectHeader.cxx
Index: kern_ObjectHeader.cxx
===================================================================
RCS file: /cvs/eros/src/base/sys/kernel/kern_ObjectHeader.cxx,v
retrieving revision 1.122
retrieving revision 1.123
diff -u -r1.122 -r1.123
--- kern_ObjectHeader.cxx 2001/06/10 19:41:50 1.122
+++ kern_ObjectHeader.cxx 2001/07/25 04:50:08 1.123
@@ -49,21 +49,17 @@
const char * names[] = {
"NtUnprep ",
"NtSegment ",
- "NtWrapper ",
- "NtDomRoot ",
+ "NtProcRoot",
"NtKeyRegs ",
"NtRegAnnex",
"NtFreeFrm ",
"PtDataPage",
- "PtCapPage ",
- "PtAllocPot",
- "PtDrvrPage",
- "PtObjPot ",
- "PtLogPage ",
- "PtRawPage ",
+ "PtNewAlloc",
+ "PtKernHeap",
#ifdef USES_MAPPING_PAGES
"PtMapPage ",
#endif
+ "PtDevPage ",
"PtFreeFrm ",
0
};
@@ -367,6 +363,7 @@
assert (InvocationCommitted == false);
if (obType == ObType::PtDataPage ||
+ obType == ObType::PtDevicePage ||
obType <= ObType::NtLAST_NODE_TYPE)
assert(IsUserPinned());
@@ -480,6 +477,12 @@
kva_t pPage = ObjectCache::ObHdrToPage(this);
bzero((void*)pPage, EROS_PAGE_SIZE);
}
+ else if (obType == ObType::PtDevicePage) {
+ MsgLog::fatal("Rescind of device pages not tested -- see shap!\n");
+ InvalidateProducts();
+
+ /* Do not explicitly zero device pages -- might be microcode! */
+ }
else
MsgLog::fatal("Rescind of non-object!\n");
@@ -546,6 +549,7 @@
ObjectHeader::InvalidateProducts()
{
if (obType == ObType::PtDataPage ||
+ obType == ObType::PtDevicePage ||
obType == ObType::NtSegment) {
/* We need to zap the product chain (MAJOR bummer!) */
while (products) {
@@ -589,6 +593,7 @@
db_printf(" producer=0x%08x\n", producer);
break;
case ObType::PtDataPage:
+ case ObType::PtDevicePage:
case ObType::NtSegment:
{
ObjectHeader *oh = products;
1.36 +51 -29 eros/src/base/sys/kernel/kern_PhysMem.cxx
Index: kern_PhysMem.cxx
===================================================================
RCS file: /cvs/eros/src/base/sys/kernel/kern_PhysMem.cxx,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -r1.35 -r1.36
--- kern_PhysMem.cxx 2001/06/23 19:36:45 1.35
+++ kern_PhysMem.cxx 2001/07/25 04:50:08 1.36
@@ -53,31 +53,10 @@
void
PhysMem::Init()
{
- nPmemInfo = BootInfoPtr->nMemInfo;
-
for (unsigned i = 0; i < BootInfoPtr->nMemInfo; i++) {
MemInfo *pmi = &BootInfoPtr->memInfo[i];
- PmemInfo *kmi = &pmemInfo[i];
-
- kmi->base = pmi->base;
- kmi->bound = pmi->bound;
- kmi->type = pmi->type;
- kmi->nPages = 0;
- kmi->basepa = 0;
- kmi->firstObHdr = 0;
-
- if (pmi->type == MI_MEMORY) {
- kmi->allocBase = pmi->base;
- kmi->allocBound = pmi->bound;
- }
- else {
- kmi->allocBase = 0;
- kmi->allocBound = 0;
- }
-#if 0
- pmi->kernFlags = 0;
-#endif
+ (void) PhysMem::AddRegion(pmi->base, pmi->bound, pmi->type);
if ( (pmi->type == MI_MEMORY || pmi->type == MI_RAMDISK ||
pmi->type == MI_PRELOAD) &&
@@ -104,6 +83,45 @@
Alloc(constraint.bound - constraint.base, &constraint);
}
+PmemInfo *
+PhysMem::AddRegion(kpa_t base, kpa_t bound, uint32_t type)
+{
+ PmemInfo *kmi = &pmemInfo[nPmemInfo];
+
+ if (type == MI_DEVICEMEM) {
+ /* Do not do this check for the bootup cases, as some of those
+ * actually do overlap. */
+ for (unsigned int i = 0; i < nPmemInfo; i++) {
+ if (base >= pmemInfo[i].base && base < pmemInfo[i].bound)
+ return 0;
+ if (bound > pmemInfo[i].base && bound <= pmemInfo[i].bound)
+ return 0;
+ }
+ }
+
+ assert (nPmemInfo < MAX_MEMINFO);
+
+ kmi->base = base;
+ kmi->bound = bound;
+ kmi->type = type;
+ kmi->nPages = 0;
+ kmi->basepa = 0;
+ kmi->firstObHdr = 0;
+
+ if (type == MI_MEMORY) {
+ kmi->allocBase = base;
+ kmi->allocBound = bound;
+ }
+ else {
+ kmi->allocBase = 0;
+ kmi->allocBound = 0;
+ }
+
+ nPmemInfo++;
+
+ return kmi;
+}
+
kpsize_t
PhysMem::TotalPhysicalPages()
{
@@ -271,7 +289,7 @@
{
extern void db_printf(const char *fmt, ...);
- for (unsigned rgn = 0; rgn < BootInfoPtr->nMemInfo; rgn++) {
+ for (unsigned rgn = 0; rgn <nPmemInfo; rgn++) {
PmemInfo *kmi = &pmemInfo[rgn];
kpa_t base = kmi->allocBase;
@@ -300,15 +318,18 @@
#endif
#define NEW_STOP false
+extern void *malloc(size_t sz);
+
void *
operator new[](size_t sz, void *place)
{
void *v = 0;
- assert (place == 0);
+ if (place == 0)
+ v = KPAtoP(void *, PhysMem::Alloc(sz, &PhysMem::any));
+ else if (place == (void *) 1)
+ v = malloc(sz);
- v = KPAtoP(void *, PhysMem::Alloc(sz, &PhysMem::any));
-
DEBUG(new)
MsgLog::dprintf(NEW_STOP, "placement vec new grabs "
"0x%x (%d) at 0x%08x\n", sz,
@@ -322,9 +343,10 @@
{
void *v = 0;
- assert (place == 0);
-
- v = KPAtoP(void *, PhysMem::Alloc(sz, &PhysMem::any));
+ if (place == 0)
+ v = KPAtoP(void *, PhysMem::Alloc(sz, &PhysMem::any));
+ else if (place == (void *) 1)
+ v = malloc(sz);
DEBUG(new)
MsgLog::dprintf(NEW_STOP, "placement new grabs "
1.3 +38 -18 eros/src/base/sys/kernel/kern_PhysPageSource.cxx
Index: kern_PhysPageSource.cxx
===================================================================
RCS file: /cvs/eros/src/base/sys/kernel/kern_PhysPageSource.cxx,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- kern_PhysPageSource.cxx 2001/07/02 20:34:04 1.2
+++ kern_PhysPageSource.cxx 2001/07/25 04:50:08 1.3
@@ -94,12 +94,18 @@
kpa_t pgFrame = (oid - OID_RESERVED_PHYSRANGE) / EROS_OBJECTS_PER_FRAME;
pgFrame *= EROS_PAGE_SIZE;
- if (!ValidPhysPage(pmi, pgFrame))
+ if (!ValidPhysPage(pmi, pgFrame)) {
+ MsgLog::dprintf(true, "OID 0x%08x%08x invalid\n",
+ (unsigned long) (oid >> 32),
+ (unsigned long) (oid));
return 0;
+ }
ObjectHeader *pObj = ObjectCache::PhysPageToObHdr(pgFrame);
- if (pObj == 0)
+ if (pObj == 0) {
+ MsgLog::dprintf(true, "PhysPageSource::GetObject(): No header!\n");
return pObj;
+ }
#ifndef NDEBUG
kpa_t relFrameNdx = (pgFrame - pmi->basepa) / EROS_PAGE_SIZE;
@@ -108,50 +114,64 @@
ObjectCache::EvictFrame(pObj);
- bzero(pObj, sizeof(*pObj));
-
pObj->ob.oid = oid;
pObj->ob.allocCount = PhysPageAllocCount;
pObj->age = Age::NewBorn;
pObj->SetFlags(OFLG_CURRENT|OFLG_DISKCAPS);
assert (pObj->GetFlags(OFLG_CKPT|OFLG_DIRTY|OFLG_REDIRTY|OFLG_IO) == 0);
- pObj->obType = ObType::PtDataPage;
+ pObj->ob.ioCount = 0;
+ if (pmi->type == MI_DEVICEMEM) {
+ pObj->obType = ObType::PtDevicePage;
+
+ /* Do not bother with calculating the checksum value, as device
+ * memory is always considered dirty. */
+ pObj->SetFlags(OFLG_DIRTY);
+ }
+ else {
+ pObj->obType = ObType::PtDataPage;
#ifdef OPTION_OB_MOD_CHECK
- pObj->ob.check = pObj->CalcCheck();
+ pObj->ob.check = pObj->CalcCheck();
#endif
+ }
+
pObj->ResetKeyRing();
pObj->Intern();
- MsgLog::fatal("PhysPageSource::GetObject() unimplemented\n");
+ MsgLog::printf("PhysPageSource::GetObject() untested!\n");
return pObj;
}
bool
PhysPageSource::Invalidate(ObjectHeader *pObj)
{
- assert(pObj->obType == ObType::PtDataPage);
+ if (pObj->obType == ObType::PtDevicePage) {
+ MsgLog::fatal("PhysPageSource::Invalidate(PtDevicePage) is nonsense\n");
+ }
+ else {
+ assert(pObj->obType == ObType::PtDataPage);
- kpa_t pgFrame = pObj->pageAddr;
+ kpa_t pgFrame = pObj->pageAddr;
- if (!ValidPhysPage(pmi, pgFrame))
- return false;
+ if (!ValidPhysPage(pmi, pgFrame))
+ return false;
/* Okay, now this is a real nuisance. Free the frame and bump the
* global physical frame allocation count. */
- assert(pObj->kr.IsEmpty());
- assert(pObj->products == 0);
+ assert(pObj->kr.IsEmpty());
+ assert(pObj->products == 0);
- pObj->Unintern();
- pObj->ClearFlags(OFLG_DIRTY);
+ pObj->Unintern();
+ pObj->ClearFlags(OFLG_DIRTY);
/* FIX: What about transaction lock? */
- ObjectCache::ReleaseFrame(pObj);
+ ObjectCache::ReleaseFrame(pObj);
- PhysPageAllocCount ++;
+ PhysPageAllocCount ++;
- MsgLog::fatal("PhysPageSource::Detach() unimplemented\n");
+ MsgLog::fatal("PhysPageSource::Invalidate() unimplemented\n");
+ }
return false;
}
1.5 +11 -4 eros/src/base/sys/kernel/kern_heap.cxx
Index: kern_heap.cxx
===================================================================
RCS file: /cvs/eros/src/base/sys/kernel/kern_heap.cxx,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- kern_heap.cxx 2001/07/24 03:59:30 1.4
+++ kern_heap.cxx 2001/07/25 04:50:08 1.5
@@ -76,6 +76,7 @@
ObjectHeader *pHdr = ObjectCache::GrabPageFrame();
kpa_t pa = VTOP(ObjectCache::ObHdrToPage(pHdr));
pHdr->obType = ObType::PtKernelHeap;
+ pHdr->SetFlags(OFLG_DIRTY); /* always */
return pa;
}
}
@@ -110,10 +111,11 @@
void *
malloc(size_t nBytes)
{
- MsgLog::printf("malloc: heap_end, heap_def, heap_limit now 0x%08x 0x%08x 0x%08x\n",
- (unsigned) heap_end,
- (unsigned) heap_defined,
- (unsigned) heap_bound);
+ DEBUG(alloc)
+ MsgLog::printf("malloc: heap_end, heap_def, heap_limit now 0x%08x 0x%08x 0x%08x\n",
+ (unsigned) heap_end,
+ (unsigned) heap_defined,
+ (unsigned) heap_bound);
if (heap_bound - heap_end < nBytes)
MsgLog::fatal("Heap space exhausted\n");
@@ -129,5 +131,10 @@
*((char *) vp) = 0; /* cause kernel to crash if page not present */
heap_end += nBytes;
+ DEBUG(alloc)
+ MsgLog::dprintf(false,
+ "malloc() returns nBytes=%d at 0x%08x\n", nBytes,
+ vp);
+
return vp;
}
1.3 +6 -6 eros/src/base/sys/kerninc/BootInfo.h
Index: BootInfo.h
===================================================================
RCS file: /cvs/eros/src/base/sys/kerninc/BootInfo.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- BootInfo.h 2001/07/24 03:59:31 1.2
+++ BootInfo.h 2001/07/25 04:50:08 1.3
@@ -37,12 +37,12 @@
* about it.
*/
-#define MI_UNUSED 0 /* unused entry */
-#define MI_MEMORY 1 /* allocatable */
-#define MI_RESERVED 2 /* architecturally reserved regions */
-#define MI_BOOT 3 /* used by boot logic */
-#define MI_PRELOAD 4 /* a preloaded range */
-#define MI_VIDEO 5 /* console video buffer region */
+#define MI_UNUSED 0 /* unused entry */
+#define MI_MEMORY 1 /* allocatable */
+#define MI_RESERVED 2 /* architecturally reserved regions */
+#define MI_BOOT 3 /* used by boot logic */
+#define MI_PRELOAD 4 /* a preloaded range */
+#define MI_DEVICEMEM 5 /* device memory region */
#define MI_RAMDISK 254 /* temporary placeholder while we are
* still using the ramdisk boot logic. */
#define MI_UNKNOWN 255 /* unknown region */
1.38 +2 -0 eros/src/base/sys/kerninc/ObjectCache.hxx
Index: ObjectCache.hxx
===================================================================
RCS file: /cvs/eros/src/base/sys/kerninc/ObjectCache.hxx,v
retrieving revision 1.37
retrieving revision 1.38
diff -u -r1.37 -r1.38
--- ObjectCache.hxx 2001/06/10 19:41:51 1.37
+++ ObjectCache.hxx 2001/07/25 04:50:08 1.38
@@ -26,6 +26,7 @@
struct Depend;
struct ObjectSource;
+struct PmemInfo;
class ObjectCache {
static uint32_t nNodes;
@@ -68,6 +69,7 @@
static bool GrabThisFrame(ObjectHeader *);
+ static void AddDevicePages(PmemInfo *);
public:
static uint32_t TotalPages()
1.90 +1 -0 eros/src/base/sys/kerninc/ObjectHeader.hxx
Index: ObjectHeader.hxx
===================================================================
RCS file: /cvs/eros/src/base/sys/kerninc/ObjectHeader.hxx,v
retrieving revision 1.89
retrieving revision 1.90
diff -u -r1.89 -r1.90
--- ObjectHeader.hxx 2001/06/23 19:36:45 1.89
+++ ObjectHeader.hxx 2001/07/25 04:50:08 1.90
@@ -57,6 +57,7 @@
#ifdef USES_MAPPING_PAGES
PtMappingPage, /* used in a virtual mapping table */
#endif
+ PtDevicePage, /* data page, but device memory */
PtFreeFrame /* unallocated */
};
1.25 +2 -0 eros/src/base/sys/kerninc/PhysMem.hxx
Index: PhysMem.hxx
===================================================================
RCS file: /cvs/eros/src/base/sys/kerninc/PhysMem.hxx,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -r1.24 -r1.25
--- PhysMem.hxx 2001/06/23 19:36:45 1.24
+++ PhysMem.hxx 2001/07/25 04:50:08 1.25
@@ -70,6 +70,8 @@
static void Init();
static PmemInfo * ChooseRegion(kpsize_t sz, PmemConstraint *);
+ static PmemInfo *AddRegion(kpa_t base, kpa_t bound, uint32_t type);
+
static kpa_t Alloc(kpsize_t sz, PmemConstraint *);
/* FIX: This is called from the x86 code that builds the kernel
1.12 +31 -0 eros/src/base/sys/key/mk_DevicePrivs.cxx
Index: mk_DevicePrivs.cxx
===================================================================
RCS file: /cvs/eros/src/base/sys/key/mk_DevicePrivs.cxx,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- mk_DevicePrivs.cxx 2001/07/06 18:06:45 1.11
+++ mk_DevicePrivs.cxx 2001/07/25 04:50:08 1.12
@@ -25,6 +25,11 @@
#include <kerninc/ThreadPile.hxx>
#include <kerninc/IRQ.hxx>
#include <kerninc/MsgLog.hxx>
+#include <kerninc/PhysMem.hxx>
+#include <disk/DiskKey.hxx>
+#include <kerninc/BootInfo.h>
+#include <kerninc/ObjectSource.hxx>
+#include <kerninc/ObjectCache.hxx>
#include <eros/target.h>
#include <eros/Invoke.h>
#include <eros/StdKeyType.h>
@@ -197,6 +202,32 @@
break;
}
+ case OC_DevPrivs_PublishMem:
+ {
+ kpa_t base = inv.entry.w1;
+ kpa_t bound = inv.entry.w2;
+
+ if ((base % EROS_PAGE_SIZE) || (bound % EROS_PAGE_SIZE)) {
+ inv.exit.code = RC_RequestError;
+ break;
+ }
+
+ PmemInfo *pmi = PhysMem::AddRegion(base, bound, MI_DEVICEMEM);
+ ObjectCache::AddDevicePages(pmi);
+
+ if (pmi) {
+ ObjectSource *source;
+
+ source = new ((void *) 1) PhysPageSource(pmi);
+ ObjectCache::AddSource(source);
+ inv.exit.code = RC_OK;
+ }
+ else
+ inv.exit.code = RC_NoAccess;
+
+ break;
+ }
+
case OC_KeyType:
inv.exit.code = RC_OK;
inv.exit.w1 = inv.keyType;
1.1 eros/src/base/sys/libkey/lk_devprivs_publishmem.c
Index: lk_devprivs_publishmem.c
===================================================================
/*
* Copyright (C) 2001, Jonathan S. Shapiro.
*
* This file is part of the EROS Operating System runtime library.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This library 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 Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, 59 Temple Place - Suite 330 Boston, MA 02111-1307, USA.
*/
#include <eros/target.h>
#include <eros/Invoke.h>
#include <eros/DevicePrivs.h>
uint32_t
devprivs_publishMem(uint32_t krDevPrivs, uint32_t begin,
uint32_t end)
{
Message msg;
msg.snd_w1 = begin;
msg.snd_w2 = end;
msg.snd_w3 = 0;
msg.snd_key0 = KR_VOID;
msg.snd_key1 = KR_VOID;
msg.snd_key2 = KR_VOID;
msg.snd_key3 = KR_VOID;
msg.snd_len = 0; /* no data sent */
msg.rcv_key0 = KR_VOID;
msg.rcv_key1 = KR_VOID;
msg.rcv_key2 = KR_VOID;
msg.rcv_key3 = KR_VOID;
msg.rcv_len = 0;
msg.rcv_data = 0;
msg.snd_invKey = krDevPrivs;
msg.snd_code = OC_DevPrivs_PublishMem;
return CALL(&msg);
}