012d7999fe
* util/i386/pc/pupa-setup.c (setup): Define the internal function find_first_partition_start at the top level, because GCC 3.0.x cannot compile internal functions in deeper scopes correctly. (find_root_device): Use lstat instead of stat. Don't follow symbolic links. Fix the path-constructing code. * util/i386/pc/biosdisk.c [__linux__] (BLKFLSBUF): New macro. (pupa_util_biosdisk_open) [__linux__]: Get the size of a device by a BLKGETSIZE ioctl first, because block devices don't fill the member st_mode of the structure stat on Linux. [__linux__] (linux_find_partition): Use a temporary buffer REAL_DEV for the working space. Copy it to DEV before returning. (open_device) [__linux__]: Call ioctl with BLKFLSBUF to make the buffer cache consistent. (get_os_disk) [__linux__]: Use the length 5 instead of 4 for strncmp. The previous value was merely wrong. (pupa_util_biosdisk_get_pupa_dev): Use stat instead of lstat. * fs/fat.c (pupa_fat_read_data): Shift 4 instead of 12 when the FAT size is 12. The previous value was merely wrong. * kern/main.c (pupa_main): Don't split the starting message from newlines. * kern/term.c (pupa_putchar): Put CR after LF instead of before LF, because BIOS goes crazy about character attributes in this case.
154 lines
2.8 KiB
C
154 lines
2.8 KiB
C
/*
|
|
* PUPA -- Preliminary Universal Programming Architecture for GRUB
|
|
* Copyright (C) 2002 Free Software Foundation, Inc.
|
|
* Copyright (C) 2002 Yoshinori K. Okuji <okuji@enbug.org>
|
|
*
|
|
* PUPA is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with PUPA; if not, write to the Free Software
|
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
*/
|
|
|
|
#include <pupa/term.h>
|
|
#include <pupa/err.h>
|
|
#include <pupa/mm.h>
|
|
|
|
/* The list of terminals. */
|
|
static pupa_term_t pupa_term_list;
|
|
|
|
/* The current terminal. */
|
|
static pupa_term_t pupa_cur_term;
|
|
|
|
void
|
|
pupa_term_register (pupa_term_t term)
|
|
{
|
|
term->next = pupa_term_list;
|
|
pupa_term_list = term;
|
|
}
|
|
|
|
void
|
|
pupa_term_unregister (pupa_term_t term)
|
|
{
|
|
pupa_term_t *p, q;
|
|
|
|
for (p = &pupa_term_list, q = *p; q; p = &(q->next), q = q->next)
|
|
if (q == term)
|
|
{
|
|
*p = q->next;
|
|
break;
|
|
}
|
|
}
|
|
|
|
void
|
|
pupa_term_iterate (int (*hook) (pupa_term_t term))
|
|
{
|
|
pupa_term_t p;
|
|
|
|
for (p = pupa_term_list; p; p = p->next)
|
|
if (hook (p))
|
|
break;
|
|
}
|
|
|
|
void
|
|
pupa_term_set_current (pupa_term_t term)
|
|
{
|
|
pupa_cur_term = term;
|
|
}
|
|
|
|
pupa_term_t
|
|
pupa_term_get_current (void)
|
|
{
|
|
return pupa_cur_term;
|
|
}
|
|
|
|
void
|
|
pupa_putchar (int c)
|
|
{
|
|
if (c == '\t' && pupa_cur_term->getxy)
|
|
{
|
|
int n;
|
|
|
|
n = 8 - ((pupa_getxy () >> 8) & 7);
|
|
while (n--)
|
|
pupa_putchar (' ');
|
|
|
|
return;
|
|
}
|
|
|
|
(pupa_cur_term->putchar) (c);
|
|
|
|
if (c == '\n')
|
|
pupa_putchar ('\r');
|
|
}
|
|
|
|
int
|
|
pupa_getkey (void)
|
|
{
|
|
return (pupa_cur_term->getkey) ();
|
|
}
|
|
|
|
int
|
|
pupa_checkkey (void)
|
|
{
|
|
return (pupa_cur_term->checkkey) ();
|
|
}
|
|
|
|
pupa_uint16_t
|
|
pupa_getxy (void)
|
|
{
|
|
return (pupa_cur_term->getxy) ();
|
|
}
|
|
|
|
void
|
|
pupa_gotoxy (pupa_uint8_t x, pupa_uint8_t y)
|
|
{
|
|
(pupa_cur_term->gotoxy) (x, y);
|
|
}
|
|
|
|
void
|
|
pupa_cls (void)
|
|
{
|
|
if (pupa_cur_term->flags & PUPA_TERM_DUMB)
|
|
pupa_putchar ('\n');
|
|
else
|
|
(pupa_cur_term->cls) ();
|
|
}
|
|
|
|
void
|
|
pupa_setcolorstate (pupa_term_color_state state)
|
|
{
|
|
if (pupa_cur_term->setcolorstate)
|
|
(pupa_cur_term->setcolorstate) (state);
|
|
}
|
|
|
|
void
|
|
pupa_setcolor (pupa_uint8_t normal_color, pupa_uint8_t highlight_color)
|
|
{
|
|
if (pupa_cur_term->setcolor)
|
|
(pupa_cur_term->setcolor) (normal_color, highlight_color);
|
|
}
|
|
|
|
int
|
|
pupa_setcursor (int on)
|
|
{
|
|
static int prev = 1;
|
|
int ret = prev;
|
|
|
|
if (pupa_cur_term->setcursor)
|
|
{
|
|
(pupa_cur_term->setcursor) (on);
|
|
prev = on;
|
|
}
|
|
|
|
return ret;
|
|
}
|
|
|