aboutsummaryrefslogtreecommitdiffstats
path: root/com32/libutil/include/movebits.h
blob: de6ee1ffd569e9bafdc4885e5b6501bdb54dcd25 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#ifndef LIBUTIL_MOVEBITS_H
#define LIBUTIL_MOVEBITS_H

#include <inttypes.h>
#include <setjmp.h>

struct movelist {
  uintptr_t dst;
  uintptr_t src;
  uintptr_t len;
  struct movelist *next;
};

struct move_descriptor {
  uint32_t dst;
  uint32_t src;
  uint32_t len;
};

/*
 * Creates a movelist consisting of only one element, and
 * if parent == NULL insert into the movelist chain immediately after
 * the parent element.
 */
struct movelist *
make_movelist(struct movelist *parent, uintptr_t dst,
	      uintptr_t src, uintptr_t len);

/*
 * Convert a movelist into a linear array of struct move_descriptors,
 * returning the number of descriptors and freeing the movelist.
 *
 * Returns (size_t)-1 on failure; if so the movelist is still valid.
 */
size_t
linearize_movelist(struct move_descriptor **d, struct movelist *m);

/*
 * moves is computed from "frags" and "freemem".  "space" lists
 * free memory areas at our disposal, and is (src, cnt) only.
 */

int
compute_movelist(struct movelist **moves, struct movelist *frags,
		 struct movelist *space);

#endif /* LIBUTIL_MOVEBITS_H */