1/* $NetBSD: rbus_machdep.c,v 1.7 2011/06/18 06:44:26 matt Exp $ */ 2 3/* 4 * Copyright (c) 2003 5 * KIYOHARA Takashi. All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions 9 * are met: 10 * 1. Redistributions of source code must retain the above copyright 11 * notice, this list of conditions and the following disclaimer. 12 * 2. Redistributions in binary form must reproduce the above copyright 13 * notice, this list of conditions and the following disclaimer in the 14 * documentation and/or other materials provided with the distribution. 15 * 16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 17 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 18 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 19 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 25 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 */ 27 28#include <sys/cdefs.h> 29 30#include <sys/param.h> 31#include <sys/device.h> 32#include <sys/systm.h> 33#include <sys/extent.h> 34#include <sys/bus.h> 35 36 37#include <uvm/uvm_extern.h> 38 39#include <dev/pci/pcivar.h> 40#include <dev/pci/pcidevs.h> 41#include <dev/cardbus/rbus.h> 42 43#include <uvm/uvm_extern.h> 44 45#include "opt_pci.h" 46 47#ifndef PCI_NETBSD_CONFIGURE 48#error requird macro PCI_NETBSD_CONFIGURE 49#endif 50 51#ifdef RBUS_DEBUG 52# define DPRINTF printf 53#else 54# define DPRINTF while (0) printf 55#endif 56 57int 58md_space_map(bus_space_tag_t t, bus_addr_t bpa, bus_size_t size, int flags, bus_space_handle_t *bshp) 59{ 60 DPRINTF("md_space_map: 0x%x, 0x%x, 0x%x\n", t->pbs_base, bpa, size); 61 62 return bus_space_map(t, bpa, size, flags, bshp); 63} 64 65void 66md_space_unmap(bus_space_tag_t t, bus_space_handle_t bsh, bus_size_t size, bus_addr_t *adrp) 67{ 68 paddr_t pa; 69 70 DPRINTF("md_space_unmap: 0x%x 0x%x\n", t->pbs_base, bsh); 71 72 if (adrp != NULL) { 73 pmap_extract(pmap_kernel(), bsh, &pa); 74 *adrp = pa - t->pbs_offset; 75 } 76 bus_space_unmap(t, bsh, size); 77} 78 79rbus_tag_t 80rbus_pccbb_parent_mem(struct pci_attach_args *pa) 81{ 82 bus_space_tag_t bst = pa->pa_memt; 83 84 return rbus_new_root_share(bst, bst->pbs_extent, bst->pbs_base, 85 bst->pbs_limit - bst->pbs_base, 0); 86} 87 88rbus_tag_t 89rbus_pccbb_parent_io(struct pci_attach_args *pa) 90{ 91 bus_space_tag_t bst = pa->pa_iot; 92 93 return rbus_new_root_share(bst, bst->pbs_extent, bst->pbs_base, 94 bst->pbs_limit - bst->pbs_base, 0); 95} 96