2 * Device driver for the SYMBIOS/LSILOGIC 53C8XX and 53C1010 family
3 * of PCI-SCSI IO processors.
5 * Copyright (C) 1999-2001 Gerard Roudier <groudier@free.fr>
7 * This driver is derived from the Linux sym53c8xx driver.
8 * Copyright (C) 1998-2000 Gerard Roudier
10 * The sym53c8xx driver is derived from the ncr53c8xx driver that had been
11 * a port of the FreeBSD ncr driver to Linux-1.2.13.
13 * The original ncr driver has been written for 386bsd and FreeBSD by
14 * Wolfgang Stanglmeier <wolf@cologne.de>
15 * Stefan Esser <se@mi.Uni-Koeln.de>
16 * Copyright (C) 1994 Wolfgang Stanglmeier
18 * Other major contributions:
20 * NVRAM detection and reading.
21 * Copyright (C) 1997 Richard Waltham <dormouse@farsrobt.demon.co.uk>
23 *-----------------------------------------------------------------------------
25 * This program is free software; you can redistribute it and/or modify
26 * it under the terms of the GNU General Public License as published by
27 * the Free Software Foundation; either version 2 of the License, or
28 * (at your option) any later version.
30 * This program is distributed in the hope that it will be useful,
31 * but WITHOUT ANY WARRANTY; without even the implied warranty of
32 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
33 * GNU General Public License for more details.
35 * You should have received a copy of the GNU General Public License
36 * along with this program; if not, write to the Free Software
37 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
44 * A la VMS/CAM-3 queue management.
46 typedef struct sym_quehead
{
47 struct sym_quehead
*flink
; /* Forward pointer */
48 struct sym_quehead
*blink
; /* Backward pointer */
51 #define sym_que_init(ptr) do { \
52 (ptr)->flink = (ptr); (ptr)->blink = (ptr); \
55 static inline struct sym_quehead
*sym_que_first(struct sym_quehead
*head
)
57 return (head
->flink
== head
) ? 0 : head
->flink
;
60 static inline struct sym_quehead
*sym_que_last(struct sym_quehead
*head
)
62 return (head
->blink
== head
) ? 0 : head
->blink
;
65 static inline void __sym_que_add(struct sym_quehead
* new,
66 struct sym_quehead
* blink
,
67 struct sym_quehead
* flink
)
75 static inline void __sym_que_del(struct sym_quehead
* blink
,
76 struct sym_quehead
* flink
)
82 static inline int sym_que_empty(struct sym_quehead
*head
)
84 return head
->flink
== head
;
87 static inline void sym_que_splice(struct sym_quehead
*list
,
88 struct sym_quehead
*head
)
90 struct sym_quehead
*first
= list
->flink
;
93 struct sym_quehead
*last
= list
->blink
;
94 struct sym_quehead
*at
= head
->flink
;
104 static inline void sym_que_move(struct sym_quehead
*orig
,
105 struct sym_quehead
*dest
)
107 struct sym_quehead
*first
, *last
;
124 #define sym_que_entry(ptr, type, member) container_of(ptr, type, member)
126 #define sym_insque(new, pos) __sym_que_add(new, pos, (pos)->flink)
128 #define sym_remque(el) __sym_que_del((el)->blink, (el)->flink)
130 #define sym_insque_head(new, head) __sym_que_add(new, head, (head)->flink)
132 static inline struct sym_quehead
*sym_remque_head(struct sym_quehead
*head
)
134 struct sym_quehead
*elem
= head
->flink
;
137 __sym_que_del(head
, elem
->flink
);
143 #define sym_insque_tail(new, head) __sym_que_add(new, (head)->blink, head)
145 static inline struct sym_quehead
*sym_remque_tail(struct sym_quehead
*head
)
147 struct sym_quehead
*elem
= head
->blink
;
150 __sym_que_del(elem
->blink
, head
);
157 * This one may be useful.
159 #define FOR_EACH_QUEUED_ELEMENT(head, qp) \
160 for (qp = (head)->flink; qp != (head); qp = qp->flink)
162 * FreeBSD does not offer our kind of queue in the CAM CCB.
163 * So, we have to cast.
165 #define sym_qptr(p) ((struct sym_quehead *) (p))
168 * Simple bitmap operations.
170 #define sym_set_bit(p, n) (((u32 *)(p))[(n)>>5] |= (1<<((n)&0x1f)))
171 #define sym_clr_bit(p, n) (((u32 *)(p))[(n)>>5] &= ~(1<<((n)&0x1f)))
172 #define sym_is_bit(p, n) (((u32 *)(p))[(n)>>5] & (1<<((n)&0x1f)))
175 * The below round up/down macros are to be used with a constant
176 * as argument (sizeof(...) for example), for the compiler to
177 * optimize the whole thing.
179 #define _U_(a,m) (a)<=(1<<m)?m:
182 * Round up logarithm to base 2 of a 16 bit constant.
184 #define _LGRU16_(a) \
186 _U_(a, 0)_U_(a, 1)_U_(a, 2)_U_(a, 3)_U_(a, 4)_U_(a, 5)_U_(a, 6)_U_(a, 7) \
187 _U_(a, 8)_U_(a, 9)_U_(a,10)_U_(a,11)_U_(a,12)_U_(a,13)_U_(a,14)_U_(a,15) \
190 #endif /* SYM_MISC_H */
This page took 0.034443 seconds and 5 git commands to generate.