merge with mainline
This commit is contained in:
commit
e57a453ad1
217 changed files with 35601 additions and 4892 deletions
|
@ -122,7 +122,7 @@ grub_core_cmd_ls (struct grub_command *cmd __attribute__ ((unused)),
|
|||
if (argc < 1)
|
||||
{
|
||||
grub_device_iterate (grub_mini_print_devices);
|
||||
grub_putchar ('\n');
|
||||
grub_xputs ("\n");
|
||||
grub_refresh ();
|
||||
}
|
||||
else
|
||||
|
@ -161,7 +161,7 @@ grub_core_cmd_ls (struct grub_command *cmd __attribute__ ((unused)),
|
|||
else if (fs)
|
||||
{
|
||||
(fs->dir) (dev, path, grub_mini_print_files);
|
||||
grub_putchar ('\n');
|
||||
grub_xputs ("\n");
|
||||
grub_refresh ();
|
||||
}
|
||||
|
||||
|
|
49
kern/dl.c
49
kern/dl.c
|
@ -39,31 +39,17 @@
|
|||
|
||||
|
||||
|
||||
struct grub_dl_list
|
||||
{
|
||||
struct grub_dl_list *next;
|
||||
grub_dl_t mod;
|
||||
};
|
||||
typedef struct grub_dl_list *grub_dl_list_t;
|
||||
|
||||
static grub_dl_list_t grub_dl_head;
|
||||
grub_dl_t grub_dl_head = 0;
|
||||
|
||||
static grub_err_t
|
||||
grub_dl_add (grub_dl_t mod)
|
||||
{
|
||||
grub_dl_list_t l;
|
||||
|
||||
if (grub_dl_get (mod->name))
|
||||
return grub_error (GRUB_ERR_BAD_MODULE,
|
||||
"`%s' is already loaded", mod->name);
|
||||
|
||||
l = (grub_dl_list_t) grub_malloc (sizeof (*l));
|
||||
if (! l)
|
||||
return grub_errno;
|
||||
|
||||
l->mod = mod;
|
||||
l->next = grub_dl_head;
|
||||
grub_dl_head = l;
|
||||
mod->next = grub_dl_head;
|
||||
grub_dl_head = mod;
|
||||
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
|
@ -71,13 +57,12 @@ grub_dl_add (grub_dl_t mod)
|
|||
static void
|
||||
grub_dl_remove (grub_dl_t mod)
|
||||
{
|
||||
grub_dl_list_t *p, q;
|
||||
grub_dl_t *p, q;
|
||||
|
||||
for (p = &grub_dl_head, q = *p; q; p = &q->next, q = *p)
|
||||
if (q->mod == mod)
|
||||
if (q == mod)
|
||||
{
|
||||
*p = q->next;
|
||||
grub_free (q);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -85,25 +70,15 @@ grub_dl_remove (grub_dl_t mod)
|
|||
grub_dl_t
|
||||
grub_dl_get (const char *name)
|
||||
{
|
||||
grub_dl_list_t l;
|
||||
grub_dl_t l;
|
||||
|
||||
for (l = grub_dl_head; l; l = l->next)
|
||||
if (grub_strcmp (name, l->mod->name) == 0)
|
||||
return l->mod;
|
||||
if (grub_strcmp (name, l->name) == 0)
|
||||
return l;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
grub_dl_iterate (int (*hook) (grub_dl_t mod))
|
||||
{
|
||||
grub_dl_list_t l;
|
||||
|
||||
for (l = grub_dl_head; l; l = l->next)
|
||||
if (hook (l->mod))
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
|
||||
struct grub_symbol
|
||||
|
@ -694,11 +669,11 @@ grub_dl_unload_unneeded (void)
|
|||
{
|
||||
/* Because grub_dl_remove modifies the list of modules, this
|
||||
implementation is tricky. */
|
||||
grub_dl_list_t p = grub_dl_head;
|
||||
grub_dl_t p = grub_dl_head;
|
||||
|
||||
while (p)
|
||||
{
|
||||
if (grub_dl_unload (p->mod))
|
||||
if (grub_dl_unload (p))
|
||||
{
|
||||
p = grub_dl_head;
|
||||
continue;
|
||||
|
@ -714,13 +689,13 @@ grub_dl_unload_all (void)
|
|||
{
|
||||
while (grub_dl_head)
|
||||
{
|
||||
grub_dl_list_t p;
|
||||
grub_dl_t p;
|
||||
|
||||
grub_dl_unload_unneeded ();
|
||||
|
||||
/* Force to decrement the ref count. This will purge pre-loaded
|
||||
modules and manually inserted modules. */
|
||||
for (p = grub_dl_head; p; p = p->next)
|
||||
p->mod->ref_count--;
|
||||
p->ref_count--;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -170,6 +170,7 @@ grub_reboot (void)
|
|||
grub_efi_fini ();
|
||||
efi_call_4 (grub_efi_system_table->runtime_services->reset_system,
|
||||
GRUB_EFI_RESET_COLD, GRUB_EFI_SUCCESS, 0, NULL);
|
||||
for (;;) ;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -179,6 +180,7 @@ grub_halt (void)
|
|||
grub_efi_fini ();
|
||||
efi_call_4 (grub_efi_system_table->runtime_services->reset_system,
|
||||
GRUB_EFI_RESET_SHUTDOWN, GRUB_EFI_SUCCESS, 0, NULL);
|
||||
for (;;) ;
|
||||
}
|
||||
|
||||
int
|
||||
|
|
|
@ -36,6 +36,9 @@ grub_efi_init (void)
|
|||
/* Initialize the memory management system. */
|
||||
grub_efi_mm_init ();
|
||||
|
||||
efi_call_4 (grub_efi_system_table->boot_services->set_watchdog_timer,
|
||||
0, 0, 0, NULL);
|
||||
|
||||
grub_efidisk_init ();
|
||||
}
|
||||
|
||||
|
|
|
@ -346,6 +346,7 @@ grub_efi_mm_init (void)
|
|||
grub_efi_uintn_t desc_size;
|
||||
grub_efi_uint64_t total_pages;
|
||||
grub_efi_uint64_t required_pages;
|
||||
int mm_status;
|
||||
|
||||
/* First of all, allocate pages to maintain allocations. */
|
||||
allocated_pages
|
||||
|
@ -361,16 +362,32 @@ grub_efi_mm_init (void)
|
|||
if (! memory_map)
|
||||
grub_fatal ("cannot allocate memory");
|
||||
|
||||
filtered_memory_map = NEXT_MEMORY_DESCRIPTOR (memory_map, MEMORY_MAP_SIZE);
|
||||
|
||||
/* Obtain descriptors for available memory. */
|
||||
map_size = MEMORY_MAP_SIZE;
|
||||
|
||||
if (grub_efi_get_memory_map (&map_size, memory_map, 0, &desc_size, 0) < 0)
|
||||
mm_status = grub_efi_get_memory_map (&map_size, memory_map, 0, &desc_size, 0);
|
||||
|
||||
if (mm_status == 0)
|
||||
{
|
||||
grub_efi_free_pages
|
||||
((grub_efi_physical_address_t) ((grub_addr_t) memory_map),
|
||||
2 * BYTES_TO_PAGES (MEMORY_MAP_SIZE));
|
||||
|
||||
memory_map = grub_efi_allocate_pages (0, 2 * BYTES_TO_PAGES (map_size));
|
||||
if (! memory_map)
|
||||
grub_fatal ("cannot allocate memory");
|
||||
|
||||
mm_status = grub_efi_get_memory_map (&map_size, memory_map, 0,
|
||||
&desc_size, 0);
|
||||
}
|
||||
|
||||
if (mm_status < 0)
|
||||
grub_fatal ("cannot get memory map");
|
||||
|
||||
memory_map_end = NEXT_MEMORY_DESCRIPTOR (memory_map, map_size);
|
||||
|
||||
filtered_memory_map = memory_map_end;
|
||||
|
||||
filtered_memory_map_end = filter_memory_map (memory_map, filtered_memory_map,
|
||||
desc_size, memory_map_end);
|
||||
|
||||
|
|
|
@ -43,9 +43,7 @@ static int grub_console_attr = A_NORMAL;
|
|||
|
||||
grub_uint8_t grub_console_cur_color = 7;
|
||||
|
||||
static grub_uint8_t grub_console_standard_color = 0x7;
|
||||
static grub_uint8_t grub_console_normal_color = 0x7;
|
||||
static grub_uint8_t grub_console_highlight_color = 0x70;
|
||||
static const grub_uint8_t grub_console_standard_color = 0x7;
|
||||
|
||||
#define NUM_COLORS 8
|
||||
|
||||
|
@ -64,60 +62,15 @@ static grub_uint8_t color_map[NUM_COLORS] =
|
|||
static int use_color;
|
||||
|
||||
static void
|
||||
grub_ncurses_putchar (grub_uint32_t c)
|
||||
grub_ncurses_putchar (struct grub_term_output *term __attribute__ ((unused)),
|
||||
const struct grub_unicode_glyph *c)
|
||||
{
|
||||
/* Better than nothing. */
|
||||
switch (c)
|
||||
{
|
||||
case GRUB_TERM_DISP_LEFT:
|
||||
c = '<';
|
||||
break;
|
||||
|
||||
case GRUB_TERM_DISP_UP:
|
||||
c = '^';
|
||||
break;
|
||||
|
||||
case GRUB_TERM_DISP_RIGHT:
|
||||
c = '>';
|
||||
break;
|
||||
|
||||
case GRUB_TERM_DISP_DOWN:
|
||||
c = 'v';
|
||||
break;
|
||||
|
||||
case GRUB_TERM_DISP_HLINE:
|
||||
c = '-';
|
||||
break;
|
||||
|
||||
case GRUB_TERM_DISP_VLINE:
|
||||
c = '|';
|
||||
break;
|
||||
|
||||
case GRUB_TERM_DISP_UL:
|
||||
case GRUB_TERM_DISP_UR:
|
||||
case GRUB_TERM_DISP_LL:
|
||||
case GRUB_TERM_DISP_LR:
|
||||
c = '+';
|
||||
break;
|
||||
|
||||
default:
|
||||
/* ncurses does not support Unicode. */
|
||||
if (c > 0x7f)
|
||||
c = '?';
|
||||
break;
|
||||
}
|
||||
|
||||
addch (c | grub_console_attr);
|
||||
}
|
||||
|
||||
static grub_ssize_t
|
||||
grub_ncurses_getcharwidth (grub_uint32_t code __attribute__ ((unused)))
|
||||
{
|
||||
return 1;
|
||||
addch (c->base | grub_console_attr);
|
||||
}
|
||||
|
||||
static void
|
||||
grub_ncurses_setcolorstate (grub_term_color_state state)
|
||||
grub_ncurses_setcolorstate (struct grub_term_output *term,
|
||||
grub_term_color_state state)
|
||||
{
|
||||
switch (state)
|
||||
{
|
||||
|
@ -126,11 +79,11 @@ grub_ncurses_setcolorstate (grub_term_color_state state)
|
|||
grub_console_attr = A_NORMAL;
|
||||
break;
|
||||
case GRUB_TERM_COLOR_NORMAL:
|
||||
grub_console_cur_color = grub_console_normal_color;
|
||||
grub_console_cur_color = term->normal_color;
|
||||
grub_console_attr = A_NORMAL;
|
||||
break;
|
||||
case GRUB_TERM_COLOR_HIGHLIGHT:
|
||||
grub_console_cur_color = grub_console_highlight_color;
|
||||
grub_console_cur_color = term->highlight_color;
|
||||
grub_console_attr = A_STANDOUT;
|
||||
break;
|
||||
default:
|
||||
|
@ -149,25 +102,10 @@ grub_ncurses_setcolorstate (grub_term_color_state state)
|
|||
}
|
||||
}
|
||||
|
||||
/* XXX: This function is never called. */
|
||||
static void
|
||||
grub_ncurses_setcolor (grub_uint8_t normal_color, grub_uint8_t highlight_color)
|
||||
{
|
||||
grub_console_normal_color = normal_color;
|
||||
grub_console_highlight_color = highlight_color;
|
||||
}
|
||||
|
||||
static void
|
||||
grub_ncurses_getcolor (grub_uint8_t *normal_color, grub_uint8_t *highlight_color)
|
||||
{
|
||||
*normal_color = grub_console_normal_color;
|
||||
*highlight_color = grub_console_highlight_color;
|
||||
}
|
||||
|
||||
static int saved_char = ERR;
|
||||
|
||||
static int
|
||||
grub_ncurses_checkkey (void)
|
||||
grub_ncurses_checkkey (struct grub_term_input *term __attribute__ ((unused)))
|
||||
{
|
||||
int c;
|
||||
|
||||
|
@ -189,7 +127,7 @@ grub_ncurses_checkkey (void)
|
|||
}
|
||||
|
||||
static int
|
||||
grub_ncurses_getkey (void)
|
||||
grub_ncurses_getkey (struct grub_term_input *term __attribute__ ((unused)))
|
||||
{
|
||||
int c;
|
||||
|
||||
|
@ -208,19 +146,19 @@ grub_ncurses_getkey (void)
|
|||
switch (c)
|
||||
{
|
||||
case KEY_LEFT:
|
||||
c = 2;
|
||||
c = GRUB_TERM_LEFT;
|
||||
break;
|
||||
|
||||
case KEY_RIGHT:
|
||||
c = 6;
|
||||
c = GRUB_TERM_RIGHT;
|
||||
break;
|
||||
|
||||
case KEY_UP:
|
||||
c = 16;
|
||||
c = GRUB_TERM_UP;
|
||||
break;
|
||||
|
||||
case KEY_DOWN:
|
||||
c = 14;
|
||||
c = GRUB_TERM_DOWN;
|
||||
break;
|
||||
|
||||
case KEY_IC:
|
||||
|
@ -228,30 +166,30 @@ grub_ncurses_getkey (void)
|
|||
break;
|
||||
|
||||
case KEY_DC:
|
||||
c = 4;
|
||||
c = GRUB_TERM_DC;
|
||||
break;
|
||||
|
||||
case KEY_BACKSPACE:
|
||||
/* XXX: For some reason ncurses on xterm does not return
|
||||
KEY_BACKSPACE. */
|
||||
case 127:
|
||||
c = 8;
|
||||
c = GRUB_TERM_BACKSPACE;
|
||||
break;
|
||||
|
||||
case KEY_HOME:
|
||||
c = 1;
|
||||
c = GRUB_TERM_HOME;
|
||||
break;
|
||||
|
||||
case KEY_END:
|
||||
c = 5;
|
||||
c = GRUB_TERM_END;
|
||||
break;
|
||||
|
||||
case KEY_NPAGE:
|
||||
c = 3;
|
||||
c = GRUB_TERM_NPAGE;
|
||||
break;
|
||||
|
||||
case KEY_PPAGE:
|
||||
c = 7;
|
||||
c = GRUB_TERM_PPAGE;
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -259,7 +197,7 @@ grub_ncurses_getkey (void)
|
|||
}
|
||||
|
||||
static grub_uint16_t
|
||||
grub_ncurses_getxy (void)
|
||||
grub_ncurses_getxy (struct grub_term_output *term __attribute__ ((unused)))
|
||||
{
|
||||
int x;
|
||||
int y;
|
||||
|
@ -270,7 +208,7 @@ grub_ncurses_getxy (void)
|
|||
}
|
||||
|
||||
static grub_uint16_t
|
||||
grub_ncurses_getwh (void)
|
||||
grub_ncurses_getwh (struct grub_term_output *term __attribute__ ((unused)))
|
||||
{
|
||||
int x;
|
||||
int y;
|
||||
|
@ -281,32 +219,34 @@ grub_ncurses_getwh (void)
|
|||
}
|
||||
|
||||
static void
|
||||
grub_ncurses_gotoxy (grub_uint8_t x, grub_uint8_t y)
|
||||
grub_ncurses_gotoxy (struct grub_term_output *term __attribute__ ((unused)),
|
||||
grub_uint8_t x, grub_uint8_t y)
|
||||
{
|
||||
move (y, x);
|
||||
}
|
||||
|
||||
static void
|
||||
grub_ncurses_cls (void)
|
||||
grub_ncurses_cls (struct grub_term_output *term __attribute__ ((unused)))
|
||||
{
|
||||
clear ();
|
||||
refresh ();
|
||||
}
|
||||
|
||||
static void
|
||||
grub_ncurses_setcursor (int on)
|
||||
grub_ncurses_setcursor (struct grub_term_output *term __attribute__ ((unused)),
|
||||
int on)
|
||||
{
|
||||
curs_set (on ? 1 : 0);
|
||||
}
|
||||
|
||||
static void
|
||||
grub_ncurses_refresh (void)
|
||||
grub_ncurses_refresh (struct grub_term_output *term __attribute__ ((unused)))
|
||||
{
|
||||
refresh ();
|
||||
}
|
||||
|
||||
static grub_err_t
|
||||
grub_ncurses_init (void)
|
||||
grub_ncurses_init (struct grub_term_output *term __attribute__ ((unused)))
|
||||
{
|
||||
initscr ();
|
||||
raw ();
|
||||
|
@ -338,7 +278,7 @@ grub_ncurses_init (void)
|
|||
}
|
||||
|
||||
static grub_err_t
|
||||
grub_ncurses_fini (void)
|
||||
grub_ncurses_fini (struct grub_term_output *term __attribute__ ((unused)))
|
||||
{
|
||||
endwin ();
|
||||
return 0;
|
||||
|
@ -358,16 +298,14 @@ static struct grub_term_output grub_ncurses_term_output =
|
|||
.init = grub_ncurses_init,
|
||||
.fini = grub_ncurses_fini,
|
||||
.putchar = grub_ncurses_putchar,
|
||||
.getcharwidth = grub_ncurses_getcharwidth,
|
||||
.getxy = grub_ncurses_getxy,
|
||||
.getwh = grub_ncurses_getwh,
|
||||
.gotoxy = grub_ncurses_gotoxy,
|
||||
.cls = grub_ncurses_cls,
|
||||
.setcolorstate = grub_ncurses_setcolorstate,
|
||||
.setcolor = grub_ncurses_setcolor,
|
||||
.getcolor = grub_ncurses_getcolor,
|
||||
.setcursor = grub_ncurses_setcursor,
|
||||
.refresh = grub_ncurses_refresh
|
||||
.refresh = grub_ncurses_refresh,
|
||||
.flags = GRUB_TERM_CODE_TYPE_ASCII
|
||||
};
|
||||
|
||||
void
|
||||
|
@ -380,5 +318,5 @@ grub_console_init (void)
|
|||
void
|
||||
grub_console_fini (void)
|
||||
{
|
||||
grub_ncurses_fini ();
|
||||
grub_ncurses_fini (&grub_ncurses_term_output);
|
||||
}
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
#include <hurd.h>
|
||||
#include <hurd/lookup.h>
|
||||
#include <hurd/fs.h>
|
||||
#include <sys/mman.h>
|
||||
#endif
|
||||
|
||||
#include <grub/mm.h>
|
||||
|
|
|
@ -342,7 +342,7 @@ find_partition_start (const char *dev)
|
|||
# endif /* !defined(__NetBSD__) */
|
||||
|
||||
# ifdef HAVE_DEVICE_MAPPER
|
||||
if (device_is_mapped (dev)) {
|
||||
if (grub_device_mapper_supported () && device_is_mapped (dev)) {
|
||||
struct dm_task *task = NULL;
|
||||
grub_uint64_t start, length;
|
||||
char *target_type, *params, *space;
|
||||
|
@ -992,6 +992,11 @@ grub_util_biosdisk_fini (void)
|
|||
grub_disk_dev_unregister (&grub_util_biosdisk_dev);
|
||||
}
|
||||
|
||||
/*
|
||||
* Note: we do not use the new partition naming scheme as dos_part does not
|
||||
* necessarily correspond to an msdos partition. See e.g. the FreeBSD code
|
||||
* in function grub_util_biosdisk_get_grub_dev.
|
||||
*/
|
||||
static char *
|
||||
make_device_name (int drive, int dos_part, int bsd_part)
|
||||
{
|
||||
|
@ -1255,7 +1260,7 @@ devmapper_out:
|
|||
for (p = path + 5; *p; ++p)
|
||||
if (grub_isdigit(*p))
|
||||
{
|
||||
p = strchr (p, 's');
|
||||
p = strpbrk (p, "sp");
|
||||
if (p)
|
||||
*p = '\0';
|
||||
break;
|
||||
|
@ -1400,11 +1405,9 @@ grub_util_biosdisk_get_grub_dev (const char *os_dev)
|
|||
For NetBSD, proceed as for Linux, except that the start sector is
|
||||
obtained from the disk label. */
|
||||
{
|
||||
char *name;
|
||||
char *name, *partname;
|
||||
grub_disk_t disk;
|
||||
grub_disk_addr_t start;
|
||||
int dos_part = -1;
|
||||
int bsd_part = -1;
|
||||
auto int find_partition (grub_disk_t dsk,
|
||||
const grub_partition_t partition);
|
||||
|
||||
|
@ -1419,17 +1422,7 @@ grub_util_biosdisk_get_grub_dev (const char *os_dev)
|
|||
|
||||
if (start == part_start)
|
||||
{
|
||||
if (partition->parent)
|
||||
{
|
||||
dos_part = partition->parent->number;
|
||||
bsd_part = partition->number;
|
||||
}
|
||||
else
|
||||
{
|
||||
dos_part = partition->number;
|
||||
bsd_part = -1;
|
||||
}
|
||||
|
||||
partname = grub_partition_get_name (partition);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -1465,6 +1458,7 @@ grub_util_biosdisk_get_grub_dev (const char *os_dev)
|
|||
if (! disk)
|
||||
return 0;
|
||||
|
||||
partname = NULL;
|
||||
grub_partition_iterate (disk, find_partition);
|
||||
if (grub_errno != GRUB_ERR_NONE)
|
||||
{
|
||||
|
@ -1472,7 +1466,7 @@ grub_util_biosdisk_get_grub_dev (const char *os_dev)
|
|||
return 0;
|
||||
}
|
||||
|
||||
if (dos_part < 0)
|
||||
if (partname == NULL)
|
||||
{
|
||||
grub_disk_close (disk);
|
||||
grub_error (GRUB_ERR_BAD_DEVICE,
|
||||
|
@ -1480,7 +1474,9 @@ grub_util_biosdisk_get_grub_dev (const char *os_dev)
|
|||
return 0;
|
||||
}
|
||||
|
||||
return make_device_name (drive, dos_part, bsd_part);
|
||||
name = grub_xasprintf ("%s,%s", disk->name, partname);
|
||||
free (partname);
|
||||
return name;
|
||||
}
|
||||
|
||||
#elif defined(__GNU__)
|
||||
|
@ -1511,7 +1507,7 @@ grub_util_biosdisk_get_grub_dev (const char *os_dev)
|
|||
}
|
||||
|
||||
#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__APPLE__)
|
||||
/* FreeBSD uses "/dev/[a-z]+[0-9]+(s[0-9]+[a-z]?)?". */
|
||||
/* FreeBSD uses "/dev/[a-z]+[0-9]+([sp][0-9]+[a-z]?)?". */
|
||||
{
|
||||
int dos_part = -1;
|
||||
int bsd_part = -1;
|
||||
|
@ -1525,7 +1521,7 @@ grub_util_biosdisk_get_grub_dev (const char *os_dev)
|
|||
for (p = os_dev + 5; *p; ++p)
|
||||
if (grub_isdigit(*p))
|
||||
{
|
||||
p = strchr (p, 's');
|
||||
p = strpbrk (p, "sp"); /* msdos or apple (or ... ?) partition map */
|
||||
if (p)
|
||||
{
|
||||
p++;
|
||||
|
|
|
@ -22,6 +22,10 @@
|
|||
#include <grub/time.h>
|
||||
#include <grub/emu/misc.h>
|
||||
|
||||
#ifdef HAVE_DEVICE_MAPPER
|
||||
# include <libdevmapper.h>
|
||||
#endif
|
||||
|
||||
int verbosity;
|
||||
|
||||
void
|
||||
|
@ -311,3 +315,38 @@ grub_make_system_path_relative_to_its_root (const char *path)
|
|||
|
||||
return buf3;
|
||||
}
|
||||
|
||||
#ifdef HAVE_DEVICE_MAPPER
|
||||
static void device_mapper_null_log (int level __attribute__ ((unused)),
|
||||
const char *file __attribute__ ((unused)),
|
||||
int line __attribute__ ((unused)),
|
||||
int dm_errno __attribute__ ((unused)),
|
||||
const char *f __attribute__ ((unused)),
|
||||
...)
|
||||
{
|
||||
}
|
||||
|
||||
int
|
||||
grub_device_mapper_supported (void)
|
||||
{
|
||||
static int supported = -1;
|
||||
|
||||
if (supported == -1)
|
||||
{
|
||||
struct dm_task *dmt;
|
||||
|
||||
/* Suppress annoying log messages. */
|
||||
dm_log_with_errno_init (&device_mapper_null_log);
|
||||
|
||||
dmt = dm_task_create (DM_DEVICE_VERSION);
|
||||
supported = (dmt != NULL);
|
||||
if (dmt)
|
||||
dm_task_destroy (dmt);
|
||||
|
||||
/* Restore the original logger. */
|
||||
dm_log_with_errno_init (NULL);
|
||||
}
|
||||
|
||||
return supported;
|
||||
}
|
||||
#endif /* HAVE_DEVICE_MAPPER */
|
||||
|
|
32
kern/fs.c
32
kern/fs.c
|
@ -27,40 +27,10 @@
|
|||
#include <grub/mm.h>
|
||||
#include <grub/term.h>
|
||||
|
||||
static grub_fs_t grub_fs_list;
|
||||
grub_fs_t grub_fs_list = 0;
|
||||
|
||||
grub_fs_autoload_hook_t grub_fs_autoload_hook = 0;
|
||||
|
||||
void
|
||||
grub_fs_register (grub_fs_t fs)
|
||||
{
|
||||
fs->next = grub_fs_list;
|
||||
grub_fs_list = fs;
|
||||
}
|
||||
|
||||
void
|
||||
grub_fs_unregister (grub_fs_t fs)
|
||||
{
|
||||
grub_fs_t *p, q;
|
||||
|
||||
for (p = &grub_fs_list, q = *p; q; p = &(q->next), q = q->next)
|
||||
if (q == fs)
|
||||
{
|
||||
*p = q->next;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
grub_fs_iterate (int (*hook) (const grub_fs_t fs))
|
||||
{
|
||||
grub_fs_t p;
|
||||
|
||||
for (p = grub_fs_list; p; p = p->next)
|
||||
if (hook (p))
|
||||
break;
|
||||
}
|
||||
|
||||
grub_fs_t
|
||||
grub_fs_probe (grub_device_t device)
|
||||
{
|
||||
|
|
|
@ -1,64 +0,0 @@
|
|||
/* handler.c - grub handler function */
|
||||
/*
|
||||
* GRUB -- GRand Unified Bootloader
|
||||
* Copyright (C) 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/>.
|
||||
*/
|
||||
|
||||
#include <grub/handler.h>
|
||||
|
||||
grub_handler_class_t grub_handler_class_list;
|
||||
|
||||
void
|
||||
grub_handler_register (grub_handler_class_t class, grub_handler_t handler)
|
||||
{
|
||||
int first_handler = (class->handler_list == 0);
|
||||
|
||||
grub_list_push (GRUB_AS_LIST_P (&class->handler_list),
|
||||
GRUB_AS_LIST (handler));
|
||||
|
||||
if (first_handler)
|
||||
{
|
||||
grub_list_push (GRUB_AS_LIST_P (&grub_handler_class_list),
|
||||
GRUB_AS_LIST (class));
|
||||
grub_handler_set_current (class, handler);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
grub_handler_unregister (grub_handler_class_t class, grub_handler_t handler)
|
||||
{
|
||||
grub_list_remove (GRUB_AS_LIST_P (&class->handler_list),
|
||||
GRUB_AS_LIST (handler));
|
||||
|
||||
if (class->handler_list == 0)
|
||||
grub_list_remove (GRUB_AS_LIST_P (&grub_handler_class_list),
|
||||
GRUB_AS_LIST (class));
|
||||
}
|
||||
|
||||
grub_err_t
|
||||
grub_handler_set_current (grub_handler_class_t class, grub_handler_t handler)
|
||||
{
|
||||
if (class->cur_handler && class->cur_handler->fini)
|
||||
if ((class->cur_handler->fini) () != GRUB_ERR_NONE)
|
||||
return grub_errno;
|
||||
|
||||
if (handler->init)
|
||||
if ((handler->init) () != GRUB_ERR_NONE)
|
||||
return grub_errno;
|
||||
|
||||
class->cur_handler = handler;
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
|
@ -71,6 +71,9 @@ grub_exit (void)
|
|||
void
|
||||
grub_machine_init (void)
|
||||
{
|
||||
#ifdef GRUB_MACHINE_QEMU
|
||||
grub_qemu_init_cirrus ();
|
||||
#endif
|
||||
/* Initialize the console as early as possible. */
|
||||
grub_vga_text_init ();
|
||||
|
||||
|
|
|
@ -83,6 +83,14 @@ make_install_device (void)
|
|||
grub_snprintf (ptr, sizeof (dev) - (ptr - dev), ")%s", grub_prefix);
|
||||
grub_strcpy (grub_prefix, dev);
|
||||
}
|
||||
else if (grub_prefix[1] == ',' || grub_prefix[1] == ')')
|
||||
{
|
||||
/* We have a prefix, but still need to fill in the boot drive. */
|
||||
grub_snprintf (dev, sizeof (dev),
|
||||
"(%cd%u%s", (grub_boot_drive & 0x80) ? 'h' : 'f',
|
||||
grub_boot_drive & 0x7f, grub_prefix + 1);
|
||||
grub_strcpy (grub_prefix, dev);
|
||||
}
|
||||
|
||||
return grub_prefix;
|
||||
}
|
||||
|
|
|
@ -1063,7 +1063,7 @@ xsmap:
|
|||
|
||||
|
||||
/*
|
||||
* void grub_console_real_putchar (int c)
|
||||
* void grub_console_putchar (const struct grub_unicode_glyph *c)
|
||||
*
|
||||
* Put the character C on the console. Because GRUB wants to write a
|
||||
* character with an attribute, this implementation is a bit tricky.
|
||||
|
@ -1076,8 +1076,9 @@ xsmap:
|
|||
* get the height of the screen, and the TELETYPE OUTPUT BIOS call doesn't
|
||||
* support setting a background attribute.
|
||||
*/
|
||||
FUNCTION(grub_console_real_putchar)
|
||||
movl %eax, %edx
|
||||
FUNCTION(grub_console_putchar)
|
||||
/* Retrieve the base character. */
|
||||
movl 0(%edx), %edx
|
||||
pusha
|
||||
movb EXT_C(grub_console_cur_color), %bl
|
||||
|
||||
|
@ -1328,8 +1329,8 @@ FUNCTION(grub_console_gotoxy)
|
|||
pushl %ebp
|
||||
pushl %ebx /* save EBX */
|
||||
|
||||
movb %dl, %dh /* %dh = y */
|
||||
movb %al, %dl /* %dl = x */
|
||||
movb %cl, %dh /* %dh = y */
|
||||
/* %dl = x */
|
||||
|
||||
call prot_to_real
|
||||
.code16
|
||||
|
@ -1405,7 +1406,7 @@ FUNCTION(grub_console_setcursor)
|
|||
pushl %ebx
|
||||
|
||||
/* push ON */
|
||||
pushl %eax
|
||||
pushl %edx
|
||||
|
||||
/* check if the standard cursor shape has already been saved */
|
||||
movw console_cursor_shape, %ax
|
||||
|
|
152
kern/i386/qemu/init.c
Normal file
152
kern/i386/qemu/init.c
Normal file
|
@ -0,0 +1,152 @@
|
|||
/*
|
||||
* 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/pci.h>
|
||||
#include <grub/machine/kernel.h>
|
||||
#include <grub/misc.h>
|
||||
#include <grub/vga.h>
|
||||
|
||||
static struct {grub_uint8_t r, g, b, a; } colors[] =
|
||||
{
|
||||
// {R, G, B, A}
|
||||
{0x00, 0x00, 0x00, 0xFF}, // 0 = black
|
||||
{0x00, 0x00, 0xA8, 0xFF}, // 1 = blue
|
||||
{0x00, 0xA8, 0x00, 0xFF}, // 2 = green
|
||||
{0x00, 0xA8, 0xA8, 0xFF}, // 3 = cyan
|
||||
{0xA8, 0x00, 0x00, 0xFF}, // 4 = red
|
||||
{0xA8, 0x00, 0xA8, 0xFF}, // 5 = magenta
|
||||
{0xA8, 0x54, 0x00, 0xFF}, // 6 = brown
|
||||
{0xA8, 0xA8, 0xA8, 0xFF}, // 7 = light gray
|
||||
|
||||
{0x54, 0x54, 0x54, 0xFF}, // 8 = dark gray
|
||||
{0x54, 0x54, 0xFE, 0xFF}, // 9 = bright blue
|
||||
{0x54, 0xFE, 0x54, 0xFF}, // 10 = bright green
|
||||
{0x54, 0xFE, 0xFE, 0xFF}, // 11 = bright cyan
|
||||
{0xFE, 0x54, 0x54, 0xFF}, // 12 = bright red
|
||||
{0xFE, 0x54, 0xFE, 0xFF}, // 13 = bright magenta
|
||||
{0xFE, 0xFE, 0x54, 0xFF}, // 14 = yellow
|
||||
{0xFE, 0xFE, 0xFE, 0xFF} // 15 = white
|
||||
};
|
||||
|
||||
#include <ascii.h>
|
||||
|
||||
static void
|
||||
load_font (void)
|
||||
{
|
||||
unsigned i;
|
||||
|
||||
grub_vga_gr_write (0 << 2, GRUB_VGA_GR_GR6);
|
||||
|
||||
grub_vga_sr_write (GRUB_VGA_SR_MEMORY_MODE_NORMAL, GRUB_VGA_SR_MEMORY_MODE);
|
||||
grub_vga_sr_write (1 << GRUB_VGA_TEXT_FONT_PLANE,
|
||||
GRUB_VGA_SR_MAP_MASK_REGISTER);
|
||||
|
||||
grub_vga_gr_write (0, GRUB_VGA_GR_DATA_ROTATE);
|
||||
grub_vga_gr_write (0, GRUB_VGA_GR_MODE);
|
||||
grub_vga_gr_write (0xff, GRUB_VGA_GR_BITMASK);
|
||||
|
||||
for (i = 0; i < 128; i++)
|
||||
grub_memcpy ((void *) (0xa0000 + 32 * i), ascii_bitmaps + 16 * i, 16);
|
||||
}
|
||||
|
||||
static void
|
||||
load_palette (void)
|
||||
{
|
||||
unsigned i;
|
||||
for (i = 0; i < 16; i++)
|
||||
{
|
||||
grub_outb (i, GRUB_VGA_IO_ARX);
|
||||
grub_outb (i, GRUB_VGA_IO_ARX);
|
||||
}
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE (colors); i++)
|
||||
grub_vga_palette_write (i, colors[i].r, colors[i].g, colors[i].b);
|
||||
}
|
||||
|
||||
void
|
||||
grub_qemu_init_cirrus (void)
|
||||
{
|
||||
auto int NESTED_FUNC_ATTR find_card (grub_pci_device_t dev, grub_pci_id_t pciid);
|
||||
int NESTED_FUNC_ATTR find_card (grub_pci_device_t dev, grub_pci_id_t pciid __attribute__ ((unused)))
|
||||
{
|
||||
grub_pci_address_t addr;
|
||||
grub_uint32_t class;
|
||||
|
||||
addr = grub_pci_make_address (dev, GRUB_PCI_REG_CLASS);
|
||||
class = grub_pci_read (addr);
|
||||
|
||||
if (((class >> 16) & 0xffff) != 0x0300)
|
||||
return 0;
|
||||
|
||||
/* FIXME: chooose addresses dynamically. */
|
||||
addr = grub_pci_make_address (dev, GRUB_PCI_REG_ADDRESS_REG0);
|
||||
grub_pci_write (addr, 0xf0000000 | GRUB_PCI_ADDR_MEM_PREFETCH
|
||||
| GRUB_PCI_ADDR_SPACE_MEMORY | GRUB_PCI_ADDR_MEM_TYPE_32);
|
||||
addr = grub_pci_make_address (dev, GRUB_PCI_REG_ADDRESS_REG1);
|
||||
grub_pci_write (addr, 0xf2000000
|
||||
| GRUB_PCI_ADDR_SPACE_MEMORY | GRUB_PCI_ADDR_MEM_TYPE_32);
|
||||
|
||||
addr = grub_pci_make_address (dev, GRUB_PCI_REG_COMMAND);
|
||||
grub_pci_write (addr, GRUB_PCI_COMMAND_MEM_ENABLED
|
||||
| GRUB_PCI_COMMAND_IO_ENABLED);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
grub_pci_iterate (find_card);
|
||||
|
||||
grub_outb (1, 0x3c2);
|
||||
|
||||
load_font ();
|
||||
|
||||
grub_vga_gr_write (GRUB_VGA_GR_GR6_MMAP_CGA, GRUB_VGA_GR_GR6);
|
||||
grub_vga_gr_write (GRUB_VGA_GR_MODE_ODD_EVEN, GRUB_VGA_GR_MODE);
|
||||
|
||||
grub_vga_sr_write (GRUB_VGA_SR_MEMORY_MODE_NORMAL, GRUB_VGA_SR_MEMORY_MODE);
|
||||
|
||||
grub_vga_sr_write ((1 << GRUB_VGA_TEXT_TEXT_PLANE)
|
||||
| (1 << GRUB_VGA_TEXT_ATTR_PLANE),
|
||||
GRUB_VGA_SR_MAP_MASK_REGISTER);
|
||||
|
||||
grub_vga_cr_write (15, GRUB_VGA_CR_CELL_HEIGHT);
|
||||
grub_vga_cr_write (79, GRUB_VGA_CR_WIDTH);
|
||||
grub_vga_cr_write (40, GRUB_VGA_CR_PITCH);
|
||||
|
||||
int vert = 25 * 16;
|
||||
grub_vga_cr_write (vert & 0xff, GRUB_VGA_CR_HEIGHT);
|
||||
grub_vga_cr_write (((vert >> GRUB_VGA_CR_OVERFLOW_HEIGHT1_SHIFT)
|
||||
& GRUB_VGA_CR_OVERFLOW_HEIGHT1_MASK)
|
||||
| ((vert >> GRUB_VGA_CR_OVERFLOW_HEIGHT2_SHIFT)
|
||||
& GRUB_VGA_CR_OVERFLOW_HEIGHT2_MASK),
|
||||
GRUB_VGA_CR_OVERFLOW);
|
||||
|
||||
load_palette ();
|
||||
|
||||
grub_outb (0x10, 0x3c0);
|
||||
grub_outb (0, 0x3c1);
|
||||
grub_outb (0x14, 0x3c0);
|
||||
grub_outb (0, 0x3c1);
|
||||
|
||||
grub_vga_sr_write (GRUB_VGA_SR_CLOCKING_MODE_8_DOT_CLOCK,
|
||||
GRUB_VGA_SR_CLOCKING_MODE);
|
||||
|
||||
grub_vga_cr_write (14, GRUB_VGA_CR_CURSOR_START);
|
||||
grub_vga_cr_write (15, GRUB_VGA_CR_CURSOR_END);
|
||||
|
||||
grub_outb (0x20, 0x3c0);
|
||||
}
|
|
@ -27,21 +27,37 @@
|
|||
#define QEMU_CMOS_MEMSIZE_HIGH 0x35
|
||||
#define QEMU_CMOS_MEMSIZE_LOW 0x34
|
||||
|
||||
#define QEMU_CMOS_MEMSIZE2_HIGH 0x31
|
||||
#define QEMU_CMOS_MEMSIZE2_LOW 0x30
|
||||
|
||||
#define min(a,b) ((a) > (b) ? (b) : (a))
|
||||
|
||||
extern char _start[];
|
||||
extern char _end[];
|
||||
|
||||
grub_size_t grub_lower_mem, grub_upper_mem;
|
||||
grub_uint64_t mem_size;
|
||||
static grub_uint64_t mem_size, above_4g;
|
||||
|
||||
void
|
||||
grub_machine_mmap_init ()
|
||||
{
|
||||
mem_size = grub_cmos_read (QEMU_CMOS_MEMSIZE_HIGH) << 24 | grub_cmos_read (QEMU_CMOS_MEMSIZE_LOW) << 16;
|
||||
mem_size = ((grub_uint64_t) grub_cmos_read (QEMU_CMOS_MEMSIZE_HIGH)) << 24
|
||||
| ((grub_uint64_t) grub_cmos_read (QEMU_CMOS_MEMSIZE_LOW)) << 16;
|
||||
if (mem_size > 0)
|
||||
{
|
||||
/* Don't ask... */
|
||||
mem_size += (16 * 1024 * 1024);
|
||||
}
|
||||
else
|
||||
{
|
||||
mem_size
|
||||
= ((((grub_uint64_t) grub_cmos_read (QEMU_CMOS_MEMSIZE2_HIGH)) << 18)
|
||||
| ((grub_uint64_t) (grub_cmos_read (QEMU_CMOS_MEMSIZE2_LOW)) << 10))
|
||||
+ 1024 * 1024;
|
||||
}
|
||||
|
||||
/* Don't ask... */
|
||||
mem_size += (16 * 1024 * 1024);
|
||||
above_4g = (((grub_uint64_t) grub_cmos_read (0x5b)) << 16)
|
||||
| (((grub_uint64_t) grub_cmos_read (0x5c)) << 24)
|
||||
| (((grub_uint64_t) grub_cmos_read (0x5d)) << 32);
|
||||
}
|
||||
|
||||
grub_err_t
|
||||
|
@ -57,6 +73,12 @@ grub_machine_mmap_iterate (int NESTED_FUNC_ATTR (*hook) (grub_uint64_t, grub_uin
|
|||
GRUB_MACHINE_MEMORY_RESERVED))
|
||||
return 1;
|
||||
|
||||
/* Everything else is free. */
|
||||
if (hook (0x100000,
|
||||
min (mem_size, (grub_uint32_t) -GRUB_BOOT_MACHINE_SIZE) - 0x100000,
|
||||
GRUB_MACHINE_MEMORY_AVAILABLE))
|
||||
return 1;
|
||||
|
||||
/* Protect boot.img, which contains the gdt. It is mapped at the top of memory
|
||||
(it is also mapped below 0x100000, but we already reserved that area). */
|
||||
if (hook ((grub_uint32_t) -GRUB_BOOT_MACHINE_SIZE,
|
||||
|
@ -64,10 +86,8 @@ grub_machine_mmap_iterate (int NESTED_FUNC_ATTR (*hook) (grub_uint64_t, grub_uin
|
|||
GRUB_MACHINE_MEMORY_RESERVED))
|
||||
return 1;
|
||||
|
||||
/* Everything else is free. */
|
||||
if (hook (0x100000,
|
||||
min (mem_size, (grub_uint32_t) -GRUB_BOOT_MACHINE_SIZE) - 0x100000,
|
||||
GRUB_MACHINE_MEMORY_AVAILABLE))
|
||||
if (above_4g != 0 && hook (0x100000000ULL, above_4g,
|
||||
GRUB_MACHINE_MEMORY_AVAILABLE))
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
#include <grub/env.h>
|
||||
#include <grub/misc.h>
|
||||
#include <grub/time.h>
|
||||
#include <grub/machine/console.h>
|
||||
#include <grub/ieee1275/console.h>
|
||||
#include <grub/ieee1275/ofdisk.h>
|
||||
#include <grub/ieee1275/ieee1275.h>
|
||||
#include <grub/offsets.h>
|
||||
|
@ -224,11 +224,12 @@ grub_machine_init (void)
|
|||
|
||||
grub_ieee1275_init ();
|
||||
|
||||
grub_console_init ();
|
||||
grub_console_init_early ();
|
||||
#ifdef __i386__
|
||||
grub_get_extended_memory ();
|
||||
#endif
|
||||
grub_claim_heap ();
|
||||
grub_console_init_lately ();
|
||||
grub_ofdisk_init ();
|
||||
|
||||
/* Process commandline. */
|
||||
|
|
|
@ -420,6 +420,7 @@ void
|
|||
grub_reboot (void)
|
||||
{
|
||||
grub_ieee1275_interpret ("reset-all", 0);
|
||||
for (;;) ;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -431,4 +432,5 @@ grub_halt (void)
|
|||
grub_ieee1275_interpret ("shut-down", 0);
|
||||
grub_ieee1275_interpret ("power-off", 0);
|
||||
grub_ieee1275_interpret ("poweroff", 0);
|
||||
for (;;) ;
|
||||
}
|
||||
|
|
82
kern/list.c
82
kern/list.c
|
@ -28,18 +28,6 @@ grub_list_push (grub_list_t *head, grub_list_t item)
|
|||
*head = item;
|
||||
}
|
||||
|
||||
void *
|
||||
grub_list_pop (grub_list_t *head)
|
||||
{
|
||||
grub_list_t item;
|
||||
|
||||
item = *head;
|
||||
if (item)
|
||||
*head = item->next;
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
void
|
||||
grub_list_remove (grub_list_t *head, grub_list_t item)
|
||||
{
|
||||
|
@ -53,51 +41,16 @@ grub_list_remove (grub_list_t *head, grub_list_t item)
|
|||
}
|
||||
}
|
||||
|
||||
int
|
||||
grub_list_iterate (grub_list_t head, grub_list_hook_t hook)
|
||||
{
|
||||
grub_list_t p;
|
||||
|
||||
for (p = head; p; p = p->next)
|
||||
if (hook (p))
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
grub_list_insert (grub_list_t *head, grub_list_t item,
|
||||
grub_list_test_t test)
|
||||
{
|
||||
grub_list_t *p, q;
|
||||
|
||||
for (p = head, q = *p; q; p = &(q->next), q = q->next)
|
||||
if (test (item, q))
|
||||
break;
|
||||
|
||||
*p = item;
|
||||
item->next = q;
|
||||
}
|
||||
|
||||
void *
|
||||
grub_named_list_find (grub_named_list_t head, const char *name)
|
||||
{
|
||||
grub_named_list_t result = NULL;
|
||||
grub_named_list_t item;
|
||||
|
||||
auto int list_find (grub_named_list_t item);
|
||||
int list_find (grub_named_list_t item)
|
||||
{
|
||||
if (! grub_strcmp (item->name, name))
|
||||
{
|
||||
result = item;
|
||||
return 1;
|
||||
}
|
||||
FOR_LIST_ELEMENTS (item, head)
|
||||
if (grub_strcmp (item->name, name) == 0)
|
||||
return item;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
grub_list_iterate (GRUB_AS_LIST (head), (grub_list_hook_t) list_find);
|
||||
return result;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -105,27 +58,30 @@ grub_prio_list_insert (grub_prio_list_t *head, grub_prio_list_t nitem)
|
|||
{
|
||||
int inactive = 0;
|
||||
|
||||
auto int test (grub_prio_list_t new_item, grub_prio_list_t item);
|
||||
int test (grub_prio_list_t new_item, grub_prio_list_t item)
|
||||
grub_prio_list_t *p, q;
|
||||
|
||||
for (p = head, q = *p; q; p = &(q->next), q = q->next)
|
||||
{
|
||||
int r;
|
||||
|
||||
r = grub_strcmp (new_item->name, item->name);
|
||||
if (r)
|
||||
return (r < 0);
|
||||
r = grub_strcmp (nitem->name, q->name);
|
||||
if (r < 0)
|
||||
break;
|
||||
if (r > 0)
|
||||
continue;
|
||||
|
||||
if (new_item->prio >= (item->prio & GRUB_PRIO_LIST_PRIO_MASK))
|
||||
if (nitem->prio >= (q->prio & GRUB_PRIO_LIST_PRIO_MASK))
|
||||
{
|
||||
item->prio &= ~GRUB_PRIO_LIST_FLAG_ACTIVE;
|
||||
return 1;
|
||||
q->prio &= ~GRUB_PRIO_LIST_FLAG_ACTIVE;
|
||||
break;
|
||||
}
|
||||
|
||||
inactive = 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
grub_list_insert (GRUB_AS_LIST_P (head), GRUB_AS_LIST (nitem),
|
||||
(grub_list_test_t) test);
|
||||
*p = nitem;
|
||||
nitem->next = q;
|
||||
|
||||
if (! inactive)
|
||||
nitem->prio |= GRUB_PRIO_LIST_FLAG_ACTIVE;
|
||||
}
|
||||
|
|
|
@ -191,7 +191,6 @@ grub_main (void)
|
|||
grub_set_root_dev ();
|
||||
|
||||
grub_register_core_commands ();
|
||||
grub_register_rescue_parser ();
|
||||
|
||||
grub_load_config ();
|
||||
grub_load_normal_mode ();
|
||||
|
|
|
@ -49,8 +49,15 @@ codestart:
|
|||
/* Parse arguments. Has to be done before relocation.
|
||||
So need to do it in asm. */
|
||||
#ifdef GRUB_MACHINE_MIPS_YEELOONG
|
||||
move $s2, $zero
|
||||
move $s3, $zero
|
||||
move $s4, $zero
|
||||
move $s5, $zero
|
||||
|
||||
/* $a2 has the environment. */
|
||||
move $t0, $a2
|
||||
addiu $t0, $a2, 1
|
||||
beq $t0, $zero, argdone
|
||||
move $t0, $a2
|
||||
argcont:
|
||||
lw $t1, 0($t0)
|
||||
beq $t1, $zero, argdone
|
||||
|
|
|
@ -26,6 +26,10 @@
|
|||
#include <grub/time.h>
|
||||
#include <grub/machine/kernel.h>
|
||||
#include <grub/machine/memory.h>
|
||||
#include <grub/mips/loongson.h>
|
||||
#include <grub/cs5536.h>
|
||||
#include <grub/term.h>
|
||||
#include <grub/machine/ec.h>
|
||||
|
||||
extern void grub_video_sm712_init (void);
|
||||
extern void grub_video_init (void);
|
||||
|
@ -33,6 +37,8 @@ extern void grub_bitmap_init (void);
|
|||
extern void grub_font_init (void);
|
||||
extern void grub_gfxterm_init (void);
|
||||
extern void grub_at_keyboard_init (void);
|
||||
extern void grub_serial_init (void);
|
||||
extern void grub_terminfo_init (void);
|
||||
|
||||
/* FIXME: use interrupt to count high. */
|
||||
grub_uint64_t
|
||||
|
@ -42,7 +48,7 @@ grub_get_rtc (void)
|
|||
static grub_uint32_t last = 0;
|
||||
grub_uint32_t low;
|
||||
|
||||
asm volatile ("mfc0 %0, $9": "=r" (low));
|
||||
asm volatile ("mfc0 %0, " GRUB_CPU_LOONGSON_COP0_TIMER_COUNT : "=r" (low));
|
||||
if (low < last)
|
||||
high++;
|
||||
last = low;
|
||||
|
@ -62,25 +68,147 @@ grub_machine_mmap_iterate (int NESTED_FUNC_ATTR (*hook) (grub_uint64_t,
|
|||
return GRUB_ERR_NONE;
|
||||
}
|
||||
|
||||
static void
|
||||
init_pci (void)
|
||||
{
|
||||
auto int NESTED_FUNC_ATTR set_card (grub_pci_device_t dev, grub_pci_id_t pciid);
|
||||
int NESTED_FUNC_ATTR set_card (grub_pci_device_t dev, grub_pci_id_t pciid)
|
||||
{
|
||||
grub_pci_address_t addr;
|
||||
/* FIXME: autoscan for BARs and devices. */
|
||||
switch (pciid)
|
||||
{
|
||||
case GRUB_YEELOONG_OHCI_PCIID:
|
||||
addr = grub_pci_make_address (dev, GRUB_PCI_REG_ADDRESS_REG0);
|
||||
grub_pci_write (addr, 0x5025000);
|
||||
addr = grub_pci_make_address (dev, GRUB_PCI_REG_COMMAND);
|
||||
grub_pci_write_word (addr, GRUB_PCI_COMMAND_SERR_ENABLE
|
||||
| GRUB_PCI_COMMAND_PARITY_ERROR
|
||||
| GRUB_PCI_COMMAND_BUS_MASTER
|
||||
| GRUB_PCI_COMMAND_MEM_ENABLED);
|
||||
|
||||
addr = grub_pci_make_address (dev, GRUB_PCI_REG_STATUS);
|
||||
grub_pci_write_word (addr, 0x0200 | GRUB_PCI_STATUS_CAPABILITIES);
|
||||
break;
|
||||
case GRUB_YEELOONG_EHCI_PCIID:
|
||||
addr = grub_pci_make_address (dev, GRUB_PCI_REG_ADDRESS_REG0);
|
||||
grub_pci_write (addr, 0x5026000);
|
||||
addr = grub_pci_make_address (dev, GRUB_PCI_REG_COMMAND);
|
||||
grub_pci_write_word (addr, GRUB_PCI_COMMAND_SERR_ENABLE
|
||||
| GRUB_PCI_COMMAND_PARITY_ERROR
|
||||
| GRUB_PCI_COMMAND_BUS_MASTER
|
||||
| GRUB_PCI_COMMAND_MEM_ENABLED);
|
||||
|
||||
addr = grub_pci_make_address (dev, GRUB_PCI_REG_STATUS);
|
||||
grub_pci_write_word (addr, (1 << GRUB_PCI_STATUS_DEVSEL_TIMING_SHIFT)
|
||||
| GRUB_PCI_STATUS_CAPABILITIES);
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
*((volatile grub_uint32_t *) GRUB_CPU_LOONGSON_PCI_HIT1_SEL_LO) = 0x8000000c;
|
||||
*((volatile grub_uint32_t *) GRUB_CPU_LOONGSON_PCI_HIT1_SEL_HI) = 0xffffffff;
|
||||
|
||||
/* Setup PCI controller. */
|
||||
*((volatile grub_uint16_t *) (GRUB_MACHINE_PCI_CONTROLLER_HEADER
|
||||
+ GRUB_PCI_REG_COMMAND))
|
||||
= GRUB_PCI_COMMAND_PARITY_ERROR | GRUB_PCI_COMMAND_BUS_MASTER
|
||||
| GRUB_PCI_COMMAND_MEM_ENABLED;
|
||||
*((volatile grub_uint16_t *) (GRUB_MACHINE_PCI_CONTROLLER_HEADER
|
||||
+ GRUB_PCI_REG_STATUS))
|
||||
= (1 << GRUB_PCI_STATUS_DEVSEL_TIMING_SHIFT)
|
||||
| GRUB_PCI_STATUS_FAST_B2B_CAPABLE | GRUB_PCI_STATUS_66MHZ_CAPABLE
|
||||
| GRUB_PCI_STATUS_CAPABILITIES;
|
||||
|
||||
*((volatile grub_uint32_t *) (GRUB_MACHINE_PCI_CONTROLLER_HEADER
|
||||
+ GRUB_PCI_REG_CACHELINE)) = 0xff;
|
||||
*((volatile grub_uint32_t *) (GRUB_MACHINE_PCI_CONTROLLER_HEADER
|
||||
+ GRUB_PCI_REG_ADDRESS_REG0))
|
||||
= 0x80000000 | GRUB_PCI_ADDR_MEM_TYPE_64 | GRUB_PCI_ADDR_MEM_PREFETCH;
|
||||
*((volatile grub_uint32_t *) (GRUB_MACHINE_PCI_CONTROLLER_HEADER
|
||||
+ GRUB_PCI_REG_ADDRESS_REG1)) = 0;
|
||||
|
||||
grub_pci_iterate (set_card);
|
||||
}
|
||||
|
||||
void
|
||||
grub_machine_init (void)
|
||||
{
|
||||
grub_addr_t modend;
|
||||
|
||||
/* FIXME: measure this. */
|
||||
if (grub_arch_busclock == 0)
|
||||
{
|
||||
grub_arch_busclock = 66000000;
|
||||
grub_arch_cpuclock = 797000000;
|
||||
}
|
||||
|
||||
grub_install_get_time_ms (grub_rtc_get_time_ms);
|
||||
|
||||
if (grub_arch_memsize == 0)
|
||||
{
|
||||
grub_port_t smbbase;
|
||||
grub_err_t err;
|
||||
grub_pci_device_t dev;
|
||||
struct grub_smbus_spd spd;
|
||||
unsigned totalmem;
|
||||
int i;
|
||||
|
||||
if (!grub_cs5536_find (&dev))
|
||||
grub_fatal ("No CS5536 found\n");
|
||||
|
||||
err = grub_cs5536_init_smbus (dev, 0x7ff, &smbbase);
|
||||
if (err)
|
||||
grub_fatal ("Couldn't init SMBus: %s\n", grub_errmsg);
|
||||
|
||||
/* Yeeloong has only one memory slot. */
|
||||
err = grub_cs5536_read_spd (smbbase, GRUB_SMB_RAM_START_ADDR, &spd);
|
||||
if (err)
|
||||
grub_fatal ("Couldn't read SPD: %s\n", grub_errmsg);
|
||||
for (i = 5; i < 13; i++)
|
||||
if (spd.ddr2.rank_capacity & (1 << (i & 7)))
|
||||
break;
|
||||
/* Something is wrong. */
|
||||
if (i == 13)
|
||||
totalmem = 256;
|
||||
else
|
||||
totalmem = ((spd.ddr2.num_of_ranks
|
||||
& GRUB_SMBUS_SPD_MEMORY_NUM_OF_RANKS_MASK) + 1) << (i + 2);
|
||||
|
||||
if (totalmem >= 256)
|
||||
{
|
||||
grub_arch_memsize = 256;
|
||||
grub_arch_highmemsize = totalmem - 256;
|
||||
}
|
||||
else
|
||||
{
|
||||
grub_arch_memsize = (totalmem >> 20);
|
||||
grub_arch_highmemsize = 0;
|
||||
}
|
||||
|
||||
grub_cs5536_init_geode (dev);
|
||||
|
||||
init_pci ();
|
||||
}
|
||||
|
||||
modend = grub_modules_get_end ();
|
||||
grub_mm_init_region ((void *) modend, (grub_arch_memsize << 20)
|
||||
- (modend - GRUB_ARCH_LOWMEMVSTART));
|
||||
/* FIXME: use upper memory as well. */
|
||||
grub_install_get_time_ms (grub_rtc_get_time_ms);
|
||||
|
||||
/* Initialize output terminal (can't be done earlier, as gfxterm
|
||||
relies on a working heap. */
|
||||
grub_video_sm712_init ();
|
||||
grub_video_init ();
|
||||
grub_video_sm712_init ();
|
||||
grub_bitmap_init ();
|
||||
grub_font_init ();
|
||||
grub_gfxterm_init ();
|
||||
|
||||
grub_at_keyboard_init ();
|
||||
|
||||
grub_terminfo_init ();
|
||||
grub_serial_init ();
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -89,20 +217,29 @@ grub_machine_fini (void)
|
|||
}
|
||||
|
||||
void
|
||||
grub_exit (void)
|
||||
grub_halt (void)
|
||||
{
|
||||
grub_outb (grub_inb (GRUB_CPU_LOONGSON_GPIOCFG)
|
||||
& ~GRUB_CPU_LOONGSON_SHUTDOWN_GPIO, GRUB_CPU_LOONGSON_GPIOCFG);
|
||||
|
||||
grub_printf ("Shutdown failed\n");
|
||||
grub_refresh ();
|
||||
while (1);
|
||||
}
|
||||
|
||||
void
|
||||
grub_halt (void)
|
||||
grub_exit (void)
|
||||
{
|
||||
while (1);
|
||||
grub_halt ();
|
||||
}
|
||||
|
||||
void
|
||||
grub_reboot (void)
|
||||
{
|
||||
grub_write_ec (GRUB_MACHINE_EC_COMMAND_REBOOT);
|
||||
|
||||
grub_printf ("Reboot failed\n");
|
||||
grub_refresh ();
|
||||
while (1);
|
||||
}
|
||||
|
||||
|
|
151
kern/misc.c
151
kern/misc.c
|
@ -142,19 +142,6 @@ grub_printf_ (const char *fmt, ...)
|
|||
return ret;
|
||||
}
|
||||
|
||||
int
|
||||
grub_puts (const char *s)
|
||||
{
|
||||
while (*s)
|
||||
{
|
||||
grub_putchar (*s);
|
||||
s++;
|
||||
}
|
||||
grub_putchar ('\n');
|
||||
|
||||
return 1; /* Cannot fail. */
|
||||
}
|
||||
|
||||
int
|
||||
grub_puts_ (const char *s)
|
||||
{
|
||||
|
@ -200,13 +187,37 @@ grub_real_dprintf (const char *file, const int line, const char *condition,
|
|||
}
|
||||
}
|
||||
|
||||
#define PREALLOC_SIZE 255
|
||||
|
||||
int
|
||||
grub_vprintf (const char *fmt, va_list args)
|
||||
{
|
||||
int ret;
|
||||
grub_size_t s;
|
||||
static char buf[PREALLOC_SIZE + 1];
|
||||
char *curbuf = buf;
|
||||
|
||||
ret = grub_vsnprintf_real (0, 0, fmt, args);
|
||||
return ret;
|
||||
s = grub_vsnprintf_real (buf, PREALLOC_SIZE, fmt, args);
|
||||
if (s > PREALLOC_SIZE)
|
||||
{
|
||||
curbuf = grub_malloc (s + 1);
|
||||
if (!curbuf)
|
||||
{
|
||||
grub_errno = GRUB_ERR_NONE;
|
||||
buf[PREALLOC_SIZE - 3] = '.';
|
||||
buf[PREALLOC_SIZE - 2] = '.';
|
||||
buf[PREALLOC_SIZE - 1] = '.';
|
||||
buf[PREALLOC_SIZE] = 0;
|
||||
}
|
||||
else
|
||||
s = grub_vsnprintf_real (curbuf, s, fmt, args);
|
||||
}
|
||||
|
||||
grub_xputs (curbuf);
|
||||
|
||||
if (curbuf != buf)
|
||||
grub_free (curbuf);
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
int
|
||||
|
@ -649,13 +660,8 @@ grub_vsnprintf_real (char *str, grub_size_t max_len, const char *fmt, va_list ar
|
|||
|
||||
void write_char (unsigned char ch)
|
||||
{
|
||||
if (str)
|
||||
{
|
||||
if (count < max_len)
|
||||
*str++ = ch;
|
||||
}
|
||||
else
|
||||
grub_putchar (ch);
|
||||
if (count < max_len)
|
||||
*str++ = ch;
|
||||
|
||||
count++;
|
||||
}
|
||||
|
@ -872,8 +878,7 @@ grub_vsnprintf_real (char *str, grub_size_t max_len, const char *fmt, va_list ar
|
|||
}
|
||||
}
|
||||
|
||||
if (str)
|
||||
*str = '\0';
|
||||
*str = '\0';
|
||||
|
||||
return count;
|
||||
}
|
||||
|
@ -906,8 +911,6 @@ grub_snprintf (char *str, grub_size_t n, const char *fmt, ...)
|
|||
return ret;
|
||||
}
|
||||
|
||||
#define PREALLOC_SIZE 255
|
||||
|
||||
char *
|
||||
grub_xvasprintf (const char *fmt, va_list ap)
|
||||
{
|
||||
|
@ -942,100 +945,6 @@ grub_xasprintf (const char *fmt, ...)
|
|||
return ret;
|
||||
}
|
||||
|
||||
/* Convert a (possibly null-terminated) UTF-8 string of at most SRCSIZE
|
||||
bytes (if SRCSIZE is -1, it is ignored) in length to a UCS-4 string.
|
||||
Return the number of characters converted. DEST must be able to hold
|
||||
at least DESTSIZE characters.
|
||||
If SRCEND is not NULL, then *SRCEND is set to the next byte after the
|
||||
last byte used in SRC. */
|
||||
grub_size_t
|
||||
grub_utf8_to_ucs4 (grub_uint32_t *dest, grub_size_t destsize,
|
||||
const grub_uint8_t *src, grub_size_t srcsize,
|
||||
const grub_uint8_t **srcend)
|
||||
{
|
||||
grub_uint32_t *p = dest;
|
||||
int count = 0;
|
||||
grub_uint32_t code = 0;
|
||||
|
||||
if (srcend)
|
||||
*srcend = src;
|
||||
|
||||
while (srcsize && destsize)
|
||||
{
|
||||
grub_uint32_t c = *src++;
|
||||
if (srcsize != (grub_size_t)-1)
|
||||
srcsize--;
|
||||
if (count)
|
||||
{
|
||||
if ((c & 0xc0) != 0x80)
|
||||
{
|
||||
/* invalid */
|
||||
code = '?';
|
||||
/* Character c may be valid, don't eat it. */
|
||||
src--;
|
||||
if (srcsize != (grub_size_t)-1)
|
||||
srcsize++;
|
||||
count = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
code <<= 6;
|
||||
code |= (c & 0x3f);
|
||||
count--;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (c == 0)
|
||||
break;
|
||||
|
||||
if ((c & 0x80) == 0x00)
|
||||
code = c;
|
||||
else if ((c & 0xe0) == 0xc0)
|
||||
{
|
||||
count = 1;
|
||||
code = c & 0x1f;
|
||||
}
|
||||
else if ((c & 0xf0) == 0xe0)
|
||||
{
|
||||
count = 2;
|
||||
code = c & 0x0f;
|
||||
}
|
||||
else if ((c & 0xf8) == 0xf0)
|
||||
{
|
||||
count = 3;
|
||||
code = c & 0x07;
|
||||
}
|
||||
else if ((c & 0xfc) == 0xf8)
|
||||
{
|
||||
count = 4;
|
||||
code = c & 0x03;
|
||||
}
|
||||
else if ((c & 0xfe) == 0xfc)
|
||||
{
|
||||
count = 5;
|
||||
code = c & 0x01;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* invalid */
|
||||
code = '?';
|
||||
count = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (count == 0)
|
||||
{
|
||||
*p++ = code;
|
||||
destsize--;
|
||||
}
|
||||
}
|
||||
|
||||
if (srcend)
|
||||
*srcend = src;
|
||||
return p - dest;
|
||||
}
|
||||
|
||||
/* Abort GRUB. This function does not return. */
|
||||
void
|
||||
grub_abort (void)
|
||||
|
|
|
@ -230,10 +230,6 @@ grub_parser_split_cmdline (const char *cmdline, grub_reader_getline_t getline,
|
|||
return 0;
|
||||
}
|
||||
|
||||
struct grub_handler_class grub_parser_class = {
|
||||
.name = "parser"
|
||||
};
|
||||
|
||||
grub_err_t
|
||||
grub_parser_execute (char *source)
|
||||
{
|
||||
|
@ -261,11 +257,9 @@ grub_parser_execute (char *source)
|
|||
while (source)
|
||||
{
|
||||
char *line;
|
||||
grub_parser_t parser;
|
||||
|
||||
getline (&line, 0);
|
||||
parser = grub_parser_get_current ();
|
||||
parser->parse_line (line, getline);
|
||||
grub_rescue_parse_line (line, getline);
|
||||
grub_free (line);
|
||||
}
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
#include <grub/misc.h>
|
||||
#include <grub/command.h>
|
||||
|
||||
static grub_err_t
|
||||
grub_err_t
|
||||
grub_rescue_parse_line (char *line, grub_reader_getline_t getline)
|
||||
{
|
||||
char *name;
|
||||
|
@ -74,15 +74,3 @@ grub_rescue_parse_line (char *line, grub_reader_getline_t getline)
|
|||
|
||||
return grub_errno;
|
||||
}
|
||||
|
||||
static struct grub_parser grub_rescue_parser =
|
||||
{
|
||||
.name = "rescue",
|
||||
.parse_line = grub_rescue_parse_line
|
||||
};
|
||||
|
||||
void
|
||||
grub_register_rescue_parser (void)
|
||||
{
|
||||
grub_parser_register ("rescue", &grub_rescue_parser);
|
||||
}
|
||||
|
|
|
@ -34,6 +34,7 @@ grub_rescue_read_line (char **line, int cont)
|
|||
{
|
||||
int c;
|
||||
int pos = 0;
|
||||
char str[4];
|
||||
|
||||
grub_printf ((cont) ? "> " : "grub rescue> ");
|
||||
grub_memset (linebuf, 0, GRUB_RESCUE_BUF_SIZE);
|
||||
|
@ -44,24 +45,28 @@ grub_rescue_read_line (char **line, int cont)
|
|||
{
|
||||
if (pos < GRUB_RESCUE_BUF_SIZE - 1)
|
||||
{
|
||||
str[0] = c;
|
||||
str[1] = 0;
|
||||
linebuf[pos++] = c;
|
||||
grub_putchar (c);
|
||||
grub_xputs (str);
|
||||
}
|
||||
}
|
||||
else if (c == '\b')
|
||||
{
|
||||
if (pos > 0)
|
||||
{
|
||||
str[0] = c;
|
||||
str[1] = ' ';
|
||||
str[2] = c;
|
||||
str[3] = 0;
|
||||
linebuf[--pos] = 0;
|
||||
grub_putchar (c);
|
||||
grub_putchar (' ');
|
||||
grub_putchar (c);
|
||||
grub_xputs (str);
|
||||
}
|
||||
}
|
||||
grub_refresh ();
|
||||
}
|
||||
|
||||
grub_putchar ('\n');
|
||||
grub_xputs ("\n");
|
||||
grub_refresh ();
|
||||
|
||||
*line = grub_strdup (linebuf);
|
||||
|
@ -86,7 +91,7 @@ grub_rescue_run (void)
|
|||
if (! line || line[0] == '\0')
|
||||
continue;
|
||||
|
||||
grub_parser_get_current ()->parse_line (line, grub_rescue_read_line);
|
||||
grub_rescue_parse_line (line, grub_rescue_read_line);
|
||||
grub_free (line);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
#include <grub/misc.h>
|
||||
#include <grub/time.h>
|
||||
#include <grub/machine/boot.h>
|
||||
#include <grub/machine/console.h>
|
||||
#include <grub/ieee1275/console.h>
|
||||
#include <grub/machine/kernel.h>
|
||||
#include <grub/machine/time.h>
|
||||
#include <grub/ieee1275/ofdisk.h>
|
||||
|
@ -155,8 +155,9 @@ void
|
|||
grub_machine_init (void)
|
||||
{
|
||||
grub_ieee1275_init ();
|
||||
grub_console_init ();
|
||||
grub_console_init_early ();
|
||||
grub_heap_init ();
|
||||
grub_console_init_lately ();
|
||||
|
||||
grub_ieee1275_set_flag (GRUB_IEEE1275_FLAG_NO_PARTITION_0);
|
||||
grub_ofdisk_init ();
|
||||
|
|
89
kern/term.c
89
kern/term.c
|
@ -28,53 +28,54 @@ struct grub_term_input *grub_term_inputs_disabled;
|
|||
struct grub_term_output *grub_term_outputs;
|
||||
struct grub_term_input *grub_term_inputs;
|
||||
|
||||
void (*grub_newline_hook) (void) = NULL;
|
||||
|
||||
/* Put a Unicode character. */
|
||||
void
|
||||
grub_putcode (grub_uint32_t code, struct grub_term_output *term)
|
||||
static void
|
||||
grub_putcode_dumb (grub_uint32_t code,
|
||||
struct grub_term_output *term)
|
||||
{
|
||||
struct grub_unicode_glyph c =
|
||||
{
|
||||
.base = code,
|
||||
.variant = 0,
|
||||
.attributes = 0,
|
||||
.ncomb = 0,
|
||||
.combining = 0,
|
||||
.estimated_width = 1
|
||||
};
|
||||
|
||||
if (code == '\t' && term->getxy)
|
||||
{
|
||||
int n;
|
||||
|
||||
n = 8 - ((term->getxy () >> 8) & 7);
|
||||
n = 8 - ((term->getxy (term) >> 8) & 7);
|
||||
while (n--)
|
||||
grub_putcode (' ', term);
|
||||
grub_putcode_dumb (' ', term);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
(term->putchar) (code);
|
||||
(term->putchar) (term, &c);
|
||||
if (code == '\n')
|
||||
(term->putchar) ('\r');
|
||||
grub_putcode_dumb ('\r', term);
|
||||
}
|
||||
|
||||
/* Put a character. C is one byte of a UTF-8 stream.
|
||||
This function gathers bytes until a valid Unicode character is found. */
|
||||
void
|
||||
grub_putchar (int c)
|
||||
static void
|
||||
grub_xputs_dumb (const char *str)
|
||||
{
|
||||
static grub_size_t size = 0;
|
||||
static grub_uint8_t buf[6];
|
||||
grub_uint8_t *rest;
|
||||
grub_uint32_t code;
|
||||
|
||||
buf[size++] = c;
|
||||
|
||||
while (grub_utf8_to_ucs4 (&code, 1, buf, size, (const grub_uint8_t **) &rest)
|
||||
!= 0)
|
||||
for (; *str; str++)
|
||||
{
|
||||
struct grub_term_output *term;
|
||||
size -= rest - buf;
|
||||
grub_memmove (buf, rest, size);
|
||||
grub_term_output_t term;
|
||||
grub_uint32_t code = *str;
|
||||
if (code > 0x7f)
|
||||
code = '?';
|
||||
|
||||
FOR_ACTIVE_TERM_OUTPUTS(term)
|
||||
grub_putcode (code, term);
|
||||
if (code == '\n' && grub_newline_hook)
|
||||
grub_newline_hook ();
|
||||
grub_putcode_dumb (code, term);
|
||||
}
|
||||
}
|
||||
|
||||
void (*grub_xputs) (const char *str) = grub_xputs_dumb;
|
||||
|
||||
int
|
||||
grub_getkey (void)
|
||||
{
|
||||
|
@ -86,9 +87,9 @@ grub_getkey (void)
|
|||
{
|
||||
FOR_ACTIVE_TERM_INPUTS(term)
|
||||
{
|
||||
int key = term->checkkey ();
|
||||
int key = term->checkkey (term);
|
||||
if (key != -1)
|
||||
return term->getkey ();
|
||||
return term->getkey (term);
|
||||
}
|
||||
|
||||
grub_cpu_idle ();
|
||||
|
@ -102,7 +103,7 @@ grub_checkkey (void)
|
|||
|
||||
FOR_ACTIVE_TERM_INPUTS(term)
|
||||
{
|
||||
int key = term->checkkey ();
|
||||
int key = term->checkkey (term);
|
||||
if (key != -1)
|
||||
return key;
|
||||
}
|
||||
|
@ -119,38 +120,12 @@ grub_getkeystatus (void)
|
|||
FOR_ACTIVE_TERM_INPUTS(term)
|
||||
{
|
||||
if (term->getkeystatus)
|
||||
status |= term->getkeystatus ();
|
||||
status |= term->getkeystatus (term);
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
void
|
||||
grub_cls (void)
|
||||
{
|
||||
struct grub_term_output *term;
|
||||
|
||||
FOR_ACTIVE_TERM_OUTPUTS(term)
|
||||
{
|
||||
if ((term->flags & GRUB_TERM_DUMB) || (grub_env_get ("debug")))
|
||||
{
|
||||
grub_putcode ('\n', term);
|
||||
grub_term_refresh (term);
|
||||
}
|
||||
else
|
||||
(term->cls) ();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
grub_setcolorstate (grub_term_color_state state)
|
||||
{
|
||||
struct grub_term_output *term;
|
||||
|
||||
FOR_ACTIVE_TERM_OUTPUTS(term)
|
||||
grub_term_setcolorstate (term, state);
|
||||
}
|
||||
|
||||
void
|
||||
grub_refresh (void)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue