cdev.h

0001 #ifndef _LINUX_CDEV_H
0002 #define _LINUX_CDEV_H
0003 
0004 #include <linux/kobject.h>
0005 #include <linux/kdev_t.h>
0006 #include <linux/list.h>
0007 
0008 struct file_operations;
0009 struct inode;
0010 struct module;
0011 
0012 struct cdev {
0013         struct kobject kobj; /* 继承了一个k对象 */
0014         struct module *owner; /* owner  只是一个指针 */
0015         const struct file_operations *ops; /* 读写等操作 */
0016         struct list_head list; /* 组织链表 */
0017         dev_t dev;  /* dev_t 是一个 u32的数据 */
0018 unsigned int count; /* 应该是一个计数 */ 0019 }; 0020 0021 void cdev_init(struct cdev *, const struct file_operations *); 0022 0023 struct cdev *cdev_alloc(void); 0024 0025 void cdev_put(struct cdev *p); 0026 0027 int cdev_add(struct cdev *, dev_t, unsigned); 0028 0029 void cdev_del(struct cdev *); 0030 0031 void cd_forget(struct inode *); 0032 0033 extern struct backing_dev_info directly_mappable_cdev_bdi; 0034 0035 #endif

没有想到module 结构体这么的庞大
0220 struct module
0221 {
0222         enum module_state state;
0223 
0224         /* Member of list of modules */
0225         struct list_head list;
0226 
0227         /* Unique handle for this module */
0228         char name[MODULE_NAME_LEN];
0229 
0230         /* Sysfs stuff. */
0231         struct module_kobject mkobj;
0232         struct module_attribute *modinfo_attrs;
0233         const char *version;
0234         const char *srcversion;
0235         struct kobject *holders_dir;
0236 
0237         /* Exported symbols */
0238         const struct kernel_symbol *syms;
0239         const unsigned long *crcs;
0240         unsigned int num_syms;
0241 
0242         /* Kernel parameters. */
0243         struct kernel_param *kp;
0244         unsigned int num_kp;
0245 
0246         /* GPL-only exported symbols. */
0247         unsigned int num_gpl_syms;
0248         const struct kernel_symbol *gpl_syms;
0249         const unsigned long *gpl_crcs;
0250 
0251 #ifdef CONFIG_UNUSED_SYMBOLS
0252         /* unused exported symbols. */
0253         const struct kernel_symbol *unused_syms;
0254         const unsigned long *unused_crcs;
0255         unsigned int num_unused_syms;
0256 
0257         /* GPL-only, unused exported symbols. */
0258         unsigned int num_unused_gpl_syms;
0259         const struct kernel_symbol *unused_gpl_syms;
0260         const unsigned long *unused_gpl_crcs;
0261 #endif
0262 
0263         /* symbols that will be GPL-only in the near future. */
0264         const struct kernel_symbol *gpl_future_syms;
0265         const unsigned long *gpl_future_crcs;
0266         unsigned int num_gpl_future_syms;
0267 
0268         /* Exception table */
0269         unsigned int num_exentries;
0270         struct exception_table_entry *extable;
0271 
0272         /* Startup function. */
0273         int (*init)(void);
0274 
0275         /* If this is non-NULL, vfree after init() returns */
0276         void *module_init;
0277 
0278         /* Here is the actual code + data, vfree'd on unload. */
0279         void *module_core;
0280 
0281         /* Here are the sizes of the init and core sections */
0282         unsigned int init_size, core_size;
0283 
0284         /* The size of the executable code in each section.  */
0285         unsigned int init_text_size, core_text_size;
0286 
0287         /* Size of RO sections of the module (text+rodata) */
0288         unsigned int init_ro_size, core_ro_size;
0289 
0290         /* Arch-specific module values */
0291         struct mod_arch_specific arch;
0292 
0293         unsigned int taints;    /* same bits as kernel:tainted */
0294 
0295 #ifdef CONFIG_GENERIC_BUG
0296         /* Support for BUG */
0297         unsigned num_bugs;
0298         struct list_head bug_list;
0299         struct bug_entry *bug_table;
0300 #endif
0301 
0302 #ifdef CONFIG_KALLSYMS
0303         /*
0304          * We keep the symbol and string tables for kallsyms.
0305          * The core_* fields below are temporary, loader-only (they
0306          * could really be discarded after module init).
0307          */
0308         Elf_Sym *symtab, *core_symtab;
0309         unsigned int num_symtab, core_num_syms;
0310         char *strtab, *core_strtab;
0311 
0312         /* Section attributes */
0313         struct module_sect_attrs *sect_attrs;
0314 
0315         /* Notes attributes */
0316         struct module_notes_attrs *notes_attrs;
0317 #endif
0318 
0319         /* The command line arguments (may be mangled).  People like
0320            keeping pointers to this stuff */
0321         char *args;
0322 
0323 #ifdef CONFIG_SMP
0324         /* Per-cpu data. */
0325         void __percpu *percpu;
0326         unsigned int percpu_size;
0327 #endif
0328 
0329 #ifdef CONFIG_TRACEPOINTS
0330         unsigned int num_tracepoints;
0331         struct tracepoint * const *tracepoints_ptrs;
0332 #endif
0333 #ifdef HAVE_JUMP_LABEL
0334         struct jump_entry *jump_entries;
0335         unsigned int num_jump_entries;
0336 #endif
0337 #ifdef CONFIG_TRACING
0338         unsigned int num_trace_bprintk_fmt;
0339         const char **trace_bprintk_fmt_start;
0340 #endif
0341 #ifdef CONFIG_EVENT_TRACING
0342         struct ftrace_event_call **trace_events;
0343         unsigned int num_trace_events;
0344 #endif
0345 #ifdef CONFIG_FTRACE_MCOUNT_RECORD
0346         unsigned int num_ftrace_callsites;
0347         unsigned long *ftrace_callsites;
0348 #endif
0349 
0350 #ifdef CONFIG_MODULE_UNLOAD
0351         /* What modules depend on me? */
0352         struct list_head source_list;
0353         /* What modules do I depend on? */
0354         struct list_head target_list;
0355 
0356         /* Who is waiting for us to be unloaded */
0357         struct task_struct *waiter;
0358 
0359         /* Destruction function. */
0360         void (*exit)(void);
0361 
0362         struct module_ref __percpu *refptr;
0363 #endif
0364 
0365 #ifdef CONFIG_CONSTRUCTORS
0366         /* Constructor functions. */
0367         ctor_fn_t *ctors;
0368         unsigned int num_ctors;
0369 #endif
0370 };
 

posted on 2013-08-25 21:23  kwingmei  阅读(383)  评论(0编辑  收藏  举报

导航