Home | History | Annotate | Line # | Download | only in common
      1 /*	$NetBSD: prom.S,v 1.3 2008/04/28 20:23:29 martin Exp $	*/
      2 
      3 /*
      4  * Copyright (c) 2000 The NetBSD Foundation, Inc.
      5  * All rights reserved.
      6  *
      7  * This code is derived from software contributed to The NetBSD Foundation
      8  * by Wayne Knowles
      9  *
     10  * Redistribution and use in source and binary forms, with or without
     11  * modification, are permitted provided that the following conditions
     12  * are met:
     13  * 1. Redistributions of source code must retain the above copyright
     14  *    notice, this list of conditions and the following disclaimer.
     15  * 2. Redistributions in binary form must reproduce the above copyright
     16  *    notice, this list of conditions and the following disclaimer in the
     17  *    documentation and/or other materials provided with the distribution.
     18  *
     19  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     20  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     21  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     22  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     23  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     24  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     25  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     26  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     27  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     28  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     29  * POSSIBILITY OF SUCH DAMAGE.
     30  */
     31 
     32 #include <mips/asm.h>
     33 #include <mips/cpuregs.h>
     34 #include <machine/prom.h>
     35 
     36 
     37 LEAF(prom_restart)
     38 	li	v0, MIPS_PROM_RESTART
     39 	j	v0
     40 	move	a0, zero
     41 END(prom_restart)
     42 
     43 NESTED(prom_open, CALLFRAME_SIZ, ra)
     44 	.mask	0x80000000, -4
     45 	subu	sp, sp, CALLFRAME_SIZ
     46 	sw	ra, CALLFRAME_RA(sp)
     47 	li	v0, MIPS_PROM_OPEN
     48 	jal	v0
     49 	nop
     50 	/*
     51 	 * On return t0 contains our _iob structure
     52 	 * v0 contains the file descriptor number
     53 	 */
     54 	la	t4, saiob
     55 	sll	t5, v0, 2
     56 	add	t4, t4, t5
     57 	lw	ra, CALLFRAME_RA(sp)
     58 	addu	sp, sp, CALLFRAME_SIZ
     59 	sw	t0, 0(t4)
     60 	j	ra
     61 	nop
     62 END(prom_open)
     63 
     64 #ifndef LIBSA_NO_DEV_CLOSE
     65 LEAF(prom_close)
     66 	li	v0, MIPS_PROM_CLOSE
     67 	j	v0
     68 	nop
     69 END(prom_close)
     70 #endif
     71 
     72 LEAF(prom_read)
     73 	li	v0, MIPS_PROM_READ
     74 	j	v0
     75 	nop
     76 END(prom_read)
     77 
     78 #ifndef LIBSA_NO_FS_WRITE
     79 LEAF(prom_write)
     80 	li	v0, MIPS_PROM_WRITE
     81 	j	v0
     82 	nop
     83 END(prom_write)
     84 #endif
     85 
     86 LEAF(printf)
     87 	li	v0, MIPS_PROM_PRINTF
     88 	j	v0
     89 	nop
     90 END(printf)
     91 
     92 #ifndef NO_GETCHAR
     93 LEAF(getchar)
     94 	li	v0, MIPS_PROM_GETCHAR
     95 	j	v0
     96 	nop
     97 END(getchar)
     98 
     99 LEAF(putchar)
    100 	li	v0, MIPS_PROM_PUTCHAR
    101 	j	v0
    102 	nop
    103 END(putchar)
    104 #endif
    105 
    106 	.sdata
    107 
    108 	.global	saiob
    109 saiob:	.space	8*4
    110 
    111