mirror of
https://git.rtems.org/rtems-libbsd/
synced 2025-10-14 07:59:07 +08:00
Update to FreeBSD head 2016-08-23
Git mirror commit 9fe7c416e6abb28b1398fd3e5687099846800cfd.
This commit is contained in:
@@ -123,38 +123,22 @@
|
||||
#define BUS_SPACE_MAXADDR 0xFFFFFFFF
|
||||
#endif
|
||||
|
||||
#define BUS_SPACE_INVALID_DATA (~0)
|
||||
#define BUS_SPACE_UNRESTRICTED (~0)
|
||||
|
||||
/*
|
||||
* Map a region of device bus space into CPU virtual address space.
|
||||
*/
|
||||
|
||||
static __inline int bus_space_map(bus_space_tag_t t, bus_addr_t addr,
|
||||
bus_size_t size, int flags,
|
||||
bus_space_handle_t *bshp);
|
||||
|
||||
static __inline int
|
||||
bus_space_map(bus_space_tag_t t __unused, bus_addr_t addr,
|
||||
bus_size_t size __unused, int flags __unused,
|
||||
bus_space_handle_t *bshp)
|
||||
{
|
||||
|
||||
*bshp = addr;
|
||||
return (0);
|
||||
}
|
||||
int bus_space_map(bus_space_tag_t tag, bus_addr_t addr, bus_size_t size,
|
||||
int flags, bus_space_handle_t *bshp);
|
||||
|
||||
/*
|
||||
* Unmap a region of device bus space.
|
||||
*/
|
||||
|
||||
static __inline void bus_space_unmap(bus_space_tag_t t, bus_space_handle_t bsh,
|
||||
bus_size_t size);
|
||||
|
||||
static __inline void
|
||||
bus_space_unmap(bus_space_tag_t t __unused, bus_space_handle_t bsh __unused,
|
||||
bus_size_t size __unused)
|
||||
{
|
||||
}
|
||||
void bus_space_unmap(bus_space_tag_t tag, bus_space_handle_t bsh,
|
||||
bus_size_t size);
|
||||
|
||||
/*
|
||||
* Get a new handle for a subregion of an already-mapped area of bus space.
|
||||
@@ -214,6 +198,12 @@ static __inline u_int32_t bus_space_read_4(bus_space_tag_t tag,
|
||||
bus_space_handle_t handle,
|
||||
bus_size_t offset);
|
||||
|
||||
#ifdef __amd64__
|
||||
static __inline uint64_t bus_space_read_8(bus_space_tag_t tag,
|
||||
bus_space_handle_t handle,
|
||||
bus_size_t offset);
|
||||
#endif
|
||||
|
||||
static __inline u_int8_t
|
||||
bus_space_read_1(bus_space_tag_t tag, bus_space_handle_t handle,
|
||||
bus_size_t offset)
|
||||
@@ -244,8 +234,16 @@ bus_space_read_4(bus_space_tag_t tag, bus_space_handle_t handle,
|
||||
return (*(volatile u_int32_t *)(handle + offset));
|
||||
}
|
||||
|
||||
#if 0 /* Cause a link error for bus_space_read_8 */
|
||||
#define bus_space_read_8(t, h, o) !!! bus_space_read_8 unimplemented !!!
|
||||
#ifdef __amd64__
|
||||
static __inline uint64_t
|
||||
bus_space_read_8(bus_space_tag_t tag, bus_space_handle_t handle,
|
||||
bus_size_t offset)
|
||||
{
|
||||
|
||||
if (tag == X86_BUS_SPACE_IO) /* No 8 byte IO space access on x86 */
|
||||
return (BUS_SPACE_INVALID_DATA);
|
||||
return (*(volatile uint64_t *)(handle + offset));
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
@@ -472,6 +470,12 @@ static __inline void bus_space_write_4(bus_space_tag_t tag,
|
||||
bus_space_handle_t bsh,
|
||||
bus_size_t offset, u_int32_t value);
|
||||
|
||||
#ifdef __amd64__
|
||||
static __inline void bus_space_write_8(bus_space_tag_t tag,
|
||||
bus_space_handle_t bsh,
|
||||
bus_size_t offset, uint64_t value);
|
||||
#endif
|
||||
|
||||
static __inline void
|
||||
bus_space_write_1(bus_space_tag_t tag, bus_space_handle_t bsh,
|
||||
bus_size_t offset, u_int8_t value)
|
||||
@@ -505,8 +509,17 @@ bus_space_write_4(bus_space_tag_t tag, bus_space_handle_t bsh,
|
||||
*(volatile u_int32_t *)(bsh + offset) = value;
|
||||
}
|
||||
|
||||
#if 0 /* Cause a link error for bus_space_write_8 */
|
||||
#define bus_space_write_8 !!! bus_space_write_8 not implemented !!!
|
||||
#ifdef __amd64__
|
||||
static __inline void
|
||||
bus_space_write_8(bus_space_tag_t tag, bus_space_handle_t bsh,
|
||||
bus_size_t offset, uint64_t value)
|
||||
{
|
||||
|
||||
if (tag == X86_BUS_SPACE_IO) /* No 8 byte IO space access on x86 */
|
||||
return;
|
||||
else
|
||||
*(volatile uint64_t *)(bsh + offset) = value;
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
|
@@ -46,7 +46,7 @@
|
||||
#define CONF2_ENABLE_CHK 0x0e
|
||||
#define CONF2_ENABLE_RES 0x0e
|
||||
|
||||
u_long hostb_alloc_start(int type, u_long start, u_long end, u_long count);
|
||||
rman_res_t hostb_alloc_start(int type, rman_res_t start, rman_res_t end, rman_res_t count);
|
||||
int pcie_cfgregopen(uint64_t base, uint8_t minbus, uint8_t maxbus);
|
||||
int pci_cfgregopen(void);
|
||||
u_int32_t pci_cfgregread(int bus, int slot, int func, int reg, int bytes);
|
||||
|
@@ -47,7 +47,7 @@ __FBSDID("$FreeBSD$");
|
||||
#ifdef CPU_ELAN
|
||||
#include <machine/md_var.h>
|
||||
#endif
|
||||
#include <machine/legacyvar.h>
|
||||
#include <x86/legacyvar.h>
|
||||
#include <machine/pci_cfgreg.h>
|
||||
#include <machine/resource.h>
|
||||
|
||||
@@ -94,7 +94,7 @@ legacy_pcib_route_interrupt(device_t pcib, device_t dev, int pin)
|
||||
|
||||
/* Pass MSI requests up to the nexus. */
|
||||
|
||||
static int
|
||||
int
|
||||
legacy_pcib_alloc_msi(device_t pcib, device_t dev, int count, int maxcount,
|
||||
int *irqs)
|
||||
{
|
||||
@@ -105,7 +105,7 @@ legacy_pcib_alloc_msi(device_t pcib, device_t dev, int count, int maxcount,
|
||||
irqs));
|
||||
}
|
||||
|
||||
static int
|
||||
int
|
||||
legacy_pcib_alloc_msix(device_t pcib, device_t dev, int *irq)
|
||||
{
|
||||
device_t bus;
|
||||
@@ -135,7 +135,6 @@ legacy_pcib_map_msi(device_t pcib, device_t dev, int irq, uint64_t *addr,
|
||||
slot, func));
|
||||
pci_ht_map_msi(hostb, *addr);
|
||||
return (0);
|
||||
|
||||
}
|
||||
|
||||
static const char *
|
||||
@@ -527,7 +526,7 @@ legacy_pcib_attach(device_t dev)
|
||||
device_probe_and_attach(pir);
|
||||
}
|
||||
#endif
|
||||
device_add_child(dev, "pci", bus);
|
||||
device_add_child(dev, "pci", -1);
|
||||
return bus_generic_attach(dev);
|
||||
}
|
||||
|
||||
@@ -578,12 +577,11 @@ legacy_pcib_write_ivar(device_t dev, device_t child, int which,
|
||||
SYSCTL_DECL(_hw_pci);
|
||||
|
||||
static unsigned long host_mem_start = 0x80000000;
|
||||
TUNABLE_ULONG("hw.pci.host_mem_start", &host_mem_start);
|
||||
SYSCTL_ULONG(_hw_pci, OID_AUTO, host_mem_start, CTLFLAG_RDTUN, &host_mem_start,
|
||||
0, "Limit the host bridge memory to being above this address.");
|
||||
|
||||
u_long
|
||||
hostb_alloc_start(int type, u_long start, u_long end, u_long count)
|
||||
rman_res_t
|
||||
hostb_alloc_start(int type, rman_res_t start, rman_res_t end, rman_res_t count)
|
||||
{
|
||||
|
||||
if (start + count - 1 != end) {
|
||||
@@ -597,20 +595,41 @@ hostb_alloc_start(int type, u_long start, u_long end, u_long count)
|
||||
|
||||
struct resource *
|
||||
legacy_pcib_alloc_resource(device_t dev, device_t child, int type, int *rid,
|
||||
u_long start, u_long end, u_long count, u_int flags)
|
||||
rman_res_t start, rman_res_t end, rman_res_t count, u_int flags)
|
||||
{
|
||||
|
||||
#if defined(__rtems__) && defined(__i386__)
|
||||
/*
|
||||
* FIXME: This is a quick and dirty hack. See pci_reserve_map().
|
||||
*/
|
||||
#else /* __rtems__ */
|
||||
start = hostb_alloc_start(type, start, end, count);
|
||||
#endif /* __rtems__ */
|
||||
return (bus_generic_alloc_resource(dev, child, type, rid, start, end,
|
||||
count, flags));
|
||||
#if defined(NEW_PCIB) && defined(PCI_RES_BUS)
|
||||
if (type == PCI_RES_BUS)
|
||||
return (pci_domain_alloc_bus(0, child, rid, start, end, count,
|
||||
flags));
|
||||
#endif
|
||||
start = hostb_alloc_start(type, start, end, count);
|
||||
return (bus_generic_alloc_resource(dev, child, type, rid, start, end,
|
||||
count, flags));
|
||||
}
|
||||
|
||||
#if defined(NEW_PCIB) && defined(PCI_RES_BUS)
|
||||
int
|
||||
legacy_pcib_adjust_resource(device_t dev, device_t child, int type,
|
||||
struct resource *r, rman_res_t start, rman_res_t end)
|
||||
{
|
||||
|
||||
if (type == PCI_RES_BUS)
|
||||
return (pci_domain_adjust_bus(0, child, r, start, end));
|
||||
return (bus_generic_adjust_resource(dev, child, type, r, start, end));
|
||||
}
|
||||
|
||||
int
|
||||
legacy_pcib_release_resource(device_t dev, device_t child, int type, int rid,
|
||||
struct resource *r)
|
||||
{
|
||||
|
||||
if (type == PCI_RES_BUS)
|
||||
return (pci_domain_release_bus(0, child, rid, r));
|
||||
return (bus_generic_release_resource(dev, child, type, rid, r));
|
||||
}
|
||||
#endif
|
||||
|
||||
static device_method_t legacy_pcib_methods[] = {
|
||||
/* Device interface */
|
||||
DEVMETHOD(device_identify, legacy_pcib_identify),
|
||||
@@ -624,8 +643,13 @@ static device_method_t legacy_pcib_methods[] = {
|
||||
DEVMETHOD(bus_read_ivar, legacy_pcib_read_ivar),
|
||||
DEVMETHOD(bus_write_ivar, legacy_pcib_write_ivar),
|
||||
DEVMETHOD(bus_alloc_resource, legacy_pcib_alloc_resource),
|
||||
#if defined(NEW_PCIB) && defined(PCI_RES_BUS)
|
||||
DEVMETHOD(bus_adjust_resource, legacy_pcib_adjust_resource),
|
||||
DEVMETHOD(bus_release_resource, legacy_pcib_release_resource),
|
||||
#else
|
||||
DEVMETHOD(bus_adjust_resource, bus_generic_adjust_resource),
|
||||
DEVMETHOD(bus_release_resource, bus_generic_release_resource),
|
||||
#endif
|
||||
DEVMETHOD(bus_activate_resource, bus_generic_activate_resource),
|
||||
DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource),
|
||||
DEVMETHOD(bus_setup_intr, bus_generic_setup_intr),
|
||||
|
Reference in New Issue
Block a user