AquilaOS documentation
How it works, and its code
Loading...
Searching...
No Matches
fbdev.c File Reference

The framebuffer devices: /dev/fb0 and up (character device 29, as on Linux). More...

#include <core/system.h>
#include <sys/uaccess.h>
#include <core/module.h>
#include <dev/fbdev.h>
#include <dev/ramdev.h>
#include <fs/vfs.h>
#include <fs/devfs.h>
#include <fs/posix.h>

Go to the source code of this file.

Macros

#define MAX_FBDEV   2

Functions

int fbdev_register (int type, void *data)
 Registers a framebuffer, which fbdev_probe() sets up with its driver.
static struct fbdev * fbdev_get (struct devid *dd)
 Returns the framebuffer of a device number, or NULL if there's none.
struct fbdev * fbdev_primary (void)
 Returns the first framebuffer, once it is set up, for the virtual terminals.
static ssize_t fbdev_write (struct devid *dd, off_t offset, struct iobuf *io)
 Writes to a framebuffer, through its driver.
static int fbdev_ioctl (struct devid *dd, int request, void *argp)
 Handles Linux's framebuffer ioctl()s: the screen information, which can be read but not changed, and panning, which isn't supported.
static int fbdev_map (struct devid *dd, struct vm_space *vm_space, struct vm_entry *vm_entry)
 Maps a framebuffer into a process's address space, through its driver.
int fbdev_probe ()
 Sets up the registered framebuffers with their drivers, and registers the framebuffer devices.

Variables

static struct fbdev registered_fbs [MAX_FBDEV]
static size_t fbdev_cnt = 0
struct dev fbdev

Detailed Description

The framebuffer devices: /dev/fb0 and up (character device 29, as on Linux).

A framebuffer driver registers its framebuffer here, and this layer gives it its device, with Linux's framebuffer ioctl()s to describe it. Writing to the device writes pixels, and mmap() maps the framebuffer into the process. The only driver is the VESA framebuffer (dev/fb/vesa/vesa.c).

Definition in file fbdev.c.

Macro Definition Documentation

◆ MAX_FBDEV

#define MAX_FBDEV   2

Definition at line 23 of file fbdev.c.

Referenced by fbdev_register().

Function Documentation

◆ fbdev_get()

struct fbdev * fbdev_get ( struct devid * dd)
static

Returns the framebuffer of a device number, or NULL if there's none.

Definition at line 49 of file fbdev.c.

References fbdev_cnt, fbdev_get(), devid::minor, NULL, and registered_fbs.

Referenced by fbdev_get(), fbdev_ioctl(), fbdev_map(), and fbdev_write().

◆ fbdev_ioctl()

int fbdev_ioctl ( struct devid * dd,
int request,
void * argp )
static

Handles Linux's framebuffer ioctl()s: the screen information, which can be read but not changed, and panning, which isn't supported.

Definition at line 84 of file fbdev.c.

References fb, fbdev_get(), fbdev_ioctl(), fbdev::fix_screeninfo, and fbdev::var_screeninfo.

Referenced by fbdev_ioctl().

◆ fbdev_map()

int fbdev_map ( struct devid * dd,
struct vm_space * vm_space,
struct vm_entry * vm_entry )
static

Maps a framebuffer into a process's address space, through its driver.

Definition at line 135 of file fbdev.c.

References fb, fbdev_get(), fbdev_map(), and fbdev::map.

Referenced by fbdev_map().

◆ fbdev_primary()

struct fbdev * fbdev_primary ( void )

Returns the first framebuffer, once it is set up, for the virtual terminals.

Returns
the framebuffer, or NULL if there is none

Definition at line 63 of file fbdev.c.

References fbdev_cnt, fbdev_primary(), fbdev::fix_screeninfo, NULL, and registered_fbs.

Referenced by fbdev_primary(), and vt_fb_probe().

◆ fbdev_probe()

int fbdev_probe ( )

Sets up the registered framebuffers with their drivers, and registers the framebuffer devices.

Returns
0

Definition at line 151 of file fbdev.c.

References fb, fbdev_cnt, fbdev_probe(), FBDEV_TYPE_VESA, kdev_chrdev_register(), registered_fbs, and fbdev::type.

Referenced by fbdev_probe().

◆ fbdev_register()

int fbdev_register ( int type,
void * data )

Registers a framebuffer, which fbdev_probe() sets up with its driver.

The first one registered is /dev/fb0.

Parameters
typeits driver (FBDEV_TYPE_VESA)
datawhat the driver needs to set it up (the VESA mode's description)
Returns
0, or -ENOSPC if there are MAX_FBDEV already

Definition at line 37 of file fbdev.c.

References fbdev::data, fbdev_cnt, fbdev_register(), MAX_FBDEV, registered_fbs, and fbdev::type.

Referenced by fbdev_register(), and process_multiboot_info().

◆ fbdev_write()

ssize_t fbdev_write ( struct devid * dd,
off_t offset,
struct iobuf * io )
static

Writes to a framebuffer, through its driver.

Definition at line 72 of file fbdev.c.

References fb, fbdev_get(), fbdev_write(), and fbdev::write.

Referenced by fbdev_write().

Variable Documentation

◆ fbdev

struct dev fbdev
Initial value:
= {
.name = "fbdev",
.probe = fbdev_probe,
.write = fbdev_write,
.ioctl = fbdev_ioctl,
.map = fbdev_map,
.fops = {
.open = posix_file_open,
.write = posix_file_write,
.ioctl = posix_file_ioctl,
.lseek = posix_file_lseek,
.can_write = __vfs_can_always,
.can_read = __vfs_can_never,
.eof = __vfs_eof_never,
},
}
static ssize_t fbdev_write(struct devid *dd, off_t offset, struct iobuf *io)
Writes to a framebuffer, through its driver.
Definition fbdev.c:72
static int fbdev_map(struct devid *dd, struct vm_space *vm_space, struct vm_entry *vm_entry)
Maps a framebuffer into a process's address space, through its driver.
Definition fbdev.c:135
int fbdev_probe()
Sets up the registered framebuffers with their drivers, and registers the framebuffer devices.
Definition fbdev.c:151
static int fbdev_ioctl(struct devid *dd, int request, void *argp)
Handles Linux's framebuffer ioctl()s: the screen information, which can be read but not changed,...
Definition fbdev.c:84
off_t posix_file_lseek(struct file *file, off_t offset, int whence)
Moves an open file's offset: to offset (SEEK_SET), by offset from where it is (SEEK_CUR),...
Definition lseek.c:22
int posix_file_open(struct file *file)
Finishes opening a file: with O_TRUNC, a regular file is truncated to 0 bytes.
Definition open.c:17
int posix_file_ioctl(struct file *file, int request, void *argp)
Passes an ioctl() request on to the file's vnode (a device's, or its filesystem's).
Definition ioctl.c:19
ssize_t posix_file_write(struct file *file, struct iobuf *io)
Writes to an open file at its offset, and moves the offset past what was written.
Definition write.c:25

Definition at line 167 of file fbdev.c.

◆ fbdev_cnt

size_t fbdev_cnt = 0
static

Definition at line 26 of file fbdev.c.

Referenced by fbdev_get(), fbdev_primary(), fbdev_probe(), and fbdev_register().

◆ registered_fbs

struct fbdev registered_fbs[MAX_FBDEV]
static

Definition at line 25 of file fbdev.c.

Referenced by fbdev_get(), fbdev_primary(), fbdev_probe(), and fbdev_register().