OSDev.org

The Place to Start for Operating System Developers
It is currently Sat Apr 27, 2024 12:24 pm

All times are UTC - 6 hours




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: Ata interrupt never stops firing on real hardware
PostPosted: Sun Jun 11, 2023 11:59 pm 
Offline
User avatar

Joined: Sun Jun 11, 2023 11:02 am
Posts: 5
On virtual machines such as Qemu the IDE controller is in compatibility mode and uses these ports: 0x1F0, 0x170, and interrupts: IRQ14/IRQ15
To get my Ata driver to work on my real machine I had to scan the PCI to find the IDE controllers and then ports via the base address registers. That worked fine and I could now read from disk on real hardware. There is only one problem, Atapi requires interrupts so I need to get those working. By reading the interrupt line field on the PCI IDE controller I determined that IRQ11 is the one I should unmask.

When I unmask IRQ11 the entire system freezes. After changing the interrupt handler to writing a "B" on screen the screen gets compleatly filled over and over. By inserting wait statements in my Ata code I found that as soon as I issue an identify command (0xEC) I get an endless stream of IRQ11. I am a beginner, and I wounder if there is something curcial missing in my code?


Code in handler:

Code:
irq_handler_11:
  pushad

  mov al, 'B'
  mov ah, 0x0C
  push ax
  call write_char
 
  push word 0
  call update_screen
 
  push word 11
  call send_end_interrupt
 
  popad
 
  iret




Code for issuing Identify command:


Code:
ata_identify_master:
    mov dx, si
    add dx, 6
    mov al, 0xA0
    out dx, al ;Select drive
   
    jmp ata_identify_continue
 
  ata_identify_slave:
    mov dx, si
    add dx, 6
    mov al, 0xB0
    out dx, al ;Select drive
 
  ata_identify_continue:
    push 10 ;Make sure controller has time to process
    call wait_milliseconds
   
    ;Wiki says these should e set to 0
   
    ;(This could be written a bit shorter)
    mov dx, si
    add dx, 2
    mov al, 0
    out dx, al ;Set to 0

    mov dx, si
    add dx, 3
    mov al, 0
    out dx, al ;Set to 0
   
    mov dx, si
    add dx, 4
    mov al, 0
    out dx, al ;Set to 0
   
    mov dx, si
    add dx, 5
    mov al, 0
    out dx, al ;Set to 0

    ;Send identify command
    mov dx, si
    add dx, 7
    mov al, 0xEC
    out dx, al


Top
 Profile  
 
 Post subject: Re: Ata interrupt never stops firing on real hardware
PostPosted: Thu Jun 15, 2023 12:35 pm 
Offline
Member
Member

Joined: Mon Mar 25, 2013 7:01 pm
Posts: 5146
PCI interrupt lines are level-triggered and your interrupt handler is sending an EOI to the interrupt controller before acknowledging the hard disk.

There's a nice diagram on the wiki explaining the problem.

(You might recall programming the 8259 PICs to use edge-triggered interrupts, but the PICs ignore that bit for PCI interrupts.)


Top
 Profile  
 
 Post subject: Re: Ata interrupt never stops firing on real hardware
PostPosted: Sat Jun 17, 2023 11:18 am 
Offline
User avatar

Joined: Sun Jun 11, 2023 11:02 am
Posts: 5
Can't thank you enought, works flawlessly now :D


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Bing [Bot], WinExperements and 19 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group