Hello,
 
I've attached to this mail the english abstract of my thesis. It describes briefly how to implement driver debugging system using the UML. (The rest is in hebrew, so I'll have to translate it before publihment).

Debugging Linux Device Drivers

Eitan Yarden

Submitted in partial fulfillment of the requirements for the

Mastera?Ts Degree in the Department of Computer Science

Bar-Ilan University

Ramat Gan 2002

1 Abstract

This study gives a solution to the problem of debugging device drivers on Linux operating system. Device drivers on Linux run as a part of the kernel, and not as a user process, and therefore a regular debugger cannot be used in order to debug them. The importance of debugging kernel code is greater since every mistake in the code can cause a system crash. Regular user space programs run under the control of the operating system, but the kernel is the operating system itself, and therefore cannot recover gracefully from errors.

Our solution is based on UML project - user-mode-linux. The code tree of Linux operating system is divided into two parts: the architecture dependent part (called arch), and the rest of the code, which is architecture independent. For every kind of hardware architecture there is a special arch. UML defines a new virtual architecture called UML machine. The UML machine is actually software and not hardware. Instead of hardware implementation, the UML uses the Linux operating system as an architecture. The kernel of this virtual machine is an executable running as a regular process under Linux operating system. This process can be debugged like any other process. However, there is one problem regarding the UML virtual machine: it is not real. It has no real hardware. Consequently if someone wants to debug device driver of a new hardware he can not do this using the UML machine, since the virtual machine can not communicate with real hardware.

The study shows a way to enhance the virtual machine so it will have the ability to interact with real hardware: IRQ registration, I/O port access, device memory mapping, DMA operations and PCI bus querying.

I/O port access is achieved using the /dev/port file. This file is mapped by the kernel to the I/O ports and can be accessed from user space. Every INB or OUTB operation is translated to reading and writing operations on this file. The ability to map device memory uses a similar technique while it calls the mmap system call on the /dev/mem file. This file is used by the kernel to map device memory and reserved system RAM.

IRQ handler registration in user space is not possible. Therefore a special driver is used to register dummy handlers which forward the interrupts to the UML kernel. This driver also allocates DMA memory and exports it to mapping by the UML kernel. In this way the UML kernel knows the physical and the virtual address of this memory, and therefore can use it for DMA operations.

The PCI interface gives to the driver a lot of information on the device. This interface can be accessed from user space by reading the /proc/bus/pci/busno/devno files. These files are special proc files which are registered by the psaudo-driver pci.c in the kernel.

After implementation of all these mechanisms, the new UMLkernel was tested by compiling and loading real drivers. The first driver was the parallel port, and the printer device, which was loaded and tested by printing some files through the /dev/lp0 file.

The second test was driver for network card. It too was compiled and loaded into the kernel. Then the interface was activated by ifconfig command and ping packets was sent to another computers on the network.

 



Hotmail.co.il - Powered by IBM eServer