minix/lib/libbdev/driver.c
David van Moolenbroek af01bda509 libbdev: initial version
The "bdev" library provides basic primitives for file systems to talk
to block device drivers, hiding the details of the underlying protocol
and interaction model.

This version of libbdev is rather basic. It is planned to support the
following features in the long run:

 - asynchronous requests and replies;
 - recovery support for underlying block drivers;
 - retrying of failed I/O requests.

The commit also changes our block-based file systems (mfs, ext2, isofs)
to make use of libbdev.
2011-11-09 14:43:25 +01:00

58 lines
953 B
C

/* libbdev - driver endpoint management */
#include <minix/drivers.h>
#include <minix/bdev.h>
#include <assert.h>
#include "proto.h"
static endpoint_t driver_endpt[NR_DEVICES];
void bdev_driver_init(void)
{
/* Initialize the driver table.
*/
int i;
for (i = 0; i < NR_DEVICES; i++)
driver_endpt[i] = NONE;
}
void bdev_driver_clear(dev_t dev)
{
/* Clear information about a driver.
*/
int major;
major = major(dev);
assert(major >= 0 && major < NR_DEVICES);
driver_endpt[major] = NONE;
}
void bdev_driver_set(dev_t dev, endpoint_t endpt)
{
/* Set the endpoint for a driver.
*/
int major;
major = major(dev);
assert(major >= 0 && major < NR_DEVICES);
driver_endpt[major] = endpt;
}
endpoint_t bdev_driver_get(dev_t dev)
{
/* Return the endpoint for a driver, or NONE if we do not know its endpoint.
*/
int major;
major = major(dev);
assert(major >= 0 && major < NR_DEVICES);
return driver_endpt[major];
}