Annotation of Examples/DriverKit/Adaptec1542B/Adaptec1542B_reloc.tproj/AHAInline.h, revision 1.1.1.1

1.1       root        1: /*
                      2:  * Copyright (c) 1992 NeXT Computer, Inc.
                      3:  *
                      4:  * Adaptec AHA-1542 SCSI controller inline functions.
                      5:  *
                      6:  * HISTORY
                      7:  *
                      8:  * 12 July 1992 David E. Bohman at NeXT
                      9:  *     Created.
                     10:  */
                     11: 
                     12: #import <driverkit/i386/ioPorts.h>
                     13: 
                     14: /*
                     15:  * Primitives to access the
                     16:  * board registers.
                     17:  */
                     18: 
                     19: static inline
                     20: void
                     21: aha_put_ctrl(
                     22:     unsigned short     base,
                     23:     aha_ctrl_reg_t     reg
                     24: )
                     25: {
                     26:     union {
                     27:        aha_ctrl_reg_t          reg;
                     28:        unsigned char           data;
                     29:     } tconv;
                     30:     
                     31:     tconv.reg = reg;
                     32: 
                     33:     outb(base + AHA_CTRL_REG_OFF, tconv.data);
                     34: }
                     35: 
                     36: static inline
                     37: aha_stat_reg_t
                     38: aha_get_stat(
                     39:     unsigned short     base
                     40: )
                     41: {
                     42:     union {
                     43:        aha_stat_reg_t          reg;
                     44:        unsigned char           data;
                     45:     } tconv;
                     46: 
                     47:     tconv.data = inb(base + AHA_STAT_REG_OFF);
                     48: 
                     49:     return (tconv.reg);
                     50: }
                     51: 
                     52: static inline
                     53: aha_intr_reg_t
                     54: aha_get_intr(
                     55:     unsigned short     base
                     56: )
                     57: {
                     58:     union {
                     59:        aha_intr_reg_t          reg;
                     60:        unsigned char           data;
                     61:     } tconv;
                     62: 
                     63:     tconv.data = inb(base + AHA_INTR_REG_OFF);
                     64: 
                     65:     return (tconv.reg);
                     66: }
                     67: 
                     68: static inline
                     69: void
                     70: aha_put_cmd(
                     71:     unsigned short     base,
                     72:     aha_cmd_reg_t      reg
                     73: )
                     74: {
                     75:     outb(base + AHA_CMD_REG_OFF, reg);
                     76: }
                     77: 
                     78: static inline
                     79: aha_cmd_reg_t
                     80: aha_get_cmd(
                     81:     unsigned short     base
                     82: )
                     83: {
                     84:     return (inb(base + AHA_CMD_REG_OFF));
                     85: }
                     86: 
                     87: /*
                     88:  * Functions built on top
                     89:  * of the primatives above.
                     90:  */
                     91: 
                     92: static inline
                     93: void
                     94: aha_clr_intr(
                     95:     unsigned short     base
                     96: )
                     97: {
                     98:     aha_ctrl_reg_t     ctrl = { 0 };
                     99: 
                    100:     ctrl.intr_clr = 1;
                    101: 
                    102:     aha_put_ctrl(base, ctrl);
                    103: }
                    104: 
                    105: 
                    106: static inline
                    107: boolean_t
                    108: aha_await_datain(
                    109:     IOEISAPortAddress  base,
                    110:     unsigned int       how_long
                    111: )
                    112: {
                    113:     aha_stat_reg_t     stat;
                    114:  
                    115:     do {
                    116:        stat = aha_get_stat(base);
                    117:     } while (!stat.datain_full && how_long--);
                    118:     return how_long;
                    119: }
                    120: 
                    121: 
                    122: static inline
                    123: boolean_t
                    124: aha_get_bytes(
                    125:     IOEISAPortAddress  base,
                    126:     unsigned char      *addr,
                    127:     unsigned int       length
                    128: )
                    129: {
                    130:     while (length--) {
                    131:        if (!aha_await_datain(base, 1000))
                    132:                return FALSE;
                    133:        *addr++ = inb(base);
                    134:     }
                    135:     return TRUE;
                    136: }
                    137: 
                    138: 
                    139: /*
                    140:  *  24-bit accessor functions (with byte swapping)
                    141:  */
                    142: static inline void
                    143: aha_put_24(unsigned int source, volatile unsigned char *dest)
                    144: {
                    145:        dest[2] = source & 0xff;
                    146:        dest[1] = (source >> 8) & 0xff;
                    147:        dest[0] = (source >> 16) & 0xff;
                    148: }
                    149: 
                    150: 
                    151: static inline unsigned int
                    152: aha_get_24(volatile unsigned char *source)
                    153: {
                    154:        return (source[0] << 16) | (source[1] << 8) | source[2];
                    155: }
                    156: 
                    157: 

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.