Wed Jul 24 03:01:09 2013 UTC ()
Add pci_bus_alloc_resource to <linux/pci.h>.


(riastradh)
diff -r1.1.2.3 -r1.1.2.4 src/sys/external/bsd/drm2/include/linux/pci.h

cvs diff -r1.1.2.3 -r1.1.2.4 src/sys/external/bsd/drm2/include/linux/pci.h (expand / switch to unified diff)

--- src/sys/external/bsd/drm2/include/linux/pci.h 2013/07/24 03:00:34 1.1.2.3
+++ src/sys/external/bsd/drm2/include/linux/pci.h 2013/07/24 03:01:09 1.1.2.4
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: pci.h,v 1.1.2.3 2013/07/24 03:00:34 riastradh Exp $ */ 1/* $NetBSD: pci.h,v 1.1.2.4 2013/07/24 03:01:09 riastradh Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2013 The NetBSD Foundation, Inc. 4 * Copyright (c) 2013 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to The NetBSD Foundation 7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Taylor R. Campbell. 8 * by Taylor R. Campbell.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
@@ -22,43 +22,94 @@ @@ -22,43 +22,94 @@
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE. 29 * POSSIBILITY OF SUCH DAMAGE.
30 */ 30 */
31 31
32#ifndef _LINUX_PCI_H_ 32#ifndef _LINUX_PCI_H_
33#define _LINUX_PCI_H_ 33#define _LINUX_PCI_H_
34 34
 35#include <sys/types.h>
 36#include <sys/bus.h>
 37#include <sys/systm.h>
 38
35#include <dev/pci/pcivar.h> 39#include <dev/pci/pcivar.h>
36 40
 41#include <linux/ioport.h>
 42
 43struct pci_bus;
37struct pci_device_id; 44struct pci_device_id;
38 45
39struct pci_dev { 46struct pci_dev {
 47 struct pci_bus *bus;
40 struct pci_attach_args pd_pa; 48 struct pci_attach_args pd_pa;
41}; 49};
42 50
43#define PCI_CAP_ID_AGP PCI_CAP_AGP 51#define PCI_CAP_ID_AGP PCI_CAP_AGP
44 52
45static inline int 53static inline int
46pci_find_capability(struct pci_dev *pdev, int cap) 54pci_find_capability(struct pci_dev *pdev, int cap)
47{ 55{
48 return pci_get_capability(pdev->pd_pa.pa_pc, pdev->pd_pa.pa_tag, cap, 56 return pci_get_capability(pdev->pd_pa.pa_pc, pdev->pd_pa.pa_tag, cap,
49 NULL, NULL); 57 NULL, NULL);
50} 58}
51 59
52static inline void 60static inline void
53pci_config_read_dword(struct pci_dev *pdev, int reg, uint32_t *valuep) 61pci_read_config_dword(struct pci_dev *pdev, int reg, uint32_t *valuep)
54{ 62{
55 *valuep = pci_conf_read(pdev->pd_pa.pa_pc, pdev->pd_pa.pa_tag, reg); 63 *valuep = pci_conf_read(pdev->pd_pa.pa_pc, pdev->pd_pa.pa_tag, reg);
56} 64}
57 65
58static inline void 66static inline void
59pci_config_write_dword(struct pci_dev *pdev, int reg, uint32_t value) 67pci_write_config_dword(struct pci_dev *pdev, int reg, uint32_t value)
60{ 68{
61 pci_conf_write(pdev->pd_pa.pa_pc, pdev->pd_pa.pa_tag, reg, value); 69 pci_conf_write(pdev->pd_pa.pa_pc, pdev->pd_pa.pa_tag, reg, value);
62} 70}
63 71
 72#define PCIBIOS_MIN_MEM 0 /* XXX bogus x86 kludge bollocks */
 73
 74static inline bus_addr_t
 75pcibios_align_resource(void *p, const struct resource *resource,
 76 bus_addr_t addr, bus_size_t size)
 77{
 78 panic("pcibios_align_resource has accessed unaligned neurons!");
 79}
 80
 81static inline int
 82pci_bus_alloc_resource(struct pci_bus *bus, struct resource *resource,
 83 bus_size_t size, bus_size_t align, bus_addr_t start, int type __unused,
 84 bus_addr_t (*align_fn)(void *, const struct resource *, bus_addr_t,
 85 bus_size_t) __unused,
 86 struct pci_dev *pdev)
 87{
 88 const struct pci_attach_args *const pa = &pdev->pd_pa;
 89 bus_space_tag_t bst;
 90 int error;
 91
 92 switch (resource->flags) {
 93 case IORESOURCE_MEM:
 94 bst = pa->pa_memt;
 95 break;
 96
 97 case IORESOURCE_IO:
 98 bst = pa->pa_iot;
 99 break;
 100
 101 default:
 102 panic("I don't know what kind of resource you want!");
 103 }
 104
 105 resource->r_bst = bst;
 106 error = bus_space_alloc(bst, start, 0xffffffffffffffffULL /* XXX */,
 107 size, align, 0, 0, &resource->start, &resource->r_bsh);
 108 if (error)
 109 return error;
 110
 111 resource->size = size;
 112 return 0;
 113}
 114
64#endif /* _LINUX_PCI_H_ */ 115#endif /* _LINUX_PCI_H_ */