]> git.lizzy.rs Git - plan9front.git/blob - sys/src/cmd/atazz/atazz.h
merge
[plan9front.git] / sys / src / cmd / atazz / atazz.h
1 enum {
2         Cmdn    = 1,
3         Cmdf,                   /* cfa only */
4         Cmdp,                   /* packet */
5         Cmd5sc,                 /* 512-byte sector size, set sector count */
6 };
7
8 typedef struct Dev Dev;
9 struct Dev {
10         Sfis;
11         int     fd;
12         uint    secsize;
13         uvlong  nsect;
14         uvlong  wwn;
15 };
16
17 enum {
18         Cmdsz   = 18,
19         Replysz = 18,
20 };
21
22 typedef struct Rcmd Rcmd;
23 struct Rcmd {
24         uchar   sdcmd;          /* sd command; 0xff means ata passthrough */
25         uchar   ataproto;       /* ata protocol.  non-data, pio, reset, dd, etc. */
26         uchar   fis[Fissize];
27 };
28
29 typedef struct Req Req;
30 struct Req {
31         int     rfd;
32         int     wfd;
33         uchar   fmtrw;
34         uvlong  lba;
35         uvlong  count;          /* bytes; allow long sectors to work */
36         uint    nsect;
37         char    haverfis;
38         uint    fisbits;                /* bitmask of manually set fields */
39         Rcmd    cmd;
40         Rcmd    reply;
41         uchar   *data;
42         uchar   raw;
43 };
44
45 void    sigfmt(Req*);
46 void    idfmt(Req*);
47 void    iofmt(Req*);
48 void    sdfmt(Req*);
49 void    smfmt(Req*);
50 void    slfmt(Req*);
51 void    glfmt(Req*);
52
53 typedef struct Btab Btab;
54 struct Btab {
55         int     bit;
56         char    *name;
57 };
58 char    *sebtab(char*, char*, Btab*, int, uint);
59
60 typedef struct Txtab Txtab;
61 typedef struct Fetab Fetab;
62
63 struct Txtab {
64         int     val;
65         char    *name;
66         Fetab   *fe;
67 };
68
69 struct Fetab {
70         int     reg;
71         Txtab   *tab;
72         int     ntab;
73 };
74
75 /* sct “registers” */
76 enum {
77         Sbase   = 1<<5,
78         Sbyte   = 0<<6,
79         Sw      = 1<<6,
80         Sdw     = 2<<6,
81         Sqw     = 3<<6,
82         Ssz     = 3<<6,
83
84         Saction = 0 | Sbase | Sw,
85         Sfn     = 1 | Sbase | Sw,
86         Slba    = 2 | Sbase | Sqw,
87         Scnt    = 6 | Sbase | Sqw,
88         Spat    = 10 | Sbase | Sdw,
89         Ssc     = 2 | Sbase | Sw,
90         Stimer  = 3 | Sbase | Sw,
91         Sfe     = 2 | Sbase | Sw,
92         Sstate  = 3 | Sbase | Sw,
93         Soptf   = 4 | Sbase | Sw,
94         Stabid  = 2 | Sbase | Sw,
95
96         Pbase   = 1<<6,
97 };
98
99 void    pw(uchar*, ushort);
100 void    pdw(uchar*, uint);
101 void    pqw(uchar*, uvlong);
102 ushort  w(uchar*);
103 uint    dw(uchar*);
104 uvlong  qw(uchar*);
105
106 /*
107  * botch.  integrate with fis.h?
108  */
109 enum {
110         Psct    = 1<<6 + 8,
111 };
112
113 typedef struct Atatab Atatab;
114 struct Atatab {
115         ushort  cc;
116         uchar   flags;
117         uchar   pktflags;
118         ushort  protocol;
119         Fetab   *tab;
120         void    (*fmt)(Req*);
121         char    *name;
122 };
123
124 int     eprint(char *, ...);
125 int     opendev(char*, Dev*);
126 int     probe(void);
127
128 extern  int     squelch;
129
130 #pragma varargck        argpos  eprint  1
131 #pragma varargck        type    "π"    char**