aboutsummaryrefslogtreecommitdiffstats
path: root/core/include
diff options
context:
space:
mode:
authorMatt Fleming <matt.fleming@intel.com>2013-02-25 15:25:16 +0000
committerMatt Fleming <matt.fleming@intel.com>2013-02-26 11:29:04 +0000
commit76da2ae050d72a31fd47c2fb53f7081781de62ff (patch)
tree6da146b5f19ca17ff24d4e74940f14264d38f914 /core/include
parent41c29c26d70fde563d7c255872bbadad87a39dfa (diff)
parent79312306de0150ef64213ef9fbc5aa8580544f03 (diff)
downloadsyslinux-76da2ae050d72a31fd47c2fb53f7081781de62ff.tar.gz
syslinux-76da2ae050d72a31fd47c2fb53f7081781de62ff.tar.xz
syslinux-76da2ae050d72a31fd47c2fb53f7081781de62ff.zip
Merge branch 'lwip' into elflink
Welcome to Syslinux 5.10. Conflicts: NEWS com32/lib/Makefile com32/lib/sys/open.c com32/lib/syslinux/ipappend.c com32/modules/Makefile com32/modules/prdhcp.c core/Makefile core/cmdline.inc core/com32.inc core/comboot.inc core/configinit.inc core/fs/chdir.c core/fs/fs.c core/fs/pxe/dnsresolv.c core/fs/pxe/pxe.c core/fs/pxe/pxe.h core/idle.c core/include/ctype.h core/init.inc core/mem/init.c core/parseconfig.inc core/runkernel.inc core/syslinux.ld core/ui.inc doc/comboot.txt version
Diffstat (limited to 'core/include')
-rw-r--r--core/include/core.h44
-rw-r--r--core/include/ctype.h12
-rw-r--r--core/include/fs.h13
-rw-r--r--core/include/kaboom.h11
-rw-r--r--core/include/mbox.h59
-rw-r--r--core/include/thread.h115
-rw-r--r--core/include/timer.h21
7 files changed, 239 insertions, 36 deletions
diff --git a/core/include/core.h b/core/include/core.h
index d54495bb..d35bd038 100644
--- a/core/include/core.h
+++ b/core/include/core.h
@@ -11,6 +11,9 @@
#include <com32.h>
#include <errno.h>
#include <syslinux/pmapi.h>
+#include <syslinux/sysappend.h>
+#include <kaboom.h>
+#include <timer.h>
extern char core_xfer_buf[65536];
extern char core_cache_buf[65536];
@@ -42,6 +45,10 @@ extern uint8_t FlowIgnore;
/* diskstart.inc isolinux.asm*/
extern void getlinsec(void);
+/* pm.inc */
+void core_pm_null_hook(void);
+extern void (*core_pm_hook)(void);
+
/* getc.inc */
extern void core_open(void);
@@ -60,6 +67,12 @@ extern void *zalloc(size_t);
extern void free(void *);
extern void mem_init(void);
+/* sysappend.c */
+extern void print_sysappend(void);
+extern const char *sysappend_strings[SYSAPPEND_MAX];
+extern uint32_t SysAppends;
+extern void sysappend_set_uuid(const uint8_t *uuid);
+
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);
@@ -74,31 +87,6 @@ void call16(void (*)(void), const com32sys_t *, com32sys_t *);
#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;
-}
-
-/*
* Helper routine to return a specific set of flags
*/
static inline void set_flags(com32sys_t *regs, uint32_t flags)
@@ -125,7 +113,11 @@ extern void cleanup_hardware(void);
extern void sirq_cleanup(void);
extern void adjust_screen(void);
-extern void execute(const char *cmdline, uint32_t type);
+extern void execute(const char *cmdline, uint32_t type, bool sysappend);
extern void load_kernel(const char *cmdline);
+extern void dmi_init(void);
+
+extern void do_sysappend(char *buf);
+
#endif /* CORE_H */
diff --git a/core/include/ctype.h b/core/include/ctype.h
index 048a77d6..6c7f57f4 100644
--- a/core/include/ctype.h
+++ b/core/include/ctype.h
@@ -22,9 +22,17 @@ static inline int tolower(int c)
return c;
}
-static inline int isspace(int c)
+static inline int isspace(int ch)
{
- return c <= ' ';
+ int space = 0;
+ if ((ch == ' ') ||
+ (ch == '\f') ||
+ (ch == '\n') ||
+ (ch == '\r') ||
+ (ch == '\t') ||
+ (ch == '\v'))
+ space = 1;
+ return space;
}
#endif /* CTYPE_H */
diff --git a/core/include/fs.h b/core/include/fs.h
index 5c13f5b5..c7d0fd75 100644
--- a/core/include/fs.h
+++ b/core/include/fs.h
@@ -12,12 +12,9 @@
#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.
+ * Maximum number of open files.
*/
-#define MAX_OPEN_LG2 5
+#define MAX_OPEN_LG2 7
#define MAX_OPEN (1 << MAX_OPEN_LG2)
#define FILENAME_MAX_LG2 8
@@ -56,7 +53,7 @@ struct fs_ops {
enum fs_flags fs_flags;
int (*fs_init)(struct fs_info *);
- void (*searchdir)(const char *, struct file *);
+ void (*searchdir)(const char *, int, struct file *);
uint32_t (*getfssec)(struct file *, char *, int, bool *);
void (*close_file)(struct file *);
void (*mangle_name)(char *, const char *);
@@ -191,10 +188,10 @@ extern char *PATH;
void pm_mangle_name(com32sys_t *);
void pm_searchdir(com32sys_t *);
void mangle_name(char *, const char *);
-int searchdir(const char *name);
+int searchdir(const char *name, int flags);
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);
+int open_file(const char *name, int flags, struct com32_filedata *filedata);
void pm_open_file(com32sys_t *);
void close_file(uint16_t handle);
void pm_close_file(com32sys_t *);
diff --git a/core/include/kaboom.h b/core/include/kaboom.h
new file mode 100644
index 00000000..4a763be9
--- /dev/null
+++ b/core/include/kaboom.h
@@ -0,0 +1,11 @@
+#ifndef KABOOM_H
+#define KABOOM_H
+
+/*
+ * Death! The macro trick is to avoid symbol conflict with
+ * the real-mode symbol kaboom.
+ */
+__noreturn _kaboom(void);
+#define kaboom() _kaboom()
+
+#endif /* KABOOM_H */
diff --git a/core/include/mbox.h b/core/include/mbox.h
new file mode 100644
index 00000000..3c35ce4e
--- /dev/null
+++ b/core/include/mbox.h
@@ -0,0 +1,59 @@
+/*
+ * mbox.h
+ *
+ * Simple thread mailbox interface
+ */
+
+#ifndef _MBOX_H
+#define _MBOX_H
+
+#include "thread.h"
+
+/*
+ * If a mailbox is allocated statically (as a struct mailbox), this
+ * is the number of slots it gets.
+ */
+#define MAILBOX_STATIC_SIZE 512
+
+struct mailbox {
+ struct semaphore prod_sem; /* Producer semaphore (empty slots) */
+ struct semaphore cons_sem; /* Consumer semaphore (data slots) */
+ struct semaphore head_sem; /* Head pointer semaphore */
+ struct semaphore tail_sem; /* Tail pointer semaphore */
+ void **wrap; /* Where pointers wrap */
+ void **head; /* Head pointer */
+ void **tail; /* Tail pointer */
+
+ void *data[MAILBOX_STATIC_SIZE]; /* Data array */
+};
+
+/* The number of bytes for an mailbox of size s */
+#define MBOX_BYTES(s) (sizeof(struct mailbox) + \
+ ((s)-MAILBOX_STATIC_SIZE)*sizeof(void *))
+
+void mbox_init(struct mailbox *mbox, size_t size);
+int mbox_post(struct mailbox *mbox, void *msg, mstime_t timeout);
+mstime_t mbox_fetch(struct mailbox *mbox, void **msg, mstime_t timeout);
+
+/*
+ * This marks a mailbox object as unusable; it will remain unusable
+ * until sem_init() is called on it again. This DOES NOT clear the
+ * list of blocked processes on this mailbox!
+ *
+ * It is also possible to mark the mailbox invalid by zeroing its
+ * memory structure.
+ */
+static inline void mbox_set_invalid(struct mailbox *mbox)
+{
+ sem_set_invalid(&mbox->prod_sem);
+}
+
+/*
+ * Ask if a mailbox object has been initialized.
+ */
+static inline bool mbox_is_valid(struct mailbox *mbox)
+{
+ return sem_is_valid(&mbox->prod_sem);
+}
+
+#endif /* _MBOX_H */
diff --git a/core/include/thread.h b/core/include/thread.h
new file mode 100644
index 00000000..6bfdfaa7
--- /dev/null
+++ b/core/include/thread.h
@@ -0,0 +1,115 @@
+#ifndef _THREAD_H
+#define _THREAD_H
+
+#include <stddef.h>
+#include <inttypes.h>
+#include <limits.h>
+#include <stdbool.h>
+#include <timer.h>
+#include <sys/cpu.h>
+
+/* The idle thread runs at this priority */
+#define IDLE_THREAD_PRIORITY INT_MAX
+
+/* This priority should normally be used for hardware-polling threads */
+#define POLL_THREAD_PRIORITY (INT_MAX-1)
+
+struct semaphore;
+
+struct thread_list {
+ struct thread_list *next, *prev;
+};
+
+/*
+ * Stack frame used by __switch_to, see thread_asm.S
+ */
+struct thread_stack {
+ int errno;
+ uint16_t rmsp, rmss;
+ uint32_t edi, esi, ebp, ebx;
+ void (*eip)(void);
+};
+
+struct thread_block {
+ struct thread_list list;
+ struct thread *thread;
+ struct semaphore *semaphore;
+ mstime_t block_time;
+ mstime_t timeout;
+ bool timed_out;
+};
+
+#define THREAD_MAGIC 0x3568eb7d
+
+struct thread {
+ struct thread_stack *esp; /* Must be first; stack pointer */
+ unsigned int thread_magic;
+ const char *name; /* Name (for debugging) */
+ struct thread_list list;
+ struct thread_block *blocked;
+ void *stack, *rmstack; /* Stacks, iff allocated by malloc/lmalloc */
+ void *pvt; /* For the benefit of lwIP */
+ int prio;
+};
+
+extern void (*sched_hook_func)(void);
+
+void __thread_process_timeouts(void);
+void __schedule(void);
+void __switch_to(struct thread *);
+void thread_yield(void);
+
+extern struct thread *__current;
+static inline struct thread *current(void)
+{
+ return __current;
+}
+
+struct semaphore {
+ int count;
+ struct thread_list list;
+};
+
+#define DECLARE_INIT_SEMAPHORE(sem, cnt) \
+ struct semaphore sem = { \
+ .count = (cnt), \
+ .list = { \
+ .next = &sem.list, \
+ .prev = &sem.list \
+ } \
+ }
+
+mstime_t sem_down(struct semaphore *, mstime_t);
+void sem_up(struct semaphore *);
+void sem_init(struct semaphore *, int);
+
+/*
+ * This marks a semaphore object as unusable; it will remain unusable
+ * until sem_init() is called on it again. This DOES NOT clear the
+ * list of blocked processes on this semaphore!
+ *
+ * It is also possible to mark the semaphore invalid by zeroing its
+ * memory structure.
+ */
+static inline void sem_set_invalid(struct semaphore *sem)
+{
+ sem->list.next = NULL;
+}
+
+/*
+ * Ask if a semaphore object has been initialized.
+ */
+static inline bool sem_is_valid(struct semaphore *sem)
+{
+ return !!sem->list.next;
+}
+
+struct thread *start_thread(const char *name, size_t stack_size, int prio,
+ void (*start_func)(void *), void *func_arg);
+void __exit_thread(void);
+void kill_thread(struct thread *);
+
+void start_idle_thread(void);
+void test_thread(void);
+
+#endif /* _THREAD_H */
diff --git a/core/include/timer.h b/core/include/timer.h
new file mode 100644
index 00000000..1d66ba73
--- /dev/null
+++ b/core/include/timer.h
@@ -0,0 +1,21 @@
+#ifndef TIMER_H
+#define TIMER_H
+
+/*
+ * Basic timer function...
+ */
+typedef uint32_t jiffies_t;
+extern volatile jiffies_t __jiffies, __ms_timer;
+static inline jiffies_t jiffies(void)
+{
+ return __jiffies;
+}
+
+typedef uint32_t mstime_t;
+typedef int32_t mstimediff_t;
+static inline mstime_t ms_timer(void)
+{
+ return __ms_timer;
+}
+
+#endif /* TIMER_H */