Remove __FreeBSD__ version abuse, also de-orbit support for FreeBSD 2

and FreeBSD 3.
This commit is contained in:
Warner Losh 2002-07-21 04:18:20 +00:00
parent 5ec699cdac
commit df9c943ac9
2 changed files with 0 additions and 447 deletions

View File

@ -172,9 +172,6 @@ bktr_name(bktr_ptr_t bktr)
}
#if (__FreeBSD__ == 2)
typedef unsigned int uintptr_t;
#endif
#endif /* __FreeBSD__ */

View File

@ -119,10 +119,6 @@ SYSCTL_INT(_hw_bt848, OID_AUTO, reverse_mute, CTLFLAG_RW, &bt848_reverse_mute, -
SYSCTL_INT(_hw_bt848, OID_AUTO, format, CTLFLAG_RW, &bt848_format, -1, "");
SYSCTL_INT(_hw_bt848, OID_AUTO, slow_msp_audio, CTLFLAG_RW, &bt848_slow_msp_audio, -1, "");
#if (__FreeBSD__ == 2)
#define PCIR_REVID PCI_CLASS_REG
#endif
#endif /* end freebsd section */
@ -835,446 +831,6 @@ int bktr_poll( dev_t dev, int events, struct thread *td)
#endif /* FreeBSD 4.x specific kernel interface routines */
/**********************************/
/* *** FreeBSD 2.2.x and 3.x *** */
/**********************************/
#if ((__FreeBSD__ == 2) || (__FreeBSD__ == 3))
static bktr_reg_t brooktree[ NBKTR ];
static const char* bktr_probe( pcici_t tag, pcidi_t type );
static void bktr_attach( pcici_t tag, int unit );
static void bktr_intr(void *arg) { common_bktr_intr(arg); }
static u_long bktr_count;
static struct pci_device bktr_device = {
"bktr",
bktr_probe,
bktr_attach,
&bktr_count
};
DATA_SET (pcidevice_set, bktr_device);
static d_open_t bktr_open;
static d_close_t bktr_close;
static d_read_t bktr_read;
static d_write_t bktr_write;
static d_ioctl_t bktr_ioctl;
static d_mmap_t bktr_mmap;
static d_poll_t bktr_poll;
#define CDEV_MAJOR 92
static struct cdevsw bktr_cdevsw =
{
bktr_open, bktr_close, bktr_read, bktr_write,
bktr_ioctl, nostop, nullreset, nodevtotty,
bktr_poll, bktr_mmap, NULL, "bktr",
NULL, -1
};
/*
* the boot time probe routine.
*/
static const char*
bktr_probe( pcici_t tag, pcidi_t type )
{
unsigned int rev = pci_conf_read( tag, PCIR_REVID) & 0x000000ff;
if (PCI_VENDOR(type) == PCI_VENDOR_BROOKTREE)
{
switch (PCI_PRODUCT(type)) {
case PCI_PRODUCT_BROOKTREE_BT848:
if (rev == 0x12) return("BrookTree 848A");
else return("BrookTree 848");
case PCI_PRODUCT_BROOKTREE_BT849:
return("BrookTree 849A");
case PCI_PRODUCT_BROOKTREE_BT878:
return("BrookTree 878");
case PCI_PRODUCT_BROOKTREE_BT879:
return("BrookTree 879");
}
};
return ((char *)0);
}
/*
* the attach routine.
*/
static void
bktr_attach( pcici_t tag, int unit )
{
bktr_ptr_t bktr;
u_long latency;
u_long fun;
unsigned int rev;
unsigned long base;
#ifdef BROOKTREE_IRQ
u_long old_irq, new_irq;
#endif
bktr = &brooktree[unit];
if (unit >= NBKTR) {
printf("brooktree%d: attach: only %d units configured.\n",
unit, NBKTR);
printf("brooktree%d: attach: invalid unit number.\n", unit);
return;
}
/* build the device name for bktr_name() */
snprintf(bktr->bktr_xname, sizeof(bktr->bktr_xname), "bktr%d",unit);
/* Enable Memory Mapping */
fun = pci_conf_read(tag, PCI_COMMAND_STATUS_REG);
pci_conf_write(tag, PCI_COMMAND_STATUS_REG, fun | 2);
/* Enable Bus Mastering */
fun = pci_conf_read(tag, PCI_COMMAND_STATUS_REG);
pci_conf_write(tag, PCI_COMMAND_STATUS_REG, fun | 4);
bktr->tag = tag;
/*
* Map control/status registers
*/
pci_map_mem( tag, PCI_MAP_REG_START, (vm_offset_t *) &base,
&bktr->phys_base );
#if (__FreeBSD_version >= 300000)
bktr->memt = I386_BUS_SPACE_MEM; /* XXX should use proper bus space */
bktr->memh = (bus_space_handle_t)base; /* XXX functions here */
#endif
/*
* Disable the brooktree device
*/
OUTL(bktr, BKTR_INT_MASK, ALL_INTS_DISABLED);
OUTW(bktr, BKTR_GPIO_DMA_CTL, FIFO_RISC_DISABLED);
#ifdef BROOKTREE_IRQ /* from the configuration file */
old_irq = pci_conf_read(tag, PCI_INTERRUPT_REG);
pci_conf_write(tag, PCI_INTERRUPT_REG, BROOKTREE_IRQ);
new_irq = pci_conf_read(tag, PCI_INTERRUPT_REG);
printf("bktr%d: attach: irq changed from %d to %d\n",
unit, (old_irq & 0xff), (new_irq & 0xff));
#endif
/*
* setup the interrupt handling routine
*/
pci_map_int(tag, bktr_intr, (void*) bktr, &tty_imask);
/* Update the Device Control Register */
/* on Bt878 and Bt879 cards */
fun = pci_conf_read(tag, 0x40);
fun = fun | 1; /* Enable writes to the sub-system vendor ID */
#if defined( BKTR_430_FX_MODE )
if (bootverbose) printf("Using 430 FX chipset compatibilty mode\n");
fun = fun | 2; /* Enable Intel 430 FX compatibility mode */
#endif
#if defined( BKTR_SIS_VIA_MODE )
if (bootverbose) printf("Using SiS/VIA chipset compatibilty mode\n");
fun = fun | 4; /* Enable SiS/VIA compatibility mode (usefull for
OPTi chipset motherboards too */
#endif
pci_conf_write(tag, 0x40, fun);
/*
* PCI latency timer. 32 is a good value for 4 bus mastering slots, if
* you have more than four, then 16 would probably be a better value.
*/
#ifndef BROOKTREE_DEF_LATENCY_VALUE
#define BROOKTREE_DEF_LATENCY_VALUE 10
#endif
latency = pci_conf_read(tag, PCI_LATENCY_TIMER);
latency = (latency >> 8) & 0xff;
if ( bootverbose ) {
if (latency)
printf("brooktree%d: PCI bus latency is", unit);
else
printf("brooktree%d: PCI bus latency was 0 changing to",
unit);
}
if ( !latency ) {
latency = BROOKTREE_DEF_LATENCY_VALUE;
pci_conf_write(tag, PCI_LATENCY_TIMER, latency<<8);
}
if ( bootverbose ) {
printf(" %d.\n", (int) latency);
}
/* read the pci device id and revision id */
fun = pci_conf_read(tag, PCI_ID_REG);
rev = pci_conf_read(tag, PCIR_REVID) & 0x000000ff;
/* call the common attach code */
common_bktr_attach( bktr, unit, fun, rev );
}
/*
* Special Memory Allocation
*/
vm_offset_t
get_bktr_mem( int unit, unsigned size )
{
vm_offset_t addr = 0;
addr = vm_page_alloc_contig(size, 0x100000, 0xffffffff, 1<<24);
if (addr == 0)
addr = vm_page_alloc_contig(size, 0x100000, 0xffffffff,
PAGE_SIZE);
if (addr == 0) {
printf("bktr%d: Unable to allocate %d bytes of memory.\n",
unit, size);
}
return( addr );
}
/*---------------------------------------------------------
**
** BrookTree 848 character device driver routines
**
**---------------------------------------------------------
*/
#define VIDEO_DEV 0x00
#define TUNER_DEV 0x01
#define VBI_DEV 0x02
#define UNIT(x) ((x) & 0x0f)
#define FUNCTION(x) ((x >> 4) & 0x0f)
/*
*
*/
int
bktr_open( dev_t dev, int flags, int fmt, struct thread *td )
{
bktr_ptr_t bktr;
int unit;
unit = UNIT( minor(dev) );
if (unit >= NBKTR) /* unit out of range */
return( ENXIO );
bktr = &(brooktree[ unit ]);
if (!(bktr->flags & METEOR_INITALIZED)) /* device not found */
return( ENXIO );
if (bt848_card != -1) {
if ((bt848_card >> 8 == unit ) &&
( (bt848_card & 0xff) < Bt848_MAX_CARD )) {
if ( bktr->bt848_card != (bt848_card & 0xff) ) {
bktr->bt848_card = (bt848_card & 0xff);
probeCard(bktr, FALSE, unit);
}
}
}
if (bt848_tuner != -1) {
if ((bt848_tuner >> 8 == unit ) &&
( (bt848_tuner & 0xff) < Bt848_MAX_TUNER )) {
if ( bktr->bt848_tuner != (bt848_tuner & 0xff) ) {
bktr->bt848_tuner = (bt848_tuner & 0xff);
probeCard(bktr, FALSE, unit);
}
}
}
if (bt848_reverse_mute != -1) {
if ((bt848_reverse_mute >> 8) == unit ) {
bktr->reverse_mute = bt848_reverse_mute & 0xff;
}
}
if (bt848_slow_msp_audio != -1) {
if ((bt848_slow_msp_audio >> 8) == unit ) {
bktr->slow_msp_audio = (bt848_slow_msp_audio & 0xff);
}
}
switch ( FUNCTION( minor(dev) ) ) {
case VIDEO_DEV:
return( video_open( bktr ) );
case TUNER_DEV:
return( tuner_open( bktr ) );
case VBI_DEV:
return( vbi_open( bktr ) );
}
return( ENXIO );
}
/*
*
*/
int
bktr_close( dev_t dev, int flags, int fmt, struct thread *td )
{
bktr_ptr_t bktr;
int unit;
unit = UNIT( minor(dev) );
if (unit >= NBKTR) /* unit out of range */
return( ENXIO );
bktr = &(brooktree[ unit ]);
switch ( FUNCTION( minor(dev) ) ) {
case VIDEO_DEV:
return( video_close( bktr ) );
case TUNER_DEV:
return( tuner_close( bktr ) );
case VBI_DEV:
return( vbi_close( bktr ) );
}
return( ENXIO );
}
/*
*
*/
int
bktr_read( dev_t dev, struct uio *uio, int ioflag )
{
bktr_ptr_t bktr;
int unit;
unit = UNIT(minor(dev));
if (unit >= NBKTR) /* unit out of range */
return( ENXIO );
bktr = &(brooktree[unit]);
switch ( FUNCTION( minor(dev) ) ) {
case VIDEO_DEV:
return( video_read( bktr, unit, dev, uio ) );
case VBI_DEV:
return( vbi_read( bktr, uio, ioflag ) );
}
return( ENXIO );
}
/*
*
*/
int
bktr_write( dev_t dev, struct uio *uio, int ioflag )
{
return( EINVAL ); /* XXX or ENXIO ? */
}
/*
*
*/
int
bktr_ioctl( dev_t dev, ioctl_cmd_t cmd, caddr_t arg, int flag, struct thread *td )
{
bktr_ptr_t bktr;
int unit;
unit = UNIT(minor(dev));
if (unit >= NBKTR) /* unit out of range */
return( ENXIO );
bktr = &(brooktree[ unit ]);
if (bktr->bigbuf == 0) /* no frame buffer allocated (ioctl failed) */
return( ENOMEM );
switch ( FUNCTION( minor(dev) ) ) {
case VIDEO_DEV:
return( video_ioctl( bktr, unit, cmd, arg, td ) );
case TUNER_DEV:
return( tuner_ioctl( bktr, unit, cmd, arg, td ) );
}
return( ENXIO );
}
/*
* bktr_mmap.
* Note: 2.2.5/2.2.6/2.2.7/3.0 users must manually
* edit the line below and change "vm_offset_t" to "int"
*/
int bktr_mmap( dev_t dev, vm_offset_t offset, int nprot )
{
int unit;
bktr_ptr_t bktr;
unit = UNIT(minor(dev));
if (unit >= NBKTR || FUNCTION(minor(dev)) > 0)
return( -1 );
bktr = &(brooktree[ unit ]);
if (nprot & PROT_EXEC)
return( -1 );
if (offset < 0)
return( -1 );
if (offset >= bktr->alloc_pages * PAGE_SIZE)
return( -1 );
return( i386_btop(vtophys(bktr->bigbuf) + offset) );
}
int bktr_poll( dev_t dev, int events, struct thread *td)
{
int unit;
bktr_ptr_t bktr;
int revents = 0;
unit = UNIT(minor(dev));
if (unit >= NBKTR)
return( -1 );
bktr = &(brooktree[ unit ]);
disable_intr();
if (events & (POLLIN | POLLRDNORM)) {
switch ( FUNCTION( minor(dev) ) ) {
case VBI_DEV:
if(bktr->vbisize == 0)
selrecord(p, &bktr->vbi_select);
else
revents |= events & (POLLIN | POLLRDNORM);
break;
}
}
enable_intr();
return (revents);
}
#endif /* FreeBSD 2.2.x and 3.x specific kernel interface routines */
/*****************/
/* *** BSDI *** */
/*****************/