outb()在LDD3示例短模块中不起作用 [英] outb() does not work in LDD3 example short module

查看:114
本文介绍了outb()在LDD3示例短模块中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在Linux设备驱动程序3的示例中尝试使用short.c

I am trying short.c in examples of Linux Device Driver 3

我的PC具有并行端口,并且在Ubuntu启动后,我可以看到以下内容:

My PC has Parallel Port and after the Ubuntu boots up, I can see these:

cat /proc/ioports
0378-037a : parport0
037b-037f : parport0

outp 0x378 1 
(outp is another example in LDD3 which write data to ports)
the LED on the port is ON.

然后我运行这些命令以删除模块

Then I run these commands to remove modules

rmmod lp
rmmod parport_pc
cat /proc/ioports
(There is no module on 0378-037f any more.)

我再次运行它,但是LED这次不亮.

I run this again but the LED is not ON this time.

outp 0x378 1

然后我安装short.ko,并且request_region()成功.

Then I install short.ko and request_region() succeeds.

cat /proc/ioports
0378-037f : short

cat /proc/devices
249 short

outp 0x378 1
the LED is not ON this time either.

我也尝试过这些,但是结果相同(LED不亮)

I tried these too, but same result (LED is not ON)

mknod /dev/short0 c 249 0
echo -n "a" > /dev/short0

"a"为0x61,因此最后一位为1.

"a" is 0x61 so that the last bit is 1.

为什么我有I/O区域却不能写出数据?

Why can I not write data out though I have got the I/O region?

感谢您的回答.

推荐答案

最后,我找到了解决方案.

Finally, I found the solution.

确保"parport"模块未加载或编译到内核中.仅卸载parport模块是不够的,因为它会使端口处于不一致状态.您必须重新启动计算机,并首先保留parport和所有相关模块/代码.

Make sure the "parport" module is not loaded or compiled into your kernel. It is not enough to simply unload the parport module, as it leaves the ports in an inconsistent state. You must reboot the machine and keep the parport and all related modules/code from loading in the first place.

一种方法是编辑/etc/modprobe.d/blacklist.conf文件并添加以下行:

One way to do this is to edit the /etc/modprobe.d/blacklist.conf file and add the following lines:

blacklist ppdev
blacklist lp
blacklist parport_pc
blacklist parport

partport似乎已经修改了并行端口的模式.

It seems that partport has modify the mode of parallel port.

如果安装了cups,则应修改/etc/modules-load.d/cups-filters.conf:

And if cups is installed, you should modify /etc/modules-load.d/cups-filters.conf:

#lp
#ppdev
#parport_pc

这篇关于outb()在LDD3示例短模块中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