diff mbox series

[1/4] i386/x86_64: make linux header definitions arch-specific

Message ID 20170905204114.9462-2-leif.lindholm@linaro.org
State New
Headers show
Series x86,efi: prerequisites for ARM* cleanup series | expand

Commit Message

Leif Lindholm Sept. 5, 2017, 8:41 p.m. UTC
Rename GRUB_LINUX_MAGIC_SIGNATURE -> GRUB_LINUX_I386_MAGIC_SIGNATURE
and linux_kernel_header -> linux_i386_kernel_header.

Also change the include guard on grub/i386/linux.h to prevent clashes
when including multiple linux.h headers (like in commands/file.c).

Signed-off-by: Leif Lindholm <leif.lindholm@linaro.org>

---

OK, so one question here: in order to follow existing style, I have kept
to the existing linux_ format. Is that the appropriate prefix, or should
this be grub_linux_ like I originally used in the ARM series?
Regardless, I intend to align the ARM patches to whatever format ends up
being used for this patch.

 grub-core/commands/file.c        |  6 +++---
 grub-core/loader/i386/linux.c    |  4 ++--
 grub-core/loader/i386/pc/linux.c | 12 ++++++------
 grub-core/loader/i386/xen_file.c |  4 ++--
 include/grub/i386/linux.h        | 10 +++++-----
 5 files changed, 18 insertions(+), 18 deletions(-)

-- 
2.11.0


_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel

Comments

Daniel Kiper Sept. 13, 2017, 3:45 a.m. UTC | #1
Hi Leif,

Sorry for late reply but I am traveling. I should be
more responsive starting from next week.

On Tue, Sep 05, 2017 at 09:41:11PM +0100, Leif Lindholm wrote:
> Rename GRUB_LINUX_MAGIC_SIGNATURE -> GRUB_LINUX_I386_MAGIC_SIGNATURE

> and linux_kernel_header -> linux_i386_kernel_header.


I think that this begs for 2 separate patches.

> Also change the include guard on grub/i386/linux.h to prevent clashes

> when including multiple linux.h headers (like in commands/file.c).


Third patch.

> Signed-off-by: Leif Lindholm <leif.lindholm@linaro.org>

> ---

>

> OK, so one question here: in order to follow existing style, I have kept

> to the existing linux_ format. Is that the appropriate prefix, or should

> this be grub_linux_ like I originally used in the ARM series?


I prefer linux_.

> Regardless, I intend to align the ARM patches to whatever format ends up

> being used for this patch.


Please do.

Daniel

_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel
Leif Lindholm Sept. 13, 2017, 8:43 a.m. UTC | #2
On Wed, Sep 13, 2017 at 05:45:58AM +0200, Daniel Kiper wrote:
> Hi Leif,

> 

> Sorry for late reply but I am traveling. I should be

> more responsive starting from next week.

> 

> On Tue, Sep 05, 2017 at 09:41:11PM +0100, Leif Lindholm wrote:

> > Rename GRUB_LINUX_MAGIC_SIGNATURE -> GRUB_LINUX_I386_MAGIC_SIGNATURE

> > and linux_kernel_header -> linux_i386_kernel_header.

> 

> I think that this begs for 2 separate patches.


Sure.

> > Also change the include guard on grub/i386/linux.h to prevent clashes

> > when including multiple linux.h headers (like in commands/file.c).

> 

> Third patch.


Sure.

> > Signed-off-by: Leif Lindholm <leif.lindholm@linaro.org>

> > ---

> >

> > OK, so one question here: in order to follow existing style, I have kept

> > to the existing linux_ format. Is that the appropriate prefix, or should

> > this be grub_linux_ like I originally used in the ARM series?

> 

> I prefer linux_.


Sure.

> > Regardless, I intend to align the ARM patches to whatever format ends up

> > being used for this patch.

> 

> Please do.

> 

> Daniel


_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel
diff mbox series

Patch

