Category : Alternate Operating Systems - Quarterdeck DesqView, CP/M, etc
Archive   : VMIXUTL.ZIP
Filename : $_MEM.H

 
Output of file : $_MEM.H contained in archive : VMIXUTL.ZIP
/*****************************************************************************
* ComSoft Library -- $_mem.h Copyright (C)1985-1992 by J. Anthony Borras
*
* DATE: Oct. 7, 1985 06-01-92
*
* NAME: $_mem.h -- include file for memory management functions
*
* SYNOPSIS:
* #INCLUDE "$_mem.h"
*
* FUNCTION:
* This header file includes the memory control structures
* and definitions.
*
* RETURNS:
* = N/A
*
*****************************************************************************/


/* OS types */

#define OSTYP_MSDOS 0
#define OSTYP_DRDOS 1
#define OSTYP_XDOS 2


/* SDA save areas */

#define MSDOS_SDA1 0x0004 /* relative to DOS stack pointer */
#define MSDOS_SDA2 0x004E /* inside the DOS SDA area */

#define DRDOS_SDA1 0x013D /* relative to DOS SDA segment */
#define DRDOS_SDA2 0x0500
#define DRDOS_SDA3 0 /* not used, save word at SDA pointer*/
#define DRDOS_SDA4 0x0852
#define DRDOS_SDA5 0x0A02

#define XDOS_SDA4 0x035E /* relative to DOS SDA segment */
#define XDOS_SDA5 0x0A64


/* MCB types */

#define MCB_MSDOS 'M'
#define MCB_END 'Z'
#define MCB_UMB 'U'


/* Page status constants */

#define PSW_LOCKED 0x0001 /* page is locked in memory*/
#define PSW_NONPG 0x0002 /* page is in nonpaged pool*/
#define PSW_STACK 0x0010 /* page assigned to stack */
#define PSW_IMAGE 0x0020 /* page assigned to image */
#define PSW_IRP 0x0040 /* page assigned to IRP */
#define PSW_SYSTEM 0x0080 /* system page */
#define PSW_FREE 0x0100 /* page is not in use */
#define PSW_ASSIGNED 0x0200 /* page assigned */
#define PSW_SWAP 0x1000 /* page has swap */

#define PSW_VIRTUAL 0x2000 /* page in vpgetbl */
#define PSW_EXTEND 0x8000 /* page in extended memory */
#define PSW_ERROR 0xF000 /* page has errors */


/* XMS access constants */

#define XMS_SEG 0xFFFF /* segment of XMS area */
#define XMS_MON 0x0100 /* load offset of MON_TEXT */
#define XMS_DATA 0x4010 /* offset of XMS VMASM_DATA*/
#define XMS_VDIR 0x8010 /* offset of XMS vpage dir */
#define XMS_VDMA 0xA010 /* offset of XMS DMA buffer*/


/* Virtual page access constants */

#define PAB_PRESENT 0x0001 /* page present in memory */
#define PAB_WRITE 0x0002 /* page is writable */
#define PAB_USER 0x0004 /* page has user priviledge*/
#define PAB_ACCESSD 0x0020 /* page was accessed */
#define PAB_DIRTY 0x0040 /* page was written to */


/* Descriptor access byte */

#define CODE_SEG_ACCESS 0x9B /* descriptor access byte */
#define DATA_SEG_ACCESS 0x93 /* descriptor access byte */


/* Memory Structure Declarations
Memory Control Block in memory data base */

struct MCB /* VMiX Memory Control Block */

{
char type; /* id byte 'M' 'V' or 'Z' */
BYTE psp[2]; /* program segment prefix */
BYTE size[2]; /* block size (para) */
BYTE empty;
unsigned int call_uid; /* uid of owner */
char fname[8]; /* file name loaded V4.X */
};

#define MCBSIZ sizeof(struct MCB)
#define MCBPSIZ (MCBSIZ >> 4)


struct PGE /* VMiX Memory Page Control Block */


