1*3db86aabSstevel /*
2*3db86aabSstevel  * CDDL HEADER START
3*3db86aabSstevel  *
4*3db86aabSstevel  * The contents of this file are subject to the terms of the
5*3db86aabSstevel  * Common Development and Distribution License, Version 1.0 only
6*3db86aabSstevel  * (the "License").  You may not use this file except in compliance
7*3db86aabSstevel  * with the License.
8*3db86aabSstevel  *
9*3db86aabSstevel  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*3db86aabSstevel  * or http://www.opensolaris.org/os/licensing.
11*3db86aabSstevel  * See the License for the specific language governing permissions
12*3db86aabSstevel  * and limitations under the License.
13*3db86aabSstevel  *
14*3db86aabSstevel  * When distributing Covered Code, include this CDDL HEADER in each
15*3db86aabSstevel  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*3db86aabSstevel  * If applicable, add the following below this CDDL HEADER, with the
17*3db86aabSstevel  * fields enclosed by brackets "[]" replaced with your own identifying
18*3db86aabSstevel  * information: Portions Copyright [yyyy] [name of copyright owner]
19*3db86aabSstevel  *
20*3db86aabSstevel  * CDDL HEADER END
21*3db86aabSstevel  */
22*3db86aabSstevel /*
23*3db86aabSstevel  * Copyright (c) 1996-1998 by Sun Microsystems, Inc.
24*3db86aabSstevel  * All rights reserved.
25*3db86aabSstevel  */
26*3db86aabSstevel 
27*3db86aabSstevel #ifndef _MEMA_TEST_H
28*3db86aabSstevel #define	_MEMA_TEST_H
29*3db86aabSstevel 
30*3db86aabSstevel #ifdef __cplusplus
31*3db86aabSstevel extern "C" {
32*3db86aabSstevel #endif
33*3db86aabSstevel 
34*3db86aabSstevel struct mtest_alloc_ent {
35*3db86aabSstevel 	struct mtest_alloc_ent	*next;
36*3db86aabSstevel 	void			*buf;
37*3db86aabSstevel };
38*3db86aabSstevel 
39*3db86aabSstevel struct mtest_handle {
40*3db86aabSstevel 	u_longlong_t		bank_size;
41*3db86aabSstevel 	ulong_t			page_size;
42*3db86aabSstevel 	ulong_t			line_size;
43*3db86aabSstevel 	ulong_t			lines_per_page;
44*3db86aabSstevel 	cfga_cond_t		condition;
45*3db86aabSstevel 	int			fd;
46*3db86aabSstevel 	ulong_t			max_errors;
47*3db86aabSstevel 	struct mtest_alloc_ent	*alloc_list;
48*3db86aabSstevel 	void			*drvhandle;
49*3db86aabSstevel 	struct cfga_msg		*msgp;
50*3db86aabSstevel };
51*3db86aabSstevel 
52*3db86aabSstevel typedef struct mtest_handle *mtest_handle_t;
53*3db86aabSstevel 
54*3db86aabSstevel typedef int mtest_func_t(mtest_handle_t);
55*3db86aabSstevel 
56*3db86aabSstevel struct mtest_table_ent {
57*3db86aabSstevel 	const char	*test_name;
58*3db86aabSstevel 	mtest_func_t	*test_func;
59*3db86aabSstevel };
60*3db86aabSstevel extern struct mtest_table_ent mtest_table[];
61*3db86aabSstevel #define	MTEST_DEFAULT_TEST	(0)
62*3db86aabSstevel extern char **mtest_build_opts(int *maxerr_idx);
63*3db86aabSstevel 
64*3db86aabSstevel #define	BANK_SIZE(H)		((H)->bank_size)
65*3db86aabSstevel #define	PAGE_SIZE(H)		((H)->page_size)
66*3db86aabSstevel #define	LINE_SIZE(H)		((H)->line_size)
67*3db86aabSstevel #define	LINES_PER_PAGE(H)	((H)->lines_per_page)
68*3db86aabSstevel #define	SET_CONDITION(H, C)	((H)->condition = (C))
69*3db86aabSstevel 
70*3db86aabSstevel struct mtest_error {
71*3db86aabSstevel 	int		error_type;
72*3db86aabSstevel };
73*3db86aabSstevel 
74*3db86aabSstevel /*
75*3db86aabSstevel  * Error types.
76*3db86aabSstevel  */
77*3db86aabSstevel #define	MTEST_ERR_NONE		0
78*3db86aabSstevel #define	MTEST_ERR_UE		1
79*3db86aabSstevel #define	MTEST_ERR_CE		2
80*3db86aabSstevel 
81*3db86aabSstevel /*
82*3db86aabSstevel  * Test routine return codes.
83*3db86aabSstevel  */
84*3db86aabSstevel #define	MTEST_DONE		0
85*3db86aabSstevel #define	MTEST_LIB_ERROR		1
86*3db86aabSstevel #define	MTEST_DEV_ERROR		2
87*3db86aabSstevel 
88*3db86aabSstevel /*
89*3db86aabSstevel  * Each test is allowed maximum number of errors and the index has
90*3db86aabSstevel  * to be coordinated with the token table size in mema_test_config.c
91*3db86aabSstevel  */
92*3db86aabSstevel #define	MAX_ERRORS		32
93*3db86aabSstevel #define	REPORT_SEC		5
94*3db86aabSstevel 
95*3db86aabSstevel /*
96*3db86aabSstevel  * Test functions should use this buffer allocation interface.
97*3db86aabSstevel  * The test framework will deallocate them on return.
98*3db86aabSstevel  */
99*3db86aabSstevel extern void *mtest_allocate_buf(mtest_handle_t, size_t);
100*3db86aabSstevel #define	mtest_allocate_page_buf(H)	mtest_allocate_buf((H), \
101*3db86aabSstevel 					(size_t)PAGE_SIZE(H))
102*3db86aabSstevel extern void mtest_deallocate_buf(mtest_handle_t, void *);
103*3db86aabSstevel extern void mtest_deallocate_buf_all(mtest_handle_t);
104*3db86aabSstevel 
105*3db86aabSstevel /*
106*3db86aabSstevel  * Test write: mtest_write(handle, buffer, page_num, line_offset, line_count)
107*3db86aabSstevel  * A line count of 0 indicates the whole page.
108*3db86aabSstevel  * A return of 0 indicates success.  A return of -1 indicates a failure of
109*3db86aabSstevel  * the device interface.
110*3db86aabSstevel  */
111*3db86aabSstevel extern int mtest_write(mtest_handle_t, void *, u_longlong_t, uint_t, uint_t);
112*3db86aabSstevel extern int mtest_read(mtest_handle_t, void *, u_longlong_t, uint_t, uint_t,
113*3db86aabSstevel     struct mtest_error *);
114*3db86aabSstevel 
115*3db86aabSstevel /*
116*3db86aabSstevel  * Message interface. If the upper layer has verbose on, the
117*3db86aabSstevel  * message will be seen by the user.
118*3db86aabSstevel  */
119*3db86aabSstevel extern void mtest_message(mtest_handle_t, const char *);
120*3db86aabSstevel 
121*3db86aabSstevel #ifdef __cplusplus
122*3db86aabSstevel }
123*3db86aabSstevel #endif
124*3db86aabSstevel 
125*3db86aabSstevel #endif /* _MEMA_TEST_H */
126