如何在MS-DOS x86汇编语言中检测16550 UART芯片?

问题描述 投票:0回答:2

我正在尝试如何在MS-DOS汇编中编写代码来检测是否安装了16550 UART芯片(串行控制器),或者是否有一个通用方法来检测所安装的UART芯片的型号。

到目前为止,我已经检查了以下资源:

  • 高级 MS-DOS 编程第二版
  • 写入 MS-DOS 设备 司机
  • Ralf Brown 的中断列表(虽然它可能在这里,但我尝试在其中搜索串行和 16550,但没有找到)
  • 已在 DosBox 源代码中搜索线索,因为我知道它已经实现了此功能,但找不到在哪里
  • https://wiki.osdev.org/Serial_Ports

尚未找到 MS-DOS 的 16550 编程手册的副本。 我初始化串口、向其发送/接收数据都没有问题,挑战是如何检测特定芯片或至少确认芯片是否是 16550 型号。

assembly serial-port x86-16 dos uart
2个回答
4
投票

虽然不是汇编程序,但可以转换为汇编程序。来自 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;
}

0
投票

上面的过程(来自 serport.txt 文档)无法正常工作(至少不是在所有地方,所以它不可靠)。 在 simtel.net 镜像(io_utils 部分)上找到 uartty12.zip 文件,其中包含正确检测程序的二进制和 asm 源代码。

© www.soinside.com 2019 - 2024. All rights reserved.