[Kos-dev] encore une IRQ !

kos-dev@enix.org kos-dev@enix.org
04 Feb 2002 12:36:43 +0100


salut,

je crois que le bout de code suivant fais exactement ce que tu as
indique en fin de ton precedent mail :


  /* Attendre que le controleur soit pret */
  while(inb(ioaddr + ATA_STATUS) & ATA_S_BSY)
    {
      printk("Status is 0x%x\n", inb(ioaddr + ATA_ALTPORT));
      usleep(1);
    }
  
  /* On lit le registre de status (a l'execution, il vaut bien 0x50) */
  printk("Status is 0x%x\n", inb(ioaddr + ATA_STATUS));

  /* On met nIEN a 1 dans device control */
  outb(ATA_A_nIEN | ATA_A_4BIT, ioaddr + ATA_DEVICE_CONTROL);
  usleep(1);
  /* => ET LA BING IRQ */

  /* on selectionne le device */
  outb(ATA_D_IBM | device, ioaddr + ATA_DRIVE);
  usleep(1);

  /* on attend que le controleur soit pret */
  while(inb(ioaddr + ATA_STATUS) & ATA_S_BSY)
    {
      printk("Status is 0x%x\n", inb(ioaddr + ATA_ALTPORT));
      usleep(1);
    }
  
  /* on affiche l'etat (a l'execution : 0x50) */
  printk("Status is 0x%x\n", inb(ioaddr + ATA_STATUS));

  /* on envoie la commande */
  printk("Sencind cmd\n");
  outb(ATA_C_ATA_IDENTIFY, ioaddr + ATA_CMD);

Et pourtant il y a bien generation d'une IRQ.

Une chose que je n'ai peut etre pas bien compris : la difference entre
le Status Register et le Alternate Status Register.

Voici mes #define pour que tu comprennes mieux :

#define ATA_MASTER                      0x00
#define ATA_SLAVE                       0x10

/* Registers */
#define ATA_DATA                        0x00    /* Data register */

#define ATA_ERROR                       0x01    /* (R) error register */

#define ATA_SECTOR_COUNT                0x02    /* sector count register */

#define ATA_SECTOR_NUMBER               0x03    /* sector number register */

#define ATA_CYL_LSB                     0x04    /* cylinder# LSB */

#define ATA_CYL_MSB                     0x05    /* cylinder# MSB */

#define ATA_DRIVE                       0x06
#define         ATA_D_IBM               0xa0

#define ATA_STATUS                      0x07    /* status register */
#define         ATA_S_ERROR             0x01    /* error */
#define         ATA_S_INDEX             0x02    /* index */
#define         ATA_S_CORR              0x04    /* data corrected */
#define         ATA_S_DRQ               0x08    /* data request */
#define         ATA_S_DSC               0x10    /* drive Seek Completed */
#define         ATA_S_DWF               0x20    /* drive write fault */
#define         ATA_S_DRDY              0x40    /* drive ready */
#define         ATA_S_BSY               0x80    /* busy */

#define ATA_CMD                         0x07    /* command register */
#define         ATA_C_ATA_IDENTIFY      0xec    /* get ATA params */
#define         ATA_C_ATAPI_IDENTIFY    0xa1    /* get ATAPI params*/
#define         ATA_C_READ              0x20    /* read command */
#define         ATA_C_WRITE             0x30    /* write command */
#define         ATA_C_READ_MULTI        0xc4    /* read multi command */
#define         ATA_C_WRITE_MULTI       0xc5    /* write multi command */
#define         ATA_C_SET_MULTI         0xc6    /* set multi size command */
#define         ATA_C_PACKET_CMD        0xa0    /* set multi size command */

#define ATA_ALTPORT                     0x206   /* alternate Status register */

#define ATA_DEVICE_CONTROL               0x206
#define         ATA_A_nIEN              0x02    /* disable interrupts */
#define         ATA_A_RESET             0x04    /* RESET controller */
#define         ATA_A_4BIT              0x08    /* 4 head bits */

Merci encore,

Thomas
-- 
PETAZZONI Thomas - thomas.petazzoni@enix.org - UIN : 34937744
(Perso)      http://www.enix.org/~thomas/
(KOS)        http://kos.enix.org/ 
(Club LinUT) http://club-linut.enix.org