Skip to content
Snippets Groups Projects
Commit 0c7eb036 authored by Dor Laor's avatar Dor Laor
Browse files

Add driver class to manage software instances of drivers (as opposued

to devices that may exist at the hardware level w/o a device driver)
parent 1a84c0e8
No related branches found
No related tags found
No related merge requests found
#include "drivers/driver.hh"
#include "debug.hh"
bool Driver::isPresent() {
return false;
}
u16 Driver::getStatus() {
return 0;
}
void Driver::setStatus(u16 s) {
}
bool
Driver::Init(Device* dev) {
if (!dev) return false;
debug(fmt("Driver:Init %x:%x") % _vid % _id);
return true;
}
void Driver::dumpConfig() const {
debug(fmt("Driver vid:id= %x:%x") % _vid % _id);
}
std::ostream& operator << (std::ostream& out, const Driver& d) {
out << "Driver dev id=" << d._id << " vid=" << d._vid << std::endl;
return out;
}
#ifndef DRIVER_H
#define DRIVER_H
#include "arch/x64/processor.hh"
#include "drivers/pci.hh"
#include "drivers/device.hh"
#include <ostream>
#include <unordered_map>
using namespace processor;
class Driver {
public:
Driver(u16 vid, u16 id) :_id(id), _vid(vid) {};
bool isPresent();
u16 getStatus();
void setStatus(u16 s);
void dumpConfig() const;
bool Init(Device *d);
friend std::ostream& operator <<(std::ostream& out, const Driver &d);
struct equal {
bool operator()(const Driver* d1, const Driver* d2) const
{
return (d1->_id == d2->_id && d1->_vid == d2->_vid);
}
};
struct hash : std::unary_function< const Driver*, std::size_t> {
std::size_t operator() ( const Driver* const key ) const {
return (size_t)(key->_id + key->_vid);
}
};
private:
u16 _id;
u16 _vid;
};
#endif
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment