Commit 6b2121fb authored by Neil Turton's avatar Neil Turton
Browse files

Import from cleaned 360 CD

s/** gitlab-language=armasm linguist-language=armasm linguist-detectable=true
SOFTWARE FUNCTIONAL SPECIFICATION
=================================
PS/2 Driver Module for Risc OS Black
------------------------------------
Drawing No: 1303,003/FS
Issue: 0.04
Author: R.C.Manby
Date: 16th June 1994
Last Issue: 0.03
________________________________________________________________________________
1. History
----------
Version Date Notes
0.01 12-04-94 Initial draft
0.02 5-05-94 Added reference to trackerball in section 3.
Added module size target to section 11.
0.03 16-05-94 Changes prompted by FS review:
Added outstanding issues:
2.1 Check trackerball and mouse data formats are
identical.
2.2 Check mouse/keyboard plug use on Kryten.
Added 12. Development Test Strategy
Added 13. Product Organisation
0.04 16-06-94 Added keyboard driver to allow device swapping for Stork
and allow Kryten user to plug mouse & keyboard into wrong
sockets.
2. Outstanding Issues
---------------------
2.1 Check that the proposed trackerball returns data in the same format as the
PS/2 mouse.
3. Product Overview
-------------------
The PS/2 driver module for RISC OS Black is to provide support for an IBM PS/2
mouse, trackerball and keyboard on an IOMD or MORRIS based platform (eg Medusa,
Kryton or Stork).
4. Concepts & Definitions
-------------------------
A PS/2 port is a bi-directional serial interface. It allows commands to be sent
to a device such as a keyboard or mouse and allows the device to return data.
The commands sent include RESET and SET SAMPLING RATE. The returned data
includes key codes (keyboard) or position reports (mouse).
The IOMD chip contains one PS/2 bi-directional serial interface intended for
use as a keyboard port.
The MORRIS chip contains two identical PS/2 bi-directional serial interfaces,
one intended for use as a keyboard port, the other for use as a mouse port.
Medusa uses the IOMD chip and uses its PS/2 interface for the keyboard.
Kryten uses the MORRIS chip. Although its PS/2 ports are labelled, the fact
that the connectors are identical will mean that some users will swap mouse and
keyboard plugs either by accident or on purpose. It is a requirement of the
Kryten project that this should work.
Stork uses the MORRIS chip. Stork uses the MORRIS 'mouse' port for connection
to an internal trackerball. The 'keyboard' port goes to an external connector
intended for use by either a keyboard or a mouse. Storks internal keyboard is
handled by the keyboard/battery-manager microcontroller. This microcontroller
communicates battery status and keyboard codes via a memory mapped parallel
interface into the Portable module. The keyboard protocol is the same as a
normal PS/2 keyboard and is routed by the portable module into the PS/2 driver.
The existing Medusa OS has a mechanism for installing mouse drivers (drivers
for quadrature and two types of serial mouse already exist) and keyboard
drivers, into which this combined keyboard/mouse driver must fit
(see 0197,257/FS Jordan Keyboard/Mouse/Serial Mouse Software Functional
Specification).
5. User Interface
-----------------
The type of device connected to each port will be determined at module start
time and the appropriate driver code selected then. A hot key will be provided
on the Stork internal keyboard to allow the 'external port' to be reset when
an external keyboard is replaced by an external mouse or vice-versa.
The PS/2 mouse can be selected from the command line by typing
*configure MouseType 3
or from the desktop using !Configure.
When !Configure's Mouse configuration window is opened, all the mouse drivers
are asked to return type and name information for the mice that they support.
This enables !Configure to construct a menu of all the available mouse drivers,
from which the user can select.
6. Programmer Interface
-----------------------
A new module, PS2Driver, will be developed which will drive PS/2 keyboards or
PS/2 mice/trackerballs connected to the interfaces provided by IOMD and MORRIS.
The module will adhere to the same interfaces as the PS/2 keyboard, quadrature
mouse and serial mouse modules written for Medusa (see 0197,257/FS Jordan
Keyboard/Mouse/Serial Mouse Software Functional Specification).
On initialisation this module will claim vector KEYV and PointerV and then
reset all available PS/2 ports. As each device responds (under interrupt), the
driver will determine its type and hence select the appropriate internal
driver code.
The keyboard.
Once the keyboard has completed its self-test, the driver calls KEYV with reason
code 0 (keyboard present), passing a keyboard id of 2 (PC-AT keyboard).
The driver does not pass key events to the Kernel until explicitly enabled
by being sent (via KVEC) reason code 4 (keyboard enable).
For a fuller description of KEYV reason codes, see 0197,257/FS Jordan Keyboard/
Mouse/Serial Mouse Software Functional Specification.
The mouse.
This code will intercept PointerV and respond to requests for device type 3
(PS/2 mouse).
Mouse movements, received as 3 byte packets, under interrupt, will be
amalgamated until PointerV is called with reason code 0 (request pointer
device state) at which time a report will be returned to the kernel.
The device driver will call KEYV to notify the system of changes in button
state.
7. Standards
------------
The code is assembled with !ObjAsm.
8. Data Interchange
-------------------
There are no data interchange formats defined by this project.
9. Data Formats
---------------
A PS/2 mouse sends position and mouse button data as 3 byte packets, in the
following format.
Byte 1 b0 Left button status 1 = button down
b1 Right button status 1 = button down
b2 Middle button status 1 = button down
b3 always 1
b4 X data sign 1 = negative
b5 Y data sign 1 = negative
b6 X data overflow 1 = overflow
b7 Y data overflow 1 = overflow
Byte 2 b0 LSB of X data combine with sign bit
~ to give a nine bit
b7 MSB of X data 2's complement number
Byte 3 b0 LSB of Y data combine with sign bit
~ to give a nine bit
b7 MSB of Y data 2's complement number
10. External Dependencies
-------------------------
Medusa hardware
MORRIS
Kryten hardware
Stork hardware
Initial development and testing of the module can be done using a PS/2 mouse or
keyboard connected to the PS/2 keyboard port of a Medusa. Final testing must be
performed using a MORRIS chip on Stork or Kryten hardware.
11. Acceptance Test
-------------------
Must function on Medusa, Kryten and Stork hardware.
Servicing the interrupts caused by mouse movements should not cause any
noticable machine slowdown.
The driver should be no larger than 3.5Kbytes (expected to be 3Kbytes).
12. Development Test Strategy
-----------------------------
Testing will take place using samples of all PS2 keyboards and mice that are
likely to be shipped with Medusa, Kryten or Stork machines and with the Stork
trackerball.
Testing will be performed to ensure that the mouse pointer accuratly and
quickly tracks the physical mouse movements and that all keys respond correctly.
Normally the mouse and keyboard will be plugged in when the machine is switched
on, but testing will be performed to show that they can be plugged in after
machine switch on, and unpluged then re-plugged (into the same sockets) at
anytime.
Testing will take place to ensure that on Stork, an external keyboard can be
swapped for an external mouse or vice versa using the 'device reset' hot key.
13. Product Organisation
------------------------
The module will form part of the RISC OS Black OS ROM image.
14. Future Enhancements
-----------------------
\ No newline at end of file
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
# Copyright 1996 Acorn Computers Ltd
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# Makefile for PS2 Driver
#
# ***********************************
# *** C h a n g e L i s t ***
# ***********************************
# Date Name Description
# ---- ---- -----------
# 30-Jun-94 AMcC Created.
#
#
# Generic options:
#
MKDIR = cdir
AS = aasm
CP = copy
RM = remove
CCFLAGS = -c -depend !Depend -IC:
ASFLAGS = -depend !Depend -Stamp -quit -module -To $@ -From
CPFLAGS = ~cfr~v
#
# Program specific options:
#
COMPONENT = PS2Driver
SOURCE = s.GetAll
TARGET = rm.${MACHINE}.PS2Driver
#
# Generic rules:
#
rom: ${TARGET}
@echo ${COMPONENT}: rom module built
export: ${EXPORTS}
@echo ${COMPONENT}: export complete
install_rom: ${TARGET}
${CP} ${TARGET} ${INSTDIR}.${COMPONENT} ${CPFLAGS}
@echo ${COMPONENT}: rom module installed
clean:
${RM} ${TARGET}
@echo ${COMPONENT}: cleaned
resources:
${MKDIR} ${RESDIR}.${COMPONENT}
${CP} Resources.${LOCALE}.Messages ${RESDIR}.${COMPONENT}.Messages ${CPFLAGS}
@echo ${COMPONENT}: resource files copied
${TARGET}: ${SOURCE}
${MKDIR} rm.${MACHINE}
${AS} ${ASFLAGS} ${SOURCE}
# Dynamic dependencies:
| Copyright 1996 Acorn Computers Ltd
|
| Licensed under the Apache License, Version 2.0 (the "License");
| you may not use this file except in compliance with the License.
| You may obtain a copy of the License at
|
| http://www.apache.org/licenses/LICENSE-2.0
|
| Unless required by applicable law or agreed to in writing, software
| distributed under the License is distributed on an "AS IS" BASIS,
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
| See the License for the specific language governing permissions and
| limitations under the License.
|
Dir <Obey$Dir>
amu_machine clean
| Copyright 1996 Acorn Computers Ltd
|
| Licensed under the Apache License, Version 2.0 (the "License");
| you may not use this file except in compliance with the License.
| You may obtain a copy of the License at
|
| http://www.apache.org/licenses/LICENSE-2.0
|
| Unless required by applicable law or agreed to in writing, software
| distributed under the License is distributed on an "AS IS" BASIS,
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
| See the License for the specific language governing permissions and
| limitations under the License.
|
Dir <Obey$Dir>
amu_machine rom
PS2Name:PS2 mouse
; > Version
;---------------------------------------------------------------------------
; Change history.
;
; 21-Mar-94 0.01 RCM Created.
; 24-Aug-94 0.02 RCM Switched off debugging output
; Added delay to ensure reliable mouse
; verses keyboard detection
; 24-Aug-94 0.03 RCM Put 0.02 back because source filer
; got its knickers in a twist and kept an
; out of date version of s.PS2driver
; 16-Sep-94 0.04 SMC Internationalised mouse type record building code properly
; (no longer assumes name string is <= 30 chars).
; Also set international flag to true and open PS2Driver.Messages
; rather than SerMouse.Messages.
; 14-Oct-94 0.05 RCM Support for Stork keyboard.
; 14-Oct-94 0.06 RCM Flag change to assemble for Morris - SecondPort set TRUE.
;
; 02-Nov-94 0.08 RCM Remove debugging hotkey (ie stop AltGr reseting driver).
; 03-Nov-94 0.09 RCM Tidied up a few comments.
; 02-Dec-94 0.10 RCM Add KEYV code to allow interrogation of device type.
; 16-Dec-94 0.11 RCM Altered device identification method to prevent flushing
; of devices internal buffer. Allows poweron-* to work again.
; 13-Jan-95 0.12 RCM Programmed the mouse resolution as 400dpi mouse appears
; to default to 200dpi. Fix MED-04334.
; 30-Jan-95 0.13 RCM Fix slow changing of LEDS problem, ie MED-04488.
; 24-Mar-95 0.14 RCM Fix control key jammed down problem, ie MED-04434.
;
GBLA Version
GBLS VString
GBLS Date
Version SETA 014
VString SETS "0.14"
Date SETS "24 Mar 1995"
END
*
!.gitignore
*
!.gitignore
*
!.gitignore
*
!.gitignore
; Copyright 1996 Acorn Computers Ltd
;
; Licensed under the Apache License, Version 2.0 (the "License");
; you may not use this file except in compliance with the License.
; You may obtain a copy of the License at
;
; http://www.apache.org/licenses/LICENSE-2.0
;
; Unless required by applicable law or agreed to in writing, software
; distributed under the License is distributed on an "AS IS" BASIS,
; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
; See the License for the specific language governing permissions and
; limitations under the License.
;
; > Sources.Front
;-----------------------------------------------------------------------------
; Useful declarations.
;
; Driver state flags.
state_RESET * &01 ; In reset.
state_KEYUP * &02 ; This key is going up.
state_WANTACK * &04 ; Don't send any more until ACK from keyboard.
state_WANTBAT * &08 ; Don't send any more until BAT from keyboard.
state_SPECIAL * &10 ; In special code sequence.
state_BREAK * &20 ; In break code sequence.
; Bytes from keyboard.
keybd_ERROR * &00
keybd_BAT * &AA
keybd_SPECIAL * &E0
keybd_BREAK * &E1
keybd_KEYUP * &F0
keybd_ACK * &FA
keybd_RESEND * &FE
; Keyboard commands.
command_SETLEDS * &ED
command_SETRATE * &F3
command_RESEND * &FE
command_RESET * &FF
command_SETCOUNT * &E8 ;AKA Set Resolution
command_ENABLE * &F4 ; Start transmission if in Incremental Stream mode
command_DISABLE * &F5 ; Stop transmission of mouse position reports
command_DEFAULT * &F6
resend_count * 10 ; Maximum number of resends in sequence.
;-----------------------------------------------------------------------------
; Workspace layout.
;
;PortName
; 1 KBDDAT & KBDCR (may have keyboard OR mouse attached)
; 2 MSEDAT & MSECR (may have mouse OR keyboard attached)
; 3 PSD (pseudo stream through KEYV to Stork internal keyboard)
;
;DeviceType
; 0 Unknown
; 1 Mouse
; 2 Keyboard
;
channel RN R10
^ 0,channel
moduleworkspace # 4 ;pointer to modules workspace ie its R12 value
TxBuffer # 16 ; Circular buffer for commands sent to keyboard.
TxBufferEnd # 0
TxInsert # 4 ; Pointer to position to insert into TxBuffer.
TxPtr # 4 ; Pointer to next byte in TxBuffer to send to keyboard.
PortName # 1
KBState # 1 ; Port state.
ResendCount # 1 ; Remaining resends allowed.
DeviceType # 1 ;
# 3:AND:(-:INDEX:@)
RXStateHandler # 4 ; Address of current state handler.
Byte1 # 1 ; First byte of serial mouse report.
Byte2 # 1 ; Second byte of serial mouse report.
Byte3 # 1 ; Third byte of serial mouse report.
Byte4 # 1 ; Fourth byte of serial mouse report.
# 3:AND:(-:INDEX:@)
channel_ws_size * :INDEX:@
;machine type/channels available
; 1 medusa ie PS2 kbd only
; 2 kryten ie PS2 kbd & PS2 mouse
; 3 stork ie PS2 kbd & PS2 mouse & Keyboard/battery micro
;
workspace RN R12
^ 0,workspace
wsorigin # 0
[ international
message_file_open # 4
message_file_block # 4*4
]
PortCount # 4
KeyState # 1 ; Keyboard driver state.
LEDState # 1 ; Current LED state.
# 3:AND:(-:INDEX:@)
MouseData # 0 ; Mouse data record.
DeltaX # 4 ; X movement since last query from Kernel.
DeltaY # 4 ; Y movement since last query from Kernel.
Buttons # 4 ; Button states.
LastButtons # 1 ; Button states on last poll.
# 3:AND:(-:INDEX:@)
[ KillAutoRepeat
KeyFlags # 16 ; Key up/down flags.
]
[ debugtable
DebugTable # 508
DebugTableEnd # 0
DebugPtr # 4
]
PS2ch1 # channel_ws_size ;KBDDAT & KBDCR (may have keyboard OR mouse attached)
PS2ch2 # channel_ws_size ;MSEDAT & MSECR (may have mouse OR keyboard attached)
PS2ch3 # channel_ws_size
max_running_work * :INDEX:@
! 0, "PS2Driver workspace is ":CC:(:STR:(:INDEX:@)):CC:" bytes"
END
; Copyright 1996 Acorn Computers Ltd
;
; Licensed under the Apache License, Version 2.0 (the "License");
; you may not use this file except in compliance with the License.
; You may obtain a copy of the License at
;
; http://www.apache.org/licenses/LICENSE-2.0
;
; Unless required by applicable law or agreed to in writing, software
; distributed under the License is distributed on an "AS IS" BASIS,
; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
; See the License for the specific language governing permissions and
; limitations under the License.
;
; > Sources.GetAll
;---------------------------------------------------------------------------
; PS2 mouse driver.
;---------------------------------------------------------------------------
Module_BaseAddr
;---------------------------------------------------------------------------
; Get the headers.
;
GET Hdr:ListOpts
GET Hdr:Macros
GET Hdr:System
GET Hdr:Machine.<Machine>
$GetIO
GET Hdr:DevNos
GET Hdr:KEYV
GET Hdr:ModHand
GET Hdr:Services
GET Hdr:MsgTrans
GET Hdr:ResourceFS
GET Hdr:Buffer
GET Hdr:FSNumbers
GET Hdr:CMOS
GET Hdr:HostFS
GET Hdr:NdrDebug
GET Hdr:DDVMacros
GET Hdr:Proc
GET Hdr:Pointer
GET Hdr:Debug
GET Hdr:Portable
GET Version
;---------------------------------------------------------------------------
; Define global variables.
;
; GBLL IOMD
;IOMD SETL {TRUE}
GBLL TMLDebug
GBLL hostvdu
TMLDebug SETL false ;true ;>>>false
debug SETL false ;true ;>>>false
hostvdu SETL false
mod SETD false
key SETD false
int SETD false
drv SETD false
table SETD false
GBLL standalone
standalone SETL false
GBLL international
international SETL true
GBLL CheckForKeyboard
CheckForKeyboard SETL true
GBLL KillAutoRepeat
KillAutoRepeat SETL true
GBLL SecondPort
SecondPort SETL true
GBLL PortInfo
PortInfo SETL true
GBLL SetMouseStep
SetMouseStep SETL true
GBLL Fix_MED_04434
Fix_MED_04434 SETL true
;---------------------------------------------------------------------------
; Get the sources.
;
GBLS GetResFiles
[ standalone
GetResFiles SETS "GET s.ResFiles"
|
GetResFiles SETS ""
]
GET s.Front
GET s.Macros
GET s.ModHead
$GetResFiles
GET s.PS2Driver
;GET s.Driver
GET s.Tail
END
; Copyright 1996 Acorn Computers Ltd
;
; Licensed under the Apache License, Version 2.0 (the "License");
; you may not use this file except in compliance with the License.
; You may obtain a copy of the License at
;
; http://www.apache.org/licenses/LICENSE-2.0
;
; Unless required by applicable law or agreed to in writing, software
; distributed under the License is distributed on an "AS IS" BASIS,
; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
; See the License for the specific language governing permissions and
; limitations under the License.
;
; > Sources.Macros
;-----------------------------------------------------------------------------
; IRQOff $reg
;
; Turn IRQs off and save the PSR in $reg.
;
MACRO
$label IRQOff $reg
$label MOV $reg, pc
TST $reg, #I_bit
TEQEQP $reg, #I_bit
MEND
;-----------------------------------------------------------------------------
; SetPSR $reg
;
; Set the PSR from bits in $reg (normally saved by IRQOff or FIQOff).
;
MACRO
$label SetPSR $reg
$label TEQP $reg, #0
MEND
;-----------------------------------------------------------------------------
; SVCMode $reg
;
; Set SVC mode with IRQs disabled saving PSR in $reg.
;
MACRO
$label SVCMode $reg
$label MOV $reg, pc
TEQP pc, #SVC_mode
MEND
;-----------------------------------------------------------------------------
; IOMDBase $reg
;
; Set $reg to IOMD base address.
;
MACRO
$label IOMDBase $reg,$cc
[ IO_Type = "IOMD"
$label MOV$cc $reg, #IOMD_Base
|
$label MOV$cc $reg, #&03000000
ADD$cc $reg, $reg, #&8000
SUB$cc $reg, $reg, #4
]
MEND
;-----------------------------------------------------------------------------
; KbdEnable
;
; Enable keyboard state machine.
;
MACRO
$label KbdEnable $ra,$rb,$cc
$label IOMDBase $ra,$cc
MOV$cc $rb, #IOMD_KBDCR_Enable
STR$cc.B $rb, [$ra, #IOMD_KBDCR]
MEND
;-----------------------------------------------------------------------------
; KbdDisable
;
; Disable keyboard state machine.
;
MACRO
$label KbdDisable $ra,$rb,$cc
$label IOMDBase $ra,$cc
MOV$cc $rb, #0
STR$cc.B $rb, [$ra, #IOMD_KBDCR]
MEND
;-----------------------------------------------------------------------------
; KbdRxOffTxOff
;
; Disable RX irqs, disable TX irqs.
;
MACRO
$label KbdRxOffTxOff $ra,$rb,$cc
$label IOMDBase $ra,$cc
[ IO_Type = "IOMD"
LDR$cc.B $rb, [$ra, #IOCIRQMSKB]
BIC$cc $rb, $rb, #serial_Rx_bit + serial_Tx_bit
STR$cc.B $rb, [$ra, #IOCIRQMSKB]
|
MOV$cc $rb, #IOMD_KBDCR_Enable
STR$cc.B $rb, [$ra, #IOMD_KBDCR]
]
MEND
;-----------------------------------------------------------------------------
; KbdRxOnTxOff
;
; Enable RX irqs, disable TX irqs.
;
MACRO
$label KbdRxOnTxOff $ra,$rb,$cc
$label IOMDBase $ra,$cc
[ IO_Type = "IOMD"
LDR$cc.B $rb, [$ra, #IOCIRQMSKB]
ORR$cc $rb, $rb, #serial_Rx_bit
BIC$cc $rb, $rb, #serial_Tx_bit
STR$cc.B $rb, [$ra, #IOCIRQMSKB]
|
MOV$cc $rb, #IOMD_KBDCR_Enable + &80
STR$cc.B $rb, [$ra, #IOMD_KBDCR]
]
MEND
;-----------------------------------------------------------------------------
; KbdRxOffTxOn
;
; Enable TX irqs, disable RX irqs.
;
MACRO
$label KbdRxOffTxOn $ra,$rb,$cc
$label IOMDBase $ra,$cc
[ IO_Type = "IOMD"
LDR$cc.B $rb, [$ra, #IOCIRQMSKB]
ORR$cc $rb, $rb, #serial_Tx_bit
BIC$cc $rb, $rb, #serial_Rx_bit
STR$cc.B $rb, [$ra, #IOCIRQMSKB]
|
Push "r0-r3,r11",$cc
BL$cc TXIRQHandler
Pull "r0-r3,r11",$cc
]
MEND
;-----------------------------------------------------------------------------
; MseEnable
;
; Enable mouse state machine.
;
MACRO
$label MseEnable $ra,$rb,$cc
$label IOMDBase $ra,$cc
MOV$cc $rb, #IOMD_MSECR_Enable
STR$cc.B $rb, [$ra, #IOMD_MSECR]
MEND
;-----------------------------------------------------------------------------
; MseDisable
;
; Disable mouse state machine.
;
MACRO
$label MseDisable $ra,$rb,$cc
$label IOMDBase $ra,$cc
MOV$cc $rb, #0
STR$cc.B $rb, [$ra, #IOMD_MSECR]
MEND
;-----------------------------------------------------------------------------
; MseRxOffTxOff
;
; Disable mouse RX irqs, disable mouse TX irqs.
;
MACRO
$label MseRxOffTxOff $ra,$rb,$cc
$label IOMDBase $ra,$cc
LDR$cc.B $rb, [$ra, #IOMD_IRQMSKD]
BIC$cc $rb, $rb, #IOMD_MouseRxFull_IRQ_bit + IOMD_MouseTxEmpty_IRQ_bit
STR$cc.B $rb, [$ra, #IOMD_IRQMSKD]
MEND
;-----------------------------------------------------------------------------
; MseRxOnTxOff
;
; Enable mouse RX irqs, disable mouse TX irqs.
;
MACRO
$label MseRxOnTxOff $ra,$rb,$cc
$label IOMDBase $ra,$cc
LDR$cc.B $rb, [$ra, #IOMD_IRQMSKD]
ORR$cc $rb, $rb, #IOMD_MouseRxFull_IRQ_bit
BIC$cc $rb, $rb, #IOMD_MouseTxEmpty_IRQ_bit
STR$cc.B $rb, [$ra, #IOMD_IRQMSKD]
MEND
;-----------------------------------------------------------------------------
; MseRxOffTxOn
;
; Enable mouse TX irqs, disable mouse RX irqs.
;
MACRO
$label MseRxOffTxOn $ra,$rb,$cc
$label IOMDBase $ra,$cc
LDR$cc.B $rb, [$ra, #IOMD_IRQMSKD]
ORR$cc $rb, $rb, #IOMD_MouseTxEmpty_IRQ_bit
BIC$cc $rb, $rb, #IOMD_MouseRxFull_IRQ_bit
STR$cc.B $rb, [$ra, #IOMD_IRQMSKD]
MEND
;-----------------------------------------------------------------------------
; PsdEnable
; Enable pseudo PS/2 port
;
MACRO
$label PsdEnable $cc
$label MOV$cc r0, #KEYV_PseudoEnable
MOV$cc r1, channel
MOV$cc r9, #KEYV
SWI$cc XOS_CallAVector
MEND
;-----------------------------------------------------------------------------
; PsdDisable
; Disable pseudo PS/2 port
;
MACRO
$label PsdDisable $cc
$label MOV$cc r0, #KEYV_PseudoDisable
MOV$cc r1, channel
MOV$cc r9, #KEYV
SWI$cc XOS_CallAVector
MEND
;-----------------------------------------------------------------------------
; PsdRxOffTxOff
;
; Disable pseudo RX irqs, disable pseudo TX irqs.
;
MACRO
$label PsdRxOffTxOff $cc
$label MOV$cc r0, #KEYV_PseudoIntMask
MOV$cc r1, #2_00
MOV$cc r9, #KEYV
SWI$cc XOS_CallAVector
MEND
;-----------------------------------------------------------------------------
; PsdRxOnTxOff
;
; Enable pseudo RX irqs, disable pseudo TX irqs.
;
MACRO
$label PsdRxOnTxOff $cc
$label MOV$cc r0, #KEYV_PseudoIntMask
MOV$cc r1, #2_01
MOV$cc r9, #KEYV
SWI$cc XOS_CallAVector
MEND
;-----------------------------------------------------------------------------
; PsdRxOffTxOn
;
; Enable pseudo TX irqs, disable pseudo RX irqs.
;
MACRO
$label PsdRxOffTxOn $cc
$label MOV$cc r0, #KEYV_PseudoIntMask
MOV$cc r1, #2_10
MOV$cc r9, #KEYV
SWI$cc XOS_CallAVector
MEND
;-----------------------------------------------------------------------------
MACRO
$label DebugTabInit $nil,$wk1,$wk2
$label
[ debugtable
ADR $wk1, DebugTable
STR $wk1, DebugPtr
ADR $wk2, DebugTableEnd
$label.clr
CMP $wk1, $wk2
STRCC $nil, [$wk2, #-4]!
BCC $label.clr
]
MEND
MACRO
$label DebugTab $wk1,$wk2,$v1,$v2,$v3
$label
[ debugtable
LDR $wk1, DebugPtr
[ "$v1" <> ""
ADR $wk2, DebugTableEnd
TEQ $wk1, $wk2
ADREQ $wk1, DebugTable
MOV $wk2, $v1
STRB $wk2, [$wk1], #1
]
[ "$v2" <> ""
ADR $wk2, DebugTableEnd
TEQ $wk1, $wk2
ADREQ $wk1, DebugTable
MOV $wk2, $v2
STRB $wk2, [$wk1], #1
]
[ "$v3" <> ""
ADR $wk2, DebugTableEnd
TEQ $wk1, $wk2
ADREQ $wk1, DebugTable
MOV $wk2, $v3
STRB $wk2, [$wk1], #1
]
STR $wk1, DebugPtr
]
MEND
END
; Copyright 1996 Acorn Computers Ltd
;
; Licensed under the Apache License, Version 2.0 (the "License");
; you may not use this file except in compliance with the License.
; You may obtain a copy of the License at
;
; http://www.apache.org/licenses/LICENSE-2.0
;
; Unless required by applicable law or agreed to in writing, software
; distributed under the License is distributed on an "AS IS" BASIS,
; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
; See the License for the specific language governing permissions and
; limitations under the License.
;
; > Sources.ModHead
LEADR Module_LoadAddr
ASSERT (.=Module_BaseAddr)
DCD 0 ; Start
DCD Init - Module_BaseAddr
DCD Die - Module_BaseAddr
DCD Service - Module_BaseAddr
DCD Title - Module_BaseAddr
DCD Helpstr - Module_BaseAddr
DCD 0 ; Helptable
DCD 0 ; SWIbase
DCD 0 ; SWIhandler
DCD 0 ; SWInames
DCD 0 ; SWIdecode
DCD 0
DCD 0
;---------------------------------------------------------------------------
Title DCB "PS2Driver",0
Helpstr DCB "PS2Driver",9,"$VString ($Date)",0
ALIGN
;---------------------------------------------------------------------------
; Module initialisation point.
;
; May corrupt R0-R6,R12,R14, must preserve R7-R11,R13
;
Init
ENTRY
;
; Check machine type
;
MOV r0, #2 ;Check main hardware details
SWI XOS_ReadSysInfo
EXIT VS
;R0 bits 8..15 give I/O control chip type
AND r0, r0, #&0000FF00 ; 0=IOC, 1=IOMD
TEQ r0, #&00000100 ; must have IOMD
BNE %FT99
;
; Hardware OK
;
LDR r2, [r12] ; Have we already some workspace?
CMP r2, #0
BNE %FT01
MOV r0, #6
LDR r3, =max_running_work
SWI XOS_Module ; Claim workspace.
EXIT VS
STR r2, [r12] ; Store workspace pointer.
01
MOV r12, r2
[ TMLDebug
InsertTMLInitialisation 0 ;my TML card uses podule slot 0
]
;DLINE "PS2 driver module initialisation"
[ standalone
ADR r0, resourcefsfiles
SWI XResourceFS_RegisterFiles
]
MOV r0, #0 ;Initialise workspace.
[ international
STR r0, message_file_open
]
[ 1 = 1
SWI XPortable_ReadFeatures ;If this call works,
MOVVC r0, #3 ; assume we're running on a Stork - don't ask
BVC %FT20 ; ReadSysInf0(2), cos we communicate via Portable module
MOV r1, #IOMD_Base
LDRB r0, [r1, #IOMD_ID0]
CMP r0, #&98
LDRB r0, [r1, #IOMD_ID1]
CMPEQ r0, #&5B
MOVEQ r0, #2 ;Morris based
MOVNE r0, #1 ;else assume IOMD
20
|
MOV r0, #1 ;Hardwire Medusa
]
STR r0, PortCount
BL StartUp
BLVS ShutDown
EXIT
;
;Wrong hardware for PS2Driver module
;
99
EXIT
;---------------------------------------------------------------------------
; Start up code.
;
StartUp
ENTRY "r0,r1,r2,channel"
Debug mod,"SM_StartUp"
;DLINE "PS2Driver: StartUp"
BL ClaimVectors
BLVC KeyInit
BLVC MouseInit
MOV r0, #3
ADR channel, PS2ch3 ;R10 points to channel workspace
BLVC StreamInit
MOV r0, #2
ADR channel, PS2ch2 ;R10 points to channel workspace
BLVC StreamInit
MOV r0, #1
ADR channel, PS2ch1 ;R10 points to channel workspace
BLVC StreamInit
[ true
LDR r1, PortCount
CMP r1, #2
BEQ %FT10
BLT %FT20
ADRVC channel, PS2ch3 ;R10 points to channel workspace
BLVC StreamEnable
10
[ SecondPort
ADRVC channel, PS2ch2 ;R10 points to channel workspace
BLVC StreamEnable
]
20
ADRVC channel, PS2ch1 ;R10 points to channel workspace
BLVC StreamEnable
|
;>>>for testing
ADRVC channel, PS2ch1 ;R10 points to channel workspace
BLVC StreamEnable
ADRVC channel, PS2ch3 ;R10 points to channel workspace
BLVC StreamEnable
]
MOVVC r0, #0 ; Get current pointer type.
SWIVC XOS_Pointer
MOVVC r1, r0
BLVC PointerSelected ; Enable if one of ours.
EXIT
;---------------------------------------------------------------------------
; Service handler.
;
Service
LDR r12, [r12]
TEQ r1, #Service_Reset
BEQ StartUp
[ standalone
TEQ r1, #Service_ResourceFSStarting
MOVNES pc, lr
ENTRY "r0-r3"
ADR r0, resourcefsfiles
MOV lr, pc
MOV pc, r2
EXITS
|
MOVS pc, lr
]
;---------------------------------------------------------------------------
; Sit on KEYV for enable call and so that LEDs can be set.
;
KeyVec
;TEQ r0, #2 ;KeyDown
;BEQ keyv_checkhotkeys
TEQ r0, #3
BEQ keyv_setleds
TEQ r0, #KEYV_PseudoRXInt
BEQ keyv_pseudoRXint
TEQ r0, #KEYV_PseudoTXInt
BEQ keyv_pseudoTXint
[ PortInfo
TEQ r0, #KEYV_PortInfo
BEQ keyv_portinfo
]
TEQ r0, #4
MOVNES pc, lr
keyv_init
[ debugtable
ENTRY "r0"
DebugTab r0,lr,#&81
|
ENTRY
]
IRQOff lr
[ KillAutoRepeat
BL ClearKbd
]
LDRB lr, KeyState ; Safe to start sending keys.
BIC lr, lr, #state_RESET
STRB lr, KeyState
EXITS
;keyv_checkhotkeys
; ;ENTRY
; ;;DREG r1, "KEYV key down &",,LongWord
; ;EXIT
;
; TEQ r1, #&60 ;Check for 'Reset Stork external Keyboard' hotkey
; MOVNES pc, lr
;
; ENTRY "channel"
; ADR channel, PS2ch1
; BL SendRESET ;An asynchronous call
; EXITS
keyv_setleds
[ debugtable
ENTRY "r1,r2,channel"
DebugTab r2,lr,#&82
|
ENTRY "r1,channel"
]
MOV lr, r1
TST lr, #4 ; Swap bits 0 and 2.
BICEQ r1, r1, #1
ORRNE r1, r1, #1
TST lr, #1
BICEQ r1, r1, #4
ORRNE r1, r1, #4
STRB r1, LEDState
ADR channel, PS2ch1 ;
BL SetLEDs ;checks device type
ADR channel, PS2ch2
BL SetLEDs
ADR channel, PS2ch3
BL SetLEDs
EXITS
[ PortInfo
;---------------------------------------------------------------------------
;
keyv_portinfo
ENTRY "R3, channel"
CMP r1, #1
LDRGE r5, PortCount
CMPGE r5, r1
EXITS LT
CMP r1, #2
ADRLT channel, PS2ch1
ADREQ channel, PS2ch2
ADRGT channel, PS2ch3
LDRB r2, DeviceType
EXITS
]
;---------------------------------------------------------------------------
; Killing the module.
;
Die
ENTRY
LDR r12, [r12]
CMP r12, #0
Pull "pc",EQ,^
BL ShutDown
EXITS
;---------------------------------------------------------------------------
; Tidy up before dying.
; out: preserves all registers and flags.
;
ShutDown
ENTRY "r0-r2,r9"
Debug mod,"SM_ShutDown"
BL ReleaseVectors ; Don't want to be enabled/get LEDs any more.
;
; Must disable (Medusa) Kbd
; (Kryten) Mse & Kbd
; (Stork) Psd, Mse & Kbd
;
LDR r1, PortCount
CMP r1, #2
BEQ %FT10
BLT %FT20
PsdDisable ;corrupts R0,R1,R9
10
[ SecondPort
MseDisable r0,r1
]
20
KbdDisable r0,r1
;>>>test for kbd active???
MOV r0, #0
SWI XOS_InstallKeyHandler
SWI XOS_InstallKeyHandler ; Reinstall current key handler to clear keys down.
;>>>
[ international
LDR r0, message_file_open ; Close the message file if it's open.
TEQ r0, #0
ADRNE r0, message_file_block
SWINE XMessageTrans_CloseFile
]
[ standalone
ADR r0, resourcefsfiles
SWI XResourceFS_DeregisterFiles
]
EXITS ; Ignore errors, preserve flags.
END
This diff is collapsed.
; Copyright 1996 Acorn Computers Ltd
;
; Licensed under the Apache License, Version 2.0 (the "License");
; you may not use this file except in compliance with the License.
; You may obtain a copy of the License at
;
; http://www.apache.org/licenses/LICENSE-2.0
;
; Unless required by applicable law or agreed to in writing, software
; distributed under the License is distributed on an "AS IS" BASIS,
; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
; See the License for the specific language governing permissions and
; limitations under the License.
;
; > Sources.ResFiles
resourcefsfiles
ResourceFile Resources.<Locale>.Messages, Resources.PS2Driver.Messages
DCD 0
END
; Copyright 1996 Acorn Computers Ltd
;
; Licensed under the Apache License, Version 2.0 (the "License");
; you may not use this file except in compliance with the License.
; You may obtain a copy of the License at
;
; http://www.apache.org/licenses/LICENSE-2.0
;
; Unless required by applicable law or agreed to in writing, software
; distributed under the License is distributed on an "AS IS" BASIS,
; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
; See the License for the specific language governing permissions and
; limitations under the License.
;
; > Sources.Tail
[ international
;---------------------------------------------------------------------------
; MsgTrans_OpenFile
;
; Open our messages file.
;
MsgTrans_OpenFile
ENTRY "r0-r2"
ADR r0, message_file_block
ADR r1, message_filename
MOV r2, #0
SWI XMessageTrans_OpenFile
MOVVC r0, #-1
STRVC r0, message_file_open
STRVS r0, [sp]
EXIT
;---------------------------------------------------------------------------
; MsgTrans_Lookup
; In: r1 -> token
; r2 -> buffer
; r3 = buffer size
; r4-r7 -> optional parameters
; Out: r0,r1 corrupted
; r2 -> result string
; r3 = size of result string before terminator
;
; Lookup a message in our messages file.
;
MsgTrans_Lookup
ENTRY
LDR r0, message_file_open
TEQ r0, #0
BLEQ MsgTrans_OpenFile
EXIT VS
ADR r0, message_file_block
SWI XMessageTrans_Lookup
EXIT
message_filename
DCB "Resources:$.Resources.PS2Driver.Messages",0
ALIGN
]
;---------------------------------------------------------------------------
[ TMLDebug
InsertDebugRoutines
]
;---------------------------------------------------------------------------
; Neil's debugging routines.
;
[ debug
InsertNDRDebugRoutines
]
END
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment