2018-10-13 20:59:22 -04:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <AK/Types.h>
|
|
|
|
#include "Limits.h"
|
2018-11-07 05:37:54 -05:00
|
|
|
#include "FileDescriptor.h"
|
2018-10-13 20:59:22 -04:00
|
|
|
|
2018-11-16 07:11:21 -05:00
|
|
|
class Process;
|
|
|
|
|
2018-10-13 20:59:22 -04:00
|
|
|
class CharacterDevice {
|
|
|
|
public:
|
|
|
|
virtual ~CharacterDevice();
|
|
|
|
|
2018-11-07 05:37:54 -05:00
|
|
|
RetainPtr<FileDescriptor> open(int options);
|
2018-10-30 08:59:29 -04:00
|
|
|
|
2018-12-02 18:39:25 -05:00
|
|
|
virtual bool has_data_available_for_reading() const = 0;
|
2018-10-25 07:07:59 -04:00
|
|
|
|
2018-12-02 17:34:50 -05:00
|
|
|
virtual ssize_t read(byte* buffer, size_t bufferSize) = 0;
|
|
|
|
virtual ssize_t write(const byte* buffer, size_t bufferSize) = 0;
|
2018-10-13 20:59:22 -04:00
|
|
|
|
2018-10-30 08:59:29 -04:00
|
|
|
unsigned major() const { return m_major; }
|
|
|
|
unsigned minor() const { return m_minor; }
|
|
|
|
|
2018-12-02 18:39:25 -05:00
|
|
|
virtual bool is_tty() const { return false; }
|
2018-10-30 17:03:02 -04:00
|
|
|
|
2018-11-16 07:11:21 -05:00
|
|
|
virtual int ioctl(Process&, unsigned request, unsigned arg);
|
|
|
|
|
2018-10-13 20:59:22 -04:00
|
|
|
protected:
|
2018-10-30 08:59:29 -04:00
|
|
|
CharacterDevice(unsigned major, unsigned minor) : m_major(major), m_minor(minor) { }
|
|
|
|
|
|
|
|
private:
|
|
|
|
unsigned m_major { 0 };
|
2018-11-16 07:11:21 -05:00
|
|
|
unsigned m_minor { 0 };
|
2018-10-13 20:59:22 -04:00
|
|
|
};
|