From: phcoder <phcoder@gmail.com>
To: The development of GRUB 2 <grub-devel@gnu.org>
Subject: [Patch] remove bsd asm helper functions
Date: Wed, 11 Feb 2009 11:29:24 +0100 [thread overview]
Message-ID: <4992A884.4050406@gmail.com> (raw)
[-- 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;
}
next reply other threads:[~2009-02-11 10:29 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-02-11 10:29 phcoder [this message]
2009-02-11 10:39 ` [Patch] remove bsd asm helper functions phcoder
2009-03-12 12:00 ` phcoder
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4992A884.4050406@gmail.com \
--to=phcoder@gmail.com \
--cc=grub-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.