PatchworkOS  966e257
A non-POSIX operating system.
Loading...
Searching...
No Matches
fb.h
Go to the documentation of this file.
1#pragma once
2
3#include <kernel/fs/sysfs.h>
4#include <kernel/mem/vmm.h>
5
6#include <stdint.h>
7#include <sys/fb.h>
8#include <sys/proc.h>
9
10typedef struct fb fb_t;
11
12/**
13 * @brief Framebuffer driver abstraction.
14 * @defgroup kernel_drivers_abstract_fb Framebuffer Abstraction
15 * @ingroup kernel_drivers_abstract
16 *
17 * Framebuffer devices are exposed as a `/dev/fb/[id]/` directory, containing the following files:
18 * - `buffer`: A file that can be `mmap`ed to access the framebuffer memory.
19 * - `info`: A read-only file that contains the `fb_info_t` struct for the framebuffer.
20 *
21 * @{
22 */
23
24/**
25 * @brief Framebuffer mmap callback type.
26 */
27typedef void* (*fb_mmap_t)(fb_t*, void*, uint64_t, uint64_t*, pml_flags_t);
28
29/**
30 * @brief Framebuffer structure.
31 * @struct fb_t
32 */
41
42/**
43 * @brief Allocate and initialize a framebuffer structure.
44 *
45 * Will make the framebuffer available under `/dev/fb/[id]`.
46 *
47 * @param info Pointer to the framebuffer information.
48 * @param mmap Function that user space will invoke to mmap the framebuffer.
49 * @return On success, the new framebuffer structure. On failure, `NULL` and `errno` is set.
50 */
52
53/**
54 * @brief Free and deinitialize a framebuffer structure.
55 *
56 * Removes the framebuffer from `/dev/fb/[id]`.
57 *
58 * @param fb Pointer to the framebuffer structure to free.
59 */
60void fb_free(fb_t* fb);
61
62/** @} */
void fb_free(fb_t *fb)
Free and deinitialize a framebuffer structure.
Definition fb.c:111
void *(* fb_mmap_t)(fb_t *, void *, uint64_t, uint64_t *, pml_flags_t)
Framebuffer mmap callback type.
Definition fb.h:27
fb_t * fb_new(const fb_info_t *info, fb_mmap_t mmap)
Allocate and initialize a framebuffer structure.
Definition fb.c:56
void * mmap(fd_t fd, void *address, uint64_t length, prot_t prot)
System call to map memory from a file.
Definition mmap.c:6
static fb_t * fb
Definition gop.c:27
static fb_info_t info
Definition gop.c:51
__UINT64_TYPE__ uint64_t
Definition stdint.h:17
Directory entry structure.
Definition dentry.h:84
Framebuffer info struct.
Definition fb.h:39
Framebuffer structure.
Definition fb.h:34
fb_mmap_t mmap
Definition fb.h:36
dentry_t * infoFile
Definition fb.h:39
dentry_t * dir
Definition fb.h:37
dentry_t * bufferFile
Definition fb.h:38
fb_info_t info
Definition fb.h:35
A entry in a page table without a specified address or callback ID.