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