The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/dev/ic/wdcevent.h

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /*      $OpenBSD: wdcevent.h,v 1.8 2015/08/17 15:36:29 krw Exp $        */
    2 /*
    3  * Copyright (c) 2001 Constantine Sapuntzakis
    4  *
    5  * Redistribution and use in source and binary forms, with or without
    6  * modification, are permitted provided that the following conditions
    7  * are met:
    8  * 1. Redistributions of source code must retain the above copyright
    9  *    notice, this list of conditions and the following disclaimer.
   10  * 2. Neither the name of the author nor the names of any co-contributors
   11  *    may be used to endorse or promote products derived from this software
   12  *    without specific prior written permission.
   13  *
   14  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
   15  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   16  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   17  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR
   18  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
   19  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
   20  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
   21  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
   22  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
   23  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
   24  * THE POSSIBILITY OF SUCH DAMAGE.
   25  *
   26  */
   27 
   28 #ifndef WDCEVENT_H
   29 #define WDCEVENT_H
   30 
   31 enum wdcevent_type {
   32         WDCEVENT_STATUS = 1,
   33         WDCEVENT_ERROR,
   34         WDCEVENT_ATAPI_CMD,
   35         WDCEVENT_ATAPI_DONE,
   36         WDCEVENT_ATA_SHORT,
   37         WDCEVENT_ATA_LONG,
   38         WDCEVENT_SET_DRIVE1,
   39         WDCEVENT_SET_DRIVE0,
   40         WDCEVENT_REG,
   41         WDCEVENT_ATA_EXT
   42 };
   43 
   44 #ifdef _KERNEL
   45 
   46 #ifdef WDCDEBUG
   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         memcpy(&record[2], cmd, 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 features, 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, features, 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 #else
  121 #define WDC_LOG_STATUS(chp, status)
  122 #define WDC_LOG_ERROR(chp, error)
  123 #define WDC_LOG_ATAPI_CMD(chp, drive, flags, len, cmd)
  124 #define WDC_LOG_ATAPI_DONE(chp, drive, flags, error)
  125 #define WDC_LOG_ATA_CMDSHORT(chp, cmd)
  126 #define WDC_LOG_ATA_CMDLONG(chp, head, features, cylinhi, cylinlo, \
  127     sector, count, command)
  128 #define WDC_LOG_SET_DRIVE(chp, drive)
  129 #define WDC_LOG_REG(chp, reg, val)
  130 #define WDC_LOG_ATA_CMDEXT(chp, lba_hi1, lba_hi2, lba_mi1, lba_mi2, \
  131     lba_lo1, lba_lo2, count1, count2, command)
  132 #endif /* WDCDEBUG */
  133 
  134 #endif  /* _KERNEL */
  135 
  136 #endif  /* WDCEVENT_H */

Cache object: d9ec1d53fd099cd286d70ded791c6919


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.