globals.h 3.49 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 _GLOBALS_H_
#define _GLOBALS_H_

/*
 * Definitions of global variables used in more than one file
 */


#include "thread.h"
#include "task.h"
#include "ipc.h"

#ifdef MAIN
#define EXTERN
#else
#define EXTERN extern
#endif

/* Align the simulated address space on an 8k boundary */
#define M_ALIGN (8 * 1024)

/* macro to align a variable to a give sized boundary */
#define ALIGN(var,boundary) ((var + (boundary - 1) ) & ~(boundary -1))

/* Possible values for Trace_option */
#define TRACE_NONE    0
#define TRACE_INST    1
#define TRACE_PRIVATE    2
#define TRACE_SHARED     4
#define TRACE_REFS        (TRACE_PRIVATE | TRACE_SHARED)
#define TRACE_SYNC    8		/* LDx_L, STx_C, MB */
#define TRACE_DEFAULT     (TRACE_REFS | TRACE_SYNC)

/* The clock frequency of the processor */
#define CLOCKS_PER_SECOND 400

/* default uid and gid to use */
#define DEFAULT_UID 9620
#define DEFAULT_GID 21

/* the number of existing processes */
EXTERN int nprocs;

/* name of the executable  */
EXTERN char *exec_name;

/* Name of the aint executable */
EXTERN char *sim_name;

/*
 * All the xxx_start variables are addresses  in the object's memory space,
 * except for Private_start
 */

EXTERN ulong default_heap_size;
EXTERN ulong default_stack_size;

EXTERN ulong shmem_start;
EXTERN ulong shmem_end;
EXTERN ulong shmem_size;

EXTERN ulong sp_shmat_start; /* Lowest addr where shmat can be requested */
EXTERN ulong sp_shmat_size;  /* Total size of attached segments in a process */
EXTERN ulong sp_shmat_end;   /* Highest addr (+size) where shmat can be
				requested */

extern unsigned long find_proc_addr (char *objname, char *symbolname);
EXTERN unsigned long sim_user_addr;

/* Hook Value for object breakpoint */
EXTERN long obj_hook;

#ifndef MAX_NPROCS
#define MAX_NPROCS 16
#endif

/*
 * Number of instructions in current picode
 */
extern int instr_count;
/*
 * Number of instructions actually allocated
 */
extern int instr_alloc;

/*
 * Ckpoint_freq controls the frequency of calls to sim_checkpoint().
 * This can be set on the command line as well as changed by the user while
 * the program is running. If set to zero, no further calls to sim_checkpoint
 * will occur.
 */
#define DEFAULT_CKPOINT_FREQ 10000000
EXTERN unsigned int ckpoint_freq;

EXTERN int recycle_threads;

/*
 * All queues are circularly doubly linked lists with a head node.
 * When a thread exits, it goes on the done_q until the parent waits on
 * it. If a parent exits before its children, it goes to sleep. When the
 * child exits, it wakes up the parent. The parent moves finished children
 * from the done_q to the free_q
 */

EXTERN thread_t run_q;
EXTERN thread_t free_q;
EXTERN thread_t done_q;
EXTERN thread_t sleep_q;
EXTERN thread_t read_pipe_q;
EXTERN thread_t write_pipe_q;

/* the array of threads, indexed by pids */
EXTERN thread_ptr threads;

EXTERN int max_pid;

/* Free list pointer for events. One event is allocated for each thread */
EXTERN event_ptr event_free;

/* The max number of processes that can be simulated */
EXTERN int max_nprocs;

/* The global shared-memory page-table */
EXTERN page_t *shmem_page_table[TB_SIZE];

/* Struct used by shmem syscalls */
EXTERN struct sysv_shm shm_seg[MAX_SHMSEG];

/* Flag telling read_text what events are flagged */
EXTERN int trace_option;

#endif /* _GLOBALS_H_ */