4012413bc6555c9f5fbe79ed5b980274cc87cb95
[fw/openocd] / src / target / algorithm.c
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2
3 /***************************************************************************
4  *   Copyright (C) 2005 by Dominic Rath                                    *
5  *   Dominic.Rath@gmx.de                                                   *
6  ***************************************************************************/
7
8 #ifdef HAVE_CONFIG_H
9 #include "config.h"
10 #endif
11
12 #include "algorithm.h"
13 #include <helper/binarybuffer.h>
14
15 void init_mem_param(struct mem_param *param, uint32_t address, uint32_t size, enum param_direction direction)
16 {
17         param->address = address;
18         param->size = size;
19         param->value = malloc(size);
20         param->direction = direction;
21 }
22
23 void destroy_mem_param(struct mem_param *param)
24 {
25         free(param->value);
26         param->value = NULL;
27 }
28
29 void init_reg_param(struct reg_param *param, char *reg_name, uint32_t size, enum param_direction direction)
30 {
31         param->reg_name = reg_name;
32         param->size = size;
33         param->value = malloc(DIV_ROUND_UP(size, 8));
34         param->direction = direction;
35 }
36
37 void destroy_reg_param(struct reg_param *param)
38 {
39         free(param->value);
40         param->value = NULL;
41 }