The following is a description for how to set a mode and initialize the
accelerator.
- Edit CACHEMAN.C to account for the resolutions
supported by your device, and the memory requirements for those resolutions.
- Edit the asr[] array in EDDESRES.C to match the
resolutions your device can support. (See Multiple
Resolution Support for information on driver initialization for a description
of this array.)
- Edit the QueryAndSelectNativeMode routine in
the EDDESRES.C file. Add code to determine the memory size of the adapter
and other configuration information.
- Edit SetObtainableModes routine in the MODEINFO.C
file. In the S3 driver, this function reads the SVGADATA.PMI file and marks
modes in the asrScreenResolution table as obtainable, based on what it finds
there. It is also possible to directly query the hardware. Another possibility
is to discard SetObtainableModes altogether, and modify CACHEMAN.C to validate
the available modes based on the amount of VRAM and DAC configuration of
the board.
- Edit QueryAndSelectNativeMode and remove the
DMS32CallBack((PFN) (SwitchToChosenMode). This is almost certainly not
what you want to do at this time. For some odd reason, the S3 driver sets
the mode twice during initialization. There is no real reason to do this,
however.
- Edit SwitchToExtendedGraphicsMode in SETMODE.C
so that it will set the appropriate video mode on your device. This may
be done by way of the base-video handler or in assembler code that you write
as part of your driver. Process the mode set in the presentation display
driver if the video handler is not yet working properly. Adding mode set
code to the display driver may let you work while the base video handler
is being developed. (Unless one developer is writing both the base video
handler and the Presentation Display Driver).
- If your device's registers are memory-mapped
rather than I/O-mapped, additional changes need to be made to FillPdb().
In the S3 driver, a flat pointer to the video aperture is obtained after
the mode set and KlugeReset(). This will not work for a memory-mapped device.
Move the first call to GetVRAMPointer() so it occurs before the first drawing-engine
operation. (It does not matter the order in which GetVRAMPointer is called.)
Also, if your device supports an aperture, this is a good place to test
if the aperture-to-video memory has been properly performed. (See Obtaining
Pointers to Video Memory for details on how to do this.) To test this,
create a small routine that copies a fixed bit map to the screen through
the aperture. If this routine generates a page fault exception (TRAP 0E),
then you do not have a valid pointer to the aperture.
- Edit KlugeReset (in HWACCESS.ASM) so it can reset
the accelerator and clear the screen. Assemble code in an INT 3 immediately
after the code that resets the accelerator. For debugging purposes, create
some small routines that perform a few basic
drawing operations on the display using the accelerator. This is a good
test to ensure that everything is set up correctly. (If your drawing engine
is not set correctly, nothing in the driver is going to work.) Also, remove
any code from the various pieces of initialization code that runs on an
S3 chip rather than your chip set.
- At this point, some code may need to be debugged.
Put an _asm {INT 3} in FillPdb() (EDDEFPDB.C), immediately before the call
to QueryAndSelectNativeMode(). (The _asm {INT 3} will cause an INT 3 instruction
to be inserted in the code, which will cause the kernel debugger to break
when it reaches that point.) Build the driver and run it under the debug
kernel. If the INT 3 you previously added is reached, the debugging has
been successful. If you are unable to reach the INT 3, try adding one to
the beginning of FillLdb() in EDDEFLDB.C. This occurs early in the driver.
If you are unable get to there, add one in the LOADPROC in DYNA32.ASM.
This is the very first entry into the driver. If you are unable to get
there, then you are not successfully building the driver. Look at your
make file for any inconsistencies.
10.
Continue going through routines debugging until
you successfully get to KlugeReset. At this point, you will be in a graphics
mode. Step through the code that enables the drawing engine of your chip,
and test it with the small routines that were written in step 7. Continue
until you get a good mode set, have the drawing engine enabled, and are
able to do some simple drawing commands inside the KlugeReset routine.
[Back: Porting the Code]
[Next: The First BitBlt]