All of lore.kernel.org
 help / color / mirror / Atom feed
* [Patch] remove bsd asm helper functions
@ 2009-02-11 10:29 phcoder
  2009-02-11 10:39 ` phcoder
  0 siblings, 1 reply; 3+ messages in thread
From: phcoder @ 2009-02-11 10:29 UTC (permalink / raw)
  To: The development of GRUB 2

[-- Attachment #1: Type: text/plain, Size: 439 bytes --]

Hello. Asm helper functions for bsd aren't really needed. Actually BSD 
entry point may be called directly as cdecl function. With this approach 
theese helper functions don't take place in kernel anymore. Tested with 
freebsd, openbsd and netbsd. However my tests were limited to launching 
kernel and see if it complains about not being able to mount root. Can 
someone test it with complete system?
Thanks
Vladimir 'phcoder' Serbinenko

[-- Attachment #2: bsd.patch --]
[-- Type: text/x-diff, Size: 4472 bytes --]

Index: kern/i386/loader.S
===================================================================
--- kern/i386/loader.S	(revision 1989)
+++ kern/i386/loader.S	(working copy)
@@ -117,23 +117,0 @@
-/*
- * Use cdecl calling convention for *BSD kernels.
- */
-
-FUNCTION(grub_unix_real_boot)
-
-        call    EXT_C(grub_dl_unload_all)
-        call    EXT_C(grub_stop_floppy)
-
-	/* Interrupts should be disabled.  */
-        cli
-
-	/* Discard `grub_unix_real_boot' return address.  */
-        popl    %eax
-
-        /* Fetch `entry' address ...  */
-        popl	%eax
-
-        /*
-         * ... and put our return address in its place. The kernel will
-         * ignore it, but it expects %esp to point to it.
-         */
-        call	*%eax
Index: include/grub/i386/loader.h
===================================================================
--- include/grub/i386/loader.h	(revision 1989)
+++ include/grub/i386/loader.h	(working copy)
@@ -22,7 +22,6 @@
 #include <grub/types.h>
 #include <grub/err.h>
 #include <grub/symbol.h>
-#include <grub/multiboot.h>
 
 extern grub_uint32_t EXPORT_VAR(grub_linux_prot_size);
 extern char *EXPORT_VAR(grub_linux_tmp_addr);
@@ -33,22 +32,21 @@
 void EXPORT_FUNC(grub_multiboot2_real_boot) (grub_addr_t entry,
                                              struct grub_multiboot_info *mbi)
      __attribute__ ((noreturn));
-void EXPORT_FUNC(grub_unix_real_boot) (grub_addr_t entry, ...)
-     __attribute__ ((cdecl,noreturn));
 
 extern grub_addr_t EXPORT_VAR(grub_multiboot_payload_orig);
 extern grub_addr_t EXPORT_VAR(grub_multiboot_payload_dest);
 extern grub_size_t EXPORT_VAR(grub_multiboot_payload_size);
 extern grub_uint32_t EXPORT_VAR(grub_multiboot_payload_entry_offset);
 
 /* It is necessary to export these functions, because normal mode commands
    reuse rescue mode commands.  */
 void grub_rescue_cmd_linux (int argc, char *argv[]);
 void grub_rescue_cmd_initrd (int argc, char *argv[]);
 
 extern grub_uint8_t EXPORT_VAR(grub_multiboot_forward_relocator);
 extern grub_uint8_t EXPORT_VAR(grub_multiboot_forward_relocator_end);
 extern grub_uint8_t EXPORT_VAR(grub_multiboot_backward_relocator);
 extern grub_uint8_t EXPORT_VAR(grub_multiboot_backward_relocator_end);
+void EXPORT_FUNC(grub_stop_floppy) (void);
 
 #define RELOCATOR_SIZEOF(x)	(&grub_multiboot_##x##_relocator_end - &grub_multiboot_##x##_relocator)

 #endif /* ! GRUB_LOADER_CPU_HEADER */
Index: loader/i386/bsd.c
===================================================================
--- loader/i386/bsd.c	(revision 1989)
+++ loader/i386/bsd.c	(working copy)
@@ -302,9 +302,17 @@
 
   bi.bi_kernend = kern_end;
 
-  grub_unix_real_boot (entry, bootflags | FREEBSD_RB_BOOTINFO, bootdev,
-		       0, 0, 0, &bi, bi.bi_modulep, kern_end);
+  grub_stop_floppy ();
 
+  asm volatile ("cli");
+
+  ((void (* __attribute__ ((cdecl,regparm (0))))  
+    (grub_uint32_t, grub_uint32_t, grub_uint32_t, grub_uint32_t, 
+     grub_uint32_t, struct grub_freebsd_bootinfo *,
+     grub_addr_t, grub_addr_t))entry)
+    (bootflags | FREEBSD_RB_BOOTINFO, bootdev,
+     0, 0, 0, &bi, bi.bi_modulep, kern_end);
+  
   /* Not reached.  */
   return GRUB_ERR_NONE;
 }
@@ -348,10 +356,18 @@
   bootdev = (OPENBSD_B_DEVMAGIC + (unit << OPENBSD_B_UNITSHIFT) +
 	     (part << OPENBSD_B_PARTSHIFT));
 
