Home | History | Annotate | Line # | Download | only in ofppc
machdep.c revision 1.118
      1  1.118   thorpej /*	$NetBSD: machdep.c,v 1.118 2021/02/27 02:52:49 thorpej Exp $	*/
      2   1.96   garbled /*-
      3   1.96   garbled  * Copyright (c) 2007 The NetBSD Foundation, Inc.
      4    1.1        ws  * All rights reserved.
      5    1.1        ws  *
      6   1.96   garbled  * This code is derived from software contributed to The NetBSD Foundation
      7   1.96   garbled  * by Tim Rightnour
      8   1.96   garbled  *
      9    1.1        ws  * Redistribution and use in source and binary forms, with or without
     10    1.1        ws  * modification, are permitted provided that the following conditions
     11    1.1        ws  * are met:
     12    1.1        ws  * 1. Redistributions of source code must retain the above copyright
     13    1.1        ws  *    notice, this list of conditions and the following disclaimer.
     14    1.1        ws  * 2. Redistributions in binary form must reproduce the above copyright
     15    1.1        ws  *    notice, this list of conditions and the following disclaimer in the
     16    1.1        ws  *    documentation and/or other materials provided with the distribution.
     17    1.1        ws  *
     18   1.96   garbled  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     19   1.96   garbled  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     20   1.96   garbled  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     21   1.96   garbled  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     22   1.96   garbled  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     23   1.96   garbled  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     24   1.96   garbled  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     25   1.96   garbled  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     26   1.96   garbled  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     27   1.96   garbled  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     28   1.96   garbled  * POSSIBILITY OF SUCH DAMAGE.
     29    1.1        ws  */
     30   1.86     lukem 
     31   1.86     lukem #include <sys/cdefs.h>
     32  1.118   thorpej __KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.118 2021/02/27 02:52:49 thorpej Exp $");
     33  1.118   thorpej 
     34  1.118   thorpej #include "opt_ofwoea.h"
     35    1.1        ws 
     36    1.1        ws #include <sys/param.h>
     37  1.107    dyoung #include <sys/systm.h>
     38    1.1        ws #include <sys/buf.h>
     39   1.93   garbled #include <sys/boot_flag.h>
     40    1.1        ws #include <sys/mount.h>
     41   1.43   thorpej #include <sys/kernel.h>
     42  1.107    dyoung #include <sys/device.h>
     43    1.1        ws 
     44   1.19  sakamoto #include <uvm/uvm_extern.h>
     45   1.19  sakamoto 
     46   1.70   thorpej #include <dev/ofw/openfirm.h>
     47   1.93   garbled #include <dev/cons.h>
     48   1.70   thorpej 
     49   1.68      matt #include <machine/autoconf.h>
     50    1.1        ws #include <machine/pmap.h>
     51    1.1        ws #include <machine/powerpc.h>
     52    1.1        ws #include <machine/trap.h>
     53  1.115    dyoung #include <sys/bus.h>
     54   1.93   garbled #include <machine/isa_machdep.h>
     55   1.54   thorpej 
     56  1.110      matt #include <powerpc/spr.h>
     57  1.110      matt #include <powerpc/oea/spr.h>
     58   1.87      matt #include <powerpc/oea/bat.h>
     59   1.93   garbled #include <powerpc/ofw_cons.h>
     60  1.102   garbled #include <powerpc/rtas.h>
     61   1.71   thorpej 
     62   1.97   garbled #include "com.h"
     63   1.97   garbled #if (NCOM > 0)
     64   1.97   garbled #include <sys/termios.h>
     65   1.97   garbled #include <dev/ic/comreg.h>
     66   1.97   garbled #include <dev/ic/comvar.h>
     67   1.97   garbled #endif
     68  1.109       phx #include "rtas.h"
     69   1.97   garbled 
     70  1.116      matt extern struct pmap ofw_pmap;
     71  1.116      matt extern char bootpath[256];
     72    1.1        ws 
     73   1.99   garbled extern u_int l2cr_config;
     74  1.108       phx #if (NRTAS > 0)
     75  1.103   garbled extern int machine_has_rtas;
     76  1.108       phx #endif
     77   1.99   garbled 
     78  1.105   garbled struct model_data modeldata;
     79  1.118   thorpej static void model_init(void);
     80  1.118   thorpej 
     81  1.118   thorpej #ifdef OFWOEA_DEBUG
     82  1.118   thorpej #define	DPRINTF printf
     83  1.118   thorpej #else
     84  1.118   thorpej #define	DPRINTF while (0) printf
     85  1.118   thorpej #endif
     86  1.118   thorpej 
     87  1.118   thorpej /*
     88  1.118   thorpej  * Scan the device tree for ranges, and return them as bitmap 0..15
     89  1.118   thorpej  */
     90  1.118   thorpej static uint16_t
     91  1.118   thorpej ranges_bitmap(int node, uint16_t bitmap)
     92  1.118   thorpej {
     93  1.118   thorpej 	int child, mlen, acells, scells, reclen, i, j;
     94  1.118   thorpej 	uint32_t addr, len, map[160];
     95  1.118   thorpej 
     96  1.118   thorpej 	for (child = OF_child(node); child; child = OF_peer(child)) {
     97  1.118   thorpej 		mlen = OF_getprop(child, "ranges", map, sizeof(map));
     98  1.118   thorpej 		if (mlen == -1)
     99  1.118   thorpej 	  		goto noranges;
    100  1.118   thorpej 
    101  1.118   thorpej 		j = OF_getprop(child, "#address-cells", &acells,
    102  1.118   thorpej 		    sizeof(acells));
    103  1.118   thorpej 		if (j == -1)
    104  1.118   thorpej 			goto noranges;
    105  1.118   thorpej 
    106  1.118   thorpej 		j = OF_getprop(child, "#size-cells", &scells,
    107  1.118   thorpej 		    sizeof(scells));
    108  1.118   thorpej 		if (j == -1)
    109  1.118   thorpej 			goto noranges;
    110  1.118   thorpej 
    111  1.118   thorpej 		reclen = acells + modeldata.ranges_offset + scells;
    112  1.118   thorpej 
    113  1.118   thorpej 		for (i = 0; i < (mlen / 4) / reclen; i++) {
    114  1.118   thorpej 			addr = map[reclen * i + acells];
    115  1.118   thorpej 			len = map[reclen * i + reclen - 1];
    116  1.118   thorpej 			for (j = 0; j < len / 0x10000000; j++)
    117  1.118   thorpej 				bitmap |= 1 << ((addr+j*0x10000000) >> 28);
    118  1.118   thorpej 			bitmap |= 1 << (addr >> 28);
    119  1.118   thorpej 		}
    120  1.118   thorpej  noranges:
    121  1.118   thorpej 		bitmap |= ranges_bitmap(child, bitmap);
    122  1.118   thorpej 		continue;
    123  1.118   thorpej 	}
    124  1.118   thorpej 	return bitmap;
    125  1.118   thorpej }
    126  1.105   garbled 
    127    1.1        ws void
    128   1.93   garbled initppc(u_int startkernel, u_int endkernel, char *args)
    129    1.1        ws {
    130  1.118   thorpej 	int node, i;
    131  1.118   thorpej 	uint16_t bitmap;
    132  1.118   thorpej 
    133  1.118   thorpej 	node = OF_finddevice("/");
    134  1.118   thorpej 	if (node != -1) {
    135  1.118   thorpej 		i = OF_getprop(node, "model", model_name, sizeof(model_name));
    136  1.118   thorpej 		if (i == -1) {
    137  1.118   thorpej 			OF_getprop(node, "name", model_name,
    138  1.118   thorpej 			    sizeof(model_name));
    139  1.118   thorpej 			model_init();
    140  1.118   thorpej 		}
    141  1.118   thorpej 	}
    142  1.118   thorpej 
    143  1.118   thorpej 	if ((oeacpufeat & OEACPU_NOBAT) == 0) {
    144  1.118   thorpej 		node = OF_finddevice("/");
    145  1.118   thorpej 
    146  1.118   thorpej 		bitmap = ranges_bitmap(node, 0);
    147  1.118   thorpej 		oea_batinit(0);
    148  1.118   thorpej 
    149  1.118   thorpej 		for (i = 1; i < 0x10; i++) {
    150  1.118   thorpej 			/* skip the three vital SR regions */
    151  1.118   thorpej 			if (i == USER_SR || i == KERNEL_SR || i == KERNEL2_SR) {
    152  1.118   thorpej 				continue;
    153  1.118   thorpej 			}
    154  1.118   thorpej 			if (bitmap & (1 << i)) {
    155  1.118   thorpej 				oea_iobat_add(0x10000000 * i, BAT_BL_256M);
    156  1.118   thorpej 				DPRINTF("Batmapped 256M at 0x%x\n",
    157  1.118   thorpej 				    0x10000000 * i);
    158  1.118   thorpej 			}
    159  1.118   thorpej 		}
    160  1.118   thorpej 	}
    161  1.118   thorpej 
    162   1.93   garbled 	ofwoea_initppc(startkernel, endkernel, args);
    163    1.1        ws }
    164    1.1        ws 
    165   1.98   garbled /* perform model-specific actions at initppc() */
    166  1.118   thorpej static void
    167   1.98   garbled model_init(void)
    168   1.98   garbled {
    169  1.105   garbled 	int qhandle, phandle, j;
    170  1.105   garbled 
    171  1.105   garbled 	memset(&modeldata, 0, sizeof(struct model_data));
    172  1.105   garbled 	/* provide sane defaults */
    173  1.105   garbled 	for (j=0; j < MAX_PCI_BUSSES; j++) {
    174  1.105   garbled 		modeldata.pciiodata[j].start = 0x00008000;
    175  1.105   garbled 		modeldata.pciiodata[j].limit = 0x0000ffff;
    176  1.105   garbled 	}
    177  1.105   garbled 	modeldata.ranges_offset = 1;
    178  1.105   garbled 
    179  1.105   garbled 	if (strncmp(model_name, "FirePower,", 10) == 0) {
    180  1.105   garbled 		modeldata.ranges_offset = 0;
    181  1.105   garbled 	}
    182  1.105   garbled 	if (strcmp(model_name, "MOT,PowerStack_II_Pro4000") == 0) {
    183  1.105   garbled 		modeldata.ranges_offset = 0;
    184  1.105   garbled 	}
    185  1.105   garbled 
    186  1.105   garbled 	/* 7044-270 and 7044-170 */
    187  1.105   garbled 	if (strncmp(model_name, "IBM,7044", 8) == 0) {
    188  1.105   garbled 		for (j=0; j < MAX_PCI_BUSSES; j++) {
    189  1.105   garbled 			modeldata.pciiodata[j].start = 0x00fff000;
    190  1.105   garbled 			modeldata.pciiodata[j].limit = 0x00ffffff;
    191  1.105   garbled 		}
    192  1.105   garbled 	}
    193   1.98   garbled 
    194   1.98   garbled 	/* Pegasos1, Pegasos2 */
    195   1.98   garbled 	if (strncmp(model_name, "Pegasos", 7) == 0) {
    196   1.98   garbled 		static uint16_t modew[] = { 640, 800, 1024, 1280, 0 };
    197   1.98   garbled 		static uint16_t modeh[] = { 480, 600, 768, 1024, 0 };
    198   1.98   garbled 		uint32_t width, height, mode, fbaddr;
    199   1.98   garbled 		char buf[32];
    200   1.98   garbled 		int i;
    201   1.98   garbled 
    202  1.105   garbled 		modeldata.pciiodata[0].start = 0x00001400;
    203  1.105   garbled 		modeldata.pciiodata[0].limit = 0x0000ffff;
    204  1.105   garbled 
    205  1.113       phx 		/* the pegasos doesn't bother to set the L2 cache up */
    206   1.99   garbled 		l2cr_config = L2CR_L2PE;
    207   1.99   garbled 
    208   1.98   garbled 		/* fix the device_type property of a graphics card */
    209   1.98   garbled 		for (qhandle = OF_peer(0); qhandle; qhandle = phandle) {
    210   1.98   garbled 			if (OF_getprop(qhandle, "name", buf, sizeof buf) > 0
    211   1.98   garbled 			    && strncmp(buf, "display", 7) == 0) {
    212   1.98   garbled 				OF_setprop(qhandle, "device_type", "display", 8);
    213   1.98   garbled 				break;
    214   1.98   garbled 			}
    215   1.98   garbled 			if ((phandle = OF_child(qhandle)))
    216   1.98   garbled 				continue;
    217   1.98   garbled 			while (qhandle) {
    218   1.98   garbled 				if ((phandle = OF_peer(qhandle)))
    219   1.98   garbled 					break;
    220   1.98   garbled 				qhandle = OF_parent(qhandle);
    221   1.98   garbled 			}
    222   1.98   garbled 		}
    223   1.98   garbled 
    224   1.98   garbled 		/*
    225   1.98   garbled 		 * Get screen width/height and switch to framebuffer mode.
    226   1.98   garbled 		 * The default dimensions are: 800 x 600
    227   1.98   garbled 		 */
    228   1.98   garbled 		OF_interpret("screen-width", 0, 1, &width);
    229   1.98   garbled 		if (width == 0)
    230   1.98   garbled 			width = 800;
    231   1.98   garbled 
    232   1.98   garbled 		OF_interpret("screen-height", 0, 1, &height);
    233   1.98   garbled 		if (height == 0)
    234   1.98   garbled 			height = 600;
    235   1.98   garbled 
    236   1.98   garbled 		/* find VESA mode */
    237   1.98   garbled 		for (i = 0, mode = 0; modew[i] != 0; i++) {
    238   1.98   garbled 			if (modew[i] == width && modeh[i] == height) {
    239   1.98   garbled 				mode = 0x101 + 2 * i;
    240   1.98   garbled 				break;
    241   1.98   garbled 			}
    242   1.98   garbled 		}
    243   1.98   garbled 		if (!mode) {
    244  1.113       phx 			mode = 0x103;
    245   1.98   garbled 			width = 800;
    246   1.98   garbled 			height = 600;
    247   1.98   garbled 		}
    248   1.98   garbled 
    249   1.98   garbled 		/* init frame buffer mode */
    250  1.117  christos 		snprintf(buf, sizeof(buf), "%x vesa-set-mode", mode);
    251   1.98   garbled 		OF_interpret(buf, 0, 0);
    252   1.98   garbled 
    253   1.98   garbled 		/* set dimensions and frame buffer address in OFW */
    254  1.117  christos 		snprintf(buf, sizeof(buf), "%x to screen-width", width);
    255   1.98   garbled 		OF_interpret(buf, 0, 0);
    256  1.117  christos 		snprintf(buf, sizeof(buf), "%x to screen-height", height);
    257   1.98   garbled 		OF_interpret(buf, 0, 0);
    258   1.98   garbled 		OF_interpret("vesa-frame-buffer-adr", 0, 1, &fbaddr);
    259   1.98   garbled 		if (fbaddr != 0) {
    260  1.117  christos 			snprintf(buf, sizeof(buf), "%x to frame-buffer-adr", fbaddr);
    261   1.98   garbled 			OF_interpret(buf, 0, 0);
    262   1.98   garbled 		}
    263   1.98   garbled 	}
    264   1.98   garbled }
    265   1.98   garbled 
    266    1.1        ws void
    267   1.93   garbled cpu_startup(void)
    268    1.1        ws {
    269   1.98   garbled 	oea_startup(model_name[0] ? model_name : NULL);
    270  1.104   garbled 	bus_space_mallocok();
    271    1.1        ws }
    272    1.1        ws 
    273   1.96   garbled 
    274    1.1        ws void
    275   1.93   garbled consinit(void)
    276    1.1        ws {
    277   1.93   garbled 	ofwoea_consinit();
    278   1.71   thorpej }
    279   1.96   garbled 
    280   1.71   thorpej 
    281   1.71   thorpej void
    282   1.93   garbled dumpsys(void)
    283   1.71   thorpej {
    284  1.101   garbled 	aprint_normal("dumpsys: TBD\n");
    285    1.1        ws }
    286    1.1        ws 
    287    1.1        ws /*
    288   1.93   garbled  * Halt or reboot the machine after syncing/dumping according to howto.
    289    1.1        ws  */
    290    1.1        ws 
    291    1.1        ws void
    292   1.93   garbled cpu_reboot(int howto, char *what)
    293    1.1        ws {
    294    1.1        ws 	static int syncing;
    295    1.1        ws 	static char str[256];
    296  1.108       phx 	char *ap = str, *ap1 = ap;
    297  1.108       phx #if (NRTAS > 0)
    298  1.102   garbled 	int junk;
    299  1.108       phx #endif
    300    1.1        ws 
    301    1.1        ws 	boothowto = howto;
    302    1.1        ws 	if (!cold && !(howto & RB_NOSYNC) && !syncing) {
    303    1.1        ws 		syncing = 1;
    304   1.93   garbled 		vfs_shutdown();         /* sync */
    305   1.93   garbled 		resettodr();            /* set wall clock */
    306    1.1        ws 	}
    307    1.1        ws 	splhigh();
    308    1.1        ws 	if (howto & RB_HALT) {
    309    1.1        ws 		doshutdownhooks();
    310  1.107    dyoung 		pmf_system_shutdown(boothowto);
    311  1.101   garbled 		aprint_normal("halted\n\n");
    312  1.108       phx #if (NRTAS > 0)
    313  1.103   garbled 		if ((howto & 0x800) && machine_has_rtas &&
    314  1.103   garbled 		    rtas_has_func(RTAS_FUNC_POWER_OFF))
    315  1.103   garbled 			rtas_call(RTAS_FUNC_POWER_OFF, 2, 1, 0, 0, &junk);
    316  1.108       phx #endif
    317    1.1        ws 		ppc_exit();
    318    1.1        ws 	}
    319    1.1        ws 	if (!cold && (howto & RB_DUMP))
    320   1.82      matt 		oea_dumpsys();
    321    1.1        ws 	doshutdownhooks();
    322  1.107    dyoung 
    323  1.107    dyoung 	pmf_system_shutdown(boothowto);
    324  1.101   garbled 	aprint_normal("rebooting\n\n");
    325   1.95   garbled 
    326  1.108       phx #if (NRTAS > 0)
    327  1.103   garbled 	if (machine_has_rtas && rtas_has_func(RTAS_FUNC_SYSTEM_REBOOT)) {
    328  1.103   garbled 		rtas_call(RTAS_FUNC_SYSTEM_REBOOT, 0, 1, &junk);
    329  1.103   garbled 		for(;;);
    330  1.103   garbled 	}
    331  1.108       phx #endif
    332    1.1        ws 	if (what && *what) {
    333    1.1        ws 		if (strlen(what) > sizeof str - 5)
    334  1.101   garbled 			aprint_normal("boot string too large, ignored\n");
    335    1.1        ws 		else {
    336    1.1        ws 			strcpy(str, what);
    337    1.1        ws 			ap1 = ap = str + strlen(str);
    338    1.1        ws 			*ap++ = ' ';
    339    1.1        ws 		}
    340    1.1        ws 	}
    341    1.1        ws 	*ap++ = '-';
    342    1.1        ws 	if (howto & RB_SINGLE)
    343    1.1        ws 		*ap++ = 's';
    344    1.1        ws 	if (howto & RB_KDB)
    345    1.1        ws 		*ap++ = 'd';
    346    1.1        ws 	*ap++ = 0;
    347    1.1        ws 	if (ap[-2] == '-')
    348    1.1        ws 		*ap1 = 0;
    349    1.1        ws 	ppc_boot(str);
    350    1.1        ws }
    351   1.97   garbled 
    352   1.97   garbled /*
    353   1.97   garbled  */
    354   1.97   garbled 
    355   1.97   garbled #define divrnd(n, q)	(((n)*2/(q)+1)/2)
    356   1.97   garbled 
    357   1.97   garbled void
    358   1.98   garbled ofppc_init_comcons(int isa_node)
    359   1.97   garbled {
    360   1.97   garbled #if (NCOM > 0)
    361   1.97   garbled 	char name[64];
    362   1.97   garbled 	uint32_t reg[2], comfreq;
    363   1.97   garbled 	uint8_t dll, dlm;
    364   1.98   garbled 	int speed, rate, err, com_node, child;
    365  1.104   garbled 	bus_space_handle_t comh;
    366   1.97   garbled 
    367   1.97   garbled 	/* if we have a serial cons, we have work to do */
    368   1.97   garbled 	memset(name, 0, sizeof(name));
    369   1.97   garbled 	OF_getprop(console_node, "device_type", name, sizeof(name));
    370   1.97   garbled 	if (strcmp(name, "serial") != 0)
    371   1.97   garbled 		return;
    372   1.97   garbled 
    373   1.98   garbled 	/* scan ISA children for serial devices to match our console */
    374   1.98   garbled 	com_node = -1;
    375   1.98   garbled 	for (child = OF_child(isa_node); child; child = OF_peer(child)) {
    376   1.98   garbled 		memset(name, 0, sizeof(name));
    377   1.98   garbled 		OF_getprop(child, "device_type", name, sizeof(name));
    378   1.98   garbled 		if (strcmp(name, "serial") == 0) {
    379   1.98   garbled 			/*
    380   1.98   garbled 			 * Serial device even matches our console_node?
    381   1.98   garbled 			 * Then we're done!
    382   1.98   garbled 			 */
    383   1.98   garbled 			if (child == console_node) {
    384   1.98   garbled 				com_node = child;
    385   1.98   garbled 				break;
    386   1.98   garbled 			}
    387   1.98   garbled 			/* remember first serial device found */
    388   1.98   garbled 			if (com_node == -1)
    389   1.98   garbled 				com_node = child;
    390   1.98   garbled 		}
    391   1.98   garbled 	}
    392   1.98   garbled 
    393   1.98   garbled 	if (com_node == -1)
    394   1.98   garbled 		return;
    395   1.98   garbled 
    396   1.98   garbled 	if (OF_getprop(com_node, "reg", reg, sizeof(reg)) == -1)
    397   1.97   garbled 		return;
    398   1.97   garbled 
    399   1.98   garbled 	if (OF_getprop(com_node, "clock-frequency", &comfreq, 4) == -1)
    400   1.97   garbled 		comfreq = 0;
    401   1.97   garbled 
    402   1.97   garbled 	if (comfreq == 0)
    403   1.97   garbled 		comfreq = COM_FREQ;
    404   1.97   garbled 
    405  1.104   garbled 	/* we need to BSM this, and then undo that before calling
    406  1.104   garbled 	 * comcnattach.
    407  1.104   garbled 	 */
    408  1.104   garbled 
    409  1.104   garbled 	if (bus_space_map(&genppc_isa_io_space_tag, reg[1], 8, 0, &comh) != 0)
    410  1.104   garbled 		panic("Can't map isa serial\n");
    411  1.104   garbled 
    412  1.104   garbled 	bus_space_write_1(&genppc_isa_io_space_tag, comh, com_cfcr, LCR_DLAB);
    413  1.104   garbled 	dll = bus_space_read_1(&genppc_isa_io_space_tag, comh, com_dlbl);
    414  1.104   garbled 	dlm = bus_space_read_1(&genppc_isa_io_space_tag, comh, com_dlbh);
    415   1.97   garbled 	rate = dll | (dlm << 8);
    416  1.104   garbled 	bus_space_write_1(&genppc_isa_io_space_tag, comh, com_cfcr, LCR_8BITS);
    417   1.97   garbled 	speed = divrnd((comfreq / 16), rate);
    418   1.97   garbled 	err = speed - (speed + 150)/300 * 300;
    419   1.97   garbled 	speed -= err;
    420   1.97   garbled 	if (err < 0)
    421   1.97   garbled 		err = -err;
    422   1.97   garbled 	if (err > 50)
    423   1.97   garbled 		speed = 9600;
    424   1.97   garbled 
    425  1.104   garbled 	bus_space_unmap(&genppc_isa_io_space_tag, comh, 8);
    426  1.104   garbled 
    427   1.97   garbled 	/* Now we can attach the comcons */
    428   1.97   garbled 	aprint_verbose("Switching to COM console at speed %d", speed);
    429   1.98   garbled 	if (comcnattach(&genppc_isa_io_space_tag, reg[1],
    430   1.98   garbled 	    speed, comfreq, COM_TYPE_NORMAL,
    431   1.97   garbled 	    ((TTYDEF_CFLAG & ~(CSIZE | CSTOPB | PARENB)) | CS8)))
    432   1.97   garbled 		panic("Can't init serial console");
    433   1.97   garbled 	aprint_verbose("\n");
    434   1.97   garbled #endif /*NCOM*/
    435   1.97   garbled }
    436   1.98   garbled 
    437   1.98   garbled void
    438  1.114      matt copy_disp_props(device_t dev, int node, prop_dictionary_t dict)
    439   1.98   garbled {
    440   1.98   garbled 	uint32_t temp;
    441   1.98   garbled 	char typestr[32];
    442   1.98   garbled 
    443   1.98   garbled 	memset(typestr, 0, sizeof(typestr));
    444   1.98   garbled 	OF_getprop(console_node, "device_type", typestr, sizeof(typestr));
    445   1.98   garbled 	if (strcmp(typestr, "serial") != 0) {
    446   1.98   garbled 		/* this is our console, when we don't have a serial console */
    447   1.98   garbled 		prop_dictionary_set_bool(dict, "is_console", 1);
    448   1.98   garbled 	}
    449   1.98   garbled 
    450   1.98   garbled 	if (!of_to_uint32_prop(dict, node, "width", "width")) {
    451   1.98   garbled 
    452   1.98   garbled 		OF_interpret("screen-width", 0, 1, &temp);
    453   1.98   garbled 		prop_dictionary_set_uint32(dict, "width", temp);
    454   1.98   garbled 	}
    455   1.98   garbled 	if (!of_to_uint32_prop(dict, node, "height", "height")) {
    456   1.98   garbled 
    457   1.98   garbled 		OF_interpret("screen-height", 0, 1, &temp);
    458   1.98   garbled 		prop_dictionary_set_uint32(dict, "height", temp);
    459   1.98   garbled 	}
    460   1.98   garbled 	of_to_uint32_prop(dict, node, "linebytes", "linebytes");
    461   1.98   garbled 	if (!of_to_uint32_prop(dict, node, "depth", "depth")) {
    462   1.98   garbled 		/*
    463   1.98   garbled 		 * XXX we should check linebytes vs. width but those
    464   1.98   garbled 		 * FBs that don't have a depth property ( /chaos/control... )
    465   1.98   garbled 		 * won't have linebytes either
    466   1.98   garbled 		 */
    467   1.98   garbled 		prop_dictionary_set_uint32(dict, "depth", 8);
    468   1.98   garbled 	}
    469   1.98   garbled 	if (!of_to_uint32_prop(dict, node, "address", "address")) {
    470   1.98   garbled 		uint32_t fbaddr = 0;
    471  1.111  kiyohara 
    472  1.111  kiyohara 		OF_interpret("frame-buffer-adr", 0, 1, &fbaddr);
    473   1.98   garbled 		if (fbaddr != 0)
    474   1.98   garbled 			prop_dictionary_set_uint32(dict, "address", fbaddr);
    475   1.98   garbled 	}
    476   1.98   garbled }
    477