diff --git a/ChangeLog b/ChangeLog index f4c40c157..d76435612 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,24 @@ +2000-01-05 OKUJI Yoshinori + + * grub/asmstub.c: Include the header shared.h after including + all the system headers, but not before. + (EXTENDED_MEMSIZE): Reduced to 3MB. + (grub_setjmp): New function. + (grub_longjmp): Likewise. + * grub/main.c: Include setjmp.h. + * stage2/asm.S (grub_setjmp): New function. Stolen from the + OSKit (which stole it from Mach). + (grub_longjmp): Likewise. + * stage2/shared.h [GRUB_UTIL] (grub_jmp_buf): New type. + [!GRUB_UTIL] (grub_jmp_buf): New macro. Defined as jmp_buf. + (grub_setjmp): Declared. + (grub_longjmp): Likewise. + (restart_env): Likewise. + * stage2/builtins.c (configfile_func): Use grub_longjmp instead + of invoking cmain again. + * stage2/stage2.c (restart_env): New variable. + (cmain): Call grub_setjmp first to initialize RESTART_ENV. + 2000-01-03 OKUJI Yoshinori * docs/multiboot.texi (Boot information format): Added the diff --git a/TODO b/TODO index 32127e4a5..3169f0603 100644 --- a/TODO +++ b/TODO @@ -13,24 +13,24 @@ Priorities: higher priority. -* Add configuration inclusion support by adding a command "include". ! +* Add configuration inclusion support by adding a command "include". -* Make symbolic links work for BSD FFS. !! +* Make symbolic links work for BSD FFS. * Add indirect block support to the BSD FFS filesystem code, so files - larger than 16MB can be read. ! + larger than 16MB can be read. * Fix-up FreeBSD, NetBSD (and OpenBSD ?) command-line boot - parameters. !!! + parameters. * Support embedding a Stage 1.5 in the "bootloader" area of a FFS - partition. !!! + partition. * Support embedding a Stage 1.5 in the EXT2_BOOT_LOADER_INO of an ext2fs partition, so that it won't be accidentally erased or modified by the kernel. -* Complete the netboot support. ! +* Complete the netboot support. !!! This is the proposed interface between the netboot module and the core system: @@ -108,19 +108,19 @@ Priorities: * Add bunzip2 support. -* Define the module system. ! +* Define the module system. * Add ISA PnP support. -* Fix the completion so that it works for BSD partitions as well. !! +* Fix the completion so that it works for BSD partitions as well. ! -* Add BSD syntax support, using results of ioprobe to map drives. +* Add BSD syntax support, using results of ioprobe to map drives. ! (0x1f0-0x1f7 = primary IDE, 0x170-0x176 = secondary, 0x1e8-0x1ef = tertiary, 0x168-0x16f = quaternary). * Add more filesystems support (XFS, NTFS, etc.) -* Add remote console support (serial, parallel and net). +* Add remote console support (serial, parallel and net). !! * Add RAID support. @@ -133,7 +133,4 @@ Priorities: * Add internationalization support, emulating gettext as much as is feasible. -* Fix keyboard/gateA20 bug (???? at least look at the code). The - keyboard status bits may be checked wrong. - ? Add command for modifying partition types. diff --git a/grub/asmstub.c b/grub/asmstub.c index 8ef074a6a..ca3df0fbe 100644 --- a/grub/asmstub.c +++ b/grub/asmstub.c @@ -1,7 +1,7 @@ /* asmstub.c - a version of shared_src/asm.S that works under Unix */ /* * GRUB -- GRand Unified Bootloader - * Copyright (C) 1999 Free Software Foundation, Inc. + * Copyright (C) 1999, 2000 Free Software Foundation, Inc. * * 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 @@ -26,11 +26,6 @@ /* Simulator entry point. */ int grub_stage2 (void); -/* We want to prevent any circularararity in our stubs, as well as - libc name clashes. */ -#define WITHOUT_LIBC_STUBS 1 -#include "shared.h" - #include #include #include @@ -67,8 +62,13 @@ int grub_stage2 (void); # include #endif /* HAVE_OPENDISK */ +/* We want to prevent any circularararity in our stubs, as well as + libc name clashes. */ +#define WITHOUT_LIBC_STUBS 1 +#include "shared.h" + /* Simulated memory sizes. */ -#define EXTENDED_MEMSIZE (4 * 1024 * 1024) /* 4MB */ +#define EXTENDED_MEMSIZE (3 * 1024 * 1024) /* 3MB */ #define CONVENTIONAL_MEMSIZE (640) /* 640kB */ /* Simulated disk sizes. */ @@ -751,6 +751,17 @@ gotoxy (int x, int y) #endif } +int +grub_setjmp (grub_jmp_buf env) +{ + return setjmp (env); +} + +void +grub_longjmp (grub_jmp_buf env, int val) +{ + longjmp (env, val); +} /* displays an ASCII character. IBM displays will translate some characters to special graphical ones */ diff --git a/grub/main.c b/grub/main.c index 4b7e0f0d7..8259baa07 100644 --- a/grub/main.c +++ b/grub/main.c @@ -1,7 +1,7 @@ /* main.c - experimental GRUB stage2 that runs under Unix */ /* * GRUB -- GRand Unified Bootloader - * Copyright (C) 1999 Free Software Foundation, Inc. + * Copyright (C) 1999, 2000 Free Software Foundation, Inc. * * 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 @@ -27,6 +27,7 @@ int grub_stage2 (void); #include #include #include +#include #define WITHOUT_LIBC_STUBS 1 #include "shared.h" diff --git a/stage2/asm.S b/stage2/asm.S index ec46b250b..407f2c59b 100644 --- a/stage2/asm.S +++ b/stage2/asm.S @@ -1,7 +1,7 @@ /* * GRUB -- GRand Unified Bootloader * Copyright (C) 1996 Erich Boleyn - * Copyright (C) 1999 Free Software Foundation, Inc. + * Copyright (C) 1999, 2000 Free Software Foundation, Inc. * * 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 @@ -1247,6 +1247,70 @@ probe_values: ret +/* This is stolen from libc/x86/setjmp.S in the OSKit */ +/* + * Mach Operating System + * Copyright (c) 1991,1990,1989 Carnegie Mellon University + * All Rights Reserved. + * + * Permission to use, copy, modify and distribute this software and its + * documentation is hereby granted, provided that both the copyright + * notice and this permission notice appear in all copies of the + * software, derivative works or modified versions, and any portions + * thereof, and that both notices appear in supporting documentation. + * + * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" + * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR + * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. + * + * Carnegie Mellon requests users of this software to return to + * + * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU + * School of Computer Science + * Carnegie Mellon University + * Pittsburgh PA 15213-3890 + * + * any improvements or extensions that they make and grant Carnegie Mellon + * the rights to redistribute these changes. + */ +/* + * C library -- _setjmp, _longjmp + * + * _longjmp(a,v) + * will generate a "return(v)" from + * the last call to + * _setjmp(a) + * by restoring registers from the stack, + * The previous signal state is NOT restored. + * + */ + +ENTRY(grub_setjmp) + movl 4(%esp), %ecx /* fetch buffer */ + movl %ebx, 0(%ecx) + movl %esi, 4(%ecx) + movl %edi, 8(%ecx) + movl %ebp, 12(%ecx) /* save frame pointer of caller */ + popl %edx + movl %esp, 16(%ecx) /* save stack pointer of caller */ + movl %edx, 20(%ecx) /* save pc of caller */ + xorl %eax, %eax + jmp *%edx + +ENTRY(grub_longjmp) + movl 8(%esp), %eax /* return(v) */ + movl 4(%esp), %ecx /* fetch buffer */ + movl 0(%ecx), %ebx + movl 4(%ecx), %esi + movl 8(%ecx), %edi + movl 12(%ecx), %ebp + movl 16(%ecx), %esp + orl %eax, %eax + jnz 0f + incl %eax +0: jmp *20(%ecx) /* done, return.... */ + + /* * putchar(c) : Puts character on the screen, interpreting '\n' as in the * UNIX fashion. diff --git a/stage2/builtins.c b/stage2/builtins.c index 6280c0aff..8bf7a453c 100644 --- a/stage2/builtins.c +++ b/stage2/builtins.c @@ -2,7 +2,7 @@ /* * GRUB -- GRand Unified Bootloader * Copyright (C) 1996 Erich Boleyn - * Copyright (C) 1999 Free Software Foundation, Inc. + * Copyright (C) 1999, 2000 Free Software Foundation, Inc. * * 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 @@ -451,7 +451,7 @@ configfile_func (char *arg, int flags) #endif /* Restart cmain. */ - cmain (); + grub_longjmp (restart_env, 0); /* Never reach here. */ return 0; diff --git a/stage2/shared.h b/stage2/shared.h index 91ac2a8f6..7ab25ec6e 100644 --- a/stage2/shared.h +++ b/stage2/shared.h @@ -2,7 +2,7 @@ /* * GRUB -- GRand Unified Bootloader * Copyright (C) 1996 Erich Boleyn - * Copyright (C) 1999 Free Software Foundation, Inc. + * Copyright (C) 1999, 2000 Free Software Foundation, Inc. * * 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 @@ -689,6 +689,20 @@ int grub_strcmp (const char *s1, const char *s2); int grub_strlen (const char *str); char *grub_strcpy (char *dest, const char *src); +#ifndef GRUB_UTIL +typedef unsigned long grub_jmp_buf[6]; +#else +/* In the grub shell, use the libc jmp_buf instead. */ +# include +# define grub_jmp_buf jmp_buf +#endif + +int grub_setjmp (grub_jmp_buf env); +void grub_longjmp (grub_jmp_buf env, int val); + +/* The environment for restarting Stage 2. */ +extern grub_jmp_buf restart_env; + /* misc */ void init_page (void); void print_error (void); diff --git a/stage2/stage2.c b/stage2/stage2.c index 993245101..2ab16af9e 100644 --- a/stage2/stage2.c +++ b/stage2/stage2.c @@ -19,6 +19,8 @@ #include "shared.h" +grub_jmp_buf restart_env; + static char * get_entry (char *list, int num, int nested) { @@ -580,6 +582,9 @@ cmain (void) char *config_entries, *menu_entries; char *kill = (char *) KILL_BUF; + /* Initialize the environment for restarting Stage 2. */ + grub_setjmp (restart_env); + /* Initialize the kill buffer. */ *kill = 0;