/*1* Copyright (c) 2018 naehrwert2* Copyright (c) 2018-2024 CTCaer3*4* This program is free software; you can redistribute it and/or modify it5* under the terms and conditions of the GNU General Public License,6* version 2, as published by the Free Software Foundation.7*8* This program is distributed in the hope it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for11* more details.12*13* You should have received a copy of the GNU General Public License14* along with this program. If not, see <http://www.gnu.org/licenses/>.15*/1617#ifndef _HEAP_H_18#define _HEAP_H_1920#include <utils/types.h>2122typedef struct _hnode23{24int used;25u32 size;26struct _hnode *prev;27struct _hnode *next;28u32 align[4]; // Align to arch cache line size.29} hnode_t;3031typedef struct _heap32{33void *start;34hnode_t *first;35hnode_t *last;36} heap_t;3738typedef struct39{40u32 total;41u32 used;42u32 nodes_total;43u32 nodes_used;44} heap_monitor_t;4546void heap_init(void *base);47void heap_set(heap_t *heap);48void *malloc(u32 size);49void *calloc(u32 num, u32 size);50void *zalloc(u32 size);51void free(void *buf);52void heap_monitor(heap_monitor_t *mon, bool print_node_stats);5354#endif555657