|
Создание драйвера устройства
A een?eiaa 1
idaan?aaeai aeaeia n nen?a?ie ide nicaaiee adaeaada "DRIVER". U?i? oaee
anna?aeedoa?ny e eeieoa?ny eae iau?iay idiada??a, iinea ?aai idaiadacoa?ny a
aaie?iue .SYS oaee. Ca?a?o, ??i i?no?n?aea n?aea aey adaeaada yaeya?ny
iid?aeuiu? yaeaiea?, ?ae eae adaeaad ide daai?a eniieucoa? nian?aaiiue n?ae MS-
DOS. A ide?ada, ideaaaaiii? a een?eiaa 6-4, nicaaa?ny ?ae?a auoiaiie .LST
oaee anna?aeada e auoiaiie .MAP oaee daaae?ida naycae. Eiia?ii ?a, .OBJ e .EXE
oaeeu ?iao? au?u oaaeaiu iinea nicaaiey .SYS oaeea.
Microsoft Macro Assembler Version 4.00 0
Warning Errors Version 3.00 Copyright Microsoft Corp 1983,
1984, 1985 A een?eiaa 2 ideaaaai
ide?ad adaeaada RAM-aenea - adaeaada aed?oaeuiiai aenea, dac?auaa?iai a ICO.
Ian?i?dy ia nai? idin?i?o, adaeaad daai?iniiniaai e ?i?a? au?u eniieuciaai ia
e?aie MS-DOS nen?a?a ia?eiay n aadnee 2.0 e auoa. Aaiiue adaeaad RAM-aenea,
eniieucoa? 360 Kaae? nen?a?iie ia?y?e aey u?oeyoee n?aiaad?iiai iy?ea?e?iaiai
aeneiaiaa. Ii ide eniieuciaaiee u?iai adaeaada, nen?a?a IE aie?ia e?a?u ii
edaeiae ?ada 512 Kaae? ia?y?e. Anee e?aa?ny ?aiuoa ia?y?e eee io?ii idin?i e?a?u
aed?oaeuiue aene ?aiuoeo dac?adia, ?i ?i?ii ec?aie?u ideie?aa?ua ii o?ie?aie?
iada?a?du, iienaiua a naeoee adaeaada "Iienaiea RAM-aenea". Iinea ?iai, eae
idiada??a auea iadaai?aia anna?aeadi? e daaae?idi? naycae, iaai iadae?aiiaa?u aa
a RDISK.SYS. E aiaaae?u a oaee CONFIG.SYS ei?aiaio? n?dieo : Ide iadaie ?a iadacaadocea adaeaad aoaa? on?aiiaeai eae
adaeaad neaao?uaai ii iidyaeo aeneiaiaa. Ie?aai aieaa aey on?aiiaee adaeaada
RDISK ia ?daaoa?ny. Ain?oi e RAM-aeneo aic?i?ai n ii?iuu? e?auo ooieoee MS-
DOS eee idiada??, ca enee??aiea? ei?aia DISKCOPY e DISKCOMP. Iaa u?e idiada??u
i?eaa?? iidaaaeaiiua ?eiu aeneia e ia daai?a?? n RAM-aenea?e. ; *** RDISK.ASM : MS-
DOS ADAEAAD RAM-AENEA *** ; ; on?dien?a,
aee??ay iaei ec ?a?iaia, ei?idue ?i?ii eniieuciaa?u aey ; IFDEF
DEBUG ;
CMD_PRE_30 EQU 00Ch ; ai MS-DOS aadnee 3.00 CR
EQU 0Ah ; eniieuco??ny a i?eaai?iuo request EQU
es:[di] ; oeaca?aeu ia aeie caidina unit db ? ; ii?ad
on?dien?aa ; units db ?
; eiee?an?ai on?dien?a bpbtabs dw ? ; ?aaeeou
BPB mchkhdr STRUC volume dd
? ; oeaca?aeu ia e?y ?i?a db (type reqhdr) DUP (?)
bpbptrs dw ? ; naa?ai? BPB db (type reqhdr) DUP(?) start dw ? ; # ia?aeuiiai nae?ida
bpbstrc STRUC nrs dw ? ; eie-ai cadacadaed. nae?idia nls dw ? ;
eie-ai eiae?aneeo nae?idia ; =============
IA?AEI EIAA ADAEAADA ================
; ============= CAAIEIAIE ADAEAADA ============== dw offset STRATEGRY ;
n?auaiea N?DA?AAEE ; ======= ?AAEEOA AADANIA IADAAI??EEIA
EI?AIA ====== dw offset
BUILD_BPB ; 2 - iin?die?u BPB dw offset READ_NOWAIT ; 5 - iadacdoo.
aaia dw offset WRITE ; 8 - auaia ia on?d-ai dw offset OUTPUT_FLUSH ; B - nadine?u auaia dw offset
DEVICE_CLOSE ; E - caedu?u on?d-ai dw offset
NO_COMMAND ; 12 dw offset NO_COMMAND ; 16 ; ============ IAEAN?U AAIIUO ADAEAADA ============== save_ss dw ? ; cia?aiea SS ia aoiaa STRATEGY PROC FAR ;
============ IDIADA??A IDADUAAIEE ===============
push bp mov word ptr save_ss,ss ; niodaie?
aoiaiia mov ax,offset local_stack - 2 ; n?ae mov bl,request.command
; caidina e ei?aiao cmp
bl,[max_cmd] ; ei?aiaa iiaaad?eaaa?ny ? ;
Ea?aue iadaai??ee iieo?aa? oidaaeaiea n CS e DS on?aiiaeaiiu?e ia ; call print_command ; auaaa? e?y iadaaa?uaaa?ie ;
Iadaoea? n?a?on ec daaen?da AX a neiai nin?iyiey aeiea caidina les
di,[req_ptr] ; iieo?e? aadan aeiea caidina mov ss,word ptr save_ss
; ainn?aiiae? cia?aiea pop si ; ============ IADAAI??EEE EI?AIA ============== MEDIA_CHECK PROC NEAR ; 1 - idiaadea iine?aey
BUILD_BPB PROC NEAR ; 2 - iin?die?u BPB IOCTL_INPUT
PROC NEAR ; 3 - aaia IOCTL call verify ; idiaadea e on?aiiaea
iada?a?dia xor ax,ax ; ia? ioeaie ret INPUT_FLUSH PROC
NEAR ; 7 - nadine?u aoiaio? i?adaau call verify ; idiaadea e
on?aiiaea iada?a?dia lds si,request.bufptr ; caienuaaa? ec aooada wr_err: WRITE_VERIFY ENDP OUTPUT_FLUSH PROC NEAR ; B - nadine?u auoiaio? i?adaau IOCTL_OUTPUT DEVICE_CLOSE
PROC NEAR ; E - caedu?u on?dien?ai mov ax,ST_BUSY ; ia? ! GENERIC_IOCTL ENDP SET_LOGICAL PROC NEAR ; 18 - on?aiiae?u e?y eiae?aneiai ; ------------ Iiaidiada??u
iadaai?ee caidinia ----------------------- ;
ES:DI - niaad?e? aadan aeiea caidina ; Idaiadaciaaiea u?iai iada?a?da a
"naa?ai?:n?auaiea". ; DS:SI - niaad?e? aadan "nae?ida" a RAM-aenea verify PROC NEAR mov cx,request.start ; ndaaie? ii?ad
ia?aeuiiai add cx,request.count ; iaeaa? ii?ad eiia?iiai jb in_range ;
iid?aeuiua ?i idiaie?e? mov request.count,0 ;
ie?aai ia auei iadaaaii mov ax,bpb.bps ; eiee?an?ai
aae? a nae?ida mul request.start ; n?auaiea iadaadaoa i?iine- add ax,dx ; aanie??iia n?au. iadaadaoa mov ax,bpb.bps ;
dac?ad nae?ida a aae?ao ; audiaiya? n?a??ee a AX
aey idaai?adauaiey iadaedu?ey cmp cx,ax ;
aooada ; on?aiiae? eiee?an?ai iadaaaaaa?uo nae?idia e
n?a??ee iadaaa?e div bpb.bps ; (DX aue 0) eie-ai nae?idia xor si,si
INCLUDE biosio.asm NO_COMMAND_msg db 'NO
COMMAND',CR,LF,'$' BUILD_BPB_msg db 'Build BIOS Parameter
Block',CR,LF,'$' READ_NOWAIT_msg db 'Nondestructive Input no-
wait',CR,LF,'$' WRITE_msg db 'Output to
Device',CR,LF,'$' OUTPUT_FLUSH_msg db 'Flush
Output Queue',CR,LF,'$' DEVICE_CLOSE_msg db 'Close a
Device',CR,LF,'$' GET_LOGICAL_msg db
'Get Logical Device',CR,LF,'$' ; ===== ?AAEEOA AADANIA I?EAAI?IUO
NIIAUAIEE ===== dw offset MEDIA_CHECK_msg ; 02 - idiaadea iine?aey dw offset READ_msg ; 05 - aaia ec on?dien?aa dw offset INPUT_FLUSH_msg ; 08 - nadin aoiaiie i?adaae dw offset OUTPUT_STATUS_msg ; 11 - auaia n?a?ona dw offset DEVICE_OPEN_msg ; 14 - i?edu?u
on?dien?ai dw offset NO_COMMAND_msg ; 17 - dw offset
GENERIC_IOCTL_msg ; 20 - adoiiiaie IOCTL caidin dw
offset GET_LOGICAL_msg ; 24 - iieo?e?u e?y aenea ; U?a
idioaaoda aucuaaa? ooieoe? BIOS aey ia?a?e (_biosprt), iadaaaaay ; auciaa u?ie
idioaaodu oaaiaiiue eia ei?aiau iadaaaa?ny a daaen?da BX. push ax ; niodaie?
niaad?e?ia daa. AX mov ax,word ptr message_table[bx] ; aadan n?diee
pop ax ; ainn?aiaaeeaaa? AX e auoiae?
; bpb_tab dw offset bpb ; oeaca?aeu ia BPB ; Iada?a?du aey 5-1/4" aaon?idiiiaai aaieiie iei?iin?e aenea n
aaay?u? SECTORS EQU 9 ; 9 nae?idia ia
aidi?ea FSECS EQU 2 ; eiee?an?ai nae?idia a FAT
CLSIZ EQU 2 ; 2 nae?ida a eean?ada ;
******** IA?AEI IAEAN?E AAIIUO RAM-AENEA ********** ORG ($-ORIGIN) +
16 - (($-ORIGIN) mod 16) ; ------------ Aeie
iada?a?dia BIOS ---------------------------------- db 'IBM 3.1' ; 8
aae? e?y e aadney dw SECTORS ; eiee?an?ai
nae?idia ia aidi?ea db (DSIZE-30) DUP (?) ; in?a?ie
boot_sector FAT_1 db MTYPE,0FFh,0FFh ; ioeaaie
in?a?ie FAT db (DSIZE-3) DUP (0) ; ioeaaie
in?a?ie FAT ; dw
0600h ; ada?y 12:00:00 (iieaaiu) db (DSIZE-32) DUP (0) ; ioeaaie
in?a?ie aedae?idey ; ************ IDIOAAODA EIEOEAEECAOEE
************** $signon db 'RAM DISK Driver Version 1.00
Installed: Drive INIT PROC NEAR ; 00 -
eieoeaeecaoey mov request.endadro,0 ; aadan eiioa
adaeaada mov request.bpbtabo,offset
bpb_tab ; auaia ia uedai
eaai?eoeeaoeiiiie n?diee @GetDOSVersion ; iieo?e? ii?ad aadnee MS-
DOS mov [max_cmd],CMD_PRE_32 ; ei?aiau aey MS-DOS 3.00 mov [max_cmd],CMD_32 ; ei?aiau aey MS-DOS 3.20 ;
************ EIIAO ADAEAADA. EIIAO OAEEA ************
| |