Skip to contentSkip to conversation

turn grub-emu into a port

PATCH In review Robert Millan 2 participants 7 messages Oct 26, 2009 – Nov 9, 2009 Kbuild

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 turn grub-emu into a port

This turns grub-emu into a port in order to make it easier to port GRUB to new CPUs. A porter can then do the CPU port without having to worry about firmware and/or hardware drivers initially.

Patch attached. Branch is available in bzr+ssh://bzr.savannah.gnu.org/grub/people/robertmh/grub-emu/

Signature · 5 lines
Robert Millan

  The DRM opt-in fallacy: "Your data belongs to us. We will decide when (and
  how) you may access your data; but nobody's threatening your freedom: we
  still allow you to remove your data and not access it at all."

=== modified file 'Makefile.in'

Makefile.in +5 -4
@@ -104,7 +104,6 @@
 UNIFONT_BDF = @UNIFONT_BDF@
 
 # Options.
-enable_grub_emu = @enable_grub_emu@
 enable_grub_emu_usb = @enable_grub_emu_usb@
 enable_grub_fstest = @enable_grub_fstest@
 enable_grub_pe2elf = @enable_grub_pe2elf@
@@ -115,9 +114,7 @@
 
 ### General variables.
 
-RMKFILES = $(addprefix conf/,common.rmk i386-coreboot.rmk i386-efi.rmk \
-	i386-qemu.rmk i386-ieee1275.rmk i386-pc.rmk i386.rmk powerpc-ieee1275.rmk \
-	sparc64-ieee1275.rmk x86_64-efi.rmk)
+RMKFILES = $(wildcard conf/*.rmk)
 
 MKFILES = $(patsubst %.rmk,%.mk,$(RMKFILES))
 
@@ -148,7 +145,11 @@
 	  $(RUBY) $(srcdir)/genmk.rb < $< > $@; \
 	fi
 
+ifeq ($(platform), emu)
+include $(srcdir)/conf/any-emu.mk
+else
 include $(srcdir)/conf/$(target_cpu)-$(platform).mk
+endif
 
 ### General targets.
 

=== modified file 'commands/acpi.c'

acpi.c +0 -1
@@ -26,7 +26,6 @@
 #include <grub/gzio.h>
 #include <grub/acpi.h>
 #include <grub/mm.h>
-#include <grub/machine/machine.h>
 #include <grub/machine/memory.h>
 #include <grub/memory.h>
 

=== modified file 'commands/halt.c'

halt.c +0 -1
@@ -18,7 +18,6 @@
  */
 
 #include <grub/dl.h>
-#include <grub/machine/machine.h>
 #include <grub/command.h>
 
 #if defined(GRUB_MACHINE_IEEE1275)

=== modified file 'commands/reboot.c'

reboot.c +0 -1
@@ -18,7 +18,6 @@
  */
 
 #include <grub/dl.h>
-#include <grub/machine/machine.h>
 #include <grub/command.h>
 
 #if defined(GRUB_MACHINE_IEEE1275)

=== added file 'conf/any-emu.rmk'

any-emu.rmk +87 -0

87 lines not on this page · raw message

=== modified file 'conf/common.rmk'

common.rmk +0 -13
@@ -64,19 +64,6 @@
 	$(YACC) -d -p grub_script_yy -b grub_script $(srcdir)/script/sh/parser.y
 DISTCLEANFILES += grub_script.tab.c grub_script.tab.h
 
-# For grub-emu.
-grub_emu_init.lst: geninit.sh $(filter-out grub_emu_init.c,$(grub_emu_SOURCES))
-	rm -f $@; grep GRUB_MOD_INIT $(filter %.c,$^) /dev/null > $@
-DISTCLEANFILES += grub_emu_init.lst
-
-grub_emu_init.h: grub_emu_init.lst $(filter-out grub_emu_init.c,$(grub_emu_SOURCES)) geninitheader.sh
-	rm -f $@; sh $(srcdir)/geninitheader.sh $< > $@
-DISTCLEANFILES += grub_emu_init.h
-
-grub_emu_init.c: grub_emu_init.lst $(filter-out grub_emu_init.c,$(grub_emu_SOURCES)) geninit.sh grub_emu_init.h
-	rm -f $@; sh $(srcdir)/geninit.sh $< $(filter %.c,$^) > $@
-DISTCLEANFILES += grub_emu_init.c
-
 # For grub-probe.
 grub_probe_init.lst: geninit.sh $(filter-out grub_probe_init.c,$(grub_probe_SOURCES))
 	rm -f $@; grep GRUB_MOD_INIT $(filter %.c,$^) /dev/null > $@

=== modified file 'conf/i386-coreboot.rmk'

i386-coreboot.rmk +0 -49

60 lines not on this page · raw message

=== modified file 'conf/i386-efi.rmk'

i386-efi.rmk +0 -48

60 lines not on this page · raw message

=== modified file 'conf/i386-ieee1275.rmk'

i386-ieee1275.rmk +0 -48

59 lines not on this page · raw message

=== modified file 'conf/i386-pc.rmk'

i386-pc.rmk +0 -56

68 lines not on this page · raw message

=== modified file 'conf/powerpc-ieee1275.rmk'

powerpc-ieee1275.rmk +0 -49

60 lines not on this page · raw message

=== modified file 'conf/sparc64-ieee1275.rmk'

sparc64-ieee1275.rmk +0 -49

61 lines not on this page · raw message

=== modified file 'conf/x86_64-efi.rmk'

x86_64-efi.rmk +0 -47

59 lines not on this page · raw message

=== modified file 'configure.ac'

configure.ac +30 -32

121 lines not on this page · raw message

=== modified file 'include/grub/autoefi.h'

grub/autoefi.h +0 -1
@@ -21,7 +21,6 @@
 #ifndef GRUB_AUTOEFI_HEADER
 #define GRUB_AUTOEFI_HEADER	1
 
-#include <grub/machine/machine.h>
 
 #ifdef GRUB_MACHINE_EFI
 # include <grub/efi/efi.h>

=== modified file 'include/grub/i386/at_keyboard.h'

grub/i386/at_keyboard.h +0 -1
@@ -19,7 +19,6 @@
 #ifndef GRUB_CPU_AT_KEYBOARD_HEADER
 #define GRUB_CPU_AT_KEYBOARD_HEADER	1
 
-#include <grub/machine/machine.h>
 
 #define SHIFT_L		0x2a
 #define SHIFT_R		0x36

=== removed file 'include/grub/i386/coreboot/machine.h'

grub/i386/coreboot/machine.h +0 -24
@@ -1,24 +0,0 @@
-/*
- *  GRUB  --  GRand Unified Bootloader
- *  Copyright (C) 2007  Free Software Foundation, Inc.
- *
- *  GRUB is free software: you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation, either version 3 of the License, or
- *  (at your option) any later version.
- *
- *  GRUB is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with GRUB.  If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef GRUB_MACHINE_MACHINE_HEADER
-#define GRUB_MACHINE_MACHINE_HEADER	1
-
-#define GRUB_MACHINE_COREBOOT	1
-
-#endif /* ! GRUB_MACHINE_MACHINE_HEADER */

=== removed file 'include/grub/i386/efi/machine.h'

grub/i386/efi/machine.h +0 -24
@@ -1,24 +0,0 @@
-/*
- *  GRUB  --  GRand Unified Bootloader
- *  Copyright (C) 2007  Free Software Foundation, Inc.
- *
- *  GRUB is free software: you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation, either version 3 of the License, or
- *  (at your option) any later version.
- *
- *  GRUB is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with GRUB.  If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef GRUB_MACHINE_MACHINE_HEADER
-#define GRUB_MACHINE_MACHINE_HEADER	1
-
-#define GRUB_MACHINE_EFI	1
-
-#endif /* ! GRUB_MACHINE_MACHINE_HEADER */

=== removed file 'include/grub/i386/ieee1275/machine.h'

grub/i386/ieee1275/machine.h +0 -24
@@ -1,24 +0,0 @@
-/*
- *  GRUB  --  GRand Unified Bootloader
- *  Copyright (C) 2008  Free Software Foundation, Inc.
- *
- *  GRUB is free software: you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation, either version 3 of the License, or
- *  (at your option) any later version.
- *
- *  GRUB is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with GRUB.  If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef GRUB_MACHINE_MACHINE_HEADER
-#define GRUB_MACHINE_MACHINE_HEADER	1
-
-#define GRUB_MACHINE_IEEE1275	1
-
-#endif /* ! GRUB_MACHINE_MACHINE_HEADER */

=== modified file 'include/grub/i386/kernel.h'

grub/i386/kernel.h +0 -1
@@ -19,7 +19,6 @@
 #ifndef GRUB_KERNEL_CPU_HEADER
 #define GRUB_KERNEL_CPU_HEADER	1
 
-#include <grub/machine/machine.h>
 
 #ifdef GRUB_MACHINE_IEEE1275
 #define GRUB_MOD_ALIGN	0x1000

=== modified file 'include/grub/i386/loader.h'

grub/i386/loader.h +0 -1
@@ -22,7 +22,6 @@
 #include <grub/types.h>
 #include <grub/err.h>
 #include <grub/symbol.h>
-#include <grub/machine/machine.h>
 
 extern grub_addr_t EXPORT_VAR(grub_os_area_addr);
 extern grub_size_t EXPORT_VAR(grub_os_area_size);

=== removed file 'include/grub/i386/pc/machine.h'

grub/i386/pc/machine.h +0 -24
@@ -1,24 +0,0 @@
-/*
- *  GRUB  --  GRand Unified Bootloader
- *  Copyright (C) 2007  Free Software Foundation, Inc.
- *
- *  GRUB is free software: you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation, either version 3 of the License, or
- *  (at your option) any later version.
- *
- *  GRUB is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with GRUB.  If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef GRUB_MACHINE_MACHINE_HEADER
-#define GRUB_MACHINE_MACHINE_HEADER	1
-
-#define GRUB_MACHINE_PCBIOS	1
-
-#endif /* ! GRUB_MACHINE_MACHINE_HEADER */

=== modified file 'include/grub/i386/pc/memory.h'

grub/i386/pc/memory.h +0 -1
@@ -21,7 +21,6 @@
 #define GRUB_MEMORY_MACHINE_HEADER	1
 
 #include <grub/symbol.h>
-#include <grub/machine/machine.h>
 #ifndef ASM_FILE
 #include <grub/types.h>
 #include <grub/err.h>

=== removed file 'include/grub/i386/qemu/machine.h'

grub/i386/qemu/machine.h +0 -24
@@ -1,24 +0,0 @@
-/*
- *  GRUB  --  GRand Unified Bootloader
- *  Copyright (C) 2009  Free Software Foundation, Inc.
- *
- *  GRUB is free software: you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation, either version 3 of the License, or
- *  (at your option) any later version.
- *
- *  GRUB is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with GRUB.  If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef GRUB_MACHINE_MACHINE_HEADER
-#define GRUB_MACHINE_MACHINE_HEADER	1
-
-#define GRUB_MACHINE_QEMU	1
-
-#endif /* ! GRUB_MACHINE_MACHINE_HEADER */

=== removed file 'include/grub/powerpc/ieee1275/machine.h'

grub/powerpc/ieee1275/machine.h +0 -24
@@ -1,24 +0,0 @@
-/*
- *  GRUB  --  GRand Unified Bootloader
- *  Copyright (C) 2007  Free Software Foundation, Inc.
- *
- *  GRUB is free software: you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation, either version 3 of the License, or
- *  (at your option) any later version.
- *
- *  GRUB is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with GRUB.  If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef GRUB_MACHINE_MACHINE_HEADER
-#define GRUB_MACHINE_MACHINE_HEADER	1
-
-#define GRUB_MACHINE_IEEE1275	1
-
-#endif /* ! GRUB_MACHINE_MACHINE_HEADER */

=== removed file 'include/grub/sparc64/ieee1275/machine.h'

grub/sparc64/ieee1275/machine.h +0 -24
@@ -1,24 +0,0 @@
-/*
- *  GRUB  --  GRand Unified Bootloader
- *  Copyright (C) 2007  Free Software Foundation, Inc.
- *
- *  GRUB is free software: you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation, either version 3 of the License, or
- *  (at your option) any later version.
- *
- *  GRUB is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with GRUB.  If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef GRUB_MACHINE_MACHINE_HEADER
-#define GRUB_MACHINE_MACHINE_HEADER	1
-
-#define GRUB_MACHINE_IEEE1275	1
-
-#endif /* ! GRUB_MACHINE_MACHINE_HEADER */

=== modified file 'include/grub/time.h'

grub/time.h +6 -1
@@ -21,8 +21,13 @@
 
 #include <grub/types.h>
 #include <grub/symbol.h>
+#include <grub/cpu/time.h>
+
+#ifdef GRUB_MACHINE_EMU
+#define GRUB_TICKS_PER_SECOND 100000
+#else
 #include <grub/machine/time.h>
-#include <grub/cpu/time.h>
+#endif
 
 void EXPORT_FUNC(grub_millisleep) (grub_uint32_t ms);
 grub_uint64_t EXPORT_FUNC(grub_get_time_ms) (void);

=== removed file 'include/grub/x86_64/efi/machine.h'

grub/x86_64/efi/machine.h +0 -24
@@ -1,24 +0,0 @@
-/*
- *  GRUB  --  GRand Unified Bootloader
- *  Copyright (C) 2007  Free Software Foundation, Inc.
- *
- *  GRUB is free software: you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation, either version 3 of the License, or
- *  (at your option) any later version.
- *
- *  GRUB is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with GRUB.  If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef GRUB_MACHINE_MACHINE_HEADER
-#define GRUB_MACHINE_MACHINE_HEADER	1
-
-#define GRUB_MACHINE_EFI	1
-
-#endif /* ! GRUB_MACHINE_MACHINE_HEADER */

=== modified file 'kern/dl.c'

dl.c +0 -1
@@ -31,7 +31,6 @@
 #include <grub/file.h>
 #include <grub/env.h>
 #include <grub/cache.h>
-#include <grub/machine/machine.h>
 
 /* Platforms where modules are in a readonly area of memory.  */
 #if defined(GRUB_MACHINE_QEMU)

=== modified file 'kern/i386/coreboot/init.c'

i386/coreboot/init.c +0 -1
@@ -23,7 +23,6 @@
 #include <grub/machine/memory.h>
 #include <grub/machine/console.h>
 #include <grub/machine/kernel.h>
-#include <grub/machine/machine.h>
 #include <grub/types.h>
 #include <grub/err.h>
 #include <grub/dl.h>

=== modified file 'loader/i386/bsd.c'

i386/bsd.c +0 -1
@@ -23,7 +23,6 @@
 #include <grub/machine/init.h>
 #include <grub/machine/memory.h>
 #include <grub/memory.h>
-#include <grub/machine/machine.h>
 #include <grub/file.h>
 #include <grub/err.h>
 #include <grub/dl.h>

=== modified file 'loader/i386/linux.c'

i386/linux.c +0 -1
@@ -17,7 +17,6 @@
  */
 
 #include <grub/loader.h>
-#include <grub/machine/machine.h>
 #include <grub/machine/memory.h>
 #include <grub/machine/loader.h>
 #include <grub/normal.h>

=== modified file 'loader/multiboot_loader.c'

multiboot_loader.c +0 -1
@@ -17,7 +17,6 @@
  *  along with GRUB.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-#include <grub/machine/machine.h>
 #include <grub/multiboot.h>
 #include <grub/multiboot2.h>
 #include <multiboot2.h>

=== modified file 'term/i386/pc/serial.c'

i386/pc/serial.c +0 -1
@@ -16,7 +16,6 @@
  *  along with GRUB.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-#include <grub/machine/machine.h>
 #include <grub/machine/memory.h>
 #include <grub/machine/serial.h>
 #include <grub/machine/console.h>

=== modified file 'term/usb_keyboard.c'

usb_keyboard.c +0 -1
@@ -18,7 +18,6 @@
  */
 
 #include <grub/term.h>
-#include <grub/machine/machine.h>
 #include <grub/machine/console.h>
 #include <grub/time.h>
 #include <grub/cpu/io.h>

=== modified file 'util/misc.c'

misc.c +2 -5
@@ -36,8 +36,6 @@
 #include <grub/mm.h>
 #include <grub/term.h>
 #include <grub/time.h>
-#include <grub/machine/time.h>
-#include <grub/machine/machine.h>
 
 /* Include malloc.h, only if memalign is available. It is known that
    memalign is declared in malloc.h in all systems, if present.  */
@@ -326,9 +324,8 @@
 
   gettimeofday (&tv, 0);
 
-  return (tv.tv_sec * GRUB_TICKS_PER_SECOND
-	  + (((tv.tv_sec % GRUB_TICKS_PER_SECOND) * 1000000 + tv.tv_usec)
-	     * GRUB_TICKS_PER_SECOND / 1000000));
+  GRUB_COMPILE_TIME_ASSERT (GRUB_TICKS_PER_SECOND == 1000000);
+  return (tv.tv_sec * 1000000 + tv.tv_usec);
 }
 
 grub_uint64_t
