aboutsummaryrefslogtreecommitdiffstats
path: root/core/include
diff options
context:
space:
mode:
authorMatt Fleming <matt.fleming@intel.com>2013-03-20 17:14:21 +0000
committerMatt Fleming <matt.fleming@intel.com>2013-03-22 13:57:44 +0000
commit37d43cf9dd5dd2d2cef1e86aa651097473fd0b48 (patch)
tree07a7df546f178c4e1576f4cbcc0bb4db3a8e18b4 /core/include
parentbf20364b582c383b4927f898de213b1cc0981a80 (diff)
parenta107cb3b6fa219cf5f65bef366c9b00b108e9a3a (diff)
downloadsyslinux-37d43cf9dd5dd2d2cef1e86aa651097473fd0b48.tar.gz
syslinux-37d43cf9dd5dd2d2cef1e86aa651097473fd0b48.tar.xz
syslinux-37d43cf9dd5dd2d2cef1e86aa651097473fd0b48.zip
Merge tag 'syslinux-5.10-pre2' into for-hpa/elflink/firmware
syslinux-5.10-pre2 Conflicts: NEWS com32/include/netinet/in.h com32/include/sys/cpu.h com32/lib/Makefile core/Makefile core/fs/diskio.c core/fs/pxe/pxe.h core/init.c core/mem/free.c core/mem/malloc.c mk/devel.mk version
Diffstat (limited to 'core/include')
-rw-r--r--core/include/core.h46
-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/net.h33
-rw-r--r--core/include/thread.h115
-rw-r--r--core/include/timer.h21
8 files changed, 273 insertions, 37 deletions
diff --git a/core/include/core.h b/core/include/core.h
index aa3bfb7a..1d20040a 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];
@@ -45,6 +48,10 @@ extern uint16_t DisplayCon;
/* 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);
@@ -63,6 +70,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);
@@ -77,31 +90,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)
@@ -114,7 +102,7 @@ static inline void set_flags(com32sys_t *regs, uint32_t flags)
regs->eflags.l = eflags;
}
-extern int start_ldlinux(char **argv);
+extern int start_ldlinux(int argc, char **argv);
extern int create_args_and_load(char *);
extern void write_serial(char data);
@@ -128,7 +116,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 560458b6..b4519cee 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 *);
@@ -192,10 +189,10 @@ void fs_init(const struct fs_ops **ops, void *priv);
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/net.h b/core/include/net.h
new file mode 100644
index 00000000..4f6819f9
--- /dev/null
+++ b/core/include/net.h
@@ -0,0 +1,33 @@
+#ifndef _NET_H
+#define _NET_H
+
+#include <stdint.h>
+#include <stddef.h>
+
+/* Protocol family */
+enum net_core_proto {
+ NET_CORE_TCP,
+ NET_CORE_UDP,
+};
+
+void net_core_init(void);
+
+struct pxe_pvt_inode;
+
+int net_core_open(struct pxe_pvt_inode *socket, enum net_core_proto proto);
+void net_core_close(struct pxe_pvt_inode *socket);
+
+void net_core_connect(struct pxe_pvt_inode *socket,
+ uint32_t ip, uint16_t port);
+void net_core_disconnect(struct pxe_pvt_inode *socket);
+
+int net_core_recv(struct pxe_pvt_inode *socket, void *buf, uint16_t *buf_len,
+ uint32_t *src_ip, uint16_t *src_port);
+
+void net_core_send(struct pxe_pvt_inode *socket,
+ const void *data, size_t len);
+
+void probe_undi(void);
+void pxe_init_isr(void);
+
+#endif /* _NET_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 */