The first time CardBuilder was mentioned in KylixDriver Architecture topic that assures of the possibility to automate the creation of your User-Mode driver. CardBuilder is constructively a Kylix IDE design window, a descendant of TClxDesignWindow class, not just a non-modal design-time window. This tool is established as the component editor for the device-modelling component whose class is TkdCustomCard. At the same time CardBuilder is established as the property editor for CardItems property of this component.
Being of a design window class, CardBuilder itself becomes a part of Kylix IDE. By means of a greater part of specific interfaces this fact allows to do things by far easier, turning out CardBuilder to be the whole instrument for design-time work. Just as the native Kylix IDE designer simplifies the visual development (management of components, management of their properties, inter-consistency between source code and visual controls, streem work and other), CardBuilder behaves so over any project involving the device-modelling component and all other components that make up the KylixDriver Application Library.
Purposeful components from this library are represented by Final Resource Classes, called so in KylixDriver terminology.
These components are also called card resources (or device resources) because they are a software abstraction of real hardware resources of different natures: memory, ports, interrupts and other.
Not all design-time code is encapsulated in the implementation of CardBuilder class. The design-time work is also addicted to the object-oriented approach and this is a good chance and a convenient way to properly handle with the majority of card resources in the development stage now and in the future. That is why necessary design-time code is brought to the implementations of card resources themselves, and that is why there are two versions of the KylixDriver Application Library: run-time and design time (in /rtl and /dtl folders correspondingly).
CardBuilder is an excellent tool for two major phases in your hardware driver development:
After the hardware is held by you, insert it into an appropriate slot (PCI/ISA) and use CardBuilder to verify that the hardware is performing as expected. And PCI (and any progressive PCI) card should be automatically detected with its resources ready to be automatically constructed by ‘Quick Card’ mode.
Testing application generation: This application allows you to test your hardware on a console and, more important, gets you an introduction of how your User Mode driver to-be should approximately look like, how different methods and properties are involved in work and which setup and cleanup sections surround some calls.
- Hardware diagnostics:
To use CardBuilder:
- Attach your hardware to the computer
- Run Kylix and create a new project (File|New Application)
- In your project create a new data module
- Look at the Component palette, find and activate KylixDriver tab on it and, finally, drop TkdCustomCard component onto the data module (Note: TkdCustomCard component can be maintained on a TDataModule container only).
- If you are a non-root, check that ModuleLoaded property of the card component is already set to true. It is supposed your administrator had made necessary preparations for you to work with KylixDriver.
- If you, however, root yourself then
- Set ScriptPath property to directory where the GDD (kdmodule.o or kdmodule.ko file) resides
- Set ModuleLoaded property to true. If everything OK, ModuleLoaded property remains set to true, otherwise it comes back to false again
- Click twice on the card component – CardBuilder appears. Alternatively, you can reach CardBuilder via the card component’s CardItems property.
- Click ‘Build By Type’ speed button on CardBuilder’s toolbar, or simply choose ‘Build By Type…’ menu item from ‘Quick Card’ menu.
- Select your PnP device from the list of devices detected by CardBuilder. For non-PnP cards, select ‘ISA Card’. For local printer, select ‘Parallel port’ .
- Diagnose your device. Before writing your device driver it is important to make sure all the hardware is working as expected. Use CardBuilder to diagnose your hardware. All of your activity will be logged onto the logger window accessible via ‘Options’ menu, so that you may later on analyze your tests. (Note: this ability of CardBuilder will be promisingly very powerful in the next release only, because we are now facing lots of interesting ideas concerned. Some inconveniences in this version shall be generously crumbled further.)
- Define your ISA/PCI device’s I/O and memory ranges, registers. Define interrupt(s) and other resources.
- If your card is ‘Plug and Play’, then by this moment CardBuilder had automatically detected almost all of its resources: all port ranges, all memory ranges, interrupt, and configuration space. And hence, CardBuilder had automatically constructed the card model by creating, attaching and adjusting all adequate Kylix components. You card model is almost ready, the only step to do yourself is to define registers.
- For non-‘Plug and Play’ hardware define resources manually.
- Test your ISA/PCI device’s resources.
- At first, your card must be registered. Click ‘Register Card’ speed button, or simply choose ‘Register Card’ menu item from ‘Card’ menu.
- Now read from and write to I/O and memory ranges, as well as to and from any registers you defined. Most of components’ properties cannot be changed after the card was registered, however you can bravely change remaining properties, for example, those responsible for transfer, thereby stating all transfer operations maximally flexible, as necessary. Writing operations, sure, require from you to enter sufficient data to write. There are comprehensible editors on a number of CardBuilder’s working tabs at your disposal.
- Listen to your hardware’s interrupts, if any.
- After the diagnostics is finished, unregister your card by clicking ‘Unregister Card’ speed button, or simply choosing ‘Unregister Card’ menu item from ‘Card’ menu.
- Generate testing application
- Select ‘Testing Application…’ menu item from ‘Generate’ menu or press the appropriate speed button.
- Next, ‘Code Generation Options’ dialog box will appear.
- Change default values, if necessary, and press ‘OK’ button to generate.
- Open a console/terminal window.
- Go to the directory where the testing application was stored.
- Successively execute the generating and the running shell scripts, if produced, to see how the application is working. Execute these scripts at the console prompt as follows:
Again, the testing application can be referenced as a sample of User Mode driving utility or can even be a starting point for you.
Figure 2: CardBuilder is effective in the definition of device model and in the diagnostics of corresponding hardware