📄 supporting functions.htm
字号:
</p><h4><tt>request_irq()</tt></h4>
<tt>int request_irq(unsigned int irq, void (*handler)(int), unsigned long flags, const char *device)</tt><br>
<tt>#include <linux/sched.h></tt><br>
<tt>#include <linux/errno.h></tt>
<p>Request an IRQ from the kernel, and install an IRQ interrupt
handler if successful. Takes four arguments:
</p><dl>
<dt><tt>irq</tt>
</dt><dd>The IRQ being requested.
</dd><dt><tt>handler</tt>
</dt><dd>The handler to be called when the IRQ occurs.
The argument to the handler function will be the number of the IRQ
that it was invoked to handle.
</dd><dt><tt>flags</tt>
</dt><dd>Set to <tt>SA_INTERRUPT</tt> to request a ``fast''
interrupt or 0 to request a normal, ``slow'' one.
</dd><dt><tt>device</tt>
</dt><dd>A string containing the name of the device
driver, <i>device</i>.
</dd><dt><b>Returns:</b>
</dt><dd><tt>-EINVAL</tt> if <tt>irq</tt> > 15 or
<tt>handler</tt> = <tt>NULL</tt>.<br>
<tt>-EBUSY</tt> if <tt>irq</tt> is already allocated.<br>
0 on success.
</dd></dl><p>If you need more functionality in your interrupt handling,
use the <tt>irqaction()</tt> function. This uses most of the
capabilities of the <tt>sigaction</tt> structure to provide
interrupt services similar to to the signal services provided
by <tt>sigaction()</tt> to user-level programs.
</p><p><b>Defined in:</b> kernel/irq.c<br>
<b>See also:</b> <tt>free_irq()</tt>, <tt>irqaction()</tt>.
</p><h4><tt>select_wait()</tt></h4>
<tt>inline void select_wait(struct wait_queue **wait_address, select_table *p)</tt><br>
<tt>#include <linux/sched.h></tt>
<p>Add a process to the proper <tt>select_wait</tt> queue.
This function takes two arguments:
</p><dl>
<dt><tt>wait_address</tt>
</dt><dd>Address of a <tt>wait_queue</tt> pointer to add to the circular
list of waits.
</dd><dt><tt>p</tt>
<dd.if =""><tt>p</tt> is <tt>NULL</tt>, <tt>select_wait</tt> does
nothing, otherwise the current process is put to sleep. This should
be the <tt>select_table *wait</tt> variable that was passed to your
<tt>select()</tt> function.
</dd.if></dt></dl>
<p><b>Defined in:</b> linux/sched.h<br>
<b>See also:</b> <tt>*sleep_on(), wake_up*()</tt>
</p><h4><tt>*sleep_on()</tt></h4>
<tt>void sleep_on(struct wait_queue ** p)</tt><br>
<tt>void interruptible_sleep_on(struct wait_queue ** p)</tt><br>
<tt>#include <linux/sched.h></tt>
<p>Sleep on an event, putting a <tt>wait_queue</tt> entry in
the list so that the process can be woken on that event.
<tt>sleep_on()</tt> goes into an uninteruptible sleep: The only
way the process can run is to be woken by <tt>wake_up()</tt>.
<tt>interruptible_sleep_on()</tt> goes into an interruptible
sleep that can be woken by signals and process timeouts will
cause the process to wake up. A call to
<tt>wake_up_interruptible()</tt> is necessary to wake up the
process and allow it to continue running where it left off.
Both take one argument:
</p><dl>
<dt><tt>p</tt>
</dt><dd>Pointer to a proper <tt>wait_queue</tt> structure
that records the information needed to wake the process.
</dd></dl>
<p><b>Defined in:</b> kernel/sched.c<br>
<b>See also:</b> <tt>select_wait()</tt>, <tt>wake_up*()</tt>.
</p><h4><tt>sti()</tt></h4>
<tt>#define sti() __asm__ __volatile__ ("sti"::)</tt><br>
<tt>#include <asm/system.h></tt>
<p>Allows interrupts to be acknowledged. <tt>sti</tt> stands
for ``SeT Interrupt enable''.
</p><p><b>Defined in:</b> asm/system.h<br>
<b>See also:</b> <tt>cli()</tt>.
</p><h4><tt>sys_get*()</tt></h4>
<tt>int sys_getpid(void)</tt><br>
<tt>int sys_getuid(void)</tt><br>
<tt>int sys_getgid(void)</tt><br>
<tt>int sys_geteuid(void)</tt><br>
<tt>int sys_getegid(void)</tt><br>
<tt>int sys_getppid(void)</tt><br>
<tt>int sys_getpgrp(void)</tt>
<p>These system calls may be used to get the information
described in the table below, or the information can be
extracted directly from the process table, like this:<br>
<tt><i>foo</i> = current-><i>pid</i>;</tt><br>
<table border="1">
<tbody><tr><td><tt>pid</tt></td><td>Process ID</td></tr>
<tr><td><tt>uid</tt></td><td>User ID</td></tr>
<tr><td><tt>gid</tt></td><td>Group ID</td></tr>
<tr><td><tt>euid</tt></td><td>Effective user ID</td></tr>
<tr><td><tt>egid</tt></td><td>Effective group ID</td></tr>
<tr><td><tt>ppid</tt></td><td>Process ID of process' parent process</td></tr>
<tr><td><tt>pgid</tt></td><td>Group ID of process' parent process</td></tr>
</tbody></table>
</p><p>The system calls should not be used because they are slower
<i>and</i> take more space. Because of this, they are no
longer exported as symbols throughout the whole kernel.
</p><p><b>Defined in:</b> kernel/sched.c
</p><h4><tt>unregister_*dev()</tt></h4>
<tt>int unregister_chrdev(unsigned int major, const char *name)</tt><br>
<tt>int unregister_blkdev(unsigned int major, const char *name)</tt><br>
<tt>#include <linux/fs.h></tt><br>
<tt>#include <linux/errno.h></tt>
<p>Removes the registration for a device device with the
kernel, letting the kernel give the major number to some other
device. Takes two arguments:
</p><dl>
<dt><tt>major</tt>
</dt><dd>Major number of device being registered.
Must be the same number given to <tt>register_*dev()</tt>.
</dd><dt><tt>name</tt>
</dt><dd>Unique string identifying driver.
Must be the same number given to <tt>register_*dev()</tt>.
</dd><dt><b>Returns:</b>
</dt><dd><tt>-EINVAL</tt> if major is >= <tt>MAX_CHRDEV</tt> or
<tt>MAX_BLKDEV</tt> (defined in <tt><linux/fs.h></tt>),
for character or block devices, respectively, or if there have
not been file operations registered for major device
<tt>major</tt>, or if <tt>name</tt> is not the same name that
the device was registered with.<br>
0 on success.
</dd></dl>
<p><b>Defined in:</b> fs/devices.c<br>
<b>See also:</b> <tt>register_*dev()</tt>
</p><h4><tt>wake_up*()</tt></h4>
<tt>void wake_up(struct wait_queue ** p)</tt><br>
<tt>void wake_up_interruptible(struct wait_queue ** p)</tt><br>
<tt>#include <linux/sched.h></tt>
<p>Wakes up a process that has been put to sleep by the
matching <tt>*sleep_on()</tt> function. <tt>wake_up()</tt> can
be used to wake up tasks in a queue where the tasks may be in a
<tt>TASK_INTERRUPTIBLE</tt> or <tt>TASK_UNINTERRUPTIBLE</tt>
state, while <tt>wake_up_interruptible()</tt> will only wake up
tasks in a <tt>TASK_INTERRUPTIBLE</tt> state, and will be
insignificantly faster than <tt>wake_up()</tt> on queues that
have only interruptible tasks. These take one argument:
</p><dl>
<dt><tt>q</tt>
</dt><dd>Pointer to the <tt>wait_queue</tt> structure of the
process to be woken.
</dd></dl>
<p>Note that <tt>wake_up()</tt> does not switch tasks, it only
makes processes that are woken up runnable, so that the next
time <tt>schedule()</tt> is called, they will be candidates to
run.
</p><p><b>Defined in:</b> kernel/sched.c<br>
<b>See also:</b> <tt>select_wait()</tt>, <tt>*sleep_on()</tt>
</p><p>Copyright (C) 1992, 1993, 1994, 1996 Michael K. Johnson,
johnsonm@redhat.com.<br>
</p><p>
</p><p></p><hr size="3">
<p><b><a name="Messages">Messages</a></b>
<nobr>
<font size="-1">
</font>
</nobr>
</p><p>
<nobr>
<dl compact="compact">
<dt> 14. <img src="supporting%20functions_files/question.gif" alt="Question:" align="middle" height="15" width="15">
<a href="http://tldp.org/LDP/khg/HyperNews/get/devices/reference/14.html">
down/up() - semaphores; set/clear/test_bit()</a> <i> by <a href="http://www.newplaces.com/">Erez Strauss</a></i> </dt>
<dt> 13. <img src="supporting%20functions_files/disagree.gif" alt="Disagree:" align="middle" height="15" width="15">
<a href="http://tldp.org/LDP/khg/HyperNews/get/devices/reference/13.html">
Bug in printk description!</a> <i> by <a href="http://web.mit.edu/tytso/www/home.html">Theodore Ts'o</a></i> </dt>
<dt> 12. <img src="supporting%20functions_files/question.gif" alt="Question:" align="middle" height="15" width="15">
<a href="http://tldp.org/LDP/khg/HyperNews/get/devices/reference/12.html">
File access within a device driver?</a> <i> by Paul Osborn</i> </dt>
<dt> 11. <img src="supporting%20functions_files/note.gif" alt="None:" align="middle" height="15" width="15">
<a href="http://tldp.org/LDP/khg/HyperNews/get/devices/reference/11.html">
man pages for reguest_region() and release_region() (?)</a> <i> by mharrison@i-55.com</i> </dt>
<dt> 10. <img src="supporting%20functions_files/question.gif" alt="Question:" align="middle" height="15" width="15">
<a href="http://tldp.org/LDP/khg/HyperNews/get/devices/reference/10.html">
Can register_*dev() assign an unused major number?</a> <i> by rgerharz@erols.com</i> </dt>
<dd>
<dl compact="compact">
<dt> 1. <img src="supporting%20functions_files/note.gif" alt="Note:" align="middle" height="15" width="15">
<a href="http://tldp.org/LDP/khg/HyperNews/get/devices/reference/10/1.html">
Register_*dev() can assign an unused major number.</a> <i> by <a href="http://www.erols.com/rgerharz">Reinhold J. Gerharz</a></i> </dt>
</dl>
</dd>
<dt> 9. <img src="supporting%20functions_files/question.gif" alt="Question:" align="middle" height="15" width="15">
<a href="http://tldp.org/LDP/khg/HyperNews/get/devices/reference/9.html">
memcpy_*fs(): which way is "fs"?</a> <i> by Reinhold J. Gerharz</i> </dt>
<dd>
<dl compact="compact">
<dt> 1. <img src="supporting%20functions_files/note.gif" alt="Note:" align="middle" height="15" width="15">
<a href="http://tldp.org/LDP/khg/HyperNews/get/devices/reference/9/1.html">
memcpy_tofs() and memcpy_fromfs()</a> <i> by <a href="http://hyper.stanford.edu/%7Edhinds">David Hinds</a></i> </dt>
</dl>
</dd>
<dt> 8. <img src="supporting%20functions_files/note.gif" alt="Note:" align="middle" height="15" width="15">
<a href="http://tldp.org/LDP/khg/HyperNews/get/devices/reference/8.html">
init_wait_queue()</a> <i> by <a href="http://tldp.org/LDP/khg/%7Ejohnsonm">Michael K. Johnson</a></i> </dt>
<dt> 7. <img src="supporting%20functions_files/question.gif" alt="Question:" align="middle" height="15" width="15">
<a href="http://tldp.org/LDP/khg/HyperNews/get/devices/reference/7.html">
request_irq(...,void *dev_id)</a> <i> by Robert Wilhelm</i> </dt>
<dd>
<dl compact="compact">
<dt> 1. <img src="supporting%20functions_files/note.gif" alt="None:" align="middle" height="15" width="15">
<a href="http://tldp.org/LDP/khg/HyperNews/get/devices/reference/7/1.html">
dev_id seems to be for IRQ sharing</a> <i> by Steven Hunyady</i> </dt>
</dl>
</dd>
<dt> 6. <img src="supporting%20functions_files/idea.gif" alt="Idea:" align="middle" height="15" width="15">
<a href="http://tldp.org/LDP/khg/HyperNews/get/devices/reference/6.html">
udelay should be mentioned</a> <i> by <a href="http://www.nbi.dk/%7Elindeman">Klaus Lindemann</a></i> </dt>
<dt> 5. <img src="supporting%20functions_files/idea.gif" alt="Idea:" align="middle" height="15" width="15">
<a href="http://tldp.org/LDP/khg/HyperNews/get/devices/reference/5.html">
vprintk would be nice...</a> <i> by Robert Baruch</i> </dt>
<dd>
<dl compact="compact">
<dt> 1. <img src="supporting%20functions_files/feedback.gif" alt="Feedback:" align="middle" height="15" width="15">
<a href="http://tldp.org/LDP/khg/HyperNews/get/devices/reference/5/1.html">
RE: vprintk would be nice...</a><i></i> </dt>
</dl>
</dd>
<dt> 4. <img src="supporting%20functions_files/question.gif" alt="Question:" align="middle" height="15" width="15">
<a href="http://tldp.org/LDP/khg/HyperNews/get/devices/reference/4.html">
add_timer function errata?</a> <i> by <a href="http://www.monash.edu.au/%7Etimf">Tim Ferguson</a></i> </dt>
<dd>
<dl compact="compact">
<dt> 1. <img src="supporting%20functions_files/smile.gif" alt="Ok:" align="middle" height="15" width="15">
<a href="http://tldp.org/LDP/khg/HyperNews/get/devices/reference/4/1.html">
add_timer function errata</a> <i> by Tom Bjorkholm</i> </dt>
</dl>
</dd>
<dt> 3. <img src="supporting%20functions_files/question.gif" alt="Question:" align="middle" height="15" width="15">
<a href="http://tldp.org/LDP/khg/HyperNews/get/devices/reference/3.html">
Very short waits</a> <i> by Kenn Humborg</i> </dt>
<dt> 2. <img src="supporting%20functions_files/note.gif" alt="None:" align="middle" height="15" width="15">
<a href="http://tldp.org/LDP/khg/HyperNews/get/devices/reference/2.html">
Add the kill_xxx() family to Supporting functions?</a> <i> by Burkhard Kohl</i> </dt>
<dt> 1. <img src="supporting%20functions_files/news.gif" alt="News:" align="middle" height="15" width="15">
<a href="http://tldp.org/LDP/khg/HyperNews/get/devices/reference/1.html">
Allocating large amount of memory</a> <i> by <a href="http://tldp.org/LDP/khg/%7Ejohnsonm">Michael K. Johnson</a></i> </dt>
<dd>
<dl compact="compact">
<dt> 1. <img src="supporting%20functions_files/question.gif" alt="Question:" align="middle" height="15" width="15">
<a href="http://tldp.org/LDP/khg/HyperNews/get/devices/reference/1/1.html">
bigphysarea for Linux 2.0?</a> <i> by <a href="http://www.cs.yale.edu/users/hager.html">Greg Hager</a></i> </dt>
</dl>
</dd>
</dl>
</nobr>
</p><p>
</p><p>
<br>
<br></p></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -