source: bootcd/isolinux/syslinux-6.03/com32/include/syslinux/movebits.h @ 26ffad7

Last change on this file since 26ffad7 was e16e8f2, checked in by Edwin Eefting <edwin@datux.nl>, 3 years ago

bootstuff

  • Property mode set to 100644
File size: 3.7 KB
Line 
1#ifndef _SYSLINUX_MOVEBITS_H
2#define _SYSLINUX_MOVEBITS_H
3
4#include <inttypes.h>
5#include <stdio.h>
6#include <stdbool.h>
7
8typedef uint32_t addr_t;
9
10/*
11 * A syslinux_movelist is a linked list of move operations.  The ordering
12 * is important, so no sorting requirement can be imposed.
13 */
14struct syslinux_movelist {
15    addr_t dst;
16    addr_t src;
17    addr_t len;
18    struct syslinux_movelist *next;
19};
20
21/*
22 * A syslinux_memmap is a sorted, linked list of memory regions,
23 * guaranteed to satisfy the constraint that no adjacent zones have
24 * the same type.  Undefined memory ranges are represented with entries;
25 * they have type SMT_UNDEFINED.
26 *
27 * Note that there is no length field.  The length of a region is obtained
28 * by looking at the start of the next entry in the chain.
29 */
30enum syslinux_memmap_types {
31    SMT_ERROR = -2,             /* Internal error token */
32    SMT_END = -1,               /* End of list */
33    SMT_UNDEFINED = 0,          /* Unknown range */
34    SMT_FREE = 1,               /* Available memory */
35    SMT_RESERVED,               /* Unusable memory */
36    SMT_ALLOC,                  /* Memory allocated by user */
37    SMT_ZERO,                   /* Memory that should be zeroed */
38    SMT_TERMINAL,               /* Memory to be used as a last resort */
39};
40
41struct syslinux_memmap {
42    addr_t start;
43    enum syslinux_memmap_types type;
44    struct syslinux_memmap *next;
45};
46
47static inline bool valid_terminal_type(enum syslinux_memmap_types type)
48{
49    return (type == SMT_FREE) || (type == SMT_TERMINAL);
50}
51
52/*
53 * moves is computed from "fraglist" and "memmap".  Areas that are
54 * to be zeroed should be marked as such in the memmap, not in the
55 * fraglist.
56 */
57
58int syslinux_compute_movelist(struct syslinux_movelist **movelist,
59                              struct syslinux_movelist *fraglist,
60                              struct syslinux_memmap *memmap);
61
62struct syslinux_memmap *syslinux_memory_map(void);
63void syslinux_free_movelist(struct syslinux_movelist *);
64int syslinux_add_movelist(struct syslinux_movelist **,
65                          addr_t dst, addr_t src, addr_t len);
66int syslinux_allocate_from_list(struct syslinux_movelist **freelist,
67                                addr_t dst, addr_t len);
68int syslinux_do_shuffle(struct syslinux_movelist *fraglist,
69                        struct syslinux_memmap *memmap,
70                        addr_t entry_point, addr_t entry_type,
71                        uint16_t bootflags);
72struct syslinux_memmap *syslinux_target_memmap(struct syslinux_movelist
73                                               *fraglist,
74                                               struct syslinux_memmap *memmap);
75
76/* Operatons on struct syslinux_memmap */
77struct syslinux_memmap *syslinux_init_memmap(void);
78int syslinux_add_memmap(struct syslinux_memmap **list,
79                        addr_t start, addr_t len,
80                        enum syslinux_memmap_types type);
81enum syslinux_memmap_types syslinux_memmap_type(struct syslinux_memmap *list,
82                                                addr_t start, addr_t len);
83int syslinux_memmap_largest(struct syslinux_memmap *list,
84                            enum syslinux_memmap_types type,
85                            addr_t * start, addr_t * len);
86int syslinux_memmap_highest(const struct syslinux_memmap *list,
87                            enum syslinux_memmap_types types,
88                            addr_t *start, addr_t len,
89                            addr_t ceiling, addr_t align);
90void syslinux_free_memmap(struct syslinux_memmap *list);
91struct syslinux_memmap *syslinux_dup_memmap(struct syslinux_memmap *list);
92int syslinux_memmap_find_type(struct syslinux_memmap *list,
93                              enum syslinux_memmap_types type,
94                              addr_t * start, addr_t * len, addr_t align);
95int syslinux_memmap_find(struct syslinux_memmap *mmap,
96                         addr_t *base, size_t size,
97                         bool relocate, size_t align,
98                         addr_t start_min, addr_t start_max,
99                         addr_t end_min, addr_t end_max);
100
101/* Debugging functions */
102#ifdef DEBUG
103void syslinux_dump_movelist(struct syslinux_movelist *ml);
104void syslinux_dump_memmap(struct syslinux_memmap *memmap);
105#else
106#define syslinux_dump_movelist(x) ((void)0)
107#define syslinux_dump_memmap(x)   ((void)0)
108#endif
109
110#endif /* _SYSLINUX_MOVEBITS_H */
Note: See TracBrowser for help on using the repository browser.