#1 lore raw
Quoted 4 lines · Robert Millan

This turns grub-emu into a port in order to make it easier to port GRUB to new CPUs. A porter can then do the CPU port without having to worry about firmware and/or hardware drivers initially.

Any comments on this?

Signature · 5 lines
Robert Millan

  The DRM opt-in fallacy: "Your data belongs to us. We will decide when (and
  how) you may access your data; but nobody's threatening your freedom: we
  still allow you to remove your data and not access it at all."
#2 lore raw
In reply to Robert Millan
Quoted 8 lines · Robert Millan

This turns grub-emu into a port in order to make it easier to port GRUB to new CPUs. A porter can then do the CPU port without having to worry about firmware and/or hardware drivers initially.

Patch attached. Branch is available in bzr+ssh://bzr.savannah.gnu.org/grub/people/robertmh/grub-emu/

Following hunk is a regression for me:
- return (tv.tv_sec * GRUB_TICKS_PER_SECOND
- + (((tv.tv_sec % GRUB_TICKS_PER_SECOND) * 1000000 + tv.tv_usec)
- * GRUB_TICKS_PER_SECOND / 1000000));
+ GRUB_COMPILE_TIME_ASSERT (GRUB_TICKS_PER_SECOND == 1000000);
+ return (tv.tv_sec * 1000000 + tv.tv_usec);
Having virtual clock going at any rate is an advantage for debugging. Other than this I'm ok with this patch and you can merge it into experimental

