Kernel, libc: Add support for querying the framebuffer's scanline via ioctl()
This commit is contained in:
parent
71633e264f
commit
2c08de044f
@ -1,12 +1,12 @@
|
||||
#include "fs/devices/Framebuffer.h"
|
||||
#include "bootboot.h"
|
||||
#include "memory/MemoryManager.h"
|
||||
#include "misc/utils.h"
|
||||
#include "std/errno.h"
|
||||
#include "std/stdio.h"
|
||||
#include "std/stdlib.h"
|
||||
#include "std/string.h"
|
||||
#include "memory/MemoryManager.h"
|
||||
#include "utils/Addresses.h"
|
||||
#include "misc/utils.h"
|
||||
#include "std/errno.h"
|
||||
#include "bootboot.h"
|
||||
|
||||
extern BOOTBOOT bootboot;
|
||||
extern char fb[1];
|
||||
@ -36,39 +36,36 @@ uintptr_t FramebufferDevice::mmap(VFS::Node* node, uintptr_t addr, size_t size,
|
||||
{
|
||||
if (!node) return -1;
|
||||
int real_prot = prot & ~(MAP_AS_OWNED_BY_TASK);
|
||||
if(round_down_to_nearest_page(offset) != (uintptr_t)offset)
|
||||
{
|
||||
return MAP_FAIL(EINVAL);
|
||||
}
|
||||
if((size + offset) > bootboot.fb_size)
|
||||
if (round_down_to_nearest_page(offset) != (uintptr_t)offset) { return MAP_FAIL(EINVAL); }
|
||||
if ((size + offset) > bootboot.fb_size)
|
||||
{
|
||||
return MAP_FAIL(ERANGE); // FIXME: Should probably be EOVERFLOW.
|
||||
}
|
||||
MemoryManager::map_several_pages(bootboot.fb_ptr + offset, addr, Utilities::get_blocks_from_size(PAGE_SIZE, size), real_prot);
|
||||
MemoryManager::map_several_pages(bootboot.fb_ptr + offset, addr, Utilities::get_blocks_from_size(PAGE_SIZE, size),
|
||||
real_prot);
|
||||
return addr;
|
||||
}
|
||||
|
||||
ssize_t FramebufferDevice::write(VFS::Node* node, size_t offset, size_t size, const char* buffer)
|
||||
{
|
||||
if (!node) return -1;
|
||||
if((size + offset) > (uint64_t)bootboot.fb_size)
|
||||
{
|
||||
size = (uint64_t)bootboot.fb_size - offset;
|
||||
}
|
||||
if ((size + offset) > (uint64_t)bootboot.fb_size) { size = (uint64_t)bootboot.fb_size - offset; }
|
||||
memcpy(fb + offset, buffer, size);
|
||||
return (ssize_t)size;
|
||||
}
|
||||
|
||||
#define FB_GET_WIDTH 0
|
||||
#define FB_GET_HEIGHT 1
|
||||
#define FB_GET_SCANLINE 2
|
||||
|
||||
long FramebufferDevice::ioctl(VFS::Node* node, int cmd, uintptr_t)
|
||||
{
|
||||
if (!node) return -1;
|
||||
switch(cmd)
|
||||
switch (cmd)
|
||||
{
|
||||
case FB_GET_WIDTH: return (long)bootboot.fb_width;
|
||||
case FB_GET_HEIGHT: return (long)bootboot.fb_height;
|
||||
default: return -EINVAL;
|
||||
case FB_GET_WIDTH: return (long)bootboot.fb_width;
|
||||
case FB_GET_HEIGHT: return (long)bootboot.fb_height;
|
||||
case FB_GET_SCANLINE: return (long)bootboot.fb_scanline;
|
||||
default: return -EINVAL;
|
||||
}
|
||||
}
|
@ -7,6 +7,8 @@
|
||||
#define FB_GET_WIDTH 0
|
||||
/* Get the height of a framebuffer device. */
|
||||
#define FB_GET_HEIGHT 1
|
||||
/* Get the scanline of a framebuffer device. */
|
||||
#define FB_GET_SCANLINE 2
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
|
Loading…
Reference in New Issue
Block a user