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:
Michael Phipps 2002-07-30 00:29:00 +00:00
parent dc6d65badb
commit 8985112ee5
8 changed files with 44 additions and 31 deletions

View File

@ -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) status_t area::createArea(char *name, int pageCount,void **address, addressSpec type,pageState inState,protectType protect)
{ {
manager->lock(); 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 requested=(unsigned long)(*address); // Hold onto this to make sure that EXACT works...
unsigned long base=mapAddressSpecToAddress(type,requested,pageCount); 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; vpage *newPage;
vnode newVnode; vnode newVnode;
newVnode.fd=0; newVnode.fd=0;
newVnode.offset=0; newVnode.offset=0;
for (int i=0;i<pageCount;i++) 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); newPage = new vpage(base+PAGE_SIZE*i,newVnode,NULL,protect,inState);
vpages.add(newPage); vpages.add(newPage);
} }
@ -74,7 +74,7 @@ status_t area::createArea(char *name, int pageCount,void **address, addressSpec
end_address=base+pageCount*PAGE_SIZE; end_address=base+pageCount*PAGE_SIZE;
manager->unlock(); manager->unlock();
*address=(void *)base; *address=(void *)base;
printf ("unlocked in createArea\n"); printf ("area::createArea: unlocked in createArea\n");
} }
void area::freeArea(void) void area::freeArea(void)
@ -117,7 +117,7 @@ bool area::contains(void *address)
{ {
// no need to lock here... // no need to lock here...
unsigned long base=(unsigned long)(address); 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)); return ((start_address<=base) && (end_address>=base));
} }

View File

@ -40,11 +40,11 @@ area *areaManager::findArea(void *address)
for (struct node *cur=areas.rock;cur;cur=cur->next) for (struct node *cur=areas.rock;cur;cur=cur->next)
{ {
area *myArea=(area *)cur; area *myArea=(area *)cur;
printf ("Looking for %d\n",address); printf ("areaManager::findArea: Looking for %d\n",address);
if (myArea->contains(address)) if (myArea->contains(address))
return myArea; return myArea;
} }
printf ("findArea is giving up\n"); printf ("areaManager::findArea is giving up\n");
return NULL; return NULL;
} }

View File

@ -19,8 +19,8 @@ class list {
rock=newNode; rock=newNode;
nodeCount++; nodeCount++;
} }
int count(void) {printf ("About to return %d\n",nodeCount);return nodeCount;} 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 rock;} void *next(void) {nodeCount--;node *n=rock;if (rock) rock=rock->next;return n;}
void remove(void *in) void remove(void *in)
{ {
struct node *toNuke=(node *)in; struct node *toNuke=(node *)in;
@ -35,7 +35,7 @@ class list {
{ {
for (struct node *cur=rock;cur;cur=cur->next) 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; struct node *rock;

View File

@ -12,7 +12,7 @@ pageManager::pageManager(int pages)
void *area; 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)) 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); exit(1);
} }
for (int i=0;i<pages;i++) for (int i=0;i<pages;i++)
@ -22,31 +22,35 @@ pageManager::pageManager(int pages)
unusedLock=create_sem (1,"unused_lock"); unusedLock=create_sem (1,"unused_lock");
inUseLock=create_sem (1,"inuse_lock"); inUseLock=create_sem (1,"inuse_lock");
totalPages=pages; 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 *pageManager::getPage(void)
{ {
page *ret=NULL; page *ret=NULL;
printf ("Checking clean\n"); printf ("pageManager::getPage: Checking clean\n");
printf ("clean = %d\n", &clean); printf ("pageManager::getPage:cleanCount = %d\n", clean.nodeCount);
printf ("cleanCount = %d\n", clean.nodeCount);
if (clean.count()) if (clean.count())
{ {
printf ("locking clean\n"); printf ("pageManager::getPage:locking clean\n");
acquire_sem(cleanLock); acquire_sem(cleanLock);
printf ("locked clean\n"); printf ("pageManager::getPage:locked clean\n");
ret=(page *)clean.next(); ret=(page *)clean.next();
printf ("got next clean\n"); printf ("pageManager::getPage:got next clean\n");
release_sem(cleanLock); release_sem(cleanLock);
printf ("unlocked clean\n"); printf ("pageManager::getPage:unlocked clean\n");
} // This could fail if someone swoops in and steal our page. } // This could fail if someone swoops in and steal our page.
if (!ret && unused.count()) if (!ret && unused.count())
{ {
printf ("Checking unused\n"); printf ("pageManager::getPage:Checking unused\n");
acquire_sem(unusedLock); acquire_sem(unusedLock);
ret=(page *)unused.next(); ret=(page *)unused.next();
printf ("pageManager::getPage:got next unused\n");
release_sem(unusedLock); release_sem(unusedLock);
printf ("ret = %x\n",ret); printf ("pageManager::getPage:next unused = %x\n",ret);
if (ret) if (ret)
ret->zero(); ret->zero();
} // This could fail if someone swoops in and steal our page. } // This could fail if someone swoops in and steal our page.

View File

@ -8,23 +8,27 @@ swapFileManager::swapFileManager(void)
void swapFileManager::write_block(vnode node,void *loc,unsigned long size) 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); lseek(node.fd,SEEK_SET,node.offset);
write(node.fd,loc,size); write(node.fd,loc,size);
node.valid=true;
} }
void swapFileManager::read_block(vnode node,void *loc,unsigned long size) 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); 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); read(node.fd,loc,size);
} }
vnode swapFileManager::findNode(void) 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; vnode tmp;
tmp.fd=swapFile; tmp.fd=swapFile;
tmp.offset=maxNode+=PAGE_SIZE; // Can't ever free, swap file grows forever... :-( tmp.offset=maxNode+=PAGE_SIZE; // Can't ever free, swap file grows forever... :-(
tmp.valid=false;
return tmp; return tmp;
} }

View File

@ -11,5 +11,9 @@ int main(int argc,char **argv)
vm.setByte(addr,99); vm.setByte(addr,99);
printf ("addr = %d\n",addr); printf ("addr = %d\n",addr);
printf ("Byte = %d\n",vm.getByte(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; return 0;
} }

View File

@ -6,6 +6,7 @@ struct vnode
{ {
int fd; int fd;
unsigned long offset; unsigned long offset;
bool valid;
}; };
typedef unsigned long owningProcess; typedef unsigned long owningProcess;
#define B_OS_NAME_LENGTH 32 #define B_OS_NAME_LENGTH 32

View File

@ -47,7 +47,7 @@ void vpage::setProtection(protectType prot)
bool vpage::fault(void *fault_address, bool writeError) // true = OK, false = panic. bool vpage::fault(void *fault_address, bool writeError) // true = OK, false = panic.
{ // This is dispatched by the real interrupt handler, who locates us { // 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) if (writeError)
{ {
dirty=true; dirty=true;
@ -66,30 +66,30 @@ bool vpage::fault(void *fault_address, bool writeError) // true = OK, false = pa
} }
} }
physPage=pageMan.getPage(); 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... // 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... 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) char vpage::getByte(unsigned long address)
{ {
printf ("inside vpage::getByte; address = %d\n",address ); printf ("vpage::getByte: address = %d\n",address );
if (!physPage) if (!physPage)
fault((void *)(address),false); 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())); return *((char *)(address-start_address+physPage->getAddress()));
} }
void vpage::setByte(unsigned long address,char value) 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) if (!physPage)
fault((void *)(address),true); fault((void *)(address),true);
*((char *)(address-start_address+physPage->getAddress()))=value; *((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) int vpage::getInt(unsigned long address)