Document system calls and the open call.
[cascardo/kernel/old_slides/.git] / _ldd.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>Linux Device Drivers</title>
8 <author><firstname>Thadeu</firstname><surname>Cascardo</surname></author>
9 </slidesinfo>
10
11 <foil>
12 <title>Introduction</title>
13 <para>
14 Devices in POSIX Systems are files in /dev directory. As with any files
15 in POSIX, they may be opened, closed, read from, written to, seeked,
16 ioctl'd, and others.
17 </para>
18
19 <para>
20 Examples of device files:
21 </para>
22
23 <itemizedlist>
24 <listitem>
25 <para>
26 /dev/sda - A SCSI block device
27 </para>
28 </listitem>
29 <listitem>
30 <para>
31 /dev/ttyS0 - A Serial terminal device
32 </para>
33 </listitem>
34 </itemizedlist>
35
36 </foil>
37
38 <foil>
39 <title>POSIX I/O calls</title>
40 <para>
41 POSIX systems have some standard calls for I/O. Since devices are files,
42 these same system calls are used to work with devices. We are gonna work
43 with the following calls:
44 </para>
45 <itemizedlist>
46 <listitem><para>
47 open
48 </para></listitem>
49 <listitem><para>
50 read
51 </para></listitem>
52 <listitem><para>
53 write
54 </para></listitem>
55 <listitem><para>
56 close
57 </para></listitem>
58 <listitem><para>
59 seek
60 </para></listitem>
61 <listitem><para>
62 ioctl
63 </para></listitem>
64 </itemizedlist>
65 </foil>
66
67 <foil>
68 <title>open</title>
69 <para>
70 The open system call opens a file. When working with devices, that's
71 when some initialization should be done. Some devices may be opened only
72 once at a time.
73 </para>
74 <para>
75 int open (char * filename, int flags);
76 </para>
77 <para>
78 flags may be O_RDONLY, O_WRONLY, O_RDWR and many others, some not
79 important for devices.
80 </para>
81 <para>
82 Example:
83 </para>
84 <para>
85 fd = open ("/dev/ttyS0", O_RDWR);
86 </para>
87 </foil>
88
89 </slides>