Home | History | Annotate | Line # | Download | only in boot
      1 /*	$NetBSD: consio2.S,v 1.2 2017/05/22 16:59:32 ragge Exp $ */
      2 /*
      3  * Copyright (c) 1994, 1998 Ludd, University of Lule}, Sweden.
      4  * All rights reserved.
      5  *
      6  * Redistribution and use in source and binary forms, with or without
      7  * modification, are permitted provided that the following conditions
      8  * are met:
      9  * 1. Redistributions of source code must retain the above copyright
     10  *    notice, this list of conditions and the following disclaimer.
     11  * 2. Redistributions in binary form must reproduce the above copyright
     12  *    notice, this list of conditions and the following disclaimer in the
     13  *    documentation and/or other materials provided with the distribution.
     14  *
     15  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     16  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     17  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     18  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     19  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     20  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     21  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     22  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     23  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     24  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     25  */
     26 
     27 #include <machine/asm.h>
     28 
     29 /*
     30  * int rom_putchar (int c)	==> putchar() using ROM-routines
     31  */
     32 ENTRY(rom_putchar, 0x0004)		# save-mask: R2
     33 	movl	4(%ap), %r2		# move argument to R2
     34 	jsb	*_C_LABEL(rom_putc)	# write it
     35 	ret				# that is all
     36 
     37 
     38 /*
     39  * int rom_getchar (void)	==> getchar() using ROM-routines
     40  */
     41 ENTRY(rom_getchar, 0x0002)		# save-mask: R1
     42 loop:					# do {
     43 	jsb	*_C_LABEL(rom_getc)	#   call the getc-routine
     44 	tstl	%r0			#   check if char ready
     45 	beql	loop			# } while (R0 == 0)
     46 	movl	%r1, %r0			# R1 holds char
     47 	ret				# we are done
     48 
     49 ENTRY(rom_testchar, 0)
     50 	mnegl	$1,%r0
     51 	jsb	*_C_LABEL(rom_getc)
     52 	tstl	%r0
     53 	beql	1f
     54 	movl	%r1,%r0
     55 1:	ret
     56 
     57 ENTRY(_rtt, 0)
     58 	halt
     59 
     60 
     61 /*
     62  * int ka630_rom_getchar (void) ==> getchar() using ROM-routines on KA630
     63  */
     64 ENTRY(ka630_rom_getchar, 0x0802)	# save-mask: R1, R11
     65 	movl	_C_LABEL(ka630_conspage),%r11  # load location of console page
     66 1:					# do {
     67 	jsb	*0x1C(%r11)		#   call the getc-routine (KA630_GETC)
     68 	blbc	%r0,1b			# } while (R0 == 0)
     69 	movl	%r1,%r0			# R1 holds char
     70 	ret				# we are done
     71 
     72 ENTRY(ka630_rom_testchar, 0)
     73 	movl	_C_LABEL(ka630_conspage),%r3
     74 	jsb	*0x1C(%r3)
     75 	blbc	%r0,1f
     76 	movl	%r1,%r0
     77 1:	ret
     78 
     79 /*
     80  * int ka630_rom_putchar (int c) ==> putchar() using ROM-routines on KA630
     81  */
     82 ENTRY(ka630_rom_putchar, 0x802)	# save-mask: R1, R11
     83 	movl	_C_LABEL(ka630_conspage),%r11
     84 				# load location of console page
     85 1:				# do {
     86 	jsb	*0x20(%r11)	#   is rom ready? (KA630_PUTC_POLL)
     87 	blbc	%r0,1b		# } while (R0 == 0)
     88 	movl	4(%ap),%r1	# R1 holds char
     89 	jsb	*0x24(%r11)	# output character (KA630_PUTC)
     90 	ret			# we are done
     91 
     92 /*
     93  * int ka53_rom_getchar (void)	==> getchar() using ROM-routines on KA53
     94  */
     95 ENTRY(ka53_rom_getchar, 0x0802)	# save-mask: R1, R11
     96 	movl	_C_LABEL(ka53_conspage),%r11
     97 				# load location of console page
     98 1:				# do {
     99 	jsb	*0x64(%r11)	#   test for char
    100 	blbc	%r0,1b		# } while (R0 == 0)
    101 	jsb	*0x6c(%r11)	# get the char
    102 	ret			# we are done
    103 
    104 ENTRY(ka53_rom_testchar, 0)
    105 	movl	_C_LABEL(ka53_conspage),%r3
    106 	jsb	*0x64(%r3)
    107 	blbc	%r0,1f
    108 	jsb	*0x6c(%r3)	# get the char
    109 1:	ret
    110 
    111 /*
    112  * int ka53_rom_putchar (int c) ==> putchar() using ROM-routines on KA53
    113  */
    114 ENTRY(ka53_rom_putchar, 0x0802)	# save-mask: R1, R11
    115 	movl	_C_LABEL(ka53_conspage),%r11
    116 				# load location of console page
    117 1:				# do {
    118 	jsb	*0x20(%r11)	#   is rom ready?
    119 	blbc	%r0,1b		# } whi	le (R0 == 0)
    120 	movl	4(%ap),%r1	# R1 holds char
    121 	jsb	*0x24(%r11)	# output character
    122 	ret			# we are done
    123