Quoted 6 lines

------------------------------------------------------------------------

_______________________________________________
Grub-devel mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/grub-devel

Signature · 3 lines
Regards
Vladimir 'phcoder' Serbinenko
Personal git repository: http://repo.or.cz/w/grub2/phcoder.git 
#3 lore raw
Quoted 15 lines · Vladimir 'phcoder' Serbinenko
Quoted 8 lines · Robert Millan

This turns grub-emu into a port in order to make it easier to port GRUB to new CPUs. A porter can then do the CPU port without having to worry about firmware and/or hardware drivers initially.

Patch attached. Branch is available in bzr+ssh://bzr.savannah.gnu.org/grub/people/robertmh/grub-emu/

Following hunk is a regression for me:

misc.c +2 -3
-  return (tv.tv_sec * GRUB_TICKS_PER_SECOND
-         + (((tv.tv_sec % GRUB_TICKS_PER_SECOND) * 1000000 + tv.tv_usec)
-            * GRUB_TICKS_PER_SECOND / 1000000));
+  GRUB_COMPILE_TIME_ASSERT (GRUB_TICKS_PER_SECOND == 1000000);
+  return (tv.tv_sec * 1000000 + tv.tv_usec);
Quoted 1 line

Having virtual clock going at any rate is an advantage for debugging.

