首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何用MS x86汇编语言检测16550 UART芯片?

如何用MS x86汇编语言检测16550 UART芯片?
EN

Stack Overflow用户
提问于 2020-11-07 05:58:34
回答 1查看 273关注 0票数 0

我正在研究如何在model程序集中编写代码,以检测是否安装了16550 UART芯片(串行控制器),或者是否有一种通用的方法来检测安装的UART芯片模型。

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

Edition

  • Writing

  • 高级MS-DOS编程第二代 MS-DOS设备驱动程序
  • Ralf Brown的中断列表(尽管它可能在这里,我已经尝试搜索它的序列和16550,但还没有找到)
  • 已经在DosBox源代码中搜索了线索,因为我知道它已经实现了这一点,但是找不到where
  • https://wiki.osdev.org/Serial_Ports

一直未能找到一个副本的16550编程手册的MS-DOS.我没有问题初始化串口,发送/接收数据给它,挑战是如何检测特定的芯片,或至少确定芯片是否是16550型号。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-11-07 08:56:50

虽然不在汇编程序中,但可以将其转换为汇编程序。来自http://www.sci.muni.cz/docs/pc/serport.txt的C语言

代码语言:javascript
复制
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;
}
票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/64724886

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档