/* Copyright (c) 1993 Xerox Corporation. All rights reserved. */ /* $Id$ $Date$ * * Virtual Dirty bytes */ #ifndef __PCR_VD_h #define __PCR_VD_h #include /* * The dirty byte for a logical page contains a dirty bit * and a write-protect disable count. * The implementation is not allowed to write-protect a page * for which the disable count is nonzero; such pages may * appear dirty. */ typedef volatile unsigned char PCR_VD_DB; #define PCR_VD_DB_dirtyBit 0x1 #define PCR_VD_DB_disabledOnce 0x2 #define PCR_VD_DB_disabledMask 0xfe /* * Initialization */ extern PCR_ERes PCR_VD_Start( unsigned long pageSize, void * addr, unsigned long bytes ); /* Start the package using the specified logical pagesize. Subsequent get/set/clear requests will only be allowed in the region [addr, addr+bytes). Pages in the region initially appear disabled and dirty. */ /* * Enable/Disable write-protecting pages. * * Disable-Enable pairs nest. * * These are intended to be fast enough to use in system * call wrappers. */ extern void PCR_VD_WriteProtectDisable( void *addr, unsigned long bytes ); /* Ensure that logical pages in the specified range will not be write-protected. Such pages may always appear dirty. It is acceptable for [addr..addr+bytes) to extend outside the address range specified to PCR_VD_Start. This is a no-op if called before PCR_VD_Start. */ extern void PCR_VD_WriteProtectEnable( void *addr, unsigned long bytes ); /* Undo the effect of a previous PCR_VD_WriteProtectDisable. This needs to be called once after PCR_VD_Start to enable checking pages. It is acceptable for [addr..addr+bytes) to extend outside the address range specified to PCR_VD_Start. Immediately after enabling, a page may always appear dirty. Like PCR_VD_WriteProtectDisable, this is a no-op if called before PCR_VD_Start. */ extern void PCR_VD_StackWriteProtectDisable( void *addr, unsigned long bytes ); extern void PCR_VD_StackWriteProtectEnable( void *addr, unsigned long bytes ); /* Accelerator when pages are known to be on thread stacks. */ #define PCR_VD_StackWriteProtectDisable(a,b) { } #define PCR_VD_StackWriteProtectEnable(a,b) { } /* for now the stacks are never write protected */ extern PCR_ERes PCR_VD_InitWriteProtectDisabled( void *addr, unsigned long bytes ); /* Set address range disabled as in PCR_VD_WriteProtectDisable. The client promises not to call PCR_VD_WriteProtectEnable on the range. Unlike PCR_VD_WriteProtectDisable, this proc is effective even if called before PCR_VD_Start; */ /* * Dirty Byte manipulation * * These procs return previous dirty byte values if db != NIL. */ extern PCR_ERes PCR_VD_Get( void *addr, unsigned long bytes, PCR_VD_DB *db ); extern PCR_ERes PCR_VD_Set( void *addr, unsigned long bytes, PCR_VD_DB *db ); extern PCR_ERes PCR_VD_Clear( void *addr, unsigned long bytes, PCR_VD_DB *db ); #endif /* !__PCR_VD_h */ /* $Log$ */