1/* 2 * Copyright 2016, Data61 3 * Commonwealth Scientific and Industrial Research Organisation (CSIRO) 4 * ABN 41 687 119 230. 5 * 6 * This software may be distributed and modified according to the terms of 7 * the BSD 2-Clause license. Note that NO WARRANTY is provided. 8 * See "LICENSE_BSD2.txt" for details. 9 * 10 * @TAG(D61_BSD) 11 */ 12 13#ifndef _C_OBJECT_ALLOCATION_TABLE_H_ 14#define _C_OBJECT_ALLOCATION_TABLE_H_ 15 16#include <stdint.h> 17#include <stdbool.h> 18#include <data_struct/cvector.h> 19#include <data_struct/cpool.h> 20 21#define COAT_INVALID_ID -1 22#define COAT_ARGS 4 23 24struct coat_s; 25typedef struct coat_s coat_t; 26 27// Not a bad idea to 'inherit' this struct. 28struct coat_s { 29 // Config 30 void (*oat_expand)(cvector_t *table); 31 cvector_item_t (*oat_create)(coat_t *oat, int id, uint32_t arg[COAT_ARGS]); 32 void (*oat_delete)(coat_t *oat, cvector_item_t *obj); 33 34 // Members. 35 cpool_t /* indexes */ pool; 36 cvector_t /* cvector_item_t */ table; 37}; 38 39void coat_init(coat_t *t, int start, int end); 40 41void coat_release(coat_t *t); 42 43int coat_alloc(coat_t *t, uint32_t arg[COAT_ARGS], cvector_item_t *out_obj); 44 45cvector_item_t coat_get(coat_t *t, int id); 46 47int coat_free(coat_t *t, int id); 48 49#endif /* _C_OBJECT_ALLOCATION_TABLE_H_ */ 50