globals.h
3.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
/*
* 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_ */