Home | History | Annotate | Line # | Download | only in obs405
rbus_machdep.c revision 1.2.88.1
      1  1.2.88.1     skrll /*	$NetBSD: rbus_machdep.c,v 1.2.88.1 2009/04/28 07:34:01 skrll 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.1  kiyohara 
     34       1.1  kiyohara #include <sys/extent.h>
     35       1.1  kiyohara 
     36       1.1  kiyohara #include <uvm/uvm_extern.h>
     37       1.1  kiyohara 
     38       1.1  kiyohara #include <machine/bus.h>
     39       1.1  kiyohara 
     40       1.1  kiyohara #include <dev/pci/pcivar.h>
     41       1.1  kiyohara #include <dev/pci/pcidevs.h>
     42       1.1  kiyohara #include <dev/cardbus/rbus.h>
     43       1.1  kiyohara 
     44       1.1  kiyohara #include "opt_pci.h"
     45       1.1  kiyohara 
     46       1.1  kiyohara #ifndef PCI_NETBSD_CONFIGURE
     47       1.1  kiyohara #error requird macro PCI_NETBSD_CONFIGURE
     48       1.1  kiyohara #endif
     49       1.1  kiyohara 
     50       1.1  kiyohara #ifdef RBUS_DEBUG
     51       1.1  kiyohara # define DPRINTF printf
     52       1.1  kiyohara #else
     53       1.1  kiyohara # define DPRINTF while (0) printf
     54       1.1  kiyohara #endif
     55       1.1  kiyohara 
     56       1.1  kiyohara int
     57  1.2.88.1     skrll md_space_map(bus_space_tag_t t, bus_addr_t bpa, bus_size_t size, int flags, bus_space_handle_t *bshp)
     58       1.1  kiyohara {
     59       1.1  kiyohara 	DPRINTF("md_space_map: 0x%x, 0x%x, 0x%x\n", t->pbs_base, bpa, size);
     60       1.1  kiyohara 
     61       1.1  kiyohara 	return bus_space_map(t, bpa, size, flags, bshp);
     62       1.1  kiyohara }
     63       1.1  kiyohara 
     64       1.1  kiyohara void
     65  1.2.88.1     skrll md_space_unmap(bus_space_tag_t t, bus_space_handle_t bsh, bus_size_t size, bus_addr_t *adrp)
     66       1.1  kiyohara {
     67       1.1  kiyohara 	paddr_t pa;
     68       1.1  kiyohara 
     69       1.1  kiyohara 	DPRINTF("md_space_unmap: 0x%x 0x%x\n", t->pbs_base, bsh);
     70       1.1  kiyohara 
     71       1.1  kiyohara 	if (adrp != NULL) {
     72       1.1  kiyohara         	pmap_extract(pmap_kernel(), bsh, &pa);
     73       1.1  kiyohara 		*adrp = pa - t->pbs_offset;
     74       1.1  kiyohara 	}
     75       1.1  kiyohara 	bus_space_unmap(t, bsh, size);
     76       1.1  kiyohara }
     77       1.1  kiyohara 
     78       1.1  kiyohara rbus_tag_t
     79  1.2.88.1     skrll rbus_pccbb_parent_mem(struct pci_attach_args *pa)
     80       1.1  kiyohara {
     81       1.1  kiyohara 	bus_addr_t start;
     82       1.1  kiyohara 	bus_size_t size;
     83       1.1  kiyohara 	pci_chipset_tag_t pc = pa->pa_pc;
     84       1.1  kiyohara 	struct extent *ex = pc->memext;
     85       1.1  kiyohara 
     86       1.1  kiyohara 	start = ex->ex_start;
     87       1.1  kiyohara 	size = ex->ex_end - start;
     88       1.1  kiyohara 
     89       1.1  kiyohara 	return rbus_new_root_share(pa->pa_memt, ex, start, size, 0);
     90       1.1  kiyohara }
     91       1.1  kiyohara 
     92       1.1  kiyohara rbus_tag_t
     93  1.2.88.1     skrll rbus_pccbb_parent_io(struct pci_attach_args *pa)
     94       1.1  kiyohara {
     95       1.1  kiyohara 	bus_addr_t start;
     96       1.1  kiyohara 	bus_size_t size;
     97       1.1  kiyohara 	pci_chipset_tag_t pc = pa->pa_pc;
     98       1.1  kiyohara 	struct extent *ex = pc->ioext;
     99       1.1  kiyohara 
    100       1.1  kiyohara 	start = ex->ex_start;
    101       1.1  kiyohara 	size = ex->ex_end - start;
    102       1.1  kiyohara 
    103       1.1  kiyohara 	return rbus_new_root_share(pa->pa_iot, ex, start, size, 0);
    104       1.1  kiyohara }
    105