1 /* $NetBSD: rf_callback.c,v 1.24 2019/10/10 03:43:59 christos 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@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.24 2019/10/10 03:43:59 christos 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_general.h" 47 #include "rf_shutdown.h" 48 #include "rf_netbsd.h" 49 50 #define RF_MAX_FREE_CALLBACK 64 51 #define RF_MIN_FREE_CALLBACK 32 52 53 static void rf_ShutdownCallback(void *); 54 static void 55 rf_ShutdownCallback(void *ignored) 56 { 57 pool_destroy(&rf_pools.callbackf); 58 pool_destroy(&rf_pools.callbackv); 59 } 60 61 int 62 rf_ConfigureCallback(RF_ShutdownList_t **listp) 63 { 64 65 rf_pool_init(&rf_pools.callbackf, sizeof(RF_CallbackFuncDesc_t), 66 "rf_callbackfpl", RF_MIN_FREE_CALLBACK, RF_MAX_FREE_CALLBACK); 67 rf_pool_init(&rf_pools.callbackv, sizeof(RF_CallbackValueDesc_t), 68 "rf_callbackvpl", RF_MIN_FREE_CALLBACK, RF_MAX_FREE_CALLBACK); 69 rf_ShutdownCreate(listp, rf_ShutdownCallback, NULL); 70 71 return (0); 72 } 73 74 RF_CallbackFuncDesc_t * 75 rf_AllocCallbackFuncDesc(void) 76 { 77 return pool_get(&rf_pools.callbackf, PR_WAITOK); 78 } 79 80 void 81 rf_FreeCallbackFuncDesc(RF_CallbackFuncDesc_t *p) 82 { 83 pool_put(&rf_pools.callbackf, p); 84 } 85 86 RF_CallbackValueDesc_t * 87 rf_AllocCallbackValueDesc(void) 88 { 89 return pool_get(&rf_pools.callbackv, PR_WAITOK); 90 } 91 92 void 93 rf_FreeCallbackValueDesc(RF_CallbackValueDesc_t *p) 94 { 95 pool_put(&rf_pools.callbackv, p); 96 } 97