Keyboard Driver Design Issue

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
User avatar
matthias
Member
Member
Posts: 158
Joined: Fri Oct 22, 2004 11:00 pm
Location: Vlaardingen, Holland
Contact:

Keyboard Driver Design Issue

Post by matthias »

I'm having some trouble with my keyboard driver. Well I mean the design. I have built an interface for drivers to register themselves through a device manager, any application or even the kernel can open a device to I/O with it.

Like:

Code: Select all

VideoHandle = OpenCoreDevice("/dev/video");

CoreDeviceSpecial(VideoHandle, 0, 0, 4000); // clear screen
CoreDeviceSpecial(VideoHandle, (char*)0x1, 0, 0); // move cursor to start of screen

// Close handle, the rest is up to our console manager
CloseCoreDevice(VideoHandle);
This is how I communicate with the video-driver. On top of the video driver I will have a console driver which manages consoles (duh).

My question is: When I get an interrupt from the keyboard, my handler for this one, could simply write the character to the screen, but I want my console driver to catch this one, but that would mean I'll have to either move the keyboard handler to the console driver or I would have to use a buffer?? (e.g. I have this function to tell the keyboard driver where this buffer is) I don't know what is the best solution.

I think moving the keyboard interrupt handler works best, but however it undermines the keyboard driver, because it relies on the console driver, which I don't like because there goes my modularity.

So should I use a buffer or use a direct output method??
The source of my problems is in the source.
User avatar
prajwal
Member
Member
Posts: 154
Joined: Sat Oct 23, 2004 11:00 pm
Contact:

Post by prajwal »

Buffering is better... Since in future implementation when multiple processing is done, only the foreground process should be interactive to the peripheral devices llike KB, Mouse....

Furthur Buffering will help the user type ahead of processing... which is not a mandate req of an OS but usefull for example. in linux u type make <enter> make install <enter> before male comes out...
User avatar
matthias
Member
Member
Posts: 158
Joined: Fri Oct 22, 2004 11:00 pm
Location: Vlaardingen, Holland
Contact:

Post by matthias »

Ok I've implemented buffering in my OS. Works quite well actually, now my console driver can do this if it wants to read a character from the buffer:

Code: Select all

// Read a character from keyboard buffer
status_t ConsoleRead(char* buf, size_t n)
{
	return ReadCoreDevice(KeyboardDevice, buf, n);
}

// loads the console driver:
void console_install()
{
    /* Install driver */
	memcpy(ConsoleDevice.Device, "console", 7);

	ConsoleDevice.type = CORE_TYPE_VIRTUAL;
	ConsoleDevice.io = CORE_IO_RW;

	ConsoleDevice.irq = -1;
	ConsoleDevice.IrqHandler = 0;

	ConsoleDevice.Read = ConsoleRead;
	ConsoleDevice.Special = ConsoleSpecial;
	ConsoleDevice.Write = ConsoleWrite;

	RegisterCoreDevice(&ConsoleDevice);

	/* Get exclusive lock on video and keyboard driver */
	VideoDevice = OpenCoreDevice("/dev/video", 1);
	KeyboardDevice = OpenCoreDevice("/dev/keyboard", 1);

	int iterator = 0;
	
	while(iterator < 12)
	{
		// set common settings
		Consoles[iterator].attribute = 0x0F;
		Consoles[iterator].csr_x = 0;
		Consoles[iterator].csr_y = 0;
		Consoles[iterator].reads = 0;
		Consoles[iterator].writes = 0;

		iterator++;
	}

	//set current Console
	CurrentConsole = &Consoles[0];
}
The source of my problems is in the source.
Post Reply