This source file includes following definitions.
- WDC_LOG_STATUS
- WDC_LOG_ERROR
- WDC_LOG_ATAPI_CMD
- WDC_LOG_ATAPI_DONE
- WDC_LOG_ATA_CMDSHORT
- WDC_LOG_ATA_CMDLONG
- WDC_LOG_SET_DRIVE
- WDC_LOG_REG
- WDC_LOG_ATA_CMDEXT
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 #ifndef WDCEVENT_H
30 #define WDCEVENT_H
31
32 enum wdcevent_type {
33 WDCEVENT_STATUS = 1,
34 WDCEVENT_ERROR,
35 WDCEVENT_ATAPI_CMD,
36 WDCEVENT_ATAPI_DONE,
37 WDCEVENT_ATA_SHORT,
38 WDCEVENT_ATA_LONG,
39 WDCEVENT_SET_DRIVE1,
40 WDCEVENT_SET_DRIVE0,
41 WDCEVENT_REG,
42 WDCEVENT_ATA_EXT
43 };
44
45 #ifdef _KERNEL
46
47 void wdc_log(struct channel_softc *chp, enum wdcevent_type type,
48 unsigned int size, char val[]);
49
50 static __inline void WDC_LOG_STATUS(struct channel_softc *chp,
51 u_int8_t status) {
52 if (chp->ch_prev_log_status == status)
53 return;
54
55 chp->ch_prev_log_status = status;
56 wdc_log(chp, WDCEVENT_STATUS, 1, &status);
57 }
58
59 static __inline void WDC_LOG_ERROR(struct channel_softc *chp,
60 u_int8_t error) {
61 wdc_log(chp, WDCEVENT_ERROR, 1, &error);
62 }
63
64 static __inline void WDC_LOG_ATAPI_CMD(struct channel_softc *chp, int drive,
65 int flags, int len, void *cmd) {
66 u_int8_t record[20];
67
68 record[0] = (flags >> 8);
69 record[1] = flags & 0xff;
70 bcopy(cmd, &record[2], len);
71
72 wdc_log(chp, WDCEVENT_ATAPI_CMD, len + 2, record);
73 }
74
75 static __inline void WDC_LOG_ATAPI_DONE(struct channel_softc *chp, int drive,
76 int flags, u_int8_t error) {
77 char record[3] = {flags >> 8, flags & 0xff, error};
78 wdc_log(chp, WDCEVENT_ATAPI_DONE, 3, record);
79 }
80
81 static __inline void WDC_LOG_ATA_CMDSHORT(struct channel_softc *chp, u_int8_t cmd) {
82 wdc_log(chp, WDCEVENT_ATA_SHORT, 1, &cmd);
83 }
84
85 static __inline void WDC_LOG_ATA_CMDLONG(struct channel_softc *chp,
86 u_int8_t head, u_int8_t precomp, u_int8_t cylinhi, u_int8_t cylinlo,
87 u_int8_t sector, u_int8_t count, u_int8_t command) {
88 char record[8] = { head, precomp, cylinhi, cylinlo,
89 sector, count, command };
90
91 wdc_log(chp, WDCEVENT_ATA_LONG, 7, record);
92 }
93
94 static __inline void WDC_LOG_SET_DRIVE(struct channel_softc *chp,
95 u_int8_t drive) {
96 wdc_log(chp, drive ? WDCEVENT_SET_DRIVE1 : WDCEVENT_SET_DRIVE0,
97 0, NULL);
98 }
99
100 static __inline void WDC_LOG_REG(struct channel_softc *chp,
101 enum wdc_regs reg, u_int16_t val) {
102 char record[3];
103
104 record[0] = reg;
105 record[1] = (val >> 8);
106 record[2] = val & 0xff;
107
108 wdc_log(chp, WDCEVENT_REG, 3, record);
109 }
110
111 static __inline void WDC_LOG_ATA_CMDEXT(struct channel_softc *chp,
112 u_int8_t lba_hi1, u_int8_t lba_hi2, u_int8_t lba_mi1, u_int8_t lba_mi2,
113 u_int8_t lba_lo1, u_int8_t lba_lo2, u_int8_t count1, u_int8_t count2,
114 u_int8_t command) {
115 char record[9] = { lba_hi1, lba_hi2, lba_mi1, lba_mi2,
116 lba_lo1, lba_lo2, count1, count2, command };
117
118 wdc_log(chp, WDCEVENT_ATA_EXT, 9, record);
119 }
120
121 #endif
122
123 #endif