[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: PUPA shell
From: |
Marco Gerards |
Subject: |
Re: PUPA shell |
Date: |
02 Oct 2003 21:39:14 +0200 |
User-agent: |
Gnus/5.09 (Gnus v5.9.0) Emacs/21.2 |
Yoshinori Okuji <address@hidden> writes:
[...]
> IMO, the grub shell should be renamed to the grub emulator or something. And,
> the executable should be called "grub-emulator" or something similar.
>
> Likewise, your executable should be renamed to pupa-emulator or something, and
> we should call it "the pupa emulator".
>
> What do you think?
When you started talking about it I suddenly remembered:
http://mail.gnu.org/archive/html/pupa-devel/2002-08/msg00000.html
(I forgot about this, sorry)
For me both names are clear, but I understand why you want to change
the name.
Here is a new patch with the changed name. Please do not forget to
regenerate "conf/i386-pc.mk".
Thanks,
Marco
30-09-2003 Marco Gerards <address@hidden>
* conf/i386-pc.rmk (sbin_UTILITIES): Add pupa-emu.
(pupa_emu_SOURCES): New variable.
(pupa_emu_LDFLAGS): Likewise.
* kern/posix/dl.c: New file.
* kern/posix/init.c: Likewise.
* term/posix/ncurses/console.c: Likewise.
* util/pupa-emu.c: Likewise.
* util/misc.c (pupa_putchar): Move function from here...
* util/i386/pc/pupa-setup.c: ... to here.
diff -uprN pupa.orig/pupa/conf/i386-pc.rmk pupa/conf/i386-pc.rmk
--- pupa.orig/pupa/conf/i386-pc.rmk 2003-09-29 23:32:53.000000000 +0200
+++ pupa/conf/i386-pc.rmk 2003-10-02 21:32:10.000000000 +0200
@@ -44,7 +44,7 @@ kernel_syms.lst: $(addprefix include/pup
# Utilities.
bin_UTILITIES = pupa-mkimage
-sbin_UTILITIES = pupa-setup
+sbin_UTILITIES = pupa-setup pupa-emu
noinst_UTILITIES = genmoddep
# For pupa-mkimage.
@@ -57,6 +57,15 @@ pupa_setup_SOURCES = util/i386/pc/pupa-s
util/misc.c kern/device.c kern/disk.c kern/file.c kern/fs.c \
kern/err.c kern/misc.c disk/i386/pc/partition.c fs/fat.c
+# For pupa
+pupa_emu_SOURCES = kern/main.c kern/device.c \
+ kern/disk.c kern/dl.c kern/file.c kern/fs.c kern/err.c \
+ kern/misc.c kern/loader.c kern/rescue.c kern/term.c \
+ disk/i386/pc/partition.c kern/posix/dl.c kern/posix/init.c \
+ util/i386/pc/biosdisk.c fs/fat.c \
+ term/posix/ncurses/console.c util/pupa-emu.c util/misc.c
+pupa_emu_LDFLAGS = -lncurses
+
# For genmoddep.
genmoddep_SOURCES = util/genmoddep.c
diff -uprN pupa.orig/pupa/kern/posix/dl.c pupa/kern/posix/dl.c
--- pupa.orig/pupa/kern/posix/dl.c 1970-01-01 01:00:00.000000000 +0100
+++ pupa/kern/posix/dl.c 2003-09-29 23:35:26.000000000 +0200
@@ -0,0 +1,39 @@
+/* dl.c -- PUPA dynamic libraries on POSIX. */
+/*
+ * PUPA -- Preliminary Universal Programming Architecture for GRUB
+ * Copyright (C) 2003 Marco Gerards <address@hidden>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <pupa/dl.h>
+
+int
+pupa_arch_dl_check_header (void *ehdr, pupa_size_t size)
+{
+ (void) ehdr;
+ (void) size;
+
+ return 0;
+}
+
+pupa_err_t
+pupa_arch_dl_relocate_symbols (pupa_dl_t mod, void *ehdr)
+{
+ (void) mod;
+ (void) ehdr;
+
+ return 0;
+}
diff -uprN pupa.orig/pupa/kern/posix/init.c pupa/kern/posix/init.c
--- pupa.orig/pupa/kern/posix/init.c 1970-01-01 01:00:00.000000000 +0100
+++ pupa/kern/posix/init.c 2003-09-30 19:35:34.000000000 +0200
@@ -0,0 +1,31 @@
+/* init.c -- Initialization of PUPA on a POSIX OS. */
+/*
+ * PUPA -- Preliminary Universal Programming Architecture for GRUB
+ * Copyright (C) 2003 Marco Gerards <address@hidden>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <pupa/dl.h>
+#include <pupa/misc.h>
+#include <pupa/machine/console.h>
+
+void
+pupa_machine_init (void)
+{
+ /* XXX: Use (fd0) for now. */
+ pupa_console_init ();
+ pupa_dl_set_prefix ("(fd0)");
+}
diff -uprN pupa.orig/pupa/term/posix/ncurses/console.c
pupa/term/posix/ncurses/console.c
--- pupa.orig/pupa/term/posix/ncurses/console.c 1970-01-01 01:00:00.000000000
+0100
+++ pupa/term/posix/ncurses/console.c 2003-09-29 23:34:12.000000000 +0200
@@ -0,0 +1,133 @@
+/* console.c -- Ncurses console for PUPA. */
+/*
+ * PUPA -- Preliminary Universal Programming Architecture for GRUB
+ * Copyright (C) 2003 Marco Gerards <address@hidden>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <curses.h>
+#include <pupa/machine/console.h>
+#include <pupa/term.h>
+#include <pupa/types.h>
+
+static void
+pupa_ncurses_putchar (pupa_uint32_t c)
+{
+ addch (c);
+ refresh ();
+}
+
+static void
+pupa_ncurses_setcolorstate (pupa_term_color_state state)
+{
+ (void) state;
+}
+
+static void
+pupa_ncurses_setcolor (pupa_uint8_t normal_color, pupa_uint8_t highlight_color)
+{
+ (void) normal_color;
+ (void) highlight_color;
+}
+
+static int
+pupa_ncurses_checkkey (void)
+{
+ return 1;
+}
+
+static int
+pupa_ncurses_getkey (void)
+{
+ return getch ();
+}
+
+static pupa_uint16_t
+pupa_ncurses_getxy (void)
+{
+ int x;
+ int y;
+
+ getyx (stdscr, y, x);
+
+ return (x << 8) | y;
+}
+
+static void
+pupa_ncurses_gotoxy (pupa_uint8_t x, pupa_uint8_t y)
+{
+ move (y, x);
+}
+
+static void
+pupa_ncurses_cls (void)
+{
+ clear ();
+ refresh ();
+}
+
+static void
+pupa_ncurses_setcursor (int on)
+{
+ (void) on;
+}
+
+static pupa_err_t
+pupa_ncurses_init (void)
+{
+ initscr ();
+ cbreak ();
+ noecho ();
+ scrollok (stdscr, TRUE);
+
+ nonl ();
+ intrflush (stdscr, FALSE);
+ keypad (stdscr, TRUE);
+
+ return 0;
+}
+
+static pupa_err_t
+pupa_ncurses_fini (void)
+{
+ endwin ();
+}
+
+
+static struct pupa_term pupa_ncurses_term =
+ {
+ .name = "console",
+ .init = pupa_ncurses_init,
+ .fini = pupa_ncurses_fini,
+ .putchar = pupa_ncurses_putchar,
+ .checkkey = pupa_ncurses_checkkey,
+ .getkey = pupa_ncurses_getkey,
+ .getxy = pupa_ncurses_getxy,
+ .gotoxy = pupa_ncurses_gotoxy,
+ .cls = pupa_ncurses_cls,
+ .setcolorstate = pupa_ncurses_setcolorstate,
+ .setcolor = pupa_ncurses_setcolor,
+ .setcursor = pupa_ncurses_setcursor,
+ .flags = 0,
+ .next = 0
+ };
+
+void
+pupa_console_init (void)
+{
+ pupa_term_register (&pupa_ncurses_term);
+ pupa_term_set_current (&pupa_ncurses_term);
+}
diff -uprN pupa.orig/pupa/util/i386/pc/pupa-setup.c
pupa/util/i386/pc/pupa-setup.c
--- pupa.orig/pupa/util/i386/pc/pupa-setup.c 2003-09-29 23:32:53.000000000
+0200
+++ pupa/util/i386/pc/pupa-setup.c 2003-09-29 23:34:12.000000000 +0200
@@ -62,6 +62,11 @@ struct boot_blocklist
pupa_uint16_t segment;
} __attribute__ ((packed));
+pupa_putchar (int c)
+{
+ putchar (c);
+}
+
static void
setup (const char *prefix, const char *dir,
const char *boot_file, const char *core_file,
diff -uprN pupa.orig/pupa/util/misc.c pupa/util/misc.c
--- pupa.orig/pupa/util/misc.c 2003-09-29 23:32:53.000000000 +0200
+++ pupa/util/misc.c 2003-09-29 23:34:12.000000000 +0200
@@ -192,9 +192,3 @@ pupa_stop (void)
{
exit (1);
}
-
-void
-pupa_putchar (int c)
-{
- putchar (c);
-}
diff -uprN pupa.orig/pupa/util/pupa-emu.c pupa/util/pupa-emu.c
--- pupa.orig/pupa/util/pupa-emu.c 1970-01-01 01:00:00.000000000 +0100
+++ pupa/util/pupa-emu.c 2003-09-29 23:34:12.000000000 +0200
@@ -0,0 +1,67 @@
+/*
+ * PUPA -- Preliminary Universal Programming Architecture for GRUB
+ * Copyright (C) 2003 Marco Gerards <address@hidden>
+ *
+ * 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 <stdlib.h>
+#include <malloc.h>
+
+#include <pupa/mm.h>
+#include <pupa/setjmp.h>
+#include <pupa/fs.h>
+#include <pupa/i386/pc/util/biosdisk.h>
+
+void *
+pupa_memalign (pupa_size_t align, pupa_size_t size)
+{
+ return memalign (align, size);
+}
+
+
+/* Some functions that we don't use. */
+void
+pupa_mm_init_region (void *addr, pupa_size_t size)
+{
+}
+
+void
+pupa_register_exported_symbols (void)
+{
+}
+
+/* XXX. */
+pupa_addr_t pupa_end_addr = -1;
+
+pupa_addr_t pupa_total_module_size = 0;
+
+
+int
+main (int argc, char *argv[])
+{
+ /* Initialize the default modules. */
+ pupa_fat_init ();
+ /* XXX: Use a fixed device.map location for now. */
+ pupa_util_biosdisk_init ("/boot/grub/device.map");
+
+ /* Start PUPA! */
+ pupa_main ();
+
+ pupa_util_biosdisk_fini ();
+ pupa_fat_fini ();
+
+ return 0;
+}