Driver Information

The OS needs drivers in order to communicate with devices, such as your USB flash drive, your headphones, your printer that you haven't used in a year, your 3D printer that you accidentally used to print a report and broke, etc. Anyway, this is the documentation for writing drivers.

Writing Drivers

Each driver has to contain 2 files: the driver name header file (mouse.h) and the driver name C file (mouse.c). There also must be two sections, <drivername>.init and <drivername>.work. Here's an example of a driver header file:

#ifdef DRIVER_H

#undef DRIVER_H

#define DRIVER_H

#else

#ifndef DRIVER_H

#define DRIVER_H


struct driver_drvr_platypusos{

void init(void);

void work(void);

}


#endif DRIVER_H

Here's a C file with all the important info:

#include "driver.h"


struct driver_drvr_platypusos driver;


void driver_driver(void){

driver.init()

driver.work()

}


void init(void){

// Code for initializing driver

}

void work(void){

// Code for just working, don't type your code in italics.

}

You may also want to include asm/io.h for reading/writing from/to ports and log/log.h for logging events.