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