Re: Bug#854568: grub2: Add support for modern sparc64 hardware

2018-02-19 Thread John Paul Adrian Glaubitz

Hi Colin!

On 09/29/2017 03:04 AM, John Paul Adrian Glaubitz wrote:

Slightly updated to fix an FTBFS because of -Wmaybe-uninitalized.


This version of the patch still applies cleanly.

Would you mind including it for the next 2.02 upload? It will be
part of GRUB upstream once version 2.04 is released.

Our sparc64 users are a bit frustrated that GRUB breaks on sparc64
everytime a new version of the Debian package is uploaded.

Thanks,
Adrian

--
 .''`.  John Paul Adrian Glaubitz
: :' :  Debian Developer - glaub...@debian.org
`. `'   Freie Universitaet Berlin - glaub...@physik.fu-berlin.de
  `-GPG: 62FF 8A75 84E0 2956 9546  0006 7426 3B37 F5B5 F913



Re: Bug#854568: grub2: Add support for modern sparc64 hardware

2017-09-28 Thread John Paul Adrian Glaubitz
On 09/29/2017 02:40 AM, John Paul Adrian Glaubitz wrote:
> Attaching an updated patch for the current 2.02-2 package.

Slightly updated to fix an FTBFS because of -Wmaybe-uninitalized.

Adrian

-- 
 .''`.  John Paul Adrian Glaubitz
: :' :  Debian Developer - glaub...@debian.org
`. `'   Freie Universitaet Berlin - glaub...@physik.fu-berlin.de
  `-GPG: 62FF 8A75 84E0 2956 9546  0006 7426 3B37 F5B5 F913
Description: Add support for sparc64
Author: Eric Snowberg 
Last-Update: 2017-09-29
Source: https://github.com/esnowberg/grub2-sparc/tree/sparc-next-v4

