1 ; mapper.S - LILO chain loader subroutine
3 ; Copyright 2003-2004 John Coffman.
6 ; Licensed under the terms contained in the file 'COPYING' in the
9 ; Check for presence of existing drive mapper
11 ; Enter with DS == CS, SS == 0000 (chain loader)
12 ; Enter with DS == CS == ES, SS != 0000 (second stage)
14 ; If a previous drive mapper exists, ES:DI points at the drvmap
17 ; If no recognizable drive map exists, DI == 0 and ZF==1
33 les di,[4*0x13] ; vector to int 0x13
35 jnz is_p_no_mapper ; our mappers start at offset 0
38 cmp di,#0xA000 ; start of system reserved locations
40 cmp di,#0x0060 ; VERY conservative
43 ; first test for new mapper
51 ; found new (v.22) mapper
53 mov di,[new13_drvmap_offset]
54 #if defined CHAIN_LOADER && defined DEBUG_NEW
62 mov cx,#new13_old_length
68 ; likely old (<=v.21) mapper
71 cmp di,#new13_old_min_offs ; validate the range of values
73 cmp di,#new13_old_max_offs ; validate the range of values
74 #if defined CHAIN_LOADER && defined DEBUG_NEW
84 xor di,di ; set DI = 0, ZF=1
86 or di,di ; set ZF by DI
92 /* LILO version 21 (and maybe earlier) drive map header signature code */
94 push ax ! save AX (contains function code in AH)
95 push bp ! need BP to mess with stack
97 pushf ! push flags (to act like interrupt)
101 new13_old_drvmap_offs = * - new13_old - 2
102 new13_old_length = new13_old_drvmap_offs
103 new13_old_min_offs = 0x46 ; min seen in old code is 0x49
104 new13_old_max_offs = 0x50 ; maxed out at 21.7.5 at 0x4d
106 .even ! this is very important
108 new13: push ax ! save AX (contains function code in AH)
109 push bp ! need BP to mess with stack
111 jmp new13a ! make space for signature
115 .word STAGE_DRIVE_MAP
116 new13_length = *-new13 ; max compare length
118 new13_drvmap_offset = * - new13
119 .word drvmap-new13 ! relative pointer to drive map
129 pushf ! push flags (to act like interrupt)
132 mapfl: seg cs ! get next entry
133 mov ax,(si) ! do not depend on DIRECTION flag
136 jz nomap ! yes -> do not map
138 jne mapfl ! no -> continue
139 mov dl,ah ! map drive
140 nomap: pop si ! restore SI
141 mov 8(bp),ax ! overwrite old flags (to remember mapping)
142 mov ax,2(bp) ! restore AX
143 mov bp,(bp) ! restore BP
148 push bp ! save BP again
152 ! +10 mapping (was flags)
158 xchg ax,4(bp) ! save AX and get command
159 pushf ! fix driver number, if necessary
160 cmp ah,#8 ! do not fix
162 cmp ah,#0x15 ! do not fix
164 mov ax,10(bp) ! no mapping ?
167 mov dl,al ! fix mapping
168 done13: mov ax,4(bp) ! restore AX
169 pop 10(bp) ! restore flags
175 drvmap: .blkw DRVMAP_SIZE+1
179 #ifdef SECOND_STAGE_LOADER
183 /* end of mapper.S */