[fbcon] Remove userptr_t from framebuffer console drivers

Simplify the framebuffer console drivers by assuming that the raw
framebuffer, character cell array, background picture, and glyph data
are all directly accessible via pointer dereferences.

In particular, this avoids the need to copy each glyph during drawing:
the VESA framebuffer driver can simply return a pointer to the glyph
data stored in the video ROM.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
Michael Brown
2025-04-25 10:52:26 +01:00
parent 4cca1cadf8
commit aa3cc56ab2
5 changed files with 112 additions and 116 deletions

View File

@@ -12,7 +12,6 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
#include <stdint.h>
#include <ipxe/ansiesc.h>
#include <ipxe/utf8.h>
#include <ipxe/uaccess.h>
#include <ipxe/console.h>
/** Character width, in pixels */
@@ -38,9 +37,9 @@ struct fbcon_font {
* Get character glyph
*
* @v character Unicode character
* @v glyph Character glyph to fill in
* @ret glyph Character glyph
*/
void ( * glyph ) ( unsigned int character, uint8_t *glyph );
const uint8_t * ( * glyph ) ( unsigned int character );
};
/** A frame buffer geometry
@@ -100,19 +99,19 @@ struct fbcon_text_cell {
/** A frame buffer text array */
struct fbcon_text {
/** Stored text cells */
userptr_t start;
struct fbcon_text_cell *cells;
};
/** A frame buffer background picture */
struct fbcon_picture {
/** Start address */
userptr_t start;
void *start;
};
/** A frame buffer console */
struct fbcon {
/** Start address */
userptr_t start;
void *start;
/** Length of one complete displayed screen */
size_t len;
/** Pixel geometry */
@@ -149,7 +148,7 @@ struct fbcon {
int show_cursor;
};
extern int fbcon_init ( struct fbcon *fbcon, userptr_t start,
extern int fbcon_init ( struct fbcon *fbcon, void *start,
struct fbcon_geometry *pixel,
struct fbcon_colour_map *map,
struct fbcon_font *font,

View File

@@ -11,7 +11,6 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
#include <stddef.h>
#include <ipxe/refcnt.h>
#include <ipxe/uaccess.h>
/** A pixel buffer */
struct pixel_buffer {
@@ -22,7 +21,7 @@ struct pixel_buffer {
/** Height */
unsigned int height;
/** 32-bit (8:8:8:8) xRGB pixel data, in host-endian order */
userptr_t data;
uint32_t *data;
/** Total length */
size_t len;
};
@@ -49,6 +48,22 @@ pixbuf_put ( struct pixel_buffer *pixbuf ) {
ref_put ( &pixbuf->refcnt );
}
/**
* Get pixel
*
* @v pixbuf Pixel buffer
* @v x X position
* @v y Y position
* @ret pixel Pixel
*/
static inline __attribute__ (( always_inline )) uint32_t *
pixbuf_pixel ( struct pixel_buffer *pixbuf, unsigned int x, unsigned int y ) {
unsigned int index;
index = ( ( y * pixbuf->width ) + x );
return &pixbuf->data[index];
}
extern struct pixel_buffer * alloc_pixbuf ( unsigned int width,
unsigned int height );