File: dat.h

package info (click to toggle)
aoetools 36-5
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye
  • size: 464 kB
  • sloc: ansic: 1,506; sh: 627; makefile: 54
file content (102 lines) | stat: -rw-r--r-- 1,476 bytes parent folder | download | duplicates (6)
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
/* dat.h - aoetools type definitions and macros
 * Copyright 2009, CORAID, Inc., and licensed under GPL v.2.
 */

#define	nil	NULL
#define	nelem(x)	(sizeof(x)/sizeof((x)[0]))

typedef unsigned char uchar;
typedef struct Aoehdr Aoehdr;
typedef struct Ata Ata;
typedef struct Conf Conf;
typedef struct Ataregs Ataregs;

/* use C99's stdint.h for fixed-width types
 *
 * There's no guarantee an unsigned short is 16-bits wide,
 * but uint16_t is always correct.
 */
typedef uint64_t vlong;
typedef uint32_t u32;
typedef uint16_t u16;

struct Ataregs {
	vlong	lba;
	uchar	cmd;
	uchar	status;
	uchar	err;
	uchar	feature;
	uchar	sectors;
};

struct Aoehdr {
	uchar	dst[6];
	uchar	src[6];
	u16	type;
	uchar	flags;
	uchar	error;
	u16	maj;
	uchar	min;
	uchar	cmd;
	uchar	tag[4];
};

struct Ata {
	Aoehdr	h;
	uchar	aflag;
	uchar	err;
	uchar	sectors;
	uchar	cmd;
	uchar	lba[6];
	uchar	resvd[2];
	uchar	data[1024];
};

struct Conf {
	Aoehdr	h;
	u16	bufcnt;
	u16	firmware;
	uchar	scnt;
	uchar	vercmd;
	u16	len;
	uchar	data[1024];
};

enum {
	AOE_ETH_PROTO = 0x88a2,

	AoEver = 1,

	ATAcmd = 0,		// command codes
	Config,

	Resp = 1<<3,		// flags
	Error = 1<<2,

	BadCmd = 1,
	BadArg,
	DevUnavailable,
	ConfigErr,
	BadVersion,

	Write = 1<<0,
	Async = 1<<1,
	Device = 1<<4,
	Extend = 1<<6,

	Qread = 0,
	Qtest,
	Qprefix,
	Qset,
	Qfset,

	Nretries = 3,

	ATAid_dev = 0xec,	// ATA commands
	ATAsmart = 0xb0,

	ATAabrt = 0x4,		// ATA error bits

	SmartDataPut = 0x01,
	SmartDataRet = 0x10,
};