OpenCores
URL https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk

Subversion Repositories openrisc_2011-10-31

[/] [openrisc/] [trunk/] [rtos/] [rtems/] [c/] [src/] [libnetworking/] [kern/] [uipc_domain.c] - Blame information for rev 318

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 30 unneback
/*
2
 * Copyright (c) 1982, 1986, 1993
3
 *      The Regents of the University of California.  All rights reserved.
4
 *
5
 * Redistribution and use in source and binary forms, with or without
6
 * modification, are permitted provided that the following conditions
7
 * are met:
8
 * 1. Redistributions of source code must retain the above copyright
9
 *    notice, this list of conditions and the following disclaimer.
10
 * 2. Redistributions in binary form must reproduce the above copyright
11
 *    notice, this list of conditions and the following disclaimer in the
12
 *    documentation and/or other materials provided with the distribution.
13
 * 3. All advertising materials mentioning features or use of this software
14
 *    must display the following acknowledgement:
15
 *      This product includes software developed by the University of
16
 *      California, Berkeley and its contributors.
17
 * 4. Neither the name of the University nor the names of its contributors
18
 *    may be used to endorse or promote products derived from this software
19
 *    without specific prior written permission.
20
 *
21
 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31
 * SUCH DAMAGE.
32
 *
33
 *      @(#)uipc_domain.c       8.2 (Berkeley) 10/18/93
34
 * $Id: uipc_domain.c,v 1.2 2001-09-27 12:01:51 chris Exp $
35
 */
36
 
37
#include <sys/param.h>
38
#include <sys/socket.h>
39
#include <sys/protosw.h>
40
#include <sys/domain.h>
41
#include <sys/mbuf.h>
42
#include <sys/kernel.h>
43
#include <sys/systm.h>
44
 
45
/*
46
 * System initialization
47
 *
48
 * Note: domain initialization wants to take place on a per domain basis
49
 * as a result of traversing a linker set.  Most likely, each domain
50
 * want to call a registration function rather than being handled here
51
 * in domaininit().  Probably this will look like:
52
 *
53
 * SYSINIT(unique, SI_SUB_PROTO_DOMAI, SI_ORDER_ANY, domain_add, xxx)
54
 *
55
 * Where 'xxx' is replaced by the address of a parameter struct to be
56
 * passed to the doamin_add() function.
57
 */
58
 
59
#if !defined(__rtems__)
60
static int      x_save_spl;                     /* used by kludge*/
61
static void kludge_splimp __P((void *));
62
static void kludge_splx __P((void *));
63
       void domaininit __P((void *));
64
SYSINIT(splimp, SI_SUB_PROTO_BEGIN, SI_ORDER_FIRST, kludge_splimp, &x_save_spl)
65
SYSINIT(domain, SI_SUB_PROTO_DOMAIN, SI_ORDER_FIRST, domaininit, NULL)
66
SYSINIT(splx, SI_SUB_PROTO_END, SI_ORDER_FIRST, kludge_splx, &x_save_spl)
67
#endif
68
 
69
static void     pffasttimo __P((void *));
70
static void     pfslowtimo __P((void *));
71
 
72
struct domain *domains;
73
 
74
#define ADDDOMAIN(x)    { \
75
        __CONCAT(x,domain.dom_next) = domains; \
76
        domains = &__CONCAT(x,domain); \
77
}
78
 
79
extern struct linker_set domain_set;
80
 
81
/* ARGSUSED*/
82
void
83
domaininit(dummy)
84
        void *dummy;
85
{
86
        register struct domain *dp;
87
        register struct protosw *pr;
88
 
89
/* - not in our sources
90
#ifdef ISDN
91
        ADDDOMAIN(isdn);
92
#endif
93
*/
94
 
95
        for (dp = domains; dp; dp = dp->dom_next) {
96
                if (dp->dom_init)
97
                        (*dp->dom_init)();
98
                for (pr = dp->dom_protosw; pr < dp->dom_protoswNPROTOSW; pr++){
99
#ifdef PRU_OLDSTYLE
100
                        /* See comments in uipc_socket2.c. */
101
                        if (pr->pr_usrreqs == 0 && pr->pr_ousrreq)
102
                                pr->pr_usrreqs = &pru_oldstyle;
103
#endif
104
                        if (pr->pr_init)
105
                                (*pr->pr_init)();
106
                }
107
        }
108
 
109
        if (max_linkhdr < 16)           /* XXX */
110
                max_linkhdr = 16;
111
        max_hdr = max_linkhdr + max_protohdr;
112
        max_datalen = MHLEN - max_hdr;
113
        timeout(pffasttimo, (void *)0, 1);
114
        timeout(pfslowtimo, (void *)0, 1);
115
}
116
 
117
 
118
#if !defined(__rtems__)
119
/*
120
 * The following two operations are kludge code.  Most likely, they should
121
 * be done as a "domainpreinit()" for the first function and then rolled
122
 * in as the last act of "domaininit()" for the second.
123
 *
124
 * In point of fact, it is questionable why other initialization prior
125
 * to this does not also take place at splimp by default.
126
 */
127
static void
128
kludge_splimp(udata)
129
        void *udata;
130
{
131
        int     *savesplp = udata;
132
 
133
        *savesplp = splimp();
134
}
135
 
136
static void
137
kludge_splx(udata)
138
        void *udata;
139
{
140
        int     *savesplp = udata;
141
 
142
        splx( *savesplp);
143
}
144
#endif /* !defined(__rtems__) */
145
 
146
struct protosw *
147
pffindtype(int family, int type)
148
{
149
        register struct domain *dp;
150
        register struct protosw *pr;
151
 
152
        for (dp = domains; dp; dp = dp->dom_next)
153
                if (dp->dom_family == family)
154
                        goto found;
155
        return (0);
156
found:
157
        for (pr = dp->dom_protosw; pr < dp->dom_protoswNPROTOSW; pr++)
158
                if (pr->pr_type && pr->pr_type == type)
159
                        return (pr);
160
        return (0);
161
}
162
 
163
struct protosw *
164
pffindproto(int family, int protocol, int type)
165
{
166
        register struct domain *dp;
167
        register struct protosw *pr;
168
        struct protosw *maybe = 0;
169
 
170
        if (family == 0)
171
                return (0);
172
        for (dp = domains; dp; dp = dp->dom_next)
173
                if (dp->dom_family == family)
174
                        goto found;
175
        return (0);
176
found:
177
        for (pr = dp->dom_protosw; pr < dp->dom_protoswNPROTOSW; pr++) {
178
                if ((pr->pr_protocol == protocol) && (pr->pr_type == type))
179
                        return (pr);
180
 
181
                if (type == SOCK_RAW && pr->pr_type == SOCK_RAW &&
182
                    pr->pr_protocol == 0 && maybe == (struct protosw *)0)
183
                        maybe = pr;
184
        }
185
        return (maybe);
186
}
187
 
188
void
189
pfctlinput(cmd, sa)
190
        int cmd;
191
        struct sockaddr *sa;
192
{
193
        register struct domain *dp;
194
        register struct protosw *pr;
195
 
196
        for (dp = domains; dp; dp = dp->dom_next)
197
                for (pr = dp->dom_protosw; pr < dp->dom_protoswNPROTOSW; pr++)
198
                        if (pr->pr_ctlinput)
199
                                (*pr->pr_ctlinput)(cmd, sa, (void *)0);
200
}
201
 
202
static void
203
pfslowtimo(arg)
204
        void *arg;
205
{
206
        register struct domain *dp;
207
        register struct protosw *pr;
208
 
209
        for (dp = domains; dp; dp = dp->dom_next)
210
                for (pr = dp->dom_protosw; pr < dp->dom_protoswNPROTOSW; pr++)
211
                        if (pr->pr_slowtimo)
212
                                (*pr->pr_slowtimo)();
213
        timeout(pfslowtimo, (void *)0, hz/2);
214
}
215
 
216
static void
217
pffasttimo(arg)
218
        void *arg;
219
{
220
        register struct domain *dp;
221
        register struct protosw *pr;
222
 
223
        for (dp = domains; dp; dp = dp->dom_next)
224
                for (pr = dp->dom_protosw; pr < dp->dom_protoswNPROTOSW; pr++)
225
                        if (pr->pr_fasttimo)
226
                                (*pr->pr_fasttimo)();
227
        timeout(pffasttimo, (void *)0, hz/5);
228
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.