RSS    

   Ðåôåðàò: Äðàéâåð æåñòêîãî äèñêà

         les     di, dword ptr request    ; çàíåñòè àäpåñ áëîêà äàííûõ

                                         ; â ES:DI

         mov     bl, es:[di+cmd_fld]     ; ïîëó÷èòü êîä êîìàíäû

         cmp     bl, num_cmd     ; äîïóñòèì ëè êîä êîìàíäû ?

         jle     bc_ok           ; ÄÀ --> bc_ok

         mov     ax, 8003h       ; êîä äëÿ "íåèçâåñòíîé êîìàíäû"

         jmp     short intr_end  ; âîçâpàò â âûçûâàþùóþ ïîäïpîãpàììó

         ; ------ åñëè êîä êîìàíäû êîppåêòåí, òî âûïîëíèòü êîìàíäó ---------

bc_ok:   shl     bl, 1           ; âû÷èñëèòü óêàçàòåëü â òàáëèöå ïåpåõîäîâ

         xor     bh, bh          ; î÷èñòèòü BH

         call    [fkt_tab+bx]    ; âûçîâ ôóíêöèè

         les     di, dword ptr request    ; çàíåñòè àäpåñ áëîêà äàííûõ

                                         ; â ES:DI                   

         ; ------ âûïîëíåíèå ôóíêöèè çàâåpøåíî -----------------------------

        

intr_end:push    cs              ; óñòàíîâèòü påãèñòp ñåãìåíòà äàííûõ

         pop     ds              ; çäåñü êîä èäåíòè÷åí äàííûì

         les     di, dword ptr request    ; çàíåñòè àäpåñ áëîêà äàííûõ

         or      ax, 0100h               ; óñòàíîâèòü áèò îêîí÷àíèÿ

         mov     es:[di+status], ax      ; çàïîìíèòü âñå â ïîëå ñîñòîÿíèÿ

         popf                            ; âîññòàíîâèòü påãèñòp ôëàãîâ

         pop     es                      ; âîññòàíîâèòü äpóãèå påãèñòpû

         pop     ds        

         pop     bp        

         pop     si        

         pop     di        

         pop     dx        

         pop     cx        

         pop     bx        

         pop     ax        

         ret                     ; âîçâpàò â âûçûâàþùóþ ïîäïpîãpàììó

intr     endp                      

init     proc    near            ; ïîäïpîãpàììà èíèöèàëèçàöèè

         mov dx, 3f6h

         xor al, al

         out dx, al        ;Turn off IRQ 14

         call waithd              ; sit back and relax…

         mov dx, 1f6h             ;SDH register

         mov al, 0a0h             ;Drive descriptor

         out dx, al

        

         mov dx, 1f2h             ;Sector count

         mov al, 1 

         out dx, al

        

         mov dx, 1f3h             ;Sector number

         mov al, 1 

         out dx, al

        

         mov dx, 1f4h      ;low cyl

         mov al, 0

         out dx, al

         mov dx, 1f5h      ;high cyl

         mov al, 0

         out dx, al ;New generation choose zero cyl.

        

         mov dx, 1f6h      ;1st head

         mov al, 1

         out dx, al

        

         mov dx, 1f7h      ;Status(Command) register

         mov al, 20h       ;Read Sector

         out dx, al

        

gword:   mov dx, 1f7h      ; Wait for data

         in al, dx

         test al, 8 ; 8th bit=1 - óñòð-âî çàíÿòî âûï-ì êîìàíäû

         jz gword

        

         mov cx, 256

         mov si, offset mbr

         mov dx, 1f0h      ;Get data

gloop:   in ax, dx

         mov [si], ax

         add si,2

         loop gloop

        

         call waithd       ; sit back and relax…

        

         mov dx, 3f6h      ;Turn on IRQ14 and exit

         mov al, 2

         out dx, al

        

         mov     al, es:[di+dev_des]    ; ïîëó÷èòü îáîçíà÷åíèå óñòpîéñòâà

         add     al, 'A'         ; ïpåîápàçîâàòü â áóêâû

         mov     im_ger, al      ; ñîõpàíèòü â ñîîáùåíèè îá óñòàíîâêå

         mov     dx, offset initm       ; àäpåñ ñîîáùåíèÿ îá óñòàíîâêå

         mov     ah, 9           ; âûâîä ñòpîêè

         int     21h            

         mov     word ptr es:[di+end_adr], offset diskdrv ; Óñòàíàâëèâàåì êîíå÷íûé àäðåñ äðàéâåðà

         mov     ax, cs

         mov     es:[di+end_adr+2], ax 

         mov     byte ptr es:[di+num_dev], 1   ; ïîääåpæèâàåòñÿ 1 óñòpîéñòâî

         mov     word ptr es:[di+bpb_adr], offset bpb_ptr ; àäpåñ óêàçàòåëÿ      

         mov     es:[di+bpb_adr+2], ds                    ; íà BPB

         mov     bpb_ptr+2, ds   ; ñåãìåíòíûé àäpåñ BPB â óêàçàòåëå íà BPB

         xor     ax, ax          ; âñå îòëè÷íî                  

         ret                     ; âîçâpàò â âûçûâàþùóþ ïpîãpàììó

init     endp

         ; -----------------------------------------------------------------

dummy    proc    near            ; New generation choose Pepsi

         xor     ax, ax          ; î÷èñòèòü áèò çàíÿòîñòè

         ret                     ; âîçâpàò â âûçûâàþùóþ ïîäïpîãpàììó

dummy    endp        

         ; -----------------------------------------------------------------

med_test proc    near

         mov     byte ptr es:[di+changed], 1

         xor     ax, ax          ; î÷èñòèòü áèò çàíÿòîñòè

         ret                     ; âîçâpàò â âûçûâàþùóþ ïîäïpîãpàììó

med_test endp        

         ; -----------------------------------------------------------------

get_bpb  proc    near            ; ïåpåäàòü DOS àäpåñ BPB

         mov     word ptr es:[di+bpb_adr], offset bpb

         mov     word ptr es:[di+bpb_adr+2], ds

         xor     ax, ax          ; î÷èñòèòü áèò çàíÿòîñòè

         ret                     ; âîçâpàò â âûçûâàþùóþ ïîäïpîãpàììó

get_bpb  endp

         ; -----------------------------------------------------------------

no_rem   proc    near            ; íîñèòåëü äèñêà ÿâëÿåòñÿ íåñìåíÿåìûì

         mov     ax, 20          ; óñòàíîâèòü áèò çàíÿòîñòè

         ret                     ; âîçâpàò â âûçûâàþùóþ ïîäïpîãpàììó

no_rem   endp

         ; -----------------------------------------------------------------

write    proc    near

         mov     bp, 30h          ; ïåpåñûëêà èç DOS â äèñê

         jmp     short   move    ; êîïèpîâàòü äàííûå

write    endp

read     proc    near

         mov     bp, 20h           ; ïåpåñûëêà èç äèñêà â DOS

read     endp

move     proc    near

         mov     bx, es:[di+num_rqst]     ; êîëè÷åñòâî ïpî÷èòàííûõ ñåêòîpîâ

         fild dword ptr es:[di+sector]  ; íîìåp ïåpâîãî ñåêòîpà

         fld1

         faddp st(1), st(0)                    ;sect+1

         fistp fsec

         les     di, es:[di+b_adr]      ; àäpåñ áóôåpà çàíåñòè â ES:DI

move_1:             ;âû÷èñëÿåì ôèç. ñåêòîð

   fild fsec ;load the number of the first sector to st(0)

         fild n63   ;load count of the phisycal sectors to st(0)

         fxch       ;you understand what I mean, that’s right?

         Fprem             ;st(0) mod st(1)

         fxch

         fcomp

         fistp n           ;save number of the phisycal sector

         mov al, byte ptr n

         mov sect, al

         fild fsec         ;âû÷èñëÿåì ãîëîâêó

         fisub n

         fidiv n63

         fist temp

         fild n255

         fxch

         fprem

         fxch

         fcomp

         fistp n           ;save number of head

         mov al, byte ptr n

         mov head, al

         fild temp  ; âû÷èñëÿåì öèëèíäð

         fisub n

         fidiv n255

 

         fistp n

         mov ax, word ptr n

         dec ax                  

         mov cyl, ax

                 

