43a871a2402642abe7d7c1bd86f1bc6f1e37d49d
[cascardo/kernel/old_slides/.git] / 03.char / 03.char.xml
1 <?xml version="1.0" encoding="UTF-8" ?>
2 <!DOCTYPE slides SYSTEM "/usr/share/xml/docbook/custom/slides/3.3.1/schema/dtd/slides-full.dtd">
3
4 <slides>
5
6 <slidesinfo>
7 <title>Character Devices</title>
8 <author><firstname>Thadeu</firstname><surname>Cascardo</surname></author>
9 </slidesinfo>
10
11 <foil>
12 <title>Introduction</title>
13 </foil>
14
15 <foil>
16 <title>Device Number Macros</title>
17 <para>
18 Nowadays, major number is 12 bits and minor number is 20 bits. This may change
19 in the future, so macros should be used.
20 </para>
21 <itemizedlist>
22 <listitem>
23 MAJOR
24 </listitem>
25 <listitem>
26 MINOR
27 </listitem>
28 <listitem>
29 MKDEV
30 </listitem>
31 </itemizedlist>
32 </foil>
33
34 <foil>
35 <title>Allocating numbers</title>
36 <para>
37 Use <emphasis>register\_chrdev\_region</emphasis> or
38 <emphasis>alloc\_chrdev\_region</emphasis> to register or allocate device
39 numbers.
40 </para>
41 <para>
42 Use <emphasis>unregister\_chrdev\_region</emphasis> to unregister it.
43 </para>
44 </foil>
45
46 <foil>
47 <title>cdev structure</title>
48 <para>
49 Use <emphasis>cdev\_alloc</emphasis> or <emphasis>cdev\_init</emphasis> to
50 allocate or initalize a cdev structure.
51 </para>
52 <para>
53 Use <emphasis>cdev\_add</emphasis> and <emphasis>cdev\_del</emphasis> to
54 register and unregister it.
55 </para>
56 </foil>
57
58 <foil>
59 <title>Open/Release</title>
60 <para>
61 Implementing open and release should be very simple for many devices. They
62 usually allocate data, and multiplex devices by minor number.
63 </para>
64 </foil>
65
66 <foil>
67 <title>Inode structure</title>
68 <para>
69 Use <emphasis>imajor</emphasis> and <emphasis>iminor</emphasis> to get the major
70 and minor number from an inode structure.
71 </para>
72 </foil>
73
74 <foil>
75 <title>Read</title>
76 <para>
77 Read may write to user space less bytes than requested.
78 </para>
79 </foil>
80
81 <foil>
82 <title>Write</title>
83 <para>
84 Write is very similar to read. Only problem is that many applications misbehave
85 when driver writes less bytes than requested.
86 </para>
87 </foil>
88
89 </slides>