如何配置 ATA 硬盘以开始生成中断?

发布于 2024-07-20 05:52:16 字数 897 浏览 8 评论 0原文

已解决

经过多次困惑和挫折,我终于让我的硬盘中断了。 :D 这基本上可以归结为我一直在读取状态寄存器而不是备用状态寄存器。 其他一些事情在启动时也被搞乱了,但重点是我的硬盘驱动器终于开始成形了。 现在,对于其他人,我将保留原来的帖子。

PS 为了进一步说明,我不需要发出任何类型的重置命令。 我所做的只是以下操作:

  1. 选择设备(不想杀死其他磁盘上的 Solaris 操作系统)
  2. 清除设备控制寄存器中的 nIEN 位
  3. 发出 IDENTIFY DEVICE 命令***

实际上,我不确定是否需要识别设备命令,因为在不发出命令的情况下测试代码之前我很高兴地离开了实验室。 然而,要点是我需要确保读取备用状态寄存器并清除 nIEN 位,而无需重置。 BIOS 显然可以处理大部分事情。


我目前正在尝试为我学校正在开发的业余操作系统编写磁盘驱动程序。 我目前有在 PCI 配置空间中读/写数据的例程,以及用 ATA/ATAPI-7 定义的各种寄存器进行端口 IO 的汇编例程。 现在,我的问题是,具体如何让 IDE 硬盘开始生成中断? 我一直在查看所有这些文档,但我并不清楚我做错了什么。

有人能准确解释一下是什么原因导致 IDE 硬盘开始产生中断吗? 我已经准备好了一个中断服务例程来测试,但我一开始就很难获得中断。 这可以通过 ATA SOFT RESET 来完成吗?

谢谢!

更新:好的,我能够通过设置设备控制寄存器中的 SRST 位进行软复位来获得辅助通道(ATAPI CDROM)来生成中断。 这对于主通道上的硬盘不起作用。 到目前为止我注意到的是,当我设置 HDD 的 SRST 位时,它会设置 BSY 位并保持其设置状态。 从那里我不知道该怎么办。

RESOLVED

After much confusion and frustration, I finally got my hard disk to interrupt. :D It basically came down to the fact that I kept reading the status register instead of the alternate status register. A few other things were messed up to boot, but the point is my hard disk driver is finally starting to take shape. Now, for others I will leave the original post.

P.S. For further clarification, I didn't need to issue any sort of reset command. All I did was the following:

  1. Select the device (didn't want to kill the Solaris OS on the other disk)
  2. clear the nIEN bit in the DEVICE CONTROL register
  3. issue an IDENTIFY DEVICE command***

Actually, I am not sure if the IDENTIFY DEVICE command is need because I left the lab happy before I could test the code without issuing the command. However, the main point is that I needed to be sure to read the alternate status register and have the nIEN bit cleared without the need for a reset. The BIOS apparently takes care of most stuff.


I am currently trying to write a disk driver for a hobby OS being developed at my school. I currently have routines to read/write data in the PCI configuration space and assembly routines to do port IO with the various registers defined by ATA/ATAPI-7. Now, my question is, specifically how will I get an IDE hard drive to start generating interrupts? I have been looking through all this documentation and is hasn't become clear to me what I am doing wrong.

Can someone explain exactly what causes an IDE hard drive to start generating interrupts? I already have an interrupts service routine ready to test, but am having difficulty getting the interrupts in the first place. Can this be accomplished through the ATA SOFT RESET?

Thanks!

UPDATE: Ok, I was able to get the secondary channel, an ATAPI CDROM to generate interrupts by setting the SRST bit in the DEVICE CONTROL register for a soft reset. This does not work for the hard disk on the primary channel. What I have noticed so far is that when I set the SRST bit for the HDD, it sets the BSY bit and leaves it set. From there I don't know what to do.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

倥絔 2024-07-27 05:52:16

此参考资料应该对您有一定帮助:Kenos ATA/ATAPI 编程说明

允许中断的基本机制是清除DCR(设备控制寄存器)中的nIEN:

nIEN:驱动中断允许位。 主机驱动器中断的使能位。 当 nIEN 为 0 或选择驱动器时,主机中断信号 INTRQ 通过三态缓冲器启用到主机。 当nIEN为1或未选择驱动器时,无论是否存在待处理中断,主机中断信号INTRQ都处于高阻抗状态。

这个www.ata-atapi.com是一个很好的起点,可以找到更多关于ATA/PATA/SATA/ATAPI 比您想知道的还要多……请注意,官方 ATA-6/7/etc 规格的价格为 T13 美元,但您可以从其中下载 ATA-8 的最新草案。

链接描述了许多<中的一些< /strong> ATA 设备与规格的不同之处。 (很久以前,我曾经为 Commodore/Amiga 编写 SCSI 和 ATA/ATAPI 驱动程序,并帮助鉴定驱动器 - 或者更准确地说,找出驱动器制造商做了什么白痴。)

This reference should help you a fair bit: Kenos description of programming ATA/ATAPI.

The basic mechanism to enable interrupts is to clear nIEN in the DCR (Device Control Register):

nIEN: Drive Interrupt Enable bit. The enable bit for the drive interrupt to the host. When nIEN is 0 or the drive is selected the host interrupt signal INTRQ is enabled through a tri state buffer to the host. When nIEN is 1 or the drive is not selected the host interrupt signal INTRQ is in a high impedance state regardless of the presence or absence of a pending interrupt.

This www.ata-atapi.com is a good jumping-off point to find way more info about ATA/PATA/SATA/ATAPI than you want to know... Note that the official ATA-6/7/etc specs cost $$ from T13, though you can download current drafts of ATA-8 from them.

This link describes a few of the many ways ATA devices vary from the specs. (I used to write SCSI and ATA/ATAPI drivers for Commodore/Amiga, way back when, as well as help with qualifying drives - or more accurately, figuring out what idiocies drive makers had done.)

弄潮 2024-07-27 05:52:16

如果这只是一个业余爱好操作系统,为什么不使用 BIOS 中断(int 13h)? 诚然,它不如直接磁盘访问那么快,但对您的硬盘驱动器来说更安全(在干扰磁盘 I/O 之前,我已将读头穿过一块板)。

if this is just a hobby OS, why not use the BIOS interrupt (int 13h)? admittedly not as fast as direct disk access but safer for your hard drive (I've put a read head through a plate before messing with disk I/O).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文