1/*
2 *
3 * This file is subject to the terms and conditions of the GNU General Public
4 * License.  See the file "COPYING" in the main directory of this archive
5 * for more details.
6 *
7 * Copyright (C) 2000-2002 Silicon Graphics, Inc. All rights reserved.
8 */
9
10#ifdef STANDALONE
11#include "lock.h"
12#endif
13
14
15#define DEF_NAPTICKS		0
16#define DEF_PASSES		0
17#define DEF_AUTO_PASSES		1000000
18#define DEF_STOP_ON_ERROR	1
19#define DEF_VERBOSE		0
20#define DEF_LINECOUNT		2
21#define DEF_ITER_MSG		0
22#define DEF_VV			0xffffffff
23#define DEF_LINEPAD		0x234
24
25
26
27#define LLSC_MAXCPUS		64
28#define CACHELINE		64
29#define MAX_LINECOUNT		1024
30#define K			1024
31#define	MB			(K*K)
32
33
34#define	uint 		unsigned int
35#define	ushort		unsigned short
36#define	uchar		unsigned char
37#define vint		volatile int
38#define vlong		volatile long
39
40#define LOCKADDR(i)	&linep->lock[(i)]
41#define LOCK(i)		set_lock(LOCKADDR(i), lockpat)
42#define UNLOCK(i)	clr_lock(LOCKADDR(i), lockpat)
43#define GETLOCK(i)	*LOCKADDR(i)
44#define ZEROLOCK(i)	init_lock(LOCKADDR(i))
45
46#define CACHEALIGN(a)	((char*)((long)(a) & ~127L))
47
48typedef uint		guard_t;
49typedef uint		lock_t;
50typedef uint		share_t;
51typedef uchar		private_t;
52
53typedef struct {
54	guard_t		guard1;
55	lock_t		lock[2];
56	share_t		share[2];
57	private_t	private[LLSC_MAXCPUS];
58	share_t		share0;
59	share_t		share1;
60	guard_t		guard2;
61} dataline_t ;
62
63
64#define LINEPAD			k_linepad
65#define LINESTRIDE		(((sizeof(dataline_t)+CACHELINE-1)/CACHELINE)*CACHELINE + LINEPAD)
66
67
68typedef struct {
69	vint		threadstate;
70	uint		threadpasses;
71	private_t	private[MAX_LINECOUNT];
72} threadprivate_t;
73
74typedef struct {
75	vlong		sk_go;		/* 0=idle, 1=init, 2=run */
76	long		sk_linecount;
77	long		sk_passes;
78	long		sk_napticks;
79	long		sk_stop_on_error;
80	long		sk_verbose;
81	long		sk_iter_msg;
82	long		sk_vv;
83	long		sk_linepad;
84	long		sk_options;
85	long		sk_testnumber;
86	vlong		sk_currentpass;
87	void 		*sk_blocks;
88	threadprivate_t	*sk_threadprivate[LLSC_MAXCPUS];
89} control_t;
90
91/* Run state (k_go) constants */
92#define ST_IDLE		0
93#define ST_INIT		1
94#define ST_RUN		2
95#define ST_STOP		3
96#define ST_ERRSTOP	4
97
98
99/* Threadstate constants */
100#define TS_STOPPED	0
101#define	TS_RUNNING	1
102#define TS_KILLED	2
103
104
105
106int llsc_main (int cpuid);
107
108