![]() |
ANU College of Engineering and Computer Science
Research School of Computer Science
|
|
|
Laboratory 5 - VirtualBox for kernel development with Linux and A simple character deviceLearning ObjectivesThe main learning objectives for this lab are to:
PreparationRead through the manual pages for mknod. You will also need to gain an understanding about the UNIX the device structure. Also draft your code for the program your are required to write during the lab.
During the LabIn this lab you will create a simple character device driver as a loadable module. The device file should be called ramp and will output a repeating sequence of characters from 'A' to 'Z'. You will than extend the device driver in a number of ways. Note that, this device controls no real hardware, however, it highlights how UNIX interfaces with devices. And it is simple to see how you could add some calls within both read_ramp and write_ramp to directly control some underling hardware. Step 1 - VirtualBoxVirtualBox enables you to run an entire OS as a normal user. This provides a more stable way of doing kernel development.This can be all done without 'admin' access. Obtain a copy of an ubuntu 'iso' and place it in the /scratch directory. They are available locally at: http://mirror.linux.org.au/ubuntu-releases/10.04/I have used: ubuntu-10.04-desktop-i386.isoThis file is also available in class' public directory. Run VirtualBox (from the applications->accessories menu). Within the VirtualMachine manager (from the File menu) add the unbuntu iso to the CD/DVD Images. Click on "New" to create a new virtual machine. Give it a name and say the os is Linux and version Ubuntu. Set the amount of Memory for the Virtual Machine (give it atleast 512MB). Create a virtual hard disk using dynamically expanding storage and placing it in /scratch these are ".vdi" files. Unbuntu should start running at which point "Install Ubuntu 10.04". If you want to install updates then it is worth pointing the "Update Manager" to the local unbuntu repository (http://mirror.linux.org.au/ubuntu). Start your new virual machine. Have a go at doing the rest of the lab in the virtual machine. Add "snapsshots" so you should be able to quickly recover from crashes. Step 2 - Reading from the deviceStart off by grabbing the hello_module.tar.gz kernel module from the second laboratory. Then perform the following steps:
Step 3 - Writing to the deviceIn this exercise you will make the device writeable by supplying a ramp_write function. The function should accept data and remember it so that a subsequent read on the device givesthe same data back. This is similar to the writeable /proc exercise in lab3.The maximum size of the writeable device is up to you, but be warned that making it unlimited in size will be quite difficult. Optional Extra - Adding an ioctlIn this exercise you will add an ioctl control on the ramp device so that the size of the device (the amount of data that can be written to it) can be set via an ioctl call on the open device. This is a more difficult exercise, only do it if you have time.To do this you will need to:
| |||||||||||||||||||||||||||||||||||||||||||||||||||
|
Please direct all enquiries to: ericm@cs.anu.edu.au Page authorised by: Head of School, RSoCS |
| The Australian National University — CRICOS Provider Number 00120C |