| Discussion |
Files |
Resources |
||||||
| - Discussion | ||||||||
|
- Device Driver - Block Device Drivers - File System Drivers - Implementation |
What is a device driver?The hard disk device is a block device. What this means is that data is transfered to/from the device in chunks, or blocks, of data. In the case of a hard disk, this block is 512 bytes. A different type of device is a character device, such as the serial port. A character device transfers data one byte at a time.
Why use a device driver?A block device driver is implemented in the form of a dynamically linked library, or dll. This driver directly controls the block device. It is the OS's interface to the hardware. After the device is loaded all subsequent access to the hard disk are performed through the device driver. The benefits of this implementation are two fold. First, there is a single well defined interface to the hardware. Second, there is a single point of control for the device. Imagine the problems that would exist if each user application required access to a hard disk and there were no unified driver. The device would suffer from multiple commands at the same time causing problems from data corruption to system crashes. Also imagine the headache in programming modules to control the same device in every application that makes use of it.
What device drivers are required for controlling a Hard Disk?To implement a hard disk driver in Windows CE 2.12 two separate drivers are required. The Block Device Driver (BDD) is necessary to control the disk and a File System Driver (FSD) is necessary to manage media storage on the device. Windows CE's philosophy behind block devices requires that a FSD be associated with a BDD. This is yet another abstraction to handling the device thereby making the OS's job much easier. (unfortunately an efficient implementation isn't always the result of an easy task) What does a Block Device driver look like? Let's step it up a notch.. The BDD dll must contain the following exported routines:
Replace xxx with letters of
your own to refer to your particular device. For instance, because our
driver started out as a CDROM driver (and can still function as a BDD
for a cdrom) we chose CDROM. Also, note that 'must' is really 'should'
or perhaps in some cases 'should not'. This is because most of the routines
listed above were obseleted when Windows CE decided to copy UNIXs implementation
of a device driver. Interesting how The read and write codes of
What about the FSD?When we started our goal was to implement a CDROM device driver. After much frustration with the documentation we decided that creating our own FSD for ISO9660 was not practical. In fact, we watched a slide presentation given by Windows which suggested that implementing a FSD might be troublesome without a reference. I guess they too don't put much stock in their documentation. Thus, we retargeted our design for an ATA hard disk, which is much simpler I might add..
How do you load the device driver?Our method for loading a BDD
was to call cecdrdrv s0 where the 's' stands for Secondary and the '0' stands for Master. After the call to Now that the OS is in controlAll disk access will come from
the FSD. The first thing that will happen is the FSD will attempt to mount
the device. This involves formatting if necessary, else the driver is
up and running. One thing to be aware of is that the documentation for
the
Implementation: How to get this thing working
Well, this is the end of the discussion. I hope you have enough information to load and run the BDD for the ATA Hard Disk... |
||||||||