source: trunk/VFDisk.asm@ 15

Last change on this file since 15 was 15, checked in by erdmann, 7 years ago

add Valerys changes, update makefile to properly generate version and date info

File size: 27.2 KB
Line 
1;==========================================================================
2;== ==
3;== VFDISK ==
4;== Copyright IBM Corporation 1991,1993,1994 ==
5;== Copyright Daniela Engert 2003 ==
6;== Portions Copyright Lars Erdmann 2010 ==
7;== ==
8;== distributed under the terms of the GNU Lesser General Public License ==
9;==========================================================================
10
11 OPTION NOSCOPED
12 .NOLIST
13 include DevHlp.inc
14 .LIST
15
16 EXTRN DOSPUTMESSAGE:FAR
17 EXTRN DOS32FLATDS:ABS
18 EXTRN _RMCreateDriver: FAR
19
20StdOut = 1
21
22DRF_STATIC = 0
23DRT_OS2 = 3
24DRS_BLOCK = 2
25
26DATESTAMP STRUC
27Year WORD ?
28Month BYTE ?
29Day BYTE ?
30DATESTAMP ENDS
31
32DRIVERSTRUCT STRUC
33DrvrName DWORD ?
34DrvrDescript DWORD ?
35VendorName DWORD ?
36MajorVer BYTE ?
37MinorVer BYTE ?
38Date DATESTAMP <>
39DrvrFlags WORD ?
40DrvrType WORD ?
41DrvrSubType WORD ?
42DrvrCallback DWORD ?
43DRIVERSTRUCT ENDS
44
45
46sBPB STRUC
47 BpSector DW ?
48 SpCluster DB ?
49 ResSectors DW ?
50 numFATs DB ?
51 numRootDirs DW ?
52 numSectorsW DW ?
53 MediaDesc DB ?
54 SpFAT DW ?
55 SpTrack DW ?
56 numHeads DW ?
57 numHidden DD ?
58 numSectorsL DD ?
59 unused DF ?
60 numCylinders DW ?
61 DeviceType DB ?
62 DeviceFlags DW ?
63sBPB ENDS
64
65sDPB STRUC
66 BpSector DW ?
67 SpCluster DB ?
68 ResSectors DW ?
69 numFATs DB ?
70 numRootDirs DW ?
71 numSectorsW DW ?
72 MediaDesc DB ?
73 SpFAT DW ?
74 SpTrack DW ?
75 numHeads DW ?
76 numHidden DD ?
77 numSectorsL DD ?
78sDPB ENDS
79
80;------------------------------------------------------------ _DATA ----
81
82_DATA SEGMENT BYTE PUBLIC USE16 'DATA'
83.386p
84
85DD_Next DD 0FFFFFFFFH
86DD_Attr DW 2880H
87DD_Strategy DW OFFSET Strategy
88DD_IDC DW 0
89DD_Units DB 1
90DD_Reserved DB 15 DUP (0)
91
92_Device_Help DD 00000H
93pMem LABEL FWORD
94lAddr DD 0
95FlatSel DW DOS32FLATDS
96thisSector DW 0
97curSector DW 0
98numSectors DW 0
99Buffer LABEL DWORD
100BufferLow DW 0
101BufferHigh DW 0
102isIOCtl DB 0
103MediaStatus DB 0FFH
104MemAllocated DB 0
105
106pBPB DW OFFSET BPB_1440
107
108DD_Table DB DD_TableLen - 1
109DD_Functions DW OFFSET Init
110 DW OFFSET MediaCheck
111 DW OFFSET BuildBPB
112 DW OFFSET NotSupported
113 DW OFFSET Read
114 DW OFFSET NotSupported
115 DW OFFSET NotSupported
116 DW OFFSET NotSupported
117 DW OFFSET Write
118 DW OFFSET Write
119 DW OFFSET NotSupported
120 DW OFFSET NotSupported
121 DW OFFSET NotSupported
122 DW OFFSET Open
123 DW OFFSET Close
124 DW OFFSET RemovableMedia
125 DW OFFSET GenIOCtl
126 DW OFFSET ResetMedia
127 DW OFFSET GetSetDriveMap
128 DW OFFSET GetSetDriveMap
129 DW OFFSET NotSupported
130DD_TableLen = ($ - DD_Functions) / 2
131
132MsgBoot DB 0DH, 0AH, 'VFDISK ',_VERMAJOR+'0','.',_VERMINOR+'0',' (c) 2003 D.Engert (2010 L. Erdmann), Drive '
133MsgDriveLetter DB 'A:', 0DH, 0AH
134MsgBootLen = $ - MsgBoot
135
136MsgAbort DB 0DH, 0AH, 'VFDISK installation aborted', 0DH, 0AH
137MsgAbortLen = $ - MsgAbort
138
139VolumeLabel DB 'VFDISK ', 8, 20 DUP (0)
140VolumeLabelSize = $ - VolumeLabel
141
142BPB_Table:
143BPB_1440 sBPB <512,1,1,2,224,2880,0F0H, 9,18,2,0,0,0,80,7,6> ; 1.44M
144BPB_1200 sBPB <512,1,1,2,224,2400,0F9H, 7,15,2,0,0,0,80,1,6> ; 1.2M
145BPB_0720 sBPB <512,2,1,2,112,1440,0F9H, 3, 9,2,0,0,0,80,2,6> ; 720K
146BPB_2880 sBPB <512,2,1,2,240,5760,0F0H, 9,36,2,0,0,0,80,9,6> ; 2.88M
147BPB_0360 sBPB <512,2,1,2,112, 720,0FDH, 2, 9,2,0,0,0,40,0,6> ; 360K
148BPB_1840 sBPB <512,1,1,2,224,3680,0F0H,11,23,2,0,0,0,80,7,6> ; 1.84M
149
150BootSectorProto:
151 DB 0EBH, 3CH, 90H, 'IBM 10.2'
152BPB sDPB <512,1,1,2,0E0H,0B40H,0F0H,9,18,2,0,0>
153 DB 00H, 00H, 29H, 14H,0E4H, 5DH
154 DB 25H, 4EH, 4FH, 20H, 4EH, 41H
155 DB 4DH, 45H, 20H, 20H, 20H, 20H
156 DB 46H, 41H, 54H, 20H, 20H, 20H
157 DB 20H, 20H, 33H,0C0H, 8EH,0D0H
158 DB 0BCH, 00H, 7CH,0BBH,0C0H, 07H
159 DB 8EH,0DBH,0A0H, 10H, 00H,0F7H
160 DB 26H, 16H, 00H, 03H, 06H, 0EH
161 DB 00H, 50H, 91H,0B8H, 20H, 00H
162 DB 0F7H, 26H, 11H, 00H, 8BH, 1EH
163 DB 0BH, 00H, 03H,0C3H, 48H,0F7H
164 DB 0F3H, 50H, 03H,0C1H,0A3H, 08H
165 DB 02H,0B8H, 00H, 10H, 8EH,0C0H
166 DB 33H,0DBH, 58H,0A2H, 07H, 02H
167 DB 8FH, 06H, 00H, 02H,0C7H, 06H
168 DB 02H, 02H, 00H, 00H,0E8H, 8AH
169 DB 00H, 33H,0DBH, 8BH, 0EH, 11H
170 DB 00H, 8BH,0FBH, 51H,0B9H, 0BH
171 DB 00H,0BEH,0ECH, 01H,0F3H,0A6H
172 DB 59H, 74H, 05H, 83H,0C3H, 20H
173 DB 0E2H,0EDH,0E3H, 4CH, 26H, 8BH
174 DB 47H, 1CH, 33H,0D2H,0F7H, 36H
175 DB 0BH, 00H,0FEH,0C0H,0A2H, 07H
176 DB 02H, 26H, 8BH, 57H, 1AH, 4AH
177 DB 4AH,0A0H, 0DH, 00H, 32H,0E4H
178 DB 0F7H,0E2H, 03H, 06H, 08H, 02H
179 DB 83H,0D2H, 00H,0A3H, 00H, 02H
180 DB 89H, 16H, 02H, 02H,0BBH, 00H
181 DB 20H, 8EH,0C3H, 33H,0DBH, 06H
182 DB 53H,0E8H, 39H, 00H, 8BH, 1EH
183 DB 08H, 02H, 8AH, 16H, 24H, 00H
184 DB 8DH, 36H, 0BH, 00H,0B8H, 00H
185 DB 10H, 8EH,0C0H, 33H,0FFH, 32H
186 DB 0F6H,0CBH,0BEH, 93H, 01H,0EBH
187 DB 03H,0BEH, 73H, 01H,0E8H, 09H
188 DB 00H,0BEH,0B8H, 01H,0E8H, 03H
189 DB 00H,0FBH,0EBH,0FEH,0ACH, 0AH
190 DB 0C0H, 74H, 09H,0B4H, 0EH,0BBH
191 DB 07H, 00H,0CDH, 10H,0EBH,0F2H
192 DB 0C3H,0A1H, 00H, 02H, 8BH, 16H
193 DB 02H, 02H, 03H, 06H, 1CH, 00H
194 DB 13H, 16H, 1EH, 00H,0F7H, 36H
195 DB 18H, 00H,0FEH,0C2H, 88H, 16H
196 DB 06H, 02H, 33H,0D2H,0F7H, 36H
197 DB 1AH, 00H, 88H, 16H, 25H, 00H
198 DB 0A3H, 04H, 02H,0A1H, 18H, 00H
199 DB 2AH, 06H, 06H, 02H, 40H, 50H
200 DB 0B4H, 02H, 8BH, 16H, 04H, 02H
201 DB 0B1H, 06H,0D2H,0E6H, 0AH, 36H
202 DB 06H, 02H, 8BH,0CAH, 86H,0E9H
203 DB 8BH, 16H, 24H, 00H,0CDH, 13H
204 DB 58H, 72H, 98H, 28H, 06H, 07H
205 DB 02H, 76H, 11H, 01H, 06H, 00H
206 DB 02H, 83H, 16H, 02H, 02H, 00H
207 DB 0F7H, 26H, 0BH, 00H, 03H,0D8H
208 DB 0EBH, 9FH,0C3H, 1DH, 00H, 41H
209 DB 20H, 64H, 69H, 73H, 6BH, 20H
210 DB 72H, 65H, 61H, 64H, 20H, 65H
211 DB 72H, 72H, 6FH, 72H, 20H, 6FH
212 DB 63H, 63H, 75H, 72H, 72H, 65H
213 DB 64H, 2EH, 0DH, 0AH, 00H, 22H
214 DB 00H, 54H, 68H, 65H, 20H, 66H
215 DB 69H, 6CH, 65H, 20H, 4FH, 53H
216 DB 32H, 4CH, 44H, 52H, 20H, 63H
217 DB 61H, 6EH, 6EH, 6FH, 74H, 20H
218 DB 62H, 65H, 20H, 66H, 6FH, 75H
219 DB 6EH, 64H, 2EH, 0DH, 0AH, 00H
220 DB 33H, 00H, 49H, 6EH, 73H, 65H
221 DB 72H, 74H, 20H, 61H, 20H, 73H
222 DB 79H, 73H, 74H, 65H, 6DH, 20H
223 DB 64H, 69H, 73H, 6BH, 65H, 74H
224 DB 74H, 65H, 20H, 61H, 6EH, 64H
225 DB 20H, 72H, 65H, 73H, 74H, 61H
226 DB 72H, 74H, 0DH, 0AH, 74H, 68H
227 DB 65H, 20H, 73H, 79H, 73H, 74H
228 DB 65H, 6DH, 2EH, 0DH, 0AH, 00H
229 DB 4FH, 53H, 32H, 4CH, 44H, 52H
230 DB 20H, 20H, 20H, 20H, 20H, 00H
231 DB 00H, 00H, 00H, 00H, 00H, 00H
232 DB 55H,0AAH
233
234EndData LABEL BYTE
235_RMFlags DD 0
236_RM_Help0 DD 0
237_RM_Help3 DD 0
238
239ddName DB 'VFDISK.SYS',00H
240ddDesc DB 'Virtual Floppy Disk Driver',00H
241ddVendor DB 'Daniela Engert (Lars Erdmann)',00H
242
243dStruct DRIVERSTRUCT <ddName,ddDesc,ddVendor,_VERMAJOR,_VERMINOR,<_YEAR,_MONTH,_DAY>,DRF_STATIC,DRT_OS2,DRS_BLOCK,0>
244hDriver DD 0
245
246_DATA ENDS
247
248CONST SEGMENT BYTE PUBLIC USE16 'CONST'
249CONST ENDS
250
251_BSS SEGMENT BYTE PUBLIC USE16 'BSS'
252_BSS ENDS
253
254DGROUP GROUP _DATA,CONST,_BSS
255
256
257
258
259;------------------------------------------------------------ _TEXT
260
261_TEXT SEGMENT PARA PUBLIC USE16 'CODE'
262 ASSUME CS:_TEXT, DS:_DATA
263
264
265;==========================================================================
266; Strategy
267;==========================================================================
268
269Strategy PROC FAR
270 PUSH BP
271 MOV BP,SP
272 AND SP,NOT 3
273 PUSH ESI
274 PUSH EDI
275 MOV DI, OFFSET DD_Table
276 MOV AL, BYTE PTR ES:[BX+2]
277 CBW
278 CMP AL, [DI]
279 JLE LOC_1
280 MOV AL, [DI]
281LOC_1:
282 ADD AX, AX
283 ADD DI, AX
284 CALL WORD PTR [DI + 1]
285 OR AX, 100h
286 MOV ES:[BX+3], AX
287 POP EDI
288 POP ESI
289 MOV SP,BP
290 POP BP
291 RET
292Strategy ENDP
293
294
295;==========================================================================
296; NotSupported
297;==========================================================================
298
299NotSupported PROC NEAR
300 MOV AX, 8103H
301 RET
302NotSupported ENDP
303
304
305;==========================================================================
306; GetSetDriveMap
307;==========================================================================
308
309GetSetDriveMap PROC NEAR
310 MOV BYTE PTR ES:[BX+1], 0
311 XOR AX, AX
312 RET
313GetSetDriveMap ENDP
314
315
316;==========================================================================
317; Open
318; Close
319; RemovableMedia
320; MediaCheck
321;==========================================================================
322
323MediaCheck PROC NEAR
324 MOV AL, [MediaStatus]
325 MOV ES:[BX+0EH], AL
326Open:
327Close:
328RemovableMedia:
329 XOR AX, AX
330 RET
331MediaCheck ENDP
332
333
334;==========================================================================
335; ResetMedia
336;==========================================================================
337
338ResetMedia PROC NEAR
339 MOV [MediaStatus], 1
340 XOR AX, AX
341 RET
342ResetMedia ENDP
343
344
345;==========================================================================
346; BuildBPB
347;==========================================================================
348
349BuildBPB PROC NEAR
350 MOV AX, [pBPB]
351 MOV ES:[BX+12H], AX
352 MOV ES:[BX+14H], DS
353 XOR AX, AX
354 RET
355BuildBPB ENDP
356
357
358;==========================================================================
359
360SectorToAddress PROC NEAR
361 MOVZX EAX, [thisSector]
362 MOVZX ECX, [BPB.BpSector]
363 MUL ECX
364 MOV EDI, [lAddr]
365 ADD EDI, EAX
366 RET
367SectorToAddress ENDP
368
369;==========================================================================
370
371GetRWParameters PROC NEAR
372 MOV AX, ES:[BX+14H]
373 MOV [thisSector], AX
374 MOV AX, ES:[BX+12H]
375 MOV [numSectors], AX
376 MOV EAX, ES:[BX+0EH]
377 MOV [Buffer], EAX
378 MOV [curSector], 0
379 MOV [isIOCtl], 0
380 RET
381GetRWParameters ENDP
382
383;==========================================================================
384
385
386GetIOCtlParms PROC NEAR
387 PUSH ES
388 PUSH BX
389 MOV EAX, ES:[BX+13H]
390 MOV [Buffer], EAX
391 LES BX, ES:[BX+0FH]
392 MOV AX, ES:[BX+3] ; Cylinder
393 SHL AX, 1
394 ADD AX, ES:[BX+1] ; Head
395 MUL BYTE PTR [BPB.SpTrack]
396 ADD AX, ES:[BX+5] ; first Sector
397 MOV [thisSector], AX
398 MOV AX, ES:[BX+7]
399 MOV [numSectors], AX
400 MOV [curSector], 0
401 MOV [isIOCtl], 1
402 POP BX
403 POP ES
404 RET
405GetIOCtlParms ENDP
406
407;==========================================================================
408; Read
409;==========================================================================
410
411Read PROC NEAR
412 CMP [MemAllocated], 0
413 MOV AX, 8107H
414 JE Read_Exit
415 CMP [MediaStatus], 0FFH
416 MOV AX, 8110H
417 JE Read_Exit
418
419 PUSH ES
420 PUSH BX
421
422 CALL GetRWParameters
423 CALL DoRead
424
425 POP BX
426 POP ES
427 MOV AX, [curSector]
428 MOV ES:[BX+12H], AX
429 XOR AX, AX
430Read_Exit:
431 RET
432Read ENDP
433
434DoRead PROC NEAR
435 MOV AX, [curSector]
436 CMP AX, [numSectors]
437 JE DoRead_Exit
438
439 CALL SectorToAddress
440 MOV ESI, EDI
441 CMP [isIOCtl], 1
442 JE DoRead_IOCtl
443 MOV BX, [BufferLow]
444 MOV AX, [BufferHigh]
445 MOV CX, [BPB.BpSector]
446 MOV DX, DevHlp_PhysToVirt + 100h
447 CALL [_Device_Help]
448 JMP DoRead_Move
449DoRead_IOCtl:
450 LES DI, [Buffer]
451DoRead_Move:
452 MOV FS, [FlatSel]
453 MOVZX EDI, DI
454 MOV ECX, 512 / 4
455 CLD
456 REP MOVS DWORD PTR ES:[EDI], FS:[ESI]
457
458 INC [thisSector]
459 ADD [Buffer], 512
460 INC [curSector]
461 JMP DoRead
462DoRead_Exit:
463 RET
464DoRead ENDP
465
466
467;==========================================================================
468; Write
469;==========================================================================
470
471Write PROC NEAR
472 CMP [MemAllocated], 0
473 MOV AX, 8102H
474 JE Write_Exit
475 CMP [MediaStatus], 0FFH
476 MOV AX, 8110H
477 JE Write_Exit
478
479 PUSH ES
480 PUSH BX
481
482 CALL GetRWParameters
483 CALL DoWrite
484
485 POP BX
486 POP ES
487 MOV AX, [curSector]
488 MOV ES:[BX+12H], AX
489 XOR AX, AX
490Write_Exit:
491 RET
492Write ENDP
493
494DoWrite PROC NEAR
495 MOV AX, [curSector]
496 CMP AX, [numSectors]
497 JAE DoWrite_Exit
498
499 CALL SectorToAddress
500 MOV ES, [FlatSel]
501 PUSH DS
502 CMP [isIOCtl], 1
503 JE DoWrite_IOCtl
504 MOV BX, [BufferLow]
505 MOV AX, [BufferHigh]
506 MOV CX, [BPB.BpSector]
507 MOV DX, DevHlp_PhysToVirt
508 CALL [_Device_Help]
509 JMP DoWrite_Move
510DoWrite_IOCtl:
511 LDS SI, [Buffer]
512DoWrite_Move:
513 MOVZX ESI, SI
514 MOV ECX, 512 / 4
515 CLD
516 REP MOVS DWORD PTR ES:[EDI], DS:[ESI]
517 POP DS
518
519 INC [thisSector]
520 ADD [Buffer], 512
521 INC [curSector]
522 JMP DoWrite
523DoWrite_Exit:
524 RET
525DoWrite ENDP
526
527
528;==========================================================================
529; GenIOCtl
530;==========================================================================
531
532GenIOCtl PROC NEAR
533 PUSH ES
534 PUSH BX
535 MOV AX, 8103H
536 MOV CX, ES:[BX+0DH]
537 CMP CL, 8
538 JNE GenIOCtl_Exit
539 CMP CH, 63H
540 JE IOCtl_63
541 CMP CH, 44H
542 JE IOCtl_44
543 CMP CH, 64H
544 JE IOCtl_64
545 CMP CH, 0FEH
546 JE IOCtl_FE
547 CMP CH, 0FFH
548 JE IOCtl_FF
549 JMP GenIOCtl_OK
550IOCtl_44:
551 CMP [MemAllocated], 0
552 MOV AX, 8102H
553 JE GenIOCtl_Exit
554
555 CALL GetIOCtlParms
556
557 MOV [MediaStatus], 0FFH
558 CALL DoWrite
559GenIOCtl_OK:
560 XOR AX, AX
561GenIOCtl_Exit:
562 POP BX
563 POP ES
564 RET
565
566IOCtl_64:
567 CMP [MemAllocated], 0
568 MOV AX, 8102H
569 JE GenIOCtl_Exit
570 CALL GetIOCtlParms
571 CALL DoRead
572 JMP GenIOCtl_OK
573
574IOCtl_63:
575 MOV AX, ES:[BX+15H]
576 MOV DI, ES:[BX+13H]
577 MOV CX, SIZE BPB_1440
578 MOV DH, 1
579 MOV DL, DevHlp_VerifyAccess
580 CALL [_Device_Help]
581 MOV AX, 810CH
582 JC GenIOCtl_Exit
583 LES DI, DWORD PTR ES:[BX+13H]
584 MOV SI, [pBPB]
585 CLD
586 REP MOVSB
587 JMP GenIOCtl_OK
588
589IOCtl_FF:
590 PUSH ES
591 PUSH BX
592 MOV [MediaStatus], 0FFH
593 CMP [MemAllocated], 0
594 JE LOC_29
595
596 MOV EAX, [lAddr]
597 MOV DL, DevHlp_VMFree
598 CALL [_Device_Help]
599 MOV [MemAllocated], 0
600LOC_29:
601 POP BX
602 POP ES
603 LES BX, DWORD PTR ES:[BX+0FH]
604 MOV AL, ES:[BX]
605 CALL SetImageType
606 OR AX, AX
607 JZ GenIOCtl_Exit
608 MOV AX, 810CH
609 JMP GenIOCtl_Exit
610
611IOCtl_FE:
612 MOV AX, ES:[BX+15H]
613 MOV DI, ES:[BX+13H]
614 MOV CX, 1
615 MOV DH, 1
616 MOV DL, DevHlp_VerifyAccess
617 CALL [_Device_Help]
618 MOV AX, 810CH
619 JC GenIOCtl_Exit
620 LES DI, DWORD PTR ES:[BX+13H]
621 MOV AL, [MemAllocated]
622 MOV ES:[DI], AL
623 JMP GenIOCtl_OK
624GenIOCtl ENDP
625
626
627;==========================================================================
628; BuildImage
629;==========================================================================
630
631BuildImage PROC NEAR
632 MOV AL, [BPB.numFATs]
633 MUL BYTE PTR [BPB.SpFAT]
634 ADD AX, [BPB.ResSectors]
635 MUL [BPB.BpSector]
636 PUSH AX
637
638 MOVZX ECX, [BPB.numRootDirs]
639 SHL CX, 5
640 ADD CX, AX
641
642 LES EDI, [pMem]
643 XOR AX, AX
644 CLD
645 REP STOS BYTE PTR ES:[EDI]
646
647 MOV EDI, [lAddr]
648 MOV ESI, OFFSET BootSectorProto
649 MOV CX, 512 / 2
650 REP MOVS WORD PTR ES:[EDI], DS:[ESI]
651
652 MOV AX, [BPB.ResSectors]
653 DEC AX
654 MUL [BPB.BpSector]
655 MOVZX EAX, AX
656 ADD EDI, EAX
657
658 MOVZX ECX, [BPB.numFATs]
659InitFATs:
660 MOV AL, [BPB.MediaDesc]
661 MOV ES:[EDI], AL
662 MOV WORD PTR ES:[EDI+1], 0FFFFH
663
664 DEC ECX
665 JCXZ InitFATs_exit
666
667 MOVZX EAX, [BPB.SpFat]
668 MUL [BPB.BpSector]
669 ADD EDI, EAX
670
671 JMP InitFATs
672InitFATs_exit:
673
674 POP DI
675 MOVZX EDI, DI
676 ADD EDI, [lAddr]
677 MOV SI, OFFSET VolumeLabel
678 MOV CX, VolumeLabelSize / 2
679 REP MOVS WORD PTR ES:[EDI], DS:[ESI]
680 RET
681BuildImage ENDP
682
683
684;==========================================================================
685; SetImageType
686;==========================================================================
687
688SetImageType PROC NEAR
689 PUSH ES
690 PUSH BX
691 CMP AL, 6
692 JBE SetImageType1
693 MOV AL, 1
694SetImageType1:
695 MOV [MemAllocated], AL
696 XOR AH, AH
697 OR AL, AL
698 JZ SetImageTypeExit
699
700 DEC AL
701 IMUL AX, SIZE BPB_1440
702 ADD AX, OFFSET BPB_Table
703 MOV [pBPB], AX
704 XCHG AX, SI
705 MOV AX, DS
706 MOV ES, AX
707 MOV DI, OFFSET BPB
708 MOV CX, SIZE BPB
709 CLD
710 REP MOVSB
711
712 MOVZX EAX, [BPB.BpSector]
713 MOVZX EDX, [BPB.numSectorsW]
714 MUL EDX
715 MOV ECX, EAX
716 XOR EAX, EAX
717 MOV EDI, EAX
718 DEC EDI
719 MOV AX, 2 + 2048 ; try with VMDHA_USEHIGHMEM flag
720 MOV DL, DevHlp_VMAlloc
721 CALL [_Device_Help]
722 JNC AllocateSuccess
723
724 MOVZX EAX, [BPB.BpSector]
725 MOVZX EDX, [BPB.numSectorsW]
726 MUL EDX
727 MOV ECX, EAX
728 XOR EAX, EAX
729 MOV EDI, EAX
730 DEC EDI
731 MOV AL, 2 ; try without VMDHA_USEHIGHMEM flag
732 MOV DL, DevHlp_VMAlloc
733 CALL [_Device_Help]
734 JC AllocateError
735
736AllocateSuccess:
737 MOV [lAddr], EAX
738 CALL BuildImage
739
740 XOR AX, AX
741 JMP SetImageTypeExit
742AllocateError:
743 MOV [MemAllocated], 0
744SetImageTypeExit:
745 POP BX
746 POP ES
747 RET
748SetImageType ENDP
749
750
751;==========================================================================
752; Init
753;==========================================================================
754
755Init PROC NEAR
756 MOV EAX, ES:[BX+0EH]
757 MOV [_Device_Help], EAX
758 MOV AL, ES:[BX+16H]
759 ADD BYTE PTR [MsgDriveLetter], AL
760 PUSH ES
761 PUSH BX
762 LES BX, ES:[BX+12H]
763 MOV AL, 1
764LOC_40:
765 INC BX
766 CMP BYTE PTR ES:[BX], 0
767 JE LOC_42
768 CMP BYTE PTR ES:[BX], 20H
769 JNE LOC_40
770LOC_41:
771 INC BX
772 CMP BYTE PTR ES:[BX], 20H
773 JE LOC_41
774 MOV AL, ES:[BX]
775 SUB AL, '0'
776LOC_42:
777 CALL SetImageType
778 PUSH AX
779
780 PUSH StdOut
781 PUSH MsgBootLen
782 PUSH DS
783 PUSH OFFSET MsgBoot
784 CALL DOSPUTMESSAGE
785
786 POP AX
787 POP BX
788 POP ES
789 OR AX, AX
790 JNE Init_Error
791
792 PUSH ES
793 PUSH BX
794 PUSH DS
795 PUSH OFFSET hDriver
796 PUSH DS
797 PUSH OFFSET dStruct
798 CALL _RMCreateDriver
799 ADD SP,8
800 POP BX
801 POP ES
802
803 MOV BYTE PTR ES:[BX+0DH], 1
804 MOV WORD PTR ES:[BX+12H], OFFSET pBPB
805 MOV ES:[BX+14H], DS
806 MOV WORD PTR ES:[BX+0EH], OFFSET Init - 1
807 MOV WORD PTR ES:[BX+10H], OFFSET EndData - 1
808 XOR AX,AX
809 RET
810Init_Error:
811 PUSH StdOut
812 PUSH MsgAbortLen
813 PUSH DS
814 PUSH OFFSET MsgAbort
815 CALL DOSPUTMESSAGE
816
817 MOV BYTE PTR ES:[BX+0DH], 0
818 MOV WORD PTR ES:[BX+0EH], 0
819 MOV WORD PTR ES:[BX+10H], 0
820 MOV AX, 8115H ; return with non-critical error if something goes wrong
821 RET
822Init ENDP
823
824_TEXT ENDS
825 END
826
827RMCode SEGMENT PARA PUBLIC USE16 'CODE'
828RMCode ENDS
829
830CGROUP GROUP _TEXT,RMCode
831
832
833
Note: See TracBrowser for help on using the repository browser.