event.c
上传用户:lgb322
上传日期:2013-02-24
资源大小:30529k
文件大小:2k
- /*
- * event.c
- *
- * a device for sending from kernel to appl.
- *
- * Author: Yong-iL Joh <tolkien@mizi.com>
- * Date : $Date: 2002/05/14 02:19:42 $
- *
- * $Revision: 1.1.2.4 $
- Tue 15 Jan 2002 Yong-iL Joh <tolkien@mizi.com>
- - initial, see "kernel vs Application API spec (0.5, draft)"
- Fri May 10 2002 Yong-iL Joh <tolkien@mizi.com>
- - kernel vs app. API spec (draft) v1.33
- *
- * This file is subject to the terms and conditions of the GNU General Public
- * License. See the file COPYING in the main directory of this archive
- * for more details.
- */
- #include <linux/config.h>
- #include <linux/module.h>
- #include <linux/kernel.h>
- #include <linux/init.h>
- #include <linux/poll.h>
- #include <linux/errno.h>
- #include <asm/hardware.h>
- /*
- system捞 sleep栏肺 甸绢埃 捞饶,
- I/O device啊 wakeup登扁 傈鳖瘤 i/o access啊 甸绢坷绰 版快
- 芭何秦具 茄促.
- */
- int mz_sys_state = MZ_SYS_UNKNOWN;
- DECLARE_WAIT_QUEUE_HEAD(mz_event_queue);
- struct mz_event_queue_t mz_event_q;
- #define INCBUF(x,mod) (((x)+1) & ((mod) - 1))
- static void mz_event_task_handler(void *data) {
- wake_up_interruptible(&mz_event_queue);
- }
- static struct tq_struct mz_event_task = {
- routine: mz_event_task_handler
- };
- void event_notify(int x_evt) {
- if (x_evt == SYSTEM_SLEEP)
- mz_sys_state = MZ_SYS_SLEEP;
- else if (x_evt == SYSTEM_WAKEUP)
- mz_sys_state = MZ_SYS_WAKEUP;
- mz_event_q.buf[mz_event_q.head] = x_evt;
- mz_event_q.head = INCBUF(mz_event_q.head, MZ_EVENT_BUF_SIZE);
- if (mz_event_q.head == mz_event_q.tail)
- mz_event_q.tail = INCBUF(mz_event_q.tail, MZ_EVENT_BUF_SIZE);
- schedule_task(&mz_event_task);
- }
- static int __init event_init(void)
- {
- init_waitqueue_head(&mz_event_queue);
- mz_event_q.head = mz_event_q.tail = 0;
- return 0;
- }
- module_init(event_init);
- MODULE_AUTHOR("Yong-iL Joh");
- MODULE_DESCRIPTION("a device for sending from kernel to appl.");
- EXPORT_SYMBOL(event_notify);
- EXPORT_SYMBOL(mz_event_queue);
- EXPORT_SYMBOL(mz_event_q);
- EXPORT_SYMBOL(mz_sys_state);
- /*
- | $Id: event.c,v 1.1.2.4 2002/05/14 02:19:42 tolkien Exp $
- |
- | Local Variables:
- | mode: c
- | mode: font-lock
- | version-control: t
- | delete-old-versions: t
- | End:
- |
- | -*- End-Of-File -*-
- */