home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Unsorted BBS Collection
/
thegreatunsorted.tar
/
thegreatunsorted
/
programming
/
misc_programming
/
mouse
< prev
next >
Wrap
Text File
|
1990-01-04
|
10KB
|
278 lines
Chapter 6
MOUSE Services Routine
----------------------
1. Introduction
For system which supports the MOUSE, the ROM BIOS contains two mouse-
related services, a PD ISR and a PD DSR (see Figure 1-1):
* PD ISR
The BIOS PD Interrupt Service Routine (ISR) is invoked via H/W INT
74h each time the mouse is moved or the mouse button is pressed
while the mouse is enabled.
PD ISR stores the PD data temporarily in the PD buffer, when it
accummulates the PD data to reach the package size, it will pass a
package of PD data through the system stack to the mouse driver.
* PD DSR
The BIOS PD Device Service Routine (DSR) is invoked via S/W INT 15h,
AH=0C2h. It is different from the keyboard DSR. PD DSR provides
some functions to initialize mouse, enable/disable mouse, set the
mouse configurations such as sample rate, resolution ..., and so on,
but it doesn't provide users access to the PD data.
<── H/W ──>│<──── BIOS Level ────────>│<───── User's Level ────────────>
Level
PD H/W ┌────────┐ ┌────────┐ ┌────────┐
Interrupt │ ├───────────────>│ System ├──────>│ MOUSE ├──> MOUSE
(IRQ 12) │ PD ISR │ ┌───────────┐│ Stack │ │ Driver │ AP
┌────────>│ │<─>│ PD buffer │└────────┘ └────┬───┘
│ │ INT 74h│ └───────────┘ │
│ │ │ ┌───────────┐ │
│ │ │<─>│ PD flags │ │
┌─┴──┐ └────────┘ ┌>└───────────┘ │
│ PD │<┐ │ Extended │
└────┘ │ │ BIOS Data │
│ ┌────────┐ │ │
│ │ ├─┘ │
│ │ PD DSR │ │
└────┤ │ │
│ INT 15h│<─────────────────────────────────────┘
│ AH=0C2h│
│ │
└────────┘
Figure 1-1. The roles of the PD ISR and PD DSR
----------------------------------------------
2. PD ISR (INT 74h) Operation
2.1 PD H/W Architecture
Please refer to Keyboard Services (Figure 2-1) for PD H/W
architecture. It must use the keyboard controller 8042 to support
the PS/2 MOUSE.
2.2 PD Data
The data structure that PD ISR passes onto the device driver is
called "package". Normally, one package contains 3 bytes as shown:
1st byte - status
bit 0 - left button status
- 1 : pressed
bit 1 - right button status
- 1 : pressed
bit 2 - reserved (must be 0)
bit 3 - reserved (must be 1)
bit 4 - X data sign
- 1 negative
bit 5 - Y data sign
- 1 negative
bit 6 - X data overflow
- 1 overflow
bit 7 - Y data overflow
- 1 overflow
2nd byte - X data
bit 0 - least significant bit
bit 7 - most significant bit
3rd byte - Y data
bit 0 - least significant bit
bit 7 - most significant bit
2.3 PD ISR Processing
The PD ISR simply collects one package of the PD data in PD buffer,
and maintains the PD flags. PD buffer and PD flags are all in the
extended BIOS data area as shown:
022h device drive far call offset
024h device drive far call segment
026h pointing device flag
bit 7 -- command in progress
bit 6 -- resend
bit 5 -- acknowledge
bit 4 -- error
bit 3 -- reserved = 0
bit 2-0 -- index count of input data
027h pointing device flag
bit 7 -- device drive far call flag
bit 6 -- Pointer device interface initialization ok
bit 5-3 -- reserved
bit 2-0 -- package size
028h-02Fh Pointing device buffer
When PD ISR collects the PD data to reach the package size, it will
pass a package of PD data through the system stack to the mouse
driver.
3. PD DSR (INT 15h, AH=0C2h) Operation
PD DSR initializes the mouse to function as follows:
For all functions of the pointing device, the output is as follows:
(cy) = 0 -- operation successfully completed
= 1 -- unsuccesful operation
(ah) = status
00 - no error
01 - invalid function call
02 - invalid function input
03 - error
04 - reserved
05 - no far call installed
06 - reserved
ENABLE OR DISABLE POINTING DEVICE
input:
(ah) = c2h
(al) = 0
(bh) = 0 disable the pointing device
= 1 enable the pointing device
> 1 Invalid function call
output: See the note as described above.
RESET POINTING DEVICE
input:
(ah) = c2h
(al) = 1
output: See the note as described above.
bx = device ID if operation is successful
Notes:
After reset, the pointing device situation is
described as follows:
- It is disabled unless the flag of pointing device
interface initialization is set.
- Sample rate at 100 reports/sec
- Resolution at 4 counts/millimeter
- Scaling at 1 to 1
- Package size remain unchanged
SET SAMPLE RATE
input:
(ah) = c2h
(al) = 2
(bh) = rate value
= 0 - 10 reports/sec
= 1 - 20 reports/sec
= 2 - 40 reports/sec
= 3 - 60 reports/sec
= 4 - 80 reports/sec
= 5 -100 reports/sec
= 6 -200 reports/sec
> 6 -Invalid input
output: See the note as described above.
SET RESOLUTION
input:
(ah) = c2h
(al) = 3
(bh) - resolution value
= 0 - 1 count /mm
= 1 - 2 counts/mm
= 2 - 4 counts/mm
= 3 - 8 counts/mm
> 3 - Invalid input
output: See the note as described above.
READ DEVICE TYPE
input:
(ah) = c2h
(al) = 4
output: See the note as described above.
If operation is successfully completed then
(bh) = device ID
INITIALIZATION
input:
(ah) = c2h
(al) = 5
(bh) - data package size
= 1 - 1 byte
= 2 - 2 bytes
= 3 - 3 bytes
= 4 - 4 bytes
= 5 - 5 bytes
= 6 - 6 bytes
= 7 - 7 bytes
= 8 - 8 bytes
> 8 - Invalid input
output: See the note as described above.
The pointing device state is as follows:
. Disabled
. Sample rate at 100 reports/sec
. Resolution at 4 counts/millimeter
. Scaling at 1 to 1
EXTENDED COMMAND
input:
(ah) = c2h
(al) = 6
(bh) = 0 return status
output: See the note as described above.
If operation is successfully completed then
(bl) - status byte 1
bit 7 = 0 - reserved
bit 6 = 0 - stream mode
= 1 - remote mode
bit 5 = 1 - pointer enable
bit 4 = 0 - 1:1 scaling
= 1 - 2:1 scaling
bit 3 = 0 - reserved
bit 2 = 1 - left butten pressed
bit 1 = 0 - reserved
bit 0 = 1 - right butten pressed
(cl) - status byte 2
00 - 1 count /mm
01 - 2 counts/mm
02 - 4 counts/mm
03 - 8 counts/mm
(dl) - status byte 3
0a - 10 reports/sec
14 - 20 reports/sec
2b - 40 reports/sec
3c - 60 reports/sec
50 - 80 reports/sec
64 -100 reports/sec
c8 -200 reports/sec
input:
(ah) = c2h
(al) = 6
(bh) = 1 set scaling to 1:1
output: See the note as described above.
input:
(ah) = c2h
(al) = 6
(bh) = 2 set scaling to 2:1
output: See the note as described above.
input:
(ah) = c2h
(al) = 6
(bh) > 2 Illegal function call
output: See the note as described above.
DEVICE DRIVER FAR CALL
input:
(ah) = c2h
(al) = 7
(es) = segment pointer
(bx) = offset pointer
output:
none