如何触发并口中断
最近在测试linux系统中断响应时间,照着网上所说,将并口的针脚9和10短接后就能产生中断,可是我照此做却发现并没有执行中断处理程序handler,也就是说没有产生中断,这是怎么回事?具体程序如下:#include <linux/version.h>
#include <linux/module.h>
#include <asm/io.h>
#define BASEPORT 0x378
#define PAR_INT 7
static adomain_t this_domain;
static adsysinfo_t sys_info;
int parcounter = 0;
long long timercounter = 0;
void handler(unsigned irq) {
printk(">>> PARALLEL PORT INT HANDLED: counter=%d\n", parcounter);
parcounter++;
adeos_control_irq(PAR_INT,0,IPIPE_ENABLE_MASK);
adeos_propagate_irq(irq);
}
void timer_tick (unsigned irq) {
timercounter++;
if (timercounter < 10) {
outb_p(0, BASEPORT);
outb_p(255, BASEPORT);
}
adeos_propagate_irq(irq);
}
void domain_entry (int iflag) {
printk("Domain %s started.\n",adp_current->name);
if (iflag) {
adeos_get_sysinfo(&sys_info);
// tmirq = timer irq
adeos_virtualize_irq(sys_info.archdep.tmirq,
&timer_tick, NULL, IPIPE_DYNAMIC_MASK);
// parallel port irq
adeos_virtualize_irq(PAR_INT,&handler,NULL,IPIPE_DYNAMIC_MASK);
//set port to interrupt mode; pins are output
outb_p(0x10, BASEPORT + 2);
adeos_control_irq(PAR_INT,0,IPIPE_ENABLE_MASK);
}
for (;;)
// This domain's idle loop
adeos_suspend_domain(); // control back to ADEOS
}
static int __init mod_init (void) {
adattr_t attr;
attr.name = "TestDomain";
attr.domid = 1; // Adeos Domain ID: >0
attr.entry = &domain_entry;
attr.estacksz = 0;// Adeos chooses a reasonable stack size
attr.priority = ADEOS_ROOT_PRI + 1;
attr.dswitch = NULL; // Domain switch hook - always a C routine
return adeos_register_domain(&this_domain,&attr);
}
static void __exit mod_exit (void) {
adeos_unregister_domain(&this_domain);
}
module_init(mod_init);
module_exit(mod_exit);
MODULE_LICENSE("GPL"); 哎,看来chinaunix论坛好人太少了 原帖由 wendy0552 于 2008-11-18 14:22 发表 http://linux.chinaunix.net/bbs/images/common/back.gif
哎,看来chinaunix论坛好人太少了
先把你的代码格式化下,最起码把那些笑脸去掉。另外,对应的问题发到对应的版块,谢谢合作! 那个笑脸只是右括号而已,没有什么别的东西。这种问题不在这里发,那要到哪里去发,我思考了很久才决定在这里发的。 原帖由 wendy0552 于 2008-11-18 17:13 发表 http://linux.chinaunix.net/bbs/images/common/back.gif
那个笑脸只是右括号而已,没有什么别的东西。
既然你坚持,那只能祝你好运了。 已经搞定 可以告诉小弟你是如何解决的吗??我也遇到类似的问题了!!!!! 十分不好意思,我都把这个帖子忘了,虽然时间过去很久了,还是把解决方法说下吧,要不实在是不太厚道。其实程序没有问题,而是犯了一个很低级的错误,就是没有把BIOS中的并口打开,实在惭愧,所以都不敢把解决方法贴出来了, :oops: 以后发贴问问题之前一定会先想清楚。 本帖最后由 shiwenjia_xq 于 2010-04-05 17:03 编辑
我最近也遇到这样的问题,但是我的BIOS里并口是打开的呀,也是指向(378/IRQ7),在加载模块之前我把系统原先所注册的7号中断处理例程parport卸载了呀!可是我加载这个模块后系统就死掉了。用dmesg查看后发现内核的打印信息如下:
I-pipe: Domain My_Domain registered.
...........
ACK :255
ACK :255
......
.......
ACK :255
BUG:soft lockup -CPU#1 stuck for 11s!
Pid: 3708,comm:insmod Not tainted
我的程序代码如下:
#include <linux/version.h>
#include <linux/module.h>
#include <asm/io.h>
#include <linux/ipipe.h>
#include <linux/time.h>
#define BASEPORT 0x378
#define PAR_INT 7
static struct ipipe_domain this_domain;
int counter = 0;
void handler(unsigned irq)
{
printk(">>> PARALLEL PORT INT HANDLED: counter=%d\n", counter);
counter++;
ipipe_control_irq(PAR_INT,0,IPIPE_ENABLE_MASK);
ipipe_propagate_irq(PAR_INT);
}
void domain_entry (void)
{
int a,k;
printk("Domain %s has start!\n",ipipe_current_domain->name);
ipipe_virtualize_irq(ipipe_current_domain,PAR_INT,(ipipe_irq_handler_t)&handler,NULL,NULL,IPIPE_DYNAMIC_MASK);
printk("handler has registered!\n");
printk("Set interrupt mode of this irq\n") ;
//set port to interrupt mode; pins are output
outb_p(0x10, BASEPORT + 2);
ipipe_control_irq(PAR_INT,0,IPIPE_ENABLE_MASK);
k = 10;
while(k--)
{
outb_p(0x00,BASEPORT);
a = inb(BASEPORT);
printk("ACK : %d\n",a);
// udelay(5);
outb_p(0xff,BASEPORT);
a = inb(BASEPORT);
printk("ACK : %d\n",a);
}
for( ;; )
ipipe_suspend_domain();
}
static int __init mod_init (void)
{
struct ipipe_domain_attr attr;
ipipe_init_attr (&attr);
attr.name = "My_Domain";
attr.priority = IPIPE_ROOT_PRIO + 1;
attr.entry = &domain_entry;
return ipipe_register_domain(&this_domain,&attr);
}
static void __exit mod_exit (void)
{
ipipe_unregister_domain(&this_domain);
}
module_init(mod_init);
module_exit(mod_exit);
MODULE_LICENSE("GPL") ;
请大家帮帮忙,帮我分析一下问题出在哪?
页:
[1]
2