[Kos-dev] ATA & LBA, more informations

Hervé Poussineau kos-dev@enix.org
Tue, 12 Feb 2002 21:39:45 +0100


Les lignes suivantes fonctionnent pour lire en LBA (sans interruption)

#define REG_DATA            0   /* data register (offset from the base reg.)
*/
#define REG_PRECOMP         1   /* start of write precompensation */
#define REG_COUNT           2   /* sectors to transfer */
#define REG_SECTOR          3   /* sector number */
#define REG_CYL_LO          4   /* low byte of cylinder number */
#define REG_CYL_HI          5   /* high byte of cylinder number */
#define REG_LDH             6   /* lba, drive and head */
#define   LDH_DEFAULT           0xA0    /* ECC enable, 512 bytes per sector
*/
#define   LDH_LBA               0x40    /* Use LBA addressing */
#define   ldh_init(drive)       (LDH_DEFAULT | ((drive) << 4))

#define REG_CTL         0x206   /* control register */
#define   CTL_NORETRY           0x80    /* disable access retry */
#define   CTL_NOECC             0x40    /* disable ecc retry */
#define   CTL_EIGHTHEADS        0x08    /* more than eight heads */
#define   CTL_RESET             0x04    /* reset controller */
#define   CTL_INTDISABLE        0x02    /* disable interrupts */


outp(hd_reg_base + REG_PRECOMP, 0);
outp(hd_reg_base + REG_COUNT, len);
outp(hd_reg_base + REG_SECTOR, (block >>  0) & 0xFF);
outp(hd_reg_base + REG_CYL_LO, (block >>  8) & 0xFF);
outp(hd_reg_base + REG_CYL_HI, (block >> 16) & 0xFF);
outp(hd_reg_base + REG_LDH, LDH_LBA | ldh_init(hd_hd) | ((block >> 24) &
0x7));
outp(hd_reg_base + REG_CTL, CTL_EIGHTHEADS | CTL_INTDISABLE); /* > a 8 tetes
*/

Hervé