grub-devel.gnu.org archive mirror
 help / color / mirror / Atom feed
* [RFT] Rewrite timer on arm efi and remove leftover in startup code
@ 2013-10-03 22:46 Vladimir 'φ-coder/phcoder' Serbinenko
  2013-10-07 11:30 ` Leif Lindholm
  0 siblings, 1 reply; 4+ messages in thread
From: Vladimir 'φ-coder/phcoder' Serbinenko @ 2013-10-03 22:46 UTC (permalink / raw)
  To: The development of GRUB 2


[-- Attachment #1.1: Type: text/plain, Size: 65 bytes --]

Current timer code for ARM EFI is horror. Can anyone test this?

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.2: arm_efi.diff --]
[-- Type: text/x-diff; name="arm_efi.diff", Size: 2341 bytes --]

=== modified file 'grub-core/kern/arm/efi/init.c'
--- grub-core/kern/arm/efi/init.c	2013-04-07 00:41:07 +0000
+++ grub-core/kern/arm/efi/init.c	2013-10-03 22:19:23 +0000
@@ -24,45 +24,47 @@
 #include <grub/time.h>
 #include <grub/efi/efi.h>
 
-/*
- * A bit ugly, but functional - and should be completely portable.
- */
+static grub_uint64_t tmr;
+static grub_efi_event_t tmr_evt;
+
 static grub_uint64_t
-grub_efi_get_time_ms(void)
-{
-  grub_efi_time_t now;
-  grub_uint64_t retval;
-  grub_efi_status_t status;
-
-  status = efi_call_2 (grub_efi_system_table->runtime_services->get_time,
-		       &now, NULL);
-  if (status != GRUB_EFI_SUCCESS)
-    {
-      grub_printf("No time!\n");
-      return 0;
-    }
-  retval = now.year * 365 * 24 * 60 * 60 * 1000;
-  retval += now.month * 30 * 24 * 60 * 60 * 1000;
-  retval += now.day * 24 * 60 * 60 * 1000;
-  retval += now.hour * 60 * 60 * 1000;
-  retval += now.minute * 60 * 1000;
-  retval += now.second * 1000;
-  retval += now.nanosecond / 1000;
- 
-  grub_dprintf("timer", "timestamp: 0x%llx\n", retval);
-
-  return retval;
+grub_efi_get_time_ms (void)
+{
+  return tmr;
+}
+
+static void 
+increment_timer (grub_efi_event_t event __attribute__ ((unused)),
+		 void *context __attribute__ ((unused)))
+{
+  tmr++;
 }
 
 void
 grub_machine_init (void)
 {
+  grub_efi_boot_services_t *b;
+
   grub_efi_init ();
+
+  b = grub_efi_system_table->boot_services;
+
+  efi_call_5 (b->create_event, GRUB_EFI_EVT_TIMER | GRUB_EFI_EVT_NOTIFY_SIGNAL,
+	      GRUB_EFI_TPL_CALLBACK, increment_timer, NULL, &tmr_evt);
+  efi_call_3 (b->set_timer, tmr_evt, GRUB_EFI_TIMER_PERIODIC, 10000);
+
   grub_install_get_time_ms (grub_efi_get_time_ms);
 }
 
 void
 grub_machine_fini (void)
 {
+  grub_efi_boot_services_t *b;
+
+  b = grub_efi_system_table->boot_services;
+
+  efi_call_3 (b->set_timer, tmr_evt, GRUB_EFI_TIMER_PERIODIC, 0);
+  efi_call_1 (b->close_event, tmr_evt);
+
   grub_efi_fini ();
 }

=== modified file 'grub-core/kern/arm/efi/startup.S'
--- grub-core/kern/arm/efi/startup.S	2013-04-07 00:41:07 +0000
+++ grub-core/kern/arm/efi/startup.S	2013-10-03 22:20:58 +0000
@@ -33,6 +33,4 @@
 	str	r1, [ip]
 	ldr	ip, =EXT_C(grub_main)
 	bx	ip
-	.thumb		@ For relocation debugging
-	blx	_start
 	.end


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 291 bytes --]

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

* Re: [RFT] Rewrite timer on arm efi and remove leftover in startup code
  2013-10-03 22:46 [RFT] Rewrite timer on arm efi and remove leftover in startup code Vladimir 'φ-coder/phcoder' Serbinenko
@ 2013-10-07 11:30 ` Leif Lindholm
  2013-10-07 16:31   ` Vladimir 'φ-coder/phcoder' Serbinenko
  2013-10-28 11:00   ` Francesco Lavra
  0 siblings, 2 replies; 4+ messages in thread