{
unsigned int nextblk; /* next page not in block */
unsigned int psw; /* page 16bit status */
unsigned int call_uid; /* uid of owner */
unsigned int protmask; /* protection mask */
unsigned short selector; /* segment LDT descriptor */
};

extern struct PGE mem0as_pgetab[SYS_MAXPGE];
#define PGESIZ sizeof(struct PGE)


struct VPGE /* 386 virtual page table block */

{
BYTE pab; /* page 8bit access */
unsigned short blkaddr; /* physical address blk */
BYTE seg32;
};


struct DRVHDR /* DOS Device Driver Header */

{
struct DRVHDR *blink; /* linked backwards from NUL */
unsigned int attr;
unsigned short strategy;
unsigned short intsrv;
union {
BYTE name[8];
BYTE blkcnt;
} x;
};


struct SDA /* DOS Save Data Area template */

{
BYTE criterr; /* critical error flag */
BYTE indos; /* in DOS count */
BYTE critdrv; /* drive where err or FFh */
BYTE errloc; /* locus of last error */
int exterr; /* extended error code */
BYTE sigerr; /* suggest'd action for err*/
BYTE classerr; /* error class */
int *errptr; /* pointer to last error */
char *currdta; /* pointer to disk buf area*/
unsigned short currpsp; /* current PSP segment */
unsigned short ctrlbksp; /* stores SP across INT 23h*/
int retcode; /* process term return code*/
char currdrv; /* current drive */
BYTE extbk; /* extended break flag */
};

#define SDASIZ sizeof(struct SDA)


struct BCB3 /* DOS BUFFERS Control Block V3.X */

{
struct BCB3 *flink; /* pointer to next in chain*/
/* -1, if last */
BYTE logidrv; /* logical drive number */
/* FFh = not in use */
BYTE bufflg; /* bit: 7 6 5 4 3 2 1 0 */
/* |X|D|A|X|D|D|F|B|
| | | | | | | |
reserved__________________| | | | | | | |
Buffer Dirty______________| | | | | | |
Buffer referenced_________| | | | | |
reserved__________________| | | | |
sector in data area_______| | | |
sector in dir_____________| | |
sector in fat_____________| |
boot sector_______________| */

unsigned int sector; /* logical sector number */
BYTE nwrt; /* number copies to write */
/* if FAT = number of FATs */
/* if data, usually 1 */
BYTE secfat; /* sectors/FAT, or 0 */
/* sect offset btwn copies */
struct DPB *dpbptr; /* phys Drive Param Block */
int reserved;
BYTE buffer[SECSIZ];
int filler[2];
};


struct BCB4 /* DOS BUFFERS Control Block V4.X */

{
unsigned short blink; /* offset to prev in chain */
unsigned short flink; /* offset to next in chain */
BYTE logidrv; /* logical drive number */
/* FFh = not in use */
BYTE bufflg; /* bit: 7 6 5 4 3 2 1 0 */
/* |R|D|A|S|D|D|F|X|
| | | | | | | |
Remote Buffer_____________| | | | | | | |
Buffer Dirty______________| | | | | | |
Buffer referenced_________| | | | | |
search data remote buf____| | | | |
sector in data area_______| | | |
sector in dir_____________| | |
sector in fat_____________| |
reserved__________________| */

unsigned long sector; /* logical sector number */
BYTE nwrt; /* number copies to write */
/* if FAT = number of FATs */
/* if data, usually 1 */
unsigned int secfat; /* sectors/FAT, or 0 */
/* sect offset btwn copies */
struct DPB *dpbptr; /* phys Drive Param Block */
int refcnt; /* buf use count, if remote*/
char filler;
BYTE buffer[SECSIZ];
};


union BCB /* overlays versions 3.X and 4.X */

{
struct BCB3 v3;
struct BCB4 v4;
};

#define BCBSIZ sizeof(union BCB)
#define BCB3SIZ BCBSIZ - 4
#define BCB4SIZ BCBSIZ


struct BIT /* DOS BUFFERS Info Table V4.X */

{
struct BHT *bhtptr; /* pointer to array of BHTs*/
unsigned int numbht; /* number of hash chains */
char *lookahead; /* pointer to lookahead buf*/
/* 0, if none */
unsigned int numlka; /* number of lookahead sect*/
/* the y in BUFFERS = x,y */
BYTE type; /* 01 DOS >= 4.01 vs 4.00 */
unsigned short emsseg1; /* EMS seg for BUFFERS /XD */
unsigned int emspge1; /* EMS physpg number of seg*/
unsigned short emsseg2; /* unk EMS seg /XD */
unsigned int emspge2; /* EMS physpg number of seg*/
BYTE numpgfrm; /* number pg frames present*/
unsigned short workseg; /* one sector workspace */
/* in low mem /XS /XD */
unsigned int bufhnd; /* EMS handle for buffers */
/* 0, if none */
unsigned int bufpge; /* physpg used for bufs 255*/
int reserved_1;
unsigned short emsseg3; /* EMS physpg frame segment*/
int reserved_2;
BYTE emsflg; /* 0=/XS, 1=/XD, FFh=noEMS */
};

#define BITSIZ sizeof(struct BIT)


struct BHT /* DOS BUFFERS Hash Table Chain V4.X */
/* one entry per chain */
{
int hash; /* EMS logical pg# or -1 */
struct BCB4 *bcbptr; /* pointer to BCB head */
BYTE refcnt; /* dirty buffers counter */
BYTE reserved;
};

#define BHTSIZ sizeof(struct BHT)


struct DPB3 /* DOS Drive SubControl Block V3.X */

{
BYTE secfat; /* sectors/FAT */
unsigned int fdirsec; /* first directory sector */
struct DRVHDR *driver; /* pointer to device driver*/
BYTE media; /* media code */
BYTE access; /* access flag */
struct DPB *flink; /* pointer to next in chain*/
unsigned int luse_clust; /* last used cluster */
char filler[3]; /* FFFFh filler */
};


struct DPB4 /* DOS Drive SubControl Block V4.X */

{
unsigned int secfat; /* sectors/FAT */
unsigned int fdirsec; /* first directory sector */
struct DRVHDR *driver; /* pointer to device driver*/
BYTE media; /* media code */
BYTE access; /* access flag */
struct DPB *flink; /* pointer to next in chain*/
unsigned int luse_clust; /* last used cluster */
int filler; /* FFFFh filler */
};


union DPB34 /* overlays versions 3.X and 4.X */

{
struct DPB3 v3;
struct DPB4 v4;
};


struct DPB /* DOS Drive Parameter Block */

{
BYTE physdrv; /* physical drive number */
BYTE unit; /* unit number */
unsigned int secsiz; /* sector size, bytes */
BYTE clustsiz; /* cluster size, sectors */
BYTE p2; /* power of 2 */
unsigned int rsvsec; /* reserved sectors */
BYTE nfat; /* number of FATs */
unsigned int rootsiz; /* root dir size, sectors */
unsigned int fusesec; /* first usable sector */
unsigned int tot_clust; /* total count + 1 */
union DPB34 x;
};

#define DPBSIZ sizeof(struct DPB)
#define DPB3SIZ DPBSIZ - 1
#define DPB4SIZ DPBSIZ


struct DCB /* DOS Device Control Block */

{
int refcnt; /* number of handles to DCB*/
unsigned int mode; /* open access mode */
/* bit15:1 if open via FCB */
BYTE dirattr; /* dir entry attribute */
unsigned int devattr; /* device attributes */
/* bit15:1 if remote file */
/* bit14:1 keep date close */
/* includes drive number */
union {
struct DRVHDR *driver; /* pointer to: */
/* Driver, if char device */
struct DPB *dpbptr; /* DPB, if block device */
} x;
unsigned int fclust; /* first cluster number */
unsigned int filetime;
unsigned int filedate;
unsigned long filesiz;
unsigned long filepos;
unsigned int rel_clust; /* within file, last access*/
unsigned int abs_clust; /* 0, if never accessed */
unsigned int dirsec; /* directory sector w/entry*/
BYTE diridx; /* dir offset=20h * diridx */
char name[8]; /* device/file name */
char ext[3]; /* file extension */
struct SFT *share_prevsft; /* ptr to SFT sharing file */
unsigned int share_machine; /* net machine ID of owner */
unsigned short psp; /* PSP of owner */
unsigned short share_rec; /* offset of share record */
/* in SHARE.EXE code seg */
int reserved_1; /* 6 fill bytes for V4.X */
int reserved_2;
int reserved_3;
};

#define DCBSIZ sizeof(struct DCB)
#define DCB3SIZ DCBSIZ - 6
#define DCB4SIZ DCBSIZ


struct SFT /* DOS System File Table Chains */

{
struct SFT *flink; /* next DCB/FCB chain blk */
/* two different tables */
int count; /* number of blocks here */
struct DCB f[1]; /* anchor block */
};


struct LDB /* DOS Logical Drive Block */

{
char drive[2]; /* drv names begining at A:*/
char currpath[65]; /* current path for drive */
unsigned int drvflg; /* bit:15 4 3 2 1 0 9 8 */
/* |N|P|J|S|X|X|X|X|
| | | |
Network Drive_____________| | | |
Physical Drive____________| | |
Join______________________| |
Subst_____________________| */

struct DPB *dpbptr; /* phys Drive Param Block */
union {
struct {

unsigned int dir_fclust; /* curr dir first cluster */
/* root = 0 */
/* never accessed = FFFFh */
long reserved_1;
} local;
struct {
int *redir_ifsptr;
int params;
} net;
} x;
unsigned int skip; /* skip bytes to '\' offset*/
/* in curr path for root */
/* dir of logidrv, else # */
/* bytes in Subst/Join path*/
char reserved_1; /* DOS 4.X fields for IFS */
int *ifsptr; /* pointer to IFS driver */
/* 0, if native DOS */
int reserved_2;
};

#define LDBSIZ sizeof(struct LDB)
#define LDB3SIZ LDBSIZ - 7
#define LDB4SIZ LDBSIZ


struct DCT /* DOS Configuration Table */
/* or List of Lists */
{
int share_rcnt; /* share retry count */
int share_delay; /* share retry delay */
union BCB *currbuf; /* current DOS buffer */
unsigned short conboff; /* current read ptr in CON */
/* buf in dosseg 0 = empty */
unsigned short mcbhead; /* seg of MCB chain head */

/* INT 21/AX=52h pointer */
struct DPB *dpbhead; /* first drive param block */
struct SFT *dcbchain; /* FILES = */
struct DRVHDR *clkdrv; /* pointer to CLOCK$ headr */
struct DRVHDR *condrv; /* pointer to CON headr */
unsigned int maxsecsiz; /* maximum block size */
union { /* BUFFERS = */
union BCB *bcbhead; /* direct in V3.X */
struct BIT *emsbit; /* via BIT in V4.X */
} x;
struct LDB *ldbhead;
struct SFT *fcbchain; /* FCBS = */
int protfcbs; /* number FCBs kept if swap*/
BYTE nphysdrives; /* number of block devices */
BYTE nlogidrives; /* LASTDRIVE = */
struct DRVHDR nul; /* 18 byte NUL driver */
BYTE numjoin; /* number of joined drives */
};

#define DCTOFF -12 /* offset to top of DCT */


struct DESCRIPTOR

{
unsigned short limit_lo_word; /* segment size =< 64K */
unsigned short base_lo_word; /* 24 bit physical address */
BYTE base_hi_byte; /* which 64K base */
BYTE access_rights; /* access byte */
BYTE limit_hi_byte; /* segment size =< 16 Mbyte*/
BYTE base_top_byte; /* 32 bit physical address */
/* which 16 Mb base */
};

extern unsigned int mem0ui_nextgdt; /* next available gdt descriptor slot*/
#define DESCRIPTORSIZ sizeof(struct DESCRIPTOR)


struct PARA /* paragraph structure */

{
BYTE mem[16];
};


struct BLKM /* INT 15h blkmov struct */

{
int signature; /* VMiX 1944 signature */
int dummy[8];
unsigned long from; /* 32 bit source addr */
int wcnt; /* word count to move */
int fill;
unsigned long to; /* 32 bit destination addr */
};


struct MEMINFO /* VMiX memory manager data
used with vm_getmeminfo */
{
unsigned short code; /* VMiX C code segment */
unsigned short data; /* VMiX C data segment */
unsigned short asmcode; /* VMiX ASM code segment */
unsigned short asmdata; /* VMiX ASM data segment */
int p386; /* processor type */
int equipmnt; /* equipment type */
int biosfeat; /* bios type */
int ostype; /* save DOS manufacturer */
int dosver; /* save DOS version */
unsigned short dosseg; /* INT 21h segment */
unsigned short dossda; /* DOS Save Data Area offset */
unsigned short dosdata; /* DOS data segment */

unsigned short topseg; /* top of real memory (para) */
unsigned short page0; /* first page address (para) */
unsigned short epage0; /* first extended page (block) */
unsigned short tpa0; /* start of VMiX TPA (para) */
unsigned int maxlloc; /* maximum exec allocate (para) */
unsigned int cur_maxlloc; /* current maximum allocatable */
unsigned int maxpara; /* maximum paged memory (para) */
unsigned int maxeblk; /* maximum extended mem (blks) */
unsigned int maxpge; /* max pages in real mem pool */
unsigned int maxepg; /* max pages in extended mem pool */
int himem; /* himem in use flag */
int crtcmem; /* video memory in use flag */
struct DCT *dct; /* pointer to DOS Configuration Table*/
struct PGE *pgetab; /* pointer to paged memory table */
struct MCB *mcbhead; /* pointer to memory chain head */
unsigned short memfree; /* free MCB memory (para) */
struct VPGE *vpgedir; /* pointer to virtual page dir */
unsigned short vpgetab; /* block of virtual page table */
unsigned short currvpg; /* block of current page table */
unsigned short vvidbuf; /* block of virtual video buffer */
int dmascnt; /* 386 DMA sectors per cylinder */
char *dmabuf; /* 386 DMA transfer buffer */
char *currvbuf; /* pointer to current video buffer */
int gcurx; /* graphics cursor position */
int gcury;
BYTE chrxsiz; /* graphics character raster */
BYTE chrysiz;
int cursorsiz; /* current cursor size */
};

#define MEMINFOSIZ sizeof(struct MEMINFO)


extern int mem0i_dosvsiz; /* size of DOS to virtualize 4K blks */


/* In-line memory management definitions */

#define is_mcb(x) ((x)->type == MCB_MSDOS || (x)->type == MCB_UMB || \
(x)->type == MCB_END) /* test for MCB presence */
#define roundeb(x) (((x) + 1) & 0xFFFE) /* round up to even byte */
#define trunceb(x) ((x) & 0xFFFE) /* truncate to even byte */
#define roundpar(x) (((x) + 15) & 0xFFF0) /* round up to paragraph */
#define roundpge(x) (((x) + SYS_PAGE - 1) & 0xFE00) /* round 0x200 */
#define roundepg(x) (((x) + SYS_EPAGE - 1) & 0xFFFFF000) /* round 0x1000 */
#define byteswap(x) (((x) << 8) + ((x) >> 8)) /* byte swap */



  3 Responses to “Category : Alternate Operating Systems - Quarterdeck DesqView, CP/M, etc
Archive   : VMIXUTL.ZIP
Filename : $_MEM.H

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/