2003-09-25 Yoshinori K. Okuji <okuji@enbug.org>

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.
This commit is contained in:
okuji 2003-09-25 20:15:53 +00:00
parent 977329f5fa
commit 18d9c7cd53
17 changed files with 1443 additions and 50 deletions

View file

@ -46,6 +46,7 @@ typedef enum
PUPA_ERR_UNKNOWN_OS,
PUPA_ERR_BAD_OS,
PUPA_ERR_NO_KERNEL,
PUPA_ERR_BAD_FONT,
PUPA_ERR_NOT_IMPLEMENTED_YET,
}
pupa_err_t;

30
include/grub/font.h Normal file
View file

@ -0,0 +1,30 @@
/*
* PUPA -- Preliminary Universal Programming Architecture for GRUB
* Copyright (C) 2003 Yoshinori K. Okuji <okuji@enbug.org>
*
* This program 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 this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef PUPA_FONT_HEADER
#define PUPA_FONT_HEADER 1
#include <pupa/types.h>
#define PUPA_FONT_MAGIC "PPF\x7f"
int pupa_font_get_glyph (pupa_uint32_t code,
unsigned char bitmap[32], unsigned *width);
#endif /* ! PUPA_FONT_HEADER */

View file

@ -36,12 +36,13 @@
#ifndef ASM_FILE
#include <pupa/types.h>
#include <pupa/symbol.h>
/* These are global to share code between C and asm. */
extern pupa_uint8_t pupa_console_cur_color;
void pupa_console_putchar (int c);
int pupa_console_checkkey (void);
int pupa_console_getkey (void);
void pupa_console_real_putchar (int c);
int EXPORT_FUNC(pupa_console_checkkey) (void);
int EXPORT_FUNC(pupa_console_getkey) (void);
pupa_uint16_t pupa_console_getxy (void);
void pupa_console_gotoxy (pupa_uint8_t x, pupa_uint8_t y);
void pupa_console_cls (void);

View file

@ -0,0 +1,31 @@
/*
* PUPA -- Preliminary Universal Programming Architecture for GRUB
* Copyright (C) 2003 Yoshinori K. Okuji <okuji@enbug.org>
*
* This program 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 this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef PUPA_VGA_MACHINE_HEADER
#define PUPA_VGA_MACHINE_HEADER 1
#include <pupa/symbol.h>
/* Set the video mode to MODE and return the previous mode. */
unsigned char EXPORT_FUNC(pupa_vga_set_mode) (unsigned char mode);
/* Return a pointer to the ROM font table. */
unsigned char *EXPORT_FUNC(pupa_vga_get_font) (void);
#endif /* ! PUPA_VGA_MACHINE_HEADER */

View file

@ -1,7 +1,7 @@
/*
* PUPA -- Preliminary Universal Programming Architecture for GRUB
* Copyright (C) 2002 Free Software Foundation, Inc.
* Copyright (C) 2002 Yoshinori K. Okuji <okuji@enbug.org>
* 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
@ -21,6 +21,7 @@
#ifndef PUPA_TERM_HEADER
#define PUPA_TERM_HEADER 1
#include <pupa/err.h>
#include <pupa/symbol.h>
#include <pupa/types.h>
@ -59,9 +60,15 @@ 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. */
void (*putchar) (int c);
/* Put a character. C is encoded in Unicode. */
void (*putchar) (pupa_uint32_t c);
/* Check if any input character is available. */
int (*checkkey) (void);
@ -100,10 +107,11 @@ 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));
void EXPORT_FUNC(pupa_term_set_current) (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);