Disabling interrupts on HDD

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Mikae
Member
Member
Posts: 94
Joined: Sun Jul 30, 2006 1:08 pm

Post by Mikae »

Well, I tried the following algorithm:

1. Set nIEN.
2. Set nIEN.
3. Clear nIEN.
4. Set nIEN.
5. Set nIEN.
6. Send IDENTIFY_DEVICE.

Interrupt has occured only at step 1. The code I used:

Code: Select all

org 0x0

 xor ax, ax
 mov ds, ax
 mov ss, ax
 mov sp, 0x7C00
 mov ax, 0xB800
 mov es, ax

 cli
 mov word [0x76 * 4], .hndlr
 mov word [0x76 * 4 + 2], 0x1000
 sti

 mov al, 0x0
 mov dx, 0x1F6
 out dx, al

 mov dx, 0x1F7
.wait_DRDY:
 in al, dx
 test al, 0x40
 mov word [es:0x2], 0x731
 jz .wait_DRDY
 mov word [es:0x2], 0x720

 mov dx, 0x1F7
 in al, dx
 nop
 nop
 nop
 nop

 mov dx, 0x3F6
 in al, dx
 nop
 nop
 nop
 nop

 mov al, 0x2
 out dx, al

 mov al, 0x2
 out dx, al

 xor al, al
 out dx, al

 mov al, 0x2
 out dx, al

 mov al, 0x2
 out dx, al

 mov dx, 0x1F7
 mov al, 0xEC
 out dx, al

 jmp $

.hndlr:
 mov dx, 0x1F7
 in al, dx
 mov ax, 0xB800
 mov es, ax
 push ds
 mov ax, 0x1000
 mov ds, ax
 inc word [counter]
 mov ax, [counter]
 mov [es:0x0], ax
 mov al, 0x20
 movzx dx, al
 out dx, al
 mov dx, 0xA0
 out dx, al
 pop ds
 iret
(It is loaded at segment 0x1000 by my loader). Character, printed in top-left cell is '1', it means, that interrupt handler was called only once.


Masterkiller
istead of MOV try OR-ing the AL and then write to 0x03F6.
Could you explain, what do you mean here?
User avatar
Masterkiller
Member
Member
Posts: 153
Joined: Sat May 05, 2007 6:20 pm

Post by Masterkiller »

Code: Select all

...
mov dx, 0x3F6
in al, dx
nop
nop
nop
nop

OR al, 0x2 ;This will set bit 1 (nEIN) and leave all other bits unchanged
out dx, al 
...
Mikae
Member
Member
Posts: 94
Joined: Sun Jul 30, 2006 1:08 pm

Post by Mikae »

Masterkiller

I'm definitely not sure about it. When you read device control register alternate status register is read. So, it is possible to write reserved bit when you write it back, or, even reset device, what is definitely not what you want.
Post Reply