Annotation of XNU/bsd/netat/adsp_internal.h, revision 1.1

1.1     ! root        1: /*
        !             2:  * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
        !             3:  *
        !             4:  * @APPLE_LICENSE_HEADER_START@
        !             5:  * 
        !             6:  * The contents of this file constitute Original Code as defined in and
        !             7:  * are subject to the Apple Public Source License Version 1.1 (the
        !             8:  * "License").  You may not use this file except in compliance with the
        !             9:  * License.  Please obtain a copy of the License at
        !            10:  * http://www.apple.com/publicsource and read it before using this file.
        !            11:  * 
        !            12:  * This Original Code and all software distributed under the License are
        !            13:  * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
        !            14:  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
        !            15:  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
        !            16:  * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
        !            17:  * License for the specific language governing rights and limitations
        !            18:  * under the License.
        !            19:  * 
        !            20:  * @APPLE_LICENSE_HEADER_END@
        !            21:  */
        !            22: #ifndef _NETAT_ADSP_INTERNAL_H_
        !            23: #define _NETAT_ADSP_INTERNAL_H_
        !            24: 
        !            25: #ifdef KERNEL
        !            26: 
        !            27: /* from h/adsp_portab.h */
        !            28: 
        !            29: /* TypeDefs for the basic data bytes. */
        !            30: 
        !            31: typedef unsigned char          byte, *bytePtr;
        !            32: 
        !            33: #ifdef NOT_USED
        !            34: typedef char                   int8;
        !            35: typedef short                  int16;
        !            36: typedef int                    int32;
        !            37: #endif
        !            38: 
        !            39: typedef unsigned char          boolean;
        !            40: 
        !            41: typedef unsigned short         word;
        !            42: 
        !            43: typedef unsigned int           dword;
        !            44: 
        !            45: #define BYTE_AT(x)             (*((byte PTR)(x)))
        !            46: #define WORD_AT(x)             (*((word PTR)(x)))
        !            47: #define DWORD_AT(x)            (*((dword PTR)(x)))
        !            48: 
        !            49: #define high(x)                        ((byte)((x) >> 8))
        !            50: #define low(x)                 ((byte)(x))
        !            51: #define hlword(h, l)           (((byte)(l)) | (((byte)(h)) << 8))
        !            52: 
        !            53: #define offsetof(typ,id)       (size_t)&(((typ*)0)->id)
        !            54: 
        !            55: /* 
        !            56:  * On a Mac, there is no need to byte-swap data on the network, so 
        !            57:  * these macros do nothing 
        !            58:  */
        !            59: 
        !            60: #define netw(x)                x
        !            61: #define netdw(x)       x
        !            62: 
        !            63: typedef struct
        !            64: {
        !            65:   at_net           network;       /* network number */
        !            66:   byte           nodeid;        /* node number    */
        !            67:   byte           socket;        /* socket number  */
        !            68: } AddrBlk, *AddrBlkPtr;
        !            69: 
        !            70: typedef union
        !            71: {
        !            72:    at_inet_t     a;
        !            73: } AddrUnion, *AddrUnionPtr;
        !            74: 
        !            75: /* End Portab.h */
        !            76: 
        !            77: /* from h/adsp_internal.h */
        !            78: 
        !            79: #undef T_IDLE
        !            80: 
        !            81: /*
        !            82: * Default Behavior for ADSP
        !            83: */
        !            84: #define        ocIntervalDefault       6
        !            85: #define ocMaximumDefault       10
        !            86: #define probeIntervalDefault   180
        !            87: 
        !            88: /*
        !            89: * MACROS for comparing 32-bit sequence numbers
        !            90: */
        !            91: #define GT(x,y)  (((long)(x-y)) > (long) 0)
        !            92: #define LT(x,y)  (((long)(x-y)) < (long) 0)
        !            93: #define GTE(x,y) (((long)(x-y)) >= (long) 0)
        !            94: #define LTE(x,y) (((long)(x-y)) <= (long) 0)
        !            95: #define BETWEEN(x,y,z) (LTE(x,y) && LTE(y,z))
        !            96: 
        !            97: /*
        !            98:  * Use the kernel tick counter for SysTicks.
        !            99:  */
        !           100: 
        !           101: #define SysTicks()     lbolt
        !           102: 
        !           103: /*
        !           104:  * Timer element used for handling timings
        !           105:  */
        !           106: typedef struct timerelem {
        !           107:     struct timerelem *link;
        !           108:     short timer;
        !           109:     char type;
        !           110:     unsigned onQ:1;            /* Bit-fields are faster than booleans */
        !           111: } TimerElem;
        !           112: 
        !           113: typedef TimerElem *TimerElemPtr;
        !           114: 
        !           115: /*
        !           116:  * For AppleTalk Phase 2 event queue
        !           117:  */
        !           118: typedef struct {
        !           119:     Ptr        qLink;
        !           120:     unsigned short qType;
        !           121:     ProcPtr callAddr;
        !           122: } LAPEventElem;
        !           123: 
        !           124: typedef LAPEventElem *LAPEventElemPtr;
        !           125: 
        !           126: /* 
        !           127:  * The Event types we're passed when an AppleTalk transition occurs
        !           128:  */
        !           129: #define AOpenTransition                0
        !           130: #define        ACloseTransition        2
        !           131: #define ANetworkTransition     5
        !           132: 
        !           133: /*
        !           134:  * The element we're passed when a NetworkTransaction event occurs
        !           135:  */
        !           136: typedef struct TNetworkTransition {
        !           137:     Ptr        private;                /* pointer used internally by NetShare */
        !           138:     ProcPtr netValidProc;      /* pointer to the network valid procedure */
        !           139: } TNetworkTransition, *TPNetworkTransition;
        !           140: 
        !           141: typedef long (*NetworkTransitionProcPtr)();
        !           142:                                /* (TPNetworkTransition nettrans, 
        !           143:                                   unsigned long thenet); */
        !           144: /*
        !           145:  * This is the connection control block
        !           146:  */
        !           147: typedef struct ccb {
        !           148:     /*---These fields may not change order or size-----------*/
        !           149: 
        !           150:     struct ccb *ccbLink;       /* link to next ccb */
        !           151:     unsigned short state;      /* state of the connection end */
        !           152:     unsigned char userFlags;   /* flags for unsolicited connection events */
        !           153:     unsigned char localSocket; /* socket number of this connection end */
        !           154:     AddrUnion remoteAddress;   /* internet address of remote end */
        !           155:     unsigned short attnCode;   /* attention code received */
        !           156:     unsigned short attnSize;   /* size of received attention data */
        !           157:     unsigned char *attnPtr;    /* ptr to received attention data */
        !           158:     unsigned short recvQPending; /* # bytes in receive queue %%% */
        !           159:     /*------------------------------------------------------ */
        !           160:        
        !           161:     struct adspcmd *opb;       /* Outstanding open/close/remove/listens */
        !           162:     struct adspcmd *spb;       /* Outstanding Sends */
        !           163:     struct adspcmd *sapb;      /* Outstanding Send Attentions */
        !           164:     struct adspcmd *frpb;      /* Outstanding Forward Resets */
        !           165:     struct adspcmd *rpb;       /* Outstanding Read Requests */
        !           166:        
        !           167:     struct ccb *otccbLink;     /* link to next ccb */
        !           168:     int pid;           /* Process ID for CCB owner */
        !           169: 
        !           170:     unsigned short remCID;     /* Remote Connection ID */
        !           171:     unsigned short locCID;     /* Local Connection ID */
        !           172:     int sendSeq;               /* Seq number of next char to send to remote */
        !           173:     int firstRtmtSeq;          /* oldest seq # in local send queue */
        !           174:     int sendWdwSeq;            /* Seq # of last char remote has bfr for */
        !           175:     int recvSeq;               /* Seq of # of next char expected from rmte */
        !           176:     int recvWdw;               /* # of bytes local end has buffer space for */
        !           177:     int attnSendSeq;           /* Seq # of next attn pkt to send to remote */
        !           178:     int attnRecvSeq;           /* Seq # of next packet local end expects */
        !           179:     int maxSendSeq;            /* Highest seq # we ever sent on connection */
        !           180: 
        !           181:     /* These must be in the first 255 bytes of the CCB */
        !           182:     TimerElem ProbeTimer;      /* Timer element for probes (and open) */
        !           183:     TimerElem FlushTimer;      /* Timer element for flushing data */
        !           184:     TimerElem RetryTimer;      /* Timer element for retransmissions */
        !           185:     TimerElem AttnTimer;       /* Timer element for attention packets */
        !           186:     TimerElem ResetTimer;      /* Timer element for forward resets */
        !           187:        
        !           188:     short openInterval;                /* Interval between open connection packets */
        !           189:     short probeInterval;       /* Interval between probes */
        !           190:     short sendInterval;                /* Interval before automatic flush */
        !           191:     short rtmtInterval;                /* Rexmit interval (dynamically determined) */
        !           192: 
        !           193:     short sendCtl;             /* Send control message bits */
        !           194:     short sendBlocking;                /* Flush unsent data if > than sendBlocking */
        !           195:     short openRetrys;          /* # of retrys for Connect & Accept */
        !           196:     short rbuflen;             /* Total size of receive buffer */
        !           197:     short sbuflen;             /* Total size of receive buffer */
        !           198:     char pad;
        !           199:     char lockFlag;
        !           200:     char badSeqMax;            /* retransmit advice send threshold */
        !           201:     char badSeqCnt;            /* # of of out-of-order packets received */
        !           202:     char useCheckSum;          /* true to use DDP checksums */
        !           203:     char openState;            /* Used for opening a connection (see below) */
        !           204: 
        !           205:     gbuf_t *rbuf_mb;           /* message block for the recv buffer */
        !           206:     gbuf_t *crbuf_mb;
        !           207:     gbuf_t *sbuf_mb;           /* message block for the send buffer */
        !           208:     gbuf_t *csbuf_mb;
        !           209:     gbuf_t *attn_mb;           /* message block for the attention buffer */
        !           210:     gbuf_t *deferred_mb;       /* message block deferred for later processing */
        !           211:        
        !           212: #ifdef NOT_USED
        !           213:     char ioDone;               /* flag for when the adsp header is busy */
        !           214: #endif
        !           215:     char probeCntr;            /* # of probes we can miss (counts down) */
        !           216:     char pktSendMax;           /* Max # of packets to send without an ack */
        !           217:     char pktSendCnt;           /* # of packets sent so far */
        !           218:        
        !           219:     int sendStamp;             /* Time of last ackRequest */
        !           220:     int timerSeq;              /* Seq # of char corresponding to above time stamp */
        !           221:     short roundTrip;           /* Average Round-Trip time (in 6ths of a second) */
        !           222:     short deviation;           /* deviation from roundTrip time */
        !           223:     
        !           224:     unsigned sData:1;          /* There's data in the send queue */
        !           225:     unsigned waitingAck:1;     /* We're waiting for an ack packet */
        !           226:     unsigned rData:1;          /* There's data in the receive queue */
        !           227:     unsigned resentData:1;     /* True when we resend data due to timeout */
        !           228:     unsigned sendDataAck:1;    /* True if he requested an ack */
        !           229:     unsigned sendAttnAck:1;    /* Must send attn acknowlege */
        !           230:     unsigned sendAttnData:1;   /* Must send attn data */
        !           231:     unsigned callSend:1;       /* Must call CheckSend() */
        !           232:     unsigned rbufFull:1;       /* We've closed our receive window. */
        !           233:     unsigned noXmitFlow:1;     /* True stops incrementing # of xmit 
        !           234:                                 * packets to send in a row after receiving 
        !           235:                                 * an ack packet. */
        !           236:     unsigned secureCCB:1;      /* True if this is a secure connection */
        !           237:     unsigned removing:1;       /* There is a dspRemove pending */
        !           238:     unsigned writeFlush:1;     /* Flush send queue even if # bytes to 
        !           239:                                 * send is less than send blocking. */
        !           240:     unsigned delay:1;          /* do not complete commands until user
        !           241:                                 * *** NO LONGER USED IN KERNEL *** */
        !           242:     ADSP_FRAME f;              /* Used to send every packet */
        !           243:     ADSP_OPEN_DATA of;         /* Holds the data for the open exchange */
        !           244:     gref_t *gref;                      /* The queue associated with the CCB */
        !           245:     gbuf_t *sp_mp;
        !           246:     atlock_t lock;
        !           247:     atlock_t lockClose;
        !           248:     atlock_t lockRemove;
        !           249: } CCB, *CCBPtr;
        !           250: 
        !           251: 
        !           252: /*
        !           253:  * Change order and die !!! --- See the receive open packet code
        !           254:  */
        !           255: #define O_STATE_NOTHING                0       /* Not opening */
        !           256: #define O_STATE_LISTEN                 1       /* Listening for open request */
        !           257: #define O_STATE_OPENWAIT       2       /* Sent Req, waiting for Ack to open 
        !           258:                                         * request */
        !           259: #define O_STATE_ESTABLISHED    3       /* Got Req, send Req+Ack,waiting Ack */
        !           260: #define O_STATE_OPEN           4       /* Connection is open */
        !           261: 
        !           262: /*
        !           263: * These bits are used in the sendCtl field to indicate what needs to be sent
        !           264: */
        !           265: #define B_CTL_PROBE            0x0001
        !           266: #define B_CTL_OREQ             0x0002
        !           267: #define B_CTL_OACK             0x0004
        !           268: #define B_CTL_OREQACK          0x0008
        !           269: #define B_CTL_ODENY            0x0010
        !           270: #define B_CTL_CLOSE            0x0020
        !           271: #define B_CTL_FRESET           0x0040
        !           272: #define B_CTL_FRESETACK                0x0080
        !           273: #define        B_CTL_RETRANSMIT        0x0100
        !           274: 
        !           275: 
        !           276: #define kProbeTimerType offsetof(CCB, ProbeTimer)
        !           277: #define kFlushTimerType offsetof(CCB, FlushTimer)
        !           278: #define kRetryTimerType offsetof(CCB, RetryTimer)
        !           279: #define kAttnTimerType offsetof(CCB, AttnTimer)
        !           280: #define kResetTimerType offsetof(CCB, ResetTimer)
        !           281: 
        !           282: /*
        !           283:  * Used to manage the send receive queue
        !           284:  */
        !           285: typedef struct {
        !           286:     short len;                 /* # of bytes in this fragment */
        !           287:     char flags;                        /* See #define's below */
        !           288:     char data[1];
        !           289: } HDR, *HDRPtr;
        !           290: 
        !           291: #define        HDR_LEN 3               /* Yes, I know it really is 4 bytes long... */
        !           292: 
        !           293: #define F_GAP          0x03
        !           294: #define F_EOM          0x04
        !           295: #define F_WRAP         0x08
        !           296: #define F_VALID                0x10
        !           297: #define F_ENCRYPTED    0x20    /* %%% Needed ??? */
        !           298: #define F_LAST         0x40    /* This is last block in buffer */
        !           299: 
        !           300: 
        !           301: /* %%% Are these two used anymore? */
        !           302: #define sbufPtr(y) (&sp->sbuf[((y) < sp->sbuflen) ? (y) : ((y) - sp->sbuflen)])
        !           303: #define rbufPtr(y) (&sp->rbuf[((y) < sp->rbuflen) ? (y) : ((y) - sp->rbuflen)])
        !           304: 
        !           305: /* End Internal.h */
        !           306: 
        !           307: /* fron h/adsp_supp.h */
        !           308: 
        !           309: void   CallUserRoutine();      /* (CCB FPTR sp); */
        !           310: 
        !           311: 
        !           312: /*
        !           313:  *     Add queue element to end of queue.  Pass Address of ptr to 
        !           314:  *     1st element of queue
        !           315:  */
        !           316: int    qAddToEnd(); /* (void FPTR FPTR qhead, void FPTR qelem); */
        !           317: 
        !           318: /*
        !           319:  *     Hunt down a linked list of queue elements looking for an element with
        !           320:  *     'data' at 'offset' bytes into the queue element.
        !           321:  */
        !           322: void *qfind_b();               /* (void *qhead, word offset, word data); */ 
        !           323: void *qfind_w();               /* (void *qhead, word offset, word data); */
        !           324: void *qfind_p();               /* (void *qhead, word offset, void *ptr); */
        !           325: void *qfind_o();               /* (void *qhead, word offset, void *ptr); */
        !           326: void *qfind_m();               /* (void *qhead, void *match, 
        !           327:                                   ProcPtr compare_fnx); */
        !           328: 
        !           329: 
        !           330: /*
        !           331:  * Routines to handle sorted timer queues
        !           332:  */
        !           333: void InsertTimerElem();                /* (TimerElemPtr *qhead, TimerElemPtr t, 
        !           334:                                   word val); */
        !           335: void RemoveTimerElem();                /* (TimerElemPtr *qhead, TimerElemPtr t); */
        !           336: void TimerQueueTick();         /* (TimerElemPtr *qhead);*/
        !           337: 
        !           338: /* from h/adsp_global.h */
        !           339: 
        !           340: typedef struct {
        !           341:        void *ccbList;          /* Ptr to list of connection control blocks */
        !           342: 
        !           343:        TimerElemPtr slowTimers; /* The probe timer list */
        !           344:        TimerElemPtr fastTimers; /* The fast timer list */
        !           345: 
        !           346:        unsigned short lastCID;         /* Last connection ID assigned */
        !           347:        char inTimer;           /* We're inside timer routine */
        !           348: } GLOBAL;
        !           349: 
        !           350: extern GLOBAL adspGlobal;
        !           351: 
        !           352: /* Address of ptr to list of ccb's */
        !           353: #define AT_ADSP_STREAMS ((CCB **)&(adspGlobal.ccbList))
        !           354: 
        !           355: #endif /* KERNEL */
        !           356: 
        !           357: #endif /* _NETAT_ADSP_INTERNAL_H_ */

unix.superglobalmegacorp.com

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