xref: /illumos-gate/usr/src/lib/libc/sparc/gen/sync_instruction_memory.S (revision 0dd92943508086ca1800de461a7c66109737bcd5)
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 (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21/*
22 * Copyright (c) 1995-1997, by Sun Microsystems, Inc.
23 * All rights reserved.
24 */
25
26	.file	"sync_instruction_memory.s"
27
28#include <sys/asm_linkage.h>
29
30/*
31 * void sync_instruction_memory(caddr_t addr, int len)
32 *
33 * Make the memory at {addr, addr+len} valid for instruction execution.
34 */
35
36#ifdef lint
37#define	nop
38void
39sync_instruction_memory(caddr_t addr, int len)
40{
41	caddr_t end = addr + len;
42	caddr_t start = addr & ~7;
43	for (; start < end; start += 8)
44		flush(start);
45	nop; nop; nop; nop; nop;
46	return;
47}
48#else
49	ENTRY(sync_instruction_memory)
50	add	%o0, %o1, %o2
51	andn	%o0, 7, %o0
52
53	cmp	%o0, %o2
54	bgeu	2f
55	nop
56	flush	%o0
571:
58	add	%o0, 8, %o0
59	cmp	%o0, %o2
60	blu,a	1b
61	flush	%o0
62	!
63	! when we get here, we have executed 3 instructions after the
64	! last flush; SPARC V8 requires 2 more for flush to be visible
65	! The retl;nop pair will do it.
66	!
672:
68	retl
69	clr	%o0
70	SET_SIZE(sync_instruction_memory)
71
72	ENTRY(nop)
73	retl
74	nop
75	SET_SIZE(nop)
76#endif
77