diff -rPu grub-0.93.orig/build grub-0.93.openbsd/build --- grub-0.93.orig/build Thu Jan 1 01:00:00 1970 +++ grub-0.93.openbsd/build Thu Jun 12 00:58:05 2003 @@ -0,0 +1,18 @@ +#!/bin/sh +DESTDIR=/tmp +runit() { + ./configure --enable-diskless $2 $3 $4 $5 && make && \ + cp stage2/pxegrub $1 && make clean +} +rm -f $DESTDIR/pxegrub* +make clean +runit $DESTDIR/pxegrub.sis-tty-19200 --enable-natsemi \ + --enable-preset-menu=preset.tty-19200 +runit $DESTDIR/pxegrub.fxp --enable-eepro100 \ + --enable-preset-menu=preset.console +runit $DESTDIR/pxegrub.fxp-tty --enable-eepro100 \ + --enable-preset-menu=preset.tty +runit $DESTDIR/pxegrub.fxp-dpci --enable-eepro100 --enable-pci-direct \ + --enable-preset-menu=preset.console +runit $DESTDIR/pxegrub.fxp-tty-dpci --enable-eepro100 --enable-pci-direct \ + --enable-preset-menu=preset.tty diff -rPu grub-0.93.orig/grub/asmstub.c grub-0.93.openbsd/grub/asmstub.c --- grub-0.93.orig/grub/asmstub.c Tue Dec 3 00:20:45 2002 +++ grub-0.93.openbsd/grub/asmstub.c Thu Jun 12 01:00:09 2003 @@ -71,7 +71,7 @@ unsigned long boot_drive = 0; int saved_entryno = 0; char version_string[] = VERSION; -char config_file[128] = "/boot/grub/menu.lst"; /* FIXME: arbitrary */ +char config_file[128] = "//grub.conf"; /* FIXME: arbitrary */ unsigned long linux_text_len = 0; char *linux_data_tmp_addr = 0; char *linux_data_real_addr = 0; diff -rPu grub-0.93.orig/netboot/etherboot.h grub-0.93.openbsd/netboot/etherboot.h --- grub-0.93.orig/netboot/etherboot.h Wed May 8 09:08:04 2002 +++ grub-0.93.openbsd/netboot/etherboot.h Thu Jun 12 01:03:14 2003 @@ -45,7 +45,7 @@ /* FIXME: Should be an option. */ #define BACKOFF_LIMIT 7 -#include +#include "osdep.h" #define CTRL_C 3 diff -rPu grub-0.93.orig/netboot/fsys_tftp.c grub-0.93.openbsd/netboot/fsys_tftp.c --- grub-0.93.orig/netboot/fsys_tftp.c Wed May 8 09:08:49 2002 +++ grub-0.93.openbsd/netboot/fsys_tftp.c Thu Jun 12 01:03:17 2003 @@ -417,6 +417,9 @@ grub_printf ("tftp_dir (%s)\n", dirname); #endif + if(dirname[0] == '/' && dirname[1] == '/') + dirname += 2; /* allow relative files by specifying two '/' */ + /* In TFTP, there is no way to know what files exist. */ if (print_possibilities) return 1; diff -rPu grub-0.93.orig/netboot/main.c grub-0.93.openbsd/netboot/main.c --- grub-0.93.orig/netboot/main.c Wed Jun 12 10:58:18 2002 +++ grub-0.93.openbsd/netboot/main.c Thu Jun 12 01:03:20 2003 @@ -53,7 +53,7 @@ struct rom_info rom; static int vendorext_isvalid; -static unsigned long netmask; +unsigned long netmask; static struct bootpd_t bootp_data; static unsigned long xid; static unsigned char *end_of_rfc1533 = NULL; diff -rPu grub-0.93.orig/preset.console grub-0.93.openbsd/preset.console --- grub-0.93.orig/preset.console Thu Jan 1 01:00:00 1970 +++ grub-0.93.openbsd/preset.console Thu Jun 12 01:03:20 2003 @@ -0,0 +1 @@ +bootp diff -rPu grub-0.93.orig/preset.tty grub-0.93.openbsd/preset.tty --- grub-0.93.orig/preset.tty Thu Jan 1 01:00:00 1970 +++ grub-0.93.openbsd/preset.tty Thu Jun 12 01:03:20 2003 @@ -0,0 +1,3 @@ +serial --unit=0 +terminal --dumb --timeout=0 serial +bootp diff -rPu grub-0.93.orig/preset.tty-19200 grub-0.93.openbsd/preset.tty-19200 --- grub-0.93.orig/preset.tty-19200 Thu Jan 1 01:00:00 1970 +++ grub-0.93.openbsd/preset.tty-19200 Thu Jun 12 01:03:20 2003 @@ -0,0 +1,3 @@ +serial --unit=0 --speed=19200 +terminal --dumb --timeout=0 serial +bootp diff -rPu grub-0.93.orig/stage2/asm.S grub-0.93.openbsd/stage2/asm.S --- grub-0.93.orig/stage2/asm.S Tue Dec 3 00:18:56 2002 +++ grub-0.93.openbsd/stage2/asm.S Thu Jun 12 01:03:23 2003 @@ -97,7 +97,7 @@ .string VERSION VARIABLE(config_file) #ifndef STAGE1_5 - .string "/boot/grub/menu.lst" + .string "//grub.conf" #else /* STAGE1_5 */ .long 0xffffffff .string "/boot/grub/stage2" diff -rPu grub-0.93.orig/stage2/boot.c grub-0.93.openbsd/stage2/boot.c --- grub-0.93.orig/stage2/boot.c Sat Nov 30 18:29:16 2002 +++ grub-0.93.openbsd/stage2/boot.c Thu Jun 12 01:03:26 2003 @@ -95,10 +95,12 @@ or bzImage. */ lh = (struct linux_kernel_header *) buffer; - /* ELF loading supported if multiboot, FreeBSD and NetBSD. */ + /* ELF loading supported if multiboot, FreeBSD, OpenBSD and NetBSD. */ if ((type == KERNEL_TYPE_MULTIBOOT || pu.elf->e_ident[EI_OSABI] == ELFOSABI_FREEBSD || grub_strcmp (pu.elf->e_ident + EI_BRAND, "FreeBSD") == 0 + || suggested_type == 0 + || suggested_type == KERNEL_TYPE_OPENBSD || suggested_type == KERNEL_TYPE_NETBSD) && len > sizeof (Elf32_Ehdr) && BOOTABLE_I386_ELF ((*((Elf32_Ehdr *) buffer)))) @@ -128,11 +130,17 @@ str2 = "NetBSD"; type = suggested_type; } - else + else if (suggested_type == KERNEL_TYPE_FREEBSD || + pu.elf->e_ident[EI_OSABI] == ELFOSABI_FREEBSD) { str2 = "FreeBSD"; type = KERNEL_TYPE_FREEBSD; } + else + { + str2 = "OpenBSD"; + type = KERNEL_TYPE_OPENBSD; + } } } else if (flags & MULTIBOOT_AOUT_KLUDGE) @@ -196,11 +204,11 @@ } else { - type = KERNEL_TYPE_NETBSD; + type = KERNEL_TYPE_OPENBSD; cur_addr = (int) entry_addr & 0xF00000; if (N_GETMAGIC ((*(pu.aout))) != NMAGIC) align_4k = 0; - str2 = "NetBSD"; + str2 = "OpenBSD"; } } @@ -593,7 +601,8 @@ grub_seek (phdr->p_offset); filesiz = phdr->p_filesz; - if (type == KERNEL_TYPE_FREEBSD || type == KERNEL_TYPE_NETBSD) + if (type == KERNEL_TYPE_FREEBSD || type == KERNEL_TYPE_NETBSD + || type == KERNEL_TYPE_OPENBSD) memaddr = RAW_ADDR (phdr->p_paddr & 0xFFFFFF); else memaddr = RAW_ADDR (phdr->p_paddr); @@ -1001,3 +1010,10 @@ extended_memory, mbi.mem_lower); } } + +#ifdef GRUB_UTIL +void openbsd_boot (kernel_t type, int bootdev, char *arg) + { bsd_boot(type, bootdev, arg);} +#else +#include "openbsd.c" +#endif diff -rPu grub-0.93.orig/stage2/builtins.c grub-0.93.openbsd/stage2/builtins.c --- grub-0.93.orig/stage2/builtins.c Wed Dec 4 05:41:57 2002 +++ grub-0.93.openbsd/stage2/builtins.c Thu Jun 12 01:03:30 2003 @@ -252,6 +252,10 @@ bsd_boot (kernel_type, bootdev, (char *) mbi.cmdline); break; + case KERNEL_TYPE_OPENBSD: + openbsd_boot (kernel_type, bootdev, (char *) mbi.cmdline); + break; + case KERNEL_TYPE_LINUX: /* Linux */ linux_boot (); @@ -2307,9 +2311,7 @@ else if (grub_memcmp (arg, "freebsd", 7) == 0) suggested_type = KERNEL_TYPE_FREEBSD; else if (grub_memcmp (arg, "openbsd", 7) == 0) - /* XXX: For now, OpenBSD is identical to NetBSD, from GRUB's - point of view. */ - suggested_type = KERNEL_TYPE_NETBSD; + suggested_type = KERNEL_TYPE_OPENBSD; else if (grub_memcmp (arg, "linux", 5) == 0) suggested_type = KERNEL_TYPE_LINUX; else if (grub_memcmp (arg, "biglinux", 8) == 0) @@ -3244,6 +3246,8 @@ "Save the current entry as the default boot entry." }; +long boot_serial_unit = 0; +long boot_serial_speed = 0; #ifdef SUPPORT_SERIAL /* serial */ @@ -3252,6 +3256,7 @@ { unsigned short port = serial_hw_get_port (0); unsigned int speed = 9600; + int unit = 0; int word_len = UART_8BITS_WORD; int parity = UART_NO_PARITY; int stop_bit_len = UART_1_STOP_BIT; @@ -3264,7 +3269,6 @@ if (grub_memcmp (arg, "--unit=", sizeof ("--unit=") - 1) == 0) { char *p = arg + sizeof ("--unit=") - 1; - int unit; if (! safe_parse_maxint (&p, &unit)) return 1; @@ -3378,6 +3382,8 @@ return 1; } + boot_serial_unit = unit; + boot_serial_speed = speed; return 0; } diff -rPu grub-0.93.orig/stage2/openbsd.c grub-0.93.openbsd/stage2/openbsd.c --- grub-0.93.orig/stage2/openbsd.c Thu Jan 1 01:00:00 1970 +++ grub-0.93.openbsd/stage2/openbsd.c Thu Jun 12 01:03:30 2003 @@ -0,0 +1,229 @@ +/* + * openbsd.c + * + * Hack to make GRUB boot OpenBSD from the network + * Booting from the hard drive will require a slightly + * different boot vector + */ + + +/************************** + * From sys/stand/boot/bootarg.h + */ +#define BOOTARG_APIVER (BAPIV_VECTOR|BAPIV_ENV|BAPIV_BMEMMAP) +#define BAPIV_ANCIENT 0x00000000 /* MD old i386 bootblocks */ +#define BAPIV_VARS 0x00000001 /* MD structure w/ add info passed */ +#define BAPIV_VECTOR 0x00000002 /* MI vector of MD structures passed */ +#define BAPIV_ENV 0x00000004 /* MI environment vars vector */ +#define BAPIV_BMEMMAP 0x00000008 /* MI memory map passed is in bytes */ +typedef struct _boot_args { + int ba_type; + long ba_size; + struct _boot_args *_dummy; +// int ba_arg[1]; +} bootarg_t; +#define BOOTARG_END -1 + + +/************************** + * From sys/arch/i386/include/biosvar.h + */ + +/* + * BIOS memory info + */ +#define BOOTARG_MEMMAP 0 +#define BIOS_MAP_END 0x00 /* End of array XXX - special */ +#define BIOS_MAP_FREE 0x01 /* Usable memory */ +#define BIOS_MAP_RES 0x02 /* Reserved memory */ +#define BIOS_MAP_ACPI 0x03 /* ACPI Reclaim memory */ +#define BIOS_MAP_NVS 0x04 /* ACPI NVS memory */ +typedef struct _bios_memmap { + unsigned long long addr; /* Beginning of block */ + unsigned long long size; /* Size of block */ + unsigned long type; /* Type of block */ +} bios_memmap_t; + +/* + * console info + * tty00 is major=8/minor=0 + */ +#define BOOTARG_CONSDEV 5 +typedef struct _bios_consdev { + int consdev; + int conspeed; +} bios_consdev_t; + +/* + * diskless info + */ +#define BOOTARG_IP4INFO 6 +typedef struct _bios_ip4info { + unsigned long ip4_myaddr; /* if != 0, my IP address, as used by boot */ + unsigned long ip4_mymask; /* if != 0, my IP netmask, as used by boot */ + unsigned long ip4_mybcast; /* if != 0, my IP broadcast address */ +} bios_ip4info_t; + +#define BOOTARG_LINKADDR 7 +typedef struct _bios_linkaddr { + unsigned char la_type; /* IFT_ETHER = 6 */ + unsigned char la_alen; /* 6 */ + unsigned char la_addr[6]; /* the ethernet boot MAC address */ +} bios_linkaddr_t; + + +/************************** + * my bad hack + */ + +/* + * our custom block + */ +struct diskless_bootinfo_s { + bootarg_t memarg; + bios_memmap_t memmap[3]; + bootarg_t ttyarg; + bios_consdev_t ttyinfo; + bootarg_t ip4arg; + bios_ip4info_t ip4info; + bootarg_t laarg; + bios_linkaddr_t lainfo; + bootarg_t endarg; +}; + +static void xxx_memcpy(long *dst, long *src, int len) { + while(len>0) { + *dst++ = *src++; + len -= 4; + } +} + +#include "../netboot/etherboot.h" +#include "term.h" +extern struct arptable_t arptable[]; +extern unsigned long netmask; +extern long boot_serial_unit; +extern long boot_serial_speed; + +/* + * All "*_boot" commands depend on the images being loaded into memory + * correctly, the variables in this file being set up correctly, and + * the root partition being set in the 'saved_drive' and 'saved_partition' + * variables. + */ +void +openbsd_boot (kernel_t type, int bootdev, char *arg) +{ + char *str; + int clval = 0; + struct diskless_bootinfo_s bv; + + /* call entry point */ + unsigned long end_mark; + +#ifdef GRUB_UTIL + entry_addr = (entry_func) bsd_boot_entry; +#else + stop_floppy (); +#endif + + while(*(++arg) && *arg != ' '); + str = arg; + while(*str) { + if(*str == '-') { + while (*str && *str != ' ') { + if (*str == 'C') + clval |= RB_CDROM; + if (*str == 'a') + clval |= RB_ASKNAME; + if (*str == 'b') + clval |= RB_HALT; + if (*str == 'c') + clval |= RB_CONFIG; + if (*str == 'd') + clval |= RB_KDB; + if (*str == 'h') + clval |= RB_SERIAL; + if (*str == 'r') + clval |= RB_DFLTROOT; + if (*str == 's') + clval |= RB_SINGLE; + if (*str == 'v') + clval |= RB_VERBOSE; + str++; + } + continue; + } + str++; + } + /* + * We now pass the various bootstrap parameters to the loaded + * image via the argument list. + * + * This is the unofficial list: + * + * arg0 = '_boothowto' (flags) + * arg1 = '_bootdev' boot device - not used + * arg2 = '_bootapiver' (boot capabilities/version flags) + * arg3 = '_esym' - not used + * arg4 = '_extmem' - extended memory - not used + * arg5 = '_cnvmem' - standard memory - not used + * arg6 = '_bootargc' - size of the boot argument vector (bytes) + * arg7 = '_bootargv' - the boot argument vector + */ + + /* + * I don't know what this stuff is, so I keep it + */ + if (mbi.flags & MB_INFO_AOUT_SYMS) + end_mark = (mbi.syms.a.addr + 4 + + mbi.syms.a.tabsize + mbi.syms.a.strsize); + else + /* FIXME: it should be mbi.syms.e.size. */ + end_mark = 0; + + /* fillup parameter block */ + bv.memarg.ba_type = BOOTARG_MEMMAP; + bv.memarg.ba_size = sizeof(bv.memarg) + sizeof(bv.memmap); + bv.memmap[0].addr = 0; + bv.memmap[0].size = mbi.mem_lower * 1024; + bv.memmap[0].type = BIOS_MAP_FREE; + bv.memmap[1].addr = 0x100000; + bv.memmap[1].size = extended_memory * 1024; + bv.memmap[1].type = BIOS_MAP_FREE; + bv.memmap[2].addr = 0; + bv.memmap[2].size = 0; + bv.memmap[2].type = BIOS_MAP_END; + bv.ttyarg.ba_type = BOOTARG_CONSDEV; + bv.ttyarg.ba_size = sizeof(bv.ttyarg)+sizeof(bv.ttyinfo); + if(current_term && !grub_strcmp(current_term->name, "serial")) { + bv.ttyinfo.consdev = 0x800+boot_serial_unit; + bv.ttyinfo.conspeed = boot_serial_speed; + } else { + bv.ttyinfo.consdev = 0; + bv.ttyinfo.conspeed = 0; + } + bv.ip4arg.ba_type = BOOTARG_IP4INFO; + bv.ip4arg.ba_size = sizeof(bv.ip4arg)+sizeof(bv.ip4info); + bv.ip4info.ip4_myaddr = arptable[ARP_CLIENT].ipaddr.s_addr; + bv.ip4info.ip4_mymask = netmask; + bv.ip4info.ip4_mybcast = (~netmask)+(bv.ip4info.ip4_myaddr & netmask); + bv.laarg.ba_type = BOOTARG_LINKADDR; + bv.laarg.ba_size = sizeof(bv.laarg)+sizeof(bv.lainfo); + bv.lainfo.la_type = 6; + bv.lainfo.la_alen = 6; + bv.lainfo.la_addr[0] = arptable[ARP_CLIENT].node[0]; + bv.lainfo.la_addr[1] = arptable[ARP_CLIENT].node[1]; + bv.lainfo.la_addr[2] = arptable[ARP_CLIENT].node[2]; + bv.lainfo.la_addr[3] = arptable[ARP_CLIENT].node[3]; + bv.lainfo.la_addr[4] = arptable[ARP_CLIENT].node[4]; + bv.lainfo.la_addr[5] = arptable[ARP_CLIENT].node[5]; + bv.endarg.ba_type = BOOTARG_END; + bv.endarg.ba_size = sizeof(bv.endarg); + + // copy args at 0x2000, and launch the thing with 8 args + xxx_memcpy((long *)0x2000, (long *)&bv, sizeof(bv)); + (*(void (*)(int, int, int, int, int, int, int, int))entry_addr) + (clval, bootdev, BOOTARG_APIVER, end_mark, + extended_memory, mbi.mem_lower, sizeof(bv), 0x2000); +} diff -rPu grub-0.93.orig/stage2/shared.h grub-0.93.openbsd/stage2/shared.h --- grub-0.93.orig/stage2/shared.h Tue Dec 3 00:15:12 2002 +++ grub-0.93.openbsd/stage2/shared.h Thu Jun 12 01:03:33 2003 @@ -831,6 +831,7 @@ KERNEL_TYPE_BIG_LINUX, /* Big Linux. */ KERNEL_TYPE_FREEBSD, /* FreeBSD. */ KERNEL_TYPE_NETBSD, /* NetBSD. */ + KERNEL_TYPE_OPENBSD, /* OpenBSD. */ KERNEL_TYPE_CHAINLOADER /* Chainloader. */ } kernel_t;