Page 1 of 1

Driver Programming in C++

Posted: Sun Aug 17, 2003 7:35 pm
by MeLkOr
I would just like to see if any one could tell me how to program drivers?
-MeLkOr

Re:Driver Programming in C++

Posted: Mon Aug 18, 2003 2:35 am
by Solar
Catch the interrupt, copy data, return from interrupt.

Re:Driver Programming in C++

Posted: Mon Aug 18, 2003 2:45 am
by distantvoices
or - micro kernel like:

catch interrupt, buffer data, send message to driver task, return from interrupt

it is a splitted interrupt handling: task is shared between isr and a thread which does the actual processing of data fetched by the isr from some port/hardware.

I am still on the way of forming more and more abstraction, til I get some descriptors in the file system which i can open/close/etc., so I can't show an appendable way of how to do it.

Re:Driver Programming in C++

Posted: Mon Aug 18, 2003 6:02 am
by Pype.Clicker
there's nothing like a generic procedure to develop any driver for any environment ... which device do you wish to support with your driver ?

Re:Driver Programming in C++

Posted: Mon Aug 18, 2003 9:01 am
by MeLkOr
Umm... I don't really know what kind of drivers I want. Lol. Probibly video drivers because that way you can see what is being outputted to the screen.
-MeLkOr

Re:Driver Programming in C++

Posted: Mon Aug 18, 2003 10:20 am
by Tim
A simple video driver:

Code: Select all

void display_string(int x, int y, const char *str)
{
    unsigned short *vidmem = (unsigned short*) 0xb8000;

    while (*str != '\0')
    {
        vidmem[y * 80 + x] = *str;
        x++;
        if (x >= 80)
        {
            x = 0;
            y++;
        }
        if (y >= 25)
            y = 0;
        str++;
    }
}
This supports one device (the video card whose text-mode buffer is located at B8000) and one operation (display_string). It doesn't use any interrupts because it doesn't need to.