kernel+init: Add a framebuffer special device file
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
58dc23e4d9
commit
841fc25137
@ -20,6 +20,7 @@ static void populate_devfs()
|
|||||||
xmknod("/dev/console", 0666, 1, 0);
|
xmknod("/dev/console", 0666, 1, 0);
|
||||||
xmknod("/dev/null", 0666, 2, 0);
|
xmknod("/dev/null", 0666, 2, 0);
|
||||||
xmknod("/dev/zero", 0666, 2, 1);
|
xmknod("/dev/zero", 0666, 2, 1);
|
||||||
|
xmknod("/dev/fb0", 0222, 3, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
|
@ -43,6 +43,7 @@ set(SOURCES
|
|||||||
src/fs/devices/NullDevice.cpp
|
src/fs/devices/NullDevice.cpp
|
||||||
src/fs/devices/ZeroDevice.cpp
|
src/fs/devices/ZeroDevice.cpp
|
||||||
src/fs/devices/ConsoleDevice.cpp
|
src/fs/devices/ConsoleDevice.cpp
|
||||||
|
src/fs/devices/FramebufferDevice.cpp
|
||||||
src/InitRD.cpp
|
src/InitRD.cpp
|
||||||
src/ELF.cpp
|
src/ELF.cpp
|
||||||
)
|
)
|
||||||
|
@ -13,6 +13,11 @@ class Device
|
|||||||
return err(ENOTTY);
|
return err(ENOTTY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
virtual usize size() const
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
virtual bool blocking() const = 0;
|
virtual bool blocking() const = 0;
|
||||||
|
|
||||||
virtual ~Device() = default;
|
virtual ~Device() = default;
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
#include "fs/devices/DeviceRegistry.h"
|
#include "fs/devices/DeviceRegistry.h"
|
||||||
#include "Log.h"
|
#include "Log.h"
|
||||||
#include "fs/devices/ConsoleDevice.h"
|
#include "fs/devices/ConsoleDevice.h"
|
||||||
|
#include "fs/devices/FramebufferDevice.h"
|
||||||
#include "fs/devices/NullDevice.h"
|
#include "fs/devices/NullDevice.h"
|
||||||
#include "fs/devices/ZeroDevice.h"
|
#include "fs/devices/ZeroDevice.h"
|
||||||
#include <luna/Vector.h>
|
#include <luna/Vector.h>
|
||||||
@ -45,6 +46,7 @@ namespace DeviceRegistry
|
|||||||
TRY(register_special_device(DeviceMajorTypes::Memory, 0, NullDevice::create));
|
TRY(register_special_device(DeviceMajorTypes::Memory, 0, NullDevice::create));
|
||||||
TRY(register_special_device(DeviceMajorTypes::Memory, 1, ZeroDevice::create));
|
TRY(register_special_device(DeviceMajorTypes::Memory, 1, ZeroDevice::create));
|
||||||
TRY(register_special_device(DeviceMajorTypes::Console, 0, ConsoleDevice::create));
|
TRY(register_special_device(DeviceMajorTypes::Console, 0, ConsoleDevice::create));
|
||||||
|
TRY(register_special_device(DeviceMajorTypes::Framebuffer, 0, FramebufferDevice::create));
|
||||||
|
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,8 @@ namespace DeviceRegistry
|
|||||||
{
|
{
|
||||||
Null = 0,
|
Null = 0,
|
||||||
Console = 1,
|
Console = 1,
|
||||||
Memory = 2
|
Memory = 2,
|
||||||
|
Framebuffer = 3,
|
||||||
};
|
};
|
||||||
|
|
||||||
Result<SharedPtr<Device>> create_special_device(u32 major, u32 minor);
|
Result<SharedPtr<Device>> create_special_device(u32 major, u32 minor);
|
||||||
|
37
kernel/src/fs/devices/FramebufferDevice.cpp
Normal file
37
kernel/src/fs/devices/FramebufferDevice.cpp
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
#include "fs/devices/FramebufferDevice.h"
|
||||||
|
#include "video/Framebuffer.h"
|
||||||
|
#include <luna/CString.h>
|
||||||
|
|
||||||
|
Result<SharedPtr<Device>> FramebufferDevice::create()
|
||||||
|
{
|
||||||
|
return (SharedPtr<Device>)TRY(make_shared<FramebufferDevice>());
|
||||||
|
}
|
||||||
|
|
||||||
|
Result<usize> FramebufferDevice::read(u8*, usize, usize) const
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
Result<usize> FramebufferDevice::write(const u8* buf, usize offset, usize length)
|
||||||
|
{
|
||||||
|
if ((offset + length) > size()) length = size() - offset;
|
||||||
|
|
||||||
|
memcpy(Framebuffer::ptr() + offset, buf, length);
|
||||||
|
|
||||||
|
return length;
|
||||||
|
}
|
||||||
|
|
||||||
|
usize FramebufferDevice::size() const
|
||||||
|
{
|
||||||
|
return Framebuffer::size();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool FramebufferDevice::blocking() const
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
Result<u64> FramebufferDevice::ioctl(int, void*)
|
||||||
|
{
|
||||||
|
return err(EINVAL);
|
||||||
|
}
|
21
kernel/src/fs/devices/FramebufferDevice.h
Normal file
21
kernel/src/fs/devices/FramebufferDevice.h
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
#pragma once
|
||||||
|
#include "fs/devices/DeviceRegistry.h"
|
||||||
|
|
||||||
|
class FramebufferDevice : public Device
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
// Initializer for DeviceRegistry.
|
||||||
|
static Result<SharedPtr<Device>> create();
|
||||||
|
|
||||||
|
Result<usize> read(u8*, usize, usize) const override;
|
||||||
|
|
||||||
|
Result<usize> write(const u8*, usize, usize) override;
|
||||||
|
|
||||||
|
bool blocking() const override;
|
||||||
|
|
||||||
|
Result<u64> ioctl(int request, void* arg) override;
|
||||||
|
|
||||||
|
usize size() const override;
|
||||||
|
|
||||||
|
virtual ~FramebufferDevice() = default;
|
||||||
|
};
|
@ -176,7 +176,7 @@ namespace TmpFS
|
|||||||
|
|
||||||
usize size() const override
|
usize size() const override
|
||||||
{
|
{
|
||||||
return 0;
|
return m_device->size();
|
||||||
}
|
}
|
||||||
|
|
||||||
mode_t mode() const override
|
mode_t mode() const override
|
||||||
|
Loading…
Reference in New Issue
Block a user