pull-in func-params branch
This commit is contained in:
commit
45ab4f486f
14 changed files with 939 additions and 762 deletions
60
ChangeLog
60
ChangeLog
|
@ -1,3 +1,63 @@
|
|||
2010-05-09 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
Transform (broken) vga terminal into (working) vga video driver.
|
||||
|
||||
* conf/i386-pc.rmk (vga_mod_SOURCES): Change term/i386/pc/vga.c to
|
||||
video/i386/pc/vga.c.
|
||||
* include/grub/video.h (grub_video_driver_id):
|
||||
Add GRUB_VIDEO_DRIVER_VGA.
|
||||
* term/i386/pc/vga.c: Renamed to ...
|
||||
* video/i386/pc/vga.c: ...this
|
||||
(DEBUG_VGA): Removed.
|
||||
(CHAR_WIDTH): Likewise.
|
||||
(CHAR_HEIGHT): Likewise.
|
||||
(TEXT_WIDTH): Likewise.
|
||||
(TEXT_HEIGHT): Likewise.
|
||||
(DEFAULT_FG_COLOR): Likewise.
|
||||
(DEFAULT_BG_COLOR): Likewise.
|
||||
(colored_char): Likewise.
|
||||
(xpos): Likewise.
|
||||
(ypos): Likewise.
|
||||
(cursor_state): Likewise.
|
||||
(fg_color): Likewise.
|
||||
(bg_color): Likewise.
|
||||
(text_buf): Likewise.
|
||||
(page): Likewise.
|
||||
(font): Likewise.
|
||||
(framebuffer): New variable.
|
||||
(set_read_map): Disabled.
|
||||
(setup): New variable.
|
||||
(is_target): Likewise.
|
||||
(grub_vga_mod_init): Likewise.
|
||||
(grub_vga_mod_fini): Likewise.
|
||||
(check_vga_mem): Likewise.
|
||||
(write_char): Likewise.
|
||||
(write_cursor): Likewise.
|
||||
(scroll_up): Likewise.
|
||||
(grub_vga_putchar): Likewise.
|
||||
(grub_vga_getcharwidth): Likewise.
|
||||
(grub_vga_getwh): Likewise.
|
||||
(grub_vga_getxy): Likewise.
|
||||
(grub_vga_gotoxy): Likewise.
|
||||
(grub_vga_cls): Likewise.
|
||||
(grub_vga_setcolorstate): Likewise.
|
||||
(grub_vga_setcursor): Likewise.
|
||||
(grub_video_vga_init): New function.
|
||||
(grub_video_vga_setup): Likewise.
|
||||
(grub_video_vga_fini): Likewise.
|
||||
(update_target): Likewise.
|
||||
(grub_video_vga_blit_bitmap): Likewise.
|
||||
(grub_video_vga_blit_render_target): Likewise.
|
||||
(grub_video_vga_set_active_render_target): Likewise.
|
||||
(grub_video_vga_get_active_render_target): Likewise.
|
||||
(grub_video_vga_swap_buffers): Likewise.
|
||||
(grub_video_vga_set_palette): Likewise.
|
||||
(grub_video_vga_get_info_and_fini): Likewise.
|
||||
(grub_vga_term): Removed.
|
||||
(grub_video_vga_adapter): New variable.
|
||||
(GRUB_MOD_INIT): Register a video driver instead of terminal.
|
||||
(GRUB_MOD_FINI): Unrefister a video driver instead of terminal.
|
||||
|
||||
2010-05-05 Vladimir Serbinenko <phcoder@gmail.com>
|
||||
|
||||
* video/readers/jpeg.c: Indented.
|
||||
|
|
|
@ -660,7 +660,7 @@ normal_mod_CFLAGS = $(COMMON_CFLAGS)
|
|||
normal_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
# For sh.mod.
|
||||
sh_mod_SOURCES = script/main.c script/script.c script/execute.c \
|
||||
sh_mod_SOURCES = script/main.c script/script.c script/argv.c script/execute.c \
|
||||
script/function.c script/lexer.c grub_script.tab.c grub_script.yy.c
|
||||
sh_mod_CFLAGS = $(COMMON_CFLAGS) $(POSIX_CFLAGS) -Wno-error
|
||||
sh_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
|
|
@ -185,7 +185,7 @@ vbetest_mod_CFLAGS = $(COMMON_CFLAGS)
|
|||
vbetest_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
# For vga.mod.
|
||||
vga_mod_SOURCES = term/i386/pc/vga.c
|
||||
vga_mod_SOURCES = video/i386/pc/vga.c
|
||||
vga_mod_CFLAGS = $(COMMON_CFLAGS)
|
||||
vga_mod_LDFLAGS = $(COMMON_LDFLAGS)
|
||||
|
||||
|
|
|
@ -64,6 +64,13 @@ struct grub_script_arg
|
|||
struct grub_script_arg *next;
|
||||
};
|
||||
|
||||
/* An argument vector. */
|
||||
struct grub_script_argv
|
||||
{
|
||||
unsigned argc;
|
||||
char **args;
|
||||
};
|
||||
|
||||
/* A complete argument. It consists of a list of one or more `struct
|
||||
grub_script_arg's. */
|
||||
struct grub_script_arglist
|
||||
|
@ -74,16 +81,6 @@ struct grub_script_arglist
|
|||
int argcount;
|
||||
};
|
||||
|
||||
/* Scope for grub script constructs. */
|
||||
struct grub_script_scope
|
||||
{
|
||||
struct grub_script_scope *next;
|
||||
|
||||
char **args;
|
||||
unsigned int argc;
|
||||
unsigned int shift;
|
||||
};
|
||||
|
||||
/* A single command line. */
|
||||
struct grub_script_cmdline
|
||||
{
|
||||
|
@ -226,6 +223,11 @@ struct grub_parser_param
|
|||
struct grub_lexer_param *lexerstate;
|
||||
};
|
||||
|
||||
void grub_script_argv_free (struct grub_script_argv *argv);
|
||||
int grub_script_argv_next (struct grub_script_argv *argv);
|
||||
int grub_script_argv_append (struct grub_script_argv *argv, const char *s);
|
||||
int grub_script_argv_split_append (struct grub_script_argv *argv, char *s);
|
||||
|
||||
struct grub_script_arglist *
|
||||
grub_script_create_arglist (struct grub_parser_param *state);
|
||||
|
||||
|
|
|
@ -181,7 +181,8 @@ typedef enum grub_video_driver_id
|
|||
GRUB_VIDEO_DRIVER_VBE,
|
||||
GRUB_VIDEO_DRIVER_EFI_UGA,
|
||||
GRUB_VIDEO_DRIVER_EFI_GOP,
|
||||
GRUB_VIDEO_DRIVER_SM712
|
||||
GRUB_VIDEO_DRIVER_SM712,
|
||||
GRUB_VIDEO_DRIVER_VGA
|
||||
} grub_video_driver_id_t;
|
||||
|
||||
struct grub_video_adapter
|
||||
|
|
128
script/argv.c
Normal file
128
script/argv.c
Normal file
|
@ -0,0 +1,128 @@
|
|||
/* argv.c - methods for constructing argument vector */
|
||||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2010 Free Software Foundation, Inc.
|
||||
*
|
||||
* GRUB 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* GRUB 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 GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <grub/mm.h>
|
||||
#include <grub/script_sh.h>
|
||||
|
||||
#define ARG_ALLOCATION_UNIT (32 * sizeof (char))
|
||||
#define ARGV_ALLOCATION_UNIT (8 * sizeof (void*))
|
||||
|
||||
void
|
||||
grub_script_argv_free (struct grub_script_argv *argv)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (argv->args)
|
||||
{
|
||||
for (i = 0; i < argv->argc; i++)
|
||||
grub_free (argv->args[i]);
|
||||
|
||||
grub_free (argv->args);
|
||||
}
|
||||
|
||||
argv->argc = 0;
|
||||
argv->args = 0;
|
||||
}
|
||||
|
||||
/* Prepare for next argc. */
|
||||
int
|
||||
grub_script_argv_next (struct grub_script_argv *argv)
|
||||
{
|
||||
char **p = argv->args;
|
||||
|
||||
if (argv->argc == 0)
|
||||
{
|
||||
p = grub_malloc (ALIGN_UP (2 * sizeof (char *), ARG_ALLOCATION_UNIT));
|
||||
if (! p)
|
||||
return 1;
|
||||
|
||||
argv->argc = 1;
|
||||
argv->args = p;
|
||||
argv->args[0] = 0;
|
||||
argv->args[1] = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (! argv->args[argv->argc - 1])
|
||||
return 0;
|
||||
|
||||
p = grub_realloc (p, ALIGN_UP ((argv->argc + 1) * sizeof (char *),
|
||||
ARG_ALLOCATION_UNIT));
|
||||
if (! p)
|
||||
return 1;
|
||||
|
||||
argv->argc++;
|
||||
argv->args = p;
|
||||
argv->args[argv->argc] = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Append `s' to the last argument. */
|
||||
int
|
||||
grub_script_argv_append (struct grub_script_argv *argv, const char *s)
|
||||
{
|
||||
int a, b;
|
||||
char *p = argv->args[argv->argc - 1];
|
||||
|
||||
if (! s)
|
||||
return 0;
|
||||
|
||||
a = p ? grub_strlen (p) : 0;
|
||||
b = grub_strlen (s);
|
||||
|
||||
p = grub_realloc (p, ALIGN_UP ((a + b + 1) * sizeof (char),
|
||||
ARG_ALLOCATION_UNIT));
|
||||
if (! p)
|
||||
return 1;
|
||||
|
||||
grub_strcpy (p + a, s);
|
||||
argv->args[argv->argc - 1] = p;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Split `s' and append words as multiple arguments. */
|
||||
int
|
||||
grub_script_argv_split_append (struct grub_script_argv *argv, char *s)
|
||||
{
|
||||
char ch;
|
||||
char *p;
|
||||
int errors = 0;
|
||||
|
||||
if (! s)
|
||||
return 0;
|
||||
|
||||
while (! errors && *s)
|
||||
{
|
||||
p = s;
|
||||
while (*s && ! grub_isspace (*s))
|
||||
s++;
|
||||
|
||||
ch = *s;
|
||||
*s = '\0';
|
||||
errors += grub_script_argv_append (argv, p);
|
||||
*s = ch;
|
||||
|
||||
while (*s && grub_isspace (*s))
|
||||
s++;
|
||||
|
||||
if (*s)
|
||||
errors += grub_script_argv_next (argv);
|
||||
}
|
||||
return errors;
|
||||
}
|
400
script/execute.c
400
script/execute.c
|
@ -30,6 +30,11 @@
|
|||
is sizeof (int) * 3, and one extra for a possible -ve sign. */
|
||||
#define ERRNO_DIGITS_MAX (sizeof (int) * 3 + 1)
|
||||
|
||||
/* Scope for grub script functions. */
|
||||
struct grub_script_scope
|
||||
{
|
||||
struct grub_script_argv argv;
|
||||
};
|
||||
static struct grub_script_scope *scope = 0;
|
||||
|
||||
grub_err_t
|
||||
|
@ -42,68 +47,196 @@ grub_script_cmd_shift (grub_command_t cmd __attribute__((unused)),
|
|||
if (! scope)
|
||||
return GRUB_ERR_NONE;
|
||||
|
||||
if (scope->argv.argc == 0)
|
||||
return GRUB_ERR_NONE;
|
||||
|
||||
if (argc == 0)
|
||||
n = 1;
|
||||
|
||||
else if (argc > 1)
|
||||
return GRUB_ERR_BAD_ARGUMENT;
|
||||
|
||||
else
|
||||
{
|
||||
n = grub_strtoul (argv[0], &p, 10);
|
||||
if (*p != '\0')
|
||||
if (*p != '\0' || n > scope->argv.argc)
|
||||
return GRUB_ERR_BAD_ARGUMENT;
|
||||
}
|
||||
|
||||
scope->shift = (unsigned int)(n > scope->argc ? 0 : n);
|
||||
scope->argv.argc -= n;
|
||||
scope->argv.args += n;
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
|
||||
static char *
|
||||
grub_script_env_get (const char *name)
|
||||
static int
|
||||
grub_env_special (const char *name)
|
||||
{
|
||||
char *p = 0;
|
||||
unsigned long num = 0;
|
||||
|
||||
if (! scope)
|
||||
return grub_env_get (name);
|
||||
|
||||
if (grub_isdigit (name[0]))
|
||||
{
|
||||
num = grub_strtoul (name, &p, 10);
|
||||
if (p && *p == '\0')
|
||||
{
|
||||
if (num == 0)
|
||||
return 0; /* XXX no file name, for now. */
|
||||
|
||||
if (num > scope->argc - scope->shift)
|
||||
return 0;
|
||||
else
|
||||
return scope->args[num - 1 + scope->shift];
|
||||
}
|
||||
else
|
||||
{
|
||||
grub_error (GRUB_ERR_BAD_ARGUMENT, "bad variabe name substitution");
|
||||
if (grub_isdigit (name[0]) ||
|
||||
grub_strcmp (name, "#") == 0 ||
|
||||
grub_strcmp (name, "*") == 0 ||
|
||||
grub_strcmp (name, "@") == 0)
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static char **
|
||||
grub_script_env_get (const char *name, grub_script_arg_type_t type)
|
||||
{
|
||||
int errors = 0;
|
||||
struct grub_script_argv result = { 0, 0 };
|
||||
|
||||
errors += grub_script_argv_next (&result);
|
||||
if (! grub_env_special (name))
|
||||
{
|
||||
char *v = grub_env_get (name);
|
||||
if (v && v[0])
|
||||
{
|
||||
if (type == GRUB_SCRIPT_ARG_TYPE_VAR)
|
||||
errors += grub_script_argv_split_append (&result, v);
|
||||
else
|
||||
errors += grub_script_argv_append (&result, v);
|
||||
}
|
||||
}
|
||||
else if (! scope)
|
||||
errors += grub_script_argv_append (&result, 0);
|
||||
|
||||
else if (grub_strcmp (name, "#") == 0)
|
||||
{
|
||||
static char buf[32]; /* Rewritten everytime. */
|
||||
grub_snprintf (buf, sizeof (buf), "%u", scope->argc - scope->shift);
|
||||
return buf;
|
||||
char buffer[ERRNO_DIGITS_MAX + 1];
|
||||
grub_snprintf (buffer, sizeof (buffer), "%u", scope->argv.argc);
|
||||
errors += grub_script_argv_append (&result, buffer);
|
||||
}
|
||||
else if (grub_strcmp (name, "*") == 0)
|
||||
{
|
||||
unsigned i;
|
||||
|
||||
for (i = 0; ! errors && i < scope->argv.argc; i++)
|
||||
if (type == GRUB_SCRIPT_ARG_TYPE_VAR)
|
||||
{
|
||||
if (i != 0)
|
||||
errors += grub_script_argv_next (&result);
|
||||
errors += grub_script_argv_split_append (&result,
|
||||
scope->argv.args[i]);
|
||||
}
|
||||
else
|
||||
return grub_env_get (name);
|
||||
{
|
||||
if (i != 0)
|
||||
errors += grub_script_argv_append (&result, " ");
|
||||
errors += grub_script_argv_append (&result,
|
||||
scope->argv.args[i]);
|
||||
}
|
||||
}
|
||||
else if (grub_strcmp (name, "@") == 0)
|
||||
{
|
||||
unsigned i;
|
||||
|
||||
for (i = 0; ! errors && i < scope->argv.argc; i++)
|
||||
{
|
||||
if (i != 0)
|
||||
errors += grub_script_argv_next (&result);
|
||||
|
||||
if (type == GRUB_SCRIPT_ARG_TYPE_VAR)
|
||||
errors += grub_script_argv_split_append (&result,
|
||||
scope->argv.args[i]);
|
||||
else
|
||||
errors += grub_script_argv_append (&result,
|
||||
scope->argv.args[i]);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
unsigned long num = grub_strtoul (name, 0, 10);
|
||||
if (num == 0)
|
||||
; /* XXX no file name, for now. */
|
||||
|
||||
else if (num <= scope->argv.argc)
|
||||
{
|
||||
if (type == GRUB_SCRIPT_ARG_TYPE_VAR)
|
||||
errors += grub_script_argv_split_append (&result,
|
||||
scope->argv.args[num - 1]);
|
||||
else
|
||||
errors += grub_script_argv_append (&result,
|
||||
scope->argv.args[num - 1]);
|
||||
}
|
||||
}
|
||||
|
||||
if (errors)
|
||||
{
|
||||
grub_script_argv_free (&result);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return result.args;
|
||||
}
|
||||
|
||||
static grub_err_t
|
||||
grub_script_env_set (const char *name, const char *val)
|
||||
{
|
||||
if (grub_isdigit (name[0]) || grub_strcmp (name, "#") == 0)
|
||||
if (grub_env_special (name))
|
||||
return grub_error (GRUB_ERR_BAD_ARGUMENT, "bad variable name");
|
||||
|
||||
return grub_env_set (name, val);
|
||||
}
|
||||
|
||||
/* Expand arguments in ARGLIST into multiple arguments. */
|
||||
static int
|
||||
grub_script_arglist_to_argv (struct grub_script_arglist *arglist,
|
||||
struct grub_script_argv *argv)
|
||||
{
|
||||
int i;
|
||||
int error = 0;
|
||||
char **values = 0;
|
||||
struct grub_script_arg *arg = 0;
|
||||
struct grub_script_argv result = { 0, 0 };
|
||||
|
||||
for (; error == 0 && arglist && arglist->arg; arglist = arglist->next)
|
||||
{
|
||||
error += grub_script_argv_next (&result);
|
||||
|
||||
arg = arglist->arg;
|
||||
while (arg)
|
||||
{
|
||||
if (error)
|
||||
break;
|
||||
|
||||
switch (arg->type)
|
||||
{
|
||||
case GRUB_SCRIPT_ARG_TYPE_VAR:
|
||||
case GRUB_SCRIPT_ARG_TYPE_DQVAR:
|
||||
values = grub_script_env_get (arg->str, arg->type);
|
||||
for (i = 0; values && values[i]; i++)
|
||||
{
|
||||
if (i != 0)
|
||||
error += grub_script_argv_next (&result);
|
||||
error += grub_script_argv_append (&result, values[i]);
|
||||
}
|
||||
grub_free (values);
|
||||
break;
|
||||
|
||||
case GRUB_SCRIPT_ARG_TYPE_TEXT:
|
||||
if (grub_strlen (arg->str))
|
||||
error += grub_script_argv_append (&result, arg->str);
|
||||
break;
|
||||
|
||||
case GRUB_SCRIPT_ARG_TYPE_DQSTR:
|
||||
case GRUB_SCRIPT_ARG_TYPE_SQSTR:
|
||||
error += grub_script_argv_append (&result, arg->str);
|
||||
break;
|
||||
}
|
||||
arg = arg->next;
|
||||
}
|
||||
}
|
||||
|
||||
if (error)
|
||||
return 1;
|
||||
|
||||
if (! result.args[result.argc - 1])
|
||||
result.argc--;
|
||||
|
||||
*argv = result;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static grub_err_t
|
||||
grub_script_execute_cmd (struct grub_script_cmd *cmd)
|
||||
{
|
||||
|
@ -120,166 +253,23 @@ grub_script_execute_cmd (struct grub_script_cmd *cmd)
|
|||
return ret;
|
||||
}
|
||||
|
||||
#define ARG_ALLOCATION_UNIT (32 * sizeof (char))
|
||||
#define ARGV_ALLOCATION_UNIT (8 * sizeof (void*))
|
||||
|
||||
/* Expand arguments in ARGLIST into multiple arguments. */
|
||||
char **
|
||||
grub_script_execute_arglist_to_argv (struct grub_script_arglist *arglist, int *count)
|
||||
{
|
||||
int i;
|
||||
int oom;
|
||||
int argc;
|
||||
int empty;
|
||||
char *ptr;
|
||||
char **argv;
|
||||
char *value;
|
||||
struct grub_script_arg *arg;
|
||||
|
||||
auto void push (char *str);
|
||||
void push (char *str)
|
||||
{
|
||||
char **p;
|
||||
|
||||
if (oom)
|
||||
return;
|
||||
|
||||
p = grub_realloc (argv, ALIGN_UP (sizeof(char*) * (argc + 1), ARGV_ALLOCATION_UNIT));
|
||||
if (!p)
|
||||
oom = 1;
|
||||
else
|
||||
{
|
||||
p[argc++] = str;
|
||||
argv = p;
|
||||
}
|
||||
}
|
||||
|
||||
auto char* append (const char *str, grub_size_t nchar);
|
||||
char* append (const char *str, grub_size_t nchar)
|
||||
{
|
||||
int len;
|
||||
int old;
|
||||
char *p;
|
||||
|
||||
if (oom || !str)
|
||||
return 0;
|
||||
|
||||
len = nchar ?: grub_strlen (str);
|
||||
old = argv[argc - 1] ? grub_strlen (argv[argc - 1]) : 0;
|
||||
p = grub_realloc (argv[argc - 1], ALIGN_UP(old + len + 1, ARG_ALLOCATION_UNIT));
|
||||
|
||||
if (p)
|
||||
{
|
||||
grub_strncpy (p + old, str, len);
|
||||
p[old + len] = '\0';
|
||||
}
|
||||
else
|
||||
{
|
||||
oom = 1;
|
||||
grub_free (argv[argc - 1]);
|
||||
}
|
||||
argv[argc - 1] = p;
|
||||
return argv[argc - 1];
|
||||
}
|
||||
|
||||
/* Move *STR to the begining of next word, but return current word. */
|
||||
auto char* move_to_next (char **str);
|
||||
char* move_to_next (char **str)
|
||||
{
|
||||
char *end;
|
||||
char *start;
|
||||
|
||||
if (oom || !str || !*str)
|
||||
return 0;
|
||||
|
||||
start = *str;
|
||||
while (*start && grub_isspace (*start)) start++;
|
||||
if (*start == '\0')
|
||||
return 0;
|
||||
|
||||
end = start + 1;
|
||||
while (*end && !grub_isspace (*end)) end++;
|
||||
|
||||
*str = end;
|
||||
return start;
|
||||
}
|
||||
|
||||
oom = 0;
|
||||
argv = 0;
|
||||
argc = 0;
|
||||
push (0);
|
||||
for (; arglist; arglist = arglist->next)
|
||||
{
|
||||
empty = 1;
|
||||
arg = arglist->arg;
|
||||
while (arg)
|
||||
{
|
||||
switch (arg->type)
|
||||
{
|
||||
case GRUB_SCRIPT_ARG_TYPE_VAR:
|
||||
value = grub_script_env_get (arg->str);
|
||||
while (value && *value && (ptr = move_to_next(&value)))
|
||||
{
|
||||
empty = 0;
|
||||
append (ptr, value - ptr);
|
||||
if (*value) push(0);
|
||||
}
|
||||
break;
|
||||
|
||||
case GRUB_SCRIPT_ARG_TYPE_TEXT:
|
||||
if (grub_strlen (arg->str) > 0)
|
||||
{
|
||||
empty = 0;
|
||||
append (arg->str, 0);
|
||||
}
|
||||
break;
|
||||
|
||||
case GRUB_SCRIPT_ARG_TYPE_DQSTR:
|
||||
case GRUB_SCRIPT_ARG_TYPE_SQSTR:
|
||||
empty = 0;
|
||||
append (arg->str, 0);
|
||||
break;
|
||||
|
||||
case GRUB_SCRIPT_ARG_TYPE_DQVAR:
|
||||
empty = 0;
|
||||
append (grub_script_env_get (arg->str), 0);
|
||||
break;
|
||||
}
|
||||
arg = arg->next;
|
||||
}
|
||||
if (!empty)
|
||||
push (0);
|
||||
}
|
||||
|
||||
if (oom)
|
||||
{
|
||||
for (i = 0; i < argc; i++)
|
||||
grub_free (argv[i]);
|
||||
grub_free (argv);
|
||||
argv = 0;
|
||||
}
|
||||
|
||||
if (argv)
|
||||
*count = argc - 1;
|
||||
|
||||
return argv;
|
||||
}
|
||||
|
||||
/* Execute a function call. */
|
||||
grub_err_t
|
||||
grub_script_function_call (grub_script_function_t func, int argc, char **args)
|
||||
{
|
||||
grub_err_t ret = 0;
|
||||
struct grub_script_scope *old_scope;
|
||||
struct grub_script_scope new_scope;
|
||||
|
||||
new_scope.shift = 0;
|
||||
new_scope.argc = argc;
|
||||
new_scope.args = args;
|
||||
grub_list_push (GRUB_AS_LIST_P (&scope), GRUB_AS_LIST (&new_scope));
|
||||
new_scope.argv.argc = argc;
|
||||
new_scope.argv.args = args;
|
||||
|
||||
old_scope = scope;
|
||||
scope = &new_scope;
|
||||
|
||||
ret = grub_script_execute (func->func);
|
||||
|
||||
grub_list_pop (GRUB_AS_LIST_P (&scope));
|
||||
scope = old_scope;
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -288,21 +278,18 @@ grub_err_t
|
|||
grub_script_execute_cmdline (struct grub_script_cmd *cmd)
|
||||
{
|
||||
struct grub_script_cmdline *cmdline = (struct grub_script_cmdline *) cmd;
|
||||
char **args = 0;
|
||||
int i = 0;
|
||||
grub_command_t grubcmd;
|
||||
grub_err_t ret = 0;
|
||||
int argcount = 0;
|
||||
grub_script_function_t func = 0;
|
||||
char errnobuf[18];
|
||||
char *cmdname;
|
||||
struct grub_script_argv argv = { 0, 0 };
|
||||
|
||||
/* Lookup the command. */
|
||||
args = grub_script_execute_arglist_to_argv (cmdline->arglist, &argcount);
|
||||
if (!args)
|
||||
if (grub_script_arglist_to_argv (cmdline->arglist, &argv))
|
||||
return grub_errno;
|
||||
|
||||
cmdname = args[0];
|
||||
cmdname = argv.args[0];
|
||||
grubcmd = grub_command_find (cmdname);
|
||||
if (! grubcmd)
|
||||
{
|
||||
|
@ -339,14 +326,12 @@ grub_script_execute_cmdline (struct grub_script_cmd *cmd)
|
|||
|
||||
/* Execute the GRUB command or function. */
|
||||
if (grubcmd)
|
||||
ret = (grubcmd->func) (grubcmd, argcount - 1, args + 1);
|
||||
ret = (grubcmd->func) (grubcmd, argv.argc - 1, argv.args + 1);
|
||||
else
|
||||
ret = grub_script_function_call (func, argcount - 1, args + 1);
|
||||
ret = grub_script_function_call (func, argv.argc - 1, argv.args + 1);
|
||||
|
||||
/* Free arguments. */
|
||||
for (i = 0; i < argcount; i++)
|
||||
grub_free (args[i]);
|
||||
grub_free (args);
|
||||
grub_script_argv_free (&argv);
|
||||
|
||||
if (grub_errno == GRUB_ERR_TEST_FAILURE)
|
||||
grub_errno = GRUB_ERR_NONE;
|
||||
|
@ -383,7 +368,7 @@ grub_script_execute_cmdif (struct grub_script_cmd *cmd)
|
|||
/* Check if the commands results in a true or a false. The value is
|
||||
read from the env variable `?'. */
|
||||
grub_script_execute_cmd (cmdif->exec_to_evaluate);
|
||||
result = grub_script_env_get ("?");
|
||||
result = grub_env_get ("?");
|
||||
|
||||
grub_errno = GRUB_ERR_NONE;
|
||||
|
||||
|
@ -399,25 +384,22 @@ grub_script_execute_cmdif (struct grub_script_cmd *cmd)
|
|||
grub_err_t
|
||||
grub_script_execute_cmdfor (struct grub_script_cmd *cmd)
|
||||
{
|
||||
int i;
|
||||
unsigned i;
|
||||
int result;
|
||||
char **args;
|
||||
int argcount;
|
||||
struct grub_script_argv argv;
|
||||
struct grub_script_cmdfor *cmdfor = (struct grub_script_cmdfor *) cmd;
|
||||
|
||||
args = grub_script_execute_arglist_to_argv (cmdfor->words, &argcount);
|
||||
if (!args)
|
||||
if (grub_script_arglist_to_argv (cmdfor->words, &argv))
|
||||
return grub_errno;
|
||||
|
||||
result = 0;
|
||||
for (i = 0; i < argcount; i++)
|
||||
for (i = 0; i < argv.argc; i++)
|
||||
{
|
||||
grub_script_env_set (cmdfor->name->str, args[i]);
|
||||
grub_script_env_set (cmdfor->name->str, argv.args[i]);
|
||||
result = grub_script_execute_cmd (cmdfor->list);
|
||||
grub_free (args[i]);
|
||||
}
|
||||
|
||||
grub_free (args);
|
||||
grub_script_argv_free (&argv);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -446,26 +428,20 @@ grub_err_t
|
|||
grub_script_execute_menuentry (struct grub_script_cmd *cmd)
|
||||
{
|
||||
struct grub_script_cmd_menuentry *cmd_menuentry;
|
||||
char **args = 0;
|
||||
int argcount = 0;
|
||||
int i = 0;
|
||||
struct grub_script_argv argv = {0, 0};
|
||||
|
||||
cmd_menuentry = (struct grub_script_cmd_menuentry *) cmd;
|
||||
|
||||
if (cmd_menuentry->arglist)
|
||||
{
|
||||
args = grub_script_execute_arglist_to_argv (cmd_menuentry->arglist, &argcount);
|
||||
if (!args)
|
||||
if (grub_script_arglist_to_argv (cmd_menuentry->arglist, &argv))
|
||||
return grub_errno;
|
||||
}
|
||||
|
||||
grub_normal_add_menu_entry (argcount, (const char **) args,
|
||||
grub_normal_add_menu_entry (argv.argc, (const char **) argv.args,
|
||||
cmd_menuentry->sourcecode);
|
||||
|
||||
/* Free arguments. */
|
||||
for (i = 0; i < argcount; i++)
|
||||
grub_free (args[i]);
|
||||
grub_free (args);
|
||||
grub_script_argv_free (&argv);
|
||||
|
||||
return grub_errno;
|
||||
}
|
||||
|
|
|
@ -119,7 +119,7 @@ DIGITS [[:digit:]]+
|
|||
NAME [[:alpha:]_][[:alnum:][:digit:]_]*
|
||||
|
||||
ESC \\.
|
||||
SPECIAL \?|\#
|
||||
SPECIAL \?|\#|\*|\@
|
||||
VARIABLE ${NAME}|$\{{NAME}\}|${DIGITS}|$\{{DIGITS}\}|${SPECIAL}|$\{{SPECIAL}\}
|
||||
DQSTR \"([^\\\"]|{ESC})*\"
|
||||
SQSTR \'[^\']*\'
|
||||
|
|
|
@ -1,513 +0,0 @@
|
|||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2000,2001,2002,2003,2004,2005,2007,2008,2009 Free Software Foundation, Inc.
|
||||
*
|
||||
* GRUB 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* GRUB 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 GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
// TODO: Deprecated and broken. Needs to be converted to Video Driver!
|
||||
|
||||
#include <grub/machine/vga.h>
|
||||
#include <grub/machine/console.h>
|
||||
#include <grub/cpu/io.h>
|
||||
#include <grub/term.h>
|
||||
#include <grub/types.h>
|
||||
#include <grub/dl.h>
|
||||
#include <grub/misc.h>
|
||||
#include <grub/font.h>
|
||||
|
||||
#define DEBUG_VGA 0
|
||||
|
||||
#define VGA_WIDTH 640
|
||||
#define VGA_HEIGHT 350
|
||||
#define CHAR_WIDTH 8
|
||||
#define CHAR_HEIGHT 16
|
||||
#define TEXT_WIDTH (VGA_WIDTH / CHAR_WIDTH)
|
||||
#define TEXT_HEIGHT (VGA_HEIGHT / CHAR_HEIGHT)
|
||||
#define VGA_MEM ((grub_uint8_t *) GRUB_MEMORY_MACHINE_VGA_ADDR)
|
||||
#define PAGE_OFFSET(x) ((x) * (VGA_WIDTH * VGA_HEIGHT / 8))
|
||||
|
||||
#define DEFAULT_FG_COLOR 0xa
|
||||
#define DEFAULT_BG_COLOR 0x0
|
||||
|
||||
struct colored_char
|
||||
{
|
||||
/* An Unicode codepoint. */
|
||||
grub_uint32_t code;
|
||||
|
||||
/* 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;
|
||||
static int page = 0;
|
||||
static grub_font_t font = 0;
|
||||
|
||||
#define SEQUENCER_ADDR_PORT 0x3C4
|
||||
#define SEQUENCER_DATA_PORT 0x3C5
|
||||
#define MAP_MASK_REGISTER 0x02
|
||||
|
||||
#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. */
|
||||
while (! (grub_inb (INPUT_STATUS1_REGISTER) & INPUT_STATUS1_VERTR_BIT));
|
||||
}
|
||||
|
||||
/* Get Map Mask Register. */
|
||||
static unsigned char
|
||||
get_map_mask (void)
|
||||
{
|
||||
unsigned char old_addr;
|
||||
unsigned char old_data;
|
||||
|
||||
old_addr = grub_inb (SEQUENCER_ADDR_PORT);
|
||||
grub_outb (MAP_MASK_REGISTER, SEQUENCER_ADDR_PORT);
|
||||
|
||||
old_data = grub_inb (SEQUENCER_DATA_PORT);
|
||||
|
||||
grub_outb (old_addr, SEQUENCER_ADDR_PORT);
|
||||
|
||||
return old_data;
|
||||
}
|
||||
|
||||
/* Set Map Mask Register. */
|
||||
static void
|
||||
set_map_mask (unsigned char mask)
|
||||
{
|
||||
unsigned char old_addr;
|
||||
|
||||
old_addr = grub_inb (SEQUENCER_ADDR_PORT);
|
||||
grub_outb (MAP_MASK_REGISTER, SEQUENCER_ADDR_PORT);
|
||||
|
||||
grub_outb (mask, SEQUENCER_DATA_PORT);
|
||||
|
||||
grub_outb (old_addr, SEQUENCER_ADDR_PORT);
|
||||
}
|
||||
|
||||
/* Set Read Map Register. */
|
||||
static void
|
||||
set_read_map (unsigned char map)
|
||||
{
|
||||
unsigned char old_addr;
|
||||
|
||||
old_addr = grub_inb (GRAPHICS_ADDR_PORT);
|
||||
|
||||
grub_outb (READ_MAP_REGISTER, GRAPHICS_ADDR_PORT);
|
||||
grub_outb (map, GRAPHICS_DATA_PORT);
|
||||
|
||||
grub_outb (old_addr, GRAPHICS_ADDR_PORT);
|
||||
}
|
||||
|
||||
/* Set start address. */
|
||||
static void
|
||||
set_start_address (unsigned int start)
|
||||
{
|
||||
unsigned char old_addr;
|
||||
|
||||
old_addr = grub_inb (CRTC_ADDR_PORT);
|
||||
|
||||
grub_outb (START_ADDR_LOW_REGISTER, CRTC_ADDR_PORT);
|
||||
grub_outb (start & 0xFF, CRTC_DATA_PORT);
|
||||
|
||||
grub_outb (START_ADDR_HIGH_REGISTER, CRTC_ADDR_PORT);
|
||||
grub_outb (start >> 8, CRTC_DATA_PORT);
|
||||
|
||||
grub_outb (old_addr, CRTC_ADDR_PORT);
|
||||
}
|
||||
|
||||
static grub_err_t
|
||||
grub_vga_mod_init (void)
|
||||
{
|
||||
text_mode = grub_vga_set_mode (0x10);
|
||||
cursor_state = 1;
|
||||
fg_color = DEFAULT_FG_COLOR;
|
||||
bg_color = DEFAULT_BG_COLOR;
|
||||
saved_map_mask = get_map_mask ();
|
||||
set_map_mask (0x0f);
|
||||
set_start_address (PAGE_OFFSET (page));
|
||||
font = grub_font_get (""); /* Choose any font, for now. */
|
||||
if (!font)
|
||||
return grub_error (GRUB_ERR_BAD_FONT, "no font loaded");
|
||||
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
|
||||
static grub_err_t
|
||||
grub_vga_mod_fini (void)
|
||||
{
|
||||
set_map_mask (saved_map_mask);
|
||||
grub_vga_set_mode (text_mode);
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
|
||||
static int
|
||||
check_vga_mem (void *p)
|
||||
{
|
||||
return (p >= (void *) (VGA_MEM + PAGE_OFFSET (page))
|
||||
&& p <= (void *) (VGA_MEM + PAGE_OFFSET (page)
|
||||
+ VGA_WIDTH * VGA_HEIGHT / 8));
|
||||
}
|
||||
|
||||
static void
|
||||
write_char (void)
|
||||
{
|
||||
struct colored_char *p = text_buf + xpos + ypos * TEXT_WIDTH;
|
||||
struct grub_font_glyph *glyph;
|
||||
unsigned char *mem_base;
|
||||
unsigned plane;
|
||||
|
||||
mem_base = (VGA_MEM + xpos +
|
||||
ypos * CHAR_HEIGHT * TEXT_WIDTH + PAGE_OFFSET (page)) - p->index;
|
||||
p -= p->index;
|
||||
|
||||
/* Get glyph for character. */
|
||||
glyph = grub_font_get_glyph (font, p->code);
|
||||
|
||||
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)
|
||||
{
|
||||
/* TODO Re-implement glyph drawing for vga module. */
|
||||
#if 0
|
||||
unsigned i;
|
||||
|
||||
unsigned char_width = 1; /* TODO Figure out wide characters. */
|
||||
for (i = 0; i < char_width && offset < 32; i++)
|
||||
{
|
||||
unsigned char fg_mask, bg_mask;
|
||||
|
||||
fg_mask = (p->fg_color & plane) ? glyph->bitmap[offset] : 0;
|
||||
bg_mask = (p->bg_color & plane) ? ~(glyph->bitmap[offset]) : 0;
|
||||
offset++;
|
||||
|
||||
if (check_vga_mem (mem + i))
|
||||
mem[i] = (fg_mask | bg_mask);
|
||||
}
|
||||
#endif /* 0 */
|
||||
}
|
||||
}
|
||||
|
||||
set_map_mask (0x0f);
|
||||
}
|
||||
|
||||
static void
|
||||
write_cursor (void)
|
||||
{
|
||||
unsigned char *mem = (VGA_MEM + PAGE_OFFSET (page) + xpos
|
||||
+ (ypos * CHAR_HEIGHT + CHAR_HEIGHT - 3) * TEXT_WIDTH);
|
||||
if (check_vga_mem (mem))
|
||||
*mem = 0xff;
|
||||
|
||||
mem += TEXT_WIDTH;
|
||||
if (check_vga_mem (mem))
|
||||
*mem = 0xff;
|
||||
}
|
||||
|
||||
static void
|
||||
scroll_up (void)
|
||||
{
|
||||
unsigned i;
|
||||
unsigned plane;
|
||||
|
||||
/* Do all the work in the other page. */
|
||||
grub_memmove (text_buf, text_buf + TEXT_WIDTH,
|
||||
sizeof (struct colored_char) * TEXT_WIDTH * (TEXT_HEIGHT - 1));
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
for (plane = 1; plane <= 4; plane++)
|
||||
{
|
||||
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,
|
||||
VGA_WIDTH * (VGA_HEIGHT - CHAR_HEIGHT) / 8);
|
||||
}
|
||||
|
||||
set_map_mask (0x0f);
|
||||
grub_memset (VGA_MEM + PAGE_OFFSET (1 - page)
|
||||
+ VGA_WIDTH * (VGA_HEIGHT - CHAR_HEIGHT) / 8, 0,
|
||||
VGA_WIDTH * CHAR_HEIGHT / 8);
|
||||
|
||||
/* Activate the other page. */
|
||||
page = 1 - page;
|
||||
wait_vretrace ();
|
||||
set_start_address (PAGE_OFFSET (page));
|
||||
}
|
||||
|
||||
static void
|
||||
grub_vga_putchar (grub_uint32_t c)
|
||||
{
|
||||
#if DEBUG_VGA
|
||||
static int show = 1;
|
||||
#endif
|
||||
|
||||
if (c == '\a')
|
||||
/* FIXME */
|
||||
return;
|
||||
|
||||
if (c == '\b' || c == '\n' || c == '\r')
|
||||
{
|
||||
/* Erase current cursor, if any. */
|
||||
if (cursor_state)
|
||||
write_char ();
|
||||
|
||||
switch (c)
|
||||
{
|
||||
case '\b':
|
||||
if (xpos > 0)
|
||||
xpos--;
|
||||
break;
|
||||
|
||||
case '\n':
|
||||
if (ypos >= TEXT_HEIGHT - 1)
|
||||
scroll_up ();
|
||||
else
|
||||
ypos++;
|
||||
break;
|
||||
|
||||
case '\r':
|
||||
xpos = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
if (cursor_state)
|
||||
write_cursor ();
|
||||
}
|
||||
else
|
||||
{
|
||||
struct grub_font_glyph *glyph;
|
||||
struct colored_char *p;
|
||||
unsigned char_width = 1;
|
||||
|
||||
glyph = grub_font_get_glyph(font, c);
|
||||
|
||||
if (xpos + char_width > TEXT_WIDTH)
|
||||
grub_putchar ('\n');
|
||||
|
||||
p = text_buf + xpos + ypos * TEXT_WIDTH;
|
||||
p->code = c;
|
||||
p->fg_color = fg_color;
|
||||
p->bg_color = bg_color;
|
||||
p->width = char_width - 1;
|
||||
p->index = 0;
|
||||
|
||||
if (char_width > 1)
|
||||
{
|
||||
unsigned i;
|
||||
|
||||
for (i = 1; i < char_width; i++)
|
||||
{
|
||||
p[i].code = ' ';
|
||||
p[i].width = char_width - 1;
|
||||
p[i].index = i;
|
||||
}
|
||||
}
|
||||
|
||||
write_char ();
|
||||
|
||||
xpos += char_width;
|
||||
if (xpos >= TEXT_WIDTH)
|
||||
{
|
||||
xpos = 0;
|
||||
|
||||
if (ypos >= TEXT_HEIGHT - 1)
|
||||
scroll_up ();
|
||||
else
|
||||
ypos++;
|
||||
}
|
||||
|
||||
if (cursor_state)
|
||||
write_cursor ();
|
||||
}
|
||||
|
||||
#if DEBUG_VGA
|
||||
if (show)
|
||||
{
|
||||
grub_uint16_t pos = grub_getxy ();
|
||||
|
||||
show = 0;
|
||||
grub_gotoxy (0, 0);
|
||||
grub_printf ("[%u:%u]", (unsigned) (pos >> 8), (unsigned) (pos & 0xff));
|
||||
grub_gotoxy (pos >> 8, pos & 0xff);
|
||||
show = 1;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
static grub_ssize_t
|
||||
grub_vga_getcharwidth (grub_uint32_t c)
|
||||
{
|
||||
#if 0
|
||||
struct grub_font_glyph glyph;
|
||||
|
||||
glyph = grub_font_get_glyph (c);
|
||||
|
||||
return glyph.char_width;
|
||||
#else
|
||||
(void) c; /* Prevent warning. */
|
||||
return 1; /* TODO Fix wide characters? */
|
||||
#endif
|
||||
}
|
||||
|
||||
static grub_uint16_t
|
||||
grub_vga_getwh (void)
|
||||
{
|
||||
return (TEXT_WIDTH << 8) | TEXT_HEIGHT;
|
||||
}
|
||||
|
||||
static grub_uint16_t
|
||||
grub_vga_getxy (void)
|
||||
{
|
||||
return ((xpos << 8) | ypos);
|
||||
}
|
||||
|
||||
static void
|
||||
grub_vga_gotoxy (grub_uint8_t x, grub_uint8_t y)
|
||||
{
|
||||
if (x >= TEXT_WIDTH || y >= TEXT_HEIGHT)
|
||||
{
|
||||
grub_error (GRUB_ERR_OUT_OF_RANGE, "invalid point (%u,%u)",
|
||||
(unsigned) x, (unsigned) y);
|
||||
return;
|
||||
}
|
||||
|
||||
if (cursor_state)
|
||||
write_char ();
|
||||
|
||||
xpos = x;
|
||||
ypos = y;
|
||||
|
||||
if (cursor_state)
|
||||
write_cursor ();
|
||||
}
|
||||
|
||||
static void
|
||||
grub_vga_cls (void)
|
||||
{
|
||||
unsigned i;
|
||||
|
||||
wait_vretrace ();
|
||||
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;
|
||||
}
|
||||
|
||||
grub_memset (VGA_MEM + PAGE_OFFSET (page), 0, VGA_WIDTH * VGA_HEIGHT / 8);
|
||||
|
||||
xpos = ypos = 0;
|
||||
}
|
||||
|
||||
static void
|
||||
grub_vga_setcolorstate (grub_term_color_state state)
|
||||
{
|
||||
switch (state)
|
||||
{
|
||||
case GRUB_TERM_COLOR_STANDARD:
|
||||
case GRUB_TERM_COLOR_NORMAL:
|
||||
fg_color = DEFAULT_FG_COLOR;
|
||||
bg_color = DEFAULT_BG_COLOR;
|
||||
break;
|
||||
case GRUB_TERM_COLOR_HIGHLIGHT:
|
||||
fg_color = DEFAULT_BG_COLOR;
|
||||
bg_color = DEFAULT_FG_COLOR;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
grub_vga_setcursor (int on)
|
||||
{
|
||||
if (cursor_state != on)
|
||||
{
|
||||
if (cursor_state)
|
||||
write_char ();
|
||||
else
|
||||
write_cursor ();
|
||||
|
||||
cursor_state = on;
|
||||
}
|
||||
}
|
||||
|
||||
static struct grub_term_output grub_vga_term =
|
||||
{
|
||||
.name = "vga",
|
||||
.init = grub_vga_mod_init,
|
||||
.fini = grub_vga_mod_fini,
|
||||
.putchar = grub_vga_putchar,
|
||||
.getcharwidth = grub_vga_getcharwidth,
|
||||
.getwh = grub_vga_getwh,
|
||||
.getxy = grub_vga_getxy,
|
||||
.gotoxy = grub_vga_gotoxy,
|
||||
.cls = grub_vga_cls,
|
||||
.setcolorstate = grub_vga_setcolorstate,
|
||||
.setcursor = grub_vga_setcursor,
|
||||
.flags = 0,
|
||||
};
|
||||
|
||||
GRUB_MOD_INIT(vga)
|
||||
{
|
||||
grub_term_register_output ("vga", &grub_vga_term);
|
||||
}
|
||||
|
||||
GRUB_MOD_FINI(vga)
|
||||
{
|
||||
grub_term_unregister_output (&grub_vga_term);
|
||||
}
|
|
@ -16,6 +16,33 @@
|
|||
# You should have received a copy of the GNU General Public License
|
||||
# along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
# simple arguments
|
||||
echo one two three
|
||||
echo "one two three"
|
||||
echo 'one two three'
|
||||
|
||||
# empty arguments
|
||||
echo a "" b
|
||||
echo a '' b
|
||||
|
||||
echo a $foo b
|
||||
echo a ${foo} b
|
||||
|
||||
echo a "$foo" b
|
||||
echo a "${foo}" b
|
||||
|
||||
# multi-part arguments
|
||||
echo one"two"three
|
||||
echo one${two}three
|
||||
echo one"two"$three
|
||||
|
||||
echo one'two'three
|
||||
echo one${two}three
|
||||
echo one'two'$three
|
||||
|
||||
echo one'two'three"four"five${six}seven$eight
|
||||
|
||||
|
||||
foo=bar
|
||||
echo $foo ${foo}
|
||||
echo "$foo" "${foo}"
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
|
||||
echo parameter count
|
||||
function fcount {
|
||||
echo "$#"
|
||||
echo fcount "$#"
|
||||
}
|
||||
|
||||
fcount
|
||||
|
@ -27,7 +27,7 @@ fcount a b
|
|||
|
||||
echo parameter count, with nesting
|
||||
function ffcount {
|
||||
echo "$#"
|
||||
echo ffcount "$#"
|
||||
fcount
|
||||
fcount a
|
||||
fcount a b
|
||||
|
@ -39,9 +39,9 @@ ffcount 1 2
|
|||
|
||||
echo parameters
|
||||
function fparam {
|
||||
echo 1 $1
|
||||
echo 2 $2
|
||||
echo 3 $3
|
||||
echo fparam 1 $1
|
||||
echo fparam 2 $2
|
||||
echo fparam 3 $3
|
||||
}
|
||||
|
||||
fparam
|
||||
|
@ -50,9 +50,9 @@ fparam a b
|
|||
|
||||
echo parameters, with nesting
|
||||
function ffparam {
|
||||
echo 1 $1
|
||||
echo 2 $2
|
||||
echo 3 $3
|
||||
echo ffparam 1 $1
|
||||
echo ffparam 2 $2
|
||||
echo ffparam 3 $3
|
||||
fparam
|
||||
fparam a
|
||||
fparam a b
|
||||
|
@ -61,3 +61,87 @@ function ffparam {
|
|||
ffparam
|
||||
ffparam 1
|
||||
ffparam 1 2
|
||||
|
||||
echo parameter expansion with specials
|
||||
function fstar {
|
||||
for f in $*
|
||||
do
|
||||
echo fstar $f
|
||||
done
|
||||
|
||||
for f in aaa$*bbb
|
||||
do
|
||||
echo fstar $f
|
||||
done
|
||||
}
|
||||
|
||||
fstar
|
||||
fstar a
|
||||
fstar a "1 2"
|
||||
fstar a "1 2" b
|
||||
|
||||
function fdqstar {
|
||||
for f in "$*"
|
||||
do
|
||||
echo fdqstar $f
|
||||
done
|
||||
|
||||
for f in aaa"$*"bbb
|
||||
do
|
||||
echo fdqstar $f
|
||||
done
|
||||
|
||||
for f in "aaa$*bbb"
|
||||
do
|
||||
echo fdqstar $f
|
||||
done
|
||||
}
|
||||
|
||||
fdqstar
|
||||
fdqstar a
|
||||
fdqstar a "1 2"
|
||||
fdqstar a "1 2" b
|
||||
|
||||
function fat {
|
||||
for f in $@
|
||||
do
|
||||
echo fat $f
|
||||
done
|
||||
|
||||
for f in aaa$@bbb
|
||||
do
|
||||
echo fat $f
|
||||
done
|
||||
}
|
||||
|
||||
fat
|
||||
fat a
|
||||
fat a "1 2"
|
||||
fat a "1 2" b
|
||||
fat a "1 2" b "c d"
|
||||
fat a "1 2" b "c d" e
|
||||
|
||||
function fdqat {
|
||||
for f in "$@"
|
||||
do
|
||||
echo fdqat $f
|
||||
done
|
||||
|
||||
for f in aaa"$@"bbb
|
||||
do
|
||||
echo fdqat $f
|
||||
done
|
||||
|
||||
for f in "aaa$@bbb"
|
||||
do
|
||||
echo fdqat $f
|
||||
done
|
||||
}
|
||||
|
||||
# fdqat # this case needs special handling, lets ignore till we really need it.
|
||||
fdqat a
|
||||
fdqat a "1 2"
|
||||
fdqat a "1 2" b
|
||||
fdqat a "1 2" b "c d"
|
||||
fdqat a "1 2" b "c d" e
|
||||
|
||||
|
|
|
@ -22,24 +22,6 @@ function f1 {
|
|||
echo f1 $# $1 $2 $3
|
||||
}
|
||||
|
||||
function f2 {
|
||||
echo f2 $# $1 $2 $3
|
||||
shift 1
|
||||
echo f2 $# $1 $2 $3
|
||||
}
|
||||
|
||||
function f3 {
|
||||
echo f3 $# $1 $2 $3
|
||||
shift 3
|
||||
echo f3 $# $1 $2 $3
|
||||
}
|
||||
|
||||
function f4 {
|
||||
echo f4 $# $1 $2 $3
|
||||
shift 100
|
||||
echo f4 $# $1 $2 $3
|
||||
}
|
||||
|
||||
f1
|
||||
f1 a
|
||||
f1 a b
|
||||
|
@ -47,6 +29,12 @@ f1 a b c
|
|||
f1 a b c d
|
||||
f1 a b c d e
|
||||
|
||||
function f2 {
|
||||
echo f2 $# $1 $2 $3
|
||||
shift 1
|
||||
echo f2 $# $1 $2 $3
|
||||
}
|
||||
|
||||
f2
|
||||
f2 a
|
||||
f2 a b
|
||||
|
@ -54,6 +42,12 @@ f2 a b c
|
|||
f2 a b c d
|
||||
f2 a b c d e
|
||||
|
||||
function f3 {
|
||||
echo f3 $# $1 $2 $3
|
||||
shift 3
|
||||
echo f3 $# $1 $2 $3
|
||||
}
|
||||
|
||||
f3
|
||||
f3 a
|
||||
f3 a b
|
||||
|
@ -61,6 +55,12 @@ f3 a b c
|
|||
f3 a b c d
|
||||
f3 a b c d e
|
||||
|
||||
function f4 {
|
||||
echo f4 $# $1 $2 $3
|
||||
shift 100
|
||||
echo f4 $# $1 $2 $3
|
||||
}
|
||||
|
||||
f4
|
||||
f4 a
|
||||
f4 a b
|
||||
|
|
412
video/i386/pc/vga.c
Normal file
412
video/i386/pc/vga.c
Normal file
|
@ -0,0 +1,412 @@
|
|||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 2000,2001,2002,2003,2004,2005,2007,2008,2009,2010 Free Software Foundation, Inc.
|
||||
*
|
||||
* GRUB 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* GRUB 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 GRUB. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#define grub_video_render_target grub_video_fbrender_target
|
||||
|
||||
#include <grub/machine/vga.h>
|
||||
#include <grub/machine/console.h>
|
||||
#include <grub/cpu/io.h>
|
||||
#include <grub/mm.h>
|
||||
#include <grub/video.h>
|
||||
#include <grub/video_fb.h>
|
||||
#include <grub/types.h>
|
||||
#include <grub/dl.h>
|
||||
#include <grub/misc.h>
|
||||
|
||||
#define VGA_WIDTH 640
|
||||
#define VGA_HEIGHT 350
|
||||
#define VGA_MEM ((grub_uint8_t *) GRUB_MEMORY_MACHINE_VGA_ADDR)
|
||||
#define PAGE_OFFSET(x) ((x) * (VGA_WIDTH * VGA_HEIGHT / 8))
|
||||
|
||||
static unsigned char text_mode;
|
||||
static unsigned char saved_map_mask;
|
||||
|
||||
static struct
|
||||
{
|
||||
struct grub_video_mode_info mode_info;
|
||||
struct grub_video_render_target *render_target;
|
||||
grub_uint8_t *temporary_buffer;
|
||||
int front_page;
|
||||
int back_page;
|
||||
} framebuffer;
|
||||
|
||||
#define SEQUENCER_ADDR_PORT 0x3C4
|
||||
#define SEQUENCER_DATA_PORT 0x3C5
|
||||
#define MAP_MASK_REGISTER 0x02
|
||||
|
||||
#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. */
|
||||
while (! (grub_inb (INPUT_STATUS1_REGISTER) & INPUT_STATUS1_VERTR_BIT));
|
||||
}
|
||||
|
||||
/* Get Map Mask Register. */
|
||||
static unsigned char
|
||||
get_map_mask (void)
|
||||
{
|
||||
unsigned char old_addr;
|
||||
unsigned char old_data;
|
||||
|
||||
old_addr = grub_inb (SEQUENCER_ADDR_PORT);
|
||||
grub_outb (MAP_MASK_REGISTER, SEQUENCER_ADDR_PORT);
|
||||
|
||||
old_data = grub_inb (SEQUENCER_DATA_PORT);
|
||||
|
||||
grub_outb (old_addr, SEQUENCER_ADDR_PORT);
|
||||
|
||||
return old_data;
|
||||
}
|
||||
|
||||
/* Set Map Mask Register. */
|
||||
static void
|
||||
set_map_mask (unsigned char mask)
|
||||
{
|
||||
unsigned char old_addr;
|
||||
|
||||
old_addr = grub_inb (SEQUENCER_ADDR_PORT);
|
||||
grub_outb (MAP_MASK_REGISTER, SEQUENCER_ADDR_PORT);
|
||||
|
||||
grub_outb (mask, SEQUENCER_DATA_PORT);
|
||||
|
||||
grub_outb (old_addr, SEQUENCER_ADDR_PORT);
|
||||
}
|
||||
|
||||
#if 0
|
||||
/* Set Read Map Register. */
|
||||
static void
|
||||
set_read_map (unsigned char map)
|
||||
{
|
||||
unsigned char old_addr;
|
||||
|
||||
old_addr = grub_inb (GRAPHICS_ADDR_PORT);
|
||||
|
||||
grub_outb (READ_MAP_REGISTER, GRAPHICS_ADDR_PORT);
|
||||
grub_outb (map, GRAPHICS_DATA_PORT);
|
||||
|
||||
grub_outb (old_addr, GRAPHICS_ADDR_PORT);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Set start address. */
|
||||
static void
|
||||
set_start_address (unsigned int start)
|
||||
{
|
||||
unsigned char old_addr;
|
||||
|
||||
old_addr = grub_inb (CRTC_ADDR_PORT);
|
||||
|
||||
grub_outb (START_ADDR_LOW_REGISTER, CRTC_ADDR_PORT);
|
||||
grub_outb (start & 0xFF, CRTC_DATA_PORT);
|
||||
|
||||
grub_outb (START_ADDR_HIGH_REGISTER, CRTC_ADDR_PORT);
|
||||
grub_outb (start >> 8, CRTC_DATA_PORT);
|
||||
|
||||
grub_outb (old_addr, CRTC_ADDR_PORT);
|
||||
}
|
||||
|
||||
static int setup = 0;
|
||||
static int is_target = 0;
|
||||
|
||||
static grub_err_t
|
||||
grub_video_vga_init (void)
|
||||
{
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
|
||||
static grub_err_t
|
||||
grub_video_vga_setup (unsigned int width, unsigned int height,
|
||||
unsigned int mode_type, unsigned int mode_mask)
|
||||
{
|
||||
grub_err_t err;
|
||||
|
||||
if ((width && width != VGA_WIDTH) || (height && height != VGA_HEIGHT))
|
||||
return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "no matching mode found");
|
||||
|
||||
framebuffer.temporary_buffer = grub_malloc (VGA_HEIGHT * VGA_WIDTH);
|
||||
framebuffer.front_page = 0;
|
||||
framebuffer.back_page = 0;
|
||||
if (!framebuffer.temporary_buffer)
|
||||
return grub_errno;
|
||||
|
||||
saved_map_mask = get_map_mask ();
|
||||
|
||||
text_mode = grub_vga_set_mode (0x10);
|
||||
setup = 1;
|
||||
set_map_mask (0x0f);
|
||||
set_start_address (PAGE_OFFSET (framebuffer.front_page));
|
||||
|
||||
framebuffer.mode_info.width = VGA_WIDTH;
|
||||
framebuffer.mode_info.height = VGA_HEIGHT;
|
||||
|
||||
framebuffer.mode_info.mode_type = GRUB_VIDEO_MODE_TYPE_INDEX_COLOR;
|
||||
|
||||
if (grub_video_check_mode_flag (mode_type, mode_mask,
|
||||
GRUB_VIDEO_MODE_TYPE_DOUBLE_BUFFERED, 1))
|
||||
{
|
||||
framebuffer.back_page = 1;
|
||||
framebuffer.mode_info.mode_type |= GRUB_VIDEO_MODE_TYPE_DOUBLE_BUFFERED;
|
||||
}
|
||||
|
||||
framebuffer.mode_info.bpp = 8;
|
||||
framebuffer.mode_info.bytes_per_pixel = 1;
|
||||
framebuffer.mode_info.pitch = VGA_WIDTH;
|
||||
framebuffer.mode_info.number_of_colors = 16;
|
||||
framebuffer.mode_info.red_mask_size = 0;
|
||||
framebuffer.mode_info.red_field_pos = 0;
|
||||
framebuffer.mode_info.green_mask_size = 0;
|
||||
framebuffer.mode_info.green_field_pos = 0;
|
||||
framebuffer.mode_info.blue_mask_size = 0;
|
||||
framebuffer.mode_info.blue_field_pos = 0;
|
||||
framebuffer.mode_info.reserved_mask_size = 0;
|
||||
framebuffer.mode_info.reserved_field_pos = 0;
|
||||
|
||||
framebuffer.mode_info.blit_format
|
||||
= grub_video_get_blit_format (&framebuffer.mode_info);
|
||||
|
||||
err = grub_video_fb_create_render_target_from_pointer (&framebuffer.render_target,
|
||||
&framebuffer.mode_info,
|
||||
framebuffer.temporary_buffer);
|
||||
|
||||
if (err)
|
||||
{
|
||||
grub_dprintf ("video", "Couldn't create FB target\n");
|
||||
return err;
|
||||
}
|
||||
|
||||
is_target = 1;
|
||||
err = grub_video_fb_set_active_render_target (framebuffer.render_target);
|
||||
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
err = grub_video_fb_set_palette (0, GRUB_VIDEO_FBSTD_NUMCOLORS,
|
||||
grub_video_fbstd_colors);
|
||||
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
|
||||
static grub_err_t
|
||||
grub_video_vga_fini (void)
|
||||
{
|
||||
if (setup)
|
||||
{
|
||||
set_map_mask (saved_map_mask);
|
||||
grub_vga_set_mode (text_mode);
|
||||
}
|
||||
setup = 0;
|
||||
grub_free (framebuffer.temporary_buffer);
|
||||
framebuffer.temporary_buffer = 0;
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
|
||||
static inline void
|
||||
update_target (void)
|
||||
{
|
||||
int plane;
|
||||
|
||||
if (!is_target)
|
||||
return;
|
||||
|
||||
for (plane = 0x01; plane <= 0x08; plane <<= 1)
|
||||
{
|
||||
grub_uint8_t *ptr;
|
||||
volatile grub_uint8_t *ptr2;
|
||||
unsigned cbyte = 0;
|
||||
int shift = 7;
|
||||
set_map_mask (plane);
|
||||
for (ptr = framebuffer.temporary_buffer,
|
||||
ptr2 = VGA_MEM + PAGE_OFFSET (framebuffer.back_page);
|
||||
ptr < framebuffer.temporary_buffer + VGA_WIDTH * VGA_HEIGHT; ptr++)
|
||||
{
|
||||
cbyte |= (!!(plane & *ptr)) << shift;
|
||||
shift--;
|
||||
if (shift == -1)
|
||||
{
|
||||
*ptr2++ = cbyte;
|
||||
shift = 7;
|
||||
cbyte = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static grub_err_t
|
||||
grub_video_vga_blit_bitmap (struct grub_video_bitmap *bitmap,
|
||||
enum grub_video_blit_operators oper, int x, int y,
|
||||
int offset_x, int offset_y,
|
||||
unsigned int width, unsigned int height)
|
||||
{
|
||||
grub_err_t ret;
|
||||
ret = grub_video_fb_blit_bitmap (bitmap, oper, x, y, offset_x, offset_y,
|
||||
width, height);
|
||||
update_target ();
|
||||
return ret;
|
||||
}
|
||||
|
||||
static grub_err_t
|
||||
grub_video_vga_blit_render_target (struct grub_video_fbrender_target *source,
|
||||
enum grub_video_blit_operators oper,
|
||||
int x, int y, int offset_x, int offset_y,
|
||||
unsigned int width, unsigned int height)
|
||||
{
|
||||
grub_err_t ret;
|
||||
|
||||
ret = grub_video_fb_blit_render_target (source, oper, x, y,
|
||||
offset_x, offset_y, width, height);
|
||||
update_target ();
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static grub_err_t
|
||||
grub_video_vga_set_active_render_target (struct grub_video_render_target *target)
|
||||
{
|
||||
if (target == GRUB_VIDEO_RENDER_TARGET_DISPLAY)
|
||||
{
|
||||
is_target = 1;
|
||||
target = framebuffer.render_target;
|
||||
}
|
||||
else
|
||||
is_target = 0;
|
||||
|
||||
return grub_video_fb_set_active_render_target (target);
|
||||
}
|
||||
|
||||
static grub_err_t
|
||||
grub_video_vga_get_active_render_target (struct grub_video_render_target **target)
|
||||
{
|
||||
grub_err_t err;
|
||||
err = grub_video_fb_get_active_render_target (target);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
if (*target == framebuffer.render_target)
|
||||
*target = GRUB_VIDEO_RENDER_TARGET_DISPLAY;
|
||||
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
|
||||
static grub_err_t
|
||||
grub_video_vga_swap_buffers (void)
|
||||
{
|
||||
if (!(framebuffer.mode_info.mode_type & GRUB_VIDEO_MODE_TYPE_DOUBLE_BUFFERED))
|
||||
return GRUB_ERR_NONE;
|
||||
|
||||
/* Activate the other page. */
|
||||
framebuffer.front_page = !framebuffer.front_page;
|
||||
framebuffer.back_page = !framebuffer.back_page;
|
||||
wait_vretrace ();
|
||||
set_start_address (PAGE_OFFSET (framebuffer.front_page));
|
||||
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
|
||||
static grub_err_t
|
||||
grub_video_vga_set_palette (unsigned int start __attribute__ ((unused)),
|
||||
unsigned int count __attribute__ ((unused)),
|
||||
struct grub_video_palette_data *palette_data __attribute__ ((unused)))
|
||||
{
|
||||
return grub_error (GRUB_ERR_IO, "can't change palette");
|
||||
}
|
||||
|
||||
static grub_err_t
|
||||
grub_video_vga_get_info_and_fini (struct grub_video_mode_info *mode_info,
|
||||
void **framebuf)
|
||||
{
|
||||
set_map_mask (0xf);
|
||||
|
||||
grub_memcpy (mode_info, &(framebuffer.mode_info), sizeof (*mode_info));
|
||||
mode_info->bpp = 1;
|
||||
mode_info->bytes_per_pixel = 0;
|
||||
mode_info->pitch = VGA_WIDTH / 8;
|
||||
mode_info->number_of_colors = 1;
|
||||
|
||||
mode_info->bg_red = 0;
|
||||
mode_info->bg_green = 0;
|
||||
mode_info->bg_blue = 0;
|
||||
mode_info->bg_alpha = 255;
|
||||
|
||||
mode_info->fg_red = 255;
|
||||
mode_info->fg_green = 255;
|
||||
mode_info->fg_blue = 255;
|
||||
mode_info->fg_alpha = 255;
|
||||
|
||||
*framebuf = VGA_MEM + PAGE_OFFSET (framebuffer.front_page);
|
||||
|
||||
grub_video_fb_fini ();
|
||||
grub_free (framebuffer.temporary_buffer);
|
||||
framebuffer.temporary_buffer = 0;
|
||||
setup = 0;
|
||||
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
|
||||
|
||||
static struct grub_video_adapter grub_video_vga_adapter =
|
||||
{
|
||||
.name = "VGA Video Driver",
|
||||
.id = GRUB_VIDEO_DRIVER_VGA,
|
||||
|
||||
.init = grub_video_vga_init,
|
||||
.fini = grub_video_vga_fini,
|
||||
.setup = grub_video_vga_setup,
|
||||
.get_info = grub_video_fb_get_info,
|
||||
.get_info_and_fini = grub_video_vga_get_info_and_fini,
|
||||
.set_palette = grub_video_vga_set_palette,
|
||||
.get_palette = grub_video_fb_get_palette,
|
||||
.set_viewport = grub_video_fb_set_viewport,
|
||||
.get_viewport = grub_video_fb_get_viewport,
|
||||
.map_color = grub_video_fb_map_color,
|
||||
.map_rgb = grub_video_fb_map_rgb,
|
||||
.map_rgba = grub_video_fb_map_rgba,
|
||||
.unmap_color = grub_video_fb_unmap_color,
|
||||
.fill_rect = grub_video_fb_fill_rect,
|
||||
.blit_bitmap = grub_video_vga_blit_bitmap,
|
||||
.blit_render_target = grub_video_vga_blit_render_target,
|
||||
.scroll = grub_video_fb_scroll,
|
||||
.swap_buffers = grub_video_vga_swap_buffers,
|
||||
.create_render_target = grub_video_fb_create_render_target,
|
||||
.delete_render_target = grub_video_fb_delete_render_target,
|
||||
.set_active_render_target = grub_video_vga_set_active_render_target,
|
||||
.get_active_render_target = grub_video_vga_get_active_render_target,
|
||||
|
||||
.next = 0
|
||||
};
|
||||
|
||||
GRUB_MOD_INIT(vga)
|
||||
{
|
||||
grub_video_register (&grub_video_vga_adapter);
|
||||
}
|
||||
|
||||
GRUB_MOD_FINI(vga)
|
||||
{
|
||||
grub_video_unregister (&grub_video_vga_adapter);
|
||||
}
|
Loading…
Reference in a new issue