⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 test.inc

📁 TestOS - 带简单GUI的DOS扩展OS// 源代码// ASM// 英文
💻 INC
字号:
port = 0x170
command = 0xa0

AtaPi_Id_Drive:
;-------------------------------------------------------
        mov dx,3f6h
	mov al,00000010b	; this clears INTRQ asserting by the HDD. Must be done before anything else if you don't want to receive IRQ from HDD.
	out dx,al
             
	call hdd_wait_ready 

	mov dx,6h 		; DH - Drive Head register
        ;mov   dx,0x7
        add   dx,word [port]
	mov al,0 ;       10100000b	; put appropriate info in drive/head register - 
	out dx,al

	call hdd_wait_ready 

	;mov dx,01f7h		; Command register when writing
        mov   dx,0x7
        add   dx,word [port]
	;mov eax,0ech		; Identify drive command
         mov   al,byte [command] 
	out dx,eax

	call hdd_wait_ready 

;-
        mov   dx,0x0                                    ; Read date/write = 0              
        add   dx,word [port]                            ; Add the base
        mov   si,packet                                 ; Point esi to how 12 byte packet
        xor   cx,cx                                     ; 0 cx  
        mov   cx,6                                      ; Mov number of words to mov into cx
WritePacket1_1:                                
        lodsw                                           ; Mov a word from packet to ax, inc esi 2
        out   dx,ax                                     ; Write ax to port (register)
        loop  WritePacket1_1                            ; Loop label

        mov   cx,0xffff                                 ; Mov cx, number of loops
        mov   dx,0x7                                    ; Read status = 7 
        add   dx,word [port]

        call hdd_wait_ready 
ret

;------------------------------------------------------
hdd_wait_ready:	
	mov ecx,512
wait1:
	dec ecx
	jnz wait1
	

	mov dx,3f6h
wait2:
	in al,dx
	and al,80h
	jnz wait2
	;mov dx,1f7h
        mov   dx,0x7
        add   dx,word [port]
	in al,dx
	ret

packet:
                        
		db 0x1b                    
		db 0x1                     
		db 0x0                     
                db 0x0                    
		db 0x2                     
		db 0x0
		db 0x0                     
		db 0x0                    
		db 0x0
		db 0x0
		db 0x0
                db 0x0   

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -