]>
Commit | Line | Data |
---|---|---|
1c79356b | 1 | /* |
8ad349bb | 2 | * Copyright (c) 2006 Apple Computer, Inc. All Rights Reserved. |
1c79356b | 3 | * |
8ad349bb | 4 | * @APPLE_LICENSE_OSREFERENCE_HEADER_START@ |
1c79356b | 5 | * |
8ad349bb A |
6 | * This file contains Original Code and/or Modifications of Original Code |
7 | * as defined in and that are subject to the Apple Public Source License | |
8 | * Version 2.0 (the 'License'). You may not use this file except in | |
9 | * compliance with the License. The rights granted to you under the | |
10 | * License may not be used to create, or enable the creation or | |
11 | * redistribution of, unlawful or unlicensed copies of an Apple operating | |
12 | * system, or to circumvent, violate, or enable the circumvention or | |
13 | * violation of, any terms of an Apple operating system software license | |
14 | * agreement. | |
15 | * | |
16 | * Please obtain a copy of the License at | |
17 | * http://www.opensource.apple.com/apsl/ and read it before using this | |
18 | * file. | |
19 | * | |
20 | * The Original Code and all software distributed under the License are | |
21 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER | |
22 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, | |
23 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
24 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. | |
25 | * Please see the License for the specific language governing rights and | |
26 | * limitations under the License. | |
27 | * | |
28 | * @APPLE_LICENSE_OSREFERENCE_HEADER_END@ | |
1c79356b A |
29 | */ |
30 | #include <sys/errno.h> | |
31 | #include <sys/types.h> | |
32 | #include <sys/param.h> | |
33 | #include <machine/spl.h> | |
34 | #include <sys/systm.h> | |
35 | #include <sys/kernel.h> | |
36 | #include <sys/proc.h> | |
37 | #include <sys/filedesc.h> | |
38 | #include <sys/fcntl.h> | |
39 | #include <sys/mbuf.h> | |
40 | #include <sys/socket.h> | |
41 | ||
42 | #include <netat/sysglue.h> | |
43 | #include <netat/appletalk.h> | |
44 | #include <netat/at_pcb.h> | |
45 | #include <netat/debug.h> | |
46 | #include <netat/adsp.h> | |
47 | #include <netat/adsp_internal.h> | |
48 | ||
49 | /* | |
50 | * These function replace the Mk68 assembly routines found in qAddToEnd.s and | |
51 | * q????.s | |
52 | * Modified for MP, 1996 by Tuyen Nguyen | |
53 | * Modified, April 9, 1997 by Tuyen Nguyen for MacOSX. | |
54 | */ | |
8ad349bb | 55 | extern atlock_t adspgen_lock; |
1c79356b A |
56 | |
57 | ||
58 | struct qlink { | |
59 | struct qlink *qlinkp; | |
60 | }; | |
61 | ||
62 | /* ---------------------------------------------------------------------- | |
63 | * void qAddToEnd(void *qhead, void *qelem) | |
64 | * | |
65 | * INPUTS: | |
66 | * Ptr to ptr to 1st item in queue | |
67 | * Ptr to item to add to end of queue | |
68 | * OUTPUTS: | |
69 | * none | |
70 | * | |
71 | * Assumptions: The link field is the FIRST field of the qelem structure. | |
72 | * ---------------------------------------------------------------------- | |
73 | */ | |
74 | int qAddToEnd(qhead, qelem) | |
75 | struct qlink **qhead; | |
76 | struct qlink *qelem; | |
77 | { | |
78 | /* define our own type to access the next field. NOTE THAT THE "NEXT" | |
79 | * FIELD IS ASSUMED TO BE THE FIRST FIELD OF THE STRUCTURE | |
80 | */ | |
81 | ||
82 | register struct qlink *q; | |
83 | ||
84 | /* Scan the linked list to the end and update the previous | |
85 | * element next field. (do that protocted). | |
86 | */ | |
87 | ||
88 | q = *qhead; | |
89 | if (q) { | |
90 | while (q->qlinkp) { | |
91 | /* are we about to link to ourself */ | |
92 | if (q == qelem) | |
93 | goto breakit; | |
94 | q = q->qlinkp; | |
95 | } | |
96 | q->qlinkp = qelem; | |
97 | } | |
98 | else { | |
99 | *qhead = qelem; | |
100 | } | |
101 | qelem->qlinkp = (struct qlink *) 0; | |
102 | breakit: | |
103 | #ifdef NOTDEF | |
104 | DPRINTF("%s: qhead=%x added elem=%x\n","qAddToEnd", qhead, qelem); | |
105 | #endif | |
106 | return 0; | |
107 | } | |
108 | ||
109 | ||
110 | ||
111 | /* ---------------------------------------------------------------------- | |
112 | * qfind_m | |
113 | * void* qfind_m(void *qhead, void NPTR match, ProcPtr compare_fnx) | |
114 | * | |
115 | * Hunt down a linked list of queue elements calling the compare | |
116 | * function on each item. When the compare function returns true, | |
117 | * return ptr to the queue element. | |
118 | * | |
119 | * | |
120 | * INPUTS: | |
121 | * qhead Address of ptr to first item in queue | |
122 | * match | |
123 | * compare_fnx | |
124 | * OUTPUTS: | |
125 | * D0 & A0 Ptr to queue element or NIL | |
126 | * REGISTERS: | |
127 | * D0,D1,A0,A1 | |
128 | * ---------------------------------------------------------------------- | |
129 | */ | |
130 | void* qfind_m(qhead, match, compare_fnx) | |
131 | CCBPtr qhead; | |
132 | void *match; | |
133 | ProcPtr compare_fnx; | |
134 | { | |
8ad349bb | 135 | int s; |
1c79356b A |
136 | CCBPtr queue_item = qhead; |
137 | ||
8ad349bb | 138 | ATDISABLE(s, adspgen_lock); |
1c79356b A |
139 | while (queue_item) { |
140 | if ((*compare_fnx)(queue_item,match)) | |
141 | break; | |
142 | ||
143 | queue_item = queue_item->ccbLink; | |
144 | } | |
8ad349bb | 145 | ATENABLE(s, adspgen_lock); |
1c79356b A |
146 | |
147 | return (queue_item); | |
148 | } |