4 | Written by Yasha
(ITOH Yasufumi
)
5 | This code is in the public domain
10 #define FDC_STATUS 0xE94001 /* status register */
11 #define FDC_DATA 0xE94003 /* data register */
13 #define INT_STAT 0xE9C001 /* interrupt control */
17 #define NE7ST_CB_BIT 4 /* FDC busy */
18 #define NE7ST_DIO_BIT 6 /* data input/output */
19 #define NE7ST_RQM_BIT 7 /* request for master */
22 #define NE7CMD_READID 0x4A /* READ ID */
25 | Read ID of all sectors in current track.
26 | This routine expects that motor on
, drive selection
27 |
and seek is already done.
29 | input
: d0.
b: 0 0 0 0 0 HD US1 US0
(binary
)
30 | output
: d0.
l: min
# sector (N C H R (2hex))
31 | d1.
l: max
# sector (N C H R (2hex))
37 .globl check_fd_format
39 moveml
%d2-
%d7
/%a1-
%a3
,%sp@
-
41 moveb
%d0
,%d6 | head
, drive
44 lea
%a1@
(FDC_DATA-FDC_STATUS
),%a2 | FDC_DATA
45 lea
%a2@
(INT_STAT-FDC_DATA
),%a3 | INT_STAT
48 oriw
#0x0700,%sr | keep out interrupts
49 moveq
#INT_FDC_BIT,%d5
50 bclr %d5
,%a3@ | disable FDC interrupt
54 movel
%d3
,%d2 | first sector
55 movel
%d3
,%d0 | sector min
57 movel
%d3
,%d1 | sector max
72 bset
%d5
,%a3@ | enable FDC interrupt
76 moveml
%a7@
+,%d2-
%d7
/%a1-
%a3
82 | input
: d6.
b: 0 0 0 0 0 HD US1 US0
(binary
)
85 | interrupt must
be disabled
86 | output
: d3.
l: sector information
: N C H R
(2hex
)
87 | d7.
l: status
(nonzero if error
)
88 | Z flag
: true if no error
, false if error
95 btst
#NE7ST_CB_BIT,%a1@
98 | send READ ID command
101 jmi fdc_send_command1
102 moveb
#NE7CMD_READID,%a2@
106 jmi fdc_send_command2
107 moveb
%d6
,%a2@ | X X X X X HD US1 US0
(binary
)
112 movel
%d3
,%d7 | d7
: FDC status
: X ST0 ST1 ST2
(2hex
)
114 jbsr fdc_read_bytes | d3
: sector info
: C H R N
(2hex
)
115 rorl
#8,%d3 | d3: sector info: N C H R (2hex)
117 andil
#0x00f8ffff,%d7 | check status (must be zero)
121 | receive d4
:w
+ 1 bytes from FDC
129 dbra
%d4
,fdc_read_bytes
134 jpl fdc_wait_rqm | NE7ST_RQM_BIT
= 7: sign bit
135 lslb
#1,%d3 | NE7ST_DIO_BIT = 6 ... move to bit #7
142 BOOT_ERROR
("READ ID failed")