-/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
- * vim:expandtab:shiftwidth=8:tabstop=8:
- *
+/*
* GPL HEADER START
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* GPL HEADER END
*/
/*
- * Copyright 2008 Sun Microsystems, Inc. All rights reserved
+ * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
* Use is subject to license terms.
*/
/*
#error Do not #include this file directly. #include <libcfs/libcfs.h> instead
#endif
+#ifndef EXPORT_SYMBOL
+# define EXPORT_SYMBOL(s)
+#endif
+
#ifdef __KERNEL__
#include <sys/types.h>
#include <sys/systm.h>
*/
#define CONFIG_SYSCTL 1
-typedef struct sysctl_oid * cfs_sysctl_table_t;
-typedef cfs_sysctl_table_t cfs_sysctl_table_header_t;
-cfs_sysctl_table_header_t *cfs_register_sysctl_table (cfs_sysctl_table_t *table, int arg);
-void cfs_unregister_sysctl_table (cfs_sysctl_table_header_t *table);
+#define ctl_table sysctl_oid
+struct ctl_table *register_sysctl_table(struct ctl_table *table);
+void unregister_sysctl_table(struct ctl_table *table);
/*
* Proc file system APIs, no /proc fs support in OSX
/*
* cfs pseudo device
*
- * cfs_psdev_t
- * cfs_psdev_register:
- * cfs_psdev_deregister:
+ * struct miscdevice
+ * misc_register:
+ * misc_deregister:
*/
-typedef struct {
+struct miscdevice{
int index;
void *handle;
const char *name;
struct cdevsw *devsw;
void *private;
-} cfs_psdev_t;
+};
-extern kern_return_t cfs_psdev_register(cfs_psdev_t *);
-extern kern_return_t cfs_psdev_deregister(cfs_psdev_t *);
+extern kern_return_t misc_register(struct miscdevice *);
+extern kern_return_t misc_deregister(struct miscdevice *);
/*
* Task struct and ...
#ifdef __DARWIN8__
-typedef struct {} cfs_task_t;
-#define cfs_current() ((cfs_task_t *)current_thread())
+typedef struct task_struct {};
+#define current ((struct task_struct *)current_thread())
#else /* !__DARWIN8__ */
-typedef struct uthread cfs_task_t;
+#define task_struct uthread
#define current_uthread() ((struct uthread *)get_bsdthread_info(current_act()))
-#define cfs_current() current_uthread()
+#define current current_uthread()
#endif /* !__DARWIN8__ */
-#define cfs_task_lock(t) do {;} while (0)
-#define cfs_task_unlock(t) do {;} while (0)
+#define task_lock(t) do {;} while (0)
+#define task_unlock(t) do {;} while (0)
#define set_current_state(s) do {;} while (0)
-#define CFS_DECL_JOURNAL_DATA
-#define CFS_PUSH_JOURNAL do {;} while(0)
-#define CFS_POP_JOURNAL do {;} while(0)
+#define DECL_JOURNAL_DATA
+#define PUSH_JOURNAL do {;} while(0)
+#define POP_JOURNAL do {;} while(0)
-#define THREAD_NAME(comm, fmt, a...)
/*
* Kernel thread:
*
#define CLONE_SIGNAL (CLONE_SIGHAND | CLONE_THREAD)
-extern int cfs_kernel_thread(cfs_thread_t func, void *arg, int flag);
-
+extern struct task_struct kthread_run(cfs_thread_t func, void *arg,
+ const char namefmt[], ...);
/*
* Wait Queue implementation
*/
typedef struct cfs_waitq {
struct ksleep_chan wq_ksleep_chan;
-} cfs_waitq_t;
+} wait_queue_head_t;
typedef struct cfs_waitlink {
struct cfs_waitq *wl_waitq;
struct ksleep_link wl_ksleep_link;
-} cfs_waitlink_t;
-
-typedef int cfs_task_state_t;
+} wait_queue_t;
-#define CFS_TASK_INTERRUPTIBLE THREAD_ABORTSAFE
-#define CFS_TASK_UNINT THREAD_UNINT
+#define TASK_INTERRUPTIBLE THREAD_ABORTSAFE
+#define TASK_UNINTERRUPTIBLE THREAD_UNINT
-void cfs_waitq_init(struct cfs_waitq *waitq);
-void cfs_waitlink_init(struct cfs_waitlink *link);
+void init_waitqueue_head(struct cfs_waitq *waitq);
+void init_waitqueue_entry_current(struct cfs_waitlink *link);
-void cfs_waitq_add(struct cfs_waitq *waitq, struct cfs_waitlink *link);
-void cfs_waitq_add_exclusive(struct cfs_waitq *waitq,
+void add_wait_queue(struct cfs_waitq *waitq, struct cfs_waitlink *link);
+void add_wait_queue_exclusive(struct cfs_waitq *waitq,
struct cfs_waitlink *link);
-void cfs_waitq_del(struct cfs_waitq *waitq, struct cfs_waitlink *link);
-int cfs_waitq_active(struct cfs_waitq *waitq);
+void remove_wait_queue(struct cfs_waitq *waitq, struct cfs_waitlink *link);
+int waitqueue_active(struct cfs_waitq *waitq);
-void cfs_waitq_signal(struct cfs_waitq *waitq);
-void cfs_waitq_signal_nr(struct cfs_waitq *waitq, int nr);
-void cfs_waitq_broadcast(struct cfs_waitq *waitq);
+void wake_up(struct cfs_waitq *waitq);
+void wake_up_nr(struct cfs_waitq *waitq, int nr);
+void wake_up_all(struct cfs_waitq *waitq);
-void cfs_waitq_wait(struct cfs_waitlink *link, cfs_task_state_t state);
-cfs_duration_t cfs_waitq_timedwait(struct cfs_waitlink *link,
- cfs_task_state_t state,
+void waitq_wait(struct cfs_waitlink *link, long state);
+cfs_duration_t waitq_timedwait(struct cfs_waitlink *link,
+ long state,
cfs_duration_t timeout);
/*
extern void thread_set_timer_deadline(__u64 deadline);
extern void thread_cancel_timer(void);
-static inline int cfs_schedule_timeout(int state, int64_t timeout)
+static inline int schedule_timeout(int state, int64_t timeout)
{
int result;
return result;
}
-#define cfs_schedule() cfs_schedule_timeout(CFS_TASK_UNINT, CFS_TICK)
-#define cfs_pause(tick) cfs_schedule_timeout(CFS_TASK_UNINT, tick)
+#define schedule() schedule_timeout(TASK_UNINTERRUPTIBLE, CFS_TICK)
+#define cfs_pause(tick) schedule_timeout(TASK_UNINTERRUPTIBLE, tick)
#define __wait_event(wq, condition) \
do { \
struct cfs_waitlink __wait; \
\
- cfs_waitlink_init(&__wait); \
+ init_waitqueue_entry_current(&__wait); \
for (;;) { \
- cfs_waitq_add(&wq, &__wait); \
+ add_wait_queue(&wq, &__wait); \
if (condition) \
break; \
- cfs_waitq_wait(&__wait, CFS_TASK_UNINT); \
- cfs_waitq_del(&wq, &__wait); \
+ waitq_wait(&__wait, TASK_UNINTERRUPTIBLE); \
+ remove_wait_queue(&wq, &__wait); \
} \
- cfs_waitq_del(&wq, &__wait); \
+ remove_wait_queue(&wq, &__wait); \
} while (0)
#define wait_event(wq, condition) \
do { \
struct cfs_waitlink __wait; \
\
- cfs_waitlink_init(&__wait); \
+ init_waitqueue_entry_current(&__wait); \
for (;;) { \
if (ex == 0) \
- cfs_waitq_add(&wq, &__wait); \
+ add_wait_queue(&wq, &__wait); \
else \
- cfs_waitq_add_exclusive(&wq, &__wait); \
+ add_wait_queue_exclusive(&wq, &__wait); \
if (condition) \
break; \
if (!cfs_signal_pending()) { \
- cfs_waitq_wait(&__wait, \
- CFS_TASK_INTERRUPTIBLE); \
- cfs_waitq_del(&wq, &__wait); \
+ waitq_wait(&__wait, \
+ TASK_INTERRUPTIBLE); \
+ remove_wait_queue(&wq, &__wait); \
continue; \
} \
ret = -ERESTARTSYS; \
break; \
} \
- cfs_waitq_del(&wq, &__wait); \
+ remove_wait_queue(&wq, &__wait); \
} while (0)
#define wait_event_interruptible(wq, condition) \
} while (0)
/* used in couple of places */
-static inline void sleep_on(cfs_waitq_t *waitq)
+static inline void sleep_on(wait_queue_head_t *waitq)
{
- cfs_waitlink_t link;
+ wait_queue_t link;
- cfs_waitlink_init(&link);
- cfs_waitq_add(waitq, &link);
- cfs_waitq_wait(&link, CFS_TASK_UNINT);
- cfs_waitq_del(waitq, &link);
+ init_waitqueue_entry_current(&link);
+ add_wait_queue(waitq, &link);
+ waitq_wait(&link, TASK_UNINTERRUPTIBLE);
+ remove_wait_queue(waitq, &link);
}
/*
* Signal
*/
-typedef sigset_t cfs_sigset_t;
-#define SIGNAL_MASK_ASSERT()
/*
* Timer
*/
-typedef struct cfs_timer {
+struct timer_list {
struct ktimer t;
-} cfs_timer_t;
+};
#define cfs_init_timer(t) do {} while(0)
-void cfs_timer_init(struct cfs_timer *t, void (*func)(unsigned long), void *arg);
-void cfs_timer_done(struct cfs_timer *t);
-void cfs_timer_arm(struct cfs_timer *t, cfs_time_t deadline);
-void cfs_timer_disarm(struct cfs_timer *t);
-int cfs_timer_is_armed(struct cfs_timer *t);
+void cfs_timer_init(struct timer_list *t, void (*func)(unsigned long), void *arg);
+void cfs_timer_done(struct timer_list *t);
+void cfs_timer_arm(struct timer_list *t, cfs_time_t deadline);
+void cfs_timer_disarm(struct timer_list *t);
+int cfs_timer_is_armed(struct timer_list *t);
-cfs_time_t cfs_timer_deadline(struct cfs_timer *t);
+cfs_time_t cfs_timer_deadline(struct timer_list *t);
/*
* Ioctl
/* XXX smp_call_function is not supported in xnu */
#define smp_call_function(f, a, n, w) do {} while(0)
int cfs_online_cpus(void);
-#define smp_num_cpus cfs_online_cpus()
/*
* Misc
#define unlikely(exp) (exp)
#endif
-#define lock_kernel() do {} while(0)
-#define unlock_kernel() do {} while(0)
+#define lock_kernel() do {} while(0)
+#define unlock_kernel() do {} while(0)
-#define USERMODEHELPER(path, argv, envp) (0)
+#define call_usermodehelper(path, argv, envp, 1) (0)
#define cfs_module(name, version, init, fini) \
extern kern_return_t _start(kmod_info_t *ki, void *data); \
#define inter_module_get(n) cfs_symbol_get(n)
#define inter_module_put(n) cfs_symbol_put(n)
-static inline int request_module(char *name)
+static inline int request_module(const char *name, ...)
{
return (-EINVAL);
}
#define __init
#endif
-#define EXPORT_SYMBOL(s)
#define MODULE_AUTHOR(s)
#define MODULE_DESCRIPTION(s)
#define MODULE_LICENSE(s)
#define MODULE_PARM(a, b)
#define MODULE_PARM_DESC(a, b)
-#define KERNEL_VERSION(a,b,c) ((a)*100+(b)*10+c)
-#define LINUX_VERSION_CODE KERNEL_VERSION(2,5,0)
-
#define NR_IRQS 512
#define in_interrupt() ml_at_interrupt_context()