]> git.proxmox.com Git - mirror_smartmontools-debian.git/blame - scsiata.h
Imported Upstream version 5.38
[mirror_smartmontools-debian.git] / scsiata.h
CommitLineData
4d59bff9
GG
1/*
2 * scsiata.h
3 *
4 * Home page of code is: http://smartmontools.sourceforge.net
5 *
6 * Copyright (C) 2006 Douglas Gilbert <dougg@torque.net>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2, or (at your option)
11 * any later version.
12 *
13 * You should have received a copy of the GNU General Public License
14 * (for example COPYING); if not, write to the Free
15 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
16 *
17 */
18
19
20#ifndef SCSIATA_H_
21#define SCSIATA_H_
22
23#define SCSIATA_H_CVSID "$Id: scsiata.h,v 1.2 2006/07/01 21:29:31 dpgilbert Exp $\n"
24
25#include <stdio.h>
26#include <stdlib.h>
27#include <string.h>
28#include <errno.h>
29
30#include "atacmds.h"
31
32#define SAT_ATA_PASSTHROUGH_12LEN 12
33#define SAT_ATA_PASSTHROUGH_16LEN 16
34
35extern int sat_command_interface(int device, smart_command_set command,
36 int select, char *data);
37
38/* Attempt an IDENTIFY DEVICE ATA command via SATL when packet_interface
39 is 0 otherwise attempt IDENTIFY PACKET DEVICE. If successful
40 return 1, else 0 */
41extern int has_sat_pass_through(int device, int packet_interface);
42
43/* This is a slightly stretched SCSI sense "descriptor" format header.
44 The addition is to allow the 0x70 and 0x71 response codes. The idea
45 is to place the salient data of both "fixed" and "descriptor" sense
46 format into one structure to ease application processing.
47 The original sense buffer should be kept around for those cases
48 in which more information is required (e.g. the LBA of a MEDIUM ERROR). */
49struct sg_scsi_sense_hdr {
50 unsigned char response_code; /* permit: 0x0, 0x70, 0x71, 0x72, 0x73 */
51 unsigned char sense_key;
52 unsigned char asc;
53 unsigned char ascq;
54 unsigned char byte4;
55 unsigned char byte5;
56 unsigned char byte6;
57 unsigned char additional_length;
58};
59
60/* Maps the salient data from a sense buffer which is in either fixed or
61 descriptor format into a structure mimicking a descriptor format
62 header (i.e. the first 8 bytes of sense descriptor format).
63 If zero response code returns 0. Otherwise returns 1 and if 'sshp' is
64 non-NULL then zero all fields and then set the appropriate fields in
65 that structure. sshp::additional_length is always 0 for response
66 codes 0x70 and 0x71 (fixed format). */
67extern int sg_scsi_normalize_sense(const unsigned char * sensep,
68 int sense_len,
69 struct sg_scsi_sense_hdr * sshp);
70
71/* Attempt to find the first SCSI sense data descriptor that matches the
72 given 'desc_type'. If found return pointer to start of sense data
73 descriptor; otherwise (including fixed format sense data) returns NULL. */
74extern const unsigned char * sg_scsi_sense_desc_find(
75 const unsigned char * sensep, int sense_len, int desc_type);
76
77#endif
78