Ch 20 ¥úºÐ¾÷ (1)

¥úºÐ¾÷¦b 1990 ¦~¥N¤¤´Á´N¤w¸g¦¨¬°¹q¸£ªº¼Ð·Ç°t³Æ¡A¦ý¬O«o«Ü¤Ö¦³¤H´£¤Î¦³Ãö¥úºÐªºµ{¦¡»s§@¡A§Ú·Q­ì¦]¤£¥~¨â­Ó¡A¤å¥ó¨ú±o¤£©ö¤Î¹L©ó½ÆÂø¡A¤p¤ì°¸°Ñ¦ÒªQ±^¤½¥q©Ò¥Xª©ªL¯®»ö½sµÛªº ¡yCD-ROM¡NÁnÅQ¥d¡N¸ê°T¦w¥þµ¥¨ç¼Æ®w³]­p¡z¤@®Ñ¤Î²Ä¤Tªi²Ä 142¡N143 ´Á»¯¤å§Ó©Ò¼gªº¡yDOS ¤Uªº CD-AUDIO ¼½­µµ{¦¡¡z¤@¤å¥H¤Î¤¤¤s¬üÄR¤§®qºëµØ°Ï¥úºÐÅX°Ê­ì©l»¡©ú¤å¥óµ¥¤åÄm¡Aµo²{´X¥G¥H C »y¨¥¼¶¼g³o¨Çµ{¦¡¡A¬G¤p¤ì°¸·Q¥H³o¤@³¹¥H¤Î¤U¤@³¹µ¥¨â³¹ªº½g´T²³æ¤¶²Ð¦p¦ó¥H²Õ¦X»y¨¥¼½©ñ­µ¼Ö¥úºÐ¤Î±±¨î¥úºÐ¾÷¡C

¦b MS DOS ªºÀô¹ÒùØ¡A­n¨Ï¥Î¥úºÐ¥²¶·¦b CONFIG.SYS Àɮפ¤¥[¤J¥úºÐªºÅX°Êµ{¦¡¡A³o­ÓÅX°Êµ{¦¡³q±`¬O¥Ñ¼t°Ó´£¨Ñ¡A¬G¦WºÙ¤£¤Ó¬Û¦P¡A±z¥²¶·¬Ý¬Ý¼t°Óªº¨Ï¥Î»¡©ú®Ñ¡A¤£¹L¦]¬°¥úºÐ¾÷¤w¸g¬Û·í´¶¹M¤F¡A©Ò¥H¦U¼t°ÓªºÅX°Êµ{¦¡´X¥G³£¯à¬Û³q¡A¤p¤ì°¸¦b CONFIG.SYS ùتº¬O¡G

DEVICE=C:\AOATAPI.SYS /D:IDECD00 /P:170,15

°£¤F¦b CONFIG.SYS ùØ­n¦³ÅX°Êµ{¦¡¥~¡A¦b AUTOEXEC.BAT ÁÙ­n¦³ Microsoft ©Ò´£¨Ñªºµ{¦¡¿ë»{¡G

C:\DOS\MSCDEX /D:IDECD00 /L:M

­nª`·Nªº¬O¡A³o¨â­Óµ{¦¡ªº°Ñ¼Æ¡y/D:¡z«á­±±µªº¤å¦r¥²¶·¬Û¦P¡A¡y/L:¡z«á­±±µªº¬O¥úºÐ¾÷ªº½s¸¹¡A¦pªG¦¨¥\¡A¨º¦b DOS ©³¤Uªº¥úºÐ¾÷¼Ð¸¹´N¬O¡yM:¡z(´N¦n¹³³nºÐ¾÷¬O A: ¤@¼Ë)¡C

¦b²Õ¦X»y¨¥¤¤¨Ï¥Î¥úºÐ¡A­n©I¥s INT 2FH ¤¤Â_¡CINT 2FH ¤]¬OÄÝ©ó DOS ªA°Èµ{¦¡¡A¦ý¥¦¬O¥ÑÅX°Êµ{¦¡©Ò´£¨Ñªº¡A¹³ºô¸ô¡N¥úºÐ¾÷¡C¦]¬° INT 2FH ´£¨Ñ³\¦hºØ³]³ÆªºªA°Èµ{¦¡¡A¦]¦¹¨Ï¥Î¤W¸û¬°½ÆÂø¡A©³¤U¶È´N¥úºÐ¾÷ªº³¡¥÷»¡©ú¡C

AX=1500H/INT 2FH ¥úºÐ¦w¸ËÀˬd

·í­n¨Ï¥Î¥úºÐ¾÷®É¡A²Ä¤@¨B´N¬O­nÀˬd¥úºÐ¾÷¬O§_¦s¦b¡A±`¥ÎªºÀˬd¤è¦¡´N¬O¥Î INT 2FH ¤¤Â_¡C¦p¦P INT 21H ¤@¼Ë¡A INT 2FH ¤¤Â_¤]§â¤£¦Pªº¥\¯à©ñ¤J AH ¼È¦s¾¹¤¤¡A¦p¦³§ó²Ó¤Àªº¡y¤l¡z¥\¯à´N©ñ¤J AL ¤¤¡C¦b¦¹Àˬd¥úºÐ¾÷¥Î

mov     ax,1500h
mov     bx,0000
int     2fh

ªð¦^®É¡A¦pªG¦³¦w¸Ë¦n¥úºÐ¾÷«h BX ·|¦s¦³¥úºÐ¾÷¼Æ (¤£ºÞ±zªº¥úºÐ¾÷¬O IDE ¬É­±©Î SCSI ¬É­±¡A¦¹³B BX ¬O¥úºÐ¾÷Á`¼Æ)¡A¦Ó CX ·|¦s¦³²Ä¤@¥x¥úºÐ¾÷ªº½s¸¹¡A¦pªG²Ä¤@¥x¥úºÐ¾÷¬O A: «h CX ¬°¹s¡F¦pªG²Ä¤@¥x¥úºÐ¾÷¬O B: «h CX ¬°¤@¡A¨Ì¦¹Ãþ±À¡C¦pªG±z¨S¸Ë¥úºÐ¾÷¡A«h BX µ¥©ó¹s¡C

CMD=0C/0/5 AX=1510H/INT 2FH ±N¥úºÐ¾÷¦«½L¥´¶}©ÎÃö¤W

¥ý»¡§â¥úºÐ¾÷ªº¦«½L¥´¶}¡C­n§â¥úºÐ¾÷ªº¦«½L¥´¶}¡A¥²¶·¥ý³]©w¤@­ÓºÙ¬° device driver request header (ÅX°Ê¸Ë¸m½Ð¨DªíÀY) ªºµ²ºcÅé¡C³o­Óµ²ºcÅ骺Äæ¦ì¦p¤U¡G

¦ì§} ªø«× ·N¸q
00BYTE µ²ºcÅéªø«×¡A¥H¦ì¤¸²Õ¬°³æ¦ì
01BYTE subunit¡A³]¬° 0 §Y¥i
02BYTE ©R¥O½X¡A°Ñ¦Ò¦¹³B
03WORD ¥Ñ INT 2FH ªð¦^®Éªºª¬ºA¡A°Ñ¦Ò¦¹³B
05DWORD «O¯d¡A§¡³]¬° 0
09DWORD «O¯d¡A§¡³]¬° 0

