event.h 3.79 KB
/*
 * Copyright (C) 1998 by the Board of Trustees
 *    of Leland Stanford Junior University.
 * Copyright (C) 1998 Digital Equipment Corporation
 *
 * This file is part of the SimOS distribution.
 * See LICENSE file for terms of the license.
 *
 */

#ifndef _EVENT_H_
#define _EVENT_H_

#include "thread.h"

/*
 * Definition of the event structure 
 */

/* a constant greater than any thread's time value */
#define MAXTIME ( ((unsigned ) (~0)) >> 1 )

typedef struct event {
    aint_time_t time;		/* at which the event occurred */
    aint_time_t *cpu_time;	/* accumulated cpu_time of this process */
    aint_time_t duration;	/* time that an unblocked process spent
				   waiting */ 
    struct event *next;		/* used in E_UNBLOCK_LIST */
    int pid;
    short type;			/* of instruction */
    long utype;			/* user-defined type */
    long iaddr;			/* instruction address */
    long vaddr;			/* the effective address the traced program
				   sees */ 
    long paddr;			/* the real address in memory */
    struct event *pevent;	/* to another event structure */
#ifdef gone
    struct icode *picode;	/* Passed only to sim_inst */
#endif
    int size;			/* size of data for read/write */
    long data;			/* data value for read/write */
    void *sptr;			/* used by talk scheduler when a task blocks */
    char *fname;		/* function name if type E_FUNCTION */
    long arg1;			/* args filled in by aint on E_FUNCTION
				   event */
    long arg2;
    long arg3;
    long arg4;
    long rval;			/* return value from malloc() type calls */
    long raddr;			/* return address */
    long raddr2;		/* caller's return address (more useful) */
} event_t, *event_ptr;

#define E_INSTR    0x0
#define E_SPECIAL  0x40

#define E_READ     0x80
#define E_WRITE    0x100
#define E_MEM_REF  (E_READ|E_WRITE)

#define E_SHARED   0x200

/* User defined event type */
#define E_USER     0x400

/* User defined function */
#define E_UFUNC    0x800

#define E_FLOAT    0x1000

#define E_BARRIER  0x2000

#define E_LD_L     0x4000
#define E_ST_C     0x8000
#define E_LOCK     (E_LD_L|E_ST_C)

/* the special types */
#define E_FORK  (E_SPECIAL | 1)
#define E_M_FORK  (E_SPECIAL | 2)
#define E_YIELD  (E_SPECIAL | 3)
#define E_DONE   (E_SPECIAL | 4)
#define E_BLOCK  (E_SPECIAL | 5)
#define E_UNBLOCK (E_SPECIAL | 6)
#define E_LOCK_ATTEMPT (E_SPECIAL | 7)
#define E_LOCK_ACQUIRE (E_SPECIAL | 8)
#define E_LOCK_RELEASE (E_SPECIAL | 9)
#define E_BARRIER_ATTEMPT (E_SPECIAL | 10)
#define E_BARRIER_ACQUIRE (E_SPECIAL | 11)
#define E_PSEMA_ATTEMPT (E_SPECIAL | 12)
#define E_PSEMA_ACQUIRE (E_SPECIAL | 13)
#define E_VSEMA  (E_SPECIAL | 14)
#define E_UNBLOCK_LIST (E_SPECIAL | 15)
#define E_WAIT  (E_SPECIAL | 16)
#define E_EXIT  (E_SPECIAL | 17)
#define E_FUNCTION (E_SPECIAL | 18)
#define E_SPROC (E_SPECIAL | 19)
#define E_KILL  (E_SPECIAL | 20)
#define E_PREFORK (E_SPECIAL | 21)
#define E_MP_CREATE (E_SPECIAL | 22)

#ifdef gone
/* function prototypes */
event_ptr event_unblock (thread_ptr pthread, thread_ptr pthr);
event_ptr event_unblock_list (thread_ptr pthread, thread_ptr pthr);
void event_block (thread_ptr pthread, int subtype);
void event_timed_block (thread_ptr pthread, int subtype, ulong time);
void event_terminate (thread_ptr pthread);
void event_done (thread_ptr pthread);
icode_ptr event_fork(icode_ptr picode, thread_ptr pthread);
icode_ptr event_load_locked(icode_ptr picode, thread_ptr pthread);
icode_ptr event_store_conditional(icode_ptr picode, thread_ptr pthread);
icode_ptr event_memory_barrier(icode_ptr picode, thread_ptr pthread);
icode_ptr event_sim_user(icode_ptr picode, thread_ptr pthread);
icode_ptr event_inst(icode_ptr picode, thread_ptr pthread);
icode_ptr event_read(icode_ptr picode, thread_ptr pthread);
icode_ptr event_write(icode_ptr picode, thread_ptr pthread);
icode_ptr event_yield(icode_ptr picode, thread_ptr pthread);
#endif

#endif /* _EVENT_H_ */