I don't get what you mean. When GRUB runs on a Unix system, a tick represents a 1000000th fraction of a second, and therefore GRUB_TICKS_PER_SECOND is 1000000.

The old behaviour tried to emulate the behaviour of the specific hardware platform, but with grub-emu being a standalone port this doesn't make sense.

I don't think we can have both things (old tick behaviour + portable grub-emu). Was that behaviour useful? It seems to me that GRUB routines don't directly care about number of ticker per second, but rather just use it as a means to archieve something else. E.g. to compare output of grub_get_rtc().

Signature · 5 lines
Robert Millan

  The DRM opt-in fallacy: "Your data belongs to us. We will decide when (and
  how) you may access your data; but nobody's threatening your freedom: we
  still allow you to remove your data and not access it at all."
#4 lore raw
Quoted 26 lines · Robert Millan
Quoted 17 lines · Vladimir 'phcoder' Serbinenko
Quoted 9 lines · Robert Millan

This turns grub-emu into a port in order to make it easier to port GRUB to new CPUs. A porter can then do the CPU port without having to worry about firmware and/or hardware drivers initially.

Patch attached. Branch is available in bzr+ssh://bzr.savannah.gnu.org/grub/people/robertmh/grub-emu/

Following hunk is a regression for me:

misc.c +2 -3
-  return (tv.tv_sec * GRUB_TICKS_PER_SECOND
-         + (((tv.tv_sec % GRUB_TICKS_PER_SECOND) * 1000000 + tv.tv_usec)
-            * GRUB_TICKS_PER_SECOND / 1000000));
+  GRUB_COMPILE_TIME_ASSERT (GRUB_TICKS_PER_SECOND == 1000000);
+  return (tv.tv_sec * 1000000 + tv.tv_usec);
Quoted 2 lines

Having virtual clock going at any rate is an advantage for debugging.

I don't get what you mean. When GRUB runs on a Unix system, a tick represents a 1000000th fraction of a second, and therefore GRUB_TICKS_PER_SECOND is 1000000.

Quoted 9 lines

The old behaviour tried to emulate the behaviour of the specific hardware platform, but with grub-emu being a standalone port this doesn't make sense.

I don't think we can have both things (old tick behaviour + portable grub-emu). Was that behaviour useful? It seems to me that GRUB routines don't directly care about number of ticker per second, but rather just use it as a means to archieve something else. E.g. to compare output of grub_get_rtc().

I meant: keep GRUB_TICKS_PER_SECOND=1000000 per default but allow easy adjustment to any number by coder

Signature · 3 lines
Regards
Vladimir 'phcoder' Serbinenko
Personal git repository: http://repo.or.cz/w/grub2/phcoder.git 
#5 lore raw
Quoted 7 lines · Vladimir 'phcoder' Serbinenko
Quoted 5 lines

misc.c line 328

Quoted 5 lines
misc.c +2 -3
-  return (tv.tv_sec * GRUB_TICKS_PER_SECOND
-         + (((tv.tv_sec % GRUB_TICKS_PER_SECOND) * 1000000 + tv.tv_usec)
-            * GRUB_TICKS_PER_SECOND / 1000000));
+  GRUB_COMPILE_TIME_ASSERT (GRUB_TICKS_PER_SECOND == 1000000);
+  return (tv.tv_sec * 1000000 + tv.tv_usec);