³o­Ó device driver request header ·|ÀHµÛ©I¥s¥\¯à¦Ó¦³©Ò¤p´T«×ÅÜ°Ê¡A¦ý¬O¤W­±³o 13 ­Ó¦ì¤¸²Õ©Ò¥Nªíªº·N¸q¬O¤£·|Åܰʪº¡C

¶}±Ò¥úºÐ¦«½L¡A¬Û·í©ó¹q¸£¥D¾÷ªO¹ï¥úºÐ¾÷¿é¥X±±¨î©R¥O¡A¤]¥i¥H¬Ý¦¨±N±±¨î©R¥Oªº¸ê®Æ¶Ç°eµ¹¥úºÐ¾÷¡C°Ñ¦Òµù¤@±oª¾©R¥O½X¬° 0CH¡A·N«ä¬O IOCTL OUTPUT¡C¦n¤F¡A·í¥úºÐ¾÷¦¬¨ì³o­Ó device driver request header ¤§«á¡A¥Ñ©R¥O½X¡A0CH¡Aª¾¹D­n±µ¦¬¥Ñ¥D¾÷ªO¨Ó«ü¥O¤F¡A¦Ó³o¨Ç«ü¥O¬O¤°»ò©O¡H­ì¨Ó³o­Ó device driver request header ÁÙ¦³¤U¥b³¡¡A³o¤U¥b³¡±`·|ÀH¥\¯à¤£¦P¡A¦Ó¦³©ÒÅÜ°Ê¡C¶}±Ò¥úºÐ¾÷¦«½L¤U¥b³¡®æ¦¡¦p¤U¡G

¦ì§} ªø«× ·N¸q
0DBYTE ¥H«eºÙ´CÅé´y­z¤l (media descriptor)¡A¦ý¤w§ïºÙ¦ì§}
¼Ò¦¡ (address mode)¡A¦¹³B³]¬° 0 §Y¥i
0EDWORD ¶Ç°e¦ì§}¡A°Ï¬q¦ì§}¤Î°¾²¾¦ì§}
12WORD ©I¥s®É¡A¬°¶Ç°e¦ì¤¸²Õ¼Æ
ªð¦^®É¡A¬°¹ê»Ú¶Ç°e¦ì¤¸²Õ¼Æ

¦b device driver request header µ²ºcÅ骺 0EH ¶}©lªº¨â¦r²Õ©Ò«üªº¦ì§}³B¦³­n¥úºÐ¾÷°õ¦æªº©R¥O¸ê®Æ¡A¦Ó­n¶Ç°eªº¸ê®Æ¥i¥H¦³³\¦hºØ¡A°Ñ¦Òµù¤Tªí®æ±oª¾¬° 0 ´N¬O¨Ï¥úºÐ¾÷¦«½L¶}±Ò¡A¦Ó¥B¥u¦³¤@­Ó¦ì¤¸²Õ¡A©Ò¥H¨Ï device driver request header ªº²Ä 12H ¶}©lªº¦r²Õ¬° 1¡Aªí¥Ü©R¥Oªø«×¥u¦³¤@­Ó¦ì¤¸²Õ¡C¦¹¥~ÁÙ±o§ä¤@¶ô°O¾ÐÅé¡A¨äªø«×¬° 1 ­Ó¦ì¤¸²Õ¡A¥B¸Ó°O¾ÐÅé¼Æ­È¬° 0 (¨Æ¹ê¤W IOCTL OUTPUT ¦³³\¦h©R¥O¸ê®Æ¡A½Ð°Ñ¦Òµù¤T)¡C³Ì«á­pºâ device driver request header Á`ªø«×¬° 13H¡A©ñ¤J¦¹µ²ºcÅ骺²Ä¹s­Ó¦ì¤¸²Õ¡C

