我正在尝试如何在MS-DOS汇编中编写代码来检测是否安装了16550 UART芯片(串行控制器),或者是否有一个通用方法来检测所安装的UART芯片的型号。
到目前为止,我已经检查了以下资源:
尚未找到 MS-DOS 的 16550 编程手册的副本。 我初始化串口、向其发送/接收数据都没有问题,挑战是如何检测特定芯片或至少确认芯片是否是 16550 型号。
虽然不是汇编程序,但可以转换为汇编程序。来自 http://www.sci.muni.cz/docs/pc/serport.txt 的 C 语言
int detect_UART(unsigned baseaddr)
{
// this function returns 0 if no UART is installed.
// 1: 8250, 2: 16450 or 8250 with scratch reg., 3: 16550, 4: 16550A
int x,olddata;
// check if a UART is present anyway
olddata=inp(baseaddr+4);
outp(baseaddr+4,0x10);
if ((inp(baseaddr+6)&0xf0)) return 0;
outp(baseaddr+4,0x1f);
if ((inp(baseaddr+6)&0xf0)!=0xf0) return 0;
outp(baseaddr+4,olddata);
// next thing to do is look for the scratch register
olddata=inp(baseaddr+7);
outp(baseaddr+7,0x55);
if (inp(baseaddr+7)!=0x55) return 1;
outp(baseaddr+7,0xAA);
if (inp(baseaddr+7)!=0xAA) return 1;
outp(baseaddr+7,olddata); // we don't need to restore it if it's not there
// then check if there's a FIFO
outp(baseaddr+2,1);
x=inp(baseaddr+2);
// some old-fashioned software relies on this!
outp(baseaddr+2,0x0);
if ((x&0x80)==0) return 2;
if ((x&0x40)==0) return 3;
return 4;
}
上面的过程(来自 serport.txt 文档)无法正常工作(至少不是在所有地方,所以它不可靠)。 在 simtel.net 镜像(io_utils 部分)上找到 uartty12.zip 文件,其中包含正确检测程序的二进制和 asm 源代码。