xref: /netbsd/sys/arch/shark/isa/isa_io_asm.S (revision ce099b40)
1*ce099b40Smartin/*	$NetBSD: isa_io_asm.S,v 1.4 2008/04/28 20:23:35 martin Exp $	*/
280675955Sthorpej
380675955Sthorpej/*-
480675955Sthorpej * Copyright (c) 1997 The NetBSD Foundation, Inc.
580675955Sthorpej * All rights reserved.
680675955Sthorpej *
780675955Sthorpej * This code is derived from software contributed to The NetBSD Foundation
880675955Sthorpej * by Mark Brinicombe.
980675955Sthorpej *
1080675955Sthorpej * Redistribution and use in source and binary forms, with or without
1180675955Sthorpej * modification, are permitted provided that the following conditions
1280675955Sthorpej * are met:
1380675955Sthorpej * 1. Redistributions of source code must retain the above copyright
1480675955Sthorpej *    notice, this list of conditions and the following disclaimer.
1580675955Sthorpej * 2. Redistributions in binary form must reproduce the above copyright
1680675955Sthorpej *    notice, this list of conditions and the following disclaimer in the
1780675955Sthorpej *    documentation and/or other materials provided with the distribution.
1880675955Sthorpej *
1980675955Sthorpej * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
2080675955Sthorpej * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
2180675955Sthorpej * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
2280675955Sthorpej * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
2380675955Sthorpej * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
2480675955Sthorpej * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
2580675955Sthorpej * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
2680675955Sthorpej * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
2780675955Sthorpej * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
2880675955Sthorpej * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
2980675955Sthorpej * POSSIBILITY OF SUCH DAMAGE.
3080675955Sthorpej */
3180675955Sthorpej
3280675955Sthorpej/*
3380675955Sthorpej * Copyright 1997
3480675955Sthorpej * Digital Equipment Corporation. All rights reserved.
3580675955Sthorpej *
3680675955Sthorpej * This software is furnished under license and may be used and
3780675955Sthorpej * copied only in accordance with the following terms and conditions.
3880675955Sthorpej * Subject to these conditions, you may download, copy, install,
3980675955Sthorpej * use, modify and distribute this software in source and/or binary
4080675955Sthorpej * form. No title or ownership is transferred hereby.
4180675955Sthorpej *
4280675955Sthorpej * 1) Any source code used, modified or distributed must reproduce
4380675955Sthorpej *    and retain this copyright notice and list of conditions as
4480675955Sthorpej *    they appear in the source file.
4580675955Sthorpej *
4680675955Sthorpej * 2) No right is granted to use any trade name, trademark, or logo of
4780675955Sthorpej *    Digital Equipment Corporation. Neither the "Digital Equipment
4880675955Sthorpej *    Corporation" name nor any trademark or logo of Digital Equipment
4980675955Sthorpej *    Corporation may be used to endorse or promote products derived
5080675955Sthorpej *    from this software without the prior written permission of
5180675955Sthorpej *    Digital Equipment Corporation.
5280675955Sthorpej *
5380675955Sthorpej * 3) This software is provided "AS-IS" and any express or implied
5480675955Sthorpej *    warranties, including but not limited to, any implied warranties
5580675955Sthorpej *    of merchantability, fitness for a particular purpose, or
5680675955Sthorpej *    non-infringement are disclaimed. In no event shall DIGITAL be
5780675955Sthorpej *    liable for any damages whatsoever, and in particular, DIGITAL
5880675955Sthorpej *    shall not be liable for special, indirect, consequential, or
5980675955Sthorpej *    incidental damages or damages for lost profits, loss of
6080675955Sthorpej *    revenue or loss of use, whether such damages arise in contract,
6180675955Sthorpej *    negligence, tort, under statute, in equity, at law or otherwise,
6280675955Sthorpej *    even if advised of the possibility of such damage.
6380675955Sthorpej */
6480675955Sthorpej
6580675955Sthorpej/*
6680675955Sthorpej * bus_space I/O functions for isa
6780675955Sthorpej */
6880675955Sthorpej
6980675955Sthorpej#include <machine/asm.h>
7080675955Sthorpej
7180675955Sthorpej#ifdef GPROF
7280675955Sthorpej#define	PAUSE	nop ; nop ; nop ; nop ; nop
7380675955Sthorpej#else
7480675955Sthorpej#define	PAUSE
7580675955Sthorpej#endif
7680675955Sthorpej
7780675955Sthorpej/*
7880675955Sthorpej * Note these functions use ARM Architecture V4 instructions as
7980675955Sthorpej * all current systems with ISA will be using processors that support
8080675955Sthorpej * V4 or later architectures (SHARK & CATS)
8180675955Sthorpej */
8280675955Sthorpej
8380675955Sthorpej/*
8480675955Sthorpej * read single
8580675955Sthorpej */
8680675955Sthorpej
8780675955SthorpejENTRY(isa_bs_r_1)
8880675955Sthorpej	ldrb	r0, [r1, r2]
8980675955Sthorpej	PAUSE
9080675955Sthorpej	mov	pc, lr
9180675955Sthorpej
9280675955SthorpejENTRY(isa_bs_r_2)
9380675955Sthorpej	ldrh	r0, [r1, r2]	/*.word	0xe19100b2*/
9480675955Sthorpej	PAUSE
9580675955Sthorpej	mov	pc, lr
9680675955Sthorpej
9780675955SthorpejENTRY(isa_bs_r_4)
9880675955Sthorpej	ldr	r0, [r1, r2]
9980675955Sthorpej	PAUSE
10080675955Sthorpej	mov	pc, lr
10180675955Sthorpej
10280675955Sthorpej/*
10380675955Sthorpej * read multiple.
10480675955Sthorpej */
10580675955Sthorpej
10680675955SthorpejENTRY(isa_bs_rm_1)
10780675955Sthorpej	add	r0, r1, r2
10880675955Sthorpej	mov	r1, r3
10980675955Sthorpej	ldr	r2, [sp, #0]
11080675955Sthorpej	teq	r2, #0
11180675955Sthorpej	moveq	pc, lr
11280675955Sthorpej
11380675955SthorpejLisa_rm_1_loop:
11480675955Sthorpej	ldrb	r3, [r0]
11580675955Sthorpej	strb	r3, [r1], #1
11680675955Sthorpej	subs	r2, r2, #1
11780675955Sthorpej	bne	Lisa_rm_1_loop
11880675955Sthorpej
11980675955Sthorpej	mov	pc, lr
12080675955Sthorpej
12180675955SthorpejENTRY(isa_bs_rm_2)
12280675955Sthorpej	add	r0, r1, r2
12380675955Sthorpej	mov	r1, r3
12480675955Sthorpej	ldr	r2, [sp, #0]
12580675955Sthorpej	teq	r2, #0
12680675955Sthorpej	moveq	pc, lr
12780675955Sthorpej
12880675955SthorpejLisa_rm_2_loop:
12980675955Sthorpej	ldrh	r3, [r0]	/*.word 0xe1d030b0*/
13080675955Sthorpej	strh	r3, [r1], #2	/*.word 0xe0c130b2*/
13180675955Sthorpej	subs	r2, r2, #1
13280675955Sthorpej	bne	Lisa_rm_2_loop
13380675955Sthorpej
13480675955Sthorpej	mov	pc, lr
13580675955Sthorpej
13680675955SthorpejENTRY(isa_bs_rm_4)
13780675955Sthorpej	add	r0, r1, r2
13880675955Sthorpej	mov	r1, r3
13980675955Sthorpej	ldr	r2, [sp, #0]
14080675955Sthorpej	teq	r2, #0
14180675955Sthorpej	moveq	pc, lr
14280675955Sthorpej
14380675955SthorpejLisa_rm_4_loop:
14480675955Sthorpej	ldr	r3, [r0]
14580675955Sthorpej	str	r3, [r1], #4
14680675955Sthorpej	subs	r2, r2, #1
14780675955Sthorpej	bne	Lisa_rm_4_loop
14880675955Sthorpej
14980675955Sthorpej	mov	pc, lr
15080675955Sthorpej
15180675955Sthorpej/*
15280675955Sthorpej * read region.
15380675955Sthorpej */
15480675955Sthorpej
15580675955SthorpejENTRY(isa_bs_rr_1)
15680675955Sthorpej	add	r0, r1, r2
15780675955Sthorpej	mov	r1, r3
15880675955Sthorpej	ldr	r2, [sp, #0]
15980675955Sthorpej	teq	r2, #0
16080675955Sthorpej	moveq	pc, lr
16180675955Sthorpej
16280675955SthorpejLisa_rr_1_loop:
16380675955Sthorpej	ldrb	r3, [r0], #1
16480675955Sthorpej	strb	r3, [r1], #1
16580675955Sthorpej	subs	r2, r2, #1
16680675955Sthorpej	bne	Lisa_rr_1_loop
16780675955Sthorpej
16880675955Sthorpej	mov	pc, lr
16980675955Sthorpej
17080675955SthorpejENTRY(isa_bs_rr_2)
17180675955Sthorpej	add	r0, r1, r2
17280675955Sthorpej	mov	r1, r3
17380675955Sthorpej	ldr	r2, [sp, #0]
17480675955Sthorpej	teq	r2, #0
17580675955Sthorpej	moveq	pc, lr
17680675955Sthorpej
17780675955SthorpejLisa_rr_2_loop:
17880675955Sthorpej	ldrh	r3, [r0], #2
17980675955Sthorpej	strh	r3, [r1], #2	/*.word 0xe0c130b2*/
18080675955Sthorpej	subs	r2, r2, #1
18180675955Sthorpej	bne	Lisa_rr_2_loop
18280675955Sthorpej
18380675955Sthorpej	mov	pc, lr
18480675955Sthorpej
18580675955SthorpejENTRY(isa_bs_rr_4)
18680675955Sthorpej	add	r0, r1, r2
18780675955Sthorpej	mov	r1, r3
18880675955Sthorpej	ldr	r2, [sp, #0]
18980675955Sthorpej	teq	r2, #0
19080675955Sthorpej	moveq	pc, lr
19180675955Sthorpej
19280675955SthorpejLisa_rr_4_loop:
19380675955Sthorpej	ldr	r3, [r0], #4
19480675955Sthorpej	str	r3, [r1], #4
19580675955Sthorpej	subs	r2, r2, #1
19680675955Sthorpej	bne	Lisa_rr_4_loop
19780675955Sthorpej
19880675955Sthorpej	mov	pc, lr
19980675955Sthorpej
20080675955Sthorpej/*
20180675955Sthorpej * write single
20280675955Sthorpej */
20380675955Sthorpej
20480675955SthorpejENTRY(isa_bs_w_1)
20580675955Sthorpej	strb	r3, [r1, r2]
20680675955Sthorpej	PAUSE
20780675955Sthorpej	mov	pc, lr
20880675955Sthorpej
20980675955SthorpejENTRY(isa_bs_w_2)
21080675955Sthorpej	strh	r3, [r1, r2]	/*.word 0xe18130b2*/
21180675955Sthorpej	PAUSE
21280675955Sthorpej	mov	pc, lr
21380675955Sthorpej
21480675955SthorpejENTRY(isa_bs_w_4)
21580675955Sthorpej	str	r3, [r1, r2]
21680675955Sthorpej	PAUSE
21780675955Sthorpej	mov	pc, lr
21880675955Sthorpej
21980675955Sthorpej/*
22080675955Sthorpej * write multiple
22180675955Sthorpej */
22280675955Sthorpej
22380675955SthorpejENTRY(isa_bs_wm_1)
22480675955Sthorpej	add	r0, r1, r2
22580675955Sthorpej	mov	r1, r3
22680675955Sthorpej	ldr	r2, [sp, #0]
22780675955Sthorpej	teq	r2, #0
22880675955Sthorpej	moveq	pc, lr
22980675955Sthorpej
23080675955SthorpejLisa_wm_1_loop:
23180675955Sthorpej	ldrb	r3, [r1], #1
23280675955Sthorpej	strb	r3, [r0]
23380675955Sthorpej	subs	r2, r2, #1
23480675955Sthorpej	bne	Lisa_wm_1_loop
23580675955Sthorpej
23680675955Sthorpej	mov	pc, lr
23780675955Sthorpej
23880675955SthorpejENTRY(isa_bs_wm_2)
23980675955Sthorpej	add	r0, r1, r2
24080675955Sthorpej	mov	r1, r3
24180675955Sthorpej	ldr	r2, [sp, #0]
24280675955Sthorpej	teq	r2, #0
24380675955Sthorpej	moveq	pc, lr
24480675955Sthorpej
24580675955SthorpejLisa_wm_2_loop:
24680675955Sthorpej	ldrh	r3, [r1], #2	/*.word 0xe0d130b2*/
24780675955Sthorpej	strh	r3, [r0]	/*.word 0xe1c030b0*/
24880675955Sthorpej	subs	r2, r2, #1
24980675955Sthorpej	bne	Lisa_wm_2_loop
25080675955Sthorpej
25180675955Sthorpej	mov	pc, lr
25280675955Sthorpej
25380675955SthorpejENTRY(isa_bs_wm_4)
25480675955Sthorpej	add	r0, r1, r2
25580675955Sthorpej	mov	r1, r3
25680675955Sthorpej	ldr	r2, [sp, #0]
25780675955Sthorpej	teq	r2, #0
25880675955Sthorpej	moveq	pc, lr
25980675955Sthorpej
26080675955SthorpejLisa_wm_4_loop:
26180675955Sthorpej	ldr	r3, [r1], #4
26280675955Sthorpej	str	r3, [r0]
26380675955Sthorpej	subs	r2, r2, #1
26480675955Sthorpej	bne	Lisa_wm_4_loop
26580675955Sthorpej
26680675955Sthorpej	mov	pc, lr
26780675955Sthorpej
26880675955Sthorpej
26980675955Sthorpej/*
27080675955Sthorpej * write region.
27180675955Sthorpej */
27280675955Sthorpej
27380675955SthorpejENTRY(isa_bs_wr_1)
27480675955Sthorpej	add	r0, r1, r2
27580675955Sthorpej	mov	r1, r3
27680675955Sthorpej	ldr	r2, [sp, #0]
27780675955Sthorpej	teq	r2, #0
27880675955Sthorpej	moveq	pc, lr
27980675955Sthorpej
28080675955SthorpejLisa_wr_1_loop:
28180675955Sthorpej	ldrb	r3, [r1], #1
28280675955Sthorpej	strb	r3, [r0], #1
28380675955Sthorpej	subs	r2, r2, #1
28480675955Sthorpej	bne	Lisa_wr_1_loop
28580675955Sthorpej
28680675955Sthorpej	mov	pc, lr
28780675955Sthorpej
28880675955SthorpejENTRY(isa_bs_wr_2)
28980675955Sthorpej	add	r0, r1, r2
29080675955Sthorpej	mov	r1, r3
29180675955Sthorpej	ldr	r2, [sp, #0]
29280675955Sthorpej	teq	r2, #0
29380675955Sthorpej	moveq	pc, lr
29480675955Sthorpej
29580675955SthorpejLisa_wr_2_loop:
29680675955Sthorpej	ldrh	r3, [r1], #2	/*.word 0xe0d130b2*/
29780675955Sthorpej	strh	r3, [r0], #2
29880675955Sthorpej	subs	r2, r2, #1
29980675955Sthorpej	bne	Lisa_wr_2_loop
30080675955Sthorpej
30180675955Sthorpej	mov	pc, lr
30280675955Sthorpej
30380675955SthorpejENTRY(isa_bs_wr_4)
30480675955Sthorpej	add	r0, r1, r2
30580675955Sthorpej	mov	r1, r3
30680675955Sthorpej	ldr	r2, [sp, #0]
30780675955Sthorpej	teq	r2, #0
30880675955Sthorpej	moveq	pc, lr
30980675955Sthorpej
31080675955SthorpejLisa_wr_4_loop:
31180675955Sthorpej	ldr	r3, [r1], #4
31280675955Sthorpej	str	r3, [r0], #4
31380675955Sthorpej	subs	r2, r2, #1
31480675955Sthorpej	bne	Lisa_wr_4_loop
31580675955Sthorpej
31680675955Sthorpej	mov	pc, lr
31780675955Sthorpej
31880675955Sthorpej/*
31980675955Sthorpej * Set region
32080675955Sthorpej */
32180675955Sthorpej
32280675955SthorpejENTRY(isa_bs_sr_2)
32380675955Sthorpej	add	r0, r1, r2
32480675955Sthorpej	mov	r1, r3
32580675955Sthorpej	ldr	r2, [sp, #0]
32680675955Sthorpej	teq	r2, #0
32780675955Sthorpej	moveq	pc, lr
32880675955Sthorpej
32980675955SthorpejLisa_bs_sr_2_loop:
33080675955Sthorpej	strh	r1, [r0], #2		/*.word e0c010b2*/
33180675955Sthorpej	subs	r2, r2, #1
33280675955Sthorpej	bne	Lisa_bs_sr_2_loop
33380675955Sthorpej
33480675955Sthorpej	mov	pc, lr
33501c812ccStsutsui
33601c812ccStsutsui/*
33701c812ccStsutsui * Copy region
33801c812ccStsutsui */
33901c812ccStsutsui
34001c812ccStsutsuiENTRY(isa_bs_c_2)
34101c812ccStsutsui	add	r0, r1, r2
34201c812ccStsutsui	ldr	r2, [sp, #0]
34301c812ccStsutsui	add	r1, r2, r3
34401c812ccStsutsui	ldr	r2, [sp, #4]
34501c812ccStsutsui	teq	r2, #0
34601c812ccStsutsui	moveq	pc, lr
34701c812ccStsutsui
34801c812ccStsutsui	cmp	r0, r1
34901c812ccStsutsui	blt	2f
35001c812ccStsutsui
35101c812ccStsutsui1:	ldrh	r3, [r0], #2
35201c812ccStsutsui	strh	r3, [r1], #2
35301c812ccStsutsui	subs	r2, r2, #1
35401c812ccStsutsui	bne	1b
35501c812ccStsutsui
35601c812ccStsutsui	mov	pc, lr
35701c812ccStsutsui
35801c812ccStsutsui2:	add	r0, r0, r2, lsl #1
35901c812ccStsutsui	add	r1, r1, r2, lsl #1
36001c812ccStsutsui	sub	r0, r0, #2
36101c812ccStsutsui	sub	r1, r1, #2
36201c812ccStsutsui
36301c812ccStsutsui3:	ldrh	r3, [r0], #-2
36401c812ccStsutsui	strh	r3, [r1], #-2
36501c812ccStsutsui	subs	r2, r2, #1
36601c812ccStsutsui	bne	3b
36701c812ccStsutsui
36801c812ccStsutsui	mov	pc, lr
369