§â device driver request header ³£³]¦n¤§«á¡A¦A¨Ó¨Ï ES:BX «ü¦V device driver request header µ²ºcÅé¡A­n¶}±Ò¦«½Lªº¥úºÐ¾÷½s¸¹©ñ¦b CX ùØ¡A0 ªí¥Ü A:¡A1 ªí¥Ü B:¡A2 ªí¥Ü C:¡C¦A§â AX ³]©w¬° 1510H ªí¥Ü±N¥\¯à½Ð¨D¶Ç°eµ¹¸Ë¸m¡A³Ì«á©I¥s INT 2FH ¤¤Â_¡C¤U­±µ{¦¡²ÕĶ«á¡AÂà´«¦¨ *.COM ÀÉ¡A¥i¥H§â¥úºÐ¾÷ªº¦«½L¥´¶}¡A

ddrh    struc           ;¦ì§}---·N-----¸q-------
len     db      ?       ; 00 device driver request header ªø«×
subunit db      ?       ; 01 subunit¡A0
command db      ?       ; 02 ©R¥O½X
status  dw      ?       ; 03 ªð¦^ª¬ºA
revers1 dd      ?       ; 05 «O¯d¡A0
revers2 dd      ?       ; 09 «O¯d¡A0
media   db      ?       ; 0D ´CÅé´y­z¤l¡A0
trn_off dw      ?       ; 0E ¶Ç°e¸ê®Æ¦ì§}¡A°¾²¾¦ì§}
trn_seg dw      ?       ;    °Ï¬q¦ì§}
len_tr  dw      ?       ; 12 ¶Ç°e¸ê®Æªø«×
ddrh    ends
;***************************************
code    segment
        assume  cs:code,ds:code
        org     100h
;---------------------------------------
start:  jmp     begin
eject   ddrh    <13h,0,0ch,?,0,0,0,offset cd_ejt,?,1>
cd_ejt  db      0       ;¶}±Ò¥úºÐ¦«½Lªº©R¥O½X
cd_rom  dw      ?       ;¥úºÐ¾÷½s¸¹
begin:  mov     ax,1500h
        sub     bx,bx
        int     2fh
        mov     cd_rom,cx
        mov     ax,cs
        mov     eject.trn_seg,ax
        mov     ax,1510h
        mov     cx,cd_rom
        mov     bx,offset eject
        int     2fh
        int     20h
;---------------------------------------
code    ends
;***************************************
        end     start

­n¨Ï¥úºÐ¾÷¦«½LÃö¤W¡Adevice driver request header ©Ò¶ñ¤Jªº¼Æ­È¬Û¦ü¡A¥u¦³¶Ç°eªº©R¥O¤£¦P¡AÃö¤W¦«½Lªº©R¥Oªø«×¤]¬O¤@­Ó¦ì¤¸²Õ¡A¦ý¸Ó©R¥O¸ê®Æ¬° 5¡C(µù¤T)

CMD=0C/01 AX=1510H/INT 2FH ±N¥úºÐ¾÷¦«½LÂê¤W©Î¶}Âê

¥úºÐ¾÷¦«½LÂê¤Wªº·N«ä¬O¨Ï¥úºÐ¾÷­±ªOªº EJECT «öÁ䥢®Ä¡A¤]´N¬O«ö¤U³o­Ó«ö¶s¥úºÐ¾÷¤´¥´¤£¶}¡A¶}Âê´N¬O¸Ñ°£³o­Ó¥\¯à¡C­n¨Ï¥úºÐ¾÷Âê¤W¤]¬O­n¥Î device driver request header¡A©R¥O½X¤]¬O 0CH¡A¦ý¬O¶Ç°eªº©R¥O¸ê®Æ¬O 01¡A01 ¨â­Ó¦ì¤¸²Õ¡F¦Ó¶}Âê«h¬O¶Ç°e©R¥O¸ê®Æ 01¡A00 ¨â­Ó¦ì¤¸²Õ¡A¨£µù¤T¡A©R¥O¸ê®Æ½s¸¹ 1 ªº³¡¥÷¡C

device driver request header ªº²Ä 12H ¦ì¤¸²Õ¶}©lªº¤@­Ó¦r²Õ¬O©R¥O¸ê®Æªø«×¡A¥²¶·³]¬° 02¡F¦Ó²Ä 0EH ¦ì¤¸²Õ¶}©lªº¨â­Ó¦r²Õ¤À§O«ü¦V¶Ç°e©R¥O¸ê®Æ¦ì§}¡F²Ä 02H ¶}©lªº¤@­Ó¦ì¤¸²Õ¬O©R¥O½X 0CH¡C±N³o¨Ç³]¦n¤§«á¡ACX ³]©w¥úºÐ¾÷½s¸¹¡AAX ³]¬° 1510H¡AES:BX «ü¦V device driver request header¡A¦A©I¥s INT 2FH §Y¥i¡C¤U­±µ{¦¡¥i¥H§â¥úºÐ¾÷Âê¤W¡G

ddrh    struc           ;¦ì§}---·N-----¸q-------
len     db      ?       ; 00 device driver request header ªø«×
subunit db      ?       ; 01 subunit¡A0
command db      ?       ; 02 ©R¥O½X
status  dw      ?       ; 03 ªð¦^ª¬ºA
revers1 dd      ?       ; 05 «O¯d¡A0
revers2 dd      ?       ; 09 «O¯d¡A0
media   db      ?       ; 0D ´CÅé´y­z¤l¡A0
trn_off dw      ?       ; 0E ¶Ç°e¸ê®Æ¦ì§}¡A°¾²¾¦ì§}
trn_seg dw      ?       ;    °Ï¬q¦ì§}
len_tr  dw      ?       ; 12 ¶Ç°e¸ê®Æªø«×
ddrh    ends
;***************************************
code    segment
        assume  cs:code,ds:code
        org     100h
