com32: make syslinux_dump_*() pure debugging functions
[profile/ivi/syslinux.git] / com32 / include / syslinux / movebits.h
1 #ifndef _SYSLINUX_MOVEBITS_H
2 #define _SYSLINUX_MOVEBITS_H
3
4 #include <inttypes.h>
5 #include <stdio.h>
6
7 typedef uint32_t addr_t;
8
9 /*
10  * A syslinux_movelist is a linked list of move operations.  The ordering
11  * is important, so no sorting requirement can be imposed.
12  */
13 struct syslinux_movelist {
14     addr_t dst;
15     addr_t src;
16     addr_t len;
17     struct syslinux_movelist *next;
18 };
19
20 /*
21  * A syslinux_memmap is a sorted, linked list of memory regions,
22  * guaranteed to satisfy the constraint that no adjacent zones have
23  * the same type.  Undefined memory ranges are represented with entries;
24  * they have type SMT_UNDEFINED.
25  *
26  * Note that there is no length field.  The length of a region is obtained
27  * by looking at the start of the next entry in the chain.
28  */
29 enum syslinux_memmap_types {
30     SMT_ERROR = -2,             /* Internal error token */
31     SMT_END = -1,               /* End of list */
32     SMT_UNDEFINED = 0,          /* Unknown range */
33     SMT_FREE = 1,               /* Available memory */
34     SMT_RESERVED,               /* Unusable memory */
35     SMT_ALLOC,                  /* Memory allocated by user */
36     SMT_ZERO,                   /* Memory that should be zeroed */
37 };
38
39 struct syslinux_memmap {
40     addr_t start;
41     enum syslinux_memmap_types type;
42     struct syslinux_memmap *next;
43 };
44
45 /*
46  * moves is computed from "fraglist" and "memmap".  Areas that are
47  * to be zeroed should be marked as such in the memmap, not in the
48  * fraglist.
49  */
50
51 int syslinux_compute_movelist(struct syslinux_movelist **movelist,
52                               struct syslinux_movelist *fraglist,
53                               struct syslinux_memmap *memmap);
54
55 struct syslinux_memmap *syslinux_memory_map(void);
56 void syslinux_free_movelist(struct syslinux_movelist *);
57 int syslinux_add_movelist(struct syslinux_movelist **,
58                           addr_t dst, addr_t src, addr_t len);
59 int syslinux_allocate_from_list(struct syslinux_movelist **freelist,
60                                 addr_t dst, addr_t len);
61 int syslinux_do_shuffle(struct syslinux_movelist *fraglist,
62                         struct syslinux_memmap *memmap,
63                         addr_t entry_point, addr_t entry_type,
64                         uint16_t bootflags);
65 struct syslinux_memmap *syslinux_target_memmap(struct syslinux_movelist
66                                                *fraglist,
67                                                struct syslinux_memmap *memmap);
68
69 /* Operatons on struct syslinux_memmap */
70 struct syslinux_memmap *syslinux_init_memmap(void);
71 int syslinux_add_memmap(struct syslinux_memmap **list,
72                         addr_t start, addr_t len,
73                         enum syslinux_memmap_types type);
74 enum syslinux_memmap_types syslinux_memmap_type(struct syslinux_memmap *list,
75                                                 addr_t start, addr_t len);
76 int syslinux_memmap_largest(struct syslinux_memmap *list,
77                             enum syslinux_memmap_types type,
78                             addr_t * start, addr_t * len);
79 void syslinux_free_memmap(struct syslinux_memmap *list);
80 struct syslinux_memmap *syslinux_dup_memmap(struct syslinux_memmap *list);
81 int syslinux_memmap_find(struct syslinux_memmap *list,
82                          enum syslinux_memmap_types type,
83                          addr_t * start, addr_t * len, addr_t align);
84
85 /* Debugging functions */
86 #ifdef DEBUG
87 void syslinux_dump_movelist(struct syslinux_movelist *ml);
88 void syslinux_dump_memmap(struct syslinux_memmap *memmap);
89 #else
90 #define syslinux_dump_movelist(x) ((void)0)
91 #define syslinux_dump_memmap(x)   ((void)0)
92 #endif
93
94 #endif /* _SYSLINUX_MOVEBITS_H */