Post by Robert PengellyPost by Robert PengellyPost by wolfgang kernPost by wolfgang kernDoes anyone know if a PS/2 mouse will be detected by the computer if it's plugged in > while the computer is on?
depends on OS, while windoze does, old DOS may not.
If it does then would using IRQ12 be a better choice instead of using INT 15h AX=0xC0xx?
That was meant to be instead of INT 15h AX=0xC2xx?
this are two different things :) you may need both.
PS/2 mouse keyboard combination is well defined,
INT15 is there for various mouse setups
IRQ12 is the thing that shall receive mouse packets.
What do you mean it's there for various setups? http://www.ctyme.com/intr/rb-1601.htm (only need to have one as an example) says POINTING DEVICE BIOS INTERFACE (PS), does the PS at the end not mean PS/2 or is it a certain set of PS/2 mice that it supports?
behind INT15C2xx there are more mouse functions available.
C207 let you set your handler address but it doesn't save you from
enabling IRQ12.
__
wolfgang
I'm having a few problems setting up IRQ12. I have the following code
push es
push ax
push bx
push dx
;; ps2_write_command (PS2_DISABLE_PORT1)
mov al, HEX (AD)
out HEX (64), al
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Enable interrupt lines, enable translation.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ps2_write_command_read_data (PS2_READ_CONFIG)
mov al, HEX (20)
out HEX (64), al
xor ax, ax
in al, HEX (60)
;; status |= PS2_PORT1_IRQ | PS2_PORT1_TLATE
or al, HEX (01)
or al, HEX (40)
xchg bl, al
;; ps2_write_command_arg (PS2_WRITE_CONFIG, status)
mov al, HEX (60)
out HEX (64), al
xchg al, bl
out HEX (60), al
;; ps2_write_command_read_data (PS2_READ_CONFIG)
mov al, HEX (20)
out HEX (64), al
xor ax, ax
in al, HEX (60)
;; ps2_write_command_read_data (0xAE)
mov al, HEX (AE)
out HEX (64), al
xor ax, ax
in al, HEX (60)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Test PS/2 port.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ps2_write_command_read_data (0xAB)
mov al, HEX (AB)
out HEX (64), al
xor ax, ax
in al, HEX (60)
and al, al
jnz mouse_initialize.no_ps2
;; ps2_write_command (PS2_ENABLE_PORT)
mov dx, HEX (64)
mov al, HEX (AD)
out dx, al
nop
cli
xor ax, ax
mov es, ax
mov word ptr es:[HEX (74) * 4], offset ps2_handler
mov word ptr es:[HEX (74) * 4 + 2], cs
sti
;; pic_unmask_irq (1)
: mov dx, HEX (20)
: xor ax, ax
: in al, dx
; mov bl, (1 << 1)
; not bl
; and al, bl
; out dx, al
IN AL,0x21
AND AL,0xFD reset bit1
OUT 0x21,al
;; pic_unmask_irq (12)
;mov dx, HEX (A0)
;xor ax, ax
;in al, dx
;mov bl, (1 << 4)
;not bl
;and al, bl
;out dx, al
IN AL,0xA1
AND AL,0xEF reset bit4
OUT 0xA1,AL
;; ps2_write_command (PS2_ENABLE_PORT1)
mov dx, HEX (64)
mov al, HEX (AE)
out dx, al
;; ps2_write_data (0xFF)
mov dx, HEX (60)
mov al, HEX (FF)
out dx, al
jmp short mouse_initialize.done
pop dx
pop bx
pop ax
pop es
ret
and http://www.ctyme.com/intr/int-74.htm says it's for IRQ12 but I'm not getting an interrupt. Am I doing something wrong?
see above, and when I remember my old code from 40 years ago it first
disables the PS/2 keyboard and then set mouse commands which all need
one special byte in front of to to tell "mouse" instead of Keyboard.
I think this was a 0xD4 byte.
__
wolfgang
;; ps2_write_command (PS2_ENABLE_PORT1)
call ps2_wait_input
mov dx, HEX (64)
mov al, HEX (AE)
out dx, al
nop
call ps2_wait_input
mov dx, HEX (64)
mov al, HEX (D4)
out dx, al
nop
;; ps2_write_data (0xFF)
call ps2_wait_input
mov dx, HEX (60)
mov al, HEX (FF)
out dx, al
nop
you don't need to use DX for any I/O below 0x0100
and the NOPs are redundant, a better delay is the dummy OUT 0xeb,al
Post by Robert Pengellybut it still doesn't work or do I need to do the 0xD4 for every write?
YEP, IIRC I had this D4 in front of all data to/from 0x60.
__
wolfgang
here is the port0x64 command list from RBIL:
(Table P0401)
Values for keyboard controller commands (data goes to PORT 0060h):
Value Description
20h read read byte zero of internal RAM, this is the last KB command
sent to the 8041/8042
Compaq put current command byte on PORT 0060h (see #P0403,#P0404)
21-3F read reads the byte specified in the lower 5 bits of the command
in the 804x's internal RAM (see #P0407)
60-7F double writes the data byte to the address specified in the 5 lower
bits of the command
60h Compaq Load new command (60 to [64], command to [60]) (see #P0404)
(also general AT-class machines)
A0h AMI get ASCIZ copyright message on PORT 0060h
A1h AMI get controller version byte on PORT 0060h
A1h Compaq unknown speedfunction ??
A1h C&T CHIPS extensions (see #P0402)
A2h Compaq unknown speedfunction ??
A2h AMI set keyboard controller pins 22 and 23 low
A2h C&T turn on turbo LED
A3h Compaq Enable system speed control
A3h AMI set keyboard controller pins 22 and 23 high
A3h C&T turn off turbo LED
A4h MCA check if password installed
returns PORT 0060h code F1h if no password, FAh if installed
A4h Compaq Toggle speed
A4h AMI set internal system speed flag to low
A5h MCA load password
write successive scan codes to PORT 0060h, terminate with 00h
A5h AMI set internal system speed flag to high
A5h Compaq Special read. the 8042 places the real values of port 2
except for bits 4 and 5 wich are given a new definition in
the output buffer. No output buffer full is generated.
if bit 5 = 0, a 9-bit keyboard is in use
if bit 5 = 1, an 11-bit keyboard is in use
if bit 4 = 0, output-buff-full interrupt disabled
if bit 4 = 1, output-buffer-full interrupt enabled
A6h MCA check password
A6h AMI get internal system speed flag on PORT 0060h
A6h Compaq unknown speedfunction ??
A7h MCA disable mouse port
A7h AMI set internal flag indicating bad write cache
A8h MCA enable mouse port
A8h AMI set internal flag indicating good write cache
A9h MCA test mouse port, return test result on PORT 0060h (see #P0406)
A9h AMI get internal flag indicating cache OK to PORT 0060h
AAh sngl initiate self-test. will return 55h to data port if self-test
successful, FCh if failed
AAh Compaq initializes ports 1 and 2, disables the keyboard and clears
the buffer pointers. It then places 55h in the output buffer.
ABh sngl initiate interface test, return result value on PORT 0060h
(see #P0406)
ACh read diagnostic dump. the contents of the 804x RAM, output port,
input port, status word are sent to PORT 0060h in scan-code
format; Chips&Technologies 8042's append "CHIPS Vxxx" where
"xxx" is the controller version number
ADh sngl disable keyboard (sets bit 4 of commmand byte)
ADh Vectra HP Vectra diagnostic dump
AEh sngl enable keyboard (resets bit 4 of commmand byte)
AFh AWARD Enhanced Command: read keyboard version
AFh AMI set extended controller RAM
write address to PORT 0060h, wait for controller ready, then
write value to PORT 0060h
B1h AMI set keyboard controller P11 line low
B2h AMI set keyboard controller P12 line low
B3h AMI set keyboard controller P13 line low
B4h AMI set keyboard controller P22 line low
B5h AMI set keyboard controller P23 line low
B8h AMI set keyboard controller P10 line high
B9h AMI set keyboard controller P11 line high
BAh AMI set keyboard controller P12 line high
BBh AMI set keyboard controller P13 line high
BCh AMI set keyboard controller P22 line high
BDh AMI set keyboard controller P23 line high
C0h read read input port and place on PORT 0060h
bit 7 keyboard NOT locked
bit 6 =0 first video is CGA
=1 first video is MDA
bit 5 =0 factory testmode
=1 normal
bit 4 =0 256KB RAM, 1=512KB
bit 5,3-0 are used in Intel chipset 386sx machines with
AMI/Phoenix BIOSes for BIOS specific hardware settings
bit 2 (MCA) no keyboard power
bit 1 (MCA) current mouse serial data input state
bit 0 (MCA) current keyboard serial input state
C0h Compaq places status of input port in output buffer. Use this
command only when the output buffer is empty
C1h MCA Enhanced Command: poll input port Low nibble, continuously
place in PORT 0064h bits 7-4 until next command
C2h MCA Enhanced Command: poll input port High nibble, continuously
place in PORT 0064h bits 7-4 until next command
C8h AMI unblock keyboard controller lines P22 and P23
C9h AMI block keyboard controller lines P22 and P23
CAh AMI read keyboard mode, return in 0060 bit 0
(bit clear if ISA mode, set if PS/2 mode)
CBh AMI set keyboard mode (write back mode byte returned by CAh,
modifying only bit 0)
CCh AMI ??? (used by AMI BIOS v1.00.12.AX1T APM code)
D0h read read output port and place on PORT 0060h (see #P0405)
D0h Compaq places byte in output port in output buffer. Use this command
only when the output buffer is empty
D1h double write output port. The next byte written to PORT 0060h will
be written to the 804x output port; the original IBM AT and
many compatibles such as the OPTi 82C392 use bit 1 of the
output port to control the A20 gate.
Important: bit 0 (system reset) should always be set here, as
the system may hang constantly; use pulse output port
(FEh) instead.
D1h Compaq the system speed bits are not set by this command use
commands A1-A6 (!) for speed functions.
D2h MCA Enhanced Command: write keyboard output buffer
D3h MCA Enhanced Command: write pointing device out.buf.
D4h MCA write to mouse/pointing device instead of to keyboard;
this controller command must precede every PORT 0060h command
directed to the mouse, otherwise it will be sent to the keyboard
D4h AWARD Enhanced Command: write to auxiliary device
DDh sngl disable address line A20 (HP Vectra only???)
default in Real Mode
DFh sngl enable address line A20 (HP Vectra only???)
E0h read read test inputs, and place in PORT 0060h
bit0 = kbd clock, bit1 = kbd data
Exxx AWARD Enhanced Command: active output port
E5h GoldStar set turbo LED color to yellow (turbo off)
E7h GoldStar set turbo LED color to yellow (turbo off)
E8h GoldStar set turbo LED color to green (turbo on)
EAh GoldStar set turbo LED color to green (turbo on)
EDh double this is a two part command to control the state of the
NumLock, CpasLock and ScrollLock LEDs
The second byte contains the state to set LEDs.
bit 7-3 reserved. should be set to 0.
bit 2 = 0 Caps Lock LED off
bit 1 = 0 Num Lock LED off
bit 0 = 0 Scroll Lock LED off
F0-FF sngl pulse output port low for 6 microseconds.
bits 0-3 contain the mask for the bits to be pulsed. A bit is
pulsed if its mask bit is zero
bit0=system reset. Don't set to zero. Pulse only!
Note: keyboard controllers are widely different from each other. You
cannot generally exchange them between different machines.
(Award) Derived from Award's Enhanced KB controller advertising sheet.
(Compaq) Derived from the Compaq Deskpro 386 Tech. Ref. Guide.
<eof>