2003-09-25 20:15:53 +00:00
|
|
|
/*
|
2004-04-04 13:46:03 +00:00
|
|
|
* GRUB -- GRand Unified Bootloader
|
2009-01-02 15:26:06 +00:00
|
|
|
* Copyright (C) 2000,2001,2002,2003,2004,2005,2007,2008,2009 Free Software Foundation, Inc.
|
2003-09-25 20:15:53 +00:00
|
|
|
*
|
2007-07-21 23:32:33 +00:00
|
|
|
* GRUB is free software: you can redistribute it and/or modify
|
2003-09-25 20:15:53 +00:00
|
|
|
* it under the terms of the GNU General Public License as published by
|
2007-07-21 23:32:33 +00:00
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
2003-09-25 20:15:53 +00:00
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
2007-07-21 23:32:33 +00:00
|
|
|
* GRUB is distributed in the hope that it will be useful,
|
2003-09-25 20:15:53 +00:00
|
|
|
* 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
|
2007-07-21 23:32:33 +00:00
|
|
|
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
2003-09-25 20:15:53 +00:00
|
|
|
*/
|
|
|
|
|
2009-01-02 15:26:06 +00:00
|
|
|
// TODO: Deprecated and broken. Needs to be converted to Video Driver!
|
|
|
|
|
2004-04-04 13:46:03 +00:00
|
|
|
#include <grub/machine/vga.h>
|
|
|
|
#include <grub/machine/console.h>
|
2007-11-10 18:34:48 +00:00
|
|
|
#include <grub/cpu/io.h>
|
2004-04-04 13:46:03 +00:00
|
|
|
#include <grub/term.h>
|
|
|
|
#include <grub/types.h>
|
|
|
|
#include <grub/dl.h>
|
|
|
|
#include <grub/misc.h>
|
|
|
|
#include <grub/font.h>
|
2003-09-25 20:15:53 +00:00
|
|
|
|
|
|
|
#define DEBUG_VGA 0
|
|
|
|
|
|
|
|
#define VGA_WIDTH 640
|
2004-11-01 16:19:30 +00:00
|
|
|
#define VGA_HEIGHT 350
|
2003-09-25 20:15:53 +00:00
|
|
|
#define CHAR_WIDTH 8
|
|
|
|
#define CHAR_HEIGHT 16
|
|
|
|
#define TEXT_WIDTH (VGA_WIDTH / CHAR_WIDTH)
|
|
|
|
#define TEXT_HEIGHT (VGA_HEIGHT / CHAR_HEIGHT)
|
2008-01-21 15:48:27 +00:00
|
|
|
#define VGA_MEM ((grub_uint8_t *) GRUB_MEMORY_MACHINE_VGA_ADDR)
|
2004-11-01 16:19:30 +00:00
|
|
|
#define PAGE_OFFSET(x) ((x) * (VGA_WIDTH * VGA_HEIGHT / 8))
|
2003-09-25 20:15:53 +00:00
|
|
|
|
|
|
|
#define DEFAULT_FG_COLOR 0xa
|
|
|
|
#define DEFAULT_BG_COLOR 0x0
|
|
|
|
|
|
|
|
struct colored_char
|
|
|
|
{
|
|
|
|
/* An Unicode codepoint. */
|
2004-04-04 13:46:03 +00:00
|
|
|
grub_uint32_t code;
|
2003-09-25 20:15:53 +00:00
|
|
|
|
|
|
|
/* Color indexes. */
|
|
|
|
unsigned char fg_color;
|
|
|
|
unsigned char bg_color;
|
|
|
|
|
|
|
|
/* The width of this character minus one. */
|
|
|
|
unsigned char width;
|
|
|
|
|
|
|
|
/* The column index of this character. */
|
|
|
|
unsigned char index;
|
|
|
|
};
|
|
|
|
|
|
|
|
static unsigned char text_mode;
|
|
|
|
static unsigned xpos, ypos;
|
|
|
|
static int cursor_state;
|
|
|
|
static unsigned char fg_color, bg_color;
|
|
|
|
static struct colored_char text_buf[TEXT_WIDTH * TEXT_HEIGHT];
|
|
|
|
static unsigned char saved_map_mask;
|
2004-11-01 16:19:30 +00:00
|
|
|
static int page = 0;
|
2009-01-02 15:26:06 +00:00
|
|
|
static grub_font_t font = 0;
|
2003-09-25 20:15:53 +00:00
|
|
|
|
|
|
|
#define SEQUENCER_ADDR_PORT 0x3C4
|
|
|
|
#define SEQUENCER_DATA_PORT 0x3C5
|
|
|
|
#define MAP_MASK_REGISTER 0x02
|
|
|
|
|
2004-11-01 16:19:30 +00:00
|
|
|
#define CRTC_ADDR_PORT 0x3D4
|
|
|
|
#define CRTC_DATA_PORT 0x3D5
|
|
|
|
#define START_ADDR_HIGH_REGISTER 0x0C
|
|
|
|
#define START_ADDR_LOW_REGISTER 0x0D
|
|
|
|
|
|
|
|
#define GRAPHICS_ADDR_PORT 0x3CE
|
|
|
|
#define GRAPHICS_DATA_PORT 0x3CF
|
|
|
|
#define READ_MAP_REGISTER 0x04
|
|
|
|
|
|
|
|
#define INPUT_STATUS1_REGISTER 0x3DA
|
|
|
|
#define INPUT_STATUS1_VERTR_BIT 0x08
|
|
|
|
|
|
|
|
static inline void
|
|
|
|
wait_vretrace (void)
|
|
|
|
{
|
|
|
|
/* Wait until there is a vertical retrace. */
|
2007-10-03 20:13:21 +00:00
|
|
|
while (! (grub_inb (INPUT_STATUS1_REGISTER) & INPUT_STATUS1_VERTR_BIT));
|
2004-11-01 16:19:30 +00:00
|
|
|
}
|
|
|
|
|
2003-09-25 20:15:53 +00:00
|
|
|
/* Get Map Mask Register. */
|
|
|
|
static unsigned char
|
|
|
|
get_map_mask (void)
|
|
|
|
{
|
|
|
|
unsigned char old_addr;
|
|
|
|
unsigned char old_data;
|
2009-06-10 21:04:23 +00:00
|
|
|
|
2007-10-03 20:13:21 +00:00
|
|
|
old_addr = grub_inb (SEQUENCER_ADDR_PORT);
|
2007-11-10 18:34:48 +00:00
|
|
|
grub_outb (MAP_MASK_REGISTER, SEQUENCER_ADDR_PORT);
|
2009-06-10 21:04:23 +00:00
|
|
|
|
2007-10-03 20:13:21 +00:00
|
|
|
old_data = grub_inb (SEQUENCER_DATA_PORT);
|
2009-06-10 21:04:23 +00:00
|
|
|
|
2007-11-10 18:34:48 +00:00
|
|
|
grub_outb (old_addr, SEQUENCER_ADDR_PORT);
|
2003-09-25 20:15:53 +00:00
|
|
|
|
|
|
|
return old_data;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Set Map Mask Register. */
|
|
|
|
static void
|
|
|
|
set_map_mask (unsigned char mask)
|
|
|
|
{
|
|
|
|
unsigned char old_addr;
|
2009-06-10 21:04:23 +00:00
|
|
|
|
2007-10-03 20:13:21 +00:00
|
|
|
old_addr = grub_inb (SEQUENCER_ADDR_PORT);
|
2007-11-10 18:34:48 +00:00
|
|
|
grub_outb (MAP_MASK_REGISTER, SEQUENCER_ADDR_PORT);
|
2009-06-10 21:04:23 +00:00
|
|
|
|
2007-11-10 18:34:48 +00:00
|
|
|
grub_outb (mask, SEQUENCER_DATA_PORT);
|
2009-06-10 21:04:23 +00:00
|
|
|
|
2007-11-10 18:34:48 +00:00
|
|
|
grub_outb (old_addr, SEQUENCER_ADDR_PORT);
|
2003-09-25 20:15:53 +00:00
|
|
|
}
|
|
|
|
|
2004-11-01 16:19:30 +00:00
|
|
|
/* Set Read Map Register. */
|
|
|
|
static void
|
|
|
|
set_read_map (unsigned char map)
|
|
|
|
{
|
|
|
|
unsigned char old_addr;
|
2009-06-10 21:04:23 +00:00
|
|
|
|
2007-10-03 20:13:21 +00:00
|
|
|
old_addr = grub_inb (GRAPHICS_ADDR_PORT);
|
2004-11-01 16:19:30 +00:00
|
|
|
|
2007-11-10 18:34:48 +00:00
|
|
|
grub_outb (READ_MAP_REGISTER, GRAPHICS_ADDR_PORT);
|
|
|
|
grub_outb (map, GRAPHICS_DATA_PORT);
|
2004-11-01 16:19:30 +00:00
|
|
|
|
2007-11-10 18:34:48 +00:00
|
|
|
grub_outb (old_addr, GRAPHICS_ADDR_PORT);
|
2004-11-01 16:19:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Set start address. */
|
|
|
|
static void
|
|
|
|
set_start_address (unsigned int start)
|
|
|
|
{
|
|
|
|
unsigned char old_addr;
|
2009-06-10 21:04:23 +00:00
|
|
|
|
2007-10-03 20:13:21 +00:00
|
|
|
old_addr = grub_inb (CRTC_ADDR_PORT);
|
2009-06-10 21:04:23 +00:00
|
|
|
|
2007-11-10 18:34:48 +00:00
|
|
|
grub_outb (START_ADDR_LOW_REGISTER, CRTC_ADDR_PORT);
|
|
|
|
grub_outb (start & 0xFF, CRTC_DATA_PORT);
|
2009-06-10 21:04:23 +00:00
|
|
|
|
2007-11-10 18:34:48 +00:00
|
|
|
grub_outb (START_ADDR_HIGH_REGISTER, CRTC_ADDR_PORT);
|
|
|
|
grub_outb (start >> 8, CRTC_DATA_PORT);
|
2004-11-01 16:19:30 +00:00
|
|
|
|
2007-11-10 18:34:48 +00:00
|
|
|
grub_outb (old_addr, CRTC_ADDR_PORT);
|
2004-11-01 16:19:30 +00:00
|
|
|
}
|
|
|
|
|
2004-04-04 13:46:03 +00:00
|
|
|
static grub_err_t
|
2010-05-07 00:30:44 +00:00
|
|
|
grub_vga_mod_init (struct grub_term_output *term __attribute__ ((unused)))
|
2003-09-25 20:15:53 +00:00
|
|
|
{
|
2004-11-01 16:19:30 +00:00
|
|
|
text_mode = grub_vga_set_mode (0x10);
|
2003-09-25 20:15:53 +00:00
|
|
|
cursor_state = 1;
|
|
|
|
fg_color = DEFAULT_FG_COLOR;
|
|
|
|
bg_color = DEFAULT_BG_COLOR;
|
|
|
|
saved_map_mask = get_map_mask ();
|
|
|
|
set_map_mask (0x0f);
|
2004-11-01 16:19:30 +00:00
|
|
|
set_start_address (PAGE_OFFSET (page));
|
2009-01-02 15:26:06 +00:00
|
|
|
font = grub_font_get (""); /* Choose any font, for now. */
|
|
|
|
if (!font)
|
2009-12-24 22:53:05 +00:00
|
|
|
return grub_error (GRUB_ERR_BAD_FONT, "no font loaded");
|
2009-06-10 21:04:23 +00:00
|
|
|
|
2004-04-04 13:46:03 +00:00
|
|
|
return GRUB_ERR_NONE;
|
2003-09-25 20:15:53 +00:00
|
|
|
}
|
|
|
|
|
2004-04-04 13:46:03 +00:00
|
|
|
static grub_err_t
|
2010-05-07 00:30:44 +00:00
|
|
|
grub_vga_mod_fini (struct grub_term_output *term __attribute__ ((unused)))
|
2003-09-25 20:15:53 +00:00
|
|
|
{
|
|
|
|
set_map_mask (saved_map_mask);
|
2004-04-04 13:46:03 +00:00
|
|
|
grub_vga_set_mode (text_mode);
|
|
|
|
return GRUB_ERR_NONE;
|
2003-09-25 20:15:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
check_vga_mem (void *p)
|
|
|
|
{
|
2004-11-01 16:19:30 +00:00
|
|
|
return (p >= (void *) (VGA_MEM + PAGE_OFFSET (page))
|
|
|
|
&& p <= (void *) (VGA_MEM + PAGE_OFFSET (page)
|
|
|
|
+ VGA_WIDTH * VGA_HEIGHT / 8));
|
2003-09-25 20:15:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
write_char (void)
|
|
|
|
{
|
|
|
|
struct colored_char *p = text_buf + xpos + ypos * TEXT_WIDTH;
|
2009-01-02 15:26:06 +00:00
|
|
|
struct grub_font_glyph *glyph;
|
2004-11-01 16:19:30 +00:00
|
|
|
unsigned char *mem_base;
|
2003-09-25 20:15:53 +00:00
|
|
|
unsigned plane;
|
|
|
|
|
2009-06-10 21:04:23 +00:00
|
|
|
mem_base = (VGA_MEM + xpos +
|
2004-11-01 16:19:30 +00:00
|
|
|
ypos * CHAR_HEIGHT * TEXT_WIDTH + PAGE_OFFSET (page)) - p->index;
|
2003-09-25 20:15:53 +00:00
|
|
|
p -= p->index;
|
|
|
|
|
2007-11-10 18:34:48 +00:00
|
|
|
/* Get glyph for character. */
|
2009-01-02 15:26:06 +00:00
|
|
|
glyph = grub_font_get_glyph (font, p->code);
|
2009-06-10 21:04:23 +00:00
|
|
|
|
2003-09-25 20:15:53 +00:00
|
|
|
for (plane = 0x01; plane <= 0x08; plane <<= 1)
|
|
|
|
{
|
|
|
|
unsigned y;
|
|
|
|
unsigned offset;
|
|
|
|
unsigned char *mem;
|
|
|
|
|
|
|
|
set_map_mask (plane);
|
|
|
|
|
|
|
|
for (y = 0, offset = 0, mem = mem_base;
|
|
|
|
y < CHAR_HEIGHT;
|
|
|
|
y++, mem += TEXT_WIDTH)
|
|
|
|
{
|
2009-01-02 15:26:06 +00:00
|
|
|
/* TODO Re-implement glyph drawing for vga module. */
|
|
|
|
#if 0
|
2003-09-25 20:15:53 +00:00
|
|
|
unsigned i;
|
|
|
|
|
2009-01-02 15:26:06 +00:00
|
|
|
unsigned char_width = 1; /* TODO Figure out wide characters. */
|
|
|
|
for (i = 0; i < char_width && offset < 32; i++)
|
2003-09-25 20:15:53 +00:00
|
|
|
{
|
|
|
|
unsigned char fg_mask, bg_mask;
|
2009-06-10 21:04:23 +00:00
|
|
|
|
2009-01-02 15:26:06 +00:00
|
|
|
fg_mask = (p->fg_color & plane) ? glyph->bitmap[offset] : 0;
|
|
|
|
bg_mask = (p->bg_color & plane) ? ~(glyph->bitmap[offset]) : 0;
|
2003-09-25 20:15:53 +00:00
|
|
|
offset++;
|
|
|
|
|
|
|
|
if (check_vga_mem (mem + i))
|
|
|
|
mem[i] = (fg_mask | bg_mask);
|
|
|
|
}
|
2009-06-10 21:04:23 +00:00
|
|
|
#endif /* 0 */
|
2003-09-25 20:15:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
set_map_mask (0x0f);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
write_cursor (void)
|
|
|
|
{
|
2004-11-01 16:19:30 +00:00
|
|
|
unsigned char *mem = (VGA_MEM + PAGE_OFFSET (page) + xpos
|
2003-09-25 20:15:53 +00:00
|
|
|
+ (ypos * CHAR_HEIGHT + CHAR_HEIGHT - 3) * TEXT_WIDTH);
|
|
|
|
if (check_vga_mem (mem))
|
|
|
|
*mem = 0xff;
|
2009-06-10 21:04:23 +00:00
|
|
|
|
2003-09-25 20:15:53 +00:00
|
|
|
mem += TEXT_WIDTH;
|
|
|
|
if (check_vga_mem (mem))
|
|
|
|
*mem = 0xff;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
scroll_up (void)
|
|
|
|
{
|
|
|
|
unsigned i;
|
|
|
|
unsigned plane;
|
2009-06-10 21:04:23 +00:00
|
|
|
|
2004-11-01 16:19:30 +00:00
|
|
|
/* Do all the work in the other page. */
|
2004-04-04 13:46:03 +00:00
|
|
|
grub_memmove (text_buf, text_buf + TEXT_WIDTH,
|
2003-09-25 20:15:53 +00:00
|
|
|
sizeof (struct colored_char) * TEXT_WIDTH * (TEXT_HEIGHT - 1));
|
2009-06-10 21:04:23 +00:00
|
|
|
|
2003-09-25 20:15:53 +00:00
|
|
|
for (i = TEXT_WIDTH * (TEXT_HEIGHT - 1); i < TEXT_WIDTH * TEXT_HEIGHT; i++)
|
|
|
|
{
|
|
|
|
text_buf[i].code = ' ';
|
|
|
|
text_buf[i].fg_color = 0;
|
|
|
|
text_buf[i].bg_color = 0;
|
|
|
|
text_buf[i].width = 0;
|
|
|
|
text_buf[i].index = 0;
|
|
|
|
}
|
|
|
|
|
2004-11-01 16:19:30 +00:00
|
|
|
for (plane = 1; plane <= 4; plane++)
|
2003-09-25 20:15:53 +00:00
|
|
|
{
|
2004-11-01 16:19:30 +00:00
|
|
|
set_read_map (plane);
|
|
|
|
set_map_mask (1 << plane);
|
|
|
|
grub_memmove (VGA_MEM + PAGE_OFFSET (1 - page), VGA_MEM
|
|
|
|
+ PAGE_OFFSET (page) + VGA_WIDTH * CHAR_HEIGHT / 8,
|
2003-09-25 20:15:53 +00:00
|
|
|
VGA_WIDTH * (VGA_HEIGHT - CHAR_HEIGHT) / 8);
|
|
|
|
}
|
|
|
|
|
|
|
|
set_map_mask (0x0f);
|
2004-11-01 16:19:30 +00:00
|
|
|
grub_memset (VGA_MEM + PAGE_OFFSET (1 - page)
|
|
|
|
+ VGA_WIDTH * (VGA_HEIGHT - CHAR_HEIGHT) / 8, 0,
|
2003-09-25 20:15:53 +00:00
|
|
|
VGA_WIDTH * CHAR_HEIGHT / 8);
|
2009-06-10 21:04:23 +00:00
|
|
|
|
2004-11-01 16:19:30 +00:00
|
|
|
/* Activate the other page. */
|
|
|
|
page = 1 - page;
|
|
|
|
wait_vretrace ();
|
|
|
|
set_start_address (PAGE_OFFSET (page));
|
2003-09-25 20:15:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2010-05-07 00:30:44 +00:00
|
|
|
grub_vga_putchar (struct grub_term_output *term __attribute__ ((unused)),
|
|
|
|
const struct grub_unicode_glyph *c)
|
2003-09-25 20:15:53 +00:00
|
|
|
{
|
2004-03-14 Marco Gerards <metgerards@student.han.nl>
* commands/boot.c: New file.
* commands/cat.c: Likewise.
* commands/cmp.c: Likewise.
* commands/ls.c: Likewise.
* commands/terminal.c: Likewise.
* normal/command.c: Include <pupa/env.h> and <pupa/dl.h>.
(pupa_register_command): Changed interface to match the new
argument parser.
(pupa_command_execute): Changed (almost rewritten) so it uses
pupa_split_command. Added support for setting variables using the
syntax `foo=bar'.
(rescue_command): Changed to work with the new argument parser.
(terminal_command): Moved from here to commands/terminal.c.
(set_command): New function.
(unset_command): New function.
(insmod_command): New function.
(rmmod_command): New function.
(lsmod_command): New function.
(pupa_command_init): Don't initialize the command terminal
anymore. Initialize the commands set, unset, insmod, rmmod and
lsmod.
* conf/i386-pc.rmk (kernel_img_SOURCES): Add kern/env.c.
(kernel_img_HEADERS): Add arg.h and env.h.
(pupa_mkimage_LDFLAGS): Add kern/env.c.
(pupa_emu_SOURCES): Add kern/env.c, commands/ls.c,
commands/terminal.c commands/boot.c commands/cmp.c commands/cat.c,
normal/arg.c.
(pkgdata_MODULES): Add ls.mod, boot.mod, cmp.mod, cat.mod and
terminal.mod.
(normal_mod_SOURCES): Add normal/arg.c and normal/arg.c.
(boot_mod_SOURCES): New variable.
(terminal_mod_SOURCES): Likewise.
(ls_mod_SOURCES): Likewise.
(cmp_mod_SOURCES): Likewise.
(cat_mod_SOURCES): Likewise.
* normal/arg.c: New file.
* kern/env.c: Likewise.
* include/pupa/arg.h: Likewise.
* include/pupa/env.h: Likewise.
* font/manager.c (font_command): Changed to match argument parsing
interface changes.
(PUPA_MOD_INIT): Likewise.
* hello/hello.c (pupa_cmd_hello): Likewise.
(PUPA_MOD_INIT): Likewise.
* include/pupa/disk.h: Include <pupa/device.h>.
(pupa_print_partinfo): New prototype.
* include/pupa/dl.h (pupa_dl_set_prefix): Prototype removed.
(pupa_dl_get_prefix): Likewise.
* include/pupa/misc.h: Include <pupa/err.h>.
(pupa_isgraph): New prototype.
(pupa_isdigit): Likewise.
(pupa_split_cmdline): Likewise.
* include/pupa/normal.h: Include <pupa/arg.h>.
(pupa_command): Changed the prototype of the member `func' to
match the argument parsing interface. Added member `options'.
(pupa_register_command): Updated to match function.
(pupa_arg_parse): New prototype.
(pupa_hello_init) [PUPA_UTIL]: New prototype.
(pupa_hello_fini) [PUPA_UTIL]: Likewise.
(pupa_ls_init) [PUPA_UTIL]: Likewise.
(pupa_ls_fini) [PUPA_UTIL]: Likewise.
(pupa_cat_init) [PUPA_UTIL]: Likewise.
(pupa_cat_fini) [PUPA_UTIL]: Likewise.
(pupa_boot_init) [PUPA_UTIL]: Likewise.
(pupa_boot_fini) [PUPA_UTIL]: Likewise.
(pupa_cmp_init) [PUPA_UTIL]: Likewise.
(pupa_cmp_fini) [PUPA_UTIL]: Likewise.
(pupa_terminal_init) [PUPA_UTIL]: Likewise.
(pupa_terminal_fini) [PUPA_UTIL]: Likewise.
* kern/disk.c: Include <pupa/file.h>.
(pupa_print_partinfo): New function.
* kern/dl.c: Include <pupa/env.h>.
(pupa_dl_dir): Variable removed.
(pupa_dl_load): Use the environment variable `prefix' instead of
the variable pupa_dl_dir.
(pupa_dl_set_prefix): Function removed.
(pupa_dl_get_prefix): Likewise.
* kern/i386/pc/init.c: Include <pupa/env.h>.
(pupa_machine_init): Use the environment variable `prefix' instead of
using pupa_dl_set_prefix to set the prefix.
* kern/main.c: Include <pupa/env.h>.
(pupa_set_root_dev): Use the environment variable `prefix' instead of
using pupa_dl_get_prefix to get the prefix.
* kern/misc.c: Include <pupa/env.h>.
(pupa_isdigit): New function.
(pupa_isgraph): Likewise.
(pupa_ftoa): Likewise.
(pupa_vsprintf): Added support for printing values of the type
`double'. Make it possible to format variable output when using
formatting like `%1.2%f'.
(pupa_split_cmdline): New function.
* kern/rescue.c: Include <pupa/env.h>.
(next_word): Removed function.
(pupa_rescue_cmd_prefix): Likewise.
(pupa_rescue_cmd_set): New function.
(pupa_rescue_cmd_unset): New function.
(pupa_enter_rescue_mode): Use the `pupa_split_cmdline' function to
split the command line instead of splitting it here. Added
support for setting variables using the syntax `foo=bar'. Don't
initialize the prefix command anymore. Initialized the set and
unset commands.
* normal/cmdline.c: Include <pupa/env.h>.
(pupa_tab_complete): Added prototypes for print_simple_completion,
print_partition_completion, add_completion, iterate_commands,
iterate_dev, iterate_part and iterate_dir. Moved code to print
partition information from here to kern/disk.c.
(pupa_cmdline_run): Don't check if the funtion exists anymore.
* normal/main.c: Include <pupa/env.h>.
(pupa_rescue_cmd_normal): Use the environment variable `prefix'
instead of using pupa_dl_get_prefix to get the prefix.
* term/i386/pc/vga.c: Include <pupa/arg.h>.
(check_vga_mem): Cast pointers to `void *' to silence a gcc
warning.
(pupa_vga_putchar) [! DEBUG_VGA]: Removed for this case.
(pupa_vga_setcolor): Declare unused variables with `__attribute__
((unused))' to silence a gcc warning.
(pupa_vga_setcolor): Likewise.
(debug_command): Changed to match argument parsing
interface changes.
* util/pupa-emu.c: Include <pupa/env.h>.
(options): Added 0's for unused fields to silence a gcc warning.
(argp): Likewise.
(main): Use the environment variable `prefix' instead of using
pupa_dl_set_prefix to set the prefix. Initialize the commands ls,
boot, cmp, cat and terminal. Finish the commands boot, cmp, cat
and terminal.
* util/i386/pc/getroot.c: Include <pupa/i386/pc/util/biosdisk.h>.
* util/misc.c: Include <malloc.h>.
(pupa_malloc): Rewritten so errors are correctly reported.
(pupa_realloc): Likewise.
(pupa_memalign): Likewise.
(pupa_mm_init_region): Declare unused variables with
`__attribute__ ((unused))' to silence a gcc warning.
* normal/i386/setjmp.S: Remove tab at the end of the file to
silence a gcc warning.
* loader/i386/pc/linux.c (pupa_rescue_cmd_initrd): Declare unused
variables with `__attribute__ ((unused))' to silence a gcc
warning.
* loader/i386/pc/multiboot.c (pupa_multiboot_unload): Make the
local variable i unsigned to silence a gcc warning.
* kern/term.c: Include <pupa/misc.h>.
(pupa_more_lines): New variable.
(pupa_more): Likewise.
(pupa_putcode): When the pager is active pause at the end of every
screen.
(pupa_set_more): New function.
* include/pupa/term.h (pupa_set_more): New prototype.
2004-03-13 13:59:25 +00:00
|
|
|
#if DEBUG_VGA
|
2003-09-25 20:15:53 +00:00
|
|
|
static int show = 1;
|
2004-03-14 Marco Gerards <metgerards@student.han.nl>
* commands/boot.c: New file.
* commands/cat.c: Likewise.
* commands/cmp.c: Likewise.
* commands/ls.c: Likewise.
* commands/terminal.c: Likewise.
* normal/command.c: Include <pupa/env.h> and <pupa/dl.h>.
(pupa_register_command): Changed interface to match the new
argument parser.
(pupa_command_execute): Changed (almost rewritten) so it uses
pupa_split_command. Added support for setting variables using the
syntax `foo=bar'.
(rescue_command): Changed to work with the new argument parser.
(terminal_command): Moved from here to commands/terminal.c.
(set_command): New function.
(unset_command): New function.
(insmod_command): New function.
(rmmod_command): New function.
(lsmod_command): New function.
(pupa_command_init): Don't initialize the command terminal
anymore. Initialize the commands set, unset, insmod, rmmod and
lsmod.
* conf/i386-pc.rmk (kernel_img_SOURCES): Add kern/env.c.
(kernel_img_HEADERS): Add arg.h and env.h.
(pupa_mkimage_LDFLAGS): Add kern/env.c.
(pupa_emu_SOURCES): Add kern/env.c, commands/ls.c,
commands/terminal.c commands/boot.c commands/cmp.c commands/cat.c,
normal/arg.c.
(pkgdata_MODULES): Add ls.mod, boot.mod, cmp.mod, cat.mod and
terminal.mod.
(normal_mod_SOURCES): Add normal/arg.c and normal/arg.c.
(boot_mod_SOURCES): New variable.
(terminal_mod_SOURCES): Likewise.
(ls_mod_SOURCES): Likewise.
(cmp_mod_SOURCES): Likewise.
(cat_mod_SOURCES): Likewise.
* normal/arg.c: New file.
* kern/env.c: Likewise.
* include/pupa/arg.h: Likewise.
* include/pupa/env.h: Likewise.
* font/manager.c (font_command): Changed to match argument parsing
interface changes.
(PUPA_MOD_INIT): Likewise.
* hello/hello.c (pupa_cmd_hello): Likewise.
(PUPA_MOD_INIT): Likewise.
* include/pupa/disk.h: Include <pupa/device.h>.
(pupa_print_partinfo): New prototype.
* include/pupa/dl.h (pupa_dl_set_prefix): Prototype removed.
(pupa_dl_get_prefix): Likewise.
* include/pupa/misc.h: Include <pupa/err.h>.
(pupa_isgraph): New prototype.
(pupa_isdigit): Likewise.
(pupa_split_cmdline): Likewise.
* include/pupa/normal.h: Include <pupa/arg.h>.
(pupa_command): Changed the prototype of the member `func' to
match the argument parsing interface. Added member `options'.
(pupa_register_command): Updated to match function.
(pupa_arg_parse): New prototype.
(pupa_hello_init) [PUPA_UTIL]: New prototype.
(pupa_hello_fini) [PUPA_UTIL]: Likewise.
(pupa_ls_init) [PUPA_UTIL]: Likewise.
(pupa_ls_fini) [PUPA_UTIL]: Likewise.
(pupa_cat_init) [PUPA_UTIL]: Likewise.
(pupa_cat_fini) [PUPA_UTIL]: Likewise.
(pupa_boot_init) [PUPA_UTIL]: Likewise.
(pupa_boot_fini) [PUPA_UTIL]: Likewise.
(pupa_cmp_init) [PUPA_UTIL]: Likewise.
(pupa_cmp_fini) [PUPA_UTIL]: Likewise.
(pupa_terminal_init) [PUPA_UTIL]: Likewise.
(pupa_terminal_fini) [PUPA_UTIL]: Likewise.
* kern/disk.c: Include <pupa/file.h>.
(pupa_print_partinfo): New function.
* kern/dl.c: Include <pupa/env.h>.
(pupa_dl_dir): Variable removed.
(pupa_dl_load): Use the environment variable `prefix' instead of
the variable pupa_dl_dir.
(pupa_dl_set_prefix): Function removed.
(pupa_dl_get_prefix): Likewise.
* kern/i386/pc/init.c: Include <pupa/env.h>.
(pupa_machine_init): Use the environment variable `prefix' instead of
using pupa_dl_set_prefix to set the prefix.
* kern/main.c: Include <pupa/env.h>.
(pupa_set_root_dev): Use the environment variable `prefix' instead of
using pupa_dl_get_prefix to get the prefix.
* kern/misc.c: Include <pupa/env.h>.
(pupa_isdigit): New function.
(pupa_isgraph): Likewise.
(pupa_ftoa): Likewise.
(pupa_vsprintf): Added support for printing values of the type
`double'. Make it possible to format variable output when using
formatting like `%1.2%f'.
(pupa_split_cmdline): New function.
* kern/rescue.c: Include <pupa/env.h>.
(next_word): Removed function.
(pupa_rescue_cmd_prefix): Likewise.
(pupa_rescue_cmd_set): New function.
(pupa_rescue_cmd_unset): New function.
(pupa_enter_rescue_mode): Use the `pupa_split_cmdline' function to
split the command line instead of splitting it here. Added
support for setting variables using the syntax `foo=bar'. Don't
initialize the prefix command anymore. Initialized the set and
unset commands.
* normal/cmdline.c: Include <pupa/env.h>.
(pupa_tab_complete): Added prototypes for print_simple_completion,
print_partition_completion, add_completion, iterate_commands,
iterate_dev, iterate_part and iterate_dir. Moved code to print
partition information from here to kern/disk.c.
(pupa_cmdline_run): Don't check if the funtion exists anymore.
* normal/main.c: Include <pupa/env.h>.
(pupa_rescue_cmd_normal): Use the environment variable `prefix'
instead of using pupa_dl_get_prefix to get the prefix.
* term/i386/pc/vga.c: Include <pupa/arg.h>.
(check_vga_mem): Cast pointers to `void *' to silence a gcc
warning.
(pupa_vga_putchar) [! DEBUG_VGA]: Removed for this case.
(pupa_vga_setcolor): Declare unused variables with `__attribute__
((unused))' to silence a gcc warning.
(pupa_vga_setcolor): Likewise.
(debug_command): Changed to match argument parsing
interface changes.
* util/pupa-emu.c: Include <pupa/env.h>.
(options): Added 0's for unused fields to silence a gcc warning.
(argp): Likewise.
(main): Use the environment variable `prefix' instead of using
pupa_dl_set_prefix to set the prefix. Initialize the commands ls,
boot, cmp, cat and terminal. Finish the commands boot, cmp, cat
and terminal.
* util/i386/pc/getroot.c: Include <pupa/i386/pc/util/biosdisk.h>.
* util/misc.c: Include <malloc.h>.
(pupa_malloc): Rewritten so errors are correctly reported.
(pupa_realloc): Likewise.
(pupa_memalign): Likewise.
(pupa_mm_init_region): Declare unused variables with
`__attribute__ ((unused))' to silence a gcc warning.
* normal/i386/setjmp.S: Remove tab at the end of the file to
silence a gcc warning.
* loader/i386/pc/linux.c (pupa_rescue_cmd_initrd): Declare unused
variables with `__attribute__ ((unused))' to silence a gcc
warning.
* loader/i386/pc/multiboot.c (pupa_multiboot_unload): Make the
local variable i unsigned to silence a gcc warning.
* kern/term.c: Include <pupa/misc.h>.
(pupa_more_lines): New variable.
(pupa_more): Likewise.
(pupa_putcode): When the pager is active pause at the end of every
screen.
(pupa_set_more): New function.
* include/pupa/term.h (pupa_set_more): New prototype.
2004-03-13 13:59:25 +00:00
|
|
|
#endif
|
2009-06-10 21:04:23 +00:00
|
|
|
|
2010-03-15 20:14:11 +00:00
|
|
|
if (c->base == '\a')
|
2003-09-25 20:15:53 +00:00
|
|
|
/* FIXME */
|
|
|
|
return;
|
|
|
|
|
2010-03-15 20:14:11 +00:00
|
|
|
if (c->base == '\b' || c->base == '\n' || c->base == '\r')
|
2003-09-25 20:15:53 +00:00
|
|
|
{
|
|
|
|
/* Erase current cursor, if any. */
|
|
|
|
if (cursor_state)
|
|
|
|
write_char ();
|
2009-06-10 21:04:23 +00:00
|
|
|
|
2010-03-15 20:14:11 +00:00
|
|
|
switch (c->base)
|
2003-09-25 20:15:53 +00:00
|
|
|
{
|
|
|
|
case '\b':
|
|
|
|
if (xpos > 0)
|
|
|
|
xpos--;
|
|
|
|
break;
|
2009-06-10 21:04:23 +00:00
|
|
|
|
2003-09-25 20:15:53 +00:00
|
|
|
case '\n':
|
2004-11-01 16:19:30 +00:00
|
|
|
if (ypos >= TEXT_HEIGHT - 1)
|
2003-09-25 20:15:53 +00:00
|
|
|
scroll_up ();
|
|
|
|
else
|
|
|
|
ypos++;
|
|
|
|
break;
|
2009-06-10 21:04:23 +00:00
|
|
|
|
2003-09-25 20:15:53 +00:00
|
|
|
case '\r':
|
|
|
|
xpos = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (cursor_state)
|
|
|
|
write_cursor ();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-01-02 15:26:06 +00:00
|
|
|
struct grub_font_glyph *glyph;
|
2003-09-25 20:15:53 +00:00
|
|
|
struct colored_char *p;
|
2009-01-02 15:26:06 +00:00
|
|
|
unsigned char_width = 1;
|
2009-06-10 21:04:23 +00:00
|
|
|
|
2010-03-15 20:14:11 +00:00
|
|
|
glyph = grub_font_get_glyph(font, c->base);
|
2003-09-25 20:15:53 +00:00
|
|
|
|
2009-01-02 15:26:06 +00:00
|
|
|
if (xpos + char_width > TEXT_WIDTH)
|
2010-03-15 20:14:11 +00:00
|
|
|
{
|
|
|
|
xpos = 0;
|
|
|
|
if (ypos >= TEXT_HEIGHT - 1)
|
|
|
|
scroll_up ();
|
|
|
|
else
|
|
|
|
ypos++;
|
|
|
|
}
|
2003-09-25 20:15:53 +00:00
|
|
|
|
|
|
|
p = text_buf + xpos + ypos * TEXT_WIDTH;
|
2010-03-15 20:14:11 +00:00
|
|
|
p->code = c->base;
|
2003-09-25 20:15:53 +00:00
|
|
|
p->fg_color = fg_color;
|
|
|
|
p->bg_color = bg_color;
|
2009-01-02 15:26:06 +00:00
|
|
|
p->width = char_width - 1;
|
2003-09-25 20:15:53 +00:00
|
|
|
p->index = 0;
|
|
|
|
|
2009-01-02 15:26:06 +00:00
|
|
|
if (char_width > 1)
|
2003-09-25 20:15:53 +00:00
|
|
|
{
|
|
|
|
unsigned i;
|
|
|
|
|
2009-01-02 15:26:06 +00:00
|
|
|
for (i = 1; i < char_width; i++)
|
2003-09-25 20:15:53 +00:00
|
|
|
{
|
|
|
|
p[i].code = ' ';
|
2009-01-02 15:26:06 +00:00
|
|
|
p[i].width = char_width - 1;
|
2003-09-25 20:15:53 +00:00
|
|
|
p[i].index = i;
|
|
|
|
}
|
|
|
|
}
|
2009-06-10 21:04:23 +00:00
|
|
|
|
2003-09-25 20:15:53 +00:00
|
|
|
write_char ();
|
2009-06-10 21:04:23 +00:00
|
|
|
|
2009-01-02 15:26:06 +00:00
|
|
|
xpos += char_width;
|
2003-09-25 20:15:53 +00:00
|
|
|
if (xpos >= TEXT_WIDTH)
|
|
|
|
{
|
|
|
|
xpos = 0;
|
2009-06-10 21:04:23 +00:00
|
|
|
|
2004-11-01 16:19:30 +00:00
|
|
|
if (ypos >= TEXT_HEIGHT - 1)
|
2003-09-25 20:15:53 +00:00
|
|
|
scroll_up ();
|
|
|
|
else
|
|
|
|
ypos++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (cursor_state)
|
|
|
|
write_cursor ();
|
|
|
|
}
|
|
|
|
|
|
|
|
#if DEBUG_VGA
|
|
|
|
if (show)
|
|
|
|
{
|
2004-04-04 13:46:03 +00:00
|
|
|
grub_uint16_t pos = grub_getxy ();
|
2003-09-25 20:15:53 +00:00
|
|
|
|
|
|
|
show = 0;
|
2004-04-04 13:46:03 +00:00
|
|
|
grub_gotoxy (0, 0);
|
|
|
|
grub_printf ("[%u:%u]", (unsigned) (pos >> 8), (unsigned) (pos & 0xff));
|
|
|
|
grub_gotoxy (pos >> 8, pos & 0xff);
|
2003-09-25 20:15:53 +00:00
|
|
|
show = 1;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2005-08-20 05:26:51 +00:00
|
|
|
static grub_ssize_t
|
2010-05-07 00:30:44 +00:00
|
|
|
grub_vga_getcharwidth (struct grub_term_output *term __attribute__ ((unused)),
|
|
|
|
const struct grub_unicode_glyph *c)
|
2005-08-20 05:26:51 +00:00
|
|
|
{
|
2009-01-02 15:26:06 +00:00
|
|
|
#if 0
|
2007-11-10 18:34:48 +00:00
|
|
|
struct grub_font_glyph glyph;
|
2009-06-10 21:04:23 +00:00
|
|
|
|
2010-03-15 20:14:11 +00:00
|
|
|
glyph = grub_font_get_glyph (c->base);
|
2009-06-10 21:04:23 +00:00
|
|
|
|
2007-11-10 18:34:48 +00:00
|
|
|
return glyph.char_width;
|
2009-01-02 15:26:06 +00:00
|
|
|
#else
|
|
|
|
(void) c; /* Prevent warning. */
|
|
|
|
return 1; /* TODO Fix wide characters? */
|
|
|
|
#endif
|
2005-08-20 05:26:51 +00:00
|
|
|
}
|
|
|
|
|
2005-08-04 18:10:51 +00:00
|
|
|
static grub_uint16_t
|
2010-05-07 00:30:44 +00:00
|
|
|
grub_vga_getwh (struct grub_term_output *term __attribute__ ((unused)))
|
2005-08-04 18:10:51 +00:00
|
|
|
{
|
|
|
|
return (TEXT_WIDTH << 8) | TEXT_HEIGHT;
|
|
|
|
}
|
|
|
|
|
2004-04-04 13:46:03 +00:00
|
|
|
static grub_uint16_t
|
2010-05-07 00:30:44 +00:00
|
|
|
grub_vga_getxy (struct grub_term_output *term __attribute__ ((unused)))
|
2004-03-14 17:48:25 +00:00
|
|
|
{
|
|
|
|
return ((xpos << 8) | ypos);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2010-05-07 00:30:44 +00:00
|
|
|
grub_vga_gotoxy (struct grub_term_output *term __attribute__ ((unused)),
|
|
|
|
grub_uint8_t x, grub_uint8_t y)
|
2004-03-14 17:48:25 +00:00
|
|
|
{
|
|
|
|
if (x >= TEXT_WIDTH || y >= TEXT_HEIGHT)
|
|
|
|
{
|
2004-04-04 13:46:03 +00:00
|
|
|
grub_error (GRUB_ERR_OUT_OF_RANGE, "invalid point (%u,%u)",
|
2004-03-14 17:48:25 +00:00
|
|
|
(unsigned) x, (unsigned) y);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (cursor_state)
|
|
|
|
write_char ();
|
|
|
|
|
|
|
|
xpos = x;
|
|
|
|
ypos = y;
|
|
|
|
|
|
|
|
if (cursor_state)
|
|
|
|
write_cursor ();
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2010-05-07 00:30:44 +00:00
|
|
|
grub_vga_cls (struct grub_term_output *term __attribute__ ((unused)))
|
2004-03-14 17:48:25 +00:00
|
|
|
{
|
|
|
|
unsigned i;
|
|
|
|
|
2004-11-01 16:19:30 +00:00
|
|
|
wait_vretrace ();
|
2004-03-14 17:48:25 +00:00
|
|
|
for (i = 0; i < TEXT_WIDTH * TEXT_HEIGHT; i++)
|
|
|
|
{
|
|
|
|
text_buf[i].code = ' ';
|
|
|
|
text_buf[i].fg_color = 0;
|
|
|
|
text_buf[i].bg_color = 0;
|
|
|
|
text_buf[i].width = 0;
|
|
|
|
text_buf[i].index = 0;
|
|
|
|
}
|
|
|
|
|
2004-11-01 16:19:30 +00:00
|
|
|
grub_memset (VGA_MEM + PAGE_OFFSET (page), 0, VGA_WIDTH * VGA_HEIGHT / 8);
|
2004-03-14 17:48:25 +00:00
|
|
|
|
|
|
|
xpos = ypos = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2010-05-07 00:30:44 +00:00
|
|
|
grub_vga_setcolorstate (struct grub_term_output *term __attribute__ ((unused)),
|
|
|
|
grub_term_color_state state)
|
2004-03-14 17:48:25 +00:00
|
|
|
{
|
|
|
|
switch (state)
|
|
|
|
{
|
2004-04-04 13:46:03 +00:00
|
|
|
case GRUB_TERM_COLOR_STANDARD:
|
|
|
|
case GRUB_TERM_COLOR_NORMAL:
|
2004-03-14 17:48:25 +00:00
|
|
|
fg_color = DEFAULT_FG_COLOR;
|
|
|
|
bg_color = DEFAULT_BG_COLOR;
|
|
|
|
break;
|
2004-04-04 13:46:03 +00:00
|
|
|
case GRUB_TERM_COLOR_HIGHLIGHT:
|
2004-03-14 17:48:25 +00:00
|
|
|
fg_color = DEFAULT_BG_COLOR;
|
|
|
|
bg_color = DEFAULT_FG_COLOR;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2010-05-07 00:30:44 +00:00
|
|
|
grub_vga_setcursor (struct grub_term_output *term __attribute__ ((unused)),
|
|
|
|
int on)
|
2004-03-14 17:48:25 +00:00
|
|
|
{
|
|
|
|
if (cursor_state != on)
|
|
|
|
{
|
|
|
|
if (cursor_state)
|
|
|
|
write_char ();
|
|
|
|
else
|
|
|
|
write_cursor ();
|
|
|
|
|
|
|
|
cursor_state = on;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-11-07 Robert Millan <rmh@aybabtu.com>
Modularize at_keyboard.mod:
* conf/i386.rmk (pkglib_MODULES): Add `at_keyboard.mod'.
(at_keyboard_mod_SOURCES, at_keyboard_mod_CFLAGS)
(at_keyboard_mod_LDFLAGS): New variables.
Actual terminal split:
* include/grub/term.h (struct grub_term): Split in ...
(struct grub_term_input): ... this, and ...
(struct grub_term_output): ... this. Update all users.
(grub_term_set_current): Split in ...
(grub_term_set_current_input): ... this, and ...
(grub_term_set_current_output): ... this.
(grub_term_get_current): Split in ...
(grub_term_get_current_input): ... this, and ...
(grub_term_get_current_output): ... this.
(grub_term_register): Split in ...
(grub_term_register_input): ... this, and ...
(grub_term_register_output): ... this.
(grub_term_unregister): Split in ...
(grub_term_unregister_input): ... this, and ...
(grub_term_unregister_output): ... this.
(grub_term_iterate): Split in ...
(grub_term_iterate_input): ... this, and ...
(grub_term_iterate_output): ... this.
* kern/term.c (grub_term_list): Split in ...
(grub_term_list_input): ... this, and ...
(grub_term_list_output): ... this. Update all users.
(grub_cur_term): Split in ...
(grub_cur_term_input): ... this, and ...
(grub_cur_term_output): ... this. Update all users.
(grub_term_set_current): Split in ...
(grub_term_set_current_input): ... this, and ...
(grub_term_set_current_output): ... this.
(grub_term_get_current): Split in ...
(grub_term_get_current_input): ... this, and ...
(grub_term_get_current_output): ... this.
(grub_term_register): Split in ...
(grub_term_register_input): ... this, and ...
(grub_term_register_output): ... this.
(grub_term_unregister): Split in ...
(grub_term_unregister_input): ... this, and ...
(grub_term_unregister_output): ... this.
(grub_term_iterate): Split in ...
(grub_term_iterate_input): ... this, and ...
(grub_term_iterate_output): ... this.
* kern/misc.c (grub_abort): Split use of grub_term_get_current() into
a check for input and one for output (and only attempt to get keys
from user when input works).
* util/grub-probe.c (grub_term_get_current): Split in ...
(grub_term_get_current_input): ... this, and ...
(grub_term_get_current_output): ... this.
* util/grub-fstest.c: Likewise.
* util/i386/pc/grub-setup.c: Likewise.
* util/grub-editenv.c: Likewise.
Portability adjustments:
* conf/i386-ieee1275.rmk (kernel_elf_SOURCES): Remove
`term/i386/pc/at_keyboard.c'.
* kern/ieee1275/init.c [__i386__] (grub_machine_init): Remove call to
grub_keyboard_controller_init() (now handled by terminal .init).
* kern/i386/coreboot/init.c (grub_machine_init): Add call to
grub_at_keyboard_init().
* include/grub/i386/ieee1275/console.h (grub_keyboard_controller_init)
(grub_console_checkkey, grub_console_getkey): Remove (now provided by
at_keyboard.mod via input terminal interface).
* include/grub/i386/coreboot/console.h: Convert into a stub for
`<grub/i386/pc/console.h>'.
Migrate full terminals to new API:
* term/efi/console.c (grub_console_term): Split into ...
(grub_console_term_input): ... this, and ...
(grub_console_term_output): ... this. Update all users.
* term/ieee1275/ofconsole.c: Remove __i386__ hack.
(grub_ofconsole_init): Split into ...
(grub_ofconsole_init_input): ... this, and ...
(grub_ofconsole_init_output): ... this.
(grub_ofconsole_term): Split into ...
(grub_ofconsole_term_input): ... this, and ...
(grub_ofconsole_term_output): ... this. Update all users.
* term/i386/pc/serial.c (grub_serial_term): Split into ...
(grub_serial_term_input): ... this, and ...
(grub_serial_term_output): ... this. Update all users.
* term/i386/pc/console.c (grub_console_term): Split into ...
(grub_console_term_input): ... this, and ...
(grub_console_term_output): ... this. Update all users.
(grub_console_term_input): Only enable it on PC/BIOS platform.
(grub_console_init): Remove grub_keyboard_controller_init() call.
Migrate input terminals to new API:
* term/i386/pc/at_keyboard.c: Replace `cpu' and `machine' with
`i386' and `i386/pc' to enable build on x86_64 (this driver is
i386-specific anyway).
(grub_console_checkkey): Rename to ...
(grub_at_keyboard_checkkey): ... this. Static-ize. Update all
users.
(grub_keyboard_controller_orig): New variable.
(grub_console_getkey): Rename to ...
(grub_at_keyboard_getkey): ... this. Static-ize. Update all
users.
(grub_keyboard_controller_init): Static-ize. Save original
controller value so that it can be restored ...
(grub_keyboard_controller_fini): ... here (new function).
(grub_at_keyboard_term): New structure.
(GRUB_MOD_INIT(at_keyboard), GRUB_MOD_FINI(at_keyboard)): New
functions.
Migrate output terminals to new API:
* term/i386/pc/vga.c (grub_vga_term): Change type to
`struct grub_term_output'. Remove `.checkkey' and `.getkey'
members. Update all users.
* term/gfxterm.c (grub_video_term): Change type to
`struct grub_term_output'. Remove `.checkkey' and `.getkey'
members. Update all users.
* include/grub/i386/pc/console.h (grub_console_checkkey)
(grub_console_getkey): Do not export (no longer needed by gfxterm,
etc).
Migrate `terminal' command and userland tools to new API:
* commands/terminal.c (grub_cmd_terminal): Split into ...
(grub_cmd_terminal_input): ... this, and ...
(grub_cmd_terminal_output): ... this.
(GRUB_MOD_INIT(terminal)): Split `terminal' command in two commands:
`terminal_input' and `terminal_output'.
* util/grub.d/00_header.in: Adjust `terminal' calls to new
`terminal_input' / `terminal_output' API.
* util/grub-mkconfig.in: Export ${GRUB_TERMINAL_INPUT} and
${GRUB_TERMINAL_OUTPUT} instead of ${GRUB_TERMINAL} (and if user
provided ${GRUB_TERMINAL}, convert it).
2008-11-07 19:11:39 +00:00
|
|
|
static struct grub_term_output grub_vga_term =
|
2004-03-14 17:48:25 +00:00
|
|
|
{
|
|
|
|
.name = "vga",
|
2005-11-13 Marco Gerards <mgerards@xs4all.nl>
* geninit.sh: New file.
* geninitheader.sh: Likewise.
* commands/boot.c (grub_boot_init, grub_boot_fini): Removed.
* commands/cat.c (grub_cat_init, grub_cat_fini): Likewise.
* commands/cmp.c (grub_cmp_init, grub_cmp_fini): Likewise.
* commands/configfile.c (grub_configfile_init)
(grub_configfile_fini): Likewise.
* commands/default.c (grub_default_init, grub_default_fini):
Likewise.
* commands/help.c (grub_help_init, grub_help_fini): Likewise.
* commands/ls.c (grub_ls_init, grub_ls_fini): Likewise.
* commands/search.c (grub_search_init, grub_search_fini): Likewise.
* commands/terminal.c (grub_terminal_init, grub_terminal_fini):
Likewise.
* commands/test.c (grub_test_init, grub_test_fini): Likewise.
* commands/timeout.c (grub_timeout_init, grub_timeout_fini):
Likewise.
* commands/i386/pc/halt.c (grub_halt_init, grub_halt_fini): Likewise.
* commands/iee1275/halt.c (grub_halt_init, grub_halt_fini):
Likewise.
* commands/i386/pc/reboot.c (grub_reboot_init, grub_reboot_fini):
Likewise.
* commands/iee1275/reboot.c (grub_reboot_init, grub_reboot_fini):
Likewise.
* disk/loopback.c (grub_loop_init, grub_loop_fini): Likewise.
* fs/affs.c (grub_affs_init, grub_affs_fini): Likewise.
* fs/ext2.c (grub_ext2_init, grub_ext2_fini): Likewise.
* fs/fat.c (grub_fat_init, grub_fat_fini): Likewise.
* fs/hfs.c (grub_hfs_init, grub_hfs_fini): Likewise.
* fs/iso9660.c (grub_iso9660_init, grub_iso9660_fini): Likewise.
* fs/jfs.c (grub_jfs_init, grub_jfs_fini): Likewise.
* fs/minix.c (grub_minix_init, grub_minix_fini): Likewise.
* fs/sfs.c (grub_sfs_init, grub_sfs_fini): Likewise.
* fs/ufs.c (grub_ufs_init, grub_ufs_fini): Likewise.
* fs/xfs.c (grub_xfs_init, grub_xfs_fini): Likewise.
* normal/main.c (grub_normal_init, grub_normal_fini): Likewise.
* partmap/amiga.c (grub_amiga_partition_map_init)
(grub_amiga_partition_map_fini): Likewise.
* partmap/apple.c (grub_apple_partition_map_init)
(grub_apple_partition_map_fini): Likewise.
* partmap/pc.c (grub_pc_partition_map_init)
(grub_pc_partition_map_fini): Likewise.
* partmap/sun.c (grub_sun_partition_map_init,
grub_sun_partition_map_fini): Likewise.
* term/terminfo.c (grub_terminal_init, grub_terminal_fini):
Likewise.
* util/grub-emu.c: Include <grub_modules_init.h>.
(main): Don't initialize and de-initialize any modules directly,
use `grub_init_all' and `grub_fini_all' instead.
* term/i386/pc/vesafb.c (grub_vesafb_init): Renamed to
`grub_vesafb_mod_init'.
(grub_vesafb_fini): Renamed to `grub_vesafb_mod_fini'. Updated
all users.
* term/i386/pc/vga.c (grub_vga_init): Renamed to
`grub_vga_mod_init'. Updated all users.
(grub_vga_fini): Renamed to `grub_vga_mod_fini'.
* conf/i386-pc.rmk (grub_emu_SOURCES): Add `grub_emu_init.c'.
(grub_modules_init.lst, grub_modules_init.h, grub_emu_init.c): New
rules.
* include/grub/dl.h (GRUB_MOD_INIT): Add argument `name'.
Generate a function to initialize the module in utilities.
Updated all callers.
(GRUB_MOD_FINI): Add argument `name'. Generate a function to
initialize the module in utilities. Updated all callers.
2005-11-13 15:47:09 +00:00
|
|
|
.init = grub_vga_mod_init,
|
|
|
|
.fini = grub_vga_mod_fini,
|
2004-04-04 13:46:03 +00:00
|
|
|
.putchar = grub_vga_putchar,
|
2005-08-20 05:26:51 +00:00
|
|
|
.getcharwidth = grub_vga_getcharwidth,
|
2005-08-04 18:10:51 +00:00
|
|
|
.getwh = grub_vga_getwh,
|
2004-04-04 13:46:03 +00:00
|
|
|
.getxy = grub_vga_getxy,
|
|
|
|
.gotoxy = grub_vga_gotoxy,
|
|
|
|
.cls = grub_vga_cls,
|
|
|
|
.setcolorstate = grub_vga_setcolorstate,
|
|
|
|
.setcursor = grub_vga_setcursor,
|
2010-03-16 18:23:21 +00:00
|
|
|
.flags = GRUB_TERM_CODE_TYPE_VISUAL_GLYPHS,
|
2010-05-07 23:06:22 +00:00
|
|
|
.normal_color = GRUB_TERM_DEFAULT_NORMAL_COLOR,
|
|
|
|
.highlight_color = GRUB_TERM_DEFAULT_HIGHLIGHT_COLOR,
|
2004-03-14 17:48:25 +00:00
|
|
|
};
|
2003-09-25 20:15:53 +00:00
|
|
|
|
2005-11-13 Marco Gerards <mgerards@xs4all.nl>
* geninit.sh: New file.
* geninitheader.sh: Likewise.
* commands/boot.c (grub_boot_init, grub_boot_fini): Removed.
* commands/cat.c (grub_cat_init, grub_cat_fini): Likewise.
* commands/cmp.c (grub_cmp_init, grub_cmp_fini): Likewise.
* commands/configfile.c (grub_configfile_init)
(grub_configfile_fini): Likewise.
* commands/default.c (grub_default_init, grub_default_fini):
Likewise.
* commands/help.c (grub_help_init, grub_help_fini): Likewise.
* commands/ls.c (grub_ls_init, grub_ls_fini): Likewise.
* commands/search.c (grub_search_init, grub_search_fini): Likewise.
* commands/terminal.c (grub_terminal_init, grub_terminal_fini):
Likewise.
* commands/test.c (grub_test_init, grub_test_fini): Likewise.
* commands/timeout.c (grub_timeout_init, grub_timeout_fini):
Likewise.
* commands/i386/pc/halt.c (grub_halt_init, grub_halt_fini): Likewise.
* commands/iee1275/halt.c (grub_halt_init, grub_halt_fini):
Likewise.
* commands/i386/pc/reboot.c (grub_reboot_init, grub_reboot_fini):
Likewise.
* commands/iee1275/reboot.c (grub_reboot_init, grub_reboot_fini):
Likewise.
* disk/loopback.c (grub_loop_init, grub_loop_fini): Likewise.
* fs/affs.c (grub_affs_init, grub_affs_fini): Likewise.
* fs/ext2.c (grub_ext2_init, grub_ext2_fini): Likewise.
* fs/fat.c (grub_fat_init, grub_fat_fini): Likewise.
* fs/hfs.c (grub_hfs_init, grub_hfs_fini): Likewise.
* fs/iso9660.c (grub_iso9660_init, grub_iso9660_fini): Likewise.
* fs/jfs.c (grub_jfs_init, grub_jfs_fini): Likewise.
* fs/minix.c (grub_minix_init, grub_minix_fini): Likewise.
* fs/sfs.c (grub_sfs_init, grub_sfs_fini): Likewise.
* fs/ufs.c (grub_ufs_init, grub_ufs_fini): Likewise.
* fs/xfs.c (grub_xfs_init, grub_xfs_fini): Likewise.
* normal/main.c (grub_normal_init, grub_normal_fini): Likewise.
* partmap/amiga.c (grub_amiga_partition_map_init)
(grub_amiga_partition_map_fini): Likewise.
* partmap/apple.c (grub_apple_partition_map_init)
(grub_apple_partition_map_fini): Likewise.
* partmap/pc.c (grub_pc_partition_map_init)
(grub_pc_partition_map_fini): Likewise.
* partmap/sun.c (grub_sun_partition_map_init,
grub_sun_partition_map_fini): Likewise.
* term/terminfo.c (grub_terminal_init, grub_terminal_fini):
Likewise.
* util/grub-emu.c: Include <grub_modules_init.h>.
(main): Don't initialize and de-initialize any modules directly,
use `grub_init_all' and `grub_fini_all' instead.
* term/i386/pc/vesafb.c (grub_vesafb_init): Renamed to
`grub_vesafb_mod_init'.
(grub_vesafb_fini): Renamed to `grub_vesafb_mod_fini'. Updated
all users.
* term/i386/pc/vga.c (grub_vga_init): Renamed to
`grub_vga_mod_init'. Updated all users.
(grub_vga_fini): Renamed to `grub_vga_mod_fini'.
* conf/i386-pc.rmk (grub_emu_SOURCES): Add `grub_emu_init.c'.
(grub_modules_init.lst, grub_modules_init.h, grub_emu_init.c): New
rules.
* include/grub/dl.h (GRUB_MOD_INIT): Add argument `name'.
Generate a function to initialize the module in utilities.
Updated all callers.
(GRUB_MOD_FINI): Add argument `name'. Generate a function to
initialize the module in utilities. Updated all callers.
2005-11-13 15:47:09 +00:00
|
|
|
GRUB_MOD_INIT(vga)
|
2003-09-25 20:15:53 +00:00
|
|
|
{
|
2009-04-14 18:12:14 +00:00
|
|
|
grub_term_register_output ("vga", &grub_vga_term);
|
2003-09-25 20:15:53 +00:00
|
|
|
}
|
|
|
|
|
2005-11-13 Marco Gerards <mgerards@xs4all.nl>
* geninit.sh: New file.
* geninitheader.sh: Likewise.
* commands/boot.c (grub_boot_init, grub_boot_fini): Removed.
* commands/cat.c (grub_cat_init, grub_cat_fini): Likewise.
* commands/cmp.c (grub_cmp_init, grub_cmp_fini): Likewise.
* commands/configfile.c (grub_configfile_init)
(grub_configfile_fini): Likewise.
* commands/default.c (grub_default_init, grub_default_fini):
Likewise.
* commands/help.c (grub_help_init, grub_help_fini): Likewise.
* commands/ls.c (grub_ls_init, grub_ls_fini): Likewise.
* commands/search.c (grub_search_init, grub_search_fini): Likewise.
* commands/terminal.c (grub_terminal_init, grub_terminal_fini):
Likewise.
* commands/test.c (grub_test_init, grub_test_fini): Likewise.
* commands/timeout.c (grub_timeout_init, grub_timeout_fini):
Likewise.
* commands/i386/pc/halt.c (grub_halt_init, grub_halt_fini): Likewise.
* commands/iee1275/halt.c (grub_halt_init, grub_halt_fini):
Likewise.
* commands/i386/pc/reboot.c (grub_reboot_init, grub_reboot_fini):
Likewise.
* commands/iee1275/reboot.c (grub_reboot_init, grub_reboot_fini):
Likewise.
* disk/loopback.c (grub_loop_init, grub_loop_fini): Likewise.
* fs/affs.c (grub_affs_init, grub_affs_fini): Likewise.
* fs/ext2.c (grub_ext2_init, grub_ext2_fini): Likewise.
* fs/fat.c (grub_fat_init, grub_fat_fini): Likewise.
* fs/hfs.c (grub_hfs_init, grub_hfs_fini): Likewise.
* fs/iso9660.c (grub_iso9660_init, grub_iso9660_fini): Likewise.
* fs/jfs.c (grub_jfs_init, grub_jfs_fini): Likewise.
* fs/minix.c (grub_minix_init, grub_minix_fini): Likewise.
* fs/sfs.c (grub_sfs_init, grub_sfs_fini): Likewise.
* fs/ufs.c (grub_ufs_init, grub_ufs_fini): Likewise.
* fs/xfs.c (grub_xfs_init, grub_xfs_fini): Likewise.
* normal/main.c (grub_normal_init, grub_normal_fini): Likewise.
* partmap/amiga.c (grub_amiga_partition_map_init)
(grub_amiga_partition_map_fini): Likewise.
* partmap/apple.c (grub_apple_partition_map_init)
(grub_apple_partition_map_fini): Likewise.
* partmap/pc.c (grub_pc_partition_map_init)
(grub_pc_partition_map_fini): Likewise.
* partmap/sun.c (grub_sun_partition_map_init,
grub_sun_partition_map_fini): Likewise.
* term/terminfo.c (grub_terminal_init, grub_terminal_fini):
Likewise.
* util/grub-emu.c: Include <grub_modules_init.h>.
(main): Don't initialize and de-initialize any modules directly,
use `grub_init_all' and `grub_fini_all' instead.
* term/i386/pc/vesafb.c (grub_vesafb_init): Renamed to
`grub_vesafb_mod_init'.
(grub_vesafb_fini): Renamed to `grub_vesafb_mod_fini'. Updated
all users.
* term/i386/pc/vga.c (grub_vga_init): Renamed to
`grub_vga_mod_init'. Updated all users.
(grub_vga_fini): Renamed to `grub_vga_mod_fini'.
* conf/i386-pc.rmk (grub_emu_SOURCES): Add `grub_emu_init.c'.
(grub_modules_init.lst, grub_modules_init.h, grub_emu_init.c): New
rules.
* include/grub/dl.h (GRUB_MOD_INIT): Add argument `name'.
Generate a function to initialize the module in utilities.
Updated all callers.
(GRUB_MOD_FINI): Add argument `name'. Generate a function to
initialize the module in utilities. Updated all callers.
2005-11-13 15:47:09 +00:00
|
|
|
GRUB_MOD_FINI(vga)
|
2003-09-25 20:15:53 +00:00
|
|
|
{
|
2008-11-07 Robert Millan <rmh@aybabtu.com>
Modularize at_keyboard.mod:
* conf/i386.rmk (pkglib_MODULES): Add `at_keyboard.mod'.
(at_keyboard_mod_SOURCES, at_keyboard_mod_CFLAGS)
(at_keyboard_mod_LDFLAGS): New variables.
Actual terminal split:
* include/grub/term.h (struct grub_term): Split in ...
(struct grub_term_input): ... this, and ...
(struct grub_term_output): ... this. Update all users.
(grub_term_set_current): Split in ...
(grub_term_set_current_input): ... this, and ...
(grub_term_set_current_output): ... this.
(grub_term_get_current): Split in ...
(grub_term_get_current_input): ... this, and ...
(grub_term_get_current_output): ... this.
(grub_term_register): Split in ...
(grub_term_register_input): ... this, and ...
(grub_term_register_output): ... this.
(grub_term_unregister): Split in ...
(grub_term_unregister_input): ... this, and ...
(grub_term_unregister_output): ... this.
(grub_term_iterate): Split in ...
(grub_term_iterate_input): ... this, and ...
(grub_term_iterate_output): ... this.
* kern/term.c (grub_term_list): Split in ...
(grub_term_list_input): ... this, and ...
(grub_term_list_output): ... this. Update all users.
(grub_cur_term): Split in ...
(grub_cur_term_input): ... this, and ...
(grub_cur_term_output): ... this. Update all users.
(grub_term_set_current): Split in ...
(grub_term_set_current_input): ... this, and ...
(grub_term_set_current_output): ... this.
(grub_term_get_current): Split in ...
(grub_term_get_current_input): ... this, and ...
(grub_term_get_current_output): ... this.
(grub_term_register): Split in ...
(grub_term_register_input): ... this, and ...
(grub_term_register_output): ... this.
(grub_term_unregister): Split in ...
(grub_term_unregister_input): ... this, and ...
(grub_term_unregister_output): ... this.
(grub_term_iterate): Split in ...
(grub_term_iterate_input): ... this, and ...
(grub_term_iterate_output): ... this.
* kern/misc.c (grub_abort): Split use of grub_term_get_current() into
a check for input and one for output (and only attempt to get keys
from user when input works).
* util/grub-probe.c (grub_term_get_current): Split in ...
(grub_term_get_current_input): ... this, and ...
(grub_term_get_current_output): ... this.
* util/grub-fstest.c: Likewise.
* util/i386/pc/grub-setup.c: Likewise.
* util/grub-editenv.c: Likewise.
Portability adjustments:
* conf/i386-ieee1275.rmk (kernel_elf_SOURCES): Remove
`term/i386/pc/at_keyboard.c'.
* kern/ieee1275/init.c [__i386__] (grub_machine_init): Remove call to
grub_keyboard_controller_init() (now handled by terminal .init).
* kern/i386/coreboot/init.c (grub_machine_init): Add call to
grub_at_keyboard_init().
* include/grub/i386/ieee1275/console.h (grub_keyboard_controller_init)
(grub_console_checkkey, grub_console_getkey): Remove (now provided by
at_keyboard.mod via input terminal interface).
* include/grub/i386/coreboot/console.h: Convert into a stub for
`<grub/i386/pc/console.h>'.
Migrate full terminals to new API:
* term/efi/console.c (grub_console_term): Split into ...
(grub_console_term_input): ... this, and ...
(grub_console_term_output): ... this. Update all users.
* term/ieee1275/ofconsole.c: Remove __i386__ hack.
(grub_ofconsole_init): Split into ...
(grub_ofconsole_init_input): ... this, and ...
(grub_ofconsole_init_output): ... this.
(grub_ofconsole_term): Split into ...
(grub_ofconsole_term_input): ... this, and ...
(grub_ofconsole_term_output): ... this. Update all users.
* term/i386/pc/serial.c (grub_serial_term): Split into ...
(grub_serial_term_input): ... this, and ...
(grub_serial_term_output): ... this. Update all users.
* term/i386/pc/console.c (grub_console_term): Split into ...
(grub_console_term_input): ... this, and ...
(grub_console_term_output): ... this. Update all users.
(grub_console_term_input): Only enable it on PC/BIOS platform.
(grub_console_init): Remove grub_keyboard_controller_init() call.
Migrate input terminals to new API:
* term/i386/pc/at_keyboard.c: Replace `cpu' and `machine' with
`i386' and `i386/pc' to enable build on x86_64 (this driver is
i386-specific anyway).
(grub_console_checkkey): Rename to ...
(grub_at_keyboard_checkkey): ... this. Static-ize. Update all
users.
(grub_keyboard_controller_orig): New variable.
(grub_console_getkey): Rename to ...
(grub_at_keyboard_getkey): ... this. Static-ize. Update all
users.
(grub_keyboard_controller_init): Static-ize. Save original
controller value so that it can be restored ...
(grub_keyboard_controller_fini): ... here (new function).
(grub_at_keyboard_term): New structure.
(GRUB_MOD_INIT(at_keyboard), GRUB_MOD_FINI(at_keyboard)): New
functions.
Migrate output terminals to new API:
* term/i386/pc/vga.c (grub_vga_term): Change type to
`struct grub_term_output'. Remove `.checkkey' and `.getkey'
members. Update all users.
* term/gfxterm.c (grub_video_term): Change type to
`struct grub_term_output'. Remove `.checkkey' and `.getkey'
members. Update all users.
* include/grub/i386/pc/console.h (grub_console_checkkey)
(grub_console_getkey): Do not export (no longer needed by gfxterm,
etc).
Migrate `terminal' command and userland tools to new API:
* commands/terminal.c (grub_cmd_terminal): Split into ...
(grub_cmd_terminal_input): ... this, and ...
(grub_cmd_terminal_output): ... this.
(GRUB_MOD_INIT(terminal)): Split `terminal' command in two commands:
`terminal_input' and `terminal_output'.
* util/grub.d/00_header.in: Adjust `terminal' calls to new
`terminal_input' / `terminal_output' API.
* util/grub-mkconfig.in: Export ${GRUB_TERMINAL_INPUT} and
${GRUB_TERMINAL_OUTPUT} instead of ${GRUB_TERMINAL} (and if user
provided ${GRUB_TERMINAL}, convert it).
2008-11-07 19:11:39 +00:00
|
|
|
grub_term_unregister_output (&grub_vga_term);
|
2003-09-25 20:15:53 +00:00
|
|
|
}
|