mirror of
https://github.com/limine-bootloader/limine
synced 2024-11-26 02:20:31 +03:00
term: Remove a bunch of dead code
This commit is contained in:
parent
82aa036ab3
commit
b1140cd653
@ -280,173 +280,3 @@ void term_fallback(void) {
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
extern void reset_term(void);
|
||||
extern void set_cursor_pos_helper(size_t x, size_t y);
|
||||
|
||||
#if defined (__i386__)
|
||||
#define TERM_XFER_CHUNK 8192
|
||||
|
||||
static uint8_t xfer_buf[TERM_XFER_CHUNK];
|
||||
#endif
|
||||
|
||||
static uint64_t context_size(struct flanterm_context *term) {
|
||||
switch (term_backend) {
|
||||
#if defined (BIOS)
|
||||
case TEXTMODE:
|
||||
return sizeof(struct textmode_context) + (VD_ROWS * VD_COLS) * 2;
|
||||
#endif
|
||||
case GTERM: {
|
||||
struct flanterm_fb_context *ctx = (void *)term;
|
||||
return sizeof(struct flanterm_fb_context) +
|
||||
ctx->font_bits_size +
|
||||
ctx->font_bool_size +
|
||||
ctx->canvas_size +
|
||||
ctx->grid_size +
|
||||
ctx->queue_size +
|
||||
ctx->map_size;
|
||||
}
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
static void context_save(struct flanterm_context *term, uint64_t buf) {
|
||||
switch (term_backend) {
|
||||
#if defined (BIOS)
|
||||
case TEXTMODE: {
|
||||
struct textmode_context *ctx = (void *)term;
|
||||
memcpy32to64(buf, (uintptr_t)ctx, sizeof(struct textmode_context));
|
||||
buf += sizeof(struct textmode_context);
|
||||
memcpy32to64(buf, (uintptr_t)ctx->back_buffer, VD_ROWS * VD_COLS);
|
||||
buf += VD_ROWS * VD_COLS;
|
||||
memcpy32to64(buf, (uintptr_t)ctx->front_buffer, VD_ROWS * VD_COLS);
|
||||
buf += VD_ROWS * VD_COLS;
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
case GTERM: {
|
||||
struct flanterm_fb_context *ctx = (void *)term;
|
||||
memcpy32to64(buf, (uintptr_t)ctx, sizeof(struct flanterm_fb_context));
|
||||
buf += sizeof(struct flanterm_fb_context);
|
||||
memcpy32to64(buf, (uintptr_t)ctx->font_bits, ctx->font_bits_size);
|
||||
buf += ctx->font_bits_size;
|
||||
memcpy32to64(buf, (uintptr_t)ctx->font_bool, ctx->font_bool_size);
|
||||
buf += ctx->font_bool_size;
|
||||
memcpy32to64(buf, (uintptr_t)ctx->canvas, ctx->canvas_size);
|
||||
buf += ctx->canvas_size;
|
||||
memcpy32to64(buf, (uintptr_t)ctx->grid, ctx->grid_size);
|
||||
buf += ctx->grid_size;
|
||||
memcpy32to64(buf, (uintptr_t)ctx->queue, ctx->queue_size);
|
||||
buf += ctx->queue_size;
|
||||
memcpy32to64(buf, (uintptr_t)ctx->map, ctx->map_size);
|
||||
buf += ctx->map_size;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void context_restore(struct flanterm_context *term, uint64_t buf) {
|
||||
switch (term_backend) {
|
||||
#if defined (BIOS)
|
||||
case TEXTMODE: {
|
||||
struct textmode_context *ctx = (void *)term;
|
||||
memcpy32to64((uintptr_t)ctx, buf, sizeof(struct textmode_context));
|
||||
buf += sizeof(struct textmode_context);
|
||||
memcpy32to64((uintptr_t)ctx->back_buffer, buf, VD_ROWS * VD_COLS);
|
||||
buf += VD_ROWS * VD_COLS;
|
||||
memcpy32to64((uintptr_t)ctx->front_buffer, buf, VD_ROWS * VD_COLS);
|
||||
buf += VD_ROWS * VD_COLS;
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
case GTERM: {
|
||||
struct flanterm_fb_context *ctx = (void *)term;
|
||||
memcpy32to64((uintptr_t)ctx, buf, sizeof(struct flanterm_fb_context));
|
||||
buf += sizeof(struct flanterm_fb_context);
|
||||
memcpy32to64((uintptr_t)ctx->font_bits, buf, ctx->font_bits_size);
|
||||
buf += ctx->font_bits_size;
|
||||
memcpy32to64((uintptr_t)ctx->font_bool, buf, ctx->font_bool_size);
|
||||
buf += ctx->font_bool_size;
|
||||
memcpy32to64((uintptr_t)ctx->canvas, buf, ctx->canvas_size);
|
||||
buf += ctx->canvas_size;
|
||||
memcpy32to64((uintptr_t)ctx->grid, buf, ctx->grid_size);
|
||||
buf += ctx->grid_size;
|
||||
memcpy32to64((uintptr_t)ctx->queue, buf, ctx->queue_size);
|
||||
buf += ctx->queue_size;
|
||||
memcpy32to64((uintptr_t)ctx->map, buf, ctx->map_size);
|
||||
buf += ctx->map_size;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void _term_write(struct flanterm_context *term, uint64_t buf, uint64_t count) {
|
||||
switch (count) {
|
||||
case TERM_OOB_OUTPUT_GET: {
|
||||
memcpy32to64(buf, (uint64_t)(uintptr_t)&term->oob_output, sizeof(uint64_t));
|
||||
return;
|
||||
}
|
||||
case TERM_OOB_OUTPUT_SET: {
|
||||
memcpy32to64((uint64_t)(uintptr_t)&term->oob_output, buf, sizeof(uint64_t));
|
||||
return;
|
||||
}
|
||||
case TERM_CTX_SIZE: {
|
||||
uint64_t ret = context_size(term);
|
||||
memcpy32to64(buf, (uint64_t)(uintptr_t)&ret, sizeof(uint64_t));
|
||||
return;
|
||||
}
|
||||
case TERM_CTX_SAVE: {
|
||||
context_save(term, buf);
|
||||
return;
|
||||
}
|
||||
case TERM_CTX_RESTORE: {
|
||||
context_restore(term, buf);
|
||||
return;
|
||||
}
|
||||
case TERM_FULL_REFRESH: {
|
||||
term->full_refresh(term);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
bool native = false;
|
||||
#if defined (__x86_64__) || defined (__aarch64__) || defined (__riscv64)
|
||||
native = true;
|
||||
#elif !defined (__i386__)
|
||||
#error Unknown architecture
|
||||
#endif
|
||||
|
||||
bool autoflush = term->autoflush;
|
||||
term->autoflush = false;
|
||||
|
||||
if (native) {
|
||||
const char *s = (const char *)(uintptr_t)buf;
|
||||
|
||||
flanterm_write(term, s, count);
|
||||
} else {
|
||||
#if defined (__i386__)
|
||||
while (count != 0) {
|
||||
uint64_t chunk;
|
||||
if (count > TERM_XFER_CHUNK) {
|
||||
chunk = TERM_XFER_CHUNK;
|
||||
} else {
|
||||
chunk = count;
|
||||
}
|
||||
|
||||
memcpy32to64((uint64_t)(uintptr_t)xfer_buf, buf, chunk);
|
||||
|
||||
flanterm_write(term, (const char *)xfer_buf, chunk);
|
||||
|
||||
count -= chunk;
|
||||
buf += chunk;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
if (autoflush) {
|
||||
term->double_buffer_flush(term);
|
||||
}
|
||||
|
||||
term->autoflush = autoflush;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user