I meant: keep GRUB_TICKS_PER_SECOND=1000000 per default but allow easy adjustment to any number by coder

Ah, you mean instead of assuming (and asserting) that they're 1000000, leave it as a hardcoded "#define GRUB_TICKS_PER_SECOND 1000000" so that this can be changed at source level?

Seems fine. If that's what you mean, I'll adjust the patch and add it to experimental.

Signature · 5 lines
Robert Millan

  The DRM opt-in fallacy: "Your data belongs to us. We will decide when (and
  how) you may access your data; but nobody's threatening your freedom: we
  still allow you to remove your data and not access it at all."
#6 lore raw
In reply to Vladimir 'phcoder' Serbinenko
Quoted 9 lines · Vladimir 'phcoder' Serbinenko

Following hunk is a regression for me:

misc.c +2 -3
-  return (tv.tv_sec * GRUB_TICKS_PER_SECOND
-         + (((tv.tv_sec % GRUB_TICKS_PER_SECOND) * 1000000 + tv.tv_usec)
-            * GRUB_TICKS_PER_SECOND / 1000000));
+  GRUB_COMPILE_TIME_ASSERT (GRUB_TICKS_PER_SECOND == 1000000);
+  return (tv.tv_sec * 1000000 + tv.tv_usec);

Having virtual clock going at any rate is an advantage for debugging. Other than this I'm ok with this patch and you can merge it into experimental

Fixed and merged in exp.

Signature · 5 lines
Robert Millan

  The DRM opt-in fallacy: "Your data belongs to us. We will decide when (and
  how) you may access your data; but nobody's threatening your freedom: we
  still allow you to remove your data and not access it at all."