Date: Thu, 18 Sep 1997 00:41:48 +0000 (GMT) From: Terry Lambert <tlambert@primenet.com> To: hackers@freebsd.org Subject: INB question Message-ID: <199709180041.RAA21191@usr04.primenet.com>
index | next in thread | raw e-mail
If a device doesn't exist, what does inb return? 0xff, right?
Specifically, how do I know if something lives at a given port?
I want to do the following:
#include <fcntl.h>
#include <machine/cpufunc.h>
/*
* MCA DMA
*/
#define IO_MCA_A_DXFR 0x18 /* DMA Extended Function Register (address)*/
#define IO_MCA_I_DXFR 0x1A /* DMA Extended Function Register (I/O)*/
/*
* High Nibble commands; low nibble specifies which channel, 0-7
*/
#define MCA_DXFR_IOAR 0x00 /* I/O Address Register*/
#define MCA_DXFR_BCAW 0x20 /* Base and Current Address Write*/
#define MCA_DXFR_BAR 0x30 /* Base Address Read*/
#define MCA_DXFR_BCCW 0x40 /* Base and Current Count Write*/
#define MCA_DXFR_BCR 0x50 /* Base Count Read*/
#define MCA_DXFR_SRR 0x60 /* Status Register Read*/
#define MCA_DXFR_EMR 0x70 /* Extended Mode Register*/
#define MCA_DXFR_MRDC 0x90 /* Mask Register Disable Channel*/
#define MCA_DXFR_MREC 0xA0 /* Mask Register Ensable Channel*/
#define MCA_DXFR_MD 0xD0 /* Master Disable*/
/*
* Channel specific commands
*/
#define MCA_DXFR_AL0 0x80 /* Arbitration Level -- Channel 0*/
#define MCA_DXFR_AL4 0x84 /* Arbitration Level -- Channel 4*/
/*
* Return 1 if MCA bus exists, 0 otherwise
*
* Note: Can't call INT 0x15, AH=0xC0 and use ptr to offset 5,
* bit 1 for MCA detect from protected mode. Instead,
* read DMA Extended Function Register's Extended Mode
* register and make sure bit 7 is 0 by assuming an
* inb on an invalid I/O port will return 0xff.
*/
int
mca_detect()
{
int rv;
outb( IO_MCA_A_DXFR, (MCA_DXFR_EMR | 0x0));
inb( 0x84); /* delay; this is bogus excpt on EISA, and
* it's not needed on EISA because it sync's
* I/O like ISA should have... should use
* outb to port 0x80 (POST code register)
* instead...
*/
rv = inb( IO_MCA_I_DXFR);
return( ( rv & 0x80) ? 0 : 1);
}
Terry Lambert
terry@lambert.org
---
Any opinions in this posting are my own and not those of my present
or previous employers.
home |
help
Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199709180041.RAA21191>
