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
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; MACRO definitions for expanded memory manager
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; 1. MACRO to save mapping context in case somebody else has
; mapped the page registers.
;
save_mapping_context macro
local save_agn_m,save_err_m,save_ok_m,save_exit_m
;
; the save mapping call for the above board -->
;
; mov ah,47h
; mov dx,handle
; int 67h
;
; on return ax = 0 signifies success
;
;
push ax ; save registers
push dx
;
; set up emm registers and execute call to save mapping context
;
save_agn_m:
mov dx,cs:[above_pid] ; get emm handle
mov ah,above_save_map_pid ; save map call
int 67h ; call the manager
or ah,ah ; is there an error?
jz save_ok_m ; if not we are done
;
; error in saving mapping context, check for error
;
cmp ah,above_error_busy ; if the emm manager was busy
jz save_agn_m ; we would like to try again
;
; unrecoverable error, indicate error type in al
;
pop dx
pop dx ; pop the regs off the stack
;
mov al,02h ; drive not ready
cmp ah,above_error_cntxt_no_stack ;
jz save_err_m
cmp ah,above_error_second_save ;
ja save_err_m
mov al,0ch ; general failure
save_err_m:
stc
jmp short save_exit_m
save_ok_m:
clc
pop dx
pop ax ; restore registers
save_exit_m:
endm
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; 2. MACRO to restore the mapping context saved earlier
;
restore_mapping_context macro
local rest_agn_m, rest_ok_m, rest_exit_m
;
; the restore above map call -->
;
; mov ah,48h
; mov dx,handle
; int 67h
; ah = 0 is success
;
;
push ax
pushf
;
rest_agn_m:
mov dx,cs:[above_pid] ; get emm handle
mov ah,above_restore_map_pid ; restore map call
int 67h ; call manager
or ah,ah ; is there any error
jz rest_ok_m ; if not go to finish up
;
; error condition, check for recoverable error
;
cmp ah,above_error_busy ; if manager was busy
jz rest_agn_m ; we sure can try again
cmp ah,above_error_no_cntxt ;
jz rest_ok_m ; ignore invalid pid error
;
; unrecoverable error
;
pop dx
pop dx
mov al,0ch ; general failure
stc
jmp short rest_exit_m
;
rest_ok_m:
popf
pop ax
rest_exit_m:
;
endm
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; 3. MACRO to map a page in the physical page map onto a logical
; page.
;
; the map above page requires
; mov ah,44h
; mov dx,handle
; mov al,physical_page# (0-3)
; mov bx,logical_page#
; int 67H
; ah = 0 success and this routine zaps ax,dx and bx
;
map_page macro
local map_agn_m,map_exit_m,map_fin_m
;
mov ah,above_map ; function map page
mov dx,cs:[above_pid] ; get emm handle
;
push ax
;
map_agn_m:
pop ax
push ax
push bx
push dx ; "damn call above_map zaps these registers"
;
int 67h ; map call
pop dx
pop bx
;
or ah,ah ; is there an error?
jz map_fin_m ; if not go to finish up
;
; error condition - check for recoverable error
;
cmp ah,above_error_busy ; if manager was busy
jz map_agn_m ; we sure can try again
;
; unrecoverable error
;
pop ax
mov al,02h ; device not ready error
stc
jmp short map_exit_m
;
; exit point
;
map_fin_m:
clc
pop ax
map_exit_m:
;
endm
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; OTHER MACROS
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; 1) MACRO to switch es:di with ds:si
;
src_dest_switch macro
;
push ds
push es
push si
mov si,di
pop di
pop ds
pop es
;
endm
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|