diff options
author | Hans Rosenfeld <rosenfeld@grumpf.hope-2000.org> | 2016-01-31 15:39:20 +0100 |
---|---|---|
committer | Hans Rosenfeld <hans.rosenfeld@nexenta.com> | 2016-03-16 17:57:15 +0100 |
commit | 9890706ed36aa6bfca8ad283fbe4dac12ecd692b (patch) | |
tree | 048351ded0c77af8d77d1fca216a020f4aa415e7 /usr/src/grub | |
parent | 621be8d08fd45483b5ca1cb8e2e88239f1502b4d (diff) | |
download | illumos-joyent-9890706ed36aa6bfca8ad283fbe4dac12ecd692b.tar.gz |
6593 want LBA48 support in grub
Reviewed by: Josef 'Jeff' Sipek <josef.sipek@nexenta.com>
Reviewed by: Dan McDonald <danmcd@omniti.com>
Reviewed by: Toomas Soome <tsoome@me.com>
Approved by: Robert Mustacchi <rm@joyent.com>
Diffstat (limited to 'usr/src/grub')
-rw-r--r-- | usr/src/grub/capability | 3 | ||||
-rw-r--r-- | usr/src/grub/grub-0.97/Makefile.solaris.defs | 1 | ||||
-rw-r--r-- | usr/src/grub/grub-0.97/grub/asmstub.c | 5 | ||||
-rw-r--r-- | usr/src/grub/grub-0.97/stage2/Makefile.solaris | 20 | ||||
-rw-r--r-- | usr/src/grub/grub-0.97/stage2/bios.c | 5 | ||||
-rw-r--r-- | usr/src/grub/grub-0.97/stage2/builtins.c | 52 | ||||
-rw-r--r-- | usr/src/grub/grub-0.97/stage2/char_io.c | 133 | ||||
-rw-r--r-- | usr/src/grub/grub-0.97/stage2/disk_io.c | 42 | ||||
-rw-r--r-- | usr/src/grub/grub-0.97/stage2/moddiv.c | 222 | ||||
-rw-r--r-- | usr/src/grub/grub-0.97/stage2/shared.h | 32 | ||||
-rw-r--r-- | usr/src/grub/grub-0.97/stage2/stage1_5.c | 7 |
11 files changed, 408 insertions, 114 deletions
diff --git a/usr/src/grub/capability b/usr/src/grub/capability index 884d019d8c..dd7c6018df 100644 --- a/usr/src/grub/capability +++ b/usr/src/grub/capability @@ -21,6 +21,7 @@ # Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. # Copyright (c) 2013, 2015 by Delphix. All rights reserved. # Copyright 2013 Saso Kiselkov. All rights reserved. +# Copyright 2016 Nexenta Systems, Inc. # # This file defines the current capabilities of GRUB over and above that # supported by the standard distribution @@ -30,7 +31,7 @@ # GRUB necessitating that the boot blocks be reinstalled for that fix or # enhancement to take effect. # -VERSION=27 +VERSION=28 dboot xVM zfs diff --git a/usr/src/grub/grub-0.97/Makefile.solaris.defs b/usr/src/grub/grub-0.97/Makefile.solaris.defs index e66071b064..6635364191 100644 --- a/usr/src/grub/grub-0.97/Makefile.solaris.defs +++ b/usr/src/grub/grub-0.97/Makefile.solaris.defs @@ -1,6 +1,7 @@ # # Copyright 2005 Sun Microsystems, Inc. All rights reserved. # Use is subject to license terms. +# Copyright 2016 Nexenta Systems, Inc. # include $(SRC)/Makefile.master diff --git a/usr/src/grub/grub-0.97/grub/asmstub.c b/usr/src/grub/grub-0.97/grub/asmstub.c index c32823b0f1..a0a1f33589 100644 --- a/usr/src/grub/grub-0.97/grub/asmstub.c +++ b/usr/src/grub/grub-0.97/grub/asmstub.c @@ -17,6 +17,9 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ +/* + * Copyright 2016 Nexenta Systems, Inc. + */ /* Try to use glibc's transparant LFS support. */ #define _LARGEFILE_SOURCE 1 @@ -928,7 +931,7 @@ hex_dump (void *buf, size_t size) int biosdisk (int subfunc, int drive, struct geometry *geometry, - unsigned int sector, int nsec, int segment) + unsigned long long sector, int nsec, int segment) { char *buf; int fd = geometry->flags; diff --git a/usr/src/grub/grub-0.97/stage2/Makefile.solaris b/usr/src/grub/grub-0.97/stage2/Makefile.solaris index 7863b5afe3..925092fd4d 100644 --- a/usr/src/grub/grub-0.97/stage2/Makefile.solaris +++ b/usr/src/grub/grub-0.97/stage2/Makefile.solaris @@ -3,6 +3,7 @@ # Use is subject to license terms. # Copyright (c) 2013 by Saso Kiselkov. All rights reserved. # Copyright 2015, OmniTI Computer Consulting, Inc. All rights reserved. +# Copyright 2016 Nexenta Systems, Inc. # include ../../Makefile.grub include ../Makefile.solaris.defs @@ -85,6 +86,7 @@ LIBGRUB_OBJS = libgrub_a-boot.o \ libgrub_a-graphics.o \ libgrub_a-gunzip.o \ libgrub_a-md5.o \ + libgrub_a-moddiv.o \ libgrub_a-serial.o \ libgrub_a-stage2.o \ libgrub_a-terminfo.o \ @@ -131,7 +133,7 @@ PROGRAMS = $(DISKLESS_EXEC) \ $(NBLOADER_EXEC) \ $(PRE_STAGE2_EXEC) \ $(PXELOADER_EXEC) \ - $(REISERFS_STAGE1_5_EXEC) \ + $(REISERFS_STAGE1_5_EXEC) \ $(START_EXEC) \ $(START_ELTORITO_EXEC) \ $(UFS2_STAGE1_5_EXEC) \ @@ -177,6 +179,7 @@ DISKLESS_OBJS = diskless_exec-bios.o \ diskless_exec-gunzip.o \ diskless_exec-hercules.o \ diskless_exec-md5.o \ + diskless_exec-moddiv.o \ diskless_exec-serial.o \ diskless_exec-smp-imps.o \ diskless_exec-stage2.o \ @@ -208,6 +211,7 @@ E2FS_STAGE1_5_OBJS = e2fs_stage1_5_exec-bios.o \ e2fs_stage1_5_exec-common.o \ e2fs_stage1_5_exec-disk_io.o \ e2fs_stage1_5_exec-fsys_ext2fs.o \ + e2fs_stage1_5_exec-moddiv.o \ e2fs_stage1_5_exec-stage1_5.o $(E2FS_STAGE1_5_EXEC) := LDFLAGS = $(BASE_LDFLAGS) $(STAGE1_5_LINK) @@ -232,6 +236,7 @@ FAT_STAGE1_5_OBJS = fat_stage1_5_exec-bios.o \ fat_stage1_5_exec-common.o \ fat_stage1_5_exec-disk_io.o \ fat_stage1_5_exec-fsys_fat.o \ + fat_stage1_5_exec-moddiv.o \ fat_stage1_5_exec-stage1_5.o $(FAT_STAGE1_5_EXEC) := LDFLAGS = $(BASE_LDFLAGS) $(STAGE1_5_LINK) @@ -256,6 +261,7 @@ FFS_STAGE1_5_OBJS = ffs_stage1_5_exec-bios.o \ ffs_stage1_5_exec-common.o \ ffs_stage1_5_exec-disk_io.o \ ffs_stage1_5_exec-fsys_ffs.o \ + ffs_stage1_5_exec-moddiv.o \ ffs_stage1_5_exec-stage1_5.o $(FFS_STAGE1_5_EXEC) := LDFLAGS = $(BASE_LDFLAGS) $(STAGE1_5_LINK) @@ -280,6 +286,7 @@ ISO9660_STAGE1_5_OBJS = iso9660_stage1_5_exec-bios.o \ iso9660_stage1_5_exec-common.o \ iso9660_stage1_5_exec-disk_io.o \ iso9660_stage1_5_exec-fsys_iso9660.o \ + iso9660_stage1_5_exec-moddiv.o \ iso9660_stage1_5_exec-stage1_5.o $(ISO9660_STAGE1_5_EXEC) := LDFLAGS = $(BASE_LDFLAGS) $(STAGE1_5_LINK) @@ -305,6 +312,7 @@ JFS_STAGE1_5_OBJS = jfs_stage1_5_exec-bios.o \ jfs_stage1_5_exec-common.o \ jfs_stage1_5_exec-disk_io.o \ jfs_stage1_5_exec-fsys_jfs.o \ + jfs_stage1_5_exec-moddiv.o \ jfs_stage1_5_exec-stage1_5.o $(JFS_STAGE1_5_EXEC) := LDFLAGS = $(BASE_LDFLAGS) $(STAGE1_5_LINK) @@ -329,6 +337,7 @@ MINIX_STAGE1_5_OBJS = minix_stage1_5_exec-bios.o \ minix_stage1_5_exec-common.o \ minix_stage1_5_exec-disk_io.o \ minix_stage1_5_exec-fsys_minix.o \ + minix_stage1_5_exec-moddiv.o \ minix_stage1_5_exec-stage1_5.o $(MINIX_STAGE1_5_EXEC) := LDFLAGS = $(BASE_LDFLAGS) $(STAGE1_5_LINK) @@ -390,6 +399,7 @@ PRE_STAGE2_OBJS = pre_stage2_exec-bios.o \ pre_stage2_exec-gunzip.o \ pre_stage2_exec-hercules.o \ pre_stage2_exec-md5.o \ + pre_stage2_exec-moddiv.o \ pre_stage2_exec-serial.o \ pre_stage2_exec-smp-imps.o \ pre_stage2_exec-stage2.o \ @@ -434,6 +444,7 @@ REISERFS_STAGE1_5_OBJS = reiserfs_stage1_5_exec-bios.o \ reiserfs_stage1_5_exec-common.o \ reiserfs_stage1_5_exec-disk_io.o \ reiserfs_stage1_5_exec-fsys_reiserfs.o \ + reiserfs_stage1_5_exec-moddiv.o \ reiserfs_stage1_5_exec-stage1_5.o $(REISERFS_STAGE1_5_EXEC) := LDFLAGS = $(BASE_LDFLAGS) $(STAGE1_5_LINK) @@ -489,6 +500,7 @@ UFS2_STAGE1_5_OBJS = ufs2_stage1_5_exec-bios.o \ ufs2_stage1_5_exec-common.o \ ufs2_stage1_5_exec-disk_io.o \ ufs2_stage1_5_exec-fsys_ufs2.o \ + ufs2_stage1_5_exec-moddiv.o \ ufs2_stage1_5_exec-stage1_5.o $(UFS2_STAGE1_5_EXEC) := LDFLAGS = $(BASE_LDFLAGS) $(STAGE1_5_LINK) @@ -513,6 +525,7 @@ UFS_STAGE1_5_OBJS = ufs_stage1_5_exec-bios.o \ ufs_stage1_5_exec-common.o \ ufs_stage1_5_exec-disk_io.o \ ufs_stage1_5_exec-fsys_ufs.o \ + ufs_stage1_5_exec-moddiv.o \ ufs_stage1_5_exec-stage1_5.o $(UFS_STAGE1_5_EXEC) := LDFLAGS = $(BASE_LDFLAGS) $(STAGE1_5_LINK) @@ -541,6 +554,7 @@ ZFS_STAGE1_5_OBJS = zfs_stage1_5_exec-bios.o \ zfs_stage1_5_exec-zfs_lz4.o \ zfs_stage1_5_exec-zfs_fletcher.o \ zfs_stage1_5_exec-fsys_zfs.o \ + zfs_stage1_5_exec-moddiv.o \ zfs_stage1_5_exec-stage1_5.o $(ZFS_STAGE1_5_EXEC) := LDFLAGS = $(BASE_LDFLAGS) $(STAGE1_5_LINK) @@ -565,6 +579,7 @@ VSTAFS_STAGE1_5_OBJS = vstafs_stage1_5_exec-bios.o \ vstafs_stage1_5_exec-common.o \ vstafs_stage1_5_exec-disk_io.o \ vstafs_stage1_5_exec-fsys_vstafs.o \ + vstafs_stage1_5_exec-moddiv.o \ vstafs_stage1_5_exec-stage1_5.o $(VSTAFS_STAGE1_5_EXEC) := LDFLAGS = $(BASE_LDFLAGS) $(STAGE1_5_LINK) @@ -589,6 +604,7 @@ XFS_STAGE1_5_OBJS = xfs_stage1_5_exec-bios.o \ xfs_stage1_5_exec-common.o \ xfs_stage1_5_exec-disk_io.o \ xfs_stage1_5_exec-fsys_xfs.o \ + xfs_stage1_5_exec-moddiv.o \ xfs_stage1_5_exec-stage1_5.o $(XFS_STAGE1_5_EXEC) := LDFLAGS = $(BASE_LDFLAGS) $(STAGE1_5_LINK) @@ -618,7 +634,7 @@ SRC_FILES = Makefile.am Makefile.in apic.h apm.S asm.S bios.c boot.c \ fsys_reiserfs.c fsys_ufs.c fsys_ufs2.c fsys_vstafs.c \ fsys_xfs.c graphics.c graphics.h gunzip.c hercules.c \ hercules.h i386-elf.h imgact_aout.h iso9660.h jfs.h \ - mb_header.h mb_info.h md5.c md5.h nbi.h nbloader.S \ + mb_header.h mb_info.h md5.c md5.h moddiv.c nbi.h nbloader.S \ pc_slice.h pxeloader.S serial.c serial.h setjmp.S shared.h \ size_test smp-imps.c smp-imps.h stage1_5.c stage2.c \ start.S start_eltorito.S term.h terminfo.c terminfo.h \ diff --git a/usr/src/grub/grub-0.97/stage2/bios.c b/usr/src/grub/grub-0.97/stage2/bios.c index c8365177eb..3203ee722d 100644 --- a/usr/src/grub/grub-0.97/stage2/bios.c +++ b/usr/src/grub/grub-0.97/stage2/bios.c @@ -17,6 +17,9 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ +/* + * Copyright 2016 Nexenta Systems, Inc. + */ #include "shared.h" @@ -47,7 +50,7 @@ extern int get_diskinfo_floppy (int drive, return the error number. Otherwise, return 0. */ int biosdisk (int read, int drive, struct geometry *geometry, - unsigned int sector, int nsec, int segment) + unsigned long long sector, int nsec, int segment) { int err; diff --git a/usr/src/grub/grub-0.97/stage2/builtins.c b/usr/src/grub/grub-0.97/stage2/builtins.c index ecc92bc819..9cc05dc99b 100644 --- a/usr/src/grub/grub-0.97/stage2/builtins.c +++ b/usr/src/grub/grub-0.97/stage2/builtins.c @@ -146,9 +146,9 @@ check_password (char *entered, char* expected, password_t type) /* Print which sector is read when loading a file. */ static void -disk_read_print_func(unsigned int sector, int offset, int length) +disk_read_print_func(unsigned long long sector, int offset, int length) { - grub_printf ("[%u,%d,%d]", sector, offset, length); + grub_printf ("[%llu,%d,%d]", sector, offset, length); } @@ -157,17 +157,17 @@ static int blocklist_func (char *arg, int flags) { char *dummy = (char *) RAW_ADDR (0x100000); - unsigned int start_sector = 0; + unsigned long long start_sector = 0; int num_sectors = 0; int num_entries = 0; int last_length = 0; - auto void disk_read_blocklist_func (unsigned int sector, int offset, + auto void disk_read_blocklist_func (unsigned long long sector, int offset, int length); /* Collect contiguous blocks into one entry as many as possible, and print the blocklist notation on the screen. */ - auto void disk_read_blocklist_func (unsigned int sector, int offset, + auto void disk_read_blocklist_func (unsigned long long sector, int offset, int length) { if (num_sectors > 0) @@ -182,15 +182,15 @@ blocklist_func (char *arg, int flags) else { if (last_length == SECTOR_SIZE) - grub_printf ("%s%d+%d", num_entries ? "," : "", + grub_printf ("%s%lld+%d", num_entries ? "," : "", start_sector - part_start, num_sectors); else if (num_sectors > 1) - grub_printf ("%s%d+%d,%d[0-%d]", num_entries ? "," : "", + grub_printf ("%s%lld+%d,%lld[0-%d]", num_entries ? "," : "", start_sector - part_start, num_sectors-1, start_sector + num_sectors-1 - part_start, last_length); else - grub_printf ("%s%d[0-%d]", num_entries ? "," : "", + grub_printf ("%s%;lld[0-%d]", num_entries ? "," : "", start_sector - part_start, last_length); num_entries++; num_sectors = 0; @@ -199,7 +199,7 @@ blocklist_func (char *arg, int flags) if (offset > 0) { - grub_printf("%s%u[%d-%d]", num_entries ? "," : "", + grub_printf("%s%llu[%d-%d]", num_entries ? "," : "", sector-part_start, offset, offset+length); num_entries++; } @@ -236,7 +236,7 @@ blocklist_func (char *arg, int flags) /* The last entry may not be printed yet. Don't check if it is a * full sector, since it doesn't matter if we read too much. */ if (num_sectors > 0) - grub_printf ("%s%d+%d", num_entries ? "," : "", + grub_printf ("%s%lld+%d", num_entries ? "," : "", start_sector - part_start, num_sectors); grub_printf ("\n"); @@ -1654,7 +1654,7 @@ harddisk: for (drive = 0x80; drive < 0x88; drive++) { unsigned long part = 0xFFFFFF; - unsigned long start, len, offset, ext_offset, gpt_offset; + unsigned long long start, len, offset, ext_offset, gpt_offset; int type, entry, gpt_count, gpt_size; char buf[SECTOR_SIZE]; @@ -1870,7 +1870,7 @@ geometry_func (char *arg, int flags) #endif grub_printf ("drive 0x%x: C/H/S = %d/%d/%d, " - "The number of sectors = %u, %s\n", + "The number of sectors = %llu, %s\n", current_drive, geom.cylinders, geom.heads, geom.sectors, geom.total_sectors, msg); @@ -2222,8 +2222,8 @@ install_func (char *arg, int flags) int src_drive, src_partition, src_part_start; int i; struct geometry dest_geom, src_geom; - unsigned int saved_sector; - unsigned int stage2_first_sector, stage2_second_sector; + unsigned long long saved_sector; + unsigned long long stage2_first_sector, stage2_second_sector; char *ptr; int installaddr, installlist; /* Point to the location of the name of a configuration file in Stage 2. */ @@ -2243,17 +2243,17 @@ install_func (char *arg, int flags) char *stage2_os_file = 0; #endif /* GRUB_UTIL */ - auto void disk_read_savesect_func (unsigned int sector, int offset, + auto void disk_read_savesect_func (unsigned long long sector, int offset, int length); - auto void disk_read_blocklist_func (unsigned int sector, int offset, + auto void disk_read_blocklist_func (unsigned long long sector, int offset, int length); /* Save the first sector of Stage2 in STAGE2_SECT. */ - auto void disk_read_savesect_func (unsigned int sector, int offset, + auto void disk_read_savesect_func (unsigned long long sector, int offset, int length) { if (debug) - printf ("[%u]", sector); + printf ("[%llu]", sector); /* ReiserFS has files which sometimes contain data not aligned on sector boundaries. Returning an error is better than @@ -2266,11 +2266,11 @@ install_func (char *arg, int flags) /* Write SECTOR to INSTALLLIST, and update INSTALLADDR and INSTALLSECT. */ - auto void disk_read_blocklist_func (unsigned int sector, int offset, + auto void disk_read_blocklist_func (unsigned long long sector, int offset, int length) { if (debug) - printf("[%u]", sector); + printf("[%llu]", sector); if (offset != 0 || last_length != SECTOR_SIZE) { @@ -2435,6 +2435,10 @@ install_func (char *arg, int flags) goto fail; stage2_first_sector = saved_sector; + if (stage2_first_sector >= 0xffffffffUL) { + grub_printf ("Error: stage2 first sector must be below 2TB\n"); + goto fail; + } /* Read the second sector of Stage 2. */ if (grub_read (stage2_second_buffer, SECTOR_SIZE) != SECTOR_SIZE) @@ -3379,7 +3383,7 @@ parttype_func (char *arg, int flags) { int new_type; unsigned long part = 0xFFFFFF; - unsigned long start, len, offset, ext_offset, gpt_offset; + unsigned long long start, len, offset, ext_offset, gpt_offset; int entry, type, gpt_count, gpt_size; char mbr[512]; @@ -3896,7 +3900,7 @@ savedefault_func (char *arg, int flags) char sect[SECTOR_SIZE]; int entryno; int sector_count = 0; - unsigned int saved_sectors[2]; + unsigned long long saved_sectors[2]; int saved_offsets[2]; int saved_lengths[2]; @@ -3906,9 +3910,9 @@ savedefault_func (char *arg, int flags) } /* Save sector information about at most two sectors. */ - auto void disk_read_savesect_func (unsigned int sector, int offset, + auto void disk_read_savesect_func (unsigned long long sector, int offset, int length); - void disk_read_savesect_func (unsigned int sector, int offset, int length) + void disk_read_savesect_func (unsigned long long sector, int offset, int length) { if (sector_count < 2) { diff --git a/usr/src/grub/grub-0.97/stage2/char_io.c b/usr/src/grub/grub-0.97/stage2/char_io.c index 7146377cd0..0240df964e 100644 --- a/usr/src/grub/grub-0.97/stage2/char_io.c +++ b/usr/src/grub/grub-0.97/stage2/char_io.c @@ -20,6 +20,7 @@ /* * Copyright 2008 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. + * Copyright 2016 Nexenta Systems, Inc. */ #include <shared.h> @@ -147,16 +148,16 @@ print_error (void) } char * -convert_to_ascii (char *buf, int c,...) +convert_to_ascii (char *buf, int c, unsigned long long num) { - unsigned long num = *((&c) + 1), mult = 10; + unsigned long mult = 10; char *ptr = buf; #ifndef STAGE1_5 if (c == 'x' || c == 'X') mult = 16; - if ((num & 0x80000000uL) && c == 'd') + if ((num & 0x8000000000000000uLL) && c == 'd') { num = (~num) + 1; *(ptr++) = '-'; @@ -198,35 +199,56 @@ grub_putstr (const char *str) static void grub_vprintf (const char *format, int *dataptr) { - char c, str[16]; + char c, str[21]; + int lflag; + unsigned long long val; while ((c = *(format++)) != 0) { + lflag = 0; if (c != '%') grub_putchar (c); else - switch (c = *(format++)) - { + while ((c = *(format++)) != 0) { + switch (c) + { + case 'l': + lflag++; + continue; + #ifndef STAGE1_5 - case 'd': - case 'x': - case 'X': + case 'd': + case 'x': + case 'X': #endif - case 'u': - *convert_to_ascii (str, c, *((unsigned long *) dataptr++)) = 0; - grub_putstr (str); - break; + case 'u': + if (lflag == 2) { + val = *(unsigned long long *)dataptr; + dataptr += 2; + } else { + if (c == 'd') + val = (long long)*(long *)dataptr++; + else + val = *(unsigned long *)dataptr++; + } + *convert_to_ascii (str, c, val) = 0; + grub_putstr (str); + break; #ifndef STAGE1_5 - case 'c': - grub_putchar ((*(dataptr++)) & 0xff); - break; + case 'c': + grub_putchar ((*(dataptr++)) & 0xff); + break; - case 's': - grub_putstr ((char *) *(dataptr++)); - break; + case 's': + grub_putstr ((char *) *(dataptr++)); + break; #endif + default: + grub_putchar (c); } + break; + } } } @@ -905,48 +927,67 @@ grub_vsprintf (char *buffer, const char *format, int *dataptr) char c, *ptr, str[16]; char *bp = buffer; int len = 0; + int lflag; + unsigned long long val; while ((c = *format++) != 0) { + lflag = 0; if (c != '%') { if (buffer) *bp++ = c; /* putchar(c); */ len++; } else { - switch (c = *(format++)) - { - case 'd': case 'u': case 'x': - *convert_to_ascii (str, c, *((unsigned long *) dataptr++)) = 0; + while (c = *(format++)) { + switch (c) + { + case 'l': + lflag++; + continue; + + case 'd': case 'u': case 'x': + if (lflag == 2) { + val = *(unsigned long long *)dataptr; + dataptr += 2; + } else { + if (c == 'd') + val = (long long)*(long *)dataptr++; + else + val = *(unsigned long *)dataptr++; + } + *convert_to_ascii (str, c, val) = 0; - ptr = str; + ptr = str; + + while (*ptr) { + if (buffer) + *bp++ = *(ptr++); /* putchar(*(ptr++)); */ + else + ptr++; + len++; + } + break; - while (*ptr) { - if (buffer) - *bp++ = *(ptr++); /* putchar(*(ptr++)); */ + case 'c': + if (buffer) + *bp++ = (*(dataptr++))&0xff; else - ptr++; + dataptr++; len++; - } - break; - - case 'c': - if (buffer) - *bp++ = (*(dataptr++))&0xff; - else - dataptr++; - len++; - /* putchar((*(dataptr++))&0xff); */ - break; + /* putchar((*(dataptr++))&0xff); */ + break; - case 's': - ptr = (char *) (*(dataptr++)); + case 's': + ptr = (char *) (*(dataptr++)); - while ((c = *ptr++) != 0) { - if (buffer) - *bp++ = c; /* putchar(c); */ - len++; - } + while ((c = *ptr++) != 0) { + if (buffer) + *bp++ = c; /* putchar(c); */ + len++; + } break; + } + break; } } } diff --git a/usr/src/grub/grub-0.97/stage2/disk_io.c b/usr/src/grub/grub-0.97/stage2/disk_io.c index 6f21277dae..1b07c23f7c 100644 --- a/usr/src/grub/grub-0.97/stage2/disk_io.c +++ b/usr/src/grub/grub-0.97/stage2/disk_io.c @@ -32,8 +32,8 @@ #endif /* instrumentation variables */ -void (*disk_read_hook) (unsigned int, int, int) = NULL; -void (*disk_read_func) (unsigned int, int, int) = NULL; +void (*disk_read_hook) (unsigned long long, int, int) = NULL; +void (*disk_read_func) (unsigned long long, int, int) = NULL; #ifndef STAGE1_5 int print_possibilities; @@ -119,8 +119,8 @@ static int block_file = 0; #endif /* NO_BLOCK_FILES */ /* these are the translated numbers for the open partition */ -unsigned long part_start; -unsigned long part_length; +unsigned long long part_start; +unsigned long long part_length; int current_slice; @@ -137,7 +137,7 @@ int find_best_root; /* disk buffer parameters */ int buf_drive = -1; -unsigned int buf_track; +unsigned long long buf_track; struct geometry buf_geom; /* filesystem common variables */ @@ -155,7 +155,7 @@ grub_log2 (unsigned long word) #define log2 grub_log2 int -rawread(int drive, unsigned int sector, int byte_offset, int byte_len, +rawread(int drive, unsigned long long sector, int byte_offset, int byte_len, char *buf) { int slen, sectors_per_vtrack; @@ -167,7 +167,7 @@ rawread(int drive, unsigned int sector, int byte_offset, int byte_len, while (byte_len > 0 && !errnum) { int soff, num_sect, size = byte_len; - unsigned int track; + unsigned long long track; char *bufaddr; /* @@ -205,7 +205,7 @@ rawread(int drive, unsigned int sector, int byte_offset, int byte_len, if (track != buf_track) { int bios_err, read_len = sectors_per_vtrack; - unsigned int read_start = track; + unsigned long long read_start = track; /* * If there's more than one read in this entire loop, then @@ -275,7 +275,7 @@ rawread(int drive, unsigned int sector, int byte_offset, int byte_len, */ if (disk_read_func) { - unsigned int sector_num = sector; + unsigned long long sector_num = sector; int length = buf_geom.sector_size - byte_offset; if (length > size) length = size; @@ -305,7 +305,7 @@ rawread(int drive, unsigned int sector, int byte_offset, int byte_len, int -devread(unsigned int sector, int byte_offset, int byte_len, char *buf) +devread(unsigned long long sector, int byte_offset, int byte_len, char *buf) { /* * Check partition boundaries @@ -325,7 +325,7 @@ devread(unsigned int sector, int byte_offset, int byte_len, char *buf) #if !defined(STAGE1_5) if (disk_read_hook && debug) - printf ("<%u, %d, %d>", sector, byte_offset, byte_len); + printf ("<%llu, %d, %d>", sector, byte_offset, byte_len); #endif /* !STAGE1_5 */ /* @@ -343,7 +343,7 @@ devread(unsigned int sector, int byte_offset, int byte_len, char *buf) #ifndef STAGE1_5 int -rawwrite(int drive, unsigned int sector, char *buf) +rawwrite(int drive, unsigned long long sector, char *buf) { if (sector == 0) { @@ -376,7 +376,7 @@ rawwrite(int drive, unsigned int sector, char *buf) } int -devwrite(unsigned int sector, int sector_count, char *buf) +devwrite(unsigned long long sector, int sector_count, char *buf) { #if defined(GRUB_UTIL) && defined(__linux__) if (current_partition != 0xFFFFFF @@ -515,7 +515,7 @@ int set_partition_hidden_flag (int hidden) { unsigned long part = 0xFFFFFF; - unsigned long start, len, offset, ext_offset, gpt_offset; + unsigned long long start, len, offset, ext_offset, gpt_offset; int entry, type, gpt_count, gpt_size; char mbr[512]; @@ -595,10 +595,10 @@ check_and_print_mount (void) int next_partition (unsigned long drive, unsigned long dest, unsigned long *partition, int *type, - unsigned long *start, unsigned long *len, - unsigned long *offset, int *entry, - unsigned long *ext_offset, - unsigned long *gpt_offset, int *gpt_count, + unsigned long long *start, unsigned long long *len, + unsigned long long *offset, int *entry, + unsigned long long *ext_offset, + unsigned long long *gpt_offset, int *gpt_count, int *gpt_size, char *buf) { /* Forward declarations. */ @@ -909,9 +909,9 @@ int real_open_partition (int flags) { unsigned long dest_partition = current_partition; - unsigned long part_offset; - unsigned long ext_offset; - unsigned long gpt_offset; + unsigned long long part_offset; + unsigned long long ext_offset; + unsigned long long gpt_offset; int gpt_count; int gpt_size; int entry; diff --git a/usr/src/grub/grub-0.97/stage2/moddiv.c b/usr/src/grub/grub-0.97/stage2/moddiv.c new file mode 100644 index 0000000000..78460cfc71 --- /dev/null +++ b/usr/src/grub/grub-0.97/stage2/moddiv.c @@ -0,0 +1,222 @@ +/* Header file for libgcc2.c. */ +/* Copyright (C) 2000, 2001, 2004, 2005, 2009 + Free Software Foundation, Inc. + +This file is part of GCC. + +GCC 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 3, or (at your option) any later +version. + +GCC 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. + +Under Section 7 of GPL version 3, you are granted additional +permissions described in the GCC Runtime Library Exception, version +3.1, as published by the Free Software Foundation. + +You should have received a copy of the GNU General Public License and +a copy of the GCC Runtime Library Exception along with this program; +see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +<http://www.gnu.org/licenses/>. */ + +typedef int SItype __attribute__ ((mode (SI))); +typedef unsigned int USItype __attribute__ ((mode (SI))); +typedef int DItype __attribute__ ((mode (DI))); +typedef unsigned int UDItype __attribute__ ((mode (DI))); + +#define BITS_PER_UNIT 8 +#define W_TYPE_SIZE (4 * BITS_PER_UNIT) +#define Wtype SItype +#define DWtype DItype +#define UWtype USItype +#define UDWtype UDItype + +struct DWstruct {Wtype low, high;}; + +typedef union +{ + struct DWstruct s; + DWtype ll; +} DWunion; + +#define sub_ddmmss(sh, sl, ah, al, bh, bl) \ + __asm__ ("sub{l} {%5,%1|%1,%5}\n\tsbb{l} {%3,%0|%0,%3}" \ + : "=r" ((USItype) (sh)), \ + "=&r" ((USItype) (sl)) \ + : "0" ((USItype) (ah)), \ + "g" ((USItype) (bh)), \ + "1" ((USItype) (al)), \ + "g" ((USItype) (bl))) + +#define umul_ppmm(w1, w0, u, v) \ + __asm__ ("mul{l} %3" \ + : "=a" ((USItype) (w0)), \ + "=d" ((USItype) (w1)) \ + : "%0" ((USItype) (u)), \ + "rm" ((USItype) (v))) +#define udiv_qrnnd(q, r, n1, n0, dv) \ + __asm__ ("div{l} %4" \ + : "=a" ((USItype) (q)), \ + "=d" ((USItype) (r)) \ + : "0" ((USItype) (n0)), \ + "1" ((USItype) (n1)), \ + "rm" ((USItype) (dv))) + +#define count_leading_zeros(count, x) ((count) = __builtin_clz (x)) + +UDWtype +__udivmoddi4 (UDWtype n, UDWtype d, UDWtype *rp) +{ + const DWunion nn = {.ll = n}; + const DWunion dd = {.ll = d}; + DWunion rr; + UWtype d0, d1, n0, n1, n2; + UWtype q0, q1; + UWtype b, bm; + + d0 = dd.s.low; + d1 = dd.s.high; + n0 = nn.s.low; + n1 = nn.s.high; + + if (d1 == 0) + { + if (d0 > n1) + { + /* 0q = nn / 0D */ + + udiv_qrnnd (q0, n0, n1, n0, d0); + q1 = 0; + + /* Remainder in n0. */ + } + else + { + /* qq = NN / 0d */ + + if (d0 == 0) + d0 = 1 / d0; /* Divide intentionally by zero. */ + + udiv_qrnnd (q1, n1, 0, n1, d0); + udiv_qrnnd (q0, n0, n1, n0, d0); + + /* Remainder in n0. */ + } + + if (rp != 0) + { + rr.s.low = n0; + rr.s.high = 0; + *rp = rr.ll; + } + } + + + else + { + if (d1 > n1) + { + /* 00 = nn / DD */ + + q0 = 0; + q1 = 0; + + /* Remainder in n1n0. */ + if (rp != 0) + { + rr.s.low = n0; + rr.s.high = n1; + *rp = rr.ll; + } + } + else + { + /* 0q = NN / dd */ + + count_leading_zeros (bm, d1); + if (bm == 0) + { + /* From (n1 >= d1) /\ (the most significant bit of d1 is set), + conclude (the most significant bit of n1 is set) /\ (the + quotient digit q0 = 0 or 1). + + This special case is necessary, not an optimization. */ + + /* The condition on the next line takes advantage of that + n1 >= d1 (true due to program flow). */ + if (n1 > d1 || n0 >= d0) + { + q0 = 1; + sub_ddmmss (n1, n0, n1, n0, d1, d0); + } + else + q0 = 0; + + q1 = 0; + + if (rp != 0) + { + rr.s.low = n0; + rr.s.high = n1; + *rp = rr.ll; + } + } + else + { + UWtype m1, m0; + /* Normalize. */ + + b = W_TYPE_SIZE - bm; + + d1 = (d1 << bm) | (d0 >> b); + d0 = d0 << bm; + n2 = n1 >> b; + n1 = (n1 << bm) | (n0 >> b); + n0 = n0 << bm; + + udiv_qrnnd (q0, n1, n2, n1, d1); + umul_ppmm (m1, m0, q0, d0); + + if (m1 > n1 || (m1 == n1 && m0 > n0)) + { + q0--; + sub_ddmmss (m1, m0, m1, m0, d1, d0); + } + + q1 = 0; + + /* Remainder in (n1n0 - m1m0) >> bm. */ + if (rp != 0) + { + sub_ddmmss (n1, n0, n1, n0, m1, m0); + rr.s.low = (n1 << b) | (n0 >> bm); + rr.s.high = n1 >> bm; + *rp = rr.ll; + } + } + } + } + + const DWunion ww = {{.low = q0, .high = q1}}; + return ww.ll; +} + +UDWtype +__udivdi3 (UDWtype n, UDWtype d) +{ + return __udivmoddi4 (n, d, (UDWtype *) 0); +} + +UDWtype +__umoddi3 (UDWtype u, UDWtype v) +{ + UDWtype w; + + (void) __udivmoddi4 (u, v, &w); + + return w; +} diff --git a/usr/src/grub/grub-0.97/stage2/shared.h b/usr/src/grub/grub-0.97/stage2/shared.h index 9cf436e346..050e6335fe 100644 --- a/usr/src/grub/grub-0.97/stage2/shared.h +++ b/usr/src/grub/grub-0.97/stage2/shared.h @@ -667,8 +667,8 @@ extern int compressed_file; #endif /* instrumentation variables */ -extern void (*disk_read_hook) (unsigned int, int, int); -extern void (*disk_read_func) (unsigned int, int, int); +extern void (*disk_read_hook) (unsigned long long, int, int); +extern void (*disk_read_func) (unsigned long long, int, int); #ifndef STAGE1_5 /* The flag for debug mode. */ @@ -708,14 +708,14 @@ struct geometry unsigned long flags; }; -extern unsigned long part_start; -extern unsigned long part_length; +extern unsigned long long part_start; +extern unsigned long long part_length; extern int current_slice; extern int buf_drive; -#define BUF_CACHE_INVALID 0xffffffff -extern unsigned int buf_track; +#define BUF_CACHE_INVALID (-1ULL) +extern unsigned long long buf_track; extern struct geometry buf_geom; /* these are the current file position and maximum file position */ @@ -889,7 +889,7 @@ int checkkey (void); /* Low-level disk I/O */ int get_diskinfo (int drive, struct geometry *geometry); int biosdisk (int subfunc, int drive, struct geometry *geometry, - unsigned int sector, int nsec, int segment); + unsigned long long sector, int nsec, int segment); void stop_floppy (void); /* Command-line interface functions. */ @@ -990,7 +990,7 @@ extern grub_jmp_buf restart_cmdline_env; /* misc */ void init_page (void); void print_error (void); -char *convert_to_ascii (char *buf, int c, ...); +char *convert_to_ascii (char *buf, int c, unsigned long long num); int get_cmdline (char *prompt, char *cmdline, int maxlen, int echo_char, int history); int substring (const char *s1, const char *s2); @@ -1006,11 +1006,11 @@ int gunzip_test_header (void); int gunzip_read (char *buf, int len); #endif /* NO_DECOMPRESSION */ -int rawread (int drive, unsigned int sector, int byte_offset, int byte_len, +int rawread (int drive, unsigned long long sector, int byte_offset, int byte_len, char *buf); -int devread (unsigned int sector, int byte_offset, int byte_len, char *buf); -int rawwrite (int drive, unsigned int sector, char *buf); -int devwrite (unsigned int sector, int sector_len, char *buf); +int devread (unsigned long long sector, int byte_offset, int byte_len, char *buf); +int rawwrite (int drive, unsigned long long sector, char *buf); +int devwrite (unsigned long long sector, int sector_len, char *buf); /* Parse a device string and initialize the global parameters. */ char *set_device (char *device); @@ -1019,10 +1019,10 @@ int real_open_partition (int flags); int open_partition (void); int next_partition (unsigned long drive, unsigned long dest, unsigned long *partition, int *type, - unsigned long *start, unsigned long *len, - unsigned long *offset, int *entry, - unsigned long *ext_offset, - unsigned long *gpt_offset, int *gpt_count, + unsigned long long *start, unsigned long long *len, + unsigned long long *offset, int *entry, + unsigned long long *ext_offset, + unsigned long long *gpt_offset, int *gpt_count, int *gpt_size, char *buf); /* Sets device to the one represented by the SAVED_* parameters. */ diff --git a/usr/src/grub/grub-0.97/stage2/stage1_5.c b/usr/src/grub/grub-0.97/stage2/stage1_5.c index f04a3371d9..f8046dae83 100644 --- a/usr/src/grub/grub-0.97/stage2/stage1_5.c +++ b/usr/src/grub/grub-0.97/stage2/stage1_5.c @@ -16,13 +16,16 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ +/* + * Copyright 2016 Nexenta Systems, Inc. + */ #include "shared.h" -static unsigned int saved_sector = (unsigned int)-1; +static unsigned long long saved_sector = (unsigned long long)-1; static void -disk_read_savesect_func (unsigned int sector, int offset, int length) +disk_read_savesect_func (unsigned long long sector, int offset, int length) { saved_sector = sector; } |