XV6 Device Driver
Why we have a Driver?
Initialization
Config Hardware
void
consoleinit(void)
{
initlock(&cons.lock, “cons”);
uartinit();
// connect read and write system calls
// to consoleread and consolewrite.
devsw[CONSOLE].read = consoleread;
devsw[CONSOLE].write = consolewrite;
}Create console device
How to read or write from device
Flow
Every input char generates an interrupt
Trap handler determines interrupt source
Accumulate inputs and Wake up
Read one char and hand over
Accumulate inputs
Wake up when get a whole line
Copy to user space
Question:
How does open(“console", O_RDWR) opens a file with DEVICE type?
open(“console", O_RDWR) opens a file with DEVICE type?Last updated