md.inc

来自「Dos6.0」· INC 代码 · 共 383 行 · 第 1/2 页

INC
383
字号
;************************************************************************
;
;       HARDWARE.INC
;
;       This file defines the hardware specific equates to be used in
;               the mouse driver.
;

IOdelay macro
         jmp       $+2
         jmp       $+2
endm

address macro StartAddr, EndAddr
        add   dx,StartAddr-EndAddr
endm

DelayIn   macro dest,src
          IOdelay
          in dest,src
endm

DelayOut  macro dest,src
          IOdelay
          out dest,src
endm

;
; This makes debugging much, much easier !!
;

IFDEF DEBUG

; Label Names.

PUBLIC  serial_next_port,  rsm_waitloop,           cfmm_retry
PUBLIC  inport_not_found,  rsm_waitover,           cfmm_failure
PUBLIC  tfs_determine_int, rsm_lookforM,           cfmm_signature_sent
PUBLIC  cfas_clean_up,     rsm_gotchar,            cfmm_cleanup
PUBLIC  r8cb_got_data,     rsm_leave,              cfmm_disable_aux
PUBLIC  r8cb_leave,        gmd_loop,               cfas_is_wait_over
PUBLIC  w8cb_leave,        tfp_no_mouse,           rpm_retry
PUBLIC  wib_success,       tfp_leave,              rpm_failure
PUBLIC  mioff_leave,       cfas_read_test_results, finished_mouse
PUBLIC  cmd_leave,         cfas_no_support,        cfmm_leave
PUBLIC  stmatd_leave,      cfas_reenable_kbd,      All_is_well
PUBLIC  gmd_buffer_empty,  cfas_leave,             possible_inport
PUBLIC  gmd_got_aux_data,  r8cb_loop,              inport_check
PUBLIC  rpm_leave,         r8cb_leave2,            bus_not_found
PUBLIC  inport_try_again,  wib_wait,               tfs_error_leave
PUBLIC  inport_found,      wib_check_output,       wcr_loop
PUBLIC  look_for_bus,      wib_failure,            wcr_success
PUBLIC  look_for_serial,   wib_check_aux_data,     mioff_cleanup
PUBLIC  serial_try_again,  wib_leave,              mioff_reenable_kbd
PUBLIC  serial_test_port,  serial_not_found,       serial_found
PUBLIC  logiTech_failure,  lt_waitloop,            lt_waitloop2
PUBLIC  lt_waitloop3,      lt_cont,                lt_found
PUBLIC  look_for_PS2

; Function Names.

PUBLIC  setup_for_detect,    RestoreCOMSetting,      WriteControlRegister  
PUBLIC  TestForInport,       SetupForWait,           WriteInputBuffer      
PUBLIC  TestForBus,          IsWaitOver,             Write8042CommandByte   
PUBLIC  TestForSerial,       CheckForAuxSupport,     ResetPS2Mouse          
PUBLIC  TestForPS2,          MouseIntOff,            SendToMouse 
PUBLIC  SaveCOMSetting,      CheckForMSMouse,        SendToMouseAndTestData
PUBLIC  SetupCOMForMouse,    WriteControlRegister,   GetMouseData           
PUBLIC  ResetSerialMouse,    Read8042CommandByte,    CheckMouseData         
PUBLIC  CheckForLogitechPS2, TestForLogitechSerial,  setupForLogitechSerial

; Global Variable Names.

PUBLIC  LATLSBSave,   LCRSave,  IERSave,        fSingle8259  
PUBLIC  LATMSBSave,   MCRSave,  SemaphoreWord,  COM_3_4_ADDRS
   
ENDIF   ;DEBUG

TRUE           EQU    0ffh
FALSE          EQU    0

LW_ClockTickCount EQU    46Ch
HW_ClockTickCount EQU    46Eh

;************************************************************************
;               I N P O R T     D E F I N I T I O N S                   *
;************************************************************************

INP_ADDR        EQU     0               ; Inport addr register offset.
INP_DATA        EQU     1               ; Inport data register offset.
INP_ID          EQU     2               ; Inport ID register offset.
INP_TEST        EQU     3               ; Inport test register offset.

INPORT_ID       EQU     0DEh            ; InPort ID byte.

INP_STATUS_REG  EQU     0               ; Status register number.
INP_DATA1_REG   EQU     1               ; Internal data register 1.
INP_DATA2_REG   EQU     2               ; Internal data register 2.
INP_MODE_REG    EQU     7               ; Mode register number.

INP_RESET       EQU     10000000b       ; Value to reset InPort.

HZ0INTR0        EQU     00000000b       ; Value to select 0 Hz, INTR=0
HZ0INTR1        EQU     00000110b       ; Value to select 0 Hz, INTR=1
HZ30            EQU     00000001b       ; Value to select 30 Hz.
DATA_INT_ENAB   EQU     00001000b       ; Data int enable bit.
TIMER_INT_ENAB  EQU     00010000b       ; Timer int enable bit.
HOLD_BIT        EQU     00100000b       ; Hold bit.

BUTTON_1_BIT    EQU     00000100b       ; Bit indicating button 1.
BUTTON_3_BIT    EQU     00000001b       ; Bit indicating button 3.
MOVEMENT_BIT    EQU     01000000b       ; Bit indicating movement.

INPORT_FIRST_PORT EQU   23Ch            ; Address of primary InPort.
INPORT_LAST_PORT EQU    238h            ; Address of secondary InPort.

MACH20_IRQ      EQU     0Ch             ; IRQ used for Mach 20 InPort
                                        ; under Mach 20 OS/2.

;****************************************************************
;               B U S   D E F I N I T I O N S                   *
;****************************************************************
; Since the Adaptor for the bus mouse is based on an 8255A, we have to
;       program the 8255A properly in order to function. We need to select:
;
;       Mode 0 (for all ports).
;       Port A (input - this allows us to read information from the ALPS
;               chip and from the buttons)
;       Port B (output - this allows us to write a value there and then
;               read it back in. It is not connected to anything)
;       Port C, upper half (output - this allows us to send control
;               information to the ALPS chip)
;       Port C, lower half (input - this allows us to poll the current states
;               of IRQs 2, 3, 4, and 5)
;
; The value that does this is
;
;       10010001
;       ||||||||-----   Port C Lower is input
;       |||||||------   Port B is output
;       ||||||-------   Mode 0 for Group B (Port B and lower half of Port C)
;       |||||--------   Port C Upper is output
;       ||||---------   Port A is input
;       |------------   Mode 0 for Group A (Port A and upper half of Port C)
;       -------------   Mode set control word
;

BUS_MOUSE_BASE  EQU     023Ch           ; Base I/O addr of bus mouse.

BUS_DATA        EQU     BUS_MOUSE_BASE  ; Port where mouse data is read from.
BUS_SIG         EQU     BUS_MOUSE_BASE + 1 ; Port unused for mouse, used for de-
                                        ; termining existence of bus adaptor.
BUS_CONTROL     EQU     BUS_MOUSE_BASE + 2 ; Port used to control adaptor.
BUS_INIT        EQU     BUS_MOUSE_BASE + 3 ; Port used to init bus adaptor.

BUS_INIT_VALUE  EQU     10010001b       ; Value used to init bus adaptor.

LOW_X           EQU     090h            ; Cmd to read low 4 bits of delta X
HI_X            EQU     0B0h            ; Cmd to read high 2 bits of delta X
LOW_Y           EQU     0D0h            ; Cmd to read low 4 bits of delta Y
HI_Y            EQU     0F0h            ; Cmd to read high 2 bits of delta Y

;************************************************************************
;               S E R I A L     D E F I N I T I O N S                   *
;************************************************************************

SERIAL_PACKETSIZE       EQU     3       ; Bytes in a packet of data.

SYNC_BIT                EQU     40H     ; Bit 6 is the sync bit

;
; These are the offsets within the COM chip of the various registers.
;

TXB             EQU     0               ; Transmit buffer
RXB             EQU     0               ; Receive buffer
LATLSB          EQU     0               ; Divisor latch, LSB
LATMSB          EQU     1               ; Divisor latch, MSB
IER             EQU     1               ; Interrupt enable register
IIR             EQU     2               ; Interrupt identification register
LCR             EQU     3               ; Line control register
MCR             EQU     4               ; Modem control register
LSR             EQU     5               ; Line status register
MSR             EQU     6               ; Modem status register

;
; These give the number of milliseconds to wait while waiting for the serial
;       mouse to reset itself. We will first use the value given by SHORTDELAY
;       and if that fails, we will then use the value given by LONGDELAY.
;

SHORTDELAY      EQU     6        ; 350  msecs  = 350/55.5  = 6  clock ticks.

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?