Home | History | Annotate | Line # | Download | only in arcbios
arcbios.c revision 1.1
      1 /*	$NetBSD: arcbios.c,v 1.1 2001/07/08 19:58:02 thorpej Exp $	*/
      2 
      3 /*-
      4  * Copyright (c) 2001 The NetBSD Foundation, Inc.
      5  * All rights reserved.
      6  *
      7  * This code is derived from software contributed to The NetBSD Foundation
      8  * by Jason R. Thorpe.
      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  * 3. All advertising materials mentioning features or use of this software
     19  *    must display the following acknowledgement:
     20  *	This product includes software developed by the NetBSD
     21  *	Foundation, Inc. and its contributors.
     22  * 4. Neither the name of The NetBSD Foundation nor the names of its
     23  *    contributors may be used to endorse or promote products derived
     24  *    from this software without specific prior written permission.
     25  *
     26  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     27  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     28  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     29  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     30  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     31  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     32  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     33  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     34  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     35  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     36  * POSSIBILITY OF SUCH DAMAGE.
     37  */
     38 
     39 #include <sys/param.h>
     40 
     41 #include <dev/cons.h>
     42 
     43 #include <dev/arcbios/arcbios.h>
     44 #include <dev/arcbios/arcbiosvar.h>
     45 
     46 const struct arcbios_spb *ARCBIOS_SPB;
     47 const struct arcbios_fv *ARCBIOS;
     48 
     49 int	arcbios_cngetc(dev_t);
     50 void	arcbios_cnputc(dev_t, int);
     51 
     52 struct consdev arcbios_cn = {
     53 	NULL, NULL, arcbios_cngetc, arcbios_cnputc, nullcnpollc, NULL,
     54 	    NODEV, CN_NORMAL,
     55 };
     56 
     57 /*
     58  * arcbios_init:
     59  *
     60  *	Initialize the ARC BIOS.
     61  */
     62 int
     63 arcbios_init(vaddr_t pblkva)
     64 {
     65 
     66 	ARCBIOS_SPB = (struct arcbios_spb *) pblkva;
     67 
     68 	switch (ARCBIOS_SPB->SPBSignature) {
     69 	case ARCBIOS_SPB_SIGNATURE:
     70 	case ARCBIOS_SPB_SIGNATURE_1:
     71 		/* Okay. */
     72 		break;
     73 
     74 	default:
     75 		/* Don't know what this is. */
     76 		return (1);
     77 	}
     78 
     79 	/* Initialize our pointer to the firmware vector. */
     80 	ARCBIOS = ARCBIOS_SPB->FirmwareVector;
     81 
     82 	/* Initialize the bootstrap console. */
     83 	cn_tab = &arcbios_cn;
     84 
     85 	return (0);
     86 }
     87 
     88 int
     89 arcbios_cngetc(dev_t dev)
     90 {
     91 	uint32_t count;
     92 	char c;
     93 
     94 	(*ARCBIOS->Read)(ARCBIOS_STDIN, &c, 1, &count);
     95 	return (c);
     96 }
     97 
     98 void
     99 arcbios_cnputc(dev_t dev, int c)
    100 {
    101 	uint32_t count;
    102 	char ch = c;
    103 
    104 	(*ARCBIOS->Write)(ARCBIOS_STDOUT, &ch, 1, &count);
    105 }
    106