[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
PUPA shell
From: |
Marco Gerards |
Subject: |
PUPA shell |
Date: |
30 Sep 2003 00:04:51 +0200 |
User-agent: |
Gnus/5.09 (Gnus v5.9.0) Emacs/21.2 |
Hi,
As I told you earlier, I'm hacking the PUPA console so it works on
GNU/Linux. (I haven't tried other OSes yet).
Here is the patch that makes it work. I know it is far from perfect,
I didn't even include a changelog entry.
I just want to send in patches early so people can see my progress and
comment on them. It is also a good way to ensure patches don't get
lost. If you think it is stupid and I should wait longer before I
send in patches, please tell me.
I have a new job so I have to ask work to sign some papers, do I have
to ask the FSF to send me some assignment papers for GRUB and/or PUPA?
(I will do some more work in the future).
Thanks,
Marco
diff -uprN pupa.orig/pupa/CVS/Entries pupa/CVS/Entries
--- pupa.orig/pupa/CVS/Entries 2003-09-29 23:32:53.000000000 +0200
+++ pupa/CVS/Entries 2003-09-29 23:40:54.000000000 +0200
@@ -33,3 +33,4 @@ D/util////
/config.h.in/1.3/Sat Sep 27 16:00:12 2003//
/configure/1.5/Sat Sep 27 16:00:13 2003//
/genmk.rb/1.5/Sat Sep 27 16:00:13 2003//
+D/font////
diff -uprN pupa.orig/pupa/CVS/Entries.Log pupa/CVS/Entries.Log
--- pupa.orig/pupa/CVS/Entries.Log 2003-09-29 23:32:53.000000000 +0200
+++ pupa/CVS/Entries.Log 1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-A D/font////
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-09-29 23:40:06.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
noinst_UTILITIES = genmoddep
# For pupa-mkimage.
@@ -57,6 +57,21 @@ 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_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.c util/misc.c
+pupa_LDFLAGS = -lncurses
+
+kernel_img_HEADERS = boot.h device.h disk.h dl.h elf.h err.h \
+ file.h fs.h kernel.h loader.h misc.h mm.h net.h rescue.h symbol.h \
+ term.h types.h machine/biosdisk.h machine/boot.h \
+ machine/console.h machine/init.h machine/memory.h \
+ machine/loader.h machine/partition.h machine/vga.h
+
# 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-29 23:36:14.000000000 +0200
@@ -0,0 +1,36 @@
+/* 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/machine/console.h>
+#include <pupa/dl.h>
+
+static char *
+make_install_device (void)
+{
+ /* XXX: Use root device. */
+ return "(fd0)";
+}
+
+void
+pupa_machine_init (void)
+{
+ pupa_console_init ();
+ pupa_dl_set_prefix (make_install_device ());
+}
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.c pupa/util/pupa.c
--- pupa.orig/pupa/util/pupa.c 1970-01-01 01:00:00.000000000 +0100
+++ pupa/util/pupa.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;
+}
- PUPA shell,
Marco Gerards <=