-  grub_unix_real_boot (entry, bootflags, bootdev, OPENBSD_BOOTARG_APIVER,
-		       0, grub_upper_mem >> 10, grub_lower_mem >> 10,
-		       (char *) pa - buf, buf);
+  grub_stop_floppy ();
 
+  asm volatile ("cli");
+
+  ((void (* __attribute__ ((cdecl,regparm (0))))  
+    (grub_uint32_t, grub_uint32_t, grub_uint32_t, grub_uint32_t, 
+     grub_uint32_t, grub_uint32_t,
+     grub_uint32_t, char *)) entry) 
+    (bootflags, bootdev, OPENBSD_BOOTARG_APIVER,
+     0, grub_upper_mem >> 10, grub_lower_mem >> 10,
+     (char *) pa - buf, buf);
+
   /* Not reached.  */
   return GRUB_ERR_NONE;
 }
@@ -376,9 +392,16 @@
   bootinfo->bi_count = 1;
   bootinfo->bi_data[0] = rootdev;
 
-  grub_unix_real_boot (entry, bootflags, 0, bootinfo,
-		       0, grub_upper_mem >> 10, grub_lower_mem >> 10);
+  grub_stop_floppy ();
 
+  asm volatile ("cli");
+
+  ((void (* __attribute__ ((cdecl,regparm (0))))  
+    (grub_uint32_t, grub_uint32_t, struct grub_netbsd_bootinfo *, 
+     grub_uint32_t, grub_uint32_t, grub_uint32_t)) entry) 
+    (bootflags, 0, bootinfo,
+     0, grub_upper_mem >> 10, grub_lower_mem >> 10);
+
   /* Not reached.  */
   return GRUB_ERR_NONE;
 }

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Patch] remove bsd asm helper functions
  2009-02-11 10:29 [Patch] remove bsd asm helper functions phcoder
@ 2009-02-11 10:39 ` phcoder
  2009-03-12 12:00   ` phcoder
  0 siblings, 1 reply; 3+ messages in thread
From: phcoder @ 2009-02-11 10:39 UTC (permalink / raw)
  To: The development of GRUB 2

Sorry, forgot changelog entry. Here it is:
2009-02-11  Vladimir Serbinenko  <phcoder@gmail.com>

	Move BSD helper out of kernel

	* conf/i386-pc.rmk: Add loader/i386/bsd_helper.S to _bsd.mod
	* kern/i386/loader.S: Removed BSD helpers
	* include/grub/i386/loader.h: Removed declaration of
	grub_unix_real_boot
	* loader/i386/bsd.c (grub_freebsd_boot): Replaced call to
	grub_unix_real_boot by direct call of kernel
	(grub_netbsd_boot): Likewise
	(grub_openbsd_boot): Likewise

phcoder wrote:
> Hello. Asm helper functions for bsd aren't really needed. Actually BSD 
> entry point may be called directly as cdecl function. With this approach 
> theese helper functions don't take place in kernel anymore. Tested with 
> freebsd, openbsd and netbsd. However my tests were limited to launching 
> kernel and see if it complains about not being able to mount root. Can 
> someone test it with complete system?
> Thanks
> Vladimir 'phcoder' Serbinenko
> 




^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Patch] remove bsd asm helper functions
  2009-02-11 10:39 ` phcoder
@ 2009-03-12 12:00   ` phcoder
  0 siblings, 0 replies; 3+ messages in thread
From: phcoder @ 2009-03-12 12:00 UTC (permalink / raw)
  To: The development of GRUB 2

Hello. Now I noticed that the helper are still necessary when booting 
i386 kernel on efi-x86_64. I would like this code to be uniform accross 
i386 branches so please don't commit this patch it will be soon 
superseed by my next work
phcoder wrote:
> Sorry, forgot changelog entry. Here it is:
> 2009-02-11  Vladimir Serbinenko  <phcoder@gmail.com>
> 
>     Move BSD helper out of kernel
> 
>     * conf/i386-pc.rmk: Add loader/i386/bsd_helper.S to _bsd.mod
>     * kern/i386/loader.S: Removed BSD helpers
>     * include/grub/i386/loader.h: Removed declaration of
>     grub_unix_real_boot
>     * loader/i386/bsd.c (grub_freebsd_boot): Replaced call to
>     grub_unix_real_boot by direct call of kernel
>     (grub_netbsd_boot): Likewise
>     (grub_openbsd_boot): Likewise
> 
> phcoder wrote:
>> Hello. Asm helper functions for bsd aren't really needed. Actually BSD 
>> entry point may be called directly as cdecl function. With this 
>> approach theese helper functions don't take place in kernel anymore. 
>> Tested with freebsd, openbsd and netbsd. However my tests were limited 
>> to launching kernel and see if it complains about not being able to 
>> mount root. Can someone test it with complete system?
>> Thanks
>> Vladimir 'phcoder' Serbinenko
>>
> 


-- 

Regards
Vladimir 'phcoder' Serbinenko



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2009-03-12 12:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-02-11 10:29 [Patch] remove bsd asm helper functions phcoder
2009-02-11 10:39 ` phcoder
2009-03-12 12:00   ` phcoder

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.