scroll mode for very long start menus
[reactos.git] / freeldr / freeldr / arch / i386 / drvmap.S
1 /*
2 * FreeLoader
3 * Copyright (C) 1998-2002 Brian Palmer <brianp@sginet.com>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 */
19
20 .text
21 .code16
22
23 #define ASM
24 #include <arch.h>
25
26
27 EXTERN(_DriveMapInt13HandlerStart)
28 Int13Handler:
29
30 pushw %bp
31 movw %sp,%bp
32 pushw %ax
33 pushw %cx
34 pushw %si
35
36 cld
37
38 /* Get callers flags from stack */
39 movw 0x06(%bp),%ax
40 movw %ax,%cs:(CallersFlags - Int13Handler)
41
42 /* Save the drive number they passed in */
43 movb %dl,%cs:(PassedInDriveNumber - Int13Handler)
44
45 /* Now we need to perform the mapping */
46 xorw %cx,%cx
47 movw $(Int13HandlerMapCount - Int13Handler),%si
48 /* Get the count of drives in the map list */
49 movb %cs:(%si),%cl
50 incw %si
51
52 /* If the map list is empty then just call the old int 13h handler */
53 cmpb $0,%cl
54 jz CallOldInt13Handler
55
56 GetMappedDriveNumberLoop:
57
58 /* Get the next drive number in the list */
59 lodsw %cs:(%si),%ax
60 /* Check to see if it's the one they are calling int 13h for */
61 cmpb %al,%dl
62 /* If not get the next one */
63 jne GetMappedDriveNumberLoopNext
64
65 /* If we get here then we have found a mapped drive */
66 /* Send new drive number on to the old int 13h handler */
67 movb %ah,%dl
68 /* Call BIOS Int 13 Handler */
69 jmp CallOldInt13Handler
70
71 GetMappedDriveNumberLoopNext:
72 loop GetMappedDriveNumberLoop
73
74 CallOldInt13Handler:
75 /* Restore the registers we changed off the stack */
76 popw %si
77 popw %cx
78 popw %ax
79
80 /* Put flags onto stack */
81 pushw %cs:(CallersFlags - Int13Handler)
82
83 /* Call old int 13h handler with new drive number */
84 .byte 0x9a /* lcall */
85 EXTERN(_DriveMapOldInt13HandlerAddress)
86 .word 0
87 .word 0
88
89 /* Update the callers flags with the values the BIOS returned */
90 pushw %ax
91 pushf
92 popw %ax
93 movw %ax,0x06(%bp)
94 popw %ax
95 /* Restore the callers drive number */
96 movb %cs:(PassedInDriveNumber - Int13Handler),%dl
97
98 popw %bp
99
100 iret
101
102 CallersFlags:
103 .word 0
104
105 PassedInDriveNumber:
106 .byte 0
107
108 EXTERN(_DriveMapInt13HandlerMapList)
109 Int13HandlerMapCount:
110 .byte 0
111
112 Int13HandlerDrive1:
113 .byte 0
114 Int13HandlerDriveNew1:
115 .byte 0
116
117 Int13HandlerDrive2:
118 .byte 0
119 Int13HandlerDriveNew2:
120 .byte 0
121
122 Int13HandlerDrive3:
123 .byte 0
124 Int13HandlerDriveNew3:
125 .byte 0
126
127 Int13HandlerDrive4:
128 .byte 0
129 Int13HandlerDriveNew4:
130 .byte 0
131
132 EXTERN(_DriveMapInt13HandlerEnd)