29949e866e40b95795203f3ee46f44a197c946e4stevel * CDDL HEADER START
29949e866e40b95795203f3ee46f44a197c946e4stevel * The contents of this file are subject to the terms of the
29949e866e40b95795203f3ee46f44a197c946e4stevel * Common Development and Distribution License (the "License").
29949e866e40b95795203f3ee46f44a197c946e4stevel * You may not use this file except in compliance with the License.
29949e866e40b95795203f3ee46f44a197c946e4stevel * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
29949e866e40b95795203f3ee46f44a197c946e4stevel * See the License for the specific language governing permissions
29949e866e40b95795203f3ee46f44a197c946e4stevel * and limitations under the License.
29949e866e40b95795203f3ee46f44a197c946e4stevel * When distributing Covered Code, include this CDDL HEADER in each
29949e866e40b95795203f3ee46f44a197c946e4stevel * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
29949e866e40b95795203f3ee46f44a197c946e4stevel * If applicable, add the following below this CDDL HEADER, with the
29949e866e40b95795203f3ee46f44a197c946e4stevel * fields enclosed by brackets "[]" replaced with your own identifying
29949e866e40b95795203f3ee46f44a197c946e4stevel * information: Portions Copyright [yyyy] [name of copyright owner]
29949e866e40b95795203f3ee46f44a197c946e4stevel * CDDL HEADER END
29949e866e40b95795203f3ee46f44a197c946e4stevel * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
29949e866e40b95795203f3ee46f44a197c946e4stevel * Use is subject to license terms.
29949e866e40b95795203f3ee46f44a197c946e4stevel/* memory setup parameters */
29949e866e40b95795203f3ee46f44a197c946e4stevel/* list of tests in progress (list protected test_mutex) */
29949e866e40b95795203f3ee46f44a197c946e4stevel /* XXX if ac ever detaches... */
29949e866e40b95795203f3ee46f44a197c946e4stevel * Is the specified bank testable?
29949e866e40b95795203f3ee46f44a197c946e4stevel /* verify the board is of the correct type */
29949e866e40b95795203f3ee46f44a197c946e4stevel * Memory must be in the spare state to be testable.
29949e866e40b95795203f3ee46f44a197c946e4stevel * However, spare memory that is testing can't be tested
29949e866e40b95795203f3ee46f44a197c946e4stevel * again, instead return the current test info.
29949e866e40b95795203f3ee46f44a197c946e4stevel * find the test entry
29949e866e40b95795203f3ee46f44a197c946e4stevel for (test = test_base; test != NULL; test = test->next) {
29949e866e40b95795203f3ee46f44a197c946e4stevel /* Not busy testing. */
29949e866e40b95795203f3ee46f44a197c946e4stevel * return the current test information to the new caller
29949e866e40b95795203f3ee46f44a197c946e4stevel * at this point, we have an available bank to test.
29949e866e40b95795203f3ee46f44a197c946e4stevel * create a test buffer
29949e866e40b95795203f3ee46f44a197c946e4stevel test = kmem_zalloc(sizeof (struct test_info), KM_SLEEP);
29949e866e40b95795203f3ee46f44a197c946e4stevel test->va = vmem_alloc(heap_arena, PAGESIZE, VM_SLEEP);
29949e866e40b95795203f3ee46f44a197c946e4stevel /* fill in all the test info details now */
1a5e258f5471356ca102c7176637cdce45bac147Josef 'Jeff' Sipek test->info.handle = atomic_inc_32_nv(&mem_test_sequence_id);
29949e866e40b95795203f3ee46f44a197c946e4stevel (void) drv_getparm(PPID, (ulong_t *)(&(test->info.tester_pid)));
29949e866e40b95795203f3ee46f44a197c946e4stevel /* If Blackbird ever gets a variable line size, this will change. */
29949e866e40b95795203f3ee46f44a197c946e4stevel test->info.line_size = cpunodes[CPU->cpu_id].ecache_linesize;
29949e866e40b95795203f3ee46f44a197c946e4stevel /* return the information to the user */
29949e866e40b95795203f3ee46f44a197c946e4stevel /* oh well, tear down the test now */
29949e866e40b95795203f3ee46f44a197c946e4stevel /* finally link us into the test database */
29949e866e40b95795203f3ee46f44a197c946e4stevel cmn_err(CE_NOTE, "!memtest: start test[%u]: board %d, bank %d",
29949e866e40b95795203f3ee46f44a197c946e4stevel#endif /* DEBUG */
29949e866e40b95795203f3ee46f44a197c946e4stevel /* get test result information */
29949e866e40b95795203f3ee46f44a197c946e4stevel /* bdlist protects all state changes... */
29949e866e40b95795203f3ee46f44a197c946e4stevel /* find the test */
29949e866e40b95795203f3ee46f44a197c946e4stevel for (test = test_base; test != NULL; test = test->next) {
29949e866e40b95795203f3ee46f44a197c946e4stevel break; /* found the test */
29949e866e40b95795203f3ee46f44a197c946e4stevel "!memtest: stop test[%u]: board %d, bank %d,"
29949e866e40b95795203f3ee46f44a197c946e4stevel " condition %d",
29949e866e40b95795203f3ee46f44a197c946e4stevel#endif /* DEBUG */
29949e866e40b95795203f3ee46f44a197c946e4stevel /* first unlink us from the test list (to allow no more entries) */
29949e866e40b95795203f3ee46f44a197c946e4stevel /* then, wait for current tests to complete */
29949e866e40b95795203f3ee46f44a197c946e4stevel /* clean up the test related allocations */
29949e866e40b95795203f3ee46f44a197c946e4stevel /* update the bank condition accordingly */
29949e866e40b95795203f3ee46f44a197c946e4stevel /* finally, delete the test element */
29949e866e40b95795203f3ee46f44a197c946e4stevel /* bdlist protects all state changes... */
29949e866e40b95795203f3ee46f44a197c946e4stevel /* find the test */
29949e866e40b95795203f3ee46f44a197c946e4stevel for (test = test_base; test != NULL; test = test->next) {
29949e866e40b95795203f3ee46f44a197c946e4stevel break; /* found the test */
29949e866e40b95795203f3ee46f44a197c946e4stevel /* No test running, nothing to do. */
29949e866e40b95795203f3ee46f44a197c946e4stevel cmn_err(CE_NOTE, "!memtest: stop test[%u] on close: "
29949e866e40b95795203f3ee46f44a197c946e4stevel "board %d, bank %d, condition %d", test->info.handle,
29949e866e40b95795203f3ee46f44a197c946e4stevel#endif /* DEBUG */
29949e866e40b95795203f3ee46f44a197c946e4stevel /* first unlink us from the test list (to allow no more entries) */
29949e866e40b95795203f3ee46f44a197c946e4stevel /* clean up the test related allocations */
29949e866e40b95795203f3ee46f44a197c946e4stevel /* update the bank condition accordingly */
29949e866e40b95795203f3ee46f44a197c946e4stevel /* finally, delete the test element */
29949e866e40b95795203f3ee46f44a197c946e4stevel t_read.page_buf = (void *)(uintptr_t)t_read32.page_buf;
29949e866e40b95795203f3ee46f44a197c946e4stevel t_read.error_buf = (sunfire_processor_error_regs_t *)
29949e866e40b95795203f3ee46f44a197c946e4stevel#else /* _MULTI_DATAMODEL */
29949e866e40b95795203f3ee46f44a197c946e4stevel#endif /* _MULTI_DATAMODEL */
29949e866e40b95795203f3ee46f44a197c946e4stevel /* verify the handle */
29949e866e40b95795203f3ee46f44a197c946e4stevel for (test = test_base; test != NULL; test = test->next) {
29949e866e40b95795203f3ee46f44a197c946e4stevel /* bump the busy bit */
29949e866e40b95795203f3ee46f44a197c946e4stevel /* verify the remaining parameters */
29949e866e40b95795203f3ee46f44a197c946e4stevel ((t_read.address.line_offset + t_read.address.line_count) >
29949e866e40b95795203f3ee46f44a197c946e4stevel page_offset = t_read.address.line_offset * test->info.line_size;
29949e866e40b95795203f3ee46f44a197c946e4stevel /* time to go quiet */
29949e866e40b95795203f3ee46f44a197c946e4stevel /* we need a va for the block instructions */
29949e866e40b95795203f3ee46f44a197c946e4stevel /* disable errors */
29949e866e40b95795203f3ee46f44a197c946e4stevel set_error_enable(orig_err & ~(EER_CEEN | EER_NCEEN));
29949e866e40b95795203f3ee46f44a197c946e4stevel /* copy the data again (using our very special copy) */
29949e866e40b95795203f3ee46f44a197c946e4stevel ac_blkcopy(src_va, dst_va, t_read.address.line_count,
29949e866e40b95795203f3ee46f44a197c946e4stevel /* process errors (if any) */
29949e866e40b95795203f3ee46f44a197c946e4stevel * clean up after our no-error copy but before enabling ints.
29949e866e40b95795203f3ee46f44a197c946e4stevel * XXX what to do about other error types?
29949e866e40b95795203f3ee46f44a197c946e4stevel /* errors back on */
29949e866e40b95795203f3ee46f44a197c946e4stevel /* tear down translation (who needs an mmu) */
29949e866e40b95795203f3ee46f44a197c946e4stevel /* we're back! */
29949e866e40b95795203f3ee46f44a197c946e4stevel * If there was a data error, attempt to return the error_buf
29949e866e40b95795203f3ee46f44a197c946e4stevel * to the user.
29949e866e40b95795203f3ee46f44a197c946e4stevel sizeof (sunfire_processor_error_regs_t), flag) != 0) {
29949e866e40b95795203f3ee46f44a197c946e4stevel /* Keep going */
29949e866e40b95795203f3ee46f44a197c946e4stevel * Then, return the page to the user (always)
29949e866e40b95795203f3ee46f44a197c946e4stevel if (ddi_copyout(dst_va, (caddr_t)(t_read.page_buf) + page_offset,
29949e866e40b95795203f3ee46f44a197c946e4stevel t_read.address.line_count * test->info.line_size, flag) != 0) {
29949e866e40b95795203f3ee46f44a197c946e4stevel t_write.page_buf = (void *)(uintptr_t)t_write32.page_buf;
29949e866e40b95795203f3ee46f44a197c946e4stevel#else /* _MULTI_DATAMODEL */
29949e866e40b95795203f3ee46f44a197c946e4stevel#endif /* _MULTI_DATAMODEL */
29949e866e40b95795203f3ee46f44a197c946e4stevel /* verify the handle */
29949e866e40b95795203f3ee46f44a197c946e4stevel for (test = test_base; test != NULL; test = test->next) {
29949e866e40b95795203f3ee46f44a197c946e4stevel /* bump the busy bit */
29949e866e40b95795203f3ee46f44a197c946e4stevel /* verify the remaining parameters */
29949e866e40b95795203f3ee46f44a197c946e4stevel ((t_write.address.line_offset + t_write.address.line_count) >
29949e866e40b95795203f3ee46f44a197c946e4stevel page_offset = t_write.address.line_offset * test->info.line_size;
29949e866e40b95795203f3ee46f44a197c946e4stevel /* copy in the specified user data */
29949e866e40b95795203f3ee46f44a197c946e4stevel if (ddi_copyin((caddr_t)(t_write.page_buf) + page_offset, src_va,
29949e866e40b95795203f3ee46f44a197c946e4stevel t_write.address.line_count * test->info.line_size, flag) != 0) {
29949e866e40b95795203f3ee46f44a197c946e4stevel /* time to go quiet */
29949e866e40b95795203f3ee46f44a197c946e4stevel /* we need a va for the block instructions */
29949e866e40b95795203f3ee46f44a197c946e4stevel /* copy the data again (using our very special copy) */
29949e866e40b95795203f3ee46f44a197c946e4stevel ac_blkcopy(src_va, dst_va, t_write.address.line_count,
29949e866e40b95795203f3ee46f44a197c946e4stevel /* tear down translation (who needs an mmu) */
29949e866e40b95795203f3ee46f44a197c946e4stevel /* we're back! */