From: Leif Lindholm @ 2013-10-07 11:30 UTC (permalink / raw)
  To: The development of GNU GRUB

On Fri, Oct 04, 2013 at 12:46:53AM +0200, Vladimir 'φ-coder/phcoder' Serbinenko wrote:
> Current timer code for ARM EFI is horror. Can anyone test this?

I can verify that this works on my Versatile Express TC2 platform,
with no noticeable performance degradation (and it does increment).

However, could this be moved to kern/efi/init.c?
I will need the same function for the 64-bit ARM port (which I
intend to post a first version of later this week).

Hmm - trunk does not however seem to be able to successfully boot a
Linux kernel on ARM/UEFI currently. I will look into that.

/
    Leif


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

* Re: [RFT] Rewrite timer on arm efi and remove leftover in startup code
  2013-10-07 11:30 ` Leif Lindholm
@ 2013-10-07 16:31   ` Vladimir 'φ-coder/phcoder' Serbinenko
  2013-10-28 11:00   ` Francesco Lavra
  1 sibling, 0 replies; 4+ messages in thread
From: Vladimir 'φ-coder/phcoder' Serbinenko @ 2013-10-07 16:31 UTC (permalink / raw)
  To: The development of GNU GRUB

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

On 07.10.2013 13:30, Leif Lindholm wrote:
> On Fri, Oct 04, 2013 at 12:46:53AM +0200, Vladimir 'φ-coder/phcoder' Serbinenko wrote:
>> Current timer code for ARM EFI is horror. Can anyone test this?
> 
> I can verify that this works on my Versatile Express TC2 platform,
> with no noticeable performance degradation (and it does increment).
> 
> However, could this be moved to kern/efi/init.c?
> I will need the same function for the 64-bit ARM port (which I
> intend to post a first version of later this week).
Moving it to kern/efi/init.c would be counterproductive as only arm uses
it. On the other hand it's fine to include 32-bit ARM files in 64-bit
port. We do the same between x86_64-efi and i386-efi.
E.g.
  x86_64_efi = kern/i386/efi/init.c;

> 
> Hmm - trunk does not however seem to be able to successfully boot a
> Linux kernel on ARM/UEFI currently. I will look into that.
> 
> /
>     Leif
> 
> _______________________________________________
> Grub-devel mailing list
> Grub-devel@gnu.org
> https://lists.gnu.org/mailman/listinfo/grub-devel
> 



[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 291 bytes --]

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

* Re: [RFT] Rewrite timer on arm efi and remove leftover in startup code
  2013-10-07 11:30 ` Leif Lindholm
  2013-10-07 16:31   ` Vladimir 'φ-coder/phcoder' Serbinenko
@ 2013-10-28 11:00   ` Francesco Lavra
  1 sibling, 0 replies; 4+ messages in thread
From: Francesco Lavra @ 2013-10-28 11:00 UTC (permalink / raw)
  To: The development of GNU GRUB

Hi,

On 10/07/2013 01:30 PM, Leif Lindholm wrote:
> Hmm - trunk does not however seem to be able to successfully boot a
> Linux kernel on ARM/UEFI currently. I will look into that.

You may have run into the same issues I run into when I try booting a
Linux kernel with device tree. See my patch at
http://lists.gnu.org/archive/html/grub-devel/2013-10/msg00209.html, it
may help.

--
Francesco


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

end of thread, other threads:[~2013-10-28 11:00 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-10-03 22:46 [RFT] Rewrite timer on arm efi and remove leftover in startup code Vladimir 'φ-coder/phcoder' Serbinenko
2013-10-07 11:30 ` Leif Lindholm
2013-10-07 16:31   ` Vladimir 'φ-coder/phcoder' Serbinenko
2013-10-28 11:00   ` Francesco Lavra

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).