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