1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
|
/********************************************************************************/
/* Function : issue_ata_command */
/* */
/* Description : Helper function that will issue the command to the device. */
/* This function addresses Task File registers to configure */
/* and start an operation. After completion of this function, */
/* the device is supposed to start an operation and then set */
/* an interrupt */
/* */
/* Inputs : s Statics structure */
/* nb_sectors Value to write in TaskFileRegister0[23:16] */
/* sector_id_lba LBA addressing value. This value, to split, */
/* is to be written in: */
/* TaskFileRegister0[31:24] */
/* TaskFileRegister1[07:00] */
/* TaskFileRegister1[15:08] */
/* TaskFileRegister1[19:16] */
/* command Command ID (eg: 0x20 READ), to write in */
/* TaskFileRegister1[31:24] */
/* */
/* Outputs : bp Buffer Entry structure */
/* */
/* Return options: None */
/********************************************************************************/
void issue_ata_command(struct sii680_statics *s, int nb_sectors, ULONG sector_id_lba, int command)
{
UCHAR lba_27_24, lba_23_16, lba_15_08, lba_07_00, uchar_temp;
int i;
//read_register_byte(s->v_base_addr_reg0, TFREG_COMMAND_STATUS_OFFSET, &uchar_temp);
//kkprintf("Status = 0x%08x\n", uchar_temp);
// Split the LBA addressing
lba_07_00 = (UCHAR)(0xFF & (sector_id_lba));
lba_15_08 = (UCHAR)(0xFF & (sector_id_lba >> 8));
lba_23_16 = (UCHAR)(0xFF & (sector_id_lba >> 16));
lba_27_24 = (UCHAR)(0x0F & (sector_id_lba >> 24));
// Send the command
write_register_byte(s->v_base_addr_reg0, TFREG_SECTOR_COUNT_OFFSET, nb_sectors);
write_register_byte(s->v_base_addr_reg0, TFREG_STARTING_SECTOR_NUMBER_OFFSET, lba_07_00);
write_register_byte(s->v_base_addr_reg0, TFREG_CYLINDER_LOW_OFFSET, lba_15_08);
write_register_byte(s->v_base_addr_reg0, TFREG_CYLINDER_HIGH_OFFSET, lba_23_16);
write_register_byte(s->v_base_addr_reg0, TFREG_DEVICE_HEAD_OFFSET, (0x40 | lba_27_24));
write_register_byte(s->v_base_addr_reg0, TFREG_COMMAND_STATUS_OFFSET, command);
} |
Partager