Skip to contentSkip to conversation

sparc64 port

PATCH Vincent Pelletier 3 participants 6 messages Aug 20, 2005

lore
Share & tools
lore
#0 lore raw

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

I fixed the sparc64 port.
Current status is : rescue mode works, it can only be netbooted, no module support, no utils (grub-emu, grub-install,...)

I separate the Changelog in 2 parts, one for the changes I made that could interfere with the other ports (sparc_common.diff), and another for the added files (sparc64_files.tar.bz2). It should add only needed files & directories.

I added /* FIXME (sparc64). */ in each file that contains hard-coded values that might not be appropriate for sparc64 port. They come from powerpc port but I don't know what to set instead. Could be in files I don't use yet (like setjmp.h).

2005-08-20 Vincent Pelletier <[email protected]>

* configure.ac: Add support for sparc64 host with ieee1275 firmware.
* configure: Generated from configure.ac.
* disk/ieee1275/ofdisk.c (grub_ofdisk_open): use grub_ssize_t instead of int.
(grub_ofdisk_read): Likewise.
(grub_ofdisk_open): Use %p to print pointer values, and cast the pointers as (void *) to remove a warning. (grub_ofdisk_close): Likewise.
(grub_ofdisk_read): Likewise.
* kern/ieee1275/ieee1275.c (grub_ieee1275_exit): This never returns, so make it return void to remove a warning.
* include/grub/ieee1275/ieee1275.h (grub_ieee1275_exit):
Corresponding prototype change.
* kern/mm.c (grub_mm_init_region): Use %p to print pointer values, and cast the pointers as (void *) to remove a warning. (grub_mm_dump): Likewise.

2005-08-20 Vincent Pelletier <[email protected]>

* boot/sparc64: New directory.
* boot/sparc64/ieee1275: New directory.
* boot/sparc64/ieee1275/cmain.c: New file.
* conf/sparc64-ieee1275.mk: New file.
* conf/sparc64-ieee1275.rmk: New file.
* include/grub/sparc64: New directory.
* include/grub/sparc64/setjmp.h: New file.
* include/grub/sparc64/types.h: New file.
* include/grub/sparc64/ieee1275: New directory.
* include/grub/sparc64/ieee1275/console.h: New file.
* include/grub/sparc64/ieee1275/ieee1275.h: New file.
* include/grub/sparc64/ieee1275/kernel.h: New file.
* include/grub/sparc64/ieee1275/time.h: New file.
* kern/sparc64: New directory.
* kern/sparc64/cache.c: New file.
* kern/sparc64/dl.c: New file.
* kern/sparc64/ieee1275: New directory.
* kern/sparc64/ieee1275/init.c: New file.
* kern/sparc64/ieee1275/openfw.c: New file.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)

iD8DBQFDBxa3FEQoKRQyjtURArmEAJ45AqBteOR4vSto4ssu/jl5NwosXQCgsio/ m9dBbZzRGeKT5mqEcr7/Zr4=
=mU/+
-----END PGP SIGNATURE-----

Index: configure
===================================================================
RCS file: /cvsroot/grub/grub2/configure,v
retrieving revision 1.20

