1 #ifndef _SYSLINUX_MOVEBITS_H
2 #define _SYSLINUX_MOVEBITS_H
7 typedef uint32_t addr_t;
10 * A syslinux_movelist is a linked list of move operations. The ordering
11 * is important, so no sorting requirement can be imposed.
13 struct syslinux_movelist {
17 struct syslinux_movelist *next;
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.
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.
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 */
39 struct syslinux_memmap {
41 enum syslinux_memmap_types type;
42 struct syslinux_memmap *next;
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
51 int syslinux_compute_movelist(struct syslinux_movelist **movelist,
52 struct syslinux_movelist *fraglist,
53 struct syslinux_memmap *memmap);
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,
65 struct syslinux_memmap *syslinux_target_memmap(struct syslinux_movelist
67 struct syslinux_memmap *memmap);
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);
85 /* Debugging functions */
86 void syslinux_dump_movelist(FILE * file, struct syslinux_movelist *ml);
87 void syslinux_dump_memmap(FILE * file, struct syslinux_memmap *memmap);
89 #endif /* _SYSLINUX_MOVEBITS_H */