diff options
author | H. Peter Anvin <hpa@zytor.com> | 2007-03-14 19:06:36 -0700 |
---|---|---|
committer | H. Peter Anvin <hpa@zytor.com> | 2007-03-14 19:06:36 -0700 |
commit | 37b99c20bf10933524f3b8c1ec04215d5c94c18d (patch) | |
tree | c4552e2d59ca2be9c901fda0fb2d447a8f5b7ab8 /com32/include/syslinux/movebits.h | |
parent | 0b4922aa3fb090ee05d2e7c20379aabe2a047835 (diff) | |
download | syslinux-37b99c20bf10933524f3b8c1ec04215d5c94c18d.tar.gz |
Finish the shuffle and boot interface, and add an ELF loading module.
The shuffle and boot interface, including the library support, should now
work as advertised. Add an ELF-loading module as a demo, and it's probably
useful for someone, too.
Diffstat (limited to 'com32/include/syslinux/movebits.h')
-rw-r--r-- | com32/include/syslinux/movebits.h | 69 |
1 files changed, 61 insertions, 8 deletions
diff --git a/com32/include/syslinux/movebits.h b/com32/include/syslinux/movebits.h index 95adf6eb..3a03c622 100644 --- a/com32/include/syslinux/movebits.h +++ b/com32/include/syslinux/movebits.h @@ -2,10 +2,14 @@ #define _SYSLINUX_MOVEBITS_H #include <inttypes.h> -#include <setjmp.h> +#include <stdio.h> typedef uint32_t addr_t; +/* + * A syslinux_movelist is a linked list of move operations. The ordering + * is important, so no sorting requirement can be imposed. + */ struct syslinux_movelist { addr_t dst; addr_t src; @@ -13,6 +17,32 @@ struct syslinux_movelist { struct syslinux_movelist *next; }; +/* + * A syslinux_memmap is a sorted, linked list of memory regions, + * guaranteed to satisfy the constraint that no adjacent zones have + * the same type. Undefined memory ranges are represented with entries; + * they have type SMT_UNDEFINED. + * + * Note that there is no length field. The length of a region is obtained + * by looking at the start of the next entry in the chain. + */ +enum syslinux_memmap_types { + SMT_ERROR = -2, /* Internal error token */ + SMT_END = -1, /* End of list */ + SMT_UNDEFINED = 0, /* Unknown range */ + SMT_FREE = 1, /* Available memory */ + SMT_RESERVED, /* Unusable memory */ + SMT_ALLOC, /* Memory allocated by user */ + SMT_ZERO, /* Memory that should be zeroed */ +}; + +struct syslinux_memmap { + addr_t start; + enum syslinux_memmap_types type; + struct syslinux_memmap *next; +}; + + struct syslinux_pm_regs { uint32_t eax, ecx, edx, ebx; uint32_t esp, ebp, esi, edi; @@ -20,25 +50,48 @@ struct syslinux_pm_regs { }; /* - * moves is computed from "frags" and "freemem". "space" lists - * free memory areas at our disposal, and is (src, cnt) only. + * moves is computed from "fraglist" and "memmap". Areas that are + * to be zeroed should be marked as such in the memmap, not in the + * fraglist. */ -int syslinux_compute_movelist(struct syslinux_movelist **, - struct syslinux_movelist *, - struct syslinux_movelist *); +int syslinux_compute_movelist(struct syslinux_movelist **movelist, + struct syslinux_movelist *fraglist, + struct syslinux_memmap *memmap); -struct syslinux_movelist *syslinux_memory_map(void); +struct syslinux_memmap *syslinux_memory_map(void); void syslinux_free_movelist(struct syslinux_movelist *); int syslinux_add_movelist(struct syslinux_movelist **, addr_t dst, addr_t src, addr_t len); -int syslinux_prepare_shuffle(struct syslinux_movelist *fraglist); +int syslinux_allocate_from_list(struct syslinux_movelist **freelist, + addr_t dst, addr_t len); +int syslinux_prepare_shuffle(struct syslinux_movelist *fraglist, + struct syslinux_memmap *memmap); int syslinux_shuffle_boot_rm(struct syslinux_movelist *fraglist, + struct syslinux_memmap *memmap, uint16_t bootflags, uint32_t edx, uint32_t esi, uint16_t ds, uint16_t cs, uint16_t ip); int syslinux_shuffle_boot_pm(struct syslinux_movelist *fraglist, + struct syslinux_memmap *memmap, uint16_t bootflags, struct syslinux_pm_regs *regs); +/* Operatons on struct syslinux_memmap */ +struct syslinux_memmap *syslinux_init_memmap(void); +int syslinux_add_memmap(struct syslinux_memmap **list, + addr_t start, addr_t len, + enum syslinux_memmap_types type); +enum syslinux_memmap_types syslinux_memmap_type(struct syslinux_memmap *list, + addr_t start, addr_t len); +int syslinux_memmap_largest(struct syslinux_memmap *list, + enum syslinux_memmap_types type, + addr_t *start, addr_t *len); +void syslinux_free_memmap(struct syslinux_memmap *list); +struct syslinux_memmap *syslinux_dup_memmap(struct syslinux_memmap *list); + +/* Debugging functions */ +void syslinux_dump_movelist(FILE *file, struct syslinux_movelist *ml); +void syslinux_dump_memmap(FILE *file, struct syslinux_memmap *memmap); + #endif /* _SYSLINUX_MOVEBITS_H */ |