/* virtual memory maneger routine header T.Tsuda. , DSA April 14,1995 */ /* constants */ #define VMMEMSIZE 0x4000 #define VMADDMASK 0xffffc000l #ifdef MEMORY #define VMTBLSIZE 0x840 #define VMCMBSIZE 0x40 /* vmtable type */ #define VMCONV 0 #define VMEMS 1 /* vmtable use */ #define VMFREE 0 #define VMBLANK 1 #define VMINUSE 2 /* virtual memory table */ struct _vmtbl { unsigned long address; /* logical memoty block base address */ unsigned type : 2; /* physical memory type (conventional / EMS) */ unsigned use : 2; /* flag (free / inuse) */ unsigned page :12; /* EMS logical page number */ }; #define VMTABLE struct _vmtbl struct { int vmready; int emsready; unsigned char far *emsadd; /* far pointer of ems physical page */ unsigned long addbase; /* memory block logical address base */ unsigned long address; /* current logical address */ long step; /* logical address step */ unsigned int freeent; /* vmtable 1st free entry */ } vmm; /* externals */ VMTABLE *vmtable; /* virtual memory table */ int vmtblnum; /* vmtable number */ unsigned int vmentry; /* vmtable entry */ /* conventional memory block (16K byte) */ /* 'vmtable[number].address' mapping to 'vmcmtbl[number]' */ unsigned char far *vmcmtbl[VMCMBSIZE]; /* macros */ #define vmismap(add) ((vmtable[vmentry].use == VMINUSE) && (vmm.addbase == ((unsigned long)(add) & VMADDMASK))) #define setvmptr(ptr) ((ptr) = (vmtable[vmentry].type == VMEMS ? vmm.emsadd : vmcmtbl[vmentry]) + (vmm.address & ~VMADDMASK)) #endif /* function of prottypes */ int vmsearch(unsigned long address); /* description: mapping physical memory to primary virtual memory (for read) if no entry not allocation memory */ int vmmap(unsigned long address); /* description: mapping physical memory to primary virtual memory (for write) if no entry allocation memory */ unsigned char far *vmmap1(unsigned long address); /* description: mapping physical memory to secondary virtual memory (for read) if no entry not allocation memory */ int vmgarbag(void); /* description: garbage collection (free memory block that all data is 0xff) */ /* user function of prottypes */ int vminit(void); /* description: initialize virtual memory */ int vmflush(void); /* description: free virtual memory */ void vmaddr(unsigned long address); /* description: specified the current logical address */ void vmstep(long step); /* description: specified the increase of logical address */ unsigned char vmread(void); /* description: reads the current logical address of the virtual memory and add step to current address */ int vmwrite(unsigned char data); /* description: writes the data to the current logical address of the virtual memory and add step to current address */ int vmreadb(unsigned char *buf,unsigned int size); /* description: reads the bytes from the virtual memory location of logical address */ int vmwriteb(unsigned char *buf,unsigned int size); /* description: writes the bytes to the virtual memory location of logical address */ int vmmove(unsigned long sorce,unsigned long distin,unsigned long size); /* description: copys third argument bytes from the virtual memory location pointed to by first argument to the virtual memory location pointed to by second argument */ int vmfill(unsigned long address,unsigned char data,unsigned long size); /* description: fills third argument bytes second argument to the virtual memory location pointed to by first argument */ int vmerase(void); /* description: erase all location of virtual mamory */ unsigned long vmfirst(unsigned long start,unsigned long end); /* description search first used(not 0xff) address from start to end */ unsigned long vmlast(unsigned long start,unsigned long end); /* description search last used(not 0xff) address from start to end */