mirror of
https://git.proxmox.com/git/grub2
synced 2025-05-25 02:29:47 +00:00

I forgot to check in these changes for a long time. This adds incomplete support for VGA console, and this is still very buggy. Also, a lot of consideration is required for I18N, UNICODE, and VGA font issues. Therefore, assume that this is such that "better than nothing". * font/manager.c: New file. * include/pupa/font.h: Likewise. * include/pupa/i386/pc/vga.h: Likewise. * term/i386/pc/vga.c: Likewise. * util/unifont2pff.rb: Likewise. * conf/i386-pc.rmk (kernel_img_HEADERS): Added machine/vga.h. (pkgdata_MODULES): Added vga.mod and font.mod. (vga_mod_SOURCES): New variables. (vga_mod_CFLAGS): Likewise. (font_mod_SOURCES): Likewise. (font_mod_CFLAGS): Likewise. * include/pupa/err.h (PUPA_ERR_BAD_FONT): New constant. * include/pupa/term.h: Include pupa/err.h. (struct pupa_term): Added init and fini. Changed the argument of putchar to pupa_uint32_t. * include/pupa/i386/pc/console.h: Include pupa/symbol.h. (pupa_console_real_putchar): New prototype. (pupa_console_putchar): Removed. (pupa_console_checkkey): Exported. (pupa_console_getkey): Likewise. * kern/misc.c (pupa_vsprintf): Add support for UNICODE characters. * kern/term.c (pupa_term_set_current): Rewritten. (pupa_putchar): Likewise. (pupa_putcode): New function. * kern/i386/pc/startup.S (pupa_console_putchar): Renamed to ... (pupa_console_real_putchar): ... this. (pupa_vga_set_mode): New function. (pupa_vga_get_font): Likewise. * normal/command.c: Include pupa/term.h. (terminal_command): New function. (pupa_command_init): Register the command "terminal". * normal/menu.c (DISP_LEFT): Changed to a UNICODE value. (DISP_UP): Likewise. (DISP_RIGHT): Likewise. (DISP_DOWN): Likewise. (DISP_HLINE): Likewise. (DISP_VLINE): Likewise. (DISP_UL): Likewise. (DISP_UR): Likewise. (DISP_LL): Likewise. (DISP_LR): Likewise. * term/i386/pc/console.c (pupa_console_putchar): New function.
129 lines
4.2 KiB
C
129 lines
4.2 KiB
C
/*
|
|
* PUPA -- Preliminary Universal Programming Architecture for GRUB
|
|
* Copyright (C) 2002 Free Software Foundation, Inc.
|
|
* Copyright (C) 2002,2003 Yoshinori K. Okuji <okuji@enbug.org>
|
|
*
|
|
* PUPA is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with PUPA; if not, write to the Free Software
|
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
*/
|
|
|
|
#ifndef PUPA_TERM_HEADER
|
|
#define PUPA_TERM_HEADER 1
|
|
|
|
#include <pupa/err.h>
|
|
#include <pupa/symbol.h>
|
|
#include <pupa/types.h>
|
|
|
|
/* These are used to represent the various color states we use. */
|
|
typedef enum
|
|
{
|
|
/* The color used to display all text that does not use the
|
|
user defined colors below. */
|
|
PUPA_TERM_COLOR_STANDARD,
|
|
/* The user defined colors for normal text. */
|
|
PUPA_TERM_COLOR_NORMAL,
|
|
/* The user defined colors for highlighted text. */
|
|
PUPA_TERM_COLOR_HIGHLIGHT
|
|
}
|
|
pupa_term_color_state;
|
|
|
|
/* Flags for representing the capabilities of a terminal. */
|
|
/* Some notes about the flags:
|
|
- These flags are used by higher-level functions but not terminals
|
|
themselves.
|
|
- If a terminal is dumb, you may assume that only putchar, getkey and
|
|
checkkey are called.
|
|
- Some fancy features (setcolorstate, setcolor and setcursor) can be set
|
|
to NULL. */
|
|
|
|
/* Set when input characters shouldn't be echoed back. */
|
|
#define PUPA_TERM_NO_ECHO (1 << 0)
|
|
/* Set when the editing feature should be disabled. */
|
|
#define PUPA_TERM_NO_EDIT (1 << 1)
|
|
/* Set when the terminal cannot do fancy things. */
|
|
#define PUPA_TERM_DUMB (1 << 2)
|
|
/* Set when the terminal needs to be initialized. */
|
|
#define PUPA_TERM_NEED_INIT (1 << 16)
|
|
|
|
struct pupa_term
|
|
{
|
|
/* The terminal name. */
|
|
const char *name;
|
|
|
|
/* Initialize the terminal. */
|
|
pupa_err_t (*init) (void);
|
|
|
|
/* Clean up the terminal. */
|
|
pupa_err_t (*fini) (void);
|
|
|
|
/* Put a character. C is encoded in Unicode. */
|
|
void (*putchar) (pupa_uint32_t c);
|
|
|
|
/* Check if any input character is available. */
|
|
int (*checkkey) (void);
|
|
|
|
/* Get a character. */
|
|
int (*getkey) (void);
|
|
|
|
/* Get the cursor position. The return value is ((X << 8) | Y). */
|
|
pupa_uint16_t (*getxy) (void);
|
|
|
|
/* Go to the position (X, Y). */
|
|
void (*gotoxy) (pupa_uint8_t x, pupa_uint8_t y);
|
|
|
|
/* Clear the screen. */
|
|
void (*cls) (void);
|
|
|
|
/* Set the current color to be used */
|
|
void (*setcolorstate) (pupa_term_color_state state);
|
|
|
|
/* Set the normal color and the highlight color. The format of each
|
|
color is VGA's. */
|
|
void (*setcolor) (pupa_uint8_t normal_color, pupa_uint8_t highlight_color);
|
|
|
|
/* Turn on/off the cursor. */
|
|
void (*setcursor) (int on);
|
|
|
|
/* The feature flags defined above. */
|
|
pupa_uint32_t flags;
|
|
|
|
/* The next terminal. */
|
|
struct pupa_term *next;
|
|
};
|
|
typedef struct pupa_term *pupa_term_t;
|
|
|
|
void EXPORT_FUNC(pupa_term_register) (pupa_term_t term);
|
|
void EXPORT_FUNC(pupa_term_unregister) (pupa_term_t term);
|
|
void EXPORT_FUNC(pupa_term_iterate) (int (*hook) (pupa_term_t term));
|
|
|
|
pupa_err_t EXPORT_FUNC(pupa_term_set_current) (pupa_term_t term);
|
|
pupa_term_t EXPORT_FUNC(pupa_term_get_current) (void);
|
|
|
|
void EXPORT_FUNC(pupa_putchar) (int c);
|
|
void EXPORT_FUNC(pupa_putcode) (pupa_uint32_t code);
|
|
int EXPORT_FUNC(pupa_getkey) (void);
|
|
int EXPORT_FUNC(pupa_checkkey) (void);
|
|
pupa_uint16_t EXPORT_FUNC(pupa_getxy) (void);
|
|
void EXPORT_FUNC(pupa_gotoxy) (pupa_uint8_t x, pupa_uint8_t y);
|
|
void EXPORT_FUNC(pupa_cls) (void);
|
|
void EXPORT_FUNC(pupa_setcolorstate) (pupa_term_color_state state);
|
|
void EXPORT_FUNC(pupa_setcolor) (pupa_uint8_t normal_color,
|
|
pupa_uint8_t highlight_color);
|
|
int EXPORT_FUNC(pupa_setcursor) (int on);
|
|
|
|
/* For convenience. */
|
|
#define PUPA_TERM_ASCII_CHAR(c) ((c) & 0xff)
|
|
|
|
#endif /* ! PUPA_TERM_HEADER */
|