diff --git a/grub-core/commands/file.c b/grub-core/commands/file.c
index 12fba99e0..63c84499b 100644
--- a/grub-core/commands/file.c
+++ b/grub-core/commands/file.c
@@ -497,7 +497,7 @@  grub_cmd_file (grub_extcmd_context_t ctxt, int argc, char **args)
     case IS_X86_LINUX32:
     case IS_X86_LINUX:
       {
-	struct linux_kernel_header lh;
+	struct linux_i386_kernel_header lh;
 	if (grub_file_read (file, &lh, sizeof (lh)) != sizeof (lh))
 	  break;
 	if (lh.boot_flag != grub_cpu_to_le16_compile_time (0xaa55))
@@ -508,7 +508,7 @@  grub_cmd_file (grub_extcmd_context_t ctxt, int argc, char **args)
 
 	/* FIXME: some really old kernels (< 1.3.73) will fail this.  */
 	if (lh.header !=
-	    grub_cpu_to_le32_compile_time (GRUB_LINUX_MAGIC_SIGNATURE)
+	    grub_cpu_to_le32_compile_time (GRUB_LINUX_I386_MAGIC_SIGNATURE)
 	    || grub_le_to_cpu16 (lh.version) < 0x0200)
 	  break;
 
@@ -521,7 +521,7 @@  grub_cmd_file (grub_extcmd_context_t ctxt, int argc, char **args)
 	/* FIXME: 2.03 is not always good enough (Linux 2.4 can be 2.03 and
 	   still not support 32-bit boot.  */
 	if (lh.header !=
-	    grub_cpu_to_le32_compile_time (GRUB_LINUX_MAGIC_SIGNATURE)
+	    grub_cpu_to_le32_compile_time (GRUB_LINUX_I386_MAGIC_SIGNATURE)
 	    || grub_le_to_cpu16 (lh.version) < 0x0203)
 	  break;
 
diff --git a/grub-core/loader/i386/linux.c b/grub-core/loader/i386/linux.c
index 083f9417c..44301e126 100644
--- a/grub-core/loader/i386/linux.c
+++ b/grub-core/loader/i386/linux.c
@@ -678,7 +678,7 @@  grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
 		int argc, char *argv[])
 {
   grub_file_t file = 0;
-  struct linux_kernel_header lh;
+  struct linux_i386_kernel_header lh;
   grub_uint8_t setup_sects;
   grub_size_t real_size, prot_size, prot_file_size;
   grub_ssize_t len;
@@ -721,7 +721,7 @@  grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
 
   /* FIXME: 2.03 is not always good enough (Linux 2.4 can be 2.03 and
      still not support 32-bit boot.  */
-  if (lh.header != grub_cpu_to_le32_compile_time (GRUB_LINUX_MAGIC_SIGNATURE)
+  if (lh.header != grub_cpu_to_le32_compile_time (GRUB_LINUX_I386_MAGIC_SIGNATURE)
       || grub_le_to_cpu16 (lh.version) < 0x0203)
     {
       grub_error (GRUB_ERR_BAD_OS, "version too old for 32-bit boot"
diff --git a/grub-core/loader/i386/pc/linux.c b/grub-core/loader/i386/pc/linux.c
index a293b17aa..b69cb7a3a 100644
--- a/grub-core/loader/i386/pc/linux.c
+++ b/grub-core/loader/i386/pc/linux.c
@@ -121,7 +121,7 @@  grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
 		int argc, char *argv[])
 {
   grub_file_t file = 0;
-  struct linux_kernel_header lh;
+  struct linux_i386_kernel_header lh;
   grub_uint8_t setup_sects;
   grub_size_t real_size;
   grub_ssize_t len;
@@ -169,7 +169,7 @@  grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
 
   maximal_cmdline_size = 256;
 
-  if (lh.header == grub_cpu_to_le32_compile_time (GRUB_LINUX_MAGIC_SIGNATURE)
+  if (lh.header == grub_cpu_to_le32_compile_time (GRUB_LINUX_I386_MAGIC_SIGNATURE)
       && grub_le_to_cpu16 (lh.version) >= 0x0200)
     {
       grub_linux_is_bzimage = (lh.loadflags & GRUB_LINUX_FLAG_BIG_KERNEL);
@@ -322,7 +322,7 @@  grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
       goto fail;
     }
 
-  if (lh.header != grub_cpu_to_le32_compile_time (GRUB_LINUX_MAGIC_SIGNATURE)
+  if (lh.header != grub_cpu_to_le32_compile_time (GRUB_LINUX_I386_MAGIC_SIGNATURE)
       || grub_le_to_cpu16 (lh.version) < 0x0200)
     /* Clear the heap space.  */
     grub_memset (grub_linux_real_chunk
@@ -387,7 +387,7 @@  grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)),
 {
   grub_size_t size = 0;
   grub_addr_t addr_max, addr_min;
-  struct linux_kernel_header *lh;
+  struct linux_i386_kernel_header *lh;
   grub_uint8_t *initrd_chunk;
   grub_addr_t initrd_addr;
   grub_err_t err;
@@ -405,9 +405,9 @@  grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)),
       goto fail;
     }
 
-  lh = (struct linux_kernel_header *) grub_linux_real_chunk;
+  lh = (struct linux_i386_kernel_header *) grub_linux_real_chunk;
 
-  if (!(lh->header == grub_cpu_to_le32_compile_time (GRUB_LINUX_MAGIC_SIGNATURE)
+  if (!(lh->header == grub_cpu_to_le32_compile_time (GRUB_LINUX_I386_MAGIC_SIGNATURE)
 	&& grub_le_to_cpu16 (lh->version) >= 0x0200))
     {
       grub_error (GRUB_ERR_BAD_OS, "the kernel is too old for initrd");
diff --git a/grub-core/loader/i386/xen_file.c b/grub-core/loader/i386/xen_file.c
index 99fad4cad..77a93e7b2 100644
--- a/grub-core/loader/i386/xen_file.c
+++ b/grub-core/loader/i386/xen_file.c
@@ -26,7 +26,7 @@  grub_elf_t
 grub_xen_file (grub_file_t file)
 {
   grub_elf_t elf;
-  struct linux_kernel_header lh;
+  struct linux_i386_kernel_header lh;
   grub_file_t off_file;
   grub_uint32_t payload_offset, payload_length;
   grub_uint8_t magic[6];
@@ -43,7 +43,7 @@  grub_xen_file (grub_file_t file)
     goto fail;
 
   if (lh.boot_flag != grub_cpu_to_le16_compile_time (0xaa55)
-      || lh.header != grub_cpu_to_le32_compile_time (GRUB_LINUX_MAGIC_SIGNATURE)
+      || lh.header != grub_cpu_to_le32_compile_time (GRUB_LINUX_I386_MAGIC_SIGNATURE)
       || grub_le_to_cpu16 (lh.version) < 0x0208)
     {
       grub_error (GRUB_ERR_BAD_OS, "version too old for xen boot");
diff --git a/include/grub/i386/linux.h b/include/grub/i386/linux.h
index da0ca3b83..854e3e687 100644
--- a/include/grub/i386/linux.h
+++ b/include/grub/i386/linux.h
@@ -16,10 +16,10 @@ 
  *  along with GRUB.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-#ifndef GRUB_LINUX_MACHINE_HEADER
-#define GRUB_LINUX_MACHINE_HEADER	1
+#ifndef GRUB_LINUX_I386_HEADER
+#define GRUB_LINUX_I386_HEADER	1
 
-#define GRUB_LINUX_MAGIC_SIGNATURE	0x53726448      /* "HdrS" */
+#define GRUB_LINUX_I386_MAGIC_SIGNATURE	0x53726448      /* "HdrS" */
 #define GRUB_LINUX_DEFAULT_SETUP_SECTS	4
 #define GRUB_LINUX_INITRD_MAX_ADDRESS	0x37FFFFFF
 #define GRUB_LINUX_MAX_SETUP_SECTS	64
@@ -85,7 +85,7 @@  enum
   };
 
 /* For the Linux/i386 boot protocol version 2.10.  */
-struct linux_kernel_header
+struct linux_i386_kernel_header
 {
   grub_uint8_t code1[0x0020];
   grub_uint16_t cl_magic;		/* Magic number 0xA33F */
@@ -312,4 +312,4 @@  struct linux_kernel_params
 } GRUB_PACKED;
 #endif /* ! ASM_FILE */
 
-#endif /* ! GRUB_LINUX_MACHINE_HEADER */
+#endif /* ! GRUB_LINUX_I386_HEADER */