Index: grub2-2.02/grub-core/Makefile.core.def
===
--- grub2-2.02.orig/grub-core/Makefile.core.def
+++ grub2-2.02/grub-core/Makefile.core.def
@@ -270,6 +270,7 @@ kernel = {
   sparc64_ieee1275 = kern/sparc64/cache.S;
   sparc64_ieee1275 = kern/sparc64/dl.c;
   sparc64_ieee1275 = kern/sparc64/ieee1275/ieee1275.c;
+  sparc64_ieee1275 = disk/ieee1275/obdisk.c;
 
   arm = kern/arm/dl.c;
   arm = kern/arm/dl_helper.c;
Index: grub2-2.02/grub-core/boot/sparc64/ieee1275/boot.S
===
--- grub2-2.02.orig/grub-core/boot/sparc64/ieee1275/boot.S
+++ grub2-2.02/grub-core/boot/sparc64/ieee1275/boot.S
@@ -69,6 +69,10 @@ prom_seek_name:		.asciz "seek"
 prom_read_name:		.asciz "read"
 prom_exit_name:		.asciz "exit"
 grub_name:		.asciz "GRUB "
+#ifdef CDBOOT
+prom_close_name:	.asciz "close"
+#endif
+
 #define GRUB_NAME_LEN	5
 
 	.align	4
@@ -213,6 +217,12 @@ bootpath_known:
 	call	prom_call_3_1_o1
 #ifdef CDBOOT
 	 LDUW_ABS(kernel_size, 0x00, %o3)
+
+	GET_ABS(prom_close_name, %o0)
+	mov	1, %g1
+	mov	0, %o5
+	call	prom_call
+	 mov	BOOTDEV_REG, %o1
 #else
 	 mov	512, %o3
 #endif
Index: grub2-2.02/grub-core/commands/ls.c
===
--- grub2-2.02.orig/grub-core/commands/ls.c
+++ grub2-2.02/grub-core/commands/ls.c
@@ -201,6 +201,8 @@ grub_ls_list_files (char *dirname, int l
   if (grub_errno == GRUB_ERR_UNKNOWN_FS)
 	grub_errno = GRUB_ERR_NONE;
 
+  grub_device_close (dev);
+  dev = NULL;
   grub_normal_print_device_info (device_name);
 }
   else if (fs)
Index: grub2-2.02/grub-core/commands/nativedisk.c
===
--- grub2-2.02.orig/grub-core/commands/nativedisk.c
+++ grub2-2.02/grub-core/commands/nativedisk.c
@@ -66,6 +66,7 @@ get_uuid (const char *name, char **uuid,
   /* Firmware disks.  */
 case GRUB_DISK_DEVICE_BIOSDISK_ID:
 case GRUB_DISK_DEVICE_OFDISK_ID:
+case GRUB_DISK_DEVICE_OBDISK_ID:
 case GRUB_DISK_DEVICE_EFIDISK_ID:
 case GRUB_DISK_DEVICE_NAND_ID:
 case GRUB_DISK_DEVICE_ARCDISK_ID:
Index: grub2-2.02/grub-core/disk/ieee1275/obdisk.c
===
--- /dev/null
+++ grub2-2.02/grub-core/disk/ieee1275/obdisk.c
@@ -0,0 +1,1079 @@
+/* obdisk.c - Open Boot disk access.  */
+/*
+ *  GRUB  --  GRand Unified Bootloader
+ *  Copyright (C) 2017 Free Software Foundation, Inc.
+ *
+ *  GRUB 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 of the License, or
+ *  (at your option) any later version.
+ *
+ *  GRUB 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 GRUB.  If not, see .
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+struct disk_dev
+{
+  struct disk_dev *next;
+  struct disk_dev **prev;
+  /* open boot canonical name */
+  char *name;
+  /* open boot raw disk name to access entire disk */
+  char *raw_name;
+  /* grub encoded device name */
+  char *grub_devpath;
+  /* grub encoded alias name  */
+  char *grub_alias_devpath;
+  /* grub unescaped name */
+  char *grub_decoded_devpath;
+  grub_ieee1275_ihandle_t ihandle;
+  grub_uint32_t block_size;
+  grub_uint64_t num_blocks;
+  unsigned int log_sector_size;
+  grub_uint32_t opened;
+  grub_uint32_t valid;
+  grub_uint32_t boot_dev;
+};
+
+struct parent_dev
+{
+  struct parent_dev *next;
+  struct parent_dev **prev;
+  /* canonical parent name */
+  char *name;
+  char *type;
+  grub_ieee1275_ihandle_t ihandle;
+  grub_uint32_t address_cells;
+};
+
+static struct grub_scsi_test_unit_ready tur =
+{
+  .opcode = grub_scsi_cmd_test_unit_ready,
+  .lun = 0,
+  .reserved1 = 0,
+  .reserved2 = 0,
+  .reserved3 = 0,
+  .control = 0,
+};
+
+static int disks_enumerated = 0;
+static struct disk_dev *disk_devs = NULL;
+static struct parent_dev *parent_devs = NULL;
+
+static const

Re: Bug#854568: grub2: Add support for modern sparc64 hardware

2017-09-28 Thread John Paul Adrian Glaubitz
Hi!

Attaching an updated patch for the current 2.02-2 package.

I am working now on integrating GRUB for sparc and sparc64 in debian-installer
and upstream has gotten new maintainers who have promised to get the sparc64
patches merged soonish [1].

Adrian

> [1] http://lists.gnu.org/archive/html/grub-devel/2017-09/msg00086.html

-- 
 .''`.  John Paul Adrian Glaubitz
: :' :  Debian Developer - glaub...@debian.org
`. `'   Freie Universitaet Berlin - glaub...@physik.fu-berlin.de
  `-GPG: 62FF 8A75 84E0 2956 9546  0006 7426 3B37 F5B5 F913
Description: Add support for sparc64
Author: Eric Snowberg 
Last-Update: 2017-09-29
Source: https://github.com/esnowberg/grub2-sparc/tree/sparc-next-v4

Index: grub2-2.02/grub-core/Makefile.core.def
===
--- grub2-2.02.orig/grub-core/Makefile.core.def
+++ grub2-2.02/grub-core/Makefile.core.def
@@ -270,6 +270,7 @@ kernel = {
   sparc64_ieee1275 = kern/sparc64/cache.S;
   sparc64_ieee1275 = kern/sparc64/dl.c;
   sparc64_ieee1275 = kern/sparc64/ieee1275/ieee1275.c;
+  sparc64_ieee1275 = disk/ieee1275/obdisk.c;
 
   arm = kern/arm/dl.c;
   arm = kern/arm/dl_helper.c;
Index: grub2-2.02/grub-core/boot/sparc64/ieee1275/boot.S
===
--- grub2-2.02.orig/grub-core/boot/sparc64/ieee1275/boot.S
+++ grub2-2.02/grub-core/boot/sparc64/ieee1275/boot.S
@@ -69,6 +69,10 @@ prom_seek_name:		.asciz "seek"
 prom_read_name:		.asciz "read"
 prom_exit_name:		.asciz "exit"
 grub_name:		.asciz "GRUB "
+#ifdef CDBOOT
+prom_close_name:	.asciz "close"
+#endif
+
 #define GRUB_NAME_LEN	5
 
 	.align	4
@@ -213,6 +217,12 @@ bootpath_known:
 	call	prom_call_3_1_o1
 #ifdef CDBOOT
 	 LDUW_ABS(kernel_size, 0x00, %o3)
+
+	GET_ABS(prom_close_name, %o0)
+	mov	1, %g1
+	mov	0, %o5
+	call	prom_call
+	 mov	BOOTDEV_REG, %o1
 #else
 	 mov	512, %o3
 #endif
Index: grub2-2.02/grub-core/commands/ls.c
===
--- grub2-2.02.orig/grub-core/commands/ls.c
+++ grub2-2.02/grub-core/commands/ls.c
@@ -201,6 +201,8 @@ grub_ls_list_files (char *dirname, int l
   if (grub_errno == GRUB_ERR_UNKNOWN_FS)
 	grub_errno = GRUB_ERR_NONE;
 
+  grub_device_close (dev);
+  dev = NULL;
   grub_normal_print_device_info (device_name);
 }
   else if (fs)
Index: grub2-2.02/grub-core/commands/nativedisk.c
===
--- grub2-2.02.orig/grub-core/commands/nativedisk.c
+++ grub2-2.02/grub-core/commands/nativedisk.c
@@ -66,6 +66,7 @@ get_uuid (const char *name, char **uuid,
   /* Firmware disks.  */
 case GRUB_DISK_DEVICE_BIOSDISK_ID:
 case GRUB_DISK_DEVICE_OFDISK_ID:
+case GRUB_DISK_DEVICE_OBDISK_ID:
 case GRUB_DISK_DEVICE_EFIDISK_ID:
 case GRUB_DISK_DEVICE_NAND_ID:
 case GRUB_DISK_DEVICE_ARCDISK_ID:
Index: grub2-2.02/grub-core/disk/ieee1275/obdisk.c
===
--- /dev/null
+++ grub2-2.02/grub-core/disk/ieee1275/obdisk.c
@@ -0,0 +1,1079 @@
+/* obdisk.c - Open Boot disk access.  */
+/*
+ *  GRUB  --  GRand Unified Bootloader
+ *  Copyright (C) 2017 Free Software Foundation, Inc.
+ *
+ *  GRUB 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 of the License, or
+ *  (at your option) any later version.
+ *
+ *  GRUB 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 GRUB.  If not, see .
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+struct disk_dev
+{
+  struct disk_dev *next;
+  struct disk_dev **prev;
+  /* open boot canonical name */
+  char *name;
+  /* open boot raw disk name to access entire disk */
+  char *raw_name;
+  /* grub encoded device name */
+  char *grub_devpath;
+  /* grub encoded alias name  */
+  char *grub_alias_devpath;
+  /* grub unescaped name */
+  char *grub_decoded_devpath;
+  grub_ieee1275_ihandle_t ihandle;
+  grub_uint32_t block_size;
+  grub_uint64_t num_blocks;
+  unsigned int log_sector_size;
+  grub_uint32_t opened;
+  grub_uint32_t valid;
+  grub_uint32_t boot_dev;
+};
+
+struct parent_dev
+{
+  struct parent_dev *next;
+  struct parent_dev **prev;
+  /* canonical parent name */
+  char *name;
+  char *type;
+  grub_ieee1275_ihandle_t ihandle;
+  grub_uint32_t address_cells;
+};
+
+static struct grub_scsi_test_unit_ready tur =
+{
+  .opcode = grub_scsi_cmd_test_unit_ready,
+  .lun = 0,
+  .reserved1 = 0,
+  .reserved2 = 0,
+  .reserved3 = 0,
+  .control = 0,
+};
+
+