[comp.sys.zenith] Programming the keyboard port

TOMIII@MTUS5.BITNET (Thomas Dwyer III) (08/14/90)

According to my "Z-386/AT Series Workstation Technical Reference
Manual, Volume II Programmable Registers" book, page 17-2 it says:

  The Status Register (Port 064H)

  The Status register is an 8-bit read-only register. [text ommited]


Now on page 17-3 it says:

  Command Register (Port 064H)

  The command register is an 8-bit write-only register, addressed at I/O
  port 064H. [text ommited]


Ok people, how can the same port be both read-only and write-only?  Am
I missing something?  Am I correct in thinking that if I write a SCP
command (page 17-5) to port 064H than I can read the results of the
command from port 060H?  My tests show that any value written to port
064H followed by a read of port 060H results in a 01CH being read.

Any help on this would be most appreciated.

Thanks,
Thomas Dwyer III                            TOMIII   @ MTUS5.BITNET
Network Programmer                          DWYERIII @ MTUS5.BITNET
Computing Technology Services
Michigan Technological University

foss@iris.ucdavis.edu (Jim Alves-Foss) (08/16/90)

In article <90226.104110TOMIII@MTUS5.BITNET> TOMIII@MTUS5.BITNET (Thomas Dwyer III) writes:
>...
>Ok people, how can the same port be both read-only and write-only?  Am
>I missing something? 
>...
>Thanks,
>Thomas Dwyer III                            TOMIII   @ MTUS5.BITNET
>Network Programmer                          DWYERIII @ MTUS5.BITNET
>Computing Technology Services
>Michigan Technological University

Well, In the PC architecture we have 512 (not 256) ports. 256 are Input ports
and 256 are Output ports. Often a card will have a R/W register with a
single address. In your case you have TWO DISTINCT registers, one input
and one output but with the same address (064H(In) and 064H(Out)).

Hope this helps.

-Jim Alves-Foss (foss@iris.ucdavis.edu)  /* Of course these are MY opinions */
                (foss@[127.120.57.20])   /* and may change without warning. */

fzsitvay@techbook.com (Frank Zsitvay) (08/18/90)

In article <90226.104110TOMIII@MTUS5.BITNET> TOMIII@MTUS5.BITNET (Thomas Dwyer III) writes:
>According to my "Z-386/AT Series Workstation Technical Reference
>Manual, Volume II Programmable Registers" book, page 17-2 it says:
>
>  The Status Register (Port 064H)
>
>  The Status register is an 8-bit read-only register. [text ommited]
>
>
>Now on page 17-3 it says:
>
>  Command Register (Port 064H)
>
>  The command register is an 8-bit write-only register, addressed at I/O
>  port 064H. [text ommited]
>
>
>Ok people, how can the same port be both read-only and write-only?  Am

   When you write to port 064H you write to the command register.  When
you read from 064H, you read the status register, not the contents of
the command register.

   zilog has been confusing programmers with this for years...



-- 
fzsitvay@techbook.COM - one of these days i'll get it right...

Version 2 of anything is usually the version that works.

men408t@vaxc.cc.monash.edu.au (08/21/90)

Any port on an I.B.M PC (Including Zeniths) system can be
BOTH written to or read from.


As we all know the ports go from h'0000 to h'FFFF in practical terms only the
range h'0000 to h'0400 is actually used.


If you write to a port that is not capable of recieving data from the bus
(i.e. a read only port) it will not respond. The converse applies accept you
end up with garbage in the accumulator after the read cycle is complete.

I/O can be constructed with totaly different functions on the read and write
of one port. This is not a bad idea if your pushed for I/O space on a card
design.


NOW to the original problem of keyboards


The keyboard lies between h'0060 and h'006F on the system port map

The location h'0060 is a read only location for data (*** BUT ***) and
I will quote this from the book of words  (Logicraft Tech Ref Manual)


"The output buffer is an 8-bit read only register at I/O address 60H.
The keyboard controller used the output buffer to send scan code recieved from
the keyboard and data bytes requested by command to the system. The output
buffer should be read only when the output buffer's bit in the status
register is 1"

"The input buffer is an 8-bit write only register at i/o address 60H or 64H.
Writing to address 60H sets a flag, that indicates a data write; writing
to address 64H set a flag, indicating a command write. Data written to I/O
60H is sent to the keyboard, unless the keyboard controler is expecting a data
byte following a controller command. Data should be written to the controller's
input buffer only if the input buffer's full bit in the status register is
equal to 0"


In summary
==========

* reading from 60H gives you data
* writing to 60H sends data to the keyboard
* reading from 64H gets you the status byte of the system keyboard controller
* writing to 64H sends a command byte to the system keyboard controller


So Yes you can flash the lights and change the states of
caps lock key etc from software. If any one is interested enough I'll mail
them the source code.

Be Warned:- The Ctrl+Alt+del is actually maped to the reset bit on the
keyboard controller and can be flipped by software access, this will reset the
computer. This is not a very gracfull way to exit a program.




   Dougal Plummer
   Monash University
   Australia


"If you steal from one author, it's plagiarism;
 if you steal from many, it's research" - Wilson Mizner