warren@hpindda.cup.hp.com (Warren Burnett) (08/23/90)
Hi. Can anyone give me some info on the protocol used on the C-64's serial bus? I mean the one that the 1541 plugs (Jim Surine) | | NCR Peripheral Products Division | | work (316)636-8586 home (316)721-6280 /_____________________________________| #! rnews 4067 Path: hplabs!ucbvax!ucsd!swrinde!zaphod.mps.ohio-state.edu!samsung!munnari.oz.au!metro!cluster!softway!thos From: thos@softway.sw.oz.au (Thomas Cohen) Newsgroups: rec.autos.sport Subject: Re: Commentator speculation of Senna/Prost reactions Summary: Not as bad as it sounds Message-ID: <3478@softway.sw.oz.au> Date: 22
ghfeil@white.toronto.edu (Georg Feil) (08/24/90)
The C-64 serial bus is a serialized version of the parallel IEEE-488 (GPIB)
bus used on Commodore PETs. The electrical characteristics are quite
different but the data transferred is the same, right down to the primary
and secondary addresses and other control information used by GPIB. Any good
book on the IEE-488 will tell you what you need to know about the bus in
general.
Commodore uses the addresses and secondary addresses on the serial bus
in a certain way to talk between the C-64 and disks & printers.
I once decoded this (by looking at the kernel ROMS) and wrote a brief
report. Here it is, slightly edited.
Georg.
======================================================================
COMMUNICATION WITH A COMMODORE DISK DRIVE THROUGH THE HP-IB BUS
---------------------------------------------------------------
Background on Commodore Disk Drives:
A Commodore disk drive receives all commands and transmits
all data through an HP-IB type bus. Being an intelligent drive, it performs
operations such as file organization (opening & closing, updating the
directory) and input/output buffering internally. Most housekeeping and
utility operations such as disk formatting or file copying are also handled
internally, so they require only a single data exchange of the appropriate
disk command to initiate them.
Communication with the disk drive is organized into 16 possible different
"channels", numbered from 0 to 15. Channel 15 is reserved as the command
channel, through which the disk accepts commands and outputs its status.
Whenever disk files are accessed, it is through one of the other 15 channels.
Channels 0 and 1 are used when reading and writing memory image files. The
rest are for use in general purpose file handling.
Channel selection is accomplished by a method very much like HPIB secondary
addressing. Every time the 8250 is addressed to talk or listen, it awaits
an additional address (ie. another byte transmitted with ATN true).
The four least-significant bits of this byte contain the channel number,
while the other four specify what is to be done with the file associated
with that channel. The following table describes the function of the
secondary address byte.
BINARY VALUE FUNCTION FUNCTION OF ENSUING DATA
------------ -------- ------------------------
-bit: 76543210
1111XXXX Open disk file Name of file to be opened
0110XXXX Read/Write data Contents read from/written into file
1110XXXX Close disk file <no data follows>
Note that the sense of the second function listed above (read or write)
depends on whether a "talk" or "listen" primary address preceded it. The
other two functions should only be used with a "listen" address.
Here is an example communications exchange with the disk to create a
new file called SAMPLE. For this example, the disk has a primary address
of 8. Channel number 2 is used. The codes in the second column are octal.
ASCII OR
ATN | OCTAL CODE | MEANING | FUNCTION
-----|------------|-----------|----------------------------------------------
true | 0 7 7 | UNL | Unaddress current listeners
true | 1 0 0 | TLK 0 | Address controller (HP/1000) as talker
true | 0 5 0 | LSN 8 | Tell 8250 to listen; it expects sec address
true | 3 6 2 |sec address| Function: open a file using channel 2
false|"0:SAMPLE,W"| filename | Name for file (write file on drive 0)
true | 0 7 7 | UNL | Unaddress 8250
true | 0 5 0 | LSN 8 | Readdress 8250
true | 1 4 2 |sec address| Function: write to file through channel 2
false|(ascii data)| contents | Data to be written in file SAMPLE
true | 0 7 7 | UNL | Unaddress 8250
true | 0 5 0 | LSN 8 | Readdress 8250
true | 3 4 2 |sec address| Function: close file assoc. with channel 2
-----|------------|-----------|----------------------------------------------
In the example, a single file is opened, written to, and closed. This might
correspond to the Basic command 'OPEN 4,8,2,"0:SAMPLE,W"'. It is
possible to have more than one file open at the same time as long as each
uses a different channel number. Note that only the lowest level of
communications is shown.
When opening files, the filename gives additional information such as the
file type and whether it is a "read" or "write" file. The complete format
is as follows:
[@]drive:name,type,mode
/ / | \ \
/ / | \ \
/ drive# | \ access mode (READ or WRITE)
/ name of \
optional '@' file file type:
symbol to replace SEQ -sequential
an existing file. PRG -program
USR -user defined
REL -relative
Eg/ 1:NUMBERS,SEQ,READ -read sequential file NUMBERS
from drive 1.
1:NUMBERS,S,R -same as above (can abbreviate
using first letter)
1:NUMBERS -same as above (SEQ & READ are
the default values)
0:NEW,USR,W -create user file called NEW
on drive 0
@1:TEST,P,W -replace existing program TEST
on drive 1
As mentioned earlier, channel 15 is the command channel. It does not need
to be opened or closed since it is permanently designated, although it may
be (if you choose to open it, the filename in the open procedure
is taken as the first disk command). Any data written to channel
15 is interpreted as a command. Here is a brief list of some of the
most commonly used commands. Refer to the disk drive user's manual for
a complete descripion.
Ndrive:diskname,id -Format a new diskette with
given name and id.
Eg/ N0:DEMO DISK,99
Sdrive:filename -Scratch files matching
given filename.
Eg/ S1:TEMP
Cdriveb=drivea -Copy all files on drivea
to driveb.
Eg/ C1=0
Cdriveb:filenameb=drivea:filenamea -Copy file filenamea to same or
other drive & call it filenameb.
Eg/ C1:COPY=0:ORIGINAL
Bdriveb=drivea -Backup disk in drivea to driveb.
Old driveb contents are lost.
Eg/ B0=1
Vdrive -Validate disk in given drive. This
is something like PK in FMGR.
Eg/ V0
UJ -Reset disk drive. This triggers
a software cold start.
When the command channel is accessed in a read operation, the data received
is a status message from the drive. This is an ascii string separated by
commas into 5 fields, as follows:
nn, xxxxxx ,nn,nn,n
/ | \ / \
/ | | \
/ | | drive last accessed (0 or 1)
error# error track &
message sector of location
Eg/ 21, READ ERROR,18,02,0
See the disk drive user's guide for descriptions of the various errors.
--
Georg Feil Internet: ghfeil@white.toronto.edu
-or- : georg@sgl.ists.ca
..if all else fails, try:
{uunet,pyramid,watmath,utzoo}!utcsri!white!ghfeil (UUCP)
ghfeil%white.toronto.edu@relay.cs.net (ARPA)ghfeil@white.toronto.edu (Georg Feil) (08/24/90)
Note: in my last posting on Commodore disks, replace all occurrences of
'8250' with the word 'disk'. This just happens to be the particular disk the
description was written for. It should apply to all Commodore disks.
Georg.
--
Georg Feil Internet: ghfeil@white.toronto.edu
-or- : georg@sgl.ists.ca
..if all else fails, try:
{uunet,pyramid,watmath,utzoo}!utcsri!white!ghfeil (UUCP)
ghfeil%white.toronto.edu@relay.cs.net (ARPA)