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
0225 struct list_head list;
0226
0227
0228 char name[MODULE_NAME_LEN];
0229
0230
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
0238 const struct kernel_symbol *syms;
0239 const unsigned long *crcs;
0240 unsigned int num_syms;
0241
0242
0243 struct kernel_param *kp;
0244 unsigned int num_kp;
0245
0246
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
0253 const struct kernel_symbol *unused_syms;
0254 const unsigned long *unused_crcs;
0255 unsigned int num_unused_syms;
0256
0257
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
0264 const struct kernel_symbol *gpl_future_syms;
0265 const unsigned long *gpl_future_crcs;
0266 unsigned int num_gpl_future_syms;
0267
0268
0269 unsigned int num_exentries;
0270 struct exception_table_entry *extable;
0271
0272
0273 int (*init)(void);
0274
0275
0276 void *module_init;
0277
0278
0279 void *module_core;
0280
0281
0282 unsigned int init_size, core_size;
0283
0284
0285 unsigned int init_text_size, core_text_size;
0286
0287
0288 unsigned int init_ro_size, core_ro_size;
0289
0290
0291 struct mod_arch_specific arch;
0292
0293 unsigned int taints;
0294
0295 #ifdef CONFIG_GENERIC_BUG
0296
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
0305
0306
0307
0308 Elf_Sym *symtab, *core_symtab;
0309 unsigned int num_symtab, core_num_syms;
0310 char *strtab, *core_strtab;
0311
0312
0313 struct module_sect_attrs *sect_attrs;
0314
0315
0316 struct module_notes_attrs *notes_attrs;
0317 #endif
0318
0319
0320
0321 char *args;
0322
0323 #ifdef CONFIG_SMP
0324
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
0352 struct list_head source_list;
0353
0354 struct list_head target_list;
0355
0356
0357 struct task_struct *waiter;
0358
0359
0360 void (*exit)(void);
0361
0362 struct module_ref __percpu *refptr;
0363 #endif
0364
0365 #ifdef CONFIG_CONSTRUCTORS
0366
0367 ctor_fn_t *ctors;
0368 unsigned int num_ctors;
0369 #endif
0370 };