Index: Makefile =================================================================== RCS file: /e/cvsync/cvsync/pkgsrc/sysutils/grub/Makefile,v retrieving revision 1.48 diff -u -a -u -r1.48 Makefile --- Makefile 7 Oct 2007 18:00:55 -0000 1.48 +++ Makefile 20 Feb 2008 06:48:28 -0000 @@ -1,7 +1,7 @@ # $NetBSD: Makefile,v 1.48 2007/10/07 18:00:55 xtraeme Exp $ DISTNAME= grub-0.97 -PKGREVISION= 8 +PKGREVISION= 9 CATEGORIES= sysutils MASTER_SITES= ftp://alpha.gnu.org/gnu/grub/ Index: distinfo =================================================================== RCS file: /e/cvsync/cvsync/pkgsrc/sysutils/grub/distinfo,v retrieving revision 1.22 diff -u -a -u -r1.22 distinfo --- distinfo 25 Jun 2007 13:05:56 -0000 1.22 +++ distinfo 20 Feb 2008 06:38:06 -0000 @@ -16,3 +16,4 @@ SHA1 (patch-ak) = 8e67eb603e639ca47536cb191e7e29ec48b95642 SHA1 (patch-al) = 58761e867ff182ad46c42b15575395ba8c38fbd6 SHA1 (patch-am) = d848f67f7f21fa076751d14bd3235ae7351be1b7 +SHA1 (patch-an) = 6bb9e7be1942d916fdacf7acf18d2100e8dde46a Index: patches/patch-an =================================================================== RCS file: patches/patch-an diff -N patches/patch-an --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ patches/patch-an 20 Feb 2008 06:38:01 -0000 @@ -0,0 +1,386 @@ +$NetBSD$ + +--- ./stage2/builtins.c.orig 2005-02-16 06:58:23.000000000 +0900 ++++ ./stage2/builtins.c 2008-02-20 15:22:25.000000000 +0900 +@@ -1233,14 +1233,16 @@ + for (drive = 0x80; drive < 0x88; drive++) + { + unsigned long part = 0xFFFFFF; +- unsigned long start, len, offset, ext_offset; +- int type, entry; ++ unsigned long start, len, offset, ext_offset, gpt_offset; ++ int type, entry, gpt_count, gpt_size; ++ + char buf[SECTOR_SIZE]; + + current_drive = drive; + while (next_partition (drive, 0xFFFFFF, &part, &type, + &start, &len, &offset, &entry, +- &ext_offset, buf)) ++ &ext_offset, &gpt_offset, ++ &gpt_count, &gpt_size, buf)) + { + if (type != PC_SLICE_TYPE_NONE + && ! IS_PC_SLICE_TYPE_BSD (type) +@@ -2815,8 +2817,8 @@ + { + int new_type; + unsigned long part = 0xFFFFFF; +- unsigned long start, len, offset, ext_offset; +- int entry, type; ++ unsigned long start, len, offset, ext_offset, gpt_offset; ++ int entry, type, gpt_count, gpt_size; + char mbr[512]; + + /* Get the drive and the partition. */ +@@ -2853,8 +2855,15 @@ + /* Look for the partition. */ + while (next_partition (current_drive, 0xFFFFFF, &part, &type, + &start, &len, &offset, &entry, +- &ext_offset, mbr)) ++ &ext_offset, &gpt_offset, &gpt_count, &gpt_size, mbr)) + { ++ /* The partition may not be a GPT partition. */ ++ if (gpt_offset != 0) ++ { ++ errnum = ERR_BAD_ARGUMENT; ++ return 1; ++ } ++ + if (part == current_partition) + { + /* Found. */ + +--- ./stage2/pc_slice.h.orig 2008-02-20 15:32:20.000000000 +0900 ++++ ./stage2/pc_slice.h 2008-02-20 15:32:21.000000000 +0900 +@@ -115,6 +115,7 @@ + #define PC_SLICE_TYPE_LINUX_EXTENDED 0x85 + #define PC_SLICE_TYPE_VSTAFS 0x9e + #define PC_SLICE_TYPE_DELL_UTIL 0xde ++#define PC_SLICE_TYPE_GPT 0xee + #define PC_SLICE_TYPE_LINUX_RAID 0xfd + + +--- ./stage2/disk_io.c.orig 2008-02-20 15:32:20.000000000 +0900 ++++ ./stage2/disk_io.c 2008-02-20 15:32:22.000000000 +0900 +@@ -21,6 +21,7 @@ + + #include + #include ++#include + + #ifdef SUPPORT_NETBOOT + # define GRUB 1 +@@ -502,8 +503,8 @@ + set_partition_hidden_flag (int hidden) + { + unsigned long part = 0xFFFFFF; +- unsigned long start, len, offset, ext_offset; +- int entry, type; ++ unsigned long start, len, offset, ext_offset, gpt_offset; ++ int entry, type, gpt_count, gpt_size; + char mbr[512]; + + /* The drive must be a hard disk. */ +@@ -524,8 +525,15 @@ + /* Look for the partition. */ + while (next_partition (current_drive, 0xFFFFFF, &part, &type, + &start, &len, &offset, &entry, +- &ext_offset, mbr)) +- { ++ &ext_offset, &gpt_offset, &gpt_count, &gpt_size, mbr)) ++ { ++ /* The partition may not be a GPT partition. */ ++ if (gpt_offset != 0) ++ { ++ errnum = ERR_BAD_ARGUMENT; ++ return 1; ++ } ++ + if (part == current_partition) + { + /* Found. */ +@@ -577,11 +585,14 @@ + unsigned long *partition, int *type, + unsigned long *start, unsigned long *len, + unsigned long *offset, int *entry, +- unsigned long *ext_offset, char *buf) ++ unsigned long *ext_offset, ++ unsigned long *gpt_offset, int *gpt_count, ++ int *gpt_size, char *buf) + { + /* Forward declarations. */ + auto int next_bsd_partition (void); + auto int next_pc_slice (void); ++ auto int next_gpt_slice(void); + + /* Get next BSD partition in current PC slice. */ + int next_bsd_partition (void) +@@ -675,6 +686,40 @@ + return 0; + } + ++ /* If this is a GPT partition table, read it as such. */ ++ if (*entry == -1 && *offset == 0 && PC_SLICE_TYPE (buf, 0) == PC_SLICE_TYPE_GPT) ++ { ++ struct grub_gpt_header *hdr = (struct grub_gpt_header *) buf; ++ ++ /* Read in the GPT Partition table header. */ ++ if (! rawread (drive, 1, 0, SECTOR_SIZE, buf)) ++ return 0; ++ ++ if (hdr->magic == GPT_HEADER_MAGIC && hdr->version == 0x10000) ++ { ++ /* Let gpt_offset point to the first entry in the GPT ++ partition table. This can also be used by callers of ++ next_partition to determine if a entry comes from a ++ GPT partition table or not. */ ++ *gpt_offset = hdr->partitions; ++ *gpt_count = hdr->maxpart; ++ *gpt_size = hdr->partentry_size; ++ ++ return next_gpt_slice(); ++ } ++ else ++ { ++ /* This is not a valid header for a GPT partition table. ++ Re-read the MBR or the boot sector of the extended ++ partition. */ ++ if (! rawread (drive, *offset, 0, SECTOR_SIZE, buf)) ++ return 0; ++ } ++ } ++ ++ /* Not a GPT partition. */ ++ *gpt_offset = 0; ++ + /* Increase the entry number. */ + (*entry)++; + +@@ -718,6 +763,42 @@ + *partition = (pc_slice_no << 16) | 0xFFFF; + return 1; + } ++ /* Get the next GPT slice. */ ++ int next_gpt_slice (void) ++ { ++ struct grub_gpt_partentry *gptentry = (struct grub_gpt_partentry *) buf; ++ /* Make GPT partitions show up as PC slices. */ ++ int pc_slice_no = (*partition & 0xFF0000) >> 16; ++ ++ /* If this is the first time... */ ++ if (pc_slice_no == 0xFF) ++ { ++ pc_slice_no = -1; ++ *entry = -1; ++ } ++ ++ do { ++ (*entry)++; ++ ++ if (*entry >= *gpt_count) ++ { ++ errnum = ERR_NO_PART; ++ return 0; ++ } ++ /* Read in the GPT Partition table entry. */ ++ if (! rawread (drive, (*gpt_offset) + GPT_ENTRY_SECTOR (*gpt_size, *entry), GPT_ENTRY_INDEX (*gpt_size, *entry), *gpt_size, buf)) ++ return 0; ++ } while (! (gptentry->type1 && gptentry->type2)); ++ ++ pc_slice_no++; ++ *start = gptentry->start; ++ *len = gptentry->end - gptentry->start + 1; ++ *type = PC_SLICE_TYPE_EXT2FS; ++ *entry = pc_slice_no; ++ *partition = (*entry << 16) | 0xFFFF; ++ ++ return 1; ++ } + + /* Start the body of this function. */ + +@@ -726,6 +807,9 @@ + return 0; + #endif + ++ if (*partition != 0xFFFFFF && *gpt_offset != 0) ++ return next_gpt_slice (); ++ + /* If previous partition is a BSD partition or a PC slice which + contains BSD partitions... */ + if ((*partition != 0xFFFFFF && IS_PC_SLICE_TYPE_BSD (*type & 0xff)) +@@ -764,6 +848,9 @@ + unsigned long dest_partition = current_partition; + unsigned long part_offset; + unsigned long ext_offset; ++ unsigned long gpt_offset; ++ int gpt_count; ++ int gpt_size; + int entry; + char buf[SECTOR_SIZE]; + int bsd_part, pc_slice; +@@ -775,7 +862,8 @@ + int ret = next_partition (current_drive, dest_partition, + ¤t_partition, ¤t_slice, + &part_start, &part_length, +- &part_offset, &entry, &ext_offset, buf); ++ &part_offset, &entry, &ext_offset, ++ &gpt_offset, &gpt_count, &gpt_size, buf); + bsd_part = (current_partition >> 8) & 0xFF; + pc_slice = current_partition >> 16; + return ret; +--- ./stage2/netbsd_reboot.h.orig 2008-02-20 15:32:21.000000000 +0900 ++++ ./stage2/netbsd_reboot.h 2008-02-20 15:32:22.000000000 +0900 +@@ -64,3 +64,69 @@ + #define NB_AB_VERBOSE 0x20000 /* boot verbosely */ + #define NB_AB_SILENT 0x40000 /* boot silently */ + #define NB_AB_DEBUG 0x80000 /* boot with debug messages */ ++/* %NetBSD: reboot.h,v 1.22 2005/02/03 19:20:02 perry Exp % */ ++ ++/* ++ * Copyright (c) 1982, 1986, 1988, 1993, 1994 ++ * The Regents of the University of California. All rights reserved. ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in the ++ * documentation and/or other materials provided with the distribution. ++ * 3. Neither the name of the University nor the names of its contributors ++ * may be used to endorse or promote products derived from this software ++ * without specific prior written permission. ++ * ++ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND ++ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE ++ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ++ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE ++ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL ++ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS ++ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ++ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT ++ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY ++ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF ++ * SUCH DAMAGE. ++ * ++ * @(#)reboot.h 8.3 (Berkeley) 12/13/94 ++ */ ++ ++/* ++ * WARNING! This file is stripped and modified! ++ */ ++ ++/* ++ * Arguments to reboot system call. These are passed to the boot program, ++ * and then on to init. ++ */ ++#define NB_RB_AUTOBOOT 0 /* flags for system auto-booting itself */ ++ ++#define NB_RB_ASKNAME 0x001 /* ask for file name to reboot from */ ++#define NB_RB_SINGLE 0x002 /* reboot to single user only */ ++#define NB_RB_NOSYNC 0x004 /* dont sync before reboot */ ++#define NB_RB_HALT 0x008 /* don't reboot, just halt */ ++#define NB_RB_INITNAME 0x010 /* name given for /etc/init (unused) */ ++#define __NB_RB_UNUSED1 0x020 /* was RB_DFLTROOT, obsolete */ ++#define NB_RB_KDB 0x040 /* give control to kernel debugger */ ++#define NB_RB_RDONLY 0x080 /* mount root fs read-only */ ++#define NB_RB_DUMP 0x100 /* dump kernel memory before reboot */ ++#define NB_RB_MINIROOT 0x200 /* mini-root present in memory at boot time */ ++#define NB_RB_STRING 0x400 /* use provided bootstr */ ++#define NB_RB_POWERDOWN (RB_HALT|0x800) /* turn power off (or at least halt) */ ++#define NB_RB_USERCONF 0x1000 /* change configured devices */ ++ ++/* ++ * Extra autoboot flags (passed by boot prog to kernel). See also ++ * macros bootverbose, bootquiet in . ++ */ ++#define NB_AB_NORMAL 0x00000 /* boot normally (default) */ ++#define NB_AB_QUIET 0x10000 /* boot quietly */ ++#define NB_AB_VERBOSE 0x20000 /* boot verbosely */ ++#define NB_AB_SILENT 0x40000 /* boot silently */ ++#define NB_AB_DEBUG 0x80000 /* boot with debug messages */ +--- ./stage2/shared.h.orig 2008-02-20 15:32:21.000000000 +0900 ++++ ./stage2/shared.h 2008-02-20 15:32:22.000000000 +0900 +@@ -934,7 +934,9 @@ + unsigned long *partition, int *type, + unsigned long *start, unsigned long *len, + unsigned long *offset, int *entry, +- unsigned long *ext_offset, char *buf); ++ unsigned long *ext_offset, ++ unsigned long *gpt_offset, int *gpt_count, ++ int *gpt_size, char *buf); + + /* Sets device to the one represented by the SAVED_* parameters. */ + int make_saved_active (void); +--- ./stage2/gpt.h.orig 2008-02-20 15:32:22.000000000 +0900 ++++ ./stage2/gpt.h 2008-02-20 15:32:22.000000000 +0900 +@@ -0,0 +1,66 @@ ++/* ++ * GRUB -- GRand Unified Bootloader ++ * Copyright (C) 2002,2005,2006 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 ++ * 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. ++ */ ++ ++#ifndef _GPT_H ++#define _GPT_H ++ ++typedef signed char grub_int8_t; ++typedef signed short grub_int16_t; ++typedef signed int grub_int32_t; ++typedef signed long long int grub_int64_t; ++typedef unsigned char grub_uint8_t; ++typedef unsigned short grub_uint16_t; ++typedef unsigned int grub_uint32_t; ++typedef unsigned long long int grub_uint64_t; ++ ++struct grub_gpt_header ++{ ++ grub_uint64_t magic; ++ grub_uint32_t version; ++ grub_uint32_t headersize; ++ grub_uint32_t crc32; ++ grub_uint32_t unused1; ++ grub_uint64_t primary; ++ grub_uint64_t backup; ++ grub_uint64_t start; ++ grub_uint64_t end; ++ grub_uint8_t guid[16]; ++ grub_uint64_t partitions; ++ grub_uint32_t maxpart; ++ grub_uint32_t partentry_size; ++ grub_uint32_t partentry_crc32; ++} __attribute__ ((packed)); ++ ++struct grub_gpt_partentry ++{ ++ grub_uint64_t type1; ++ grub_uint64_t type2; ++ grub_uint8_t guid[16]; ++ grub_uint64_t start; ++ grub_uint64_t end; ++ grub_uint8_t attrib; ++ char name[72]; ++} __attribute__ ((packed)); ++ ++#define GPT_HEADER_MAGIC 0x5452415020494645UL ++ ++#define GPT_ENTRY_SECTOR(size,entry) ((((entry) * (size) + 1) & ~(SECTOR_SIZE - 1)) >> SECTOR_BITS) ++#define GPT_ENTRY_INDEX(size,entry) ((((entry) * (size) + 1) & (SECTOR_SIZE - 1)) - 1) ++ ++#endif /* _GPT_H */