floppy disk interrupt
Posted: Thu Nov 01, 2007 7:46 am
Hello,
I'm trying to write a floppy disk driver. The first problem that I've encountered is that the floppy interrupt isn't getting called. Here's parts of my code:
The interrupt handler:
I setup the idt entries like this:
I'm not sure if I should use INT_GATE or TRAP_GATE?
I initialize the pic like this:
I enable irqs like this:
Then I do:
Then I program the floppy disk controller
Documentation says that I should receive a floppy interrupt after doing that, but I don't.
I've tried on a real computer as well as on VMWare
timer and keyboard interrupts work just fine.
I hope someone can help me with this, thanks.
--
Sigurd Lerstad
I'm trying to write a floppy disk driver. The first problem that I've encountered is that the floppy interrupt isn't getting called. Here's parts of my code:
The interrupt handler:
Code: Select all
global _floppy_int
_floppy_int:
mov byte[0xb8000],'F'
mov byte[0xb8002],'L'
mov byte[0xb8004],'O'
mov byte[0xb8006],'P'
mov byte[0xb8008],'P'
mov byte[0xb800A],'Y'
jmp $
I setup the idt entries like this:
Code: Select all
load_idt_entry(32, timer_int, 8, 0x8E);
load_idt_entry(33, keyboard_int, 8, 0x8E);
load_idt_entry(38, floppy_int, 8, 0x8E/*BITS_32 | PRESENT | INT_GATE | RING_0*/);
I initialize the pic like this:
Code: Select all
void pic_init()
{
outb(MASTER_PORT_A, 0x11); // ICW 1
outb(SLAVE_PORT_A, 0x11); // 7 | 6 | 5 | 4 | 3 | 2 | 1 |
// 0 | 0 | 0 | 1 |Trig|M/S|ICW4|
// Master Slave Configuration
// IC4 needed
outb(MASTER_PORT_B, 0x20); // ICW 2
outb(SLAVE_PORT_B, 0x28); // INT 0x20-0x27 mapped to IRQ 0 to IRQ 7
// INT 0x28-0x2F mapped to IRQ 8 to IRQ 15
outb(MASTER_PORT_B, 0x04); // ICW 3
outb(SLAVE_PORT_B, 0x02); // IR 2 of master is connected to slave pic
// IRQ on master this slave is connected to
outb(MASTER_PORT_B, 0x01); // ICW 4
outb(SLAVE_PORT_B, 0x01); // Master, Fully Nested Mode
// Slave, Fully Nested Mode
outb(MASTER_PORT_B, 0xFF); // All interrupts except IRQ 0 are disabled
outb(SLAVE_PORT_B, 0xFF);
}
Code: Select all
void enable_irq(byte irq_num)
{
byte mask = 1 << irq_num;
irq_status_master |= mask;
outb(MASTER_PORT_B,(byte)~irq_status_master);
}
Code: Select all
#define FLOPPY 0x6
enable_irq(FLOPPY);
Code: Select all
#define FLOPPY_PRIMARY_BASE 0x03F0
#define DIGITAL_OUTPUT_REG 0x0002
#define DOR_ENABLE 0x04 /* enable controller (= !reset) */
#define DOR_IRQDMA 0x08 /* IRQ & DMA enabled */
outportb((base+DIGITAL_OUTPUT_REG),0x00); /*disable controller*/
outportb((base+DIGITAL_OUTPUT_REG), (DOR_ENABLE | DOR_IRQDMA)/*0x0c*/); /*enable controller*/
I've tried on a real computer as well as on VMWare
timer and keyboard interrupts work just fine.
I hope someone can help me with this, thanks.
--
Sigurd Lerstad