Imported some slides from last LDD course.
authorThadeu Lima de Souza Cascardo <cascardo@holoscopio.com>
Sun, 16 May 2010 18:52:52 +0000 (15:52 -0300)
committerThadeu Lima de Souza Cascardo <cascardo@holoscopio.com>
Sun, 16 May 2010 18:52:52 +0000 (15:52 -0300)
04char/chrdev [new file with mode: 0644]

diff --git a/04char/chrdev b/04char/chrdev
new file mode 100644 (file)
index 0000000..5b6f7e9
--- /dev/null
@@ -0,0 +1,41 @@
+# Introduction
+
+Devices in POSIX Systems are files in /dev directory. As with any files
+in POSIX, they may be opened, closed, read from, written to, seeked,
+ioctl'd, and others.
+
+Examples of device files:
+
+* /dev/sda - A SCSI block device
+* /dev/ttyS0 - A Serial terminal device
+
+# POSIX I/O calls
+
+POSIX systems have some standard calls for I/O. Since devices are files,
+these same system calls are used to work with devices. We are gonna work
+with the following calls:
+
+* open
+* read
+* write
+* close
+* lseek
+* ioctl
+
+# Device types and numbers
+
+Linux devices may be of different types, including character devices,
+block devices or network devices. Both character and block devices have
+identifying numbers, a major and a minor number.
+
+# Character devices allocation
+
+In Linux, major and minor numbers have to be requested or allocated. The
+calls to do that for character devices are:
+
+
+* int register\\_chrdev\\_region (dev\\_t first, unsigned int count, char
+*name);
+* int alloc\\_chrdev\\_region (dev\\_t *dev, unsigned int firstminor,
+unsigned int count, char *name);
+* void unregister\\_chrdev\\_region (dev\\_t dev, unsigned int count);