configure +2 -0
diff -u -p -r1.20 configure
@@ -1397,6 +1397,7 @@ host_os=`echo $ac_cv_host | sed 's/^\([^
 case "$host_cpu" in
   i[3456]86) host_cpu=i386 ;;
   powerpc) ;;
+  sparc64) ;;
   *) { { echo "$as_me:$LINENO: error: unsupported CPU type" >&5
 echo "$as_me: error: unsupported CPU type" >&2;}
    { (exit 1); exit 1; }; } ;;
@@ -1405,6 +1406,7 @@ esac
 case "$host_cpu"-"$host_vendor" in
   i386-*) host_vendor=pc ;;
   powerpc-*) host_vendor=ieee1275 ;;
+  sparc64-*) host_vendor=ieee1275 ;;
   *) { { echo "$as_me:$LINENO: error: unsupported machine type" >&5
 echo "$as_me: error: unsupported machine type" >&2;}
    { (exit 1); exit 1; }; } ;;

Index: configure.ac
===================================================================
RCS file: /cvsroot/grub/grub2/configure.ac,v
retrieving revision 1.12

configure.ac +2 -0
diff -u -p -r1.12 configure.ac
@@ -23,12 +23,14 @@ AC_CANONICAL_HOST
 case "$host_cpu" in
   i[[3456]]86) host_cpu=i386 ;;
   powerpc) ;;
+  sparc64) ;;
   *) AC_MSG_ERROR([unsupported CPU type]) ;;
 esac
 
 case "$host_cpu"-"$host_vendor" in
   i386-*) host_vendor=pc ;;
   powerpc-*) host_vendor=ieee1275 ;;
+  sparc64-*) host_vendor=ieee1275 ;;
   *) AC_MSG_ERROR([unsupported machine type]) ;;
 esac
 

Index: disk/ieee1275/ofdisk.c
===================================================================
RCS file: /cvsroot/grub/grub2/disk/ieee1275/ofdisk.c,v retrieving revision 1.1

ieee1275/ofdisk.c +7 -8
diff -u -p -r1.1 ofdisk.c
@@ -53,7 +53,7 @@ grub_ofdisk_open (const char *name, grub
   char *devpath;
   /* XXX: This should be large enough for any possible case.  */
   char prop[64];
-  int actual;
+  grub_ssize_t actual;
 
   devpath = grub_strndup (name, grub_strlen (name) + 2);
   if (! devpath)
@@ -72,7 +72,7 @@ grub_ofdisk_open (const char *name, grub
       goto fail;
     }
 
-  grub_dprintf ("disk", "Opened `%s' as handle 0x%x.\n", devpath, dev_ihandle);
+  grub_dprintf ("disk", "Opened `%s' as handle %p.\n", devpath, (void *) dev_ihandle);
 
   if (grub_ieee1275_finddevice (devpath, &dev))
     {
@@ -116,8 +116,8 @@ grub_ofdisk_open (const char *name, grub
 static void
 grub_ofdisk_close (grub_disk_t disk)
 {
-  grub_dprintf ("disk", "Closing handle 0x%x.\n",
-		(grub_ieee1275_ihandle_t) disk->data);
+  grub_dprintf ("disk", "Closing handle %p.\n",
+		(void *) disk->data);
   grub_ieee1275_close ((grub_ieee1275_ihandle_t) disk->data);
 }
 
@@ -125,13 +125,12 @@ static grub_err_t
 grub_ofdisk_read (grub_disk_t disk, unsigned long sector,
 		  unsigned long size, char *buf)
 {
-  int status;
-  int actual;
+  grub_ssize_t status, actual;
   unsigned long long pos;
 
   grub_dprintf ("disk",
-		"Reading handle 0x%x: sector 0x%lx, size 0x%lx, buf %p.\n",
-		(grub_ieee1275_ihandle_t) disk->data, sector, size, buf);
+		"Reading handle %p: sector 0x%lx, size 0x%lx, buf %p.\n",
+		(void *) disk->data, sector, size, buf);
 
   pos = (unsigned long long) sector * 512UL;
 

Index: include/grub/ieee1275/ieee1275.h
===================================================================
RCS file: /cvsroot/grub/grub2/include/grub/ieee1275/ieee1275.h,v retrieving revision 1.1

grub/ieee1275/ieee1275.h +1 -1
diff -u -p -r1.1 ieee1275.h
@@ -126,7 +126,7 @@ int EXPORT_FUNC(grub_ieee1275_parent) (g
 int EXPORT_FUNC(grub_ieee1275_interpret) (const char *command,
 					  grub_ieee1275_cell_t *catch);
 int EXPORT_FUNC(grub_ieee1275_enter) (void);
-int EXPORT_FUNC(grub_ieee1275_exit) (void) __attribute__ ((noreturn));
+void EXPORT_FUNC(grub_ieee1275_exit) (void) __attribute__ ((noreturn));
 int EXPORT_FUNC(grub_ieee1275_open) (const char *node,
 				     grub_ieee1275_ihandle_t *result);
 int EXPORT_FUNC(grub_ieee1275_close) (grub_ieee1275_ihandle_t ihandle);

Index: kern/mm.c
===================================================================
RCS file: /cvsroot/grub/grub2/kern/mm.c,v
retrieving revision 1.12

mm.c +3 -3
diff -u -p -r1.12 mm.c
@@ -137,7 +137,7 @@ grub_mm_init_region (void *addr, grub_si
   grub_mm_header_t h;
   grub_mm_region_t r, *p, q;
 
-  grub_dprintf ("mem", "Using memory for heap: addr=%p, size=%u\n", addr, size);
+  grub_dprintf ("mem", "Using memory for heap: addr=%p, size=%u\n", addr, (unsigned int) size);
 
   /* If this region is too small, ignore it.  */
   if (size < GRUB_MM_ALIGN * 2)
@@ -408,10 +408,10 @@ grub_mm_dump (unsigned lineno)
 	    {
 	    case GRUB_MM_FREE_MAGIC:
 	      grub_printf ("F:%p:%u:%p\n",
-			   p, p->size << GRUB_MM_ALIGN_LOG2, p->next);
+			   p, (unsigned int) p->size << GRUB_MM_ALIGN_LOG2, p->next);
 	      break;
 	    case GRUB_MM_ALLOC_MAGIC:
-	      grub_printf ("A:%p:%u\n", p, p->size << GRUB_MM_ALIGN_LOG2);
+	      grub_printf ("A:%p:%u\n", p, (unsigned int) p->size << GRUB_MM_ALIGN_LOG2);
 	      break;
 	    }
 	}

Index: kern/ieee1275/ieee1275.c
===================================================================
RCS file: /cvsroot/grub/grub2/kern/ieee1275/ieee1275.c,v retrieving revision 1.1

ieee1275/ieee1275.c +1 -1
diff -u -p -r1.1 ieee1275.c
@@ -393,7 +393,7 @@ grub_ieee1275_enter (void)
   return 0;
 }
 
-int
+void
 grub_ieee1275_exit (void)
 {
   struct exit_args
#1 lore raw
Quoted 1 line · Vincent Pelletier

* boot/sparc64/ieee1275/cmain.c: New file.

This is wrong. I guess you just followed the powerpc port, but it is also wrong. Instead, this file must be put in the kernel. The directory boot is used to organize files for the bootstrap of the kernel, which are not a part of the kernel.

In principle, the kernel should not be linked with a file in another directory. Unfortunately, this is not always true, in order to solve "chicken and egg" problems. Nevertheless, we should try to make the kernel as much independent of other directories as possible.

Quoted 1 line

       * kern/sparc64/cache.c: New file.

The contents of this file is strange. Why don't you simply include grub/cache.h?

About the ChangeLog:

Please do not mention new directories. They are not worth describing, because they don't cause bugs, and they are not related to copyright problems.

Please use simply "Likewise" when you repeat the same description. This is not obligatory, but often easier to read.

Okuji

#2 lore raw

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Quoted 3 lines · Yoshinori K. Okuji
Quoted 1 line · Vincent Pelletier

* boot/sparc64/ieee1275/cmain.c: New file.

This is wrong.

Corrected.

Quoted 3 lines
Quoted 1 line

* kern/sparc64/cache.c: New file.

The contents of this file is strange. Why don't you simply include grub/cache.h?

Done.

2005-08-20 Vincent Pelletier <[email protected]>

* configure.ac: Add support for sparc64 host with ieee1275 firmware.
* configure: Generated from configure.ac.
* disk/ieee1275/ofdisk.c (grub_ofdisk_open): use grub_ssize_t instead of int.
(grub_ofdisk_read): Likewise.
(grub_ofdisk_open): Use %p to print pointer values, and cast the pointers as (void *) to remove a warning. (grub_ofdisk_close): Likewise.
(grub_ofdisk_read): Likewise.
* kern/ieee1275/ieee1275.c (grub_ieee1275_exit): This never returns, so make it return void to remove a warning.
* include/grub/ieee1275/ieee1275.h (grub_ieee1275_exit):
Corresponding prototype change.
* kern/mm.c (grub_mm_init_region): Use %p to print pointer values, and cast the pointers as (void *) to remove a warning. (grub_mm_dump): Likewise.

2005-08-20 Vincent Pelletier <[email protected]>

* conf/sparc64-ieee1275.mk: New file.
* conf/sparc64-ieee1275.rmk: Likewise.
* include/grub/sparc64/setjmp.h: Likewise.
* include/grub/sparc64/types.h: Likewise.
* include/grub/sparc64/ieee1275/console.h: Likewise.
* include/grub/sparc64/ieee1275/ieee1275.h: Likewise.
* include/grub/sparc64/ieee1275/kernel.h: Likewise.
* include/grub/sparc64/ieee1275/time.h: Likewise.
* kern/sparc64/cache.c: Likewise.
* kern/sparc64/dl.c: Likewise.
* kern/sparc64/ieee1275/init.c: Likewise.
* kern/sparc64/ieee1275/openfw.c: Likewise.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)

iD8DBQFDBzdMFEQoKRQyjtURApAOAKCrh0SBed8sT+RdIxjSg4md23rkrACbBOTj xya2F+fAkszTpaD9eieLgrk=
=6Cqh
-----END PGP SIGNATURE-----

Index: configure
===================================================================
RCS file: /cvsroot/grub/grub2/configure,v
retrieving revision 1.20

configure +2 -0
diff -u -p -r1.20 configure
@@ -1397,6 +1397,7 @@ host_os=`echo $ac_cv_host | sed 's/^\([^
 case "$host_cpu" in
   i[3456]86) host_cpu=i386 ;;
   powerpc) ;;
+  sparc64) ;;
   *) { { echo "$as_me:$LINENO: error: unsupported CPU type" >&5
 echo "$as_me: error: unsupported CPU type" >&2;}
    { (exit 1); exit 1; }; } ;;
@@ -1405,6 +1406,7 @@ esac
 case "$host_cpu"-"$host_vendor" in
   i386-*) host_vendor=pc ;;
   powerpc-*) host_vendor=ieee1275 ;;
+  sparc64-*) host_vendor=ieee1275 ;;
   *) { { echo "$as_me:$LINENO: error: unsupported machine type" >&5
 echo "$as_me: error: unsupported machine type" >&2;}
    { (exit 1); exit 1; }; } ;;

Index: configure.ac
===================================================================
RCS file: /cvsroot/grub/grub2/configure.ac,v
retrieving revision 1.12

configure.ac +2 -0
diff -u -p -r1.12 configure.ac
@@ -23,12 +23,14 @@ AC_CANONICAL_HOST
 case "$host_cpu" in
   i[[3456]]86) host_cpu=i386 ;;
   powerpc) ;;
+  sparc64) ;;
   *) AC_MSG_ERROR([unsupported CPU type]) ;;
 esac
 
 case "$host_cpu"-"$host_vendor" in
   i386-*) host_vendor=pc ;;
   powerpc-*) host_vendor=ieee1275 ;;
+  sparc64-*) host_vendor=ieee1275 ;;
   *) AC_MSG_ERROR([unsupported machine type]) ;;
 esac
 

Index: disk/ieee1275/ofdisk.c
===================================================================
RCS file: /cvsroot/grub/grub2/disk/ieee1275/ofdisk.c,v retrieving revision 1.1

ieee1275/ofdisk.c +7 -8
diff -u -p -r1.1 ofdisk.c
@@ -53,7 +53,7 @@ grub_ofdisk_open (const char *name, grub
   char *devpath;
   /* XXX: This should be large enough for any possible case.  */
   char prop[64];
-  int actual;
+  grub_ssize_t actual;
 
   devpath = grub_strndup (name, grub_strlen (name) + 2);
   if (! devpath)
@@ -72,7 +72,7 @@ grub_ofdisk_open (const char *name, grub
       goto fail;
     }
 
-  grub_dprintf ("disk", "Opened `%s' as handle 0x%x.\n", devpath, dev_ihandle);
+  grub_dprintf ("disk", "Opened `%s' as handle %p.\n", devpath, (void *) dev_ihandle);
 
   if (grub_ieee1275_finddevice (devpath, &dev))
     {
@@ -116,8 +116,8 @@ grub_ofdisk_open (const char *name, grub
 static void
 grub_ofdisk_close (grub_disk_t disk)
 {
-  grub_dprintf ("disk", "Closing handle 0x%x.\n",
-		(grub_ieee1275_ihandle_t) disk->data);
+  grub_dprintf ("disk", "Closing handle %p.\n",
+		(void *) disk->data);
   grub_ieee1275_close ((grub_ieee1275_ihandle_t) disk->data);
 }
 
@@ -125,13 +125,12 @@ static grub_err_t
 grub_ofdisk_read (grub_disk_t disk, unsigned long sector,
 		  unsigned long size, char *buf)
 {
-  int status;
-  int actual;
+  grub_ssize_t status, actual;
   unsigned long long pos;
 
   grub_dprintf ("disk",
-		"Reading handle 0x%x: sector 0x%lx, size 0x%lx, buf %p.\n",
-		(grub_ieee1275_ihandle_t) disk->data, sector, size, buf);
+		"Reading handle %p: sector 0x%lx, size 0x%lx, buf %p.\n",
+		(void *) disk->data, sector, size, buf);
 
   pos = (unsigned long long) sector * 512UL;
 

Index: include/grub/ieee1275/ieee1275.h
===================================================================
RCS file: /cvsroot/grub/grub2/include/grub/ieee1275/ieee1275.h,v retrieving revision 1.1

grub/ieee1275/ieee1275.h +1 -1
diff -u -p -r1.1 ieee1275.h
@@ -126,7 +126,7 @@ int EXPORT_FUNC(grub_ieee1275_parent) (g
 int EXPORT_FUNC(grub_ieee1275_interpret) (const char *command,
 					  grub_ieee1275_cell_t *catch);
 int EXPORT_FUNC(grub_ieee1275_enter) (void);
-int EXPORT_FUNC(grub_ieee1275_exit) (void) __attribute__ ((noreturn));
+void EXPORT_FUNC(grub_ieee1275_exit) (void) __attribute__ ((noreturn));
 int EXPORT_FUNC(grub_ieee1275_open) (const char *node,
 				     grub_ieee1275_ihandle_t *result);
 int EXPORT_FUNC(grub_ieee1275_close) (grub_ieee1275_ihandle_t ihandle);

Index: kern/mm.c
===================================================================
RCS file: /cvsroot/grub/grub2/kern/mm.c,v
retrieving revision 1.12

mm.c +3 -3
diff -u -p -r1.12 mm.c
@@ -137,7 +137,7 @@ grub_mm_init_region (void *addr, grub_si
   grub_mm_header_t h;
   grub_mm_region_t r, *p, q;
 
-  grub_dprintf ("mem", "Using memory for heap: addr=%p, size=%u\n", addr, size);
+  grub_dprintf ("mem", "Using memory for heap: addr=%p, size=%u\n", addr, (unsigned int) size);
 
   /* If this region is too small, ignore it.  */
   if (size < GRUB_MM_ALIGN * 2)
@@ -408,10 +408,10 @@ grub_mm_dump (unsigned lineno)
 	    {
 	    case GRUB_MM_FREE_MAGIC:
 	      grub_printf ("F:%p:%u:%p\n",
-			   p, p->size << GRUB_MM_ALIGN_LOG2, p->next);
+			   p, (unsigned int) p->size << GRUB_MM_ALIGN_LOG2, p->next);
 	      break;
 	    case GRUB_MM_ALLOC_MAGIC:
-	      grub_printf ("A:%p:%u\n", p, p->size << GRUB_MM_ALIGN_LOG2);
+	      grub_printf ("A:%p:%u\n", p, (unsigned int) p->size << GRUB_MM_ALIGN_LOG2);
 	      break;
 	    }
 	}

Index: kern/ieee1275/ieee1275.c
===================================================================
RCS file: /cvsroot/grub/grub2/kern/ieee1275/ieee1275.c,v retrieving revision 1.1

ieee1275/ieee1275.c +1 -1
diff -u -p -r1.1 ieee1275.c
@@ -393,7 +393,7 @@ grub_ieee1275_enter (void)
   return 0;
 }
 
-int
+void
 grub_ieee1275_exit (void)
 {
   struct exit_args
#4 lore raw
In reply to Vincent Pelletier

Vincent Pelletier <[email protected]> writes:

Hi Vincent,

This is really nice! Thanks a lot. You asked me on IRC if I can test if it still builds on the PPC. I will test that (and let you know on IRC), after that you can commit the patch if you fix the things I mention in my email and Okuji mentioned in his.

Quoted 2 lines

* disk/ieee1275/ofdisk.c (grub_ofdisk_open): use grub_ssize_t instead of int.

Please start sentences with an uppercase letter, same for the other entries.

Some files are not GPL'ed (cache.c, for example). The copyright years are not always correct, like that of ieee1275.h (you wrote it, so it should be (C) 2005 only).

Can't openfw.c be shared? I think it can be...

Thanks,
Marco

#5 lore raw

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Quoted 2 lines · Marco Gerards

Please start sentences with an uppercase letter, same for the other entries.

Oops.

Quoted 3 lines

Some files are not GPL'ed (cache.c, for example). The copyright years are not always correct, like that of ieee1275.h (you wrote it, so it should be (C) 2005 only).

(bis repetita).

Quoted 1 line

Can't openfw.c be shared? I think it can be...

I think too. The worse it that both powerpc and sparc versions are conflicting : both have been modified since I originally extracted the powerpc version. Going to resolve the problems, and I'll patch a common version to be checked in before my port.

Vincent Pelletier
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)

iD8DBQFDB0dHFEQoKRQyjtURAnYFAJ0e23MrnkEiDua5dsDuzcrF4DNKkQCfeMu1 vrwwuyXQ/rB1tOtJSNF2J+A=
=AZqu
-----END PGP SIGNATURE-----

___________________________________________________________________________
Appel audio GRATUIT partout dans le monde avec le nouveau Yahoo! Messenger Téléchargez cette version sur http://fr.messenger.yahoo.com