Rodolphe Ortalo writes:
> Attached to this mail is a file containing a description of some VGA
> registers in the fictious language I'd like to see available. This is just
> a tentative syntax (do not hesitate to propose modifications) but it
> should demonstrate the concept.
>
> >From such a description, I'd expect a (to-be-written) translator to
> generate C functions for easily accessing registers, so as to allow to
> write "SET_Vertical_Retrace_Start(0x23);" etc. without bothering to write
> carefully specific bits of the field in 2 or more registers.
>
> I send this example because I'd like to ask a question to all the past or
> future graphic chipset driver developpers that may be on the lists:
> Do you think the availability of such a description language would really
> ease driver development ?
For me I don't think it would help much. Personally I'd try another
(in a way similiar) approach, like this:
Split the driver into two parts, a part that merely provides a wrapper
around the (usually real ugly) details of actually programming the
hardware, and the actual driver which computes the needed values.
The wrapper provides a COM interface which the real driver uses. The
wrapper may provide numerous interfaces e.g. for VGA it may make sense
to have a separate interface for accessing the DAC. Below is an
example COM interface for Hercules/MDA (it's an assembler header file,
it would look a bit nicer in C, and a bit nicer still in IDL).
This is similiar, since here the COM interface describes the hardware,
but at a slightly higher level than the raw bits, e.g. that interface
provides one logical `mode' value, but the actual bits are spread
across 3 or so registers. (What the wrapper shouldn't do is provide
any functionality that the hardward doesn't directly support -- that's
what the real driver is for).
Food for thought at least :-).
Cheers,
__
\/ Andrew Apted <[EMAIL PROTECTED]>
//---------------------------------------------------------------------------
// interface IMda : IUnknown
//
// GUID: 374581C7.1CA30EBE.3e.F6.3A.DB.E8.80.56.62
//
#define IID_IMda_DEF \
0x374581C7, 0x1CA30EBE, 0xDB3AF63e, 0x625680E8
// Functions
IMda_Allocate = 12 // () : HRESULT
IMda_Free = 16 // () : HRESULT
IMda_GetMemory = 20 // (VAR base: ADDR, VAR size: ULONG) : HRESULT
IMda_EncodeAttr = 24 // (attr: UBYTE) : UWORD;
IMda_DecodeAttr = 28 // (value: UWORD) : UBYTE;
IMda_ReadStatus = 32 // () : ULONG
IMda_SetHorizTimings = 40 // (total, displayed, sync_pos,
sync_width: ULONG) : HRESULT
IMda_GetHorizTimings = 44 // (VAR total, displayed, sync_pos,
sync_width: ULONG)
IMda_SetVertTimings = 48 // (total, adjust, displayed,
sync_pos: ULONG)
IMda_GetVertTimings = 52 // (VAR total, adjust, displayed,
sync_pos: ULONG)
IMda_SetMaxScanLine = 56 // (value: ULONG) : HRESULT
IMda_GetMaxScanLine = 60 // () : ULONG
IMda_SetCursorShape = 64 // (start, end, blink: ULONG) : HRESULT
IMda_GetCursorShape = 68 // (VAR start, end, blink: ULONG)
IMda_SetCursorLocation = 72 // (offset: ULONG) : HRESULT
IMda_GetCursorLocation = 76 // () : ULONG
IMda_SetStartAddress = 80 // (start: ULONG) : HRESULT
IMda_GetStartAddress = 84 // () : ULONG
IMda_SetMode = 88 // (mode: ULONG)
IMda_GetMode = 92 // () : ULONG
// Attributes (not encoded)
MDA_ATTR_REVERSE = 0x01
MDA_ATTR_UNDERLINE = 0x02
MDA_ATTR_BOLD = 0x04
MDA_ATTR_BLINK = 0x08
// Status flags
MDA_STATUS_HSYNC = 0x01
MDA_STATUS_VSYNC = 0x80
MDA_STATUS_VIDEO = 0x08
// Blink values
MDA_BLINK_OFF = 0x00
MDA_BLINK_SLOW = 0x01
MDA_BLINK_FAST = 0x02
// Mode bits
MDA_MODE_HERCULES_GFX = 0x01
MDA_MODE_VIDEO_ENABLE = 0x02
MDA_MODE_BLINK_ENABLE = 0x04
MDA_MODE_GFX_PAGE_1 = 0x08
MDA_MODE_132_COLUMN = 0x10
MDA_MODE_MODE_ENABLE = 0x20
MDA_MODE_PAGE_ENABLE = 0x40
MDA_MODE_INTERLACE = 0x80
//======================================================================
//
// INTERFACE:
//
// IMda : IUnknown
//
// DESCRIPTION
//
// Provides access to the Monochrome Display Adapter card.
// Includes the Hercules card.
//
//----------------------------------------------------------------------
//
// FUNCTION:
//
// IMda_Allocate () : HRESULT
//
// DESCRIPTION:
//
// Attempt to allocate the MDA card for exclusive use, returning
// S_OK if successful otherwise an error code (typically
// E_ALLOC_FAILED).
//
//----------------------------------------------------------------------
//
// FUNCTION:
//
// IMda_Free () : HRESULT
//
// DESCRIPTION:
//
// Frees this MDA card, returning S_OK if successful, otherwise an
// error code but note well that under NO circumstances should you
// attempt to Free() something that you did not Allocate() !
//
// FIXME: document all the remaining functions !