h_ok:    mov dx, 3f6h             ; Turn off IRQ14

         xor al, al

         out dx, al

        

         call waithd       ; sit back and relax…

         mov dx, 1f6h             ;SDH Register

         mov al, 0a0h

         out dx, al

        

         mov dx, 1f2h             ;Sector count

         mov al, 1

         out dx, al

        

         mov dx, 1f3h             ;Sector number

         mov al, sect;1

         out dx, al

         

         mov dx, 1f4h             ;Cyl. low

         mov al, byte ptr cyl;0

         out dx, al

         mov dx, 1f5h             ;Cyl. high

         mov al, byte ptr cyl+1;0

         out dx, al

        

         mov dx, 1f6h             ;SDH register

         mov al, head             ;1

         out dx, al

        

         mov dx, 1f7h             ;Status(command) register

         mov ax, bp        ;20h

         out dx, al

        

mword:   mov dx, 1f7h             ;wait for data

         in al, dx

         test al, 8        ; 8th bit=1 - óñòð-âî çàíÿòî âûï-ì êîìàíäû

         jz mword

        

         mov cx, 256

         mov dx, 1f0h

mloop:   cmp bp, 20h       ;Read or Write?

         jne wr

         in ax, dx

         mov es:[di], ax

         jmp short nx

wr:      mov ax,es:[di]

         out dx, ax

nx:      add di, 2

         loop mloop

        

         call waithd       ;æäåì-ñ

        

         mov dx, 3f6h      ;Turn on IRQ14

         mov al, 2

         out dx, al

         dec bx

         cmp bx, 0  ; êîëè÷åñòâî ïpî÷èòàííûõ ñåêòîpîâ = 0 ?

         je move_e  ;if equal, goto end

         fild fsec

         fld1

         faddp st(1), st(0)

         fistp fsec

         jmp move_1        

move_e:  xor     ax, ax          ; âñå îòëè÷íî                  

         mov di, si

         ret                     ; âîçâpàò â âûçûâàþùóþ ïpîãpàììó

move     endp

;------------Wait till not busy---------------

waithd:  mov dx, 1f7h

         in al, dx

         test al, 128      ;128=01000000b, it means that device is ready for R/W

         jnz waithd

         ret

diskdrv  equ     $

initm    db      "Your disk installed and ready to use"

im_ger   db      "?"

         db      ": $", 13, 10, 10

         ; -----------------------------------------------------------------

code     ends

         end


Ìèíèñòåðñòâî Îáðàçîâàíèÿ è Êóëüòóðû Êûðãûçñêîé Ðåñïóáëèêè

Êûðãûçñêèé Òåõíè÷åñêèé Óíèâåðñèòåò èì. È. Ðàççàêîâà.

Êàôåäðà Èíôîðìàòèêè è Âû÷èñëèòåëüíîé Òåõíèêè

Êóðñîâîé Ïðîåêò

ïî Îðãàíèçàöèè âû÷èñëèòåëüíûõ ïðîöåññîâ

íà òåìó: Ðàçðàáîòêà äðàéâåðà æåñòêîãî äèñêà

Âûïîëíèë:    ñò. ãð. ÝÂÌ-1-99 

     Ûéñàåâ Ó.Á.

Ïðèíÿëà:       äîö. Òîêìåðãåíîâà À.Ç.

Áèøêåê 2003.


Ñòðàíèöû: 1, 2, 3, 4, 5, 6


Íîâîñòè


Áûñòðûé ïîèñê

Ãðóïïà âÊîíòàêòå: íîâîñòè

Ïîêà íåò

Íîâîñòè â Twitter è Facebook

                   

Íîâîñòè

Îáðàòíàÿ ñâÿçü

Ïîèñê
Îáðàòíàÿ ñâÿçü
Ðåêëàìà è ðàçìåùåíèå ñòàòåé íà ñàéòå
© 2010.