xfree86supportforAS1200
FBSD_AS1200
mail_list at mindspring.com
Mon Jan 5 20:42:01 PST 2004
S.C. Gehl wrote:
>Cheers...
>
>sorry for the excessive quote... it's a bitch to
>edit/format a ong letter in 'links'
>
>...I can not find freebsdPci.c nor can I find Pci.h
>
>I have looked in both fbsd-current and xf-current.
>
>Have you made any head way on this? I have barely just
>begun to learn C, so this is a great way for me to jump in
>head first... but honestly I am not sure where to jump.
>The letter seems to say where, and it makes sense. I am
>glad that they are aware of the source of the problem..
>but where are these files! -Sean.
>
>
>
>>Just wanted to get some comments or opinions on the AS1200
>>suggestions received from the XFree86 mailing list as
>>quoted below.
>>
>>
>>
>>FBSD_AS1200 wrote (in a message from Saturday 3)
>> > Thank you for the reference. I have read the note but
>>still don't feel
>> > any closer to finding support for my system. The
>>Domain.note appears to
>> > be geared toward sun linux systems. While the note did
>>mention
>> > multi-domain alpha systems (I assume this is a ref to
>>multi pci-host
>> > bridges) I am still not clear on how I should implement
>>an XFree86
>> > system on an AlphaServer 1200 under FreeBSD. I think I
>>MUST be missing a
>> > point or two... Would it be possible to find further
>>documentation on
>> > this issue so I can get up to speed on X development.
>>From the post I
>> > have been reading on XFree86 and FreeBSD mailing list
>>there are several
>> > people with multi-pci bus alpha systems that would like
>>to assist in
>> > getting XFree up and running under a BSD variant. Thank
>>you for your
>> > assistance!
>>
>>I'm sorry, I don't know any other written documentation
>>that could
>>help you.
>>What you need is to implement the xf86GetPciDomain(),
>>xf86MapDomainMemory(),
>>xf86MapDomainIO() and xf86ReadDomainMemory(). functions in
>>freebsdPci.c. Once you've done this, you can edit Pci.h
>>and remove
>>the INCLUDE_XF86_NO_DOMAIN for FreeBSD/alpha. Then the
>>XFree86 drivers
>>will be able to access the video card(s) independently of
>>the bus they
>>are attached to.
>>
>>There can be 2 approaches for that :
>>
>>- if the FreeBSD kernel already provides an API to
>>enumerate the PCI
>> host bridges and the configuration space and memory
>>mappings for
>> each host bridge, use that (this is what freebsdPci.c
>>currently does
>> for a single host bridge).
>>
>>- it there's no such interface available, then you need to
>>develop a
>> driver that will poke directly into the main chipset I/O
>>registers
>> to probe the various host bridges and handle their
>>memory mappings
>> from userland. This is for instance what sparcPci.c does
>>for SunOS.
>>
>>Don't hesitate to join the devel at xfree86 mailing list and
>>ask more
>>questions here if needed. This list is more appropriate
>>for
>>developpement related questions.
>>
>>Looking forward for your contributions.
>>
>> Matthieu
>>
>>
>>_______________________________________________
>>freebsd-alpha at freebsd.org mailing list
>>http://lists.freebsd.org/mailman/listinfo/freebsd-alpha
>>To unsubscribe, send any mail to
>>"freebsd-alpha-unsubscribe at freebsd.org"
>>
>>
>>
>
>_______________________________________________
>freebsd-alpha at freebsd.org mailing list
>http://lists.freebsd.org/mailman/listinfo/freebsd-alpha
>To unsubscribe, send any mail to "freebsd-alpha-unsubscribe at freebsd.org"
>
>
>
Here are the most recent versions I could find. Maybe I will get a
chance to play with them a bit later. Let us know if you make any headway.
-------------- next part --------------
/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bus/Pci.h,v 1.42 2003/08/29 21:08:06 tsi Exp $ */
/*
* Copyright 1998 by Concurrent Computer Corporation
*
* Permission to use, copy, modify, distribute, and sell this software
* and its documentation for any purpose is hereby granted without fee,
* provided that the above copyright notice appear in all copies and that
* both that copyright notice and this permission notice appear in
* supporting documentation, and that the name of Concurrent Computer
* Corporation not be used in advertising or publicity pertaining to
* distribution of the software without specific, written prior
* permission. Concurrent Computer Corporation makes no representations
* about the suitability of this software for any purpose. It is
* provided "as is" without express or implied warranty.
*
* CONCURRENT COMPUTER CORPORATION DISCLAIMS ALL WARRANTIES WITH REGARD
* TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS, IN NO EVENT SHALL CONCURRENT COMPUTER CORPORATION BE
* LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
* DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
* WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
* SOFTWARE.
*
* Copyright 1998 by Metro Link Incorporated
*
* Permission to use, copy, modify, distribute, and sell this software
* and its documentation for any purpose is hereby granted without fee,
* provided that the above copyright notice appear in all copies and that
* both that copyright notice and this permission notice appear in
* supporting documentation, and that the name of Metro Link
* Incorporated not be used in advertising or publicity pertaining to
* distribution of the software without specific, written prior
* permission. Metro Link Incorporated makes no representations
* about the suitability of this software for any purpose. It is
* provided "as is" without express or implied warranty.
*
* METRO LINK INCORPORATED DISCLAIMS ALL WARRANTIES WITH REGARD
* TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS, IN NO EVENT SHALL METRO LINK INCORPORATED BE
* LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
* DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
* WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
* SOFTWARE.
*
* This file is derived in part from the original xf86_PCI.h that included
* following copyright message:
*
* Copyright 1995 by Robin Cutshaw <robin at XFree86.Org>
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
* the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation, and that the names of the above listed copyright holder(s)
* not be used in advertising or publicity pertaining to distribution of
* the software without specific, written prior permission. The above listed
* copyright holder(s) make(s) no representations about the suitability of this
* software for any purpose. It is provided "as is" without express or
* implied warranty.
*
* THE ABOVE LISTED COPYRIGHT HOLDER(S) DISCLAIM(S) ALL WARRANTIES WITH REGARD
* TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS, IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE
* LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
* DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
*/
/*
* Copyright (c) 1999-2003 by The XFree86 Project, Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
* Except as contained in this notice, the name of the copyright holder(s)
* and author(s) shall not be used in advertising or otherwise to promote
* the sale, use or other dealings in this Software without prior written
* authorization from the copyright holder(s) and author(s).
*/
/*
* This file has the private Pci definitions. The public ones are imported
* from xf86Pci.h. Drivers should not use this file.
*/
#ifndef _PCI_H
#define _PCI_H 1
#include "Xarch.h"
#include "Xfuncproto.h"
#include "xf86Pci.h"
#include "xf86PciInfo.h"
/*
* Global Definitions
*/
#define MAX_PCI_DEVICES 64 /* Max number of devices accomodated */
/* by xf86scanpci */
#if defined(sun) && defined(SVR4) && defined(sparc)
# define MAX_PCI_BUSES 4096 /* Max number of PCI buses */
#elif defined(__alpha__) && defined (linux)
# define MAX_PCI_DOMAINS 512
# define PCI_DOM_MASK 0x01fful
# define MAX_PCI_BUSES (MAX_PCI_DOMAINS*256) /* 256 per domain */
#else
# define MAX_PCI_BUSES 256 /* Max number of PCI buses */
#endif
#define DEVID(vendor, device) \
((CARD32)((PCI_##device << 16) | PCI_##vendor))
#ifndef PCI_DOM_MASK
# define PCI_DOM_MASK 0x0ffu
#endif
#define PCI_DOMBUS_MASK (((PCI_DOM_MASK) << 8) | 0x0ffu)
/*
* "b" contains an optional domain number.
*/
#define PCI_MAKE_TAG(b,d,f) ((((b) & (PCI_DOMBUS_MASK)) << 16) | \
(((d) & 0x00001fu) << 11) | \
(((f) & 0x000007u) << 8))
#define PCI_MAKE_BUS(d,b) ((((d) & (PCI_DOM_MASK)) << 8) | ((b) & 0xffu))
#define PCI_DOM_FROM_TAG(tag) (((tag) >> 24) & (PCI_DOM_MASK))
#define PCI_BUS_FROM_TAG(tag) (((tag) >> 16) & (PCI_DOMBUS_MASK))
#define PCI_DEV_FROM_TAG(tag) (((tag) & 0x0000f800u) >> 11)
#define PCI_FUNC_FROM_TAG(tag) (((tag) & 0x00000700u) >> 8)
#define PCI_DFN_FROM_TAG(tag) (((tag) & 0x0000ff00u) >> 8)
#define PCI_BDEV_FROM_TAG(tag) ((tag) & 0x00fff800u)
#define PCI_DOM_FROM_BUS(bus) (((bus) >> 8) & (PCI_DOM_MASK))
#define PCI_BUS_NO_DOMAIN(bus) ((bus) & 0xffu)
#define PCI_TAG_NO_DOMAIN(tag) ((tag) & 0x00ffff00u)
/*
* Macros for bus numbers found in P2P headers.
*/
#define PCI_PRIMARY_BUS_EXTRACT(x, tag) \
((((x) & PCI_PRIMARY_BUS_MASK ) >> 0) | (PCI_DOM_FROM_TAG(tag) << 8))
#define PCI_SECONDARY_BUS_EXTRACT(x, tag) \
((((x) & PCI_SECONDARY_BUS_MASK ) >> 8) | (PCI_DOM_FROM_TAG(tag) << 8))
#define PCI_SUBORDINATE_BUS_EXTRACT(x, tag) \
((((x) & PCI_SUBORDINATE_BUS_MASK) >> 16) | (PCI_DOM_FROM_TAG(tag) << 8))
#define PCI_PRIMARY_BUS_INSERT(x, y) \
(((x) & ~PCI_PRIMARY_BUS_MASK ) | (((y) & 0xffu) << 0))
#define PCI_SECONDARY_BUS_INSERT(x, y) \
(((x) & ~PCI_SECONDARY_BUS_MASK ) | (((y) & 0xffu) << 8))
#define PCI_SUBORDINATE_BUS_INSERT(x, y) \
(((x) & ~PCI_SUBORDINATE_BUS_MASK) | (((y) & 0xffu) << 16))
/* Ditto for CardBus bridges */
#define PCI_CB_PRIMARY_BUS_EXTRACT(x, tag) \
PCI_PRIMARY_BUS_EXTRACT(x, tag)
#define PCI_CB_CARDBUS_BUS_EXTRACT(x, tag) \
PCI_SECONDARY_BUS_EXTRACT(x, tag)
#define PCI_CB_SUBORDINATE_BUS_EXTRACT(x, tag) \
PCI_SUBORDINATE_BUS_EXTRACT(x, tag)
#define PCI_CB_PRIMARY_BUS_INSERT(x, tag) \
PCI_PRIMARY_BUS_INSERT(x, tag)
#define PCI_CB_CARDBUS_BUS_INSERT(x, tag) \
PCI_SECONDARY_BUS_INSERT(x, tag)
#define PCI_CB_SUBORDINATE_BUS_INSERT(x, tag) \
PCI_SUBORDINATE_BUS_INSERT(x, tag)
#if X_BYTE_ORDER == X_BIG_ENDIAN
#define PCI_CPU(val) (((val >> 24) & 0x000000ff) | \
((val >> 8) & 0x0000ff00) | \
((val << 8) & 0x00ff0000) | \
((val << 24) & 0xff000000))
#else
#define PCI_CPU(val) (val)
#endif
/*
* Debug Macros/Definitions
*/
/* #define DEBUGPCI 2 */ /* Disable/enable trace in PCI code */
#if defined(DEBUGPCI)
# define PCITRACE(lvl,printfargs) \
if (lvl > xf86Verbose) { \
ErrorF printfargs; \
}
#else /* !defined(DEBUGPCI) */
# define PCITRACE(lvl,printfargs)
#endif /* !defined(DEBUGPCI) */
/*
* PCI Config mechanism definitions
*/
#define PCI_EN 0x80000000
#define PCI_CFGMECH1_ADDRESS_REG 0xCF8
#define PCI_CFGMECH1_DATA_REG 0xCFC
#define PCI_CFGMECH1_MAXDEV 32
/*
* Select architecture specific PCI init function
*/
#if defined(__alpha__)
# if defined(linux)
# define ARCH_PCI_INIT axpPciInit
# define INCLUDE_XF86_MAP_PCI_MEM
# elif defined(__FreeBSD__) || defined(__OpenBSD__)
# define ARCH_PCI_INIT freebsdPciInit
# define INCLUDE_XF86_MAP_PCI_MEM
# define INCLUDE_XF86_NO_DOMAIN
# elif defined(__NetBSD__)
# define ARCH_PCI_INIT netbsdPciInit
# define INCLUDE_XF86_MAP_PCI_MEM
# define INCLUDE_XF86_NO_DOMAIN
# endif
#elif defined(__arm__)
# if defined(linux)
# define ARCH_PCI_INIT linuxPciInit
# define INCLUDE_XF86_MAP_PCI_MEM
# define INCLUDE_XF86_NO_DOMAIN
# endif
#elif defined(__hppa__)
# if defined(linux)
# define ARCH_PCI_INIT linuxPciInit
# define INCLUDE_XF86_MAP_PCI_MEM
# define INCLUDE_XF86_NO_DOMAIN
# endif
#elif defined(__ia64__)
# if defined(linux)
# define ARCH_PCI_INIT linuxPciInit
# define INCLUDE_XF86_MAP_PCI_MEM
# define INCLUDE_XF86_NO_DOMAIN
# endif
# define XF86SCANPCI_WRAPPER ia64ScanPCIWrapper
#elif defined(__i386__)
# define ARCH_PCI_INIT ix86PciInit
# define INCLUDE_XF86_MAP_PCI_MEM
# define INCLUDE_XF86_NO_DOMAIN
# if defined(linux)
# define ARCH_PCI_OS_INIT linuxPciInit
# endif
#elif defined(__mc68000__)
# if defined(linux)
# define ARCH_PCI_INIT linuxPciInit
# define INCLUDE_XF86_MAP_PCI_MEM
# define INCLUDE_XF86_NO_DOMAIN
# endif
#elif defined(__mips__)
# if defined(linux)
# define ARCH_PCI_INIT linuxPciInit
# define INCLUDE_XF86_MAP_PCI_MEM
# define INCLUDE_XF86_NO_DOMAIN
# endif
#elif defined(__powerpc__)
# if defined(linux)
# define ARCH_PCI_INIT linuxPciInit
# define INCLUDE_XF86_MAP_PCI_MEM
# define INCLUDE_XF86_NO_DOMAIN /* Needs kernel work to remove */
# elif defined(__OpenBSD__)
# define ARCH_PCI_INIT freebsdPciInit
# define INCLUDE_XF86_MAP_PCI_MEM
# define INCLUDE_XF86_NO_DOMAIN
# elif defined(__NetBSD__)
# define ARCH_PCI_INIT netbsdPciInit
# define INCLUDE_XF86_MAP_PCI_MEM
# define INCLUDE_XF86_NO_DOMAIN
# elif defined(PowerMAX_OS) /* This port is broken */
# define ARCH_PCI_INIT ppcPciInit
# else
# define ARCH_PCI_INIT ppcPciInit
# define INCLUDE_XF86_MAP_PCI_MEM
# define INCLUDE_XF86_NO_DOMAIN
# endif
#elif defined(__s390__)
# if defined(linux)
# define ARCH_PCI_INIT linuxPciInit
# define INCLUDE_XF86_MAP_PCI_MEM
# define INCLUDE_XF86_NO_DOMAIN
# endif
#elif defined(__sh__)
# if defined(linux)
# define ARCH_PCI_INIT linuxPciInit
# define INCLUDE_XF86_MAP_PCI_MEM
# define INCLUDE_XF86_NO_DOMAIN
# endif
#elif defined(__sparc__)
# if defined(linux)
# define ARCH_PCI_INIT linuxPciInit
# define INCLUDE_XF86_MAP_PCI_MEM
# elif defined(sun)
# define ARCH_PCI_INIT sparcPciInit
# define INCLUDE_XF86_MAP_PCI_MEM
# elif defined(__OpenBSD__) && defined(__sparc64__)
# define ARCH_PCI_INIT freebsdPciInit
# define INCLUDE_XF86_MAP_PCI_MEM
# define INCLUDE_XF86_NO_DOMAIN
# endif
# define ARCH_PCI_PCI_BRIDGE sparcPciPciBridge
#elif defined(__AMD64__)
# define ARCH_PCI_INIT ix86PciInit
# define INCLUDE_XF86_MAP_PCI_MEM
# define INCLUDE_XF86_NO_DOMAIN
# if defined(linux)
# define ARCH_PCI_OS_INIT linuxPciInit
# endif
#endif
#ifndef ARCH_PCI_INIT
#error No PCI support available for this architecture/OS combination
#endif
extern void ARCH_PCI_INIT(void);
#if defined(ARCH_PCI_OS_INIT)
extern void ARCH_PCI_OS_INIT(void);
#endif
#if defined(ARCH_PCI_PCI_BRIDGE)
extern void ARCH_PCI_PCI_BRIDGE(pciConfigPtr pPCI);
#endif
#if defined(XF86SCANPCI_WRAPPER)
typedef enum {
SCANPCI_INIT,
SCANPCI_TERM
} scanpciWrapperOpt;
extern void XF86SCANPCI_WRAPPER(scanpciWrapperOpt flags);
#endif
/*
* Table of functions used to access a specific PCI bus domain
* (e.g. a primary PCI bus and all of its secondaries)
*/
typedef struct pci_bus_funcs {
CARD32 (*pciReadLong)(PCITAG, int);
void (*pciWriteLong)(PCITAG, int, CARD32);
void (*pciSetBitsLong)(PCITAG, int, CARD32, CARD32);
ADDRESS (*pciAddrHostToBus)(PCITAG, PciAddrType, ADDRESS);
ADDRESS (*pciAddrBusToHost)(PCITAG, PciAddrType, ADDRESS);
/*
* The next three are optional. If NULL, the corresponding function is
* to be performed generically.
*/
CARD16 (*pciControlBridge)(int, CARD16, CARD16);
void (*pciGetBridgeBuses)(int, int *, int *, int *);
/* Use pointer's to avoid #include recursion */
void (*pciGetBridgeResources)(int, pointer *, pointer *, pointer *);
} pciBusFuncs_t, *pciBusFuncs_p;
/*
* pciBusInfo_t - One structure per defined PCI bus
*/
typedef struct pci_bus_info {
unsigned char configMech; /* PCI config type to use */
unsigned char numDevices; /* Range of valid devnums */
unsigned char secondary; /* Boolean: bus is a secondary */
int primary_bus; /* Parent bus */
#ifdef PowerMAX_OS
unsigned long ppc_io_base; /* PowerPC I/O spc membase */
unsigned long ppc_io_size; /* PowerPC I/O spc size */
#endif
pciBusFuncs_p funcs; /* PCI access functions */
void *pciBusPriv; /* Implementation private data */
pciConfigPtr bridge; /* bridge that opens this bus */
} pciBusInfo_t;
#define HOST_NO_BUS ((pciBusInfo_t *)(-1))
/* configMech values */
#define PCI_CFG_MECH_UNKNOWN 0 /* Not yet known */
#define PCI_CFG_MECH_1 1 /* Most machines */
#define PCI_CFG_MECH_2 2 /* Older PC's */
#define PCI_CFG_MECH_OTHER 3 /* Something else */
/* Generic PCI service functions and helpers */
PCITAG pciGenFindFirst(void);
PCITAG pciGenFindNext(void);
CARD32 pciCfgMech1Read(PCITAG tag, int offset);
void pciCfgMech1Write(PCITAG tag, int offset, CARD32 val);
void pciCfgMech1SetBits(PCITAG tag, int offset, CARD32 mask,
CARD32 val);
CARD32 pciByteSwap(CARD32);
Bool pciMfDev(int, int);
ADDRESS pciAddrNOOP(PCITAG tag, PciAddrType type, ADDRESS);
extern PCITAG (*pciFindFirstFP)(void);
extern PCITAG (*pciFindNextFP)(void);
extern CARD32 pciDevid;
extern CARD32 pciDevidMask;
extern int pciMaxBusNum;
extern int pciBusNum;
extern int pciDevNum;
extern int pciFuncNum;
extern PCITAG pciDeviceTag;
extern pciBusInfo_t *pciBusInfo[];
#endif /* _PCI_H */
-------------- next part --------------
/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bus/freebsdPci.c,v 1.5 2002/08/27 22:07:07 tsi Exp $ */
/*
* Copyright 1998 by Concurrent Computer Corporation
*
* Permission to use, copy, modify, distribute, and sell this software
* and its documentation for any purpose is hereby granted without fee,
* provided that the above copyright notice appear in all copies and that
* both that copyright notice and this permission notice appear in
* supporting documentation, and that the name of Concurrent Computer
* Corporation not be used in advertising or publicity pertaining to
* distribution of the software without specific, written prior
* permission. Concurrent Computer Corporation makes no representations
* about the suitability of this software for any purpose. It is
* provided "as is" without express or implied warranty.
*
* CONCURRENT COMPUTER CORPORATION DISCLAIMS ALL WARRANTIES WITH REGARD
* TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS, IN NO EVENT SHALL CONCURRENT COMPUTER CORPORATION BE
* LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
* DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
* WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
* SOFTWARE.
*
* Copyright 1998 by Metro Link Incorporated
*
* Permission to use, copy, modify, distribute, and sell this software
* and its documentation for any purpose is hereby granted without fee,
* provided that the above copyright notice appear in all copies and that
* both that copyright notice and this permission notice appear in
* supporting documentation, and that the name of Metro Link
* Incorporated not be used in advertising or publicity pertaining to
* distribution of the software without specific, written prior
* permission. Metro Link Incorporated makes no representations
* about the suitability of this software for any purpose. It is
* provided "as is" without express or implied warranty.
*
* METRO LINK INCORPORATED DISCLAIMS ALL WARRANTIES WITH REGARD
* TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS, IN NO EVENT SHALL METRO LINK INCORPORATED BE
* LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
* DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
* WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
* SOFTWARE.
*/
#include <stdio.h>
#include "compiler.h"
#include "xf86.h"
#include "xf86Priv.h"
#include "xf86_OSlib.h"
#include "Pci.h"
#include <sys/pciio.h>
/*
* freebsd platform specific PCI access functions -- using /dev/pci
* needs kernel version 2.2.x
*/
static CARD32 freebsdPciCfgRead(PCITAG tag, int off);
static void freebsdPciCfgWrite(PCITAG, int off, CARD32 val);
static void freebsdPciCfgSetBits(PCITAG tag, int off, CARD32 mask, CARD32 bits);
static pciBusFuncs_t freebsdFuncs0 = {
/* pciReadLong */ freebsdPciCfgRead,
/* pciWriteLong */ freebsdPciCfgWrite,
/* pciSetBitsLong */ freebsdPciCfgSetBits,
/* pciAddrHostToBus */ pciAddrNOOP,
/* pciAddrBusToHost */ pciAddrNOOP
};
static pciBusInfo_t freebsdPci0 = {
/* configMech */ PCI_CFG_MECH_OTHER,
/* numDevices */ 32,
/* secondary */ FALSE,
/* primary_bus */ 0,
#ifdef PowerMAX_OS
/* ppc_io_base */ 0,
/* ppc_io_size */ 0,
#endif
/* funcs */ &freebsdFuncs0,
/* pciBusPriv */ NULL,
/* bridge */ NULL
};
#if !defined(__OpenBSD__)
#if X_BYTE_ORDER == X_BIG_ENDIAN
#ifdef __sparc__
#ifndef ASI_PL
#define ASI_PL 0x88
#endif
#define PCI_CPU(val) ({ \
int __ret; \
__asm__ __volatile__("lduwa [%1] %2, %0" : "=r" (__ret) : "r" (&val), "i" (ASI_PL)); \
__ret; \
})
#else
#define PCI_CPU(val) (((val >> 24) & 0x000000ff) | \
((val >> 8) & 0x0000ff00) | \
((val << 8) & 0x00ff0000) | \
((val << 24) & 0xff000000))
#endif
#else
#define PCI_CPU(val) (val)
#endif
#else /* ! OpenBSD */
/* OpenBSD has already the bytes in the right order
for all architectures */
#define PCI_CPU(val) (val)
#endif
#define BUS(tag) (((tag)>>16)&0xff)
#define DFN(tag) (((tag)>>8)&0xff)
static int pciFd = -1;
void
freebsdPciInit()
{
pciFd = open("/dev/pci", O_RDWR);
if (pciFd < 0)
return;
pciNumBuses = 1;
pciBusInfo[0] = &freebsdPci0;
pciFindFirstFP = pciGenFindFirst;
pciFindNextFP = pciGenFindNext;
}
static CARD32
freebsdPciCfgRead(PCITAG tag, int off)
{
struct pci_io io;
int error;
io.pi_sel.pc_bus = BUS(tag);
io.pi_sel.pc_dev = DFN(tag) >> 3;
io.pi_sel.pc_func = DFN(tag) & 7;
io.pi_reg = off;
io.pi_width = 4;
error = ioctl(pciFd, PCIOCREAD, &io);
if (error)
return ~0;
return PCI_CPU(io.pi_data);
}
static void
freebsdPciCfgWrite(PCITAG tag, int off, CARD32 val)
{
struct pci_io io;
io.pi_sel.pc_bus = BUS(tag);
io.pi_sel.pc_dev = DFN(tag) >> 3;
io.pi_sel.pc_func = DFN(tag) & 7;
io.pi_reg = off;
io.pi_width = 4;
io.pi_data = PCI_CPU(val);
ioctl(pciFd, PCIOCWRITE, &io);
}
static void
freebsdPciCfgSetBits(PCITAG tag, int off, CARD32 mask, CARD32 bits)
{
CARD32 val = freebsdPciCfgRead(tag, off);
val = (val & ~mask) | (bits & mask);
freebsdPciCfgWrite(tag, off, val);
}
More information about the freebsd-alpha
mailing list