source: rtems-libbsd/rtemsbsd/src/rtems-bsd-pci_cfgreg.c @ 36ebd68

4.1155-freebsd-126-freebsd-12freebsd-9.3
Last change on this file since 36ebd68 was 36ebd68, checked in by Jennifer Averett <jennifer.averett@…>, on 06/29/12 at 17:42:00

Added legacy in order to get pcib to work correctly and resoleved fxp attach issue.
The fxp attach has a resource allocation issue still to address, but
should work as soon as that is debugged.

  • Property mode set to 100644
File size: 3.2 KB
Line 
1#include <freebsd/machine/rtems-bsd-config.h>
2
3/**
4 * @file
5 *
6 * @ingroup rtems_bsd_rtems
7 *
8 * @brief This is the rtems version for the FreeBSD cpu specific
9 * file pci_cfgreg.c.  Please note that the Ether Express is not
10 * supported in this version.
11 */
12
13/*
14 * COPYRIGHT (c) 2012. On-Line Applications Research Corporation (OAR).
15 * All rights reserved.
16 *
17 * Redistribution and use in source and binary forms, with or without
18 * modification, are permitted provided that the following conditions
19 * are met:
20 * 1. Redistributions of source code must retain the above copyright
21 *    notice, this list of conditions and the following disclaimer.
22 * 2. Redistributions in binary form must reproduce the above copyright
23 *    notice, this list of conditions and the following disclaimer in the
24 *    documentation and/or other materials provided with the distribution.
25 *
26 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
27 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
29 * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
30 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
31 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
32 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
35 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36 * SUCH DAMAGE.
37 */
38
39#include <freebsd/sys/cdefs.h>
40__FBSDID("$FreeBSD$");
41
42#include <freebsd/sys/param.h>
43#include <freebsd/sys/systm.h>
44#include <freebsd/sys/bus.h>
45#include <freebsd/sys/lock.h>
46#include <freebsd/sys/kernel.h>
47#include <freebsd/sys/malloc.h>
48#include <freebsd/sys/sysctl.h>
49#include <freebsd/dev/pci/pcivar.h>
50#include <freebsd/dev/pci/pcireg.h>
51#include <freebsd/machine/pci_cfgreg.h>
52
53#include <rtems/pci.h>
54
55
56/*
57 * Initialise access to PCI configuration space
58 */
59int
60pci_cfgregopen(void)
61{
62  return(1);
63}
64
65/*
66 * Read configuration space register
67 */
68u_int32_t
69pci_cfgregread(int bus, int slot, int func, int reg, int bytes)
70{
71  u_int32_t value;
72  uint8_t   v8;
73  uint16_t  v16;
74  uint32_t  v32;
75  int       data;
76
77  switch (bytes) {
78    case 1:
79      data = pci_read_config_byte( bus, slot, func, reg, &v8 );
80      value = v8;
81      break;
82    case 2:
83      data = pci_read_config_word( bus, slot, func, reg, &v16 );
84      value = v16;
85      break;
86    case 4:
87      data = pci_read_config_dword( bus, slot, func, reg, &v32 );
88      value = v32;
89      break;
90  }
91
92  return value;
93}
94
95/*
96 * Write configuration space register
97 */
98void
99pci_cfgregwrite(int bus, int slot, int func, int reg, u_int32_t data, int bytes)
100{
101  uint8_t   v8  = data & 0xff;
102  uint16_t  v16 = data & 0xffff;
103  uint32_t  v32 = data;
104
105  switch (bytes) {
106    case 1:
107      pci_write_config_byte( bus, slot, func, reg, v8 );
108      break;
109    case 2:
110      pci_write_config_word( bus, slot, func, reg, v16 );
111      break;
112    case 4:
113      pci_write_config_dword( bus, slot, func, reg, v32 );
114      break;
115  }
116}
Note: See TracBrowser for help on using the repository browser.