mirror of
https://git.rtems.org/rtems-libbsd/
synced 2025-10-14 08:44:27 +08:00
Update to FreeBSD 9.2
This commit is contained in:
@@ -54,6 +54,7 @@ __FBSDID("$FreeBSD$");
|
||||
#include <i386/bios/mca_machdep.h>
|
||||
#endif
|
||||
|
||||
#include <machine/clock.h>
|
||||
#include <machine/legacyvar.h>
|
||||
#include <machine/resource.h>
|
||||
|
||||
@@ -351,9 +352,22 @@ cpu_read_ivar(device_t dev, device_t child, int index, uintptr_t *result)
|
||||
{
|
||||
struct cpu_device *cpdev;
|
||||
|
||||
if (index != CPU_IVAR_PCPU)
|
||||
switch (index) {
|
||||
case CPU_IVAR_PCPU:
|
||||
cpdev = device_get_ivars(child);
|
||||
*result = (uintptr_t)cpdev->cd_pcpu;
|
||||
break;
|
||||
#ifndef __rtems__
|
||||
case CPU_IVAR_NOMINAL_MHZ:
|
||||
if (tsc_is_invariant) {
|
||||
*result = (uintptr_t)(atomic_load_acq_64(&tsc_freq) /
|
||||
1000000);
|
||||
break;
|
||||
}
|
||||
/* FALLTHROUGH */
|
||||
#endif /* __rtems__ */
|
||||
default:
|
||||
return (ENOENT);
|
||||
cpdev = device_get_ivars(child);
|
||||
*result = (uintptr_t)cpdev->cd_pcpu;
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
@@ -55,13 +55,13 @@ extern u_int read_eflags(void);
|
||||
|
||||
struct region_descriptor;
|
||||
|
||||
#define readb(va) (*(volatile u_int8_t *) (va))
|
||||
#define readw(va) (*(volatile u_int16_t *) (va))
|
||||
#define readl(va) (*(volatile u_int32_t *) (va))
|
||||
#define readb(va) (*(volatile uint8_t *) (va))
|
||||
#define readw(va) (*(volatile uint16_t *) (va))
|
||||
#define readl(va) (*(volatile uint32_t *) (va))
|
||||
|
||||
#define writeb(va, d) (*(volatile u_int8_t *) (va) = (d))
|
||||
#define writew(va, d) (*(volatile u_int16_t *) (va) = (d))
|
||||
#define writel(va, d) (*(volatile u_int32_t *) (va) = (d))
|
||||
#define writeb(va, d) (*(volatile uint8_t *) (va) = (d))
|
||||
#define writew(va, d) (*(volatile uint16_t *) (va) = (d))
|
||||
#define writel(va, d) (*(volatile uint32_t *) (va) = (d))
|
||||
|
||||
#if defined(__GNUCLIKE_ASM) && defined(__CC_SUPPORTS___INLINE)
|
||||
|
||||
@@ -98,6 +98,13 @@ clflush(u_long addr)
|
||||
__asm __volatile("clflush %0" : : "m" (*(char *)addr));
|
||||
}
|
||||
|
||||
static __inline void
|
||||
clts(void)
|
||||
{
|
||||
|
||||
__asm __volatile("clts");
|
||||
}
|
||||
|
||||
static __inline void
|
||||
disable_intr(void)
|
||||
{
|
||||
@@ -135,16 +142,18 @@ enable_intr(void)
|
||||
}
|
||||
|
||||
static __inline void
|
||||
cpu_monitor(const void *addr, int extensions, int hints)
|
||||
cpu_monitor(const void *addr, u_long extensions, u_int hints)
|
||||
{
|
||||
__asm __volatile("monitor;"
|
||||
: :"a" (addr), "c" (extensions), "d"(hints));
|
||||
|
||||
__asm __volatile("monitor"
|
||||
: : "a" (addr), "c" (extensions), "d" (hints));
|
||||
}
|
||||
|
||||
static __inline void
|
||||
cpu_mwait(int extensions, int hints)
|
||||
cpu_mwait(u_long extensions, u_int hints)
|
||||
{
|
||||
__asm __volatile("mwait;" : :"a" (hints), "c" (extensions));
|
||||
|
||||
__asm __volatile("mwait" : : "a" (hints), "c" (extensions));
|
||||
}
|
||||
|
||||
static __inline void
|
||||
@@ -200,7 +209,7 @@ inb(u_int port)
|
||||
{
|
||||
u_char data;
|
||||
|
||||
__asm volatile("inb %w1, %0" : "=a" (data) : "Nd" (port));
|
||||
__asm __volatile("inb %w1, %0" : "=a" (data) : "Nd" (port));
|
||||
return (data);
|
||||
}
|
||||
|
||||
@@ -209,33 +218,33 @@ inl(u_int port)
|
||||
{
|
||||
u_int data;
|
||||
|
||||
__asm volatile("inl %w1, %0" : "=a" (data) : "Nd" (port));
|
||||
__asm __volatile("inl %w1, %0" : "=a" (data) : "Nd" (port));
|
||||
return (data);
|
||||
}
|
||||
|
||||
static __inline void
|
||||
insb(u_int port, void *addr, size_t cnt)
|
||||
insb(u_int port, void *addr, size_t count)
|
||||
{
|
||||
__asm __volatile("cld; rep; insb"
|
||||
: "+D" (addr), "+c" (cnt)
|
||||
: "+D" (addr), "+c" (count)
|
||||
: "d" (port)
|
||||
: "memory");
|
||||
}
|
||||
|
||||
static __inline void
|
||||
insw(u_int port, void *addr, size_t cnt)
|
||||
insw(u_int port, void *addr, size_t count)
|
||||
{
|
||||
__asm __volatile("cld; rep; insw"
|
||||
: "+D" (addr), "+c" (cnt)
|
||||
: "+D" (addr), "+c" (count)
|
||||
: "d" (port)
|
||||
: "memory");
|
||||
}
|
||||
|
||||
static __inline void
|
||||
insl(u_int port, void *addr, size_t cnt)
|
||||
insl(u_int port, void *addr, size_t count)
|
||||
{
|
||||
__asm __volatile("cld; rep; insl"
|
||||
: "+D" (addr), "+c" (cnt)
|
||||
: "+D" (addr), "+c" (count)
|
||||
: "d" (port)
|
||||
: "memory");
|
||||
}
|
||||
@@ -251,7 +260,7 @@ inw(u_int port)
|
||||
{
|
||||
u_short data;
|
||||
|
||||
__asm volatile("inw %w1, %0" : "=a" (data) : "Nd" (port));
|
||||
__asm __volatile("inw %w1, %0" : "=a" (data) : "Nd" (port));
|
||||
return (data);
|
||||
}
|
||||
|
||||
@@ -264,37 +273,37 @@ outb(u_int port, u_char data)
|
||||
static __inline void
|
||||
outl(u_int port, u_int data)
|
||||
{
|
||||
__asm volatile("outl %0, %w1" : : "a" (data), "Nd" (port));
|
||||
__asm __volatile("outl %0, %w1" : : "a" (data), "Nd" (port));
|
||||
}
|
||||
|
||||
static __inline void
|
||||
outsb(u_int port, const void *addr, size_t cnt)
|
||||
outsb(u_int port, const void *addr, size_t count)
|
||||
{
|
||||
__asm __volatile("cld; rep; outsb"
|
||||
: "+S" (addr), "+c" (cnt)
|
||||
: "+S" (addr), "+c" (count)
|
||||
: "d" (port));
|
||||
}
|
||||
|
||||
static __inline void
|
||||
outsw(u_int port, const void *addr, size_t cnt)
|
||||
outsw(u_int port, const void *addr, size_t count)
|
||||
{
|
||||
__asm __volatile("cld; rep; outsw"
|
||||
: "+S" (addr), "+c" (cnt)
|
||||
: "+S" (addr), "+c" (count)
|
||||
: "d" (port));
|
||||
}
|
||||
|
||||
static __inline void
|
||||
outsl(u_int port, const void *addr, size_t cnt)
|
||||
outsl(u_int port, const void *addr, size_t count)
|
||||
{
|
||||
__asm __volatile("cld; rep; outsl"
|
||||
: "+S" (addr), "+c" (cnt)
|
||||
: "+S" (addr), "+c" (count)
|
||||
: "d" (port));
|
||||
}
|
||||
|
||||
static __inline void
|
||||
outw(u_int port, u_short data)
|
||||
{
|
||||
__asm volatile("outw %0, %w1" : : "a" (data), "Nd" (port));
|
||||
__asm __volatile("outw %0, %w1" : : "a" (data), "Nd" (port));
|
||||
}
|
||||
|
||||
static __inline void
|
||||
@@ -343,6 +352,15 @@ rdtsc(void)
|
||||
return (rv);
|
||||
}
|
||||
|
||||
static __inline uint32_t
|
||||
rdtsc32(void)
|
||||
{
|
||||
uint32_t rv;
|
||||
|
||||
__asm __volatile("rdtsc" : "=a" (rv) : : "edx");
|
||||
return (rv);
|
||||
}
|
||||
|
||||
static __inline void
|
||||
wbinvd(void)
|
||||
{
|
||||
@@ -455,11 +473,11 @@ invlpg(u_int addr)
|
||||
#endif
|
||||
}
|
||||
|
||||
static __inline u_int
|
||||
static __inline u_short
|
||||
rfs(void)
|
||||
{
|
||||
u_int sel;
|
||||
__asm __volatile("mov %%fs,%0" : "=rm" (sel));
|
||||
u_short sel;
|
||||
__asm __volatile("movw %%fs,%0" : "=rm" (sel));
|
||||
return (sel);
|
||||
}
|
||||
|
||||
@@ -471,11 +489,11 @@ rgdt(void)
|
||||
return (gdtr);
|
||||
}
|
||||
|
||||
static __inline u_int
|
||||
static __inline u_short
|
||||
rgs(void)
|
||||
{
|
||||
u_int sel;
|
||||
__asm __volatile("mov %%gs,%0" : "=rm" (sel));
|
||||
u_short sel;
|
||||
__asm __volatile("movw %%gs,%0" : "=rm" (sel));
|
||||
return (sel);
|
||||
}
|
||||
|
||||
@@ -495,11 +513,11 @@ rldt(void)
|
||||
return (ldtr);
|
||||
}
|
||||
|
||||
static __inline u_int
|
||||
static __inline u_short
|
||||
rss(void)
|
||||
{
|
||||
u_int sel;
|
||||
__asm __volatile("mov %%ss,%0" : "=rm" (sel));
|
||||
u_short sel;
|
||||
__asm __volatile("movw %%ss,%0" : "=rm" (sel));
|
||||
return (sel);
|
||||
}
|
||||
|
||||
@@ -512,15 +530,15 @@ rtr(void)
|
||||
}
|
||||
|
||||
static __inline void
|
||||
load_fs(u_int sel)
|
||||
load_fs(u_short sel)
|
||||
{
|
||||
__asm __volatile("mov %0,%%fs" : : "rm" (sel));
|
||||
__asm __volatile("movw %0,%%fs" : : "rm" (sel));
|
||||
}
|
||||
|
||||
static __inline void
|
||||
load_gs(u_int sel)
|
||||
load_gs(u_short sel)
|
||||
{
|
||||
__asm __volatile("mov %0,%%gs" : : "rm" (sel));
|
||||
__asm __volatile("movw %0,%%gs" : : "rm" (sel));
|
||||
}
|
||||
|
||||
static __inline void
|
||||
@@ -690,6 +708,9 @@ int breakpoint(void);
|
||||
#endif
|
||||
u_int bsfl(u_int mask);
|
||||
u_int bsrl(u_int mask);
|
||||
void clflush(u_long addr);
|
||||
void clts(void);
|
||||
void cpuid_count(u_int ax, u_int cx, u_int *p);
|
||||
void disable_intr(void);
|
||||
void do_cpuid(u_int ax, u_int *p);
|
||||
void enable_intr(void);
|
||||
@@ -697,9 +718,9 @@ void halt(void);
|
||||
void ia32_pause(void);
|
||||
u_char inb(u_int port);
|
||||
u_int inl(u_int port);
|
||||
void insb(u_int port, void *addr, size_t cnt);
|
||||
void insl(u_int port, void *addr, size_t cnt);
|
||||
void insw(u_int port, void *addr, size_t cnt);
|
||||
void insb(u_int port, void *addr, size_t count);
|
||||
void insl(u_int port, void *addr, size_t count);
|
||||
void insw(u_int port, void *addr, size_t count);
|
||||
register_t intr_disable(void);
|
||||
void intr_restore(register_t ef);
|
||||
void invd(void);
|
||||
@@ -719,14 +740,14 @@ void load_dr4(u_int dr4);
|
||||
void load_dr5(u_int dr5);
|
||||
void load_dr6(u_int dr6);
|
||||
void load_dr7(u_int dr7);
|
||||
void load_fs(u_int sel);
|
||||
void load_gs(u_int sel);
|
||||
void load_fs(u_short sel);
|
||||
void load_gs(u_short sel);
|
||||
void ltr(u_short sel);
|
||||
void outb(u_int port, u_char data);
|
||||
void outl(u_int port, u_int data);
|
||||
void outsb(u_int port, const void *addr, size_t cnt);
|
||||
void outsl(u_int port, const void *addr, size_t cnt);
|
||||
void outsw(u_int port, const void *addr, size_t cnt);
|
||||
void outsb(u_int port, const void *addr, size_t count);
|
||||
void outsl(u_int port, const void *addr, size_t count);
|
||||
void outsw(u_int port, const void *addr, size_t count);
|
||||
void outw(u_int port, u_short data);
|
||||
u_int rcr0(void);
|
||||
u_int rcr2(void);
|
||||
|
@@ -54,6 +54,7 @@
|
||||
* therefore always exactly five 32-bit words.
|
||||
*/
|
||||
#if defined(__GNUCLIKE_ASM) && !defined(__INTEL_COMPILER)
|
||||
#if defined(IPVERSION) && (IPVERSION == 4)
|
||||
static __inline u_int
|
||||
in_cksum_hdr(const struct ip *ip)
|
||||
{
|
||||
@@ -88,6 +89,7 @@ in_cksum_update(struct ip *ip)
|
||||
__tmpsum = (int)ntohs(ip->ip_sum) + 256;
|
||||
ip->ip_sum = htons(__tmpsum + (__tmpsum >> 16));
|
||||
}
|
||||
#endif
|
||||
|
||||
static __inline u_short
|
||||
in_addword(u_short sum, u_short b)
|
||||
@@ -121,6 +123,7 @@ in_pseudo(u_int sum, u_int b, u_int c)
|
||||
}
|
||||
|
||||
#else
|
||||
#if defined(IPVERSION) && (IPVERSION == 4)
|
||||
#define in_cksum_update(ip) \
|
||||
do { \
|
||||
int __tmpsum; \
|
||||
@@ -129,10 +132,13 @@ in_pseudo(u_int sum, u_int b, u_int c)
|
||||
} while(0)
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef _KERNEL
|
||||
#if !defined(__GNUCLIKE_ASM) || defined(__INTEL_COMPILER)
|
||||
#if defined(IPVERSION) && (IPVERSION == 4)
|
||||
u_int in_cksum_hdr(const struct ip *ip);
|
||||
#endif
|
||||
u_short in_addword(u_short sum, u_short b);
|
||||
u_short in_pseudo(u_int sum, u_int b, u_int c);
|
||||
#endif
|
||||
|
@@ -123,14 +123,15 @@ struct trapframe;
|
||||
extern struct mtx icu_lock;
|
||||
extern int elcr_found;
|
||||
|
||||
#ifndef DEV_ATPIC
|
||||
void atpic_reset(void);
|
||||
#endif
|
||||
/* XXX: The elcr_* prototypes probably belong somewhere else. */
|
||||
int elcr_probe(void);
|
||||
enum intr_trigger elcr_read_trigger(u_int irq);
|
||||
void elcr_resume(void);
|
||||
void elcr_write_trigger(u_int irq, enum intr_trigger trigger);
|
||||
#ifdef SMP
|
||||
void intr_add_cpu(u_int cpu);
|
||||
#endif
|
||||
int intr_add_handler(const char *name, int vector, driver_filter_t filter,
|
||||
driver_intr_t handler, void *arg, enum intr_type flags, void **cookiep);
|
||||
#ifdef SMP
|
||||
|
@@ -91,6 +91,7 @@ void doreti_popl_fs(void) __asm(__STRING(doreti_popl_fs));
|
||||
void doreti_popl_fs_fault(void) __asm(__STRING(doreti_popl_fs_fault));
|
||||
void dump_add_page(vm_paddr_t);
|
||||
void dump_drop_page(vm_paddr_t);
|
||||
void initializecpu(void);
|
||||
void enable_sse(void);
|
||||
void fillw(int /*u_short*/ pat, void *base, size_t cnt);
|
||||
void i686_pagezero(void *addr);
|
||||
|
@@ -27,6 +27,9 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __X86_PCI_CFGREG_H__
|
||||
#define __X86_PCI_CFGREG_H__
|
||||
|
||||
#define CONF1_ADDR_PORT 0x0cf8
|
||||
#define CONF1_DATA_PORT 0x0cfc
|
||||
|
||||
@@ -43,10 +46,15 @@
|
||||
#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);
|
||||
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);
|
||||
void pci_cfgregwrite(int bus, int slot, int func, int reg, u_int32_t data, int bytes);
|
||||
#ifdef __HAVE_PIR
|
||||
void pci_pir_open(void);
|
||||
int pci_pir_probe(int bus, int require_parse);
|
||||
int pci_pir_route_interrupt(int bus, int device, int func, int pin);
|
||||
#endif
|
||||
|
||||
#endif /* !__X86_PCI_CFGREG_H__ */
|
||||
|
@@ -209,6 +209,12 @@
|
||||
#define CPUID_HTT_CORES 0x00ff0000
|
||||
#define CPUID_LOCAL_APIC_ID 0xff000000
|
||||
|
||||
/*
|
||||
* CPUID instruction 6 ecx info
|
||||
*/
|
||||
#define CPUID_PERF_STAT 0x00000001
|
||||
#define CPUID_PERF_BIAS 0x00000008
|
||||
|
||||
/*
|
||||
* CPUID instruction 0xb ebx info.
|
||||
*/
|
||||
@@ -216,6 +222,11 @@
|
||||
#define CPUID_TYPE_SMT 1
|
||||
#define CPUID_TYPE_CORE 2
|
||||
|
||||
/*
|
||||
* CPUID instruction 0xd Processor Extended State Enumeration Sub-leaf 1
|
||||
*/
|
||||
#define CPUID_EXTSTATE_XSAVEOPT 0x00000001
|
||||
|
||||
/*
|
||||
* AMD extended function 8000_0007h edx info
|
||||
*/
|
||||
|
@@ -53,13 +53,6 @@ __FBSDID("$FreeBSD$");
|
||||
|
||||
#include <rtems/bsd/local/pcib_if.h>
|
||||
|
||||
#ifndef __rtems__
|
||||
static int pcibios_pcib_route_interrupt(device_t pcib, device_t dev,
|
||||
int pin);
|
||||
#else /* __rtems__ */
|
||||
int pcibios_pcib_route_interrupt(device_t pcib, device_t dev, int pin);
|
||||
#endif /* __rtems__ */
|
||||
|
||||
int
|
||||
legacy_pcib_maxslots(device_t dev)
|
||||
{
|
||||
@@ -68,7 +61,7 @@ legacy_pcib_maxslots(device_t dev)
|
||||
|
||||
/* read configuration space register */
|
||||
|
||||
u_int32_t
|
||||
uint32_t
|
||||
legacy_pcib_read_config(device_t dev, u_int bus, u_int slot, u_int func,
|
||||
u_int reg, int bytes)
|
||||
{
|
||||
@@ -79,11 +72,26 @@ legacy_pcib_read_config(device_t dev, u_int bus, u_int slot, u_int func,
|
||||
|
||||
void
|
||||
legacy_pcib_write_config(device_t dev, u_int bus, u_int slot, u_int func,
|
||||
u_int reg, u_int32_t data, int bytes)
|
||||
u_int reg, uint32_t data, int bytes)
|
||||
{
|
||||
pci_cfgregwrite(bus, slot, func, reg, data, bytes);
|
||||
}
|
||||
|
||||
/* route interrupt */
|
||||
|
||||
static int
|
||||
legacy_pcib_route_interrupt(device_t pcib, device_t dev, int pin)
|
||||
{
|
||||
|
||||
#ifdef __HAVE_PIR
|
||||
return (pci_pir_route_interrupt(pci_get_bus(dev), pci_get_slot(dev),
|
||||
pci_get_function(dev), pin));
|
||||
#else
|
||||
/* No routing possible */
|
||||
return (PCI_INVALID_IRQ);
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Pass MSI requests up to the nexus. */
|
||||
|
||||
static int
|
||||
@@ -135,6 +143,7 @@ legacy_pcib_is_host_bridge(int bus, int slot, int func,
|
||||
uint32_t id, uint8_t class, uint8_t subclass,
|
||||
uint8_t *busnum)
|
||||
{
|
||||
#ifdef __i386__
|
||||
const char *s = NULL;
|
||||
static uint8_t pxb[4]; /* hack for 450nx */
|
||||
|
||||
@@ -352,6 +361,14 @@ legacy_pcib_is_host_bridge(int bus, int slot, int func,
|
||||
}
|
||||
|
||||
return s;
|
||||
#else
|
||||
const char *s = NULL;
|
||||
|
||||
*busnum = 0;
|
||||
if (class == PCIC_BRIDGE && subclass == PCIS_BRIDGE_HOST)
|
||||
s = "Host to PCI bridge";
|
||||
return s;
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -362,7 +379,7 @@ static void
|
||||
legacy_pcib_identify(driver_t *driver, device_t parent)
|
||||
{
|
||||
int bus, slot, func;
|
||||
u_int8_t hdrtype;
|
||||
uint8_t hdrtype;
|
||||
int found = 0;
|
||||
int pcifunchigh;
|
||||
int found824xx = 0;
|
||||
@@ -405,8 +422,8 @@ legacy_pcib_identify(driver_t *driver, device_t parent)
|
||||
/*
|
||||
* Read the IDs and class from the device.
|
||||
*/
|
||||
u_int32_t id;
|
||||
u_int8_t class, subclass, busnum;
|
||||
uint32_t id;
|
||||
uint8_t class, subclass, busnum;
|
||||
const char *s;
|
||||
device_t *devs;
|
||||
int ndevs, i;
|
||||
@@ -493,21 +510,23 @@ legacy_pcib_probe(device_t dev)
|
||||
static int
|
||||
legacy_pcib_attach(device_t dev)
|
||||
{
|
||||
#ifdef __HAVE_PIR
|
||||
device_t pir;
|
||||
#endif
|
||||
int bus;
|
||||
|
||||
bus = pcib_get_bus(dev);
|
||||
#ifdef __HAVE_PIR
|
||||
/*
|
||||
* Look for a PCI BIOS interrupt routing table as that will be
|
||||
* our method of routing interrupts if we have one.
|
||||
*/
|
||||
bus = pcib_get_bus(dev);
|
||||
#ifndef __rtems__
|
||||
if (pci_pir_probe(bus, 0)) {
|
||||
pir = BUS_ADD_CHILD(device_get_parent(dev), 0, "pir", 0);
|
||||
if (pir != NULL)
|
||||
device_probe_and_attach(pir);
|
||||
}
|
||||
#endif /* __rtems__ */
|
||||
#endif
|
||||
device_add_child(dev, "pci", bus);
|
||||
return bus_generic_attach(dev);
|
||||
}
|
||||
@@ -543,35 +562,45 @@ legacy_pcib_write_ivar(device_t dev, device_t child, int which,
|
||||
return ENOENT;
|
||||
}
|
||||
|
||||
/*
|
||||
* Helper routine for x86 Host-PCI bridge driver resource allocation.
|
||||
* This is used to adjust the start address of wildcard allocation
|
||||
* requests to avoid low addresses that are known to be problematic.
|
||||
*
|
||||
* If no memory preference is given, use upper 32MB slot most BIOSes
|
||||
* use for their memory window. This is typically only used on older
|
||||
* laptops that don't have PCI busses behind a PCI bridge, so assuming
|
||||
* > 32MB is likely OK.
|
||||
*
|
||||
* However, this can cause problems for other chipsets, so we make
|
||||
* this tunable by hw.pci.host_mem_start.
|
||||
*/
|
||||
SYSCTL_DECL(_hw_pci);
|
||||
|
||||
static unsigned long legacy_host_mem_start = 0x80000000;
|
||||
TUNABLE_ULONG("hw.pci.host_mem_start", &legacy_host_mem_start);
|
||||
SYSCTL_ULONG(_hw_pci, OID_AUTO, host_mem_start, CTLFLAG_RDTUN,
|
||||
&legacy_host_mem_start, 0x80000000,
|
||||
"Limit the host bridge memory to being above this address. Must be\n\
|
||||
set at boot via a tunable.");
|
||||
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)
|
||||
{
|
||||
|
||||
if (start + count - 1 != end) {
|
||||
if (type == SYS_RES_MEMORY && start < host_mem_start)
|
||||
start = host_mem_start;
|
||||
if (type == SYS_RES_IOPORT && start < 0x1000)
|
||||
start = 0x1000;
|
||||
}
|
||||
return (start);
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
/*
|
||||
* If no memory preference is given, use upper 32MB slot most
|
||||
* bioses use for their memory window. Typically other bridges
|
||||
* before us get in the way to assert their preferences on memory.
|
||||
* Hardcoding like this sucks, so a more MD/MI way needs to be
|
||||
* found to do it. This is typically only used on older laptops
|
||||
* that don't have pci busses behind pci bridge, so assuming > 32MB
|
||||
* is liekly OK.
|
||||
*
|
||||
* However, this can cause problems for other chipsets, so we make
|
||||
* this tunable by hw.pci.host_mem_start.
|
||||
*/
|
||||
if (type == SYS_RES_MEMORY && start == 0UL && end == ~0UL)
|
||||
start = legacy_host_mem_start;
|
||||
if (type == SYS_RES_IOPORT && start == 0UL && end == ~0UL)
|
||||
start = 0x1000;
|
||||
|
||||
start = hostb_alloc_start(type, start, end, count);
|
||||
return (bus_generic_alloc_resource(dev, child, type, rid, start, end,
|
||||
count, flags));
|
||||
}
|
||||
@@ -600,7 +629,7 @@ static device_method_t legacy_pcib_methods[] = {
|
||||
DEVMETHOD(pcib_maxslots, legacy_pcib_maxslots),
|
||||
DEVMETHOD(pcib_read_config, legacy_pcib_read_config),
|
||||
DEVMETHOD(pcib_write_config, legacy_pcib_write_config),
|
||||
DEVMETHOD(pcib_route_interrupt, pcibios_pcib_route_interrupt),
|
||||
DEVMETHOD(pcib_route_interrupt, legacy_pcib_route_interrupt),
|
||||
DEVMETHOD(pcib_alloc_msi, legacy_pcib_alloc_msi),
|
||||
DEVMETHOD(pcib_release_msi, pcib_release_msi),
|
||||
DEVMETHOD(pcib_alloc_msix, legacy_pcib_alloc_msix),
|
||||
@@ -616,7 +645,6 @@ DEFINE_CLASS_0(pcib, legacy_pcib_driver, legacy_pcib_methods, 1);
|
||||
DRIVER_MODULE(pcib, legacy, legacy_pcib_driver, hostb_devclass, 0, 0);
|
||||
|
||||
|
||||
#ifndef __rtems__
|
||||
/*
|
||||
* Install placeholder to claim the resources owned by the
|
||||
* PCI bus interface. This could be used to extract the
|
||||
@@ -665,7 +693,7 @@ static devclass_t pcibus_pnp_devclass;
|
||||
DEFINE_CLASS_0(pcibus_pnp, pcibus_pnp_driver, pcibus_pnp_methods, 1);
|
||||
DRIVER_MODULE(pcibus_pnp, isa, pcibus_pnp_driver, pcibus_pnp_devclass, 0, 0);
|
||||
|
||||
|
||||
#ifdef __HAVE_PIR
|
||||
/*
|
||||
* Provide a PCI-PCI bridge driver for PCI busses behind PCI-PCI bridges
|
||||
* that appear in the PCIBIOS Interrupt Routing Table to use the routing
|
||||
@@ -676,39 +704,17 @@ static int pcibios_pcib_probe(device_t bus);
|
||||
static device_method_t pcibios_pcib_pci_methods[] = {
|
||||
/* Device interface */
|
||||
DEVMETHOD(device_probe, pcibios_pcib_probe),
|
||||
DEVMETHOD(device_attach, pcib_attach),
|
||||
DEVMETHOD(device_shutdown, bus_generic_shutdown),
|
||||
DEVMETHOD(device_suspend, bus_generic_suspend),
|
||||
DEVMETHOD(device_resume, bus_generic_resume),
|
||||
|
||||
/* Bus interface */
|
||||
DEVMETHOD(bus_read_ivar, pcib_read_ivar),
|
||||
DEVMETHOD(bus_write_ivar, pcib_write_ivar),
|
||||
DEVMETHOD(bus_alloc_resource, pcib_alloc_resource),
|
||||
DEVMETHOD(bus_release_resource, bus_generic_release_resource),
|
||||
DEVMETHOD(bus_activate_resource, bus_generic_activate_resource),
|
||||
DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource),
|
||||
DEVMETHOD(bus_setup_intr, bus_generic_setup_intr),
|
||||
DEVMETHOD(bus_teardown_intr, bus_generic_teardown_intr),
|
||||
|
||||
/* pcib interface */
|
||||
DEVMETHOD(pcib_maxslots, pcib_maxslots),
|
||||
DEVMETHOD(pcib_read_config, pcib_read_config),
|
||||
DEVMETHOD(pcib_write_config, pcib_write_config),
|
||||
DEVMETHOD(pcib_route_interrupt, pcibios_pcib_route_interrupt),
|
||||
DEVMETHOD(pcib_alloc_msi, pcib_alloc_msi),
|
||||
DEVMETHOD(pcib_release_msi, pcib_release_msi),
|
||||
DEVMETHOD(pcib_alloc_msix, pcib_alloc_msix),
|
||||
DEVMETHOD(pcib_release_msix, pcib_release_msix),
|
||||
DEVMETHOD(pcib_map_msi, pcib_map_msi),
|
||||
DEVMETHOD(pcib_route_interrupt, legacy_pcib_route_interrupt),
|
||||
|
||||
DEVMETHOD_END
|
||||
{0, 0}
|
||||
};
|
||||
|
||||
static devclass_t pcib_devclass;
|
||||
|
||||
DEFINE_CLASS_0(pcib, pcibios_pcib_driver, pcibios_pcib_pci_methods,
|
||||
sizeof(struct pcib_softc));
|
||||
DEFINE_CLASS_1(pcib, pcibios_pcib_driver, pcibios_pcib_pci_methods,
|
||||
sizeof(struct pcib_softc), pcib_driver);
|
||||
DRIVER_MODULE(pcibios_pcib, pci, pcibios_pcib_driver, pcib_devclass, 0, 0);
|
||||
|
||||
static int
|
||||
@@ -727,11 +733,4 @@ pcibios_pcib_probe(device_t dev)
|
||||
device_set_desc(dev, "PCIBIOS PCI-PCI bridge");
|
||||
return (-2000);
|
||||
}
|
||||
|
||||
static int
|
||||
pcibios_pcib_route_interrupt(device_t pcib, device_t dev, int pin)
|
||||
{
|
||||
return (pci_pir_route_interrupt(pci_get_bus(dev), pci_get_slot(dev),
|
||||
pci_get_function(dev), pin));
|
||||
}
|
||||
#endif /* __rtems__ */
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user