Data Structures

How to add an (S)VGA driver to XFree86 : The Driver Itself : Data Structures
Previous: Multiple Chipsets And Options
Next: The Ident() function

## 6.2. Data Structures

Once you have an understanding of what is needed from the above description, it is time to fill in the driver data structures. First we will deal with the `vgaSDCRec' structure. This data structure is the driver-local structure that holds the SVGA state information. The first entry in this data structure is ALWAYS `vgaHWRec std'. This piece holds the generic VGA portion of the information. After that, you will have one `unsigned char' field for each register that will be manipulated by your driver. That's all there is to this data structure.

Next you must initialize the `SDC' structure (type `vgaVideoChipRec'). This is the global structure that identifies your driver to the server. Its name MUST be `SDC', in all caps - i.e. it must match the directory name for your driver. This is required so that the Link Kit reconfiguration can identify all of the requisite directories and global data structures.

The first section of this structure simply holds pointers to the driver functions.

Next, you must initialize the information about how your chipset does bank switching. The following fields must be filled in:

1. ChipMapSize - the amount of memory that must be mapped into the server's address space. This is almost always 64k (from 0xA0000 to 0xAFFFF). Some chipsets use a 128k map (from 0xA0000 to 0xBFFFF). If your chipset gives an option, use the 64k window, as a 128k window rules out using a Hercules or Monochrome Display Adapter card with the SVGA.
2. ChipSegmentSize - the size of each bank within the ChipMapSize window. This is usually also 64k, however, some chipsets split the mapped window into a read portion and a write portion (for example the PVGA1/Western Digital chipsets).
3. ChipSegmentShift - the number of bits by which an address will be shifted right to mask of the bank number. This is log-base-2 of ChipSegmentSize.
4. ChipSegmentMask - a bitmask used to mask off the address within a given bank. This is (ChipSegmentSize-1).
5. ChipReadBottom,ChipReadTop - the addresses within the mapped window in which read operations can be done. Usually 0, and 64k, respectively, except for those chipset that have separate read and write windows.
6. ChipWriteBottom,ChipWriteTop - same as above, for write operations.
7. ChipUse2Banks - a boolean value for whether this chipset has one or two bank registers. This is used to set up the screen-to-screen operations properly.

There are three more fields that must be filled in:

1. ChipInterlaceType - this is either VGA_NO_DIVIDE_VERT or VGA_DIVIDE_VERT. Some chipsets require that the vertical timing numbers be divided in half for interlaced modes. Setting this flag will take care of that.
2. ChipOptionFlags - this should always be `{0,}' in the data structure initialization. This is a bitfield that contains the Option flags that are valid for this driver. The appropriate bits are initialized at the end of the Probe function.
3. ChipRounding - this gets set to the multiple by which the virtual width of the display must be rounded for the 256-color server. This value is usually 8, but may be 4 or 16 for some chipsets.

How to add an (S)VGA driver to XFree86 : The Driver Itself : Data Structures
Previous: Multiple Chipsets And Options
Next: The Ident() function