[BACK]Return to wdcevent.h CVS log [TXT][DIR] Up to [local] / sys / dev / ic

Annotation of sys/dev/ic/wdcevent.h, Revision 1.1

1.1     ! nbrk        1: /* $OpenBSD: wdcevent.h,v 1.4 2003/09/28 21:01:43 grange Exp $ */
        !             2:
        !             3: /*
        !             4:  * Copyright (c) 2001 Constantine Sapuntzakis
        !             5:  *
        !             6:  * Redistribution and use in source and binary forms, with or without
        !             7:  * modification, are permitted provided that the following conditions
        !             8:  * are met:
        !             9:  * 1. Redistributions of source code must retain the above copyright
        !            10:  *    notice, this list of conditions and the following disclaimer.
        !            11:  * 2. Neither the name of the author nor the names of any co-contributors
        !            12:  *    may be used to endorse or promote products derived from this software
        !            13:  *    without specific prior written permission.
        !            14:  *
        !            15:  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
        !            16:  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
        !            17:  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
        !            18:  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR
        !            19:  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
        !            20:  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
        !            21:  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
        !            22:  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
        !            23:  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
        !            24:  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
        !            25:  * THE POSSIBILITY OF SUCH DAMAGE.
        !            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 /* _KERNEL */
        !           122:
        !           123: #endif /* WDCEVENT_H */

CVSweb