rf_callback.c revision 1.8 1 /* $NetBSD: rf_callback.c,v 1.8 2002/10/25 03:14:37 oster Exp $ */
2 /*
3 * Copyright (c) 1995 Carnegie-Mellon University.
4 * All rights reserved.
5 *
6 * Author: Jim Zelenka
7 *
8 * Permission to use, copy, modify and distribute this software and
9 * its documentation is hereby granted, provided that both the copyright
10 * notice and this permission notice appear in all copies of the
11 * software, derivative works or modified versions, and any portions
12 * thereof, and that both notices appear in supporting documentation.
13 *
14 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
15 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
16 * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
17 *
18 * Carnegie Mellon requests users of this software to return to
19 *
20 * Software Distribution Coordinator or Software.Distribution (at) CS.CMU.EDU
21 * School of Computer Science
22 * Carnegie Mellon University
23 * Pittsburgh PA 15213-3890
24 *
25 * any improvements or extensions that they make and grant Carnegie the
26 * rights to redistribute these changes.
27 */
28
29 /*****************************************************************************************
30 *
31 * callback.c -- code to manipulate callback descriptor
32 *
33 ****************************************************************************************/
34
35
36 #include <sys/cdefs.h>
37 __KERNEL_RCSID(0, "$NetBSD: rf_callback.c,v 1.8 2002/10/25 03:14:37 oster Exp $");
38
39 #include <dev/raidframe/raidframevar.h>
40 #include <sys/pool.h>
41
42 #include "rf_archs.h"
43 #include "rf_threadstuff.h"
44 #include "rf_callback.h"
45 #include "rf_debugMem.h"
46 #include "rf_freelist.h"
47 #include "rf_shutdown.h"
48
49 static struct pool rf_callback_pool;
50
51 #define RF_MAX_FREE_CALLBACK 64
52 #define RF_CALLBACK_INC 4
53 #define RF_CALLBACK_INITIAL 32
54
55 static void rf_ShutdownCallback(void *);
56 static void
57 rf_ShutdownCallback(ignored)
58 void *ignored;
59 {
60 pool_destroy(&rf_callback_pool);
61 }
62
63 int
64 rf_ConfigureCallback(listp)
65 RF_ShutdownList_t **listp;
66 {
67 int rc;
68
69 pool_init(&rf_callback_pool, sizeof(RF_CallbackDesc_t), 0, 0,
70 RF_CALLBACK_INITIAL, "rf_callbackpl", NULL);
71 pool_sethiwat(&rf_callback_pool, RF_MAX_FREE_CALLBACK);
72 rc = rf_ShutdownCreate(listp, rf_ShutdownCallback, NULL);
73 if (rc) {
74 rf_print_unable_to_add_shutdown(__FILE__,__LINE__, rc);
75 rf_ShutdownCallback(NULL);
76 return (rc);
77 }
78 return (0);
79 }
80
81 RF_CallbackDesc_t *
82 rf_AllocCallbackDesc()
83 {
84 RF_CallbackDesc_t *p;
85
86 p = pool_get(&rf_callback_pool, PR_NOWAIT);
87 return (p);
88 }
89
90 void
91 rf_FreeCallbackDesc(p)
92 RF_CallbackDesc_t *p;
93 {
94 pool_put(&rf_callback_pool, p);
95 }
96