Home | History | Annotate | Line # | Download | only in walnut
machdep.c revision 1.51
      1 /*	$NetBSD: machdep.c,v 1.51 2011/06/18 06:44:28 matt Exp $	*/
      2 
      3 /*
      4  * Copyright 2001, 2002 Wasabi Systems, Inc.
      5  * All rights reserved.
      6  *
      7  * Written by Eduardo Horvath and Simon Burge for Wasabi Systems, Inc.
      8  *
      9  * Redistribution and use in source and binary forms, with or without
     10  * modification, are permitted provided that the following conditions
     11  * are met:
     12  * 1. Redistributions of source code must retain the above copyright
     13  *    notice, this list of conditions and the following disclaimer.
     14  * 2. Redistributions in binary form must reproduce the above copyright
     15  *    notice, this list of conditions and the following disclaimer in the
     16  *    documentation and/or other materials provided with the distribution.
     17  * 3. All advertising materials mentioning features or use of this software
     18  *    must display the following acknowledgement:
     19  *      This product includes software developed for the NetBSD Project by
     20  *      Wasabi Systems, Inc.
     21  * 4. The name of Wasabi Systems, Inc. may not be used to endorse
     22  *    or promote products derived from this software without specific prior
     23  *    written permission.
     24  *
     25  * THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND
     26  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     27  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     28  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL WASABI SYSTEMS, INC
     29  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     30  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     31  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     32  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     33  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     34  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     35  * POSSIBILITY OF SUCH DAMAGE.
     36  */
     37 
     38 /*
     39  * Copyright (C) 1995, 1996 Wolfgang Solfrank.
     40  * Copyright (C) 1995, 1996 TooLs GmbH.
     41  * All rights reserved.
     42  *
     43  * Redistribution and use in source and binary forms, with or without
     44  * modification, are permitted provided that the following conditions
     45  * are met:
     46  * 1. Redistributions of source code must retain the above copyright
     47  *    notice, this list of conditions and the following disclaimer.
     48  * 2. Redistributions in binary form must reproduce the above copyright
     49  *    notice, this list of conditions and the following disclaimer in the
     50  *    documentation and/or other materials provided with the distribution.
     51  * 3. All advertising materials mentioning features or use of this software
     52  *    must display the following acknowledgement:
     53  *	This product includes software developed by TooLs GmbH.
     54  * 4. The name of TooLs GmbH may not be used to endorse or promote products
     55  *    derived from this software without specific prior written permission.
     56  *
     57  * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR
     58  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     59  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     60  * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
     61  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
     62  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
     63  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
     64  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
     65  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
     66  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     67  */
     68 
     69 #include <sys/cdefs.h>
     70 __KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.51 2011/06/18 06:44:28 matt Exp $");
     71 
     72 #include "opt_compat_netbsd.h"
     73 #include "opt_ddb.h"
     74 #include "opt_ipkdb.h"
     75 #include "opt_modular.h"
     76 
     77 #include <sys/param.h>
     78 #include <sys/buf.h>
     79 #include <sys/exec.h>
     80 #include <sys/malloc.h>
     81 #include <sys/mbuf.h>
     82 #include <sys/mount.h>
     83 #include <sys/msgbuf.h>
     84 #include <sys/proc.h>
     85 #include <sys/reboot.h>
     86 #include <sys/syscallargs.h>
     87 #include <sys/syslog.h>
     88 #include <sys/systm.h>
     89 #include <sys/kernel.h>
     90 #include <sys/boot_flag.h>
     91 #include <sys/ksyms.h>
     92 #include <sys/device.h>
     93 #include <sys/module.h>
     94 #include <sys/cpu.h>
     95 #include <sys/bus.h>
     96 
     97 #include <uvm/uvm_extern.h>
     98 
     99 #include <net/netisr.h>
    100 
    101 #include <prop/proplib.h>
    102 
    103 #include <machine/powerpc.h>
    104 #include <machine/trap.h>
    105 #include <machine/walnut.h>
    106 #include <machine/pcb.h>
    107 
    108 #include <powerpc/spr.h>
    109 #include <powerpc/ibm4xx/spr.h>
    110 #include <powerpc/ibm4xx/cpu.h>
    111 #include <powerpc/ibm4xx/dcr4xx.h>
    112 
    113 #include <dev/cons.h>
    114 #include <dev/pci/pcivar.h>
    115 #include <dev/pci/pciconf.h>
    116 
    117 #include "ksyms.h"
    118 
    119 #if defined(DDB)
    120 #include <machine/db_machdep.h>
    121 #include <ddb/db_extern.h>
    122 #endif
    123 
    124 
    125 #define TLB_PG_SIZE 	(16*1024*1024)
    126 
    127 /*
    128  * Global variables used here and there
    129  */
    130 struct vm_map *phys_map = NULL;
    131 
    132 /*
    133  * This should probably be in autoconf!				XXX
    134  */
    135 char cpu_model[80];
    136 char machine[] = MACHINE;		/* from <machine/param.h> */
    137 char machine_arch[] = MACHINE_ARCH;	/* from <machine/param.h> */
    138 
    139 char bootpath[256];
    140 paddr_t msgbuf_paddr;
    141 vaddr_t msgbuf_vaddr;
    142 
    143 #if NKSYMS || defined(DDB) || defined(MODULAR)
    144 void *startsym, *endsym;
    145 #endif
    146 
    147 void initppc(u_int, u_int, char *, void *);
    148 
    149 static void dumpsys(void);
    150 static void install_extint(void (*)(void));
    151 
    152 #define MEMREGIONS	8
    153 struct mem_region physmemr[MEMREGIONS];		/* Hard code memory */
    154 struct mem_region availmemr[MEMREGIONS];	/* Who's supposed to set these up? */
    155 
    156 struct board_cfg_data board_data;
    157 
    158 void
    159 initppc(u_int startkernel, u_int endkernel, char *args, void *info_block)
    160 {
    161 	extern int defaulttrap, defaultsize;
    162 	extern int sctrap, scsize;
    163 	extern int alitrap, alisize;
    164 	extern int dsitrap, dsisize;
    165 	extern int isitrap, isisize;
    166 	extern int mchktrap, mchksize;
    167 	extern int tlbimiss4xx, tlbim4size;
    168 	extern int tlbdmiss4xx, tlbdm4size;
    169 	extern int pitfitwdog, pitfitwdogsize;
    170 	extern int debugtrap, debugsize;
    171 	extern int errata51handler, errata51size;
    172 #ifdef DDB
    173 	extern int ddblow, ddbsize;
    174 #endif
    175 #ifdef IPKDB
    176 	extern int ipkdblow, ipkdbsize;
    177 #endif
    178 	vaddr_t va;
    179 	int exc, dbcr0;
    180 	struct cpu_info * const ci = curcpu();
    181 
    182 	/* Disable all external interrupts */
    183 	mtdcr(DCR_UIC0_BASE + DCR_UIC_ER, 0);
    184 
    185         /* Initialize cache info for memcpy, etc. */
    186         cpu_probe_cache();
    187 
    188 	/* Save info block */
    189 	memcpy(&board_data, info_block, sizeof(board_data));
    190 
    191 	memset(physmemr, 0, sizeof physmemr);
    192 	memset(availmemr, 0, sizeof availmemr);
    193 	physmemr[0].start = 0;
    194 	physmemr[0].size = board_data.mem_size & ~PGOFSET;
    195 	/* Lower memory reserved by eval board BIOS */
    196 	availmemr[0].start = startkernel;
    197 	availmemr[0].size = board_data.mem_size - availmemr[0].start;
    198 
    199 	/* Linear map kernel memory */
    200 	for (va = 0; va < endkernel; va += TLB_PG_SIZE)
    201 		ppc4xx_tlb_reserve(va, va, TLB_PG_SIZE, TLB_EX);
    202 
    203 	/* Map console after physmem (see pmap_tlbmiss()) */
    204 	ppc4xx_tlb_reserve(0xef000000, roundup(physmemr[0].size, TLB_PG_SIZE),
    205 	    TLB_PG_SIZE, TLB_I | TLB_G);
    206 
    207 	/*
    208 	 * Initialize lwp0 and current pcb and pmap pointers.
    209 	 */
    210 	lwp0.l_cpu = ci;
    211 
    212 	curpcb = lwp_getpcb(&lwp0);
    213 	memset(curpcb, 0, sizeof(struct pcb));
    214 	curpcb->pcb_pm = pmap_kernel();
    215 
    216 	/*
    217 	 * Set up trap vectors
    218 	 */
    219 	for (exc = EXC_RSVD; exc <= EXC_LAST; exc += 0x100)
    220 		switch (exc) {
    221 		default:
    222 			memcpy((void *)exc, &defaulttrap, (size_t)&defaultsize);
    223 			break;
    224 		case EXC_EXI:
    225 			/*
    226 			 * This one is (potentially) installed during autoconf
    227 			 */
    228 			break;
    229 		case EXC_SC:
    230 			memcpy((void *)EXC_SC, &sctrap, (size_t)&scsize);
    231 			break;
    232 		case EXC_ALI:
    233 			memcpy((void *)EXC_ALI, &alitrap, (size_t)&alisize);
    234 			break;
    235 		case EXC_DSI:
    236 			memcpy((void *)EXC_DSI, &dsitrap, (size_t)&dsisize);
    237 			break;
    238 		case EXC_ISI:
    239 			memcpy((void *)EXC_ISI, &isitrap, (size_t)&isisize);
    240 			break;
    241 		case EXC_MCHK:
    242 			memcpy((void *)EXC_MCHK, &mchktrap, (size_t)&mchksize);
    243 			break;
    244 		case EXC_ITMISS:
    245 			memcpy((void *)EXC_ITMISS, &tlbimiss4xx,
    246 				(size_t)&tlbim4size);
    247 			break;
    248 		case EXC_DTMISS:
    249 			memcpy((void *)EXC_DTMISS, &tlbdmiss4xx,
    250 				(size_t)&tlbdm4size);
    251 			break;
    252 		/*
    253 		 * EXC_PIT, EXC_FIT, EXC_WDOG handlers
    254 		 * are spaced by 0x10 bytes only..
    255 		 */
    256 		case EXC_PIT:
    257 			memcpy((void *)EXC_PIT, &pitfitwdog,
    258 				(size_t)&pitfitwdogsize);
    259 			break;
    260 		case EXC_DEBUG:
    261 			memcpy((void *)EXC_DEBUG, &debugtrap,
    262 				(size_t)&debugsize);
    263 			break;
    264 		case EXC_DTMISS|EXC_ALI:
    265                         /* PPC405GP Rev D errata item 51 */
    266 			memcpy((void *)(EXC_DTMISS|EXC_ALI), &errata51handler,
    267 				(size_t)&errata51size);
    268 			break;
    269 #if defined(DDB) || defined(IPKDB)
    270 		case EXC_PGM:
    271 #if defined(DDB)
    272 			memcpy((void *)exc, &ddblow, (size_t)&ddbsize);
    273 #elif defined(IPKDB)
    274 			memcpy((void *)exc, &ipkdblow, (size_t)&ipkdbsize);
    275 #endif
    276 #endif /* DDB | IPKDB */
    277 			break;
    278 		}
    279 
    280 	__syncicache((void *)EXC_RST, EXC_LAST - EXC_RST + 0x100);
    281 	mtspr(SPR_EVPR, 0);		/* Set Exception vector base */
    282 
    283 	consinit();
    284 
    285 	/* Handle trap instruction as PGM exception */
    286 	__asm volatile("mfspr %0,%1":"=r"(dbcr0):"K"(SPR_DBCR0));
    287 	__asm volatile("mtspr %0,%1"::"K"(SPR_DBCR0),"r"(dbcr0 & ~DBCR0_TDE));
    288 
    289 	/*
    290 	 * external interrupt handler install
    291 	 */
    292 	install_extint(ext_intr);
    293 
    294 	/*
    295 	 * Now enable translation (and machine checks/recoverable interrupts).
    296 	 */
    297 	__asm volatile ("mfmsr %0; ori %0,%0,%1; mtmsr %0; isync"
    298 		      : : "r"(0), "K"(PSL_IR|PSL_DR));
    299 	/* XXXX PSL_ME - With ME set kernel gets stuck... */
    300 
    301 	uvm_setpagesize();
    302 
    303 	/*
    304 	 * Initialize pmap module.
    305 	 */
    306 	pmap_bootstrap(startkernel, endkernel);
    307 
    308 #ifdef DEBUG
    309 	printf("Board config data:\n");
    310 	printf("  usr_config_ver = %s\n", board_data.usr_config_ver);
    311 	printf("  rom_sw_ver = %s\n", board_data.rom_sw_ver);
    312 	printf("  mem_size = %u\n", board_data.mem_size);
    313 	printf("  mac_address_local = %02x:%02x:%02x:%02x:%02x:%02x\n",
    314 	    board_data.mac_address_local[0], board_data.mac_address_local[1],
    315 	    board_data.mac_address_local[2], board_data.mac_address_local[3],
    316 	    board_data.mac_address_local[4], board_data.mac_address_local[5]);
    317 	printf("  mac_address_pci = %02x:%02x:%02x:%02x:%02x:%02x\n",
    318 	    board_data.mac_address_pci[0], board_data.mac_address_pci[1],
    319 	    board_data.mac_address_pci[2], board_data.mac_address_pci[3],
    320 	    board_data.mac_address_pci[4], board_data.mac_address_pci[5]);
    321 	printf("  processor_speed = %u\n", board_data.processor_speed);
    322 	printf("  plb_speed = %u\n", board_data.plb_speed);
    323 	printf("  pci_speed = %u\n", board_data.pci_speed);
    324 #endif
    325 
    326 #if NKSYMS || defined(DDB) || defined(MODULAR)
    327 	ksyms_addsyms_elf((int)((u_int)endsym - (u_int)startsym), startsym, endsym);
    328 #endif
    329 #ifdef DDB
    330 	if (boothowto & RB_KDB)
    331 		Debugger();
    332 #endif
    333 #ifdef IPKDB
    334 	/*
    335 	 * Now trap to IPKDB
    336 	 */
    337 	ipkdb_init();
    338 	if (boothowto & RB_KDB)
    339 		ipkdb_connect(0);
    340 #endif
    341 
    342 	/*
    343 	 * Look for the ibm4xx modules in the right place.
    344 	 */
    345 	module_machine = module_machine_ibm4xx;
    346 }
    347 
    348 static void
    349 install_extint(void (*handler)(void))
    350 {
    351 	extern int extint, extsize;
    352 	extern u_long extint_call;
    353 	u_long offset = (u_long)handler - (u_long)&extint_call;
    354 	int msr;
    355 
    356 #ifdef	DIAGNOSTIC
    357 	if (offset > 0x1ffffff)
    358 		panic("install_extint: too far away");
    359 #endif
    360 	__asm volatile ("mfmsr %0; wrteei 0" : "=r"(msr));
    361 	extint_call = (extint_call & 0xfc000003) | offset;
    362 	memcpy((void *)EXC_EXI, &extint, (size_t)&extsize);
    363 	__syncicache((void *)&extint_call, sizeof extint_call);
    364 	__syncicache((void *)EXC_EXI, (int)&extsize);
    365 	__asm volatile ("mtmsr %0" :: "r"(msr));
    366 }
    367 
    368 /*
    369  * Machine dependent startup code.
    370  */
    371 
    372 char msgbuf[MSGBUFSIZE];
    373 
    374 void
    375 cpu_startup(void)
    376 {
    377 	vaddr_t minaddr, maxaddr;
    378 	prop_number_t pn;
    379 	prop_data_t pd;
    380 	char pbuf[9];
    381 
    382 	/*
    383 	 * Initialize error message buffer (at end of core).
    384 	 */
    385 #if 0	/* For some reason this fails... --Artem
    386 	 * Besides, do we really have to put it at the end of core?
    387 	 * Let's use static buffer for now
    388 	 */
    389 	if (!(msgbuf_vaddr = uvm_km_alloc(kernel_map, round_page(MSGBUFSIZE), 0,
    390 	    UVM_KMF_VAONLY)))
    391 		panic("startup: no room for message buffer");
    392 	for (i = 0; i < btoc(MSGBUFSIZE); i++)
    393 		pmap_kenter_pa(msgbuf_vaddr + i * PAGE_SIZE,
    394 		    msgbuf_paddr + i * PAGE_SIZE, VM_PROT_READ|VM_PROT_WRITE, 0);
    395 	initmsgbuf((void *)msgbuf_vaddr, round_page(MSGBUFSIZE));
    396 #else
    397 	initmsgbuf((void *)msgbuf, round_page(MSGBUFSIZE));
    398 #endif
    399 
    400 	printf("%s%s", copyright, version);
    401 	printf("Walnut PowerPC 405GP Evaluation Board\n");
    402 
    403 	format_bytes(pbuf, sizeof(pbuf), ctob(physmem));
    404 	printf("total memory = %s\n", pbuf);
    405 
    406 	minaddr = 0;
    407 	/*
    408 	 * Allocate a submap for physio
    409 	 */
    410 	phys_map = uvm_km_suballoc(kernel_map, &minaddr, &maxaddr,
    411 				 VM_PHYS_SIZE, 0, false, NULL);
    412 
    413 	/*
    414 	 * No need to allocate an mbuf cluster submap.  Mbuf clusters
    415 	 * are allocated via the pool allocator, and we use direct-mapped
    416 	 * pool pages.
    417 	 */
    418 
    419 	format_bytes(pbuf, sizeof(pbuf), ptoa(uvmexp.free));
    420 	printf("avail memory = %s\n", pbuf);
    421 
    422 	/*
    423 	 * Set up the board properties dictionary.
    424 	 */
    425 	board_properties = prop_dictionary_create();
    426 	KASSERT(board_properties != NULL);
    427 
    428 	pn = prop_number_create_integer(board_data.mem_size);
    429 	KASSERT(pn != NULL);
    430 	if (prop_dictionary_set(board_properties, "mem-size", pn) == false)
    431 		panic("setting mem-size");
    432 	prop_object_release(pn);
    433 
    434 	pd = prop_data_create_data_nocopy(board_data.mac_address_local,
    435 					  sizeof(board_data.mac_address_local));
    436 	KASSERT(pd != NULL);
    437 	if (prop_dictionary_set(board_properties, "emac0-mac-addr",
    438 				pd) == false)
    439 		panic("setting emac0-mac-addr");
    440 	prop_object_release(pd);
    441 
    442 	pd = prop_data_create_data_nocopy(board_data.mac_address_pci,
    443 					  sizeof(board_data.mac_address_pci));
    444 	KASSERT(pd != NULL);
    445 	if (prop_dictionary_set(board_properties, "sip0-mac-addr",
    446 				pd) == false)
    447 		panic("setting sip0-mac-addr");
    448 	prop_object_release(pd);
    449 
    450 	pn = prop_number_create_integer(board_data.processor_speed);
    451 	KASSERT(pn != NULL);
    452 	if (prop_dictionary_set(board_properties, "processor-frequency",
    453 				pn) == false)
    454 		panic("setting processor-frequency");
    455 	prop_object_release(pn);
    456 
    457 	/*
    458 	 * Now that we have VM, malloc()s are OK in bus_space.
    459 	 */
    460 	bus_space_mallocok();
    461 	fake_mapiodev = 0;
    462 }
    463 
    464 
    465 static void
    466 dumpsys(void)
    467 {
    468 
    469 	printf("dumpsys: TBD\n");
    470 }
    471 
    472 /*
    473  * Halt or reboot the machine after syncing/dumping according to howto.
    474  */
    475 void
    476 cpu_reboot(int howto, char *what)
    477 {
    478 	static int syncing;
    479 	static char str[256];
    480 	char *ap = str, *ap1 = ap;
    481 
    482 	boothowto = howto;
    483 	if (!cold && !(howto & RB_NOSYNC) && !syncing) {
    484 		syncing = 1;
    485 		vfs_shutdown();		/* sync */
    486 		resettodr();		/* set wall clock */
    487 	}
    488 
    489 	splhigh();
    490 
    491 	if (!cold && (howto & RB_DUMP))
    492 		dumpsys();
    493 
    494 	doshutdownhooks();
    495 
    496 	pmf_system_shutdown(boothowto);
    497 
    498 	if ((howto & RB_POWERDOWN) == RB_POWERDOWN) {
    499 	  /* Power off here if we know how...*/
    500 	}
    501 
    502 	if (howto & RB_HALT) {
    503 		printf("halted\n\n");
    504 
    505 		goto reboot;	/* XXX for now... */
    506 
    507 #ifdef DDB
    508 		printf("dropping to debugger\n");
    509 		while(1)
    510 			Debugger();
    511 #endif
    512 	}
    513 
    514 	printf("rebooting\n\n");
    515 	if (what && *what) {
    516 		if (strlen(what) > sizeof str - 5)
    517 			printf("boot string too large, ignored\n");
    518 		else {
    519 			strcpy(str, what);
    520 			ap1 = ap = str + strlen(str);
    521 			*ap++ = ' ';
    522 		}
    523 	}
    524 	*ap++ = '-';
    525 	if (howto & RB_SINGLE)
    526 		*ap++ = 's';
    527 	if (howto & RB_KDB)
    528 		*ap++ = 'd';
    529 	*ap++ = 0;
    530 	if (ap[-2] == '-')
    531 		*ap1 = 0;
    532 
    533 	/* flush cache for msgbuf */
    534 	__syncicache((void *)msgbuf_paddr, round_page(MSGBUFSIZE));
    535 
    536  reboot:
    537 	ppc4xx_reset();
    538 
    539 	printf("ppc4xx_reset() failed!\n");
    540 #ifdef DDB
    541 	while(1)
    542 		Debugger();
    543 #else
    544 	while (1)
    545 		/* nothing */;
    546 #endif
    547 }
    548 
    549 void
    550 mem_regions(struct mem_region **mem, struct mem_region **avail)
    551 {
    552 
    553 	*mem = physmemr;
    554 	*avail = availmemr;
    555 }
    556 
    557 
    558 int
    559 pci_bus_maxdevs(pci_chipset_tag_t pc, int busno)
    560 {
    561 
    562 	/*
    563 	 * Bus number is irrelevant.  Configuration Mechanism 1 is in
    564 	 * use, can have devices 0-32 (i.e. the `normal' range).
    565 	 */
    566 	return 5;
    567 }
    568 
    569 int
    570 pci_intr_map(const struct pci_attach_args *pa, pci_intr_handle_t *ihp)
    571 {
    572 	int pin = pa->pa_intrpin;
    573 	int dev = pa->pa_device;
    574 
    575 	if (pin == 0)
    576 		/* No IRQ used. */
    577 		goto bad;
    578 
    579 	if (pin > 4) {
    580 		printf("pci_intr_map: bad interrupt pin %d\n", pin);
    581 		goto bad;
    582 	}
    583 
    584 	/*
    585 	 * We need to map the interrupt pin to the interrupt bit in the UIC
    586 	 * associated with it.  This is highly machine-dependent.
    587 	 */
    588 	switch(dev) {
    589 	case 1:
    590 	case 2:
    591 	case 3:
    592 	case 4:
    593 		*ihp = 27 + dev;
    594 		break;
    595 	default:
    596 		printf("Hmm.. PCI device %d should not exist on this board\n",
    597 			dev);
    598 		goto bad;
    599 	}
    600 	return 0;
    601 
    602 bad:
    603 	*ihp = -1;
    604 	return 1;
    605 }
    606 
    607 void
    608 pci_conf_interrupt(pci_chipset_tag_t pc, int bus, int dev, int pin,
    609 		   int swiz, int *iline)
    610 {
    611 
    612 	if (bus == 0)
    613 		switch(dev) {
    614 		case 1:
    615 		case 2:
    616 		case 3:
    617 		case 4:
    618 			*iline = 31 - dev;
    619 		}
    620 	else
    621 		*iline = 20 + ((swiz + dev + 1) & 3);
    622 }
    623