Fixing list.h (doh!) and some smaller changes.
Improved all of the printf's to have their method name, for easier tracking git-svn-id: file:///srv/svn/repos/haiku/trunk/current@538 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
dc6d65badb
commit
8985112ee5
@ -55,17 +55,17 @@ status_t area::createAreaMappingFile(char *name, int pageCount,void **address, a
|
||||
status_t area::createArea(char *name, int pageCount,void **address, addressSpec type,pageState inState,protectType protect)
|
||||
{
|
||||
manager->lock();
|
||||
printf ("Locked in createArea\n");
|
||||
printf ("area::createArea: Locked in createArea\n");
|
||||
unsigned long requested=(unsigned long)(*address); // Hold onto this to make sure that EXACT works...
|
||||
unsigned long base=mapAddressSpecToAddress(type,requested,pageCount);
|
||||
printf ("in area::createArea, base address = %d\n",base);
|
||||
printf ("area::createArea: base address = %d\n",base);
|
||||
vpage *newPage;
|
||||
vnode newVnode;
|
||||
newVnode.fd=0;
|
||||
newVnode.offset=0;
|
||||
for (int i=0;i<pageCount;i++)
|
||||
{
|
||||
printf ("in area::createArea, creating page = %d\n",i);
|
||||
printf ("in area::createArea: creating page = %d\n",i);
|
||||
newPage = new vpage(base+PAGE_SIZE*i,newVnode,NULL,protect,inState);
|
||||
vpages.add(newPage);
|
||||
}
|
||||
@ -74,7 +74,7 @@ status_t area::createArea(char *name, int pageCount,void **address, addressSpec
|
||||
end_address=base+pageCount*PAGE_SIZE;
|
||||
manager->unlock();
|
||||
*address=(void *)base;
|
||||
printf ("unlocked in createArea\n");
|
||||
printf ("area::createArea: unlocked in createArea\n");
|
||||
}
|
||||
|
||||
void area::freeArea(void)
|
||||
@ -117,7 +117,7 @@ bool area::contains(void *address)
|
||||
{
|
||||
// no need to lock here...
|
||||
unsigned long base=(unsigned long)(address);
|
||||
printf ("Inside contains; looking for %d in %d -- %d, value = %d\n",base,start_address,end_address, ((start_address<=base) && (end_address>=base)));
|
||||
printf ("area::contains: looking for %d in %d -- %d, value = %d\n",base,start_address,end_address, ((start_address<=base) && (end_address>=base)));
|
||||
|
||||
return ((start_address<=base) && (end_address>=base));
|
||||
}
|
||||
|
@ -40,11 +40,11 @@ area *areaManager::findArea(void *address)
|
||||
for (struct node *cur=areas.rock;cur;cur=cur->next)
|
||||
{
|
||||
area *myArea=(area *)cur;
|
||||
printf ("Looking for %d\n",address);
|
||||
printf ("areaManager::findArea: Looking for %d\n",address);
|
||||
if (myArea->contains(address))
|
||||
return myArea;
|
||||
}
|
||||
printf ("findArea is giving up\n");
|
||||
printf ("areaManager::findArea is giving up\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -19,8 +19,8 @@ class list {
|
||||
rock=newNode;
|
||||
nodeCount++;
|
||||
}
|
||||
int count(void) {printf ("About to return %d\n",nodeCount);return nodeCount;}
|
||||
void *next(void) {nodeCount--;node *n=rock;if (rock) rock=rock->next;return rock;}
|
||||
int count(void) {printf ("list::count: About to return %d\n",nodeCount);return nodeCount;}
|
||||
void *next(void) {nodeCount--;node *n=rock;if (rock) rock=rock->next;return n;}
|
||||
void remove(void *in)
|
||||
{
|
||||
struct node *toNuke=(node *)in;
|
||||
@ -35,7 +35,7 @@ class list {
|
||||
{
|
||||
for (struct node *cur=rock;cur;cur=cur->next)
|
||||
{
|
||||
printf ("At %x, next = %x\n",cur,cur->next);
|
||||
printf ("list::dump: At %x, next = %x\n",cur,cur->next);
|
||||
}
|
||||
}
|
||||
struct node *rock;
|
||||
|
@ -12,7 +12,7 @@ pageManager::pageManager(int pages)
|
||||
void *area;
|
||||
if (0>=create_area("vm_test",&area,B_ANY_ADDRESS,B_PAGE_SIZE*pages,B_NO_LOCK,B_READ_AREA|B_WRITE_AREA))
|
||||
{
|
||||
printf ("No memory!\n");
|
||||
printf ("pageManager::pageManager: No memory!\n");
|
||||
exit(1);
|
||||
}
|
||||
for (int i=0;i<pages;i++)
|
||||
@ -22,31 +22,35 @@ pageManager::pageManager(int pages)
|
||||
unusedLock=create_sem (1,"unused_lock");
|
||||
inUseLock=create_sem (1,"inuse_lock");
|
||||
totalPages=pages;
|
||||
printf ("pageManager::pageManager: About to dump the clean pages (should be 0):\n\n");
|
||||
clean.dump();
|
||||
printf ("pageManager::pageManager: About to dump the unused pages (should not be 0):\n\n");
|
||||
unused.dump();
|
||||
}
|
||||
|
||||
page *pageManager::getPage(void)
|
||||
{
|
||||
page *ret=NULL;
|
||||
printf ("Checking clean\n");
|
||||
printf ("clean = %d\n", &clean);
|
||||
printf ("cleanCount = %d\n", clean.nodeCount);
|
||||
printf ("pageManager::getPage: Checking clean\n");
|
||||
printf ("pageManager::getPage:cleanCount = %d\n", clean.nodeCount);
|
||||
if (clean.count())
|
||||
{
|
||||
printf ("locking clean\n");
|
||||
printf ("pageManager::getPage:locking clean\n");
|
||||
acquire_sem(cleanLock);
|
||||
printf ("locked clean\n");
|
||||
printf ("pageManager::getPage:locked clean\n");
|
||||
ret=(page *)clean.next();
|
||||
printf ("got next clean\n");
|
||||
printf ("pageManager::getPage:got next clean\n");
|
||||
release_sem(cleanLock);
|
||||
printf ("unlocked clean\n");
|
||||
printf ("pageManager::getPage:unlocked clean\n");
|
||||
} // This could fail if someone swoops in and steal our page.
|
||||
if (!ret && unused.count())
|
||||
{
|
||||
printf ("Checking unused\n");
|
||||
printf ("pageManager::getPage:Checking unused\n");
|
||||
acquire_sem(unusedLock);
|
||||
ret=(page *)unused.next();
|
||||
printf ("pageManager::getPage:got next unused\n");
|
||||
release_sem(unusedLock);
|
||||
printf ("ret = %x\n",ret);
|
||||
printf ("pageManager::getPage:next unused = %x\n",ret);
|
||||
if (ret)
|
||||
ret->zero();
|
||||
} // This could fail if someone swoops in and steal our page.
|
||||
|
@ -8,23 +8,27 @@ swapFileManager::swapFileManager(void)
|
||||
|
||||
void swapFileManager::write_block(vnode node,void *loc,unsigned long size)
|
||||
{
|
||||
printf ("writing, node.fd = %d, node.offset = %d\n",node.fd, node.offset);
|
||||
printf ("swapFileManager::write_block: writing, node.fd = %d, node.offset = %d\n",node.fd, node.offset);
|
||||
lseek(node.fd,SEEK_SET,node.offset);
|
||||
write(node.fd,loc,size);
|
||||
node.valid=true;
|
||||
}
|
||||
|
||||
void swapFileManager::read_block(vnode node,void *loc,unsigned long size)
|
||||
{
|
||||
printf ("reading, node.fd = %d, node.offset = %d\n",node.fd, node.offset);
|
||||
printf ("swapFileManager::read_block: reading, node.fd = %d, node.offset = %d\n",node.fd, node.offset);
|
||||
lseek(node.fd,SEEK_SET,node.offset);
|
||||
if (node.valid==false)
|
||||
return; // Do nothing. This prevents "garbage" data on disk from being read in...
|
||||
read(node.fd,loc,size);
|
||||
}
|
||||
|
||||
vnode swapFileManager::findNode(void)
|
||||
{
|
||||
printf ("Finding a new node for you master\n");
|
||||
printf ("swapFileManager::findNode: Finding a new node for you, Master\n");
|
||||
vnode tmp;
|
||||
tmp.fd=swapFile;
|
||||
tmp.offset=maxNode+=PAGE_SIZE; // Can't ever free, swap file grows forever... :-(
|
||||
tmp.valid=false;
|
||||
return tmp;
|
||||
}
|
||||
|
@ -11,5 +11,9 @@ int main(int argc,char **argv)
|
||||
vm.setByte(addr,99);
|
||||
printf ("addr = %d\n",addr);
|
||||
printf ("Byte = %d\n",vm.getByte(addr));
|
||||
printf ("\n\n\n\n\n");
|
||||
vm.setByte(addr+4097,99);
|
||||
printf ("addr = %d\n",addr);
|
||||
printf ("Byte = %d\n",vm.getByte(addr));
|
||||
return 0;
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ struct vnode
|
||||
{
|
||||
int fd;
|
||||
unsigned long offset;
|
||||
bool valid;
|
||||
};
|
||||
typedef unsigned long owningProcess;
|
||||
#define B_OS_NAME_LENGTH 32
|
||||
|
@ -47,7 +47,7 @@ void vpage::setProtection(protectType prot)
|
||||
|
||||
bool vpage::fault(void *fault_address, bool writeError) // true = OK, false = panic.
|
||||
{ // This is dispatched by the real interrupt handler, who locates us
|
||||
printf ("Inside fault; address = %d, write = %s\n",(unsigned long) fault_address,((writeError)?"true":"false"));
|
||||
printf ("vpage::fault: address = %d, write = %s\n",(unsigned long) fault_address,((writeError)?"true":"false"));
|
||||
if (writeError)
|
||||
{
|
||||
dirty=true;
|
||||
@ -66,30 +66,30 @@ bool vpage::fault(void *fault_address, bool writeError) // true = OK, false = pa
|
||||
}
|
||||
}
|
||||
physPage=pageMan.getPage();
|
||||
printf ("New page allocated! address = %s\n",physPage->getAddress());
|
||||
printf ("vpage::fault: New page allocated! address = %x\n",physPage->getAddress());
|
||||
// Update the architecture specific stuff here...
|
||||
// This refresh is unneeded if the code was never written out...
|
||||
// This refresh is unneeded if the data was never written out...
|
||||
refresh(); // I wonder if these vnode calls are safe during an interrupt...
|
||||
printf ("Refreshed\n");
|
||||
printf ("vpage::fault: Refreshed\n");
|
||||
|
||||
}
|
||||
|
||||
char vpage::getByte(unsigned long address)
|
||||
{
|
||||
printf ("inside vpage::getByte; address = %d\n",address );
|
||||
printf ("vpage::getByte: address = %d\n",address );
|
||||
if (!physPage)
|
||||
fault((void *)(address),false);
|
||||
printf ("About to return %d\n", *((char *)(address-start_address+physPage->getAddress())));
|
||||
printf ("vpage::getByte: About to return %d\n", *((char *)(address-start_address+physPage->getAddress())));
|
||||
return *((char *)(address-start_address+physPage->getAddress()));
|
||||
}
|
||||
|
||||
void vpage::setByte(unsigned long address,char value)
|
||||
{
|
||||
printf ("inside vpage::setByte; address = %d, value = %d\n",address, value);
|
||||
printf ("vpage::setByte: address = %d, value = %d\n",address, value);
|
||||
if (!physPage)
|
||||
fault((void *)(address),true);
|
||||
*((char *)(address-start_address+physPage->getAddress()))=value;
|
||||
printf ("inside vpage::setByte; physical address = %d, value = %d\n",physPage->getAddress(), *((char *)(physPage->getAddress())));
|
||||
printf ("vpage::setByte: physical address = %d, value = %d\n",physPage->getAddress(), *((char *)(physPage->getAddress())));
|
||||
}
|
||||
|
||||
int vpage::getInt(unsigned long address)
|
||||
|
Loading…
Reference in New Issue
Block a user