Home | History | Annotate | Line # | Download | only in virtex
consinit.c revision 1.1.28.1
      1  1.1.28.1  joerg /*	$NetBSD: consinit.c,v 1.1.28.1 2007/10/26 15:42:27 joerg Exp $ */
      2       1.1  freza 
      3       1.1  freza /*
      4       1.1  freza  * Copyright (c) 2006 Jachym Holecek
      5       1.1  freza  * All rights reserved.
      6       1.1  freza  *
      7       1.1  freza  * Written for DFC Design, s.r.o.
      8       1.1  freza  *
      9       1.1  freza  * Redistribution and use in source and binary forms, with or without
     10       1.1  freza  * modification, are permitted provided that the following conditions
     11       1.1  freza  * are met:
     12       1.1  freza  *
     13       1.1  freza  * 1. Redistributions of source code must retain the above copyright
     14       1.1  freza  *    notice, this list of conditions and the following disclaimer.
     15       1.1  freza  *
     16       1.1  freza  * 2. Redistributions in binary form must reproduce the above copyright
     17       1.1  freza  *    notice, this list of conditions and the following disclaimer in the
     18       1.1  freza  *    documentation and/or other materials provided with the distribution.
     19       1.1  freza  *
     20       1.1  freza  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     21       1.1  freza  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     22       1.1  freza  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     23       1.1  freza  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     24       1.1  freza  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     25       1.1  freza  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     26       1.1  freza  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     27       1.1  freza  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     28       1.1  freza  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     29       1.1  freza  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     30       1.1  freza  */
     31       1.1  freza 
     32       1.1  freza #include "opt_cons.h"
     33       1.1  freza #include "xlcom.h"
     34       1.1  freza 
     35       1.1  freza #include <sys/cdefs.h>
     36  1.1.28.1  joerg __KERNEL_RCSID(0, "$NetBSD: consinit.c,v 1.1.28.1 2007/10/26 15:42:27 joerg Exp $");
     37       1.1  freza 
     38       1.1  freza #include <sys/param.h>
     39       1.1  freza #include <sys/systm.h>
     40       1.1  freza #include <sys/device.h>
     41       1.1  freza 
     42       1.1  freza #include <machine/bus.h>
     43       1.1  freza 
     44       1.1  freza #include <evbppc/virtex/virtex.h>
     45       1.1  freza 
     46       1.1  freza #include <dev/cons.h>
     47       1.1  freza 
     48       1.1  freza 
     49       1.1  freza #if NXLCOM > 0
     50       1.1  freza extern struct consdev 	consdev_xlcom;
     51       1.1  freza void    		xlcom_cninit(struct consdev *, bus_addr_t);
     52  1.1.28.1  joerg #if defined(KGDB)
     53  1.1.28.1  joerg void 			xlcom_kgdbinit(void);
     54  1.1.28.1  joerg #endif
     55       1.1  freza #endif
     56       1.1  freza 
     57       1.1  freza struct consdev 		*cn_tab = NULL;
     58       1.1  freza bus_space_tag_t 	consdev_iot;
     59       1.1  freza bus_space_handle_t 	consdev_ioh;
     60       1.1  freza 
     61  1.1.28.1  joerg #if defined(KGDB)
     62  1.1.28.1  joerg bus_space_tag_t 	kgdb_iot;
     63  1.1.28.1  joerg bus_space_handle_t 	kgdb_ioh;
     64  1.1.28.1  joerg #endif
     65  1.1.28.1  joerg 
     66       1.1  freza 
     67       1.1  freza /*
     68       1.1  freza  * Initialize the system console (hmm, as if anyone can see those panics).
     69       1.1  freza  */
     70       1.1  freza void
     71       1.1  freza consinit(void)
     72       1.1  freza {
     73       1.1  freza 	static int 	initted = 0;
     74       1.1  freza 
     75       1.1  freza 	if (initted)
     76       1.1  freza 		return;
     77       1.1  freza 
     78       1.1  freza 	/* Pick MD knowledge about console. */
     79  1.1.28.1  joerg 	if (virtex_bus_space_tag(CONS_NAME, &consdev_iot))
     80       1.1  freza 		panic("No bus space for %s console", CONS_NAME);
     81       1.1  freza 
     82  1.1.28.1  joerg #if defined(KGDB)
     83  1.1.28.1  joerg 	if (virtex_bus_space_tag(KGDB_NAME, &kgdb_iot))
     84  1.1.28.1  joerg 		panic("No bus space for %s kgdb", KGDB_NAME);
     85  1.1.28.1  joerg #endif
     86  1.1.28.1  joerg 
     87       1.1  freza #if NXLCOM > 0
     88  1.1.28.1  joerg #if defined(KGDB)
     89  1.1.28.1  joerg 	if (strncmp("xlcom", KGDB_NAME, 5)) {
     90  1.1.28.1  joerg 		xlcom_kgdbinit();
     91  1.1.28.1  joerg 
     92  1.1.28.1  joerg 		/* Overtake console device, we're higher priority. */
     93  1.1.28.1  joerg 		if (strcmp(KGDB_NAME, CONS_NAME) == 0 &&
     94  1.1.28.1  joerg 		    KGDB_ADDR == CONS_ADDR)
     95  1.1.28.1  joerg 			goto done;
     96  1.1.28.1  joerg 	}
     97  1.1.28.1  joerg #endif
     98       1.1  freza 	if (strncmp("xlcom", CONS_NAME, 5) == 0) {
     99       1.1  freza 		cn_tab = &consdev_xlcom;
    100       1.1  freza 		xlcom_cninit(cn_tab, CONS_ADDR);
    101       1.1  freza 
    102       1.1  freza 		goto done;
    103       1.1  freza 	}
    104       1.1  freza #endif
    105       1.1  freza 
    106       1.1  freza 	panic("No console"); 	/* XXX really panic? */
    107       1.1  freza  done:
    108  1.1.28.1  joerg 	/* If kgdb overtook console, cn_tab is NULL and dev/cons.c deals. */
    109       1.1  freza 	initted = 1;
    110       1.1  freza }
    111