-
Notifications
You must be signed in to change notification settings - Fork 6
/
search_id_section.txt
88 lines (64 loc) · 4.34 KB
/
search_id_section.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
TPDD1 FDC-mode command "S" - Search ID Section
Page 38 of the software manual
https://archive.org/details/tandy-service-manual-26-3808-s-software-manual-for-portable-disk-drive/page/38/
This is an odd command that isn't actually used by any of the main TPDD clients
or applications as far as I've seen yet. All the "DOS"s (TS-DOS, DSKMGR, TEENY, Floppy, etc)
use only "Operation-mode" (aka file-access) commands.
The only applications I know of so far that use FDC-mode (aka sector-access) commands
are Sardine and the installer for Disk-Power, and neither of those uses this command.
So there is no client software I know of to test if we are emulating this function well enough.
What we do have is, pdd.sh was used to probe out what a real drive does,
and then both pdd.sh and dl2 do that.
So *maybe* we are emulating the real drives "S" command more or less?
The software manual explains almost nothing about this command. It only says:
"The procedure is similar to that for the Write Sector command,
except that you send a search string instead of data to be written."
Which is not only insufficient but also not as correct as it could be.
The process is actually more like the Write ID Section command.
The process goes like this (as far as I can tell):
0 - client sends the Operation-mode command for "switch to FDC-mode"
0x5A 0x5A 0x08 0x00 0xDC
(ZZ 0x08 NULL checksum)
"Search ID Section" is an FDC-mode command, and a real drive always starts
in Operation-mode at power-on by default. So if not done already,
the drive must first be switched from Operation-mode to FDC-mode before
you can issue any FDC-mode commands.
https://archive.org/details/tandy-service-manual-26-3808-s-software-manual-for-portable-disk-drive/page/21/
The drive does not send back any response to this command.
The drive is simply now in FDC-mode, waiting to accept FDC-mode commands instead of Operation-mode commands.
1 - client sends 0x53 0x0D
(S carriage-return)
This command takes no parameters after the S.
dl2 silently ignores any extra characters,
but a real drive gives error 0x61 if there are any extra bytes after the S.
2 - drive sends a standard FDC-mode response block(a)
(8 bytes, all ascii "0"s if there was no hardware fault or other error)
If the command was valid and no hardware problem: err:0 dat:0 len:0
(0x30 0x30 0x30 0x30 0x30 0x30 0x30 0x30 = "00000000" = err:0x00 = success)
If the command was malformed: err:0x61 dat:0 len:0
(0x36 0x31 0x30 0x30 0x30 0x30 0x30 0x30 = "61000000" = err:0x61 = error)
client parses the response block
if err>0, abort operation
drive returns to waiting for new commands
client should not send or expect anything more for this operation
otherwise, if err==0, proceed...
3 - client sends exactly 12 bytes of data
no less or more
right-pad with 0x00 or truncate to 12 bytes as necessary
to search for "abc" send 0x61 0x62 0x63 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
drive is busy for up to 20 seconds while searching up to 80 IDs for a match
drive does not send anything during this time
client must not send anything during this time
wait at least 20 seconds and abort if no response by 30 seconds
4 - drive sends another FDC-mode response block
If a match was found: err:0x00 dat:sector-number len:logical-sector-size-bytes
If a match was not found: err:0x60 dat:0xFF len:logical-sector-size-bytes
There seems to be no way to search for multiple sectors with the same ID.
(other than using READ ID and reading them all yourself instead of using SEARCH ID)
The search always only returns the 1st match, and there is no way to tell it to start at some other sector than 0.
github/bkw777/pdd.sh has an implementation of the client side of this and is working with real TPDD drives.
dl2 has an implementation of the server side of this and is working with pdd.sh at least.
(a) all FDC-mode commands use this 8-byte response format:
2 bytes = 1 ascii hex pair representing a uint8_t for error/status code (err:#) 0=success, >0 = various errors & conditions
2 bytes = 1 ascii hex pair representing a uint8_t for result data (dat:#), meaning depends on command
4 bytes = 2 ascii hex pairs representing a uint16_t (msb-first) for length or address or offset (len:#), meaning depends on command