14e98e3e1Schristos /* Hardware memory allocator. 2*88241920Schristos Copyright (C) 1998-2024 Free Software Foundation, Inc. 34e98e3e1Schristos Contributed by Cygnus Support. 44e98e3e1Schristos 54e98e3e1Schristos This file is part of GDB, the GNU debugger. 64e98e3e1Schristos 74e98e3e1Schristos This program is free software; you can redistribute it and/or modify 84e98e3e1Schristos it under the terms of the GNU General Public License as published by 94e98e3e1Schristos the Free Software Foundation; either version 3 of the License, or 104e98e3e1Schristos (at your option) any later version. 114e98e3e1Schristos 124e98e3e1Schristos This program is distributed in the hope that it will be useful, 134e98e3e1Schristos but WITHOUT ANY WARRANTY; without even the implied warranty of 144e98e3e1Schristos MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 154e98e3e1Schristos GNU General Public License for more details. 164e98e3e1Schristos 174e98e3e1Schristos You should have received a copy of the GNU General Public License 184e98e3e1Schristos along with this program. If not, see <http://www.gnu.org/licenses/>. */ 194e98e3e1Schristos 204e98e3e1Schristos 214e98e3e1Schristos #ifndef HW_ALLOC_H 224e98e3e1Schristos #define HW_ALLOC_H 234e98e3e1Schristos 244e98e3e1Schristos /* Mechanism for associating memory allocated by a device to that 254e98e3e1Schristos device. 264e98e3e1Schristos 274e98e3e1Schristos When a device is deleted any remaining memory regions associated to 284e98e3e1Schristos it are reclaimed. 294e98e3e1Schristos 304e98e3e1Schristos FIXME: Perhaphs this can be generalized. Perhaphs it should not 314e98e3e1Schristos be. */ 324e98e3e1Schristos 334e98e3e1Schristos 344e98e3e1Schristos #define HW_ZALLOC(me,type) (type*) hw_zalloc (me, sizeof (type)) 354e98e3e1Schristos #define HW_MALLOC(me,type) (type*) hw_malloc (me, sizeof (type)) 364e98e3e1Schristos #define HW_NALLOC(me,type,n) (type*) hw_malloc (me, sizeof (type) * (n)) 374e98e3e1Schristos #define HW_NZALLOC(me,type,n) (type*) hw_zalloc (me, sizeof (type) * (n)) 384e98e3e1Schristos 394e98e3e1Schristos extern void *hw_zalloc (struct hw *me, unsigned long size); 404e98e3e1Schristos extern void *hw_malloc (struct hw *me, unsigned long size); 414e98e3e1Schristos 424e98e3e1Schristos extern void hw_free (struct hw *me, void *); 434e98e3e1Schristos 444e98e3e1Schristos 454e98e3e1Schristos /* Duplicate a string allocating memory using the per-device heap */ 464e98e3e1Schristos 474e98e3e1Schristos extern char *hw_strdup (struct hw *me, const char *str); 484e98e3e1Schristos 494e98e3e1Schristos #endif 50