现在的位置: 首页 > 综合 > 正文

Programming Floppy Disk Controllers (中)

2013年10月16日 ⁄ 综合 ⁄ 共 4771字 ⁄ 字号 评论关闭

原文:可编程软盘控制器

Data Register

数据寄存器是一个8位的寄存器,类似其他的寄存器,它间接的提供了一个寄存器栈。一个命令可能是0~9个字节长,第一个字节告诉控制器可能的字节数目。控制器发送命令字节给栈里正确的寄存器,保存程序员需要的索引寄存器,类似于其他的设备(比如VGA的寄存器)。

有些控制器,比如i82077A,它有一块可编程范围的缓冲区,允许一次传输多个字节。这样可以提高数据和命令的传输和减少uPD765的相应时间。

伴随命令的完成,会有返回值在状态寄存器里面。下面将详细介绍这些状态寄存器。

- Status Register ST0

IC1,IC0:interrupt code.

  00 = normal termination, command terminated without any errors

  01 = abnormal termination, the controller stared execution of the command, but couldn't terminate it correctly

  10 = invalid command, the controller could not start command execution

  11 = abnormal termination by polling, drive became not ready

SE:seek end.

  the controller has completed a seek or a calibration command, or has correctly executed a read or write command which has an implicit seek

UC:unit check.

  set if the drive faults or if a recalibrate cannot find track 0 after 79 pulses

NR:drive not ready.

HD:head currently active

  1 = head 1, 0 = head 0

US1,US0:currently selected drive (unit select).

  00 = drive 0 (A:)

  01 = drive 1 (B:)

  10 = drive 2 (C:)

  11 = drive 3 (D:)

- Status Register ST1

EN:end of cylinder.

  set when the sector count exceeds the number of sectors on a track.

  i.e. the controller attempts to access a sector after the last sector of a cylinder

xx:bit unused.

DE:data error.

  set if the controller detected an error in the ID address field or the data field of a sector

TO:time-out.

  set for a data overrun, no signal received from the DMA controller or CPU within the required time period

NDAT:no data.

  set if: the addressed sector in a read sector or read deleted sector cannot be found by the controller,

       or: the controller cannot read the ID address mask in response to a read ID command without error,

       or: the controller cannot correctly determine the sequence of sectors in a read track command

NW:not writable.

  set if the disk in the selected drive is write protected while the controller attempts to execute a write command

NID:no address mask.

  set if: the ID address mask was not found after one complete disk revolution,

       or: the controller could not find a data address mask DAM or a deleted data address mask DAM on the specified track

- Status Register ST2

xx:bit unused.

  value always equal to 0

DADM:deleted address mask.

  set if: a deleted data address mask DAM is detected when a read sector command is being executed,

       or: a valid data address mask DAM is detected when a read deleted sector command is being executed

CRCE:CRC error in data field.

  set if a CRC error was detected in the data field of the sector

WCYL:wrong cylinder.

  set if the track address in the controller and the track address in the ID address mask are different

SEQ:seek equal.

  set if: controller is a uPD765 and the condition seek equal is fulfilled,

     else: SGL is not used, the field is always equal to 0

SERR:seek error.

  set if: controller is a uPD765 and the controller did not find the corresponding sector when seeking on the cylinder,

     else: SERR is not used, this field is always equal to 0

BCYL:bad cylinder.

  this field indicates that the track address in the ID address mask differs from the track address in the controller, the value equals ffh, indicating a bad track with a physical error, according to the IBM soft sector
format

NDAM:not data address mask DAM.

  set if the controller cannot find a valid or deleted data address mask DAM

- Status Register ST3

ESIG:error.

  set if: controller is a uPD765 and the drives error signal is active, i.e. an error has occurred

WPDR:write protection.

  set if the disk is write protected (indicates the write-protection line is active)

RDY:ready.

  set if: controller is a uPD765 and the drive is ready (indicates the ready signal of the drive is active)

TRK0:track 0.

  the head is above track 0 (the TRK0 signal of the drive is active)

DSDR:double sided drive.

  the drive is double sided (indicates the DSDR signal is active)

HDDR:head.

  this bit indicates the status of the HDSEL signal of the drive: 1 = head 1 active, 0 = head 0 active

DS1,DS0:drive select.

  both bits indicate the select signals DS1 and DS0 of the drive:

  00 = drive 0 (A:)

  01 = drive 1 (B:)

  10 = drive 2 (C:)

  11 = drive 3 (D:)

Digital Input Register

CHAN:disk change.

  1 = disk changed since last command, 0 = disk not changed

RAT1,RAT0:data rate.

  00 = 500 kbits/s, 01 = 300 kbits/s, 10 = 250 kbits/s, 11 = 1 mbits/s

HiDe:high-density rate.

  1 = data rate 250 kbits/s or 300 kbits/s, 0 = data rate 1 mbits/s or 500 kbits/s

DMA:value of DMA bit in DOR.

NOPR:value of NOPR bit in control configuration register.

这个寄存器仅在AT和PS/2机里有效,只读。上图中展示了这个寄存器在AT机,PS/2机和PS/2 model 30机的3种不同配置。它们都用bit 7去侦测磁盘改变,还有其他信息只对PS/2机和PS/2 model 30机有效。

对于每个寄存器,当bit 7被置位,它表示磁盘已经被改变了因为最后一次命令的执行。驱动器通过缓存数据来加快数据的传输。当缓存数据,如果磁盘没有改变,被请求的扇区可能已经在内存中请求好了(比如,一次读取整个磁道然后存储在缓存中,它可能存储了多个磁道当需要从不同的柱面读取扇区的时候)。如果说一个新的柱面需要读取或者磁盘改变了,那么数据就需要从磁盘读了。

在PS/2机和PS/2 model 30机种,寄存器还包含了当前数据传输率大小。对于model 30,通过读取bit 1和0,而对于其他PS/2 models,读取bit 2和1。这个数据当control configuration register设定后,可以来检查当前的传输率或者在任何时候检查控制器设定的传输率。

在非model 30的PS/2机种,bit 1位可以用来检测控制器对高密度磁盘是设定在高还是低的数据传输率。

对于model 30机,bit 3位对应DOR寄存器的bit 3位。bit 2位对应CCR寄存器的bit 2位(仅仅用于此model)。对于这两个bit,值是只读的在DIR寄存器中,在对应的寄存器中可写。

Control Configuration Register

RAT1,RAT0:data rate.

  00 = 500 kbits/s, 01 = 300 kbits/s, 10 = 250 kbits/s, 11 = 1 mbits/s

NOPR:(no) precompensate.

  0 = precompensation enabled (standard)

  1 = no precompensation

在AT机和所有的PS/2机中,数据传输率可以通过CCR的bit 1和0位设定。在下面的表中展示了适合这两个位的值。

在model 30机中,它可以通过这个寄存器的bit 2位编程precompensation。它默认是precompensation使能通过设定该位为0。设定该位为1可以关掉了precompensation。

Status Registers A and B

Data Rate Select Register

抱歉!评论已关闭.