home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / sys / cbm / 3397 < prev    next >
Encoding:
Text File  |  1992-08-14  |  9.5 KB  |  211 lines

  1. Newsgroups: comp.sys.cbm
  2. Path: sparky!uunet!usc!sol.ctr.columbia.edu!destroyer!ubc-cs!unixg.ubc.ca!kakwa.ucs.ualberta.ca!access.usask.ca!ccu.umanitoba.ca!shad04
  3. From: shad04@ccu.umanitoba.ca (Dan Fandrich)
  4. Subject: Re: serial bus
  5. Message-ID: <1992Aug15.062851.21910@ccu.umanitoba.ca>
  6. Organization: University of Manitoba, Winnipeg, Manitoba, Canada
  7. References: <1992Aug6.101701.5868@etek.chalmers.se> <1992Aug12.211643.23084@ccu.umanitoba.ca>
  8. Date: Sat, 15 Aug 1992 06:28:51 GMT
  9. Lines: 200
  10.  
  11. In article <1992Aug6.101701.5868@etek.chalmers.se> mcl@etek.chalmers.se (Mathias Luthi) writes:
  12. >  I am looking for a good description (better than the one found in the
  13. >  programmer's guide) of the serial bus protocol. Does anyone have such
  14. >  a thing ?
  15.  
  16. Since my last post, I found an article stashed away on my hard disk that,
  17. in combination with Jim Butterfield's magazine writeup, would probably be all
  18. you need to implement the protocol yourself.  Here's it is:
  19.  
  20. ---------
  21. Article 1524 of comp.sys.cbm:
  22. Path: ccu.umanitoba.ca!clyde.concordia.ca!mcgill-vision!snorkelwacker!paperboy!husc6!rutgers!news-server.csri.toronto.edu!white.toronto.edu!ghfeil
  23. From: ghfeil@white.toronto.edu (Georg Feil)
  24. Newsgroups: comp.sys.cbm
  25. Subject: Re: C-64 serial bus info
  26. Message-ID: <1990Aug23.184800.2387@jarvis.csri.toronto.edu>
  27. Date: 23 Aug 90 22:48:00 GMT
  28. References: <4280001@hpindda.cup.hp.com>
  29. Organization: CSRI, University of Toronto
  30. Lines: 174
  31.  
  32.  
  33. The C-64 serial bus is a serialized version of the parallel IEEE-488 (GPIB) 
  34. bus used on Commodore PETs. The electrical characteristics are quite 
  35. different but the data transferred is the same, right down to the primary 
  36. and secondary addresses and other control information used by GPIB. Any good 
  37. book on the IEE-488 will tell you what you need to know about the bus in 
  38. general.
  39.  
  40. Commodore uses the addresses and secondary addresses on the serial bus
  41. in a certain way to talk between the C-64 and disks & printers. 
  42. I once decoded this (by looking at the kernel ROMS) and wrote a brief
  43. report. Here it is, slightly edited.
  44.  
  45. Georg.
  46.  
  47. ======================================================================
  48.  
  49.  COMMUNICATION WITH A COMMODORE DISK DRIVE THROUGH THE HP-IB BUS 
  50.  --------------------------------------------------------------- 
  51.   
  52. Background on Commodore Disk Drives:
  53.   
  54.  A Commodore disk drive receives all commands and transmits
  55. all data through an HP-IB type bus.  Being an intelligent drive, it performs
  56. operations such as file organization (opening & closing, updating the 
  57. directory) and input/output buffering internally.  Most housekeeping and
  58. utility operations such as disk formatting or file copying are also handled 
  59. internally, so they require only a single data exchange of the appropriate
  60. disk command to initiate them.
  61.   
  62.  Communication with the disk drive is organized into 16 possible different
  63. "channels", numbered from 0 to 15.  Channel 15 is reserved as the command 
  64. channel, through which the disk accepts commands and outputs its status.
  65. Whenever disk files are accessed, it is through one of the other 15 channels. 
  66. Channels 0 and 1 are used when reading and writing memory image files. The
  67. rest are for use in general purpose file handling.
  68.   
  69.  Channel selection is accomplished by a method very much like HPIB secondary 
  70. addressing. Every time the 8250 is addressed to talk or listen, it awaits 
  71. an additional address (ie. another byte transmitted with ATN true). 
  72. The four least-significant bits of this byte contain the channel number,
  73. while the other four specify what is to be done with the file associated
  74. with that channel. The following table describes the function of the
  75. secondary address byte. 
  76.   
  77.   
  78.     BINARY VALUE    FUNCTION            FUNCTION OF ENSUING DATA
  79.     ------------    --------            ------------------------
  80. -bit: 76543210
  81.   
  82.       1111XXXX    Open disk file      Name of file to be opened 
  83.       0110XXXX    Read/Write data     Contents read from/written into file
  84.       1110XXXX    Close disk file     <no data follows> 
  85.   
  86.   
  87. Note that the sense of the second function listed above (read or write) 
  88. depends on whether a "talk" or "listen" primary address preceded it. The
  89. other two functions should only be used with a "listen" address.
  90.   
  91.  Here is an example communications exchange with the disk to create a 
  92. new file called SAMPLE. For this example, the disk has a primary address
  93. of 8. Channel number 2 is used. The codes in the second column are octal.
  94.   
  95.  
  96.         ASCII OR
  97.   ATN | OCTAL CODE |  MEANING  |                 FUNCTION 
  98.  -----|------------|-----------|----------------------------------------------
  99.  true |   0 7 7    |   UNL     |  Unaddress current listeners 
  100.  true |   1 0 0    |   TLK 0   |  Address controller (HP/1000) as talker
  101.  true |   0 5 0    |   LSN 8   |  Tell 8250 to listen; it expects sec address 
  102.  true |   3 6 2    |sec address|  Function: open a file using channel 2 
  103.  false|"0:SAMPLE,W"|  filename |  Name for file  (write file on drive 0)
  104.  true |   0 7 7    |   UNL     |  Unaddress 8250
  105.  true |   0 5 0    |   LSN 8   |  Readdress 8250
  106.  true |   1 4 2    |sec address|  Function: write to file through channel 2 
  107.  false|(ascii data)|  contents |  Data to be written in file SAMPLE 
  108.  true |   0 7 7    |   UNL     |  Unaddress 8250
  109.  true |   0 5 0    |   LSN 8   |  Readdress 8250
  110.  true |   3 4 2    |sec address|  Function: close file assoc. with channel 2
  111.  -----|------------|-----------|----------------------------------------------
  112.  
  113.   
  114. In the example, a single file is opened, written to, and closed. This might
  115. correspond to the Basic command 'OPEN 4,8,2,"0:SAMPLE,W"'. It is
  116. possible to have more than one file open at the same time as long as each 
  117. uses a different channel number. Note that only the lowest level of 
  118. communications is shown. 
  119.   
  120.  When opening files, the filename gives additional information such as the
  121. file type and whether it is a "read" or "write" file. The complete format 
  122. is as follows:
  123.   
  124.                 [@]drive:name,type,mode 
  125.                 /   /      |    \     \ 
  126.                /   /       |     \     \
  127.               / drive#     |      \     access mode (READ or WRITE) 
  128.              /          name of    \
  129.       optional '@'       file    file type: 
  130.       symbol to replace          SEQ -sequential
  131.       an existing file.          PRG -program 
  132.                                  USR -user defined
  133.                                  REL -relative
  134.   
  135.     Eg/       1:NUMBERS,SEQ,READ         -read sequential file NUMBERS
  136.                                           from drive 1. 
  137.               1:NUMBERS,S,R              -same as above (can abbreviate 
  138.                                           using first letter) 
  139.               1:NUMBERS                  -same as above (SEQ & READ are 
  140.                                           the default values) 
  141.               0:NEW,USR,W                -create user file called NEW 
  142.                                           on drive 0
  143.               @1:TEST,P,W                -replace existing program TEST 
  144.                                           on drive 1
  145.   
  146.   
  147.  As mentioned earlier, channel 15 is the command channel. It does not need
  148. to be opened or closed since it is permanently designated, although it may
  149. be (if you choose to open it, the filename in the open procedure
  150. is taken as the first disk command). Any data written to channel
  151. 15 is interpreted as a command.  Here is a brief list of some of the
  152. most commonly used commands. Refer to the disk drive user's manual for
  153. a complete descripion.
  154.   
  155.   
  156.     Ndrive:diskname,id                     -Format a new diskette with
  157.                                             given name and id.
  158.         Eg/  N0:DEMO DISK,99
  159.   
  160.     Sdrive:filename                        -Scratch files matching
  161.                                             given filename. 
  162.         Eg/  S1:TEMP
  163.   
  164.     Cdriveb=drivea                         -Copy all files on drivea
  165.                                             to driveb.
  166.         Eg/  C1=0 
  167.   
  168.     Cdriveb:filenameb=drivea:filenamea     -Copy file filenamea to same or
  169.                                             other drive & call it filenameb.
  170.         Eg/  C1:COPY=0:ORIGINAL 
  171.   
  172.     Bdriveb=drivea                         -Backup disk in drivea to driveb.
  173.                                             Old driveb contents are lost. 
  174.         Eg/  B0=1 
  175.   
  176.     Vdrive                                 -Validate disk in given drive. This
  177.                                             is something like PK in FMGR. 
  178.         Eg/  V0 
  179.   
  180.     UJ                                     -Reset disk drive. This triggers 
  181.                                             a software cold start.
  182.   
  183.   
  184.  When the command channel is accessed in a read operation, the data received
  185. is a status message from the drive. This is an ascii string separated by
  186. commas into 5 fields, as follows: 
  187.   
  188.                     nn, xxxxxx ,nn,nn,n 
  189.                     /     |      \ /   \
  190.                    /      |       |     \ 
  191.                   /       |       |      drive last accessed (0 or 1) 
  192.               error#   error    track & 
  193.                        message  sector of location
  194.   
  195.   
  196.     Eg/   21, READ ERROR,18,02,0
  197.   
  198. See the disk drive user's guide for descriptions of the various errors. 
  199.   
  200. --
  201. Georg Feil                                 Internet: ghfeil@white.toronto.edu
  202.                                              -or-  : georg@sgl.ists.ca
  203. ..if all else fails, try:
  204. {uunet,pyramid,watmath,utzoo}!utcsri!white!ghfeil      (UUCP)
  205. ghfeil%white.toronto.edu@relay.cs.net                  (ARPA)
  206. ------------
  207.  
  208. >>> Dan
  209. -- 
  210. Internet: shad04@ccu.umanitoba.ca               Compu$erve: 72365,306
  211.