diff options
Diffstat (limited to 'contrib/syslinux-4.02/core/include')
-rw-r--r-- | contrib/syslinux-4.02/core/include/cache.h | 23 | ||||
-rw-r--r-- | contrib/syslinux-4.02/core/include/codepage.h | 27 | ||||
-rw-r--r-- | contrib/syslinux-4.02/core/include/core.h | 78 | ||||
-rw-r--r-- | contrib/syslinux-4.02/core/include/ctype.h | 25 | ||||
-rw-r--r-- | contrib/syslinux-4.02/core/include/disk.h | 37 | ||||
-rw-r--r-- | contrib/syslinux-4.02/core/include/fs.h | 227 | ||||
-rw-r--r-- | contrib/syslinux-4.02/core/include/pmapi.h | 8 |
7 files changed, 425 insertions, 0 deletions
diff --git a/contrib/syslinux-4.02/core/include/cache.h b/contrib/syslinux-4.02/core/include/cache.h new file mode 100644 index 0000000..1f451af --- /dev/null +++ b/contrib/syslinux-4.02/core/include/cache.h @@ -0,0 +1,23 @@ +#ifndef _CACHE_H +#define _CACHE_H + +#include <stdint.h> +#include <com32.h> +#include "disk.h" +#include "fs.h" + +/* The cache structure */ +struct cache { + block_t block; + struct cache *prev; + struct cache *next; + void *data; +}; + +/* functions defined in cache.c */ +void cache_init(struct device *, int); +const void *get_cache(struct device *, block_t); +struct cache *_get_cache_block(struct device *, block_t); +void cache_lock_block(struct cache *); + +#endif /* cache.h */ diff --git a/contrib/syslinux-4.02/core/include/codepage.h b/contrib/syslinux-4.02/core/include/codepage.h new file mode 100644 index 0000000..a24d90f --- /dev/null +++ b/contrib/syslinux-4.02/core/include/codepage.h @@ -0,0 +1,27 @@ +/* + * Codepage data structure as generated by cptable.pl + */ +#ifndef CODEPAGE_H +#define CODEPAGE_H + +#include <stdint.h> + +#define CODEPAGE_MAGIC UINT64_C(0x51d21eb158a8b3d4) + +struct codepage { + uint64_t magic; + uint32_t reserved[6]; + + uint8_t upper[256]; /* Codepage upper case table */ + uint8_t lower[256]; /* Codepage lower case table */ + + /* + * The primary Unicode match is the same case, i.e. A -> A, + * the secondary Unicode match is the opposite case, i.e. A -> a. + */ + uint16_t uni[2][256]; /* Primary and alternate Unicode matches */ +}; + +extern const struct codepage codepage; + +#endif /* CODEPAGE_H */ diff --git a/contrib/syslinux-4.02/core/include/core.h b/contrib/syslinux-4.02/core/include/core.h new file mode 100644 index 0000000..7db5daf --- /dev/null +++ b/contrib/syslinux-4.02/core/include/core.h @@ -0,0 +1,78 @@ +#ifndef CORE_H +#define CORE_H + +#include <klibc/compiler.h> +#include <com32.h> +#include <syslinux/pmapi.h> + +extern char core_xfer_buf[65536]; +extern char core_cache_buf[65536]; +extern char trackbuf[]; +extern char CurrentDirName[]; +extern char SubvolName[]; +extern char ConfigName[]; +extern char KernelName[]; +extern char cmd_line[]; +extern char ConfigFile[]; + +/* diskstart.inc isolinux.asm*/ +extern void getlinsec(void); + +/* getc.inc */ +extern void core_open(void); + +/* hello.c */ +extern void myputs(const char*); + +/* idle.c */ +extern int (*idle_hook_func)(void); +extern void __idle(void); +extern void reset_idle(void); + +/* mem/malloc.c, mem/free.c, mem/init.c */ +extern void *malloc(size_t); +extern void *lmalloc(size_t); +extern void *pmapi_lmalloc(size_t); +extern void *zalloc(size_t); +extern void free(void *); +extern void mem_init(void); + +void __cdecl core_intcall(uint8_t, const com32sys_t *, com32sys_t *); +void __cdecl core_farcall(uint32_t, const com32sys_t *, com32sys_t *); +int __cdecl core_cfarcall(uint32_t, const void *, uint32_t); + +extern const com32sys_t zero_regs; +void call16(void (*)(void), const com32sys_t *, com32sys_t *); + +/* + * __lowmem is in the low 1 MB; __bss16 in the low 64K + */ +#define __lowmem __attribute__((nocommon,section(".lowmem"))) +#define __bss16 __attribute__((nocommon,section(".bss16"))) + +/* + * Section for very large aligned objects, not zeroed on startup + */ +#define __hugebss __attribute__((nocommon,section(".hugebss"),aligned(4096))) + +/* + * Death! The macro trick is to avoid symbol conflict with + * the real-mode symbol kaboom. + */ +__noreturn _kaboom(void); +#define kaboom() _kaboom() + +/* + * Basic timer function... + */ +extern volatile uint32_t __jiffies, __ms_timer; +static inline uint32_t jiffies(void) +{ + return __jiffies; +} +static inline uint32_t ms_timer(void) +{ + return __ms_timer; +} + +#endif /* CORE_H */ diff --git a/contrib/syslinux-4.02/core/include/ctype.h b/contrib/syslinux-4.02/core/include/ctype.h new file mode 100644 index 0000000..5c6d4cb --- /dev/null +++ b/contrib/syslinux-4.02/core/include/ctype.h @@ -0,0 +1,25 @@ +#ifndef CTYPE_H +#define CTYPE_H + +/* + * Small subset of <ctype.h> for parsing uses, only handles ASCII + * and passes the rest through. + */ + +static inline int toupper(int c) +{ + if (c >= 'a' && c <= 'z') + c -= 0x20; + + return c; +} + +static inline int tolower(int c) +{ + if (c >= 'A' && c <= 'Z') + c += 0x20; + + return c; +} + +#endif /* CTYPE_H */ diff --git a/contrib/syslinux-4.02/core/include/disk.h b/contrib/syslinux-4.02/core/include/disk.h new file mode 100644 index 0000000..ac23e92 --- /dev/null +++ b/contrib/syslinux-4.02/core/include/disk.h @@ -0,0 +1,37 @@ +#ifndef DISK_H +#define DISK_H + +#include <stddef.h> +#include <stdint.h> +#include <stdbool.h> + +typedef uint64_t sector_t; +typedef uint64_t block_t; + +/* + * struct disk: contains the information about a specific disk and also + * contains the I/O function. + */ +struct disk { + unsigned int disk_number; /* in BIOS style */ + unsigned int sector_size; /* gener512B or 2048B */ + unsigned int sector_shift; + unsigned int maxtransfer; /* Max sectors per transfer */ + + unsigned int h, s; /* CHS geometry */ + unsigned int secpercyl; /* h*s */ + unsigned int _pad; + + sector_t part_start; /* the start address of this partition(in sectors) */ + + int (*rdwr_sectors)(struct disk *, void *, sector_t, size_t, bool); +}; + +extern void read_sectors(char *, sector_t, int); +extern void getoneblk(struct disk *, char *, block_t, int); + +/* diskio.c */ +struct disk *disk_init(uint8_t, bool, sector_t, uint16_t, uint16_t, uint32_t); +struct device *device_init(uint8_t, bool, sector_t, uint16_t, uint16_t, uint32_t); + +#endif /* DISK_H */ diff --git a/contrib/syslinux-4.02/core/include/fs.h b/contrib/syslinux-4.02/core/include/fs.h new file mode 100644 index 0000000..ecd148d --- /dev/null +++ b/contrib/syslinux-4.02/core/include/fs.h @@ -0,0 +1,227 @@ +#ifndef FS_H +#define FS_H + +#include <stddef.h> +#include <stdbool.h> +#include <string.h> +#include <com32.h> +#include <stdio.h> +#include <sys/dirent.h> +#include "core.h" +#include "disk.h" + +/* + * Maximum number of open files. This is *currently* constrained by the + * fact that PXE needs to be able to fit all its packet buffers into a + * 64K segment; this should be fixed by moving the packet buffers to high + * memory. + */ +#define MAX_OPEN_LG2 5 +#define MAX_OPEN (1 << MAX_OPEN_LG2) + +#define FILENAME_MAX_LG2 8 +#define FILENAME_MAX (1 << FILENAME_MAX_LG2) + +#define CURRENTDIR_MAX FILENAME_MAX + +#define BLOCK_SIZE(fs) ((fs)->block_size) +#define BLOCK_SHIFT(fs) ((fs)->block_shift) +#define SECTOR_SIZE(fs) ((fs)->sector_size) +#define SECTOR_SHIFT(fs) ((fs)->sector_shift) + +struct fs_info { + const struct fs_ops *fs_ops; + struct device *fs_dev; + void *fs_info; /* The fs-specific information */ + int sector_shift, sector_size; + int block_shift, block_size; + struct inode *root, *cwd; /* Root and current directories */ + char cwd_name[CURRENTDIR_MAX]; /* Current directory by name */ +}; + +extern struct fs_info *this_fs; + +struct dirent; /* Directory entry structure */ +struct file; +enum fs_flags { + FS_NODEV = 1 << 0, + FS_USEMEM = 1 << 1, /* If we need a malloc routine, set it */ + FS_THISIND = 1 << 2, /* Set cwd based on config file location */ +}; + +struct fs_ops { + /* in fact, we use fs_ops structure to find the right fs */ + const char *fs_name; + enum fs_flags fs_flags; + + int (*fs_init)(struct fs_info *); + void (*searchdir)(const char *, struct file *); + uint32_t (*getfssec)(struct file *, char *, int, bool *); + void (*close_file)(struct file *); + void (*mangle_name)(char *, const char *); + size_t (*realpath)(struct fs_info *, char *, const char *, size_t); + int (*chdir)(struct fs_info *, const char *); + int (*load_config)(void); + + struct inode * (*iget_root)(struct fs_info *); + struct inode * (*iget)(const char *, struct inode *); + int (*readlink)(struct inode *, char *); + + /* the _dir_ stuff */ + int (*readdir)(struct file *, struct dirent *); + + int (*next_extent)(struct inode *, uint32_t); +}; + +/* + * Extent structure: contains the mapping of some chunk of a file + * that is contiguous on disk. + */ +struct extent { + sector_t pstart; /* Physical start sector */ + uint32_t lstart; /* Logical start sector */ + uint32_t len; /* Number of contiguous sectors */ +}; + +/* Special sector numbers used for struct extent.pstart */ +#define EXTENT_ZERO ((sector_t)-1) /* All-zero extent */ +#define EXTENT_VOID ((sector_t)-2) /* Invalid information */ + +#define EXTENT_SPECIAL(x) ((x) >= EXTENT_VOID) + +/* + * The inode structure, including the detail file information + */ +struct inode { + struct fs_info *fs; /* The filesystem this inode is associated with */ + struct inode *parent; /* Parent directory, if any */ + int refcnt; + int mode; /* FILE , DIR or SYMLINK */ + uint32_t size; + uint32_t blocks; /* How many blocks the file take */ + uint32_t ino; /* Inode number */ + uint32_t atime; /* Access time */ + uint32_t mtime; /* Modify time */ + uint32_t ctime; /* Create time */ + uint32_t dtime; /* Delete time */ + uint32_t flags; + uint32_t file_acl; + struct extent this_extent, next_extent; + char pvt[0]; /* Private filesystem data */ +}; + +struct file { + struct fs_info *fs; + uint32_t offset; /* for next read */ + struct inode *inode; /* The file-specific information */ +}; + +/* + * Struct device contains: + * the pointer points to the disk structure, + * the cache stuff. + */ +struct cache; + +struct device { + struct disk *disk; + + /* the cache stuff */ + char *cache_data; + struct cache *cache_head; + uint16_t cache_block_size; + uint16_t cache_entries; + uint32_t cache_size; +}; + +/* + * Our definition of "not whitespace" + */ +static inline bool not_whitespace(char c) +{ + return (unsigned char)c > ' '; +} + +/* + * Inode allocator/deallocator + */ +struct inode *alloc_inode(struct fs_info *fs, uint32_t ino, size_t data); +static inline void free_inode(struct inode * inode) +{ + free(inode); +} + +static inline struct inode *get_inode(struct inode *inode) +{ + inode->refcnt++; + return inode; +} + +void put_inode(struct inode *inode); + +static inline void malloc_error(char *obj) +{ + printf("Out of memory: can't allocate memory for %s\n", obj); + kaboom(); +} + +/* + * File handle conversion functions + */ +extern struct file files[]; +static inline uint16_t file_to_handle(struct file *file) +{ + return file ? (file - files)+1 : 0; +} +static inline struct file *handle_to_file(uint16_t handle) +{ + return handle ? &files[handle-1] : NULL; +} + +/* fs.c */ +void pm_mangle_name(com32sys_t *); +void pm_searchdir(com32sys_t *); +void mangle_name(char *, const char *); +int searchdir(const char *name); +void _close_file(struct file *); +size_t pmapi_read_file(uint16_t *handle, void *buf, size_t sectors); +int open_file(const char *name, struct com32_filedata *filedata); +void pm_open_file(com32sys_t *); +void close_file(uint16_t handle); +void pm_close_file(com32sys_t *); + +/* chdir.c */ +void pm_realpath(com32sys_t *regs); +size_t realpath(char *dst, const char *src, size_t bufsize); +int chdir(const char *src); + +/* readdir.c */ +DIR *opendir(const char *pathname); +struct dirent *readdir(DIR *dir); +int closedir(DIR *dir); + +/* getcwd.c */ +char *getcwd(char *buf, size_t size); + +/* + * Generic functions that filesystem drivers may choose to use + */ + +/* mangle.c */ +void generic_mangle_name(char *, const char *); + +/* loadconfig.c */ +int search_config(const char *search_directores[], const char *filenames[]); +int generic_load_config(void); + +/* close.c */ +void generic_close_file(struct file *file); + +/* getfssec.c */ +uint32_t generic_getfssec(struct file *file, char *buf, + int sectors, bool *have_more); + +/* nonextextent.c */ +int no_next_extent(struct inode *, uint32_t); + +#endif /* FS_H */ diff --git a/contrib/syslinux-4.02/core/include/pmapi.h b/contrib/syslinux-4.02/core/include/pmapi.h new file mode 100644 index 0000000..57d2e6f --- /dev/null +++ b/contrib/syslinux-4.02/core/include/pmapi.h @@ -0,0 +1,8 @@ +#ifndef PMAPI_H +#define PMAPI_H + +#include <syslinux/pmapi.h> + +size_t pmapi_read_file(uint16_t *, void *, size_t); + +#endif /* PMAPI_H */ |