summaryrefslogtreecommitdiff
path: root/Board/EM/Sredir/SerialCallback.Asm
blob: 6c5005c874fdf6f76d4aad9ec1f9188950157059 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185

        TITLE   SerialCallback.ASM - Oem callback function from sredir.bin

;****************************************************************************
;****************************************************************************
;**                                                                        **
;**             (C)Copyright 1985-2010, American Megatrends, Inc.          **
;**                                                                        **
;**                          All Rights Reserved.                          **
;**                                                                        **
;**                 5555 Oakbrook Pkwy, Suite 200, Norcross, GA 30093      **
;**                                                                        **
;**                          Phone (770)-246-8600                          **
;**                                                                        **
;****************************************************************************
;****************************************************************************

;****************************************************************************
; $Header: /Alaska/SOURCE/Modules/Legacy Serial Redirection/SerialCallback.ASM 1     5/03/10 1:53a Rameshr $
;
; $Revision: 1 $
;
; $Date: 5/03/10 1:53a $
;****************************************************************************
; Revision History
; ----------------
; $Log: /Alaska/SOURCE/Modules/Legacy Serial Redirection/SerialCallback.ASM $
; 
; 1     5/03/10 1:53a Rameshr
; Callback function added for read and write function of the Serial Port.
; EIP 37850
;
;****************************************************************************

;----------------------------------------------------------------------------
;       INCLUDE FILES
;----------------------------------------------------------------------------

;----------------------------------------------------------------------------
;       EXTERNS USED
;----------------------------------------------------------------------------
.586p
OEM16_CSEG SEGMENT PARA PUBLIC 'CODE' USE16
        ASSUME cs:OEM16_CSEG, ds:OEM16_CSEG
;-------------------------------------------------------------------------
        PUBLIC SerialCallBackApiModuleStart
SerialCallBackApiModuleStart LABEL BYTE
        jmp     SHORT SerialCallbackCsm16Api

;<AMI_PHDR_START>
;----------------------------------------------------------------------------
;
; Procedure:     SerialCsm16_API
;
; Description:    This routine is implementation of the CSM16 API #B 
;
; Input:         CX     00h   - Serial Read
;                     	01h   - Serial Write 
;
; Output:       
;
; Modified:         None
;
;----------------------------------------------------------------------------
;<AMI_PHDR_END>
SerialCallbackCsm16Api  PROC FAR PUBLIC
; Adjust current IP so that the data offsets are valid
        call    $+3                     ; Push curent IP
        pop     bx                      ; Get current IP in BX
        shr     bx, 4
        mov     ax, cs                  ; Always x000h
        add     ax, bx                  ; New CS
        push    ax
        push    newSerialOffset-SerialCallBackApiModuleStart
        retf                            ; Execute from new CS:IP

newSerialOffset:
        push    bp
        mov     bp, sp
        mov     dx,  ss:[bp+42h]    ; Serial Port Address
        mov     ax,  ss:[bp+40h]    ; Write Data, For read it's invalid 

        cmp     cx, 0
        je      SerialRead
        cmp     cx,1
        je      SerialWrite
        jmp     UnknownFunction
SerialRead:
        Call    ReadSerialPort 
        jmp     UnknownFunction
SerialWrite:
        Call    WriteSerialPort
        jmp     UnknownFunction

UnknownFunction:
        pop     bp

; Adjust sp as if we returned to csm16_func_ret
        add     sp, 4                   ; cs:ip of F000:csm16_func_ret

; Save AX, restore it after popad
        push    ax
        pop     ds

        popad

        push    ds
        pop     ax

        pop     gs
        pop     fs
        pop     es
        pop     ds

        popf
        pop     ds
        pop     si

        add     sp, 2                   ; Do not "pop ax", preserving return code

        pop     bp
        add     sp, 4

        clc
        retf        
SerialCallbackCsm16Api  ENDP

;<AMI_PHDR_START>
;----------------------------------------------------------------------------
;
; Procedure:  	WriteSerialPort
;
; Description:  Oem Function before serial Read 
;
; Input:      	None
;                
; Output:       None
;
; Modified:	None
;
;----------------------------------------------------------------------------
;<AMI_PHDR_END>
WriteSerialPort   PROC    NEAR     PUBLIC
        out     dx,al
        jmp     $+2
        ret
WriteSerialPort   ENDP

;<AMI_PHDR_START>
;----------------------------------------------------------------------------
;
; Procedure:  	ReadSerialPort
;
; Description:  Oem Function before serial Write 
;
; Input:      	None
;                
; Output:       None
;
; Modified:	None
;
;----------------------------------------------------------------------------
;<AMI_PHDR_END>
ReadSerialPort   PROC    NEAR     PUBLIC
        in      al,dx
        jmp     $+2
        ret
ReadSerialPort   ENDP

OEM16_CSEG ENDS

END
;****************************************************************************
;****************************************************************************
;**                                                                        **
;**             (C)Copyright 1985-2010, American Megatrends, Inc.          **
;**                                                                        **
;**                          All Rights Reserved.                          **
;**                                                                        **
;**                 5555 Oakbrook Pkwy, Suite 200, Norcross, GA 30093      **
;**                                                                        **
;**                          Phone (770)-246-8600                          **
;**                                                                        **
;****************************************************************************
;****************************************************************************