]> git.kernelconcepts.de Git - karo-tx-uboot.git/blob - board/MAI/bios_emulator/scitech/src/pm/smx/_event.asm
* Patch by Thomas Frieden, 13 Nov 2002:
[karo-tx-uboot.git] / board / MAI / bios_emulator / scitech / src / pm / smx / _event.asm
1 ;****************************************************************************
2 ;*
3 ;*                  SciTech Multi-platform Graphics Library
4 ;*
5 ;*  ========================================================================
6 ;*
7 ;*    The contents of this file are subject to the SciTech MGL Public
8 ;*    License Version 1.0 (the "License"); you may not use this file
9 ;*    except in compliance with the License. You may obtain a copy of
10 ;*    the License at http://www.scitechsoft.com/mgl-license.txt
11 ;*
12 ;*    Software distributed under the License is distributed on an
13 ;*    "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
14 ;*    implied. See the License for the specific language governing
15 ;*    rights and limitations under the License.
16 ;*
17 ;*    The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc.
18 ;*
19 ;*    The Initial Developer of the Original Code is SciTech Software, Inc.
20 ;*    All Rights Reserved.
21 ;*
22 ;*  ========================================================================
23 ;*
24 ;* Language:    80386 Assembler
25 ;* Environment: IBM PC (MS DOS)
26 ;*
27 ;* Description: Assembly language support routines for the event module.
28 ;*
29 ;****************************************************************************
30
31         ideal
32
33 include "scitech.mac"           ; Memory model macros
34
35 ifdef flatmodel
36
37 header  _event                  ; Set up memory model
38
39 begdataseg  _event
40
41     cextern  _EVT_biosPtr,DPTR
42
43     cpublic _EVT_dataStart
44
45 ifdef   USE_NASM
46 %define KB_HEAD     WORD esi+01Ah   ; Keyboard buffer head in BIOS data area
47 %define KB_TAIL     WORD esi+01Ch   ; Keyboard buffer tail in BIOS data area
48 %define KB_START    WORD esi+080h   ; Start of keyboard buffer in BIOS data area
49 %define KB_END      WORD esi+082h   ; End of keyboard buffer in BIOS data area
50 else
51 KB_HEAD     EQU WORD esi+01Ah       ; Keyboard buffer head in BIOS data area
52 KB_TAIL     EQU WORD esi+01Ch       ; Keyboard buffer tail in BIOS data area
53 KB_START    EQU WORD esi+080h       ; Start of keyboard buffer in BIOS data area
54 KB_END      EQU WORD esi+082h       ; End of keyboard buffer in BIOS data area
55 endif
56
57     cpublic _EVT_dataEnd
58
59 enddataseg  _event
60
61 begcodeseg  _event              ; Start of code segment
62
63     cpublic _EVT_codeStart
64
65 ;----------------------------------------------------------------------------
66 ; int _EVT_getKeyCode(void)
67 ;----------------------------------------------------------------------------
68 ; Returns the key code for the next available key by extracting it from
69 ; the BIOS keyboard buffer.
70 ;----------------------------------------------------------------------------
71 cprocstart  _EVT_getKeyCode
72
73         enter_c
74
75         mov     esi,[_EVT_biosPtr]
76         xor     ebx,ebx
77         xor     eax,eax
78         mov     bx,[KB_HEAD]
79         cmp     bx,[KB_TAIL]
80         jz      @@Done
81         xor     eax,eax
82         mov     ax,[esi+ebx]    ; EAX := character from keyboard buffer
83         inc     _bx
84         inc     _bx
85         cmp     bx,[KB_END]     ; Hit the end of the keyboard buffer?
86         jl      @@1
87         mov     bx,[KB_START]
88 @@1:    mov     [KB_HEAD],bx    ; Update keyboard buffer head pointer
89
90 @@Done: leave_c
91         ret
92
93 cprocend
94
95 ;----------------------------------------------------------------------------
96 ; int _EVT_disableInt(void);
97 ;----------------------------------------------------------------------------
98 ; Return processor interrupt status and disable interrupts.
99 ;----------------------------------------------------------------------------
100 cprocstart  _EVT_disableInt
101
102         pushf                   ; Put flag word on stack
103         cli                     ; Disable interrupts!
104         pop     eax             ; deposit flag word in return register
105         ret
106
107 cprocend
108
109 ;----------------------------------------------------------------------------
110 ; void _EVT_restoreInt(int ps);
111 ;----------------------------------------------------------------------------
112 ; Restore processor interrupt status.
113 ;----------------------------------------------------------------------------
114 cprocstart  _EVT_restoreInt
115
116         ARG     ps:UINT
117
118         push    ebp
119         mov     ebp,esp         ; Set up stack frame
120         push    [DWORD ps]
121         popf                    ; Restore processor status (and interrupts)
122         pop     ebp
123         ret
124
125 cprocend
126
127 ;----------------------------------------------------------------------------
128 ; int EVT_rdinx(int port,int index)
129 ;----------------------------------------------------------------------------
130 ; Reads an indexed register value from an I/O port.
131 ;----------------------------------------------------------------------------
132 cprocstart  EVT_rdinx
133
134         ARG     port:UINT, index:UINT
135
136         push    ebp
137         mov     ebp,esp
138         mov     edx,[port]
139         mov     al,[BYTE index]
140         out     dx,al
141         inc     dx
142         in      al,dx
143         movzx   eax,al
144         pop     ebp
145         ret
146
147 cprocend
148
149 ;----------------------------------------------------------------------------
150 ; void EVT_wrinx(int port,int index,int value)
151 ;----------------------------------------------------------------------------
152 ; Writes an indexed register value to an I/O port.
153 ;----------------------------------------------------------------------------
154 cprocstart  EVT_wrinx
155
156         ARG     port:UINT, index:UINT, value:UINT
157
158         push    ebp
159         mov     ebp,esp
160         mov     edx,[port]
161         mov     al,[BYTE index]
162         mov     ah,[BYTE value]
163         out     dx,ax
164         pop     ebp
165         ret
166
167 cprocend
168
169     cpublic _EVT_codeEnd
170
171 endcodeseg  _event
172
173 endif
174
175         END                         ; End of module