/* #define DEBUG */

/*************************************************
Header file for LOADER.  The source files
are: main.c, bit.c, vmem.c, and tables.c.

Written by:  Douglas Braun
             99 Summit Rd.
	     Riverside, CT 06878

July 1, 1985

**************************************************/

#include <stdio.h>

/* The following is only useful for the CW/C compiler */

#define printf qprintf

/* These are defaults for the various table sizes. */

#define D_MAX_OFFSETS 100
#define D_MAX_SYMBOLS 600
#define D_MAX_CHAINS 6500

/* These are values of the address type field of the .REL format */

#define ABSOLUTE 0
#define PROGREL 1
#define DATAREL 2
#define COMMONREL 3

/* These define values of the segment list status field */

#define UNTOUCHED 0
#define NOBUFFER 1
#define CLEAN 2
#define DIRTY 3

/* values of swapdir */

#define TOP 1
#define BOTTOM 2

/* The following function in CW/C gives the amount of memory available
for malloc, etc. */

unsigned maxsbrk();


typedef struct segment
{
    char status;
    char filler;
    char *buffer;

} SEGMENT, *SEGPTR;


typedef char BIT;


/* An "A field" in the .REL format */

typedef struct afield
{
    char addrtype;
    int address;
} AFIELD;


/* A "B field" in the .REL format */

typedef struct bfield
{
    char b_symbol[9];
} BFIELD;


/* An element of the offset table */

typedef struct offset
{
    unsigned o_address;   /* Where to plug it in */
    unsigned o_value;     /* What to plug in */
} OFFSET, *OFFSETPTR;


/* An entry in a liat of chains */

typedef struct chain
{
    struct chain *c_next;  /* Next in linked list */
    unsigned c_head;       /* Memory location of head of chain */
} CHAIN, *CHAINPTR;


/* An element of the symbol table */

typedef struct symbol
{
    char s_defined;    /* TRUE if defined */
    char s_name[9];   /* 8 chars plus null */
    CHAIN *s_chain;    /* Pointer to chain list if undefined */
    unsigned s_value;  /* Value if defined */
} SYMBOL, *SYMBOLPTR;
