我正在研究如何在model程序集中编写代码,以检测是否安装了16550 UART芯片(串行控制器),或者是否有一种通用的方法来检测安装的UART芯片模型。
到目前为止,我检查了以下资源:
Edition
。
一直未能找到一个副本的16550编程手册的MS-DOS.我没有问题初始化串口,发送/接收数据给它,挑战是如何检测特定的芯片,或至少确定芯片是否是16550型号。
发布于 2020-11-07 08:56:50
虽然不在汇编程序中,但可以将其转换为汇编程序。来自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;
}https://stackoverflow.com/questions/64724886
复制相似问题