Ò׽ؽØÍ¼Èí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

linuxÇý¶¯³ÌÐòʵÀý

±¾ÀýÊÇ·ë¹ú½øµÄ ¡¶Ç¶ÈëʽLinux Çý¶¯³ÌÐòÉè¼Æ´ÓÈëÃŵ½¾«Í¨¡·µÄµÚÒ»¸öÀý×Ó
¸Ð¾õÕæÊǺÃÊé   Ç¿ÁÒÍÆ¼ö
×¢ÊÍÊÇdeep_pro¼ÓµÄ ×ªÔØÇë×¢Ã÷£¡ÎÒµÄÌØµãÊÇÎIJ»¼Óµã£¡
Õâ¸öÇý¶¯ÊÇÔÚÄÚ´æÖзÖÅäÒ»¸ö256×ֽڵĿռ䣬¹©Óû§Ì¬Ó¦ÓóÌÐò¶Áд¡£
ÏÈÊÇÍ·Îļþ demo.h
#ifndef _DEMO_H_
#define _DEMO_H_
#include <linux/ioctl.h> /* needed for the _IOW etc stuff used later */
/********************************************************
* Macros to help debugging
********************************************************/
#undef PDEBUG             /* undef it, just in case */
#ifdef DEMO_DEBUG
#ifdef __KERNEL__
#    define PDEBUG(fmt, args...) printk( KERN_DEBUG "DEMO: " fmt, ## args)
#else//usr space
#    define PDEBUG(fmt, args...) fprintf(stderr, fmt, ## args)
#endif
#else
# define PDEBUG(fmt, args...) /* not debugging: nothing */
#endif
#undef PDEBUGG
#define PDEBUGG(fmt, args...) /* nothing: it's a placeholder */
//É豸ºÅ
#define DEMO_MAJOR 224
#define DEMO_MINOR 0
#define COMMAND1 1
#define COMMAND2 2
//×Ô¼º¶¨ÒåµÄÉ豸½á¹¹
struct DEMO_dev
{
    struct cdev cdev;    /* Char device structure        */
};
//º¯ÊýÉêÃ÷ Ô­À´LinuxÇý¶¯³ÌÐòÉè¼ÆÕâô¼òµ¥ Ö»ÐèҪʵÏÖÕâô¼¸¸öº¯Êý¾Í¿ÉÒÔÁË
ssize_t DEMO_read(struct file *filp, char __user *buf, size_t count,
                   loff_t *f_pos);
ssize_t DEMO_write(struct file *filp, const char __user *buf, size_t count,
                    loff_t *f_pos);
loff_t DEMO_llseek(struct file *filp, loff_t off, int whence);
int     DEMO_ioctl(struct inode *inode, struct file *filp,
                &nbs


Ïà¹ØÎĵµ£º

linux ÐÂÔöϵͳµ÷ÓÃ


´ËÎÄÓÚ2010-02-26±»ÍƼöµ½CSDNÊ×Ò³
ÈçºÎ±»ÍƼö£¿
×î½üÔÚÑо¿ Linux
Äں˵Äʱ¼ä×Óϵͳ£¬ÎªÏÂһƪ³¤ÎÄ¡¶·þÎñÆ÷³ÌÐòÖеÄÈÕÆÚÓëʱ¼ä¡·×ö×¼±¸£¬ÎÞÒâÖÐ×¢Òâµ½ÁË Linux
ÐÂÔöµÄ¼¸¸öϵͳµ÷ÓõĶԱàд·þÎñÆ÷´úÂëµÄÓ°Ï죬ÏÈ´óּǼÔÚÕâÀï¡£ÕâÆª²©¿ÍÒ²¿ÉËã×÷ǰһƪ¡¶¶àÏß
³Ì·þÎñÆ÷µÄ³£Óñà³ÌÄ£ÐÍ¡·
µÄÒ»¸ö×¢½Å¡£
< type="te ......

Linux use notes

-----------------------------
Based on Fedora 8 version:
-----------------------------
1. No common command like ifconfig in os?
Root cause is the standard search path not include /sbin and /usr/sbin. Try to include them in /etc/profile. As belows:
 #Kenny add /sbin and /usr/sbin here.
&n ......

Linux 2.6 ×Ö·ûÉ豸Çý¶¯³ÌÐò

¡ð
¡¢ËµÃ÷
±Ê¼ÇÊÊÓÃÓÚ
Linux
µÄ
2.6.10
ÒÔºóµÄÄںˡ£
±Ê¼ÇÒÔ
Linux
Device
Driver3
ÌṩµÄ
scull
³ÌÐò
(scull
Ŀ¼ÖеÄ
main.c
ºÍ
scull.h)
Ϊ¼Ç¼Ö÷Ïߣ¬²¢ÒÔ¸ÃÇý¶¯³ÌÐòÖеĸ÷ÖÖϵͳµ÷Óúͺ¯Êýµ÷ÓÃÁ÷³ÌΪ¼Ç
¼˳Ðò¡£±ÈÈ磬
module_init( )
ºÍ
module_exit(
)
ΪÏà¶ÔÓ¦µÄÒ»¶Ôϵͳµ÷Óã¬Ò»°ãÊé¼®Öж ......

linuxÄÚºËÇý¶¯Ä£¿é¼ÓÔØ·½Ê½

ÔÚÀàunix
²Ù×÷ϵͳ
ÖУ¬Çý¶¯
¼ÓÔØ
·½Ê½Ò»°ã·ÖΪ£º¶¯Ì¬¼ÓÔØºÍ¾²Ì¬¼ÓÔØ£¬ÏÂÃæ·Ö±ð¶ÔÆäÏêϸÂÛÊö¡£
Ò»¡¢¶¯Ì¬¼ÓÔØ
    ¶¯Ì¬¼ÓÔØÊǽ«Çý¶¯Ä£¿é¼ÓÔØµ½ÄÚºË
ÖУ¬¶ø²»ÄÜ·ÅÈë/lib/modules/Ï¡£
     ÔÚ2.4ÄÚºËÖУ¬¼ÓÔØÇý¶¯ÃüÁî
Ϊ£ºinsmod ,ɾ³ýÄ£¿éΪ£ºrmmod£»
     ÔÚ2 ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