Driver Programming in C++

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
MeLkOr

Driver Programming in C++

Post by MeLkOr »

I would just like to see if any one could tell me how to program drivers?
-MeLkOr
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re:Driver Programming in C++

Post by Solar »

Catch the interrupt, copy data, return from interrupt.
Every good solution is obvious once you've found it.
distantvoices
Member
Member
Posts: 1600
Joined: Wed Oct 18, 2006 11:59 am
Location: Vienna/Austria
Contact:

Re:Driver Programming in C++

Post 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.
... the osdever formerly known as beyond infinity ...
BlueillusionOS iso image
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:Driver Programming in C++

Post 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 ?
MeLkOr

Re:Driver Programming in C++

Post 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
Tim

Re:Driver Programming in C++

Post 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.
Post Reply