xref: /onnv-gate/usr/src/lib/libc/sparc/gen/sync_instruction_memory.s (revision 7298:b69e27387f74)
10Sstevel@tonic-gate/*
20Sstevel@tonic-gate * CDDL HEADER START
30Sstevel@tonic-gate *
40Sstevel@tonic-gate * The contents of this file are subject to the terms of the
5*7298SMark.J.Nelson@Sun.COM * Common Development and Distribution License (the "License").
6*7298SMark.J.Nelson@Sun.COM * You may not use this file except in compliance with the License.
70Sstevel@tonic-gate *
80Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing.
100Sstevel@tonic-gate * See the License for the specific language governing permissions
110Sstevel@tonic-gate * and limitations under the License.
120Sstevel@tonic-gate *
130Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each
140Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the
160Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying
170Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner]
180Sstevel@tonic-gate *
190Sstevel@tonic-gate * CDDL HEADER END
200Sstevel@tonic-gate */
210Sstevel@tonic-gate/*
220Sstevel@tonic-gate * Copyright (c) 1995-1997, by Sun Microsystems, Inc.
230Sstevel@tonic-gate * All rights reserved.
240Sstevel@tonic-gate */
250Sstevel@tonic-gate
26*7298SMark.J.Nelson@Sun.COM	.file	"sync_instruction_memory.s"
270Sstevel@tonic-gate
280Sstevel@tonic-gate#include <sys/asm_linkage.h>
290Sstevel@tonic-gate
300Sstevel@tonic-gate/*
310Sstevel@tonic-gate * void sync_instruction_memory(caddr_t addr, int len)
320Sstevel@tonic-gate *
330Sstevel@tonic-gate * Make the memory at {addr, addr+len} valid for instruction execution.
340Sstevel@tonic-gate */
350Sstevel@tonic-gate
360Sstevel@tonic-gate#ifdef lint
370Sstevel@tonic-gate#define	nop
380Sstevel@tonic-gatevoid
390Sstevel@tonic-gatesync_instruction_memory(caddr_t addr, int len)
400Sstevel@tonic-gate{
410Sstevel@tonic-gate	caddr_t end = addr + len;
420Sstevel@tonic-gate	caddr_t start = addr & ~7;
430Sstevel@tonic-gate	for (; start < end; start += 8)
440Sstevel@tonic-gate		flush(start);
450Sstevel@tonic-gate	nop; nop; nop; nop; nop;
460Sstevel@tonic-gate	return;
470Sstevel@tonic-gate}
480Sstevel@tonic-gate#else
490Sstevel@tonic-gate	ENTRY(sync_instruction_memory)
500Sstevel@tonic-gate	add	%o0, %o1, %o2
510Sstevel@tonic-gate	andn	%o0, 7, %o0
520Sstevel@tonic-gate
530Sstevel@tonic-gate	cmp	%o0, %o2
540Sstevel@tonic-gate	bgeu	2f
550Sstevel@tonic-gate	nop
560Sstevel@tonic-gate	flush	%o0
570Sstevel@tonic-gate1:
580Sstevel@tonic-gate	add	%o0, 8, %o0
590Sstevel@tonic-gate	cmp	%o0, %o2
600Sstevel@tonic-gate	blu,a	1b
610Sstevel@tonic-gate	flush	%o0
620Sstevel@tonic-gate	!
630Sstevel@tonic-gate	! when we get here, we have executed 3 instructions after the
640Sstevel@tonic-gate	! last flush; SPARC V8 requires 2 more for flush to be visible
650Sstevel@tonic-gate	! The retl;nop pair will do it.
660Sstevel@tonic-gate	!
670Sstevel@tonic-gate2:
680Sstevel@tonic-gate	retl
690Sstevel@tonic-gate	clr	%o0
700Sstevel@tonic-gate	SET_SIZE(sync_instruction_memory)
710Sstevel@tonic-gate
720Sstevel@tonic-gate	ENTRY(nop)
730Sstevel@tonic-gate	retl
740Sstevel@tonic-gate	nop
750Sstevel@tonic-gate	SET_SIZE(nop)
760Sstevel@tonic-gate#endif
77