2017-12-18 19:11:03 +00:00
|
|
|
/***************************************************************************
|
|
|
|
|
The Disc Image Chef
|
|
|
|
|
----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
Filename : atapi.c
|
|
|
|
|
Version : 4.0
|
|
|
|
|
Author(s) : Natalia Portillo
|
|
|
|
|
|
|
|
|
|
Component : DiscImageChef.Device.Report
|
|
|
|
|
|
|
|
|
|
--[ Description ] ----------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
Contains ATAPI commands.
|
|
|
|
|
|
|
|
|
|
--[ License ] --------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
|
|
|
it under the terms of the GNU General Public License as
|
|
|
|
|
published by the Free Software Foundation, either version 3 of the
|
|
|
|
|
License, or (at your option) any later version.
|
|
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
|
|
----------------------------------------------------------------------------
|
|
|
|
|
Copyright (C) 2011-2018 Claunia.com
|
|
|
|
|
****************************************************************************/
|
2017-12-13 00:32:26 +00:00
|
|
|
|
|
|
|
|
#include <malloc.h>
|
|
|
|
|
#include <string.h>
|
2017-12-18 18:28:33 +00:00
|
|
|
#include <stdint.h>
|
2017-12-13 00:32:26 +00:00
|
|
|
#include "ata.h"
|
|
|
|
|
#include "atapi.h"
|
|
|
|
|
|
|
|
|
|
int IdentifyPacket(int fd, unsigned char **buffer, AtaErrorRegistersCHS **errorRegisters)
|
|
|
|
|
{
|
|
|
|
|
*buffer = malloc(512);
|
|
|
|
|
memset(*buffer, 0, 512);
|
|
|
|
|
AtaRegistersCHS registers;
|
|
|
|
|
memset(®isters, 0, sizeof(AtaRegistersCHS));
|
|
|
|
|
|
|
|
|
|
registers.command = ATA_IDENTIFY_PACKET_DEVICE;
|
|
|
|
|
|
2017-12-18 18:28:33 +00:00
|
|
|
int error = SendAtaCommandChs(fd, registers, errorRegisters, ATA_PROTOCOL_PIO_IN, ATA_TRANSFER_NONE, *buffer, 512,
|
|
|
|
|
0);
|
2017-12-13 00:32:26 +00:00
|
|
|
|
|
|
|
|
return error;
|
|
|
|
|
}
|