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

        z502.h

        This include file is used by only the Z502.

        Revision History:
               1.3  July 1992:          Make structures smaller.
                                        Reduce size of SECTOR.
*********************************************************************/

#define         COST_OF_MEMORY_ACCESS           1L
#define         COST_OF_DISK_ACCESS             8L
#define         COST_OF_DELAY                   2L
#define         COST_OF_CLOCK                   3L
#define         COST_OF_TIMER                   2L
#define         COST_OF_MAKE_CONTEXT            20L
#define         COST_OF_DESTROY_CONTEXT         10L
#define         COST_OF_SWITCH_CONTEXT          15L
#define         COST_OF_SOFTWARE_TRAP           5L
#define         COST_OF_CPU_INSTRUCTION         1L
#define         COST_OF_CALL                    2L

#ifndef NULL
#define         NULL                            0
#endif

#define         EVENT_STRUCTURE_ID              (unsigned char)124
#define         SECTOR_STRUCTURE_ID             (unsigned char)125
#define         CONTEXT_STRUCTURE_ID            (unsigned char)126

#define         EVENT_RING_BUFFER_SIZE          16

typedef struct
    {
    INT32               *queue;
    INT32               time_of_event;
    INT16               vector;
    INT16               event_type;
    unsigned char       structure_id;
} EVENT;

/* Supports history which is dumped on a hardware panic */

typedef struct
    {
    INT32               time_of_request;
    INT32               time_of_event;
    INT16               vector;
    INT16               event_type;
} RING_EVENT;


typedef struct
    {
    INT32               *queue;
    unsigned char       structure_id;
    unsigned char       disk_id;
    unsigned char       cylinder;
    unsigned char       sector;
    char                sector_data[PGSIZE];
} SECTOR;

typedef struct
    {
    unsigned char       structure_id;
    void                *entry;
    UINT16              *page_table_ptr;
    INT16               page_table_len;
    INT16               pc;
    INT32               call_type;
    Z502_ARG            arg1, arg2, arg3, arg4, arg5, arg6;
    INT32               reg1, reg2, reg3, reg4, reg5;
    INT32               reg6, reg7, reg8, reg9;
    INT16               program_mode;
    INT16               mode_at_first_interrupt;        
    BOOL                fault_in_progress;
} CONTEXT;

typedef struct
    {
    INT16               last_cylinder;
    INT16               last_sector;
    BOOL                disk_in_use;
    EVENT               *event_ptr;
} DISK_STATE;

typedef struct
    {
    BOOL                timer_in_use;
    EVENT               *event_ptr;
} TIMER_STATE;
 