;---------------------------------------
start:  jmp     begin
lock_rq ddrh    <13h,0,0ch,?,0,0,0,offset cd_lock,?,2>
cd_lock db      1,1    ;Âê¤W¥úºÐ¦«½Lªº©R¥O¸ê®Æ
cd_rom  dw      ?      ;¥úºÐ¾÷½s¸¹
begin:  mov     ax,1500h
        sub     bx,bx
        int     2fh
        mov     cd_rom,cx
        mov     ax,cs
        mov     lock_rq.trn_seg,ax
        mov     ax,1510h
        mov     cx,cd_rom
        mov     bx,offset lock_rq
        int     2fh
        int     20h
;---------------------------------------
code    ends
;***************************************
        end     start

µù¤@¡G device driver ªº©R¥O½X
©R¥O½X »¡¡@¡@¡@¡@¡@©ú
¤Q¤»¶i¦ì ¤Q¶i¦ì
000 INIT
011 MEDIA CHECK (block devices)
022BUILD BPB (block devices)
033IOCTL INPUT
044INPUT
055NONDESTRUCTIVE INPUT, NO WAIT (character devices)
066INPUT STATUS (character devices)
077INPUT FLUSH (character devices)
088OUTPUT
099OUTPUT WITH VERIFY
0A10OUTPUT STATUS (character devices)
0B11OUTPUT FLUSH (character devices)
0C12IOCTL OUTPUT
0D13(DOS 3.0+) DEVICE OPEN
0E14(DOS 3.0+) DEVICE CLOSE
0F15(DOS 3.0+) REMOVABLE MEDIA (block devices)
1016(DOS 3.0+) OUTPUT UNTIL BUSY (character devices)
1117(European MS-DOS 4.0) STOP OUTPUT (console screen drivers only)
1218(European MS-DOS 4.0) RESTART OUTPUT (console screen drivers only)
1319(DOS 3.2+) GENERIC IOCTL
1420(DOS 4.0, KKCFUNC) DEVICE RESTORE (character device)
1521(European MS-DOS 4.0) RESET UNCERTAIN MEDIA FLAG
1622(DOS 4.0) unknown???
1723(DOS 3.2+) GET LOGICAL DEVICE
1824(DOS 3.2+) SET LOGICAL DEVICE
1925(DOS 5.0+) CHECK GENERIC IOCTL SUPPORT
80128(CD-ROM,DRFAT32) READ LONG
81129(CD-ROM) reserved
82130(CD-ROM,DRFAT32) READ LONG PREFETCH
83131(CD-ROM,DRFAT32) SEEK
84132(CD-ROM) PLAY AUDIO
85133(CD-ROM) STOP AUDIO
86134(CD-ROM,DRFAT32) WRITE LONG
87135(CD-ROM,DRFAT32) WRITE LONG VERIFY
88136(CD-ROM) RESUME AUDIO

µù¤G
¡Gdevice driver request header ªð¦^®É¡Aª¬ºA»¡©ú¡G
¦ì¤¸ »¡¡@¡@©ú
0F ¦pªG¿ù»~¡A¦¹¦ì¤¸³]¬°¤@¡A§_«h¬°¹s
0E-0B «O¯d¡A§¡¬°¹s
0A ¬Y¨Ç©I¥sÅX°Êµ{¦¡«á¡A¥Ñ DOS ³]©w
09 ¦£¸L®É³]¬°¤@
08 ©I¥s§¹¦¨
¦pªG¦ì¤¸ 0F ¬°¤@®É¡A07-00 ¦ì¤¸¬°¿ù»~½X
07 ¥¼ª¾ªº´CÅé
06 ´M§ä¿ù»~
05 ¿ù»~ªº¥\¯à½Ð¨D
04 CRC ¿ù»~
03 ¥¼ª¾©R¥O
02 ©|¥¼·Ç³Æ¦n
01 ¥¼ª¾ unit
00 ¼g¤J«OÅ@¿ù»~

µù¤T
¡G©R¥O¸ê®Æªº¼Ð¸¹¤Î»¡©ú¡G
©R¥O¸ê®Æ½s¸¹ ©R¥O¸ê®Æªø«× »¡¡@¡@©ú
01 ¶}±Ò¥úºÐ¾÷¦«½L
12 Âê¤W©Î¶}Âê¥úºÐ¾÷¦«½L
21 ­«¸m¥úºÐ¾÷
39 ­µÀW±±¨î
4? ?
51 Ãö¤W¥úºÐ¾÷¦«½L

¦^¨ì­º­¶¡A ¨ì²Ä¤Q¤E³¹¡A ¨ì²Ä¤G¤Q¤@³¹