English 中文(简体)
1. 将装置驱动器作为一套舱面模块
原标题:Implementing a device driver as a set of kernel modules

我有一个用户空间图书馆,用于向一个连续港口的装置传送。 图书馆相当复杂,执行许多任务,包括使负责人上载有效、分散信息、发送信息、处理答复、启动装置等等。

我愿将这一图书馆迁至凯尔特空间,并考虑将图书馆拆入几个明确界定的凯里略模块,以便让图书馆能够进入空间。

  • I can leave the door open to swap out layers in the future (for example swapping out the USART layer with an SPI layer).
  • Development will be easier. If it were divided up, I could migrate the library to kernel-space piece-by-piece.

Has anyone ever done something like this before? What are the best ways (in terms of efficiency) to communicate between kernel modules? Are there any pitfalls I should avoid?

最后,是否有好的驾驶员实例作为一套掩体模块加以实施?

最佳回答

所有舱面模块都在同一个地址空间运行。 为了从另一个单元中提一个单元,你需要出口一些符号:功能或全球变量。 虽然在这种情况下使用全球变量可能是坏的风格。 请注意,你的出口标志将与所有其他舱面符号相同。 为避免名称冲突,你应使用一些明确界定的预留办法,通常是单元的名称和强调。 因此,如果你的一个单元被称作<代码>foo,而且你希望出口bar(>>,你可以在foo上使用这种代码。 模块:

void foo_bar(const char *prm) {
  printk (KERN_INFO "foo_bar(%s) was called
", prm);
}
EXPORT_SYMBOL(foo_bar);

在其他模块,如buz,仅称这一功能:

foo_bar("qux");

<>strong Be注意到,在格列车模块中,你可以使用校准(或其他图书馆)的特征,而诸如记忆管理、档案I/O、网络建设等许多通常事物可能确实复杂。 还指出,油轮模块分解并非是一项微不足道的任务,许多错误将造成恐慌,而不是造成伤害。

因此,在将一些工作图书馆迁至地库里之前,会想摩擦。 或许最好把图书馆分为相同的“模块”,但(或大部分)保留在用户空间。

问题回答

不能确定这种帮助,但ALSA为每种不同声音芯片和其他一些共同体组成许多不同的单元:

$ lsmod | grep snd
snd_hrtimer            12744  1 
snd_hda_codec_realtek   330769  1 
snd_hda_intel          33390  2 
snd_usb_audio         118064  0 
snd_hda_codec         104802  2 snd_hda_codec_realtek,snd_hda_intel
snd_pcm                96714  3 snd_hda_intel,snd_usb_audio,snd_hda_codec
snd_hwdep              13668  2 snd_usb_audio,snd_hda_codec
snd_usbmidi_lib        25371  1 snd_usb_audio
snd_seq_midi           13324  0 
snd_rawmidi            30547  2 snd_usbmidi_lib,snd_seq_midi
snd_seq_midi_event     14899  1 snd_seq_midi
snd_seq                61896  3 snd_seq_midi,snd_seq_midi_event
snd_timer              29991  3 snd_hrtimer,snd_pcm,snd_seq
snd_seq_device         14540  3 snd_seq_midi,snd_rawmidi,snd_seq
snd                    68266  16 snd_hda_codec_realtek,snd_hda_intel,snd_usb_audio,snd_hda_codec,snd_pcm,snd_hwdep,snd_usbmidi_lib,snd_rawmidi,snd_seq,snd_timer,snd_seq_device
soundcore              12680  1 snd
snd_page_alloc         18529  2 snd_hda_intel,snd_pcm

重构依赖性图表的工作留给读者。





相关问题
Signed executables under Linux

For security reasons, it is desirable to check the integrity of code before execution, avoiding tampered software by an attacker. So, my question is How to sign executable code and run only trusted ...

encoding of file shell script

How can I check the file encoding in a shell script? I need to know if a file is encoded in utf-8 or iso-8859-1. Thanks

How to write a Remote DataModule to run on a linux server?

i would like to know if there are any solution to do this. Does anyone? The big picture: I want to access data over the web, using my delphi thin clients. But i´would like to keep my server/service ...

How can I use exit codes to run shell scripts sequentially?

Since cruise control is full of bugs that have wasted my entire week, I have decided the existing shell scripts I have are simpler and thus better. Here is what I have so far svn update /var/www/...

Good, free, easy-to-use C graphics libraries? [closed]

I was wondering if there were any good free graphics libraries for C that are easy to use? It s for plotting 2d and 3d graphs and then saving to a file. It s on a Linux system and there s no gnuplot ...

热门标签