]>
wirehaze git hosting - MS-DOS.git/blob - v4.0/src/MEMM/MEMM/ROM_SRCH.ASM
5 ;******************************************************************************
6 title ROM_SRCH
- search for option ROMs
7 ;******************************************************************************
9 ; (C) Copyright MICROSOFT Corp. 1986
11 ; Title: MEMM.EXE - MICROSOFT Expanded Memory Manager 386 Driver
13 ; Module: ROM_SRCH - search for option ROMS and RAM
21 ;******************************************************************************
25 ; DATE REVISION DESCRIPTION
26 ; -------- -------- ------------------------------------------------------
27 ; 06/05/86 Original Adapted from ROM code
28 ; 06/25/86 0.02 Fixed upd_map.
29 ; 06/26/86 0.02 Fixed upd_map (again) and ram_srch
30 ; 06/28/86 0.02 Name changed from MEMM386 to MEMM
31 ; 07/06/86 0.04 changed assume to DGROUP
32 ; 08/01/88 Updated to identify mappable segs between C000 and E000
34 ;******************************************************************************
36 ;******************************************************************************
38 ; Functional description:
40 ; This module contains the code that scans the ROM at the segment
41 ; supplied in register AX looking for ROMs on hardware interface
42 ; boards. The layout of each valid ROM is as follows:
44 ; OFFSET +-----------------------+
46 ; +-----------------------+
48 ; +-----------------------+
49 ; 2 | ROM size / 512 |
50 ; +-----------------------+
51 ; 3 | Start of init code |
54 ; +-----------------------+
55 ; (Sum of all bytes MOD 100h is 00h.)
57 ; This module also contains the code to search and vector to VDU
58 ; roms (C000:0 to C000:7800 in 2K increments).
60 ;******************************************************************************
64 ;******************************************************************************
66 ;******************************************************************************
68 public rom_srch
; Search and Vector to option ROMs.
69 ;******************************************************************************
71 ;******************************************************************************
75 extrn mappable_segs
:byte
76 extrn exclude_segments
:near
80 ;******************************************************************************
82 ;******************************************************************************
84 FIRST_ROM
= 0C800H ; Segment address of first option ROM.
85 LAST_ROM
= 0EF80H ; Segment address of last option ROM.
86 FIRST_VDU_ROM
= 0C000H ; Seg address of first VDU option ROM.
87 LAST_VDU_ROM
= 0C780H ; Seg address of last VDU option ROM.
88 FIRST_RAM
= 0C000H ; Seg address of 1st possible RAM addr
89 LAST_RAM
= 0EF80H ; Seg addr of last possible RAM addr
90 NOT_FOUND_INCR
= 0800H ; Amount to skip if no ROM found.
94 include romstruc
.equ
; Option ROM structure.
95 PF_LENGTH equ
0400h ; length of a page frame (*16)
97 ;******************************************************************************
99 ;******************************************************************************
101 ASSUME
CS:LAST
, DS:DGROUP
104 ;******************************************************************************
106 ; ROM_SRCH - Search for option ROMs.
108 ; This section of code searches the auxiliary rom area (from C8000 up
109 ; to E0000) in 2K increments. A ROM checksum is calculated to insure
110 ; that the ROMs are valid. Valid ROMs must have the 1st byte = 55H
111 ; and the next byte = 0AAH. The next byte indicates the size of the
112 ; ROM in 512-byte blocks. The sum of all bytes in the ROM, modulo 256,
115 ; If a ROM is not found at a location, the next location 2K-bytes down
116 ; is examined. However, if it is found, the next location after this
117 ; ROM is tried. The next ROM location is determine according to the
118 ; size of the previous ROM.
121 ;******************************************************************************
122 rom_srch proc
near ; Entry point.
125 ; search for option ROMs
127 mov ax,FIRST_ROM
; Segment address of first option ROM.
128 cld ; Set direction flag.
130 call opt_rom
; Look for option ROM.
131 jnc not_fnd1
; No ROM here
134 cmp ax,LAST_ROM
;Q: All ROMs looked at ?
135 jbe nxt_opt
; No, keep looking
136 ; Y: check for VDU roms
138 ; search for VDM ROMs
140 mov ax,FIRST_VDU_ROM
; segment addr for first vdu ROM
143 call opt_rom
; Q:is it there
144 jnc not_fnd2
; No ROM here
147 cmp ax,LAST_VDU_ROM
;Q: last VDU ROM ?
148 jbe nxt_vdu
; N: continue
153 mov ax,FIRST_RAM
; first seg addr for RAM search
156 call ram_srch
;Q: RAM here ?
157 jnc not_fndr
; N: check again ?
160 cmp ax,LAST_RAM
;Q: last RAM location
161 jbe nxt_ram
; N: continue searching
169 ;******************************************************************************
170 ; OPT_ROM - This routine looks at the ROM located at the segment address
171 ; specified in AX to see if 0TH and 1ST Bytes = 0AA55H.
172 ; If so, it calculates the checksum over the length of
173 ; ROM. If the checksum is valid it updates AX to point
174 ; to the location of the next ROM.
176 ; Inputs: AX = Segment address of ROM.
178 ; Outputs: CY = Found a VDU ROM at this location.
179 ; NC = Did not find a valid ROM at this location.
180 ; AX = Segment address of next ROM location.
181 ; DX = Length of this ROM
183 ;******************************************************************************
191 mov ds,ax ; DS=ROM segment address.
192 xor bx,bx ; Index uses less code than absolute.
193 cmp [bx.ROM_RECOGNITION
],0AA55H ;Q: Looks like a ROM?
194 jne rs_3
; No, Skip down
196 ; Compute checksum over ROM.
198 xor si,si ; DS:SI=ROM Pointer; Start at beg.
199 xor cx,cx ; Prepare to accept byte into word.
200 mov ch,[bx.ROM_LEN
] ; CH=byte count/512 (CX=byte count/2)
201 shl cx,1 ; CX=adjusted byte count.
202 mov dx,cx ; Extract size.
204 lodsb ; MOV AL,DS:[SI+]; Pickup next byte.
205 add bl,al ; Checksum += byte(SEG:offset)
206 loop rs_2
; Loop doesn't affect flags.
207 jnz rs_3
; Jump down if bad checksum.
209 mov cl,4 ; Shift of 4...
210 shr dx,cl ; Converts bytes to paragraphs (D.03)
211 mov ax,ds ; Replace segment in AX.
212 add ax,dx ; increment segment by this amount
214 jmp short rs_exit
; Continue.
217 mov dx,(NOT_FOUND_INCR
shr 4) ; Prepare for next ROM.
218 mov ax,ds ; Replace segment in AX.
219 add ax,dx ; Increment segment.
232 ;******************************************************************************
233 ; RAM_SRCH - This routine looks at the address range potentially used
234 ; by the Page Frame to determine if any RAM is in the way.
235 ; It updates the map accordingly.
237 ; Inputs: AX = Segment address for RAM search.
239 ; Outputs: CY = Found RAM at this location.
240 ; NC = Did not find RAM at this location.
241 ; AX = Segment address of next RAM location.
242 ; DX = Length of this RAM
244 ;******************************************************************************
253 xor dx,dx ; length = 0
256 add ax,(NOT_FOUND_INCR
shr 4); prepare for next chunk
257 mov bx,ds:0 ; get a word
258 xor ds:0,0FFFFh ; flip all bits
259 xor bx,0FFFFh ; BX = "flipped" value
260 cmp bx,ds:0 ;Q: "flipped" value written out ?
261 jne no_more_ram
; N: not RAM - leave
262 xor ds:0,0FFFFh ; Y: is ram, flip bits back
263 add dx,(NOT_FOUND_INCR
shr 4); increment length count
264 cmp ax,LAST_RAM
;Q: last RAM location ?
265 jbe ram_loop
; N: continue searching
266 mov ds,ax ; Y: no more searching
269 mov ax,ds ; get current segment
270 or dx,dx ;Q: any RAM found ?
271 jnz ram_found
; Y: set RAM found & chk DS seg again
273 add ax,(NOT_FOUND_INCR
shr 4) ; AX -> next one to check
274 jmp short ram_exit
; and leave
287 ;******************************************************************************
288 ; UPD_SEG - This routine looks at the address range used by the ROM/RAM
289 ; that was found to determine how many potential physical
290 ; pages are invalidated from being mappable. It updates
291 ; the mappable_segs array appropriately.
293 ; Inputs: AX = Segment address of next ROM/RAM position.
294 ; DX = Length of ROM/RAM
296 ; Outputs: [mappable_segs] updated.
298 ; Written: 8/1/88 ISP
299 ; Modif: 8/25/88 ISP to make use of exclude_segments
300 ;******************************************************************************
307 sub bx,dx ; bx now has the first segment of the area
308 dec ax ; and ax has the last segment of the area
310 call exclude_segments