signed long ioman_findUnusedSpot(IOManager *ioman) { signed long r=-1; unsigned short c; unsigned char fr=0,lr=0xFF; for(c=0;c<ioman->numbuf;c++){ if(ioman_getUseCnt(ioman,c)==0){ if(!ioman_isWritable(c) && !fr){ fr=1; lr=0xFF; r=-1; } if(ioman_isWritable(c) && !fr){ if(ioman_getRefCnt(ioman,c)<=lr){ r=c; lr=ioman_getRefCnt(ioman,c); } } if(fr && !ioman_isWritable(c)){ if(ioman_getRefCnt(ioman,c)<=lr){ r=c; lr=ioman_getRefCnt(ioman,c); } } } } return(r); }
esint32 ioman_findUnusedSpot(IOManager *ioman) { esint32 r=-1; euint16 c; euint8 fr=0,lr=0xFF; for(c=0;c<ioman->numbuf;c++){ if(ioman_getUseCnt(ioman,c)==0){ if(!ioman_isWritable(c) && !fr){ fr=1; lr=0xFF; r=-1; } if(ioman_isWritable(c) && !fr){ if(ioman_getRefCnt(ioman,c)<=lr){ r=c; lr=ioman_getRefCnt(ioman,c); } } if(fr && !ioman_isWritable(c)){ if(ioman_getRefCnt(ioman,c)<=lr){ r=c; lr=ioman_getRefCnt(ioman,c); } } } } return(r); }
void ioman_printStatus(IOManager *ioman) { unsigned short c; DBG((TXT("IO-Manager -- Report\n====================\n"))); DBG((TXT("Buffer is %i sectors, from %p to %p\n"), ioman->numbuf,ioman->bufptr,ioman->bufptr+(ioman->numbuf*512))); for(c=0;c<ioman->numbuf;c++){ if(ioman_isValid(c)){ DBG((TXT("BP %3i\t SC %8li\t\t US %i\t RF %i\t %s %s\n"), c,ioman->sector[c],ioman_getUseCnt(ioman,c),ioman_getRefCnt(ioman,c), ioman_isUserBuf(c) ? "USRBUF" : " ", ioman_isWritable(c) ? "WRITABLE" : "READONLY")); } } }
signed char ioman_releaseSector(IOManager *ioman,unsigned char* buf) { unsigned short bp; bp=ioman_getBp(ioman,buf); ioman_decUseCnt(ioman,bp); if(ioman_getUseCnt(ioman,bp)==0 && ioman->itptr[bp]!=0){ if(ioman_isWritable(bp)){ ioman_flushSector(ioman,bp); } ioman_pop(ioman,bp); ioman_putSectorInCache(ioman,ioman->sector[bp],bp); } return(0); }
esint8 ioman_releaseSector(IOManager *ioman,euint8* buf) { euint16 bp; bp=ioman_getBp(ioman,buf); ioman_decUseCnt(ioman,bp); if(ioman_getUseCnt(ioman,bp)==0 && ioman->itptr[bp]!=0){ if(ioman_isWritable(bp)){ ioman_flushSector(ioman,bp); } ioman_pop(ioman,bp); ioman_putSectorInCache(ioman,ioman->sector[bp],bp); } return(0); }