Skip to contentSkip to conversation

Re-enable grub-extras

PATCH In review Colin Watson 3 participants 11 messages Sep 21, 2010 – Oct 2, 2010 Kbuild

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Re-enable grub-extras

Here's a patch to re-enable grub-extras by allowing extra modules to provide Autogen definitions files. A few things to note:

* I had to have autogen.sh create 'contrib' symlinks in the source tree, as Automake got hopelessly confused when I had $(GRUB_CONTRIB) in source file names - automatic dependency handling in particular broke in some thoroughly tortuous ways. I don't think this is too ugly but you might like to know why I did it!

* I added the facility for image blocks in .def files to override the image extension, in order to translate ntldr-img's build system reasonably faithfully.

* This patch supports extra modules providing either Makefile.core.def (for extra target objects, built from grub-core) or Makefile.util.def (for extra utility programs, built from the top level). I don't have any examples of the latter right now, but it was easy to provide both and might save somebody scratching their head working out how to do it later.

* Extra modules may also provide Makefile.common with literal Automake input, for those cases where it's too hard to cram things into Autogen.

* I know we don't normally discuss grub-extras patches here, but it seems difficult not to in this case. I've attached the patches required for each of the five grub-extras modules I know about to this mail.

* grldr.img used to have build rules but not actually be built automatically; it's now built automatically. I didn't think it was worth the contortions to try to fix this.

2010-09-21 Colin Watson <[email protected]>

Re-enable grub-extras.

* Makefile.am: Include Makefile.extras.am.
* grub-core/Makefile.am: Likewise.
* autogen.sh: Create symlinks to ${GRUB_CONTRIB} if necessary to avoid confusing Automake. Run autogen for each extra module.
* .bzrignore: Add Makefile.extras.am, contrib, grub-core/Makefile.extras.am, and grub-core/contrib.

* gentpl.py (image): Allow definitions files to override the image extension.

=== modified file '.bzrignore'

.bzrignore +4 -0
@@ -104,9 +104,13 @@ grub-core/lib/libgcrypt-grub
 **/.deps-core
 **/.dirstamp
 Makefile.util.am
+Makefile.extras.am
+contrib
 grub-core/Makefile.core.am
 grub-core/Makefile.gcry.am
 grub-core/Makefile.gcry.def
+grub-core/Makefile.extras.am
+grub-core/contrib
 grub-core/genmod.sh
 grub-core/gensyminfo.sh
 grub-core/*.module

=== modified file 'Makefile.am'

Makefile.am +1 -0
@@ -19,6 +19,7 @@ CPPFLAGS_PROGRAM += $(CPPFLAGS_GNULIB)
 CCASFLAGS_PROGRAM += $(CCASFLAGS_GNULIB)
 
 include $(srcdir)/Makefile.util.am
+include $(srcdir)/Makefile.extras.am
 
 # XXX Use Automake's LEX & YACC support
 grub_script.tab.h: $(top_srcdir)/grub-core/script/parser.y

=== modified file 'autogen.sh'

autogen.sh +31 -0
@@ -18,6 +18,37 @@ autogen -T Makefile.tpl Makefile.util.de
 autogen -T Makefile.tpl grub-core/Makefile.core.def | sed -e '/^$/{N;/^\n$/D;}' > grub-core/Makefile.core.am
 autogen -T Makefile.tpl grub-core/Makefile.gcry.def | sed -e '/^$/{N;/^\n$/D;}' > grub-core/Makefile.gcry.am
 
+# Automake doesn't like including files from a path outside the project.
+if [ "x${GRUB_CONTRIB}" != x ] && [ "x${GRUB_CONTRIB}" != xcontrib ]; then
+  rm -f contrib grub-core/contrib
+  ln -s "${GRUB_CONTRIB}" contrib
+  ln -s ../contrib grub-core/contrib
+fi
+
+> grub-core/Makefile.extras.am
+for extra in contrib/*/Makefile.core.def; do
+  if test -e "$extra"; then
+    extra_name="$(basename "$(dirname "$extra")")"
+    autogen -T Makefile.tpl "$extra" | sed -e '/^$/{N;/^\n$/D;}' > "contrib/$extra_name/Makefile.core.am"
+    if test -e "contrib/$extra_name/Makefile.common"; then
+      echo "include contrib/$extra_name/Makefile.common" >> grub-core/Makefile.extras.am
+    fi
+    echo "include contrib/$extra_name/Makefile.core.am" >> grub-core/Makefile.extras.am
+  fi
+done
+
+> Makefile.extras.am
+for extra in contrib/*/Makefile.util.def; do
+  if test -e "$extra"; then
+    extra_name="$(basename "$(dirname "$extra")")"
+    autogen -T Makefile.tpl "$extra" | sed -e '/^$/{N;/^\n$/D;}' > "contrib/$extra_name/Makefile.util.am"
+    if test -e "contrib/$extra_name/Makefile.common"; then
+      echo "include contrib/$extra_name/Makefile.common" >> Makefile.extras.am
+    fi
+    echo "include contrib/$extra_name/Makefile.util.am" >> Makefile.extras.am
+  fi
+done
+
 echo "Saving timestamps..."
 echo timestamp > stamp-h.in
 

=== modified file 'gentpl.py'

gentpl.py +4 -3
@@ -328,9 +328,10 @@ def image(platform):
     r += gvar_add("BUILT_SOURCES", "$(nodist_" + cname() + "_SOURCES)")
     r += gvar_add("CLEANFILES", "$(nodist_" + cname() + "_SOURCES)")
 
-    r += gvar_add("platform_DATA", "[+ name +].img")
-    r += gvar_add("CLEANFILES", "[+ name +].img")
-    r += rule("[+ name +].img", "[+ name +].image$(EXEEXT)", """
+    extension = "[+ IF extension defined +][+ extension +][+ ELSE +]img[+ ENDIF +]"
+    r += gvar_add("platform_DATA", "[+ name +]." + extension)
+    r += gvar_add("CLEANFILES", "[+ name +]." + extension)
+    r += rule("[+ name +]." + extension, "[+ name +].image$(EXEEXT)", """
 if test x$(USE_APPLE_CC_FIXES) = xyes; then \
   $(MACHO2IMG) $< $@; \
 else \

=== modified file 'grub-core/Makefile.am'

Makefile.am +1 -0
@@ -52,6 +52,7 @@ CLEANFILES += grub_script.yy.c grub_scri
 
 include $(srcdir)/Makefile.core.am
 include $(srcdir)/Makefile.gcry.am
+include $(srcdir)/Makefile.extras.am
 
 KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/cache.h
 KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/command.h
Signature · 1 line
Colin Watson                                       [[email protected]]

=== added file '.bzrignore'

.bzrignore +3 -0
@@ -0,0 +1,3 @@
+**/.deps-core
+**/.dirstamp
+Makefile.core.am

=== added file 'Makefile.core.def'

Makefile.core.def +8 -0
@@ -0,0 +1,8 @@
+AutoGen definitions Makefile.tpl;
+
+module = {
+  name = '915resolution';
+  i386_pc = 'contrib/915resolution/915resolution.c';
+  cflags = -Wno-error;
+  enable = i386_pc;
+};

=== removed directory 'conf'
=== removed file 'conf/common.rmk'

common.rmk +0 -2
@@ -1,2 +0,0 @@
-# -*- makefile -*-
--include $(GRUB_CONTRIB)/915resolution/conf/$(target_cpu)-$(platform).mk

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

i386-pc.rmk +0 -6
@@ -1,6 +0,0 @@
-# -*- makefile -*-
-
-pkglib_MODULES += 915resolution.mod
-915resolution_mod_SOURCES = $(GRUB_CONTRIB)/915resolution/915resolution.c
-915resolution_mod_CFLAGS = $(COMMON_CFLAGS) -Wno-error
-915resolution_mod_LDFLAGS = $(COMMON_LDFLAGS)

=== modified file '.bzrignore'

.bzrignore +3 -1
@@ -1 +1,3 @@
-conf/common.mk
+**/.deps-core
+**/.dirstamp
+Makefile.core.am

=== added file 'Makefile.common'

Makefile.common +2 -0
@@ -0,0 +1,2 @@
+GPXE_CPPFLAGS = '-DFILE_LICENCE(x)=' -Icontrib/gpxe/src/include -Icontrib/gpxe/include_wrap
+GPXE_CFLAGS = -Wno-pointer-arith -Wno-error

=== added file 'Makefile.core.def'

Makefile.core.def +431 -0

431 lines not on this page · raw message

=== removed directory 'conf'
=== removed file 'conf/common.rmk'

common.rmk +0 -323

323 lines not on this page · raw message

=== added file '.bzrignore'

.bzrignore +3 -0
@@ -0,0 +1,3 @@
+**/.deps-core
+**/.dirstamp
+Makefile.core.am

=== added file 'Makefile.core.def'

Makefile.core.def +36 -0
@@ -0,0 +1,36 @@
+AutoGen definitions Makefile.tpl;
+
+module = {
+  name = lua;
+  common = 'contrib/lua/lapi.c';
+  common = 'contrib/lua/lcode.c';
+  common = 'contrib/lua/ldebug.c';
+  common = 'contrib/lua/ldo.c';
+  common = 'contrib/lua/ldump.c';
+  common = 'contrib/lua/lfunc.c';
+  common = 'contrib/lua/lgc.c';
+  common = 'contrib/lua/llex.c';
+  common = 'contrib/lua/lmem.c';
+  common = 'contrib/lua/lobject.c';
+  common = 'contrib/lua/lopcodes.c';
+  common = 'contrib/lua/lparser.c';
+  common = 'contrib/lua/lstate.c';
+  common = 'contrib/lua/lstring.c';
+  common = 'contrib/lua/ltable.c';
+  common = 'contrib/lua/ltm.c';
+  common = 'contrib/lua/lundump.c';
+  common = 'contrib/lua/lvm.c';
+  common = 'contrib/lua/lzio.c';
+  common = 'contrib/lua/lauxlib.c';
+  common = 'contrib/lua/lbaselib.c';
+  common = 'contrib/lua/linit.c';
+  common = 'contrib/lua/ltablib.c';
+  common = 'contrib/lua/lstrlib.c';
+  common = 'contrib/lua/grub_main.c';
+  common = 'contrib/lua/grub_lib.c';
+  cflags = -Wno-error;
+};
+
+/* Extra libraries for lua
+   script/lua/lmathlib.c script/lua/loslib.c script/lua/liolib.c
+   script/lua/ldblib.c script/lua/loadlib.c  */

=== removed directory 'conf'
=== removed file 'conf/common.rmk'

common.rmk +0 -18
@@ -1,18 +0,0 @@
-# -*- makefile -*-
-
-pkglib_MODULES += lua.mod
-lua_mod_SOURCES = $(GRUB_CONTRIB)/lua/lapi.c $(GRUB_CONTRIB)/lua/lcode.c $(GRUB_CONTRIB)/lua/ldebug.c \
-	$(GRUB_CONTRIB)/lua/ldo.c $(GRUB_CONTRIB)/lua/ldump.c $(GRUB_CONTRIB)/lua/lfunc.c \
-	$(GRUB_CONTRIB)/lua/lgc.c $(GRUB_CONTRIB)/lua/llex.c $(GRUB_CONTRIB)/lua/lmem.c \
-	$(GRUB_CONTRIB)/lua/lobject.c $(GRUB_CONTRIB)/lua/lopcodes.c $(GRUB_CONTRIB)/lua/lparser.c \
-	$(GRUB_CONTRIB)/lua/lstate.c $(GRUB_CONTRIB)/lua/lstring.c $(GRUB_CONTRIB)/lua/ltable.c \
-	$(GRUB_CONTRIB)/lua/ltm.c $(GRUB_CONTRIB)/lua/lundump.c $(GRUB_CONTRIB)/lua/lvm.c \
-	$(GRUB_CONTRIB)/lua/lzio.c $(GRUB_CONTRIB)/lua/lauxlib.c $(GRUB_CONTRIB)/lua/lbaselib.c \
-	$(GRUB_CONTRIB)/lua/linit.c $(GRUB_CONTRIB)/lua/ltablib.c $(GRUB_CONTRIB)/lua/lstrlib.c \
-	$(GRUB_CONTRIB)/lua/grub_main.c $(GRUB_CONTRIB)/lua/grub_lib.c
-lua_mod_CFLAGS = $(COMMON_CFLAGS) -Wno-error
-lua_mod_LDFLAGS = $(COMMON_LDFLAGS)
-
-# Extra libraries for lua
-# script/lua/lmathlib.c script/lua/loslib.c script/lua/liolib.c
-# script/lua/ldblib.c script/lua/loadlib.c

=== added file '.bzrignore'

.bzrignore +3 -0
@@ -0,0 +1,3 @@
+**/.deps-core
+**/.dirstamp
+Makefile.core.am

=== added file 'Makefile.common'

Makefile.common +20 -0
@@ -0,0 +1,20 @@
+grldr.mbr: grldr.img
+	head -c 8192 $< > $@
+CLEANFILES += grldr.mbr
+
+bin2h: contrib/ntldr-img/bin2h.c
+	$(CC) $^ -o $@
+CLEANFILES += bin2h
+
+grub_mbr.h: grldr.mbr bin2h
+	./bin2h grub_mbr 8192 < $< > $@
+CLEANFILES += grub_mbr.h
+
+grubinst: contrib/ntldr-img/grubinst.c contrib/ntldr-img/utils.c grub_mbr.h
+	$(CC) -I. -Icontrib/ntldr-img -DLINUX -o $@ contrib/ntldr-img/grubinst.c contrib/ntldr-img/utils.c
+CLEANFILES += grubinst
+
+noinst_PROGRAMS += g2ldr.mbr
+g2ldr.mbr: grubinst
+	./grubinst --grub2 -o $@
+CLEANFILES += g2ldr.mbr

=== added file 'Makefile.core.def'

Makefile.core.def +22 -0
@@ -0,0 +1,22 @@
+AutoGen definitions Makefile.tpl;
+
+image = {
+  name = g2hdr;
+  extension = bin;
+  i386_pc = 'contrib/ntldr-img/g2hdr.S';
+  i386_pc_ldflags = '$(TARGET_IMG_LDFLAGS)';
+  i386_pc_ldflags = '$(TARGET_IMG_BASE_LDOPT),0x0';
+  objcopyflags = '-O binary';
+  enable = i386_pc;
+};
+
+image = {
+  name = grldr;
+  i386_pc = 'contrib/ntldr-img/grldrstart.S';
+  i386_pc = 'contrib/ntldr-img/ntfsbs.S';
+  i386_pc_ccasflags = -DGRLDR_MBR;
+  i386_pc_ldflags = '$(TARGET_IMG_LDFLAGS)';
+  i386_pc_ldflags = '$(TARGET_IMG_BASE_LDOPT),0x7c00';
+  objcopyflags = '-O binary';
+  enable = i386_pc;
+};

=== removed directory 'conf'
=== removed file 'conf/common.rmk'

common.rmk +0 -2
@@ -1,2 +0,0 @@
-# -*- makefile -*-
--include $(GRUB_CONTRIB)/ntldr-img/conf/$(target_cpu)-$(platform).mk

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

i386-pc.rmk +0 -37
@@ -1,37 +0,0 @@
-# -*- makefile -*-
-
-pkglib_IMAGES += g2ldr.mbr g2hdr.bin grldr.img
-
-all: g2ldr.mbr g2hdr.bin
-
-DISTCLEANFILES += g2ldr.mbr g2hdr.bin
-
-g2hdr_bin_SOURCES = $(GRUB_CONTRIB)/ntldr-img/g2hdr.S
-g2hdr_bin_ASFLAGS = $(COMMON_ASFLAGS)
-g2hdr_bin_LDFLAGS = $(COMMON_LDFLAGS) $(TARGET_IMG_LDFLAGS)0x0
-g2hdr_bin_FORMAT = binary
-
-grldr_img_SOURCES = $(GRUB_CONTRIB)/ntldr-img/grldrstart.S $(GRUB_CONTRIB)/ntldr-img/ntfsbs.S
-grldr_img_ASFLAGS = $(COMMON_ASFLAGS) -DGRLDR_MBR
-grldr_img_LDFLAGS = $(COMMON_LDFLAGS) $(TARGET_IMG_LDFLAGS)0x7c00
-grldr_img_FORMAT = binary
-
-grldr.mbr: grldr.img
-	head -c 8192 $< > $@
-DISTCLEANFILES += grldr.mbr
-
-bin2h: $(GRUB_CONTRIB)/ntldr-img/bin2h.c
-	$(CC) $^ -o $@
-DISTCLEANFILES += bin2h
-
-grub_mbr.h: grldr.mbr bin2h
-	./bin2h grub_mbr 8192 < $< > $@
-DISTCLEANFILES += grub_mbr.h
-
-grubinst: $(GRUB_CONTRIB)/ntldr-img/grubinst.c $(GRUB_CONTRIB)/ntldr-img/utils.c grub_mbr.h
-	$(CC) -I. -I$(GRUB_CONTRIB)/ntldr-img -DLINUX -o $@ $(GRUB_CONTRIB)/ntldr-img/grubinst.c $(GRUB_CONTRIB)/ntldr-img/utils.c
-DISTCLEANFILES += grubinst
-
-g2ldr.mbr: grubinst
-	./grubinst --grub2 -o $@
-DISTCLEANFILES += g2ldr.mbr

=== added file '.bzrignore'

.bzrignore +3 -0
@@ -0,0 +1,3 @@
+**/.deps-core
+**/.dirstamp
+Makefile.core.am

=== added file 'Makefile.common'

Makefile.common +2 -0
@@ -0,0 +1,2 @@
+ZFS_CPPFLAGS = -Icontrib/zfs/include
+ZFS_CFLAGS = -Wno-error

=== added file 'Makefile.core.def'

Makefile.core.def +18 -0
@@ -0,0 +1,18 @@
+AutoGen definitions Makefile.tpl;
+
+module = {
+  name = zfs;
+  common = 'contrib/zfs/zfs.c';
+  common = 'contrib/zfs/zfs_lzjb.c';
+  common = 'contrib/zfs/zfs_sha256.c';
+  common = 'contrib/zfs/zfs_fletcher.c';
+  cppflags = '$(ZFS_CPPFLAGS)';
+  cflags = '$(ZFS_CFLAGS)';
+};
+
+module = {
+  name = zfsinfo;
+  common = 'contrib/zfs/zfsinfo.c';
+  cppflags = '$(ZFS_CPPFLAGS)';
+  cflags = '$(ZFS_CFLAGS)';
+};

=== removed directory 'conf'
=== removed file 'conf/common.rmk'

common.rmk +0 -13
@@ -1,13 +0,0 @@
-# -*- makefile -*-
-
-COMMON_CFLAGS += -I$(GRUB_CONTRIB)/zfs/include
-
-pkglib_MODULES += zfs.mod
-zfs_mod_SOURCES = $(GRUB_CONTRIB)/zfs/zfs.c $(GRUB_CONTRIB)/zfs/zfs_lzjb.c $(GRUB_CONTRIB)/zfs/zfs_sha256.c $(GRUB_CONTRIB)/zfs/zfs_fletcher.c
-zfs_mod_CFLAGS = $(COMMON_CFLAGS) -Wno-error
-zfs_mod_LDFLAGS = $(COMMON_LDFLAGS)
-
-pkglib_MODULES += zfsinfo.mod
-zfsinfo_mod_SOURCES = $(GRUB_CONTRIB)/zfs/zfsinfo.c
-zfsinfo_mod_CFLAGS = $(COMMON_CFLAGS) -Wno-error
-zfsinfo_mod_LDFLAGS = $(COMMON_LDFLAGS)
#1 lore raw
Quoted 2 lines · Colin Watson

Here's a patch to re-enable grub-extras by allowing extra modules to provide Autogen definitions files. A few things to note:

Vladimir commented on this on IRC, noting three problems. In reverse order of complexity:

1) The GRUB_CONTRIB check in autogen.sh should also check for grub-core/contrib.

Fixed.

2) What's the problem with renaming g2hdr.bin to g2hdr.img?

I know of at least one piece of software which expects the current file
name: win32-loader, written by Robert and maintained in Debian. It probably wouldn't be completely awful to change this, but it would be nice not to need to. That said, perhaps g2hdr.bin could be a symlink to g2hdr.img (which could be done in Makefile.common). I've updated my patch to do this, and removed the extension-override facility from gentpl.py.

3) It would be nice if extra modules could add new sources to existing targets defined in one of the main definitions files: for example, it would be useful to be able to add zfs to libgrub.a.

This was the hard bit that took me a day or two to fix.

Vladimir's original suggestion on IRC was to create a separate libgrubzfs.a and arrange to link the utilities with that as well. When I looked into this, I decided that I didn't like this approach because it simply pushes the problem of appending to an existing list up a level; as far as the Autogen definitions go, there isn't a significant difference between appending to grub_probe_LDADD and appending to libgrub_a_SOURCES. I would prefer to solve this some other way.

My preferred approach is to try not to expose any of the difficulties in the definitions file, so that it can just look like this:

  library = {
    name = libgrub.a;
    common = contrib/zfs/zfs.c;
    common = contrib/zfs/zfs_lzjb.c;
    common = contrib/zfs/zfs_sha256.c;
    common = contrib/zfs/zfs_fletcher.c;
    cppflags = '$(ZFS_CPPFLAGS)';
    cflags = '$(ZFS_CFLAGS)';
  };

Doing this actually turned out to be very difficult because Autogen's native macros aren't powerful enough: they can only really emit text rather than using temporary storage, which means that you can't do things like "look for all the library blocks with the same name and concatenate them" or "append to _SOURCES variables if we've seen them before". Some Automake variables can be handled with simple appends while some of them have some boilerplate only at the start which shouldn't be repeated; Automake variables must be initialised exactly once on all possible intersections of conditional paths; and we should also avoid generating duplicate rules. All these constraints make it a hard problem.

Fortunately, Autogen supports embedding bits of Guile, which makes the problem merely hard rather than impossible. I tried a few different approaches, and the one that I found to be most practical is in the following patch: effectively we remember whether we've seen a given target before and treat it slightly differently, and furthermore we emit initialisations for non-global variables to avoid problems with Automake's restrictions on variable initialisation.

For now, I only implemented this for 'library' blocks, so something that wants to compile extra files into the GRUB kernel for example will be out of luck. If people feel this is an onerous restriction then it's fairly easy to fix; I was just trying not to change too much at once, particularly for paths I wasn't going to test.

Doing this involved feeding all the files relevant to a given Automake input stream to Autogen in one go, so I eliminated Makefile.gcry.am.

This was an exercise in programming in six languages at once (Python, Autogen native macros, Guile, Autogen definitions, Automake, and make). I found it to be a bit much, and my impression is that Autogen got in the way more than it helped. I suggest that after 1.99 we should look at having a Python program generate Automake input directly, which would avoid many contortions and allow us to improve the output (it could merge the multiple _SOURCES lines into just one per conditional path, for instance). The .def file format is of course just fine as it is, and could easily be preserved.

Quoted 3 lines

* Extra modules may also provide Makefile.common with literal Automake input, for those cases where it's too hard to cram things into Autogen.

I also added Makefile.core.common and Makefile.util.common (starting to run out of good names) for literal Automake input that should only be used in grub-core or at the top level respectively. ntldr-img needed the former.

Once again, the required patches to grub-extras modules are attached.

2010-09-22 Colin Watson <[email protected]>

Re-enable grub-extras.

* autogen.sh: Create symlinks to ${GRUB_CONTRIB} if necessary to avoid confusing Automake. Run autogen only twice, once for the top level and once for grub-core. Add Makefile.util.def and Makefile.core.def from extra modules to the appropriate autogen invocations. If Makefile.common exists in an extra module, include it in both Makefile.util.am and grub-core/Makefile.core.am; similarly, include any Makefile.util.common file in Makefile.util.am and any Makefile.core.common file in grub-core/Makefile.core.am.
* conf/Makefile.common ($(top_srcdir)/grub-core/Makefile.core.am):
Depend on $(top_srcdir)/grub-core/Makefile.gcry.def. ($(top_srcdir)/grub-core/Makefile.gcry.def): Remove.
* grub-core/Makefile.am: Remove inclusion of Makefile.gcry.am.

* gentpl.py (gvar_add): Turn GVARS into a set. (global_variable_initializers): Sort global variables on output. (vars_init): New function.
(first_time): Likewise.
(library): Ensure that non-global variable initialisations are emitted before the first time we emit code for a library block. Append to variables rather than setting them. Only emit noinst_LIBRARIES, BUILT_SOURCES, and CLEANFILES the first time for each conditional path.
(program): installdir() emits an Autogen macro, so must be passed to var_add rather than gvar_add.
(data): Likewise.
(script): Likewise.
(rules): New function, centralising handling for different target types. Set up Guile association lists for first_time and vars_init, and send most output to a diversion so that variable initialisations can be emitted first.
(module_rules): Use new rules function.
(kernel_rules): Likewise.
(image_rules): Likewise.
(library_rules): Likewise.
(program_rules): Likewise.
(script_rules): Likewise.
(data_rules): Likewise.

* configure.ac: Add AC_PROG_LN_S, for the benefit of ntldr-img.

* .bzrignore: Add contrib and grub-core/contrib. Remove grub-core/Makefile.gcry.am.

=== modified file '.bzrignore'

.bzrignore +2 -1
@@ -104,9 +104,10 @@ grub-core/lib/libgcrypt-grub
 **/.deps-core
 **/.dirstamp
 Makefile.util.am
+contrib
 grub-core/Makefile.core.am
-grub-core/Makefile.gcry.am
 grub-core/Makefile.gcry.def
+grub-core/contrib
 grub-core/genmod.sh
 grub-core/gensyminfo.sh
 grub-core/*.module

=== modified file 'autogen.sh'

autogen.sh +44 -3

53 lines not on this page · raw message

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

Makefile.common +3 -7
@@ -146,11 +146,7 @@ $(top_srcdir)/Makefile.util.am: $(top_sr
 	mv [email protected] $@
 
 .PRECIOUS: $(top_srcdir)/grub-core/Makefile.core.am
-$(top_srcdir)/grub-core/Makefile.core.am: $(top_srcdir)/grub-core/Makefile.core.def $(top_srcdir)/Makefile.tpl
-	autogen -T $(top_srcdir)/Makefile.tpl $< | sed -e '/^$$/{N;/^\\n$$/D;}' > [email protected] || (rm -f [email protected]; exit 1)
-	mv [email protected] $@
-
-.PRECIOUS: $(top_srcdir)/grub-core/Makefile.gcry.am
-$(top_srcdir)/grub-core/Makefile.gcry.am: $(top_srcdir)/grub-core/Makefile.gcry.def $(top_srcdir)/Makefile.tpl
-	autogen -T $(top_srcdir)/Makefile.tpl $< | sed -e '/^$$/{N;/^\\n$$/D;}' > [email protected] || (rm -f [email protected]; exit 1)
+$(top_srcdir)/grub-core/Makefile.core.am: $(top_srcdir)/grub-core/Makefile.core.def $(top_srcdir)/grub-core/Makefile.gcry.def $(top_srcdir)/Makefile.tpl
+	if [ "x$$GRUB_CONTRIB" != x ]; then echo "You need to run ./autogen.sh manually." >&2; exit 1; fi
+	autogen -T $(top_srcdir)/Makefile.tpl $(top_srcdir)/grub-core/Makefile.core.def $(top_srcdir)/grub-core/Makefile.gcry.def | sed -e '/^$$/{N;/^\\n$$/D;}' > [email protected] || (rm -f [email protected]; exit 1)
 	mv [email protected] $@

=== modified file 'configure.ac'

configure.ac +1 -0
@@ -235,6 +235,7 @@ AC_PROG_LEX
 AC_PROG_YACC
 AC_PROG_MAKE_SET
 AC_PROG_MKDIR_P
+AC_PROG_LN_S
 
 if test "x$LEX" = "x:"; then
   AC_MSG_ERROR([flex is not found])

=== modified file 'gentpl.py'

gentpl.py +66 -31

166 lines not on this page · raw message

=== modified file 'grub-core/Makefile.am'

Makefile.am +0 -1
@@ -51,7 +51,6 @@ grub_script.yy.c: grub_script.yy.h
 CLEANFILES += grub_script.yy.c grub_script.yy.h
 
 include $(srcdir)/Makefile.core.am
-include $(srcdir)/Makefile.gcry.am
 
 KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/cache.h
 KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/command.h
Signature · 1 line
Colin Watson                                       [[email protected]]
#2 lore raw
Quoted 1 line · Colin Watson

Once again, the required patches to grub-extras modules are attached.

No, really! Here they are.

Signature · 1 line
Colin Watson                                       [[email protected]]

=== added file '.bzrignore'

.bzrignore +3 -0
@@ -0,0 +1,3 @@
+**/.deps-core
+**/.dirstamp
+Makefile.core.am

=== added file 'Makefile.core.def'

Makefile.core.def +8 -0
@@ -0,0 +1,8 @@
+AutoGen definitions Makefile.tpl;
+
+module = {
+  name = '915resolution';
+  i386_pc = contrib/915resolution/915resolution.c;
+  cflags = -Wno-error;
+  enable = i386_pc;
+};

=== removed directory 'conf'
=== removed file 'conf/common.rmk'

common.rmk +0 -2
@@ -1,2 +0,0 @@
-# -*- makefile -*-
--include $(GRUB_CONTRIB)/915resolution/conf/$(target_cpu)-$(platform).mk

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

i386-pc.rmk +0 -6
@@ -1,6 +0,0 @@
-# -*- makefile -*-
-
-pkglib_MODULES += 915resolution.mod
-915resolution_mod_SOURCES = $(GRUB_CONTRIB)/915resolution/915resolution.c
-915resolution_mod_CFLAGS = $(COMMON_CFLAGS) -Wno-error
-915resolution_mod_LDFLAGS = $(COMMON_LDFLAGS)

=== modified file '.bzrignore'

.bzrignore +3 -1
@@ -1 +1,3 @@
-conf/common.mk
+**/.deps-core
+**/.dirstamp
+Makefile.core.am

=== added file 'Makefile.common'

Makefile.common +2 -0
@@ -0,0 +1,2 @@
+GPXE_CPPFLAGS = '-DFILE_LICENCE(x)=' -Icontrib/gpxe/src/include -Icontrib/gpxe/include_wrap
+GPXE_CFLAGS = -Wno-pointer-arith -Wno-error

=== added file 'Makefile.core.def'

Makefile.core.def +431 -0

431 lines not on this page · raw message

=== removed directory 'conf'
=== removed file 'conf/common.rmk'

common.rmk +0 -323

323 lines not on this page · raw message

=== added file '.bzrignore'

.bzrignore +3 -0
@@ -0,0 +1,3 @@
+**/.deps-core
+**/.dirstamp
+Makefile.core.am

=== added file 'Makefile.core.def'

Makefile.core.def +36 -0
@@ -0,0 +1,36 @@
+AutoGen definitions Makefile.tpl;
+
+module = {
+  name = lua;
+  common = contrib/lua/lapi.c;
+  common = contrib/lua/lcode.c;
+  common = contrib/lua/ldebug.c;
+  common = contrib/lua/ldo.c;
+  common = contrib/lua/ldump.c;
+  common = contrib/lua/lfunc.c;
+  common = contrib/lua/lgc.c;
+  common = contrib/lua/llex.c;
+  common = contrib/lua/lmem.c;
+  common = contrib/lua/lobject.c;
+  common = contrib/lua/lopcodes.c;
+  common = contrib/lua/lparser.c;
+  common = contrib/lua/lstate.c;
+  common = contrib/lua/lstring.c;
+  common = contrib/lua/ltable.c;
+  common = contrib/lua/ltm.c;
+  common = contrib/lua/lundump.c;
+  common = contrib/lua/lvm.c;
+  common = contrib/lua/lzio.c;
+  common = contrib/lua/lauxlib.c;
+  common = contrib/lua/lbaselib.c;
+  common = contrib/lua/linit.c;
+  common = contrib/lua/ltablib.c;
+  common = contrib/lua/lstrlib.c;
+  common = contrib/lua/grub_main.c;
+  common = contrib/lua/grub_lib.c;
+  cflags = -Wno-error;
+};
+
+/* Extra libraries for lua
+   script/lua/lmathlib.c script/lua/loslib.c script/lua/liolib.c
+   script/lua/ldblib.c script/lua/loadlib.c  */

=== removed directory 'conf'
=== removed file 'conf/common.rmk'

common.rmk +0 -18
@@ -1,18 +0,0 @@
-# -*- makefile -*-
-
-pkglib_MODULES += lua.mod
-lua_mod_SOURCES = $(GRUB_CONTRIB)/lua/lapi.c $(GRUB_CONTRIB)/lua/lcode.c $(GRUB_CONTRIB)/lua/ldebug.c \
-	$(GRUB_CONTRIB)/lua/ldo.c $(GRUB_CONTRIB)/lua/ldump.c $(GRUB_CONTRIB)/lua/lfunc.c \
-	$(GRUB_CONTRIB)/lua/lgc.c $(GRUB_CONTRIB)/lua/llex.c $(GRUB_CONTRIB)/lua/lmem.c \
-	$(GRUB_CONTRIB)/lua/lobject.c $(GRUB_CONTRIB)/lua/lopcodes.c $(GRUB_CONTRIB)/lua/lparser.c \
-	$(GRUB_CONTRIB)/lua/lstate.c $(GRUB_CONTRIB)/lua/lstring.c $(GRUB_CONTRIB)/lua/ltable.c \
-	$(GRUB_CONTRIB)/lua/ltm.c $(GRUB_CONTRIB)/lua/lundump.c $(GRUB_CONTRIB)/lua/lvm.c \
-	$(GRUB_CONTRIB)/lua/lzio.c $(GRUB_CONTRIB)/lua/lauxlib.c $(GRUB_CONTRIB)/lua/lbaselib.c \
-	$(GRUB_CONTRIB)/lua/linit.c $(GRUB_CONTRIB)/lua/ltablib.c $(GRUB_CONTRIB)/lua/lstrlib.c \
-	$(GRUB_CONTRIB)/lua/grub_main.c $(GRUB_CONTRIB)/lua/grub_lib.c
-lua_mod_CFLAGS = $(COMMON_CFLAGS) -Wno-error
-lua_mod_LDFLAGS = $(COMMON_LDFLAGS)
-
-# Extra libraries for lua
-# script/lua/lmathlib.c script/lua/loslib.c script/lua/liolib.c
-# script/lua/ldblib.c script/lua/loadlib.c

=== added file '.bzrignore'

.bzrignore +3 -0
@@ -0,0 +1,3 @@
+**/.deps-core
+**/.dirstamp
+Makefile.core.am

=== added file 'Makefile.core.common'

Makefile.core.common +27 -0
@@ -0,0 +1,27 @@
+# Compatibility symlink.
+noinst_PROGRAMS += g2hdr.bin
+g2hdr.bin: g2hdr.img
+	rm -f $@
+	$(LN_S) $< $@
+CLEANFILES += g2hdr.bin
+
+grldr.mbr: grldr.img
+	head -c 8192 $< > $@
+CLEANFILES += grldr.mbr
+
+bin2h: contrib/ntldr-img/bin2h.c
+	$(CC) $^ -o $@
+CLEANFILES += bin2h
+
+grub_mbr.h: grldr.mbr bin2h
+	./bin2h grub_mbr 8192 < $< > $@
+CLEANFILES += grub_mbr.h
+
+grubinst: contrib/ntldr-img/grubinst.c contrib/ntldr-img/utils.c grub_mbr.h
+	$(CC) -I. -Icontrib/ntldr-img -DLINUX -o $@ contrib/ntldr-img/grubinst.c contrib/ntldr-img/utils.c
+CLEANFILES += grubinst
+
+noinst_PROGRAMS += g2ldr.mbr
+g2ldr.mbr: grubinst
+	./grubinst --grub2 -o $@
+CLEANFILES += g2ldr.mbr

=== added file 'Makefile.core.def'

Makefile.core.def +21 -0
@@ -0,0 +1,21 @@
+AutoGen definitions Makefile.tpl;
+
+image = {
+  name = g2hdr;
+  i386_pc = contrib/ntldr-img/g2hdr.S;
+  i386_pc_ldflags = '$(TARGET_IMG_LDFLAGS)';
+  i386_pc_ldflags = '$(TARGET_IMG_BASE_LDOPT),0x0';
+  objcopyflags = '-O binary';
+  enable = i386_pc;
+};
+
+image = {
+  name = grldr;
+  i386_pc = contrib/ntldr-img/grldrstart.S;
+  i386_pc = contrib/ntldr-img/ntfsbs.S;
+  i386_pc_ccasflags = -DGRLDR_MBR;
+  i386_pc_ldflags = '$(TARGET_IMG_LDFLAGS)';
+  i386_pc_ldflags = '$(TARGET_IMG_BASE_LDOPT),0x7c00';
+  objcopyflags = '-O binary';
+  enable = i386_pc;
+};

=== removed directory 'conf'
=== removed file 'conf/common.rmk'

common.rmk +0 -2
@@ -1,2 +0,0 @@
-# -*- makefile -*-
--include $(GRUB_CONTRIB)/ntldr-img/conf/$(target_cpu)-$(platform).mk

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

i386-pc.rmk +0 -37
@@ -1,37 +0,0 @@
-# -*- makefile -*-
-
-pkglib_IMAGES += g2ldr.mbr g2hdr.bin grldr.img
-
-all: g2ldr.mbr g2hdr.bin
-
-DISTCLEANFILES += g2ldr.mbr g2hdr.bin
-
-g2hdr_bin_SOURCES = $(GRUB_CONTRIB)/ntldr-img/g2hdr.S
-g2hdr_bin_ASFLAGS = $(COMMON_ASFLAGS)
-g2hdr_bin_LDFLAGS = $(COMMON_LDFLAGS) $(TARGET_IMG_LDFLAGS)0x0
-g2hdr_bin_FORMAT = binary
-
-grldr_img_SOURCES = $(GRUB_CONTRIB)/ntldr-img/grldrstart.S $(GRUB_CONTRIB)/ntldr-img/ntfsbs.S
-grldr_img_ASFLAGS = $(COMMON_ASFLAGS) -DGRLDR_MBR
-grldr_img_LDFLAGS = $(COMMON_LDFLAGS) $(TARGET_IMG_LDFLAGS)0x7c00
-grldr_img_FORMAT = binary
-
-grldr.mbr: grldr.img
-	head -c 8192 $< > $@
-DISTCLEANFILES += grldr.mbr
-
-bin2h: $(GRUB_CONTRIB)/ntldr-img/bin2h.c
-	$(CC) $^ -o $@
-DISTCLEANFILES += bin2h
-
-grub_mbr.h: grldr.mbr bin2h
-	./bin2h grub_mbr 8192 < $< > $@
-DISTCLEANFILES += grub_mbr.h
-
-grubinst: $(GRUB_CONTRIB)/ntldr-img/grubinst.c $(GRUB_CONTRIB)/ntldr-img/utils.c grub_mbr.h
-	$(CC) -I. -I$(GRUB_CONTRIB)/ntldr-img -DLINUX -o $@ $(GRUB_CONTRIB)/ntldr-img/grubinst.c $(GRUB_CONTRIB)/ntldr-img/utils.c
-DISTCLEANFILES += grubinst
-
-g2ldr.mbr: grubinst
-	./grubinst --grub2 -o $@
-DISTCLEANFILES += g2ldr.mbr

=== added file '.bzrignore'

.bzrignore +5 -0
@@ -0,0 +1,5 @@
+**/.deps-core
+**/.deps-util
+**/.dirstamp
+Makefile.core.am
+Makefile.util.am

=== added file 'Makefile.common'

Makefile.common +2 -0
@@ -0,0 +1,2 @@
+ZFS_CPPFLAGS = -Icontrib/zfs/include
+ZFS_CFLAGS = -Wno-error

=== added file 'Makefile.core.def'

Makefile.core.def +18 -0
@@ -0,0 +1,18 @@
+AutoGen definitions Makefile.tpl;
+
+module = {
+  name = zfs;
+  common = contrib/zfs/zfs.c;
+  common = contrib/zfs/zfs_lzjb.c;
+  common = contrib/zfs/zfs_sha256.c;
+  common = contrib/zfs/zfs_fletcher.c;
+  cppflags = '$(ZFS_CPPFLAGS)';
+  cflags = '$(ZFS_CFLAGS)';
+};
+
+module = {
+  name = zfsinfo;
+  common = contrib/zfs/zfsinfo.c;
+  cppflags = '$(ZFS_CPPFLAGS)';
+  cflags = '$(ZFS_CFLAGS)';
+};

=== added file 'Makefile.util.def'

Makefile.util.def +11 -0
@@ -0,0 +1,11 @@
+AutoGen definitions Makefile.tpl;
+
+library = {
+  name = libgrub.a;
+  common = contrib/zfs/zfs.c;
+  common = contrib/zfs/zfs_lzjb.c;
+  common = contrib/zfs/zfs_sha256.c;
+  common = contrib/zfs/zfs_fletcher.c;
+  cppflags = '$(ZFS_CPPFLAGS)';
+  cflags = '$(ZFS_CFLAGS)';
+};

=== removed directory 'conf'
=== removed file 'conf/common.rmk'

common.rmk +0 -13
@@ -1,13 +0,0 @@
-# -*- makefile -*-
-
-COMMON_CFLAGS += -I$(GRUB_CONTRIB)/zfs/include
-
-pkglib_MODULES += zfs.mod
-zfs_mod_SOURCES = $(GRUB_CONTRIB)/zfs/zfs.c $(GRUB_CONTRIB)/zfs/zfs_lzjb.c $(GRUB_CONTRIB)/zfs/zfs_sha256.c $(GRUB_CONTRIB)/zfs/zfs_fletcher.c
-zfs_mod_CFLAGS = $(COMMON_CFLAGS) -Wno-error
-zfs_mod_LDFLAGS = $(COMMON_LDFLAGS)
-
-pkglib_MODULES += zfsinfo.mod
-zfsinfo_mod_SOURCES = $(GRUB_CONTRIB)/zfs/zfsinfo.c
-zfsinfo_mod_CFLAGS = $(COMMON_CFLAGS) -Wno-error
-zfsinfo_mod_LDFLAGS = $(COMMON_LDFLAGS)
#3 lore raw
Quoted 4 lines · Colin Watson
Quoted 1 line · Colin Watson

Once again, the required patches to grub-extras modules are attached.

No, really! Here they are.

At Keshav's request, I made sure 'make install' worked properly. This required one additional change to gpxe, and the updated patch for that is attached (commenting out gpxe_depca since it doesn't build anything useful).

Keshav asked on IRC whether grubinst could be installed. This would probably be a one-liner, but I wanted to check if other developers thought that was OK. I do know that Wubi uses its own build of grubinst (it runs it itself so that it can pass the --boot-file option), so maybe this would indeed be something users of the ntldr-img extra module would like to have. I think it's enough of a corner case that it should go in pkglib_PROGRAMS or something, though - I'd prefer not to get people confused between grubinst and grub-install.

Any objections?

Signature · 1 line
Colin Watson                                       [[email protected]]

=== modified file '.bzrignore'

.bzrignore +3 -1
@@ -1 +1,3 @@
-conf/common.mk
+**/.deps-core
+**/.dirstamp
+Makefile.core.am

=== added file 'Makefile.common'

Makefile.common +2 -0
@@ -0,0 +1,2 @@
+GPXE_CPPFLAGS = '-DFILE_LICENCE(x)=' -Icontrib/gpxe/src/include -Icontrib/gpxe/include_wrap
+GPXE_CFLAGS = -Wno-pointer-arith -Wno-error

=== added file 'Makefile.core.def'

Makefile.core.def +434 -0

434 lines not on this page · raw message

=== removed directory 'conf'
=== removed file 'conf/common.rmk'

common.rmk +0 -323

323 lines not on this page · raw message

#4 lore raw
In reply to Colin Watson

Go ahead for both trunk and extras

Quoted 444 lines · Colin Watson
Quoted 3 lines · Colin Watson

Here's a patch to re-enable grub-extras by allowing extra modules to provide Autogen definitions files. A few things to note:

Vladimir commented on this on IRC, noting three problems. In reverse order of complexity:

1) The GRUB_CONTRIB check in autogen.sh should also check for grub-core/contrib.

Fixed.

2) What's the problem with renaming g2hdr.bin to g2hdr.img?

I know of at least one piece of software which expects the current file
name: win32-loader, written by Robert and maintained in Debian. It probably wouldn't be completely awful to change this, but it would be nice not to need to. That said, perhaps g2hdr.bin could be a symlink to g2hdr.img (which could be done in Makefile.common). I've updated my patch to do this, and removed the extension-override facility from gentpl.py.

3) It would be nice if extra modules could add new sources to existing targets defined in one of the main definitions files: for example, it would be useful to be able to add zfs to libgrub.a.

This was the hard bit that took me a day or two to fix.

Vladimir's original suggestion on IRC was to create a separate libgrubzfs.a and arrange to link the utilities with that as well. When I looked into this, I decided that I didn't like this approach because it simply pushes the problem of appending to an existing list up a level; as far as the Autogen definitions go, there isn't a significant difference between appending to grub_probe_LDADD and appending to libgrub_a_SOURCES. I would prefer to solve this some other way.

My preferred approach is to try not to expose any of the difficulties in the definitions file, so that it can just look like this:

  library = {
    name = libgrub.a;
    common = contrib/zfs/zfs.c;
    common = contrib/zfs/zfs_lzjb.c;
    common = contrib/zfs/zfs_sha256.c;
    common = contrib/zfs/zfs_fletcher.c;
    cppflags = '$(ZFS_CPPFLAGS)';
    cflags = '$(ZFS_CFLAGS)';
  };

Doing this actually turned out to be very difficult because Autogen's native macros aren't powerful enough: they can only really emit text rather than using temporary storage, which means that you can't do things like "look for all the library blocks with the same name and concatenate them" or "append to _SOURCES variables if we've seen them before". Some Automake variables can be handled with simple appends while some of them have some boilerplate only at the start which shouldn't be repeated; Automake variables must be initialised exactly once on all possible intersections of conditional paths; and we should also avoid generating duplicate rules. All these constraints make it a hard problem.

Fortunately, Autogen supports embedding bits of Guile, which makes the problem merely hard rather than impossible. I tried a few different approaches, and the one that I found to be most practical is in the following patch: effectively we remember whether we've seen a given target before and treat it slightly differently, and furthermore we emit initialisations for non-global variables to avoid problems with Automake's restrictions on variable initialisation.

For now, I only implemented this for 'library' blocks, so something that wants to compile extra files into the GRUB kernel for example will be out of luck. If people feel this is an onerous restriction then it's fairly easy to fix; I was just trying not to change too much at once, particularly for paths I wasn't going to test.

Doing this involved feeding all the files relevant to a given Automake input stream to Autogen in one go, so I eliminated Makefile.gcry.am.

This was an exercise in programming in six languages at once (Python, Autogen native macros, Guile, Autogen definitions, Automake, and make). I found it to be a bit much, and my impression is that Autogen got in the way more than it helped. I suggest that after 1.99 we should look at having a Python program generate Automake input directly, which would avoid many contortions and allow us to improve the output (it could merge the multiple _SOURCES lines into just one per conditional path, for instance). The .def file format is of course just fine as it is, and could easily be preserved.

Quoted 4 lines

* Extra modules may also provide Makefile.common with literal Automake input, for those cases where it's too hard to cram things into Autogen.

I also added Makefile.core.common and Makefile.util.common (starting to run out of good names) for literal Automake input that should only be used in grub-core or at the top level respectively. ntldr-img needed the former.

Once again, the required patches to grub-extras modules are attached.

2010-09-22 Colin Watson <[email protected]>

Re-enable grub-extras.

* autogen.sh: Create symlinks to ${GRUB_CONTRIB} if necessary to avoid confusing Automake. Run autogen only twice, once for the top level and once for grub-core. Add Makefile.util.def and Makefile.core.def from extra modules to the appropriate autogen invocations. If Makefile.common exists in an extra module, include it in both Makefile.util.am and grub-core/Makefile.core.am; similarly, include any Makefile.util.common file in Makefile.util.am and any Makefile.core.common file in grub-core/Makefile.core.am.
* conf/Makefile.common ($(top_srcdir)/grub-core/Makefile.core.am):
Depend on $(top_srcdir)/grub-core/Makefile.gcry.def. ($(top_srcdir)/grub-core/Makefile.gcry.def): Remove.
* grub-core/Makefile.am: Remove inclusion of Makefile.gcry.am.

* gentpl.py (gvar_add): Turn GVARS into a set. (global_variable_initializers): Sort global variables on output. (vars_init): New function.
(first_time): Likewise.
(library): Ensure that non-global variable initialisations are emitted before the first time we emit code for a library block. Append to variables rather than setting them. Only emit noinst_LIBRARIES, BUILT_SOURCES, and CLEANFILES the first time for each conditional path.
(program): installdir() emits an Autogen macro, so must be passed to var_add rather than gvar_add.
(data): Likewise.
(script): Likewise.
(rules): New function, centralising handling for different target types. Set up Guile association lists for first_time and vars_init, and send most output to a diversion so that variable initialisations can be emitted first.
(module_rules): Use new rules function.
(kernel_rules): Likewise.
(image_rules): Likewise.
(library_rules): Likewise.
(program_rules): Likewise.
(script_rules): Likewise.
(data_rules): Likewise.

* configure.ac: Add AC_PROG_LN_S, for the benefit of ntldr-img.

* .bzrignore: Add contrib and grub-core/contrib. Remove grub-core/Makefile.gcry.am.

=== modified file '.bzrignore'

.bzrignore +2 -1
@@ -104,9 +104,10 @@ grub-core/lib/libgcrypt-grub
 **/.deps-core
 **/.dirstamp
 Makefile.util.am
+contrib
 grub-core/Makefile.core.am
-grub-core/Makefile.gcry.am
 grub-core/Makefile.gcry.def
+grub-core/contrib
 grub-core/genmod.sh
 grub-core/gensyminfo.sh
 grub-core/*.module

=== modified file 'autogen.sh'

autogen.sh +44 -3
@@ -14,9 +14,50 @@ echo "Creating Makefile.tpl..."
 python gentpl.py | sed -e '/^$/{N;/^\n$/D;}' > Makefile.tpl
 
 echo "Running autogen..."
-autogen -T Makefile.tpl Makefile.util.def | sed -e '/^$/{N;/^\n$/D;}' > Makefile.util.am
-autogen -T Makefile.tpl grub-core/Makefile.core.def | sed -e '/^$/{N;/^\n$/D;}' > grub-core/Makefile.core.am
-autogen -T Makefile.tpl grub-core/Makefile.gcry.def | sed -e '/^$/{N;/^\n$/D;}' > grub-core/Makefile.gcry.am
+
+# Automake doesn't like including files from a path outside the project.
+rm -f contrib grub-core/contrib
+if [ "x${GRUB_CONTRIB}" != x ]; then
+  [ "${GRUB_CONTRIB}" = contrib ] || ln -s "${GRUB_CONTRIB}" contrib
+  [ "${GRUB_CONTRIB}" = grub-core/contrib ] || ln -s ../contrib grub-core/contrib
+fi
+
+UTIL_DEFS=Makefile.util.def
+CORE_DEFS='grub-core/Makefile.core.def grub-core/Makefile.gcry.def'
+
+for extra in contrib/*/Makefile.util.def; do
+  if test -e "$extra"; then
+    UTIL_DEFS="$UTIL_DEFS $extra"
+  fi
+done
+
+for extra in contrib/*/Makefile.core.def; do
+  if test -e "$extra"; then
+    CORE_DEFS="$CORE_DEFS $extra"
+  fi
+done
+
+cat $UTIL_DEFS | autogen -T Makefile.tpl | sed -e '/^$/{N;/^\n$/D;}' > Makefile.util.am
+cat $CORE_DEFS | autogen -T Makefile.tpl | sed -e '/^$/{N;/^\n$/D;}' > grub-core/Makefile.core.am
+
+for extra in contrib/*/Makefile.common; do
+  if test -e "$extra"; then
+    echo "include $extra" >> Makefile.util.am
+    echo "include $extra" >> grub-core/Makefile.core.am
+  fi
+done
+
+for extra in contrib/*/Makefile.util.common; do
+  if test -e "$extra"; then
+    echo "include $extra" >> Makefile.util.am
+  fi
+done
+
+for extra in contrib/*/Makefile.core.common; do
+  if test -e "$extra"; then
+    echo "include $extra" >> grub-core/Makefile.core.am
+  fi
+done
 
 echo "Saving timestamps..."
 echo timestamp > stamp-h.in

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

Makefile.common +3 -7
@@ -146,11 +146,7 @@ $(top_srcdir)/Makefile.util.am: $(top_sr
 	mv [email protected] $@
 
 .PRECIOUS: $(top_srcdir)/grub-core/Makefile.core.am
-$(top_srcdir)/grub-core/Makefile.core.am: $(top_srcdir)/grub-core/Makefile.core.def $(top_srcdir)/Makefile.tpl
-	autogen -T $(top_srcdir)/Makefile.tpl $< | sed -e '/^$$/{N;/^\\n$$/D;}' > [email protected] || (rm -f [email protected]; exit 1)
-	mv [email protected] $@
-
-.PRECIOUS: $(top_srcdir)/grub-core/Makefile.gcry.am
-$(top_srcdir)/grub-core/Makefile.gcry.am: $(top_srcdir)/grub-core/Makefile.gcry.def $(top_srcdir)/Makefile.tpl
-	autogen -T $(top_srcdir)/Makefile.tpl $< | sed -e '/^$$/{N;/^\\n$$/D;}' > [email protected] || (rm -f [email protected]; exit 1)
+$(top_srcdir)/grub-core/Makefile.core.am: $(top_srcdir)/grub-core/Makefile.core.def $(top_srcdir)/grub-core/Makefile.gcry.def $(top_srcdir)/Makefile.tpl
+	if [ "x$$GRUB_CONTRIB" != x ]; then echo "You need to run ./autogen.sh manually." >&2; exit 1; fi
+	autogen -T $(top_srcdir)/Makefile.tpl $(top_srcdir)/grub-core/Makefile.core.def $(top_srcdir)/grub-core/Makefile.gcry.def | sed -e '/^$$/{N;/^\\n$$/D;}' > [email protected] || (rm -f [email protected]; exit 1)
 	mv [email protected] $@

=== modified file 'configure.ac'

configure.ac +1 -0
@@ -235,6 +235,7 @@ AC_PROG_LEX
 AC_PROG_YACC
 AC_PROG_MAKE_SET
 AC_PROG_MKDIR_P
+AC_PROG_LN_S
 
 if test "x$LEX" = "x:"; then
   AC_MSG_ERROR([flex is not found])

=== modified file 'gentpl.py'

gentpl.py +66 -31
@@ -70,16 +70,15 @@ for platform in GRUB_PLATFORMS:
 #
 # Global variables
 #
-GVARS = []
+GVARS = set()
 
 def gvar_add(var, value):
-    if var not in GVARS:
-        GVARS.append(var)
+    GVARS.add(var)
     return var + " += " + value + "\n"
 
 def global_variable_initializers():
     r = ""
-    for var in GVARS:
+    for var in sorted(GVARS):
         r += var + " ?= \n"
     return r
 
@@ -87,6 +86,16 @@ def global_variable_initializers():
 # Per PROGRAM/SCRIPT variables 
 #
 
+def vars_init(*var_list):
+    r = "[+ IF (if (not (assoc-ref seen-vars (get \".name\"))) \"seen\") +]"
+    r += "[+ (out-suspend \"v\") +]"
+    for var in var_list:
+        r += var + "  = \n"
+    r += "[+ (out-resume \"v\") +]"
+    r += "[+ (set! seen-vars (assoc-set! seen-vars (get \".name\") 0)) +]"
+    r += "[+ ENDIF +]"
+    return first_time(r)
+
 def var_set(var, value):
     return var + "  = " + value + "\n"
 
@@ -257,6 +266,15 @@ def platform_ccasflags(p): return platfo
 def platform_stripflags(p): return platform_specific_values(p, "_stripflags", "stripflags")
 def platform_objcopyflags(p): return platform_specific_values(p, "_objcopyflags", "objcopyflags")
 
+#
+# Emit snippet only the first time through for the current name.
+#
+def first_time(snippet):
+    r = "[+ IF (if (not (assoc-ref seen-target (get \".name\"))) \"seen\") +]"
+    r += snippet
+    r += "[+ ENDIF +]"
+    return r
+
 def module(platform):
     r = set_canonical_name_suffix(".module")
 
@@ -341,18 +359,25 @@ fi
 
 def library(platform):
     r = set_canonical_name_suffix("")
-    r += gvar_add("noinst_LIBRARIES", "[+ name +]")
-    r += var_set(cname() + "_SOURCES", platform_sources(platform))
-    r += var_set("nodist_" + cname() + "_SOURCES", platform_nodist_sources(platform))
-    r += var_set(cname() + "_CFLAGS", "$(AM_CFLAGS) $(CFLAGS_LIBRARY) " + platform_cflags(platform))
-    r += var_set(cname() + "_CPPFLAGS", "$(AM_CPPFLAGS) $(CPPFLAGS_LIBRARY) " + platform_cppflags(platform))
-    r += var_set(cname() + "_CCASFLAGS", "$(AM_CCASFLAGS) $(CCASFLAGS_LIBRARY) " + platform_ccasflags(platform))
-    # r += var_set(cname() + "_DEPENDENCIES", platform_dependencies(platform) + " " + platform_ldadd(platform))
 
-    r += gvar_add("EXTRA_DIST", extra_dist())
-    r += gvar_add("BUILT_SOURCES", "$(nodist_" + cname() + "_SOURCES)")
-    r += gvar_add("CLEANFILES", "$(nodist_" + cname() + "_SOURCES)")
+    r += vars_init(cname() + "_SOURCES",
+                   "nodist_" + cname() + "_SOURCES",
+                   cname() + "_CFLAGS",
+                   cname() + "_CPPFLAGS",
+                   cname() + "_CCASFLAGS")
+    #              cname() + "_DEPENDENCIES")
 
+    r += first_time(gvar_add("noinst_LIBRARIES", "[+ name +]"))
+    r += var_add(cname() + "_SOURCES", platform_sources(platform))
+    r += var_add("nodist_" + cname() + "_SOURCES", platform_nodist_sources(platform))
+    r += var_add(cname() + "_CFLAGS", first_time("$(AM_CFLAGS) $(CFLAGS_LIBRARY) ") + platform_cflags(platform))
+    r += var_add(cname() + "_CPPFLAGS", first_time("$(AM_CPPFLAGS) $(CPPFLAGS_LIBRARY) ") + platform_cppflags(platform))
+    r += var_add(cname() + "_CCASFLAGS", first_time("$(AM_CCASFLAGS) $(CCASFLAGS_LIBRARY) ") + platform_ccasflags(platform))
+    # r += var_add(cname() + "_DEPENDENCIES", platform_dependencies(platform) + " " + platform_ldadd(platform))
+
+    r += gvar_add("EXTRA_DIST", extra_dist())
+    r += first_time(gvar_add("BUILT_SOURCES", "$(nodist_" + cname() + "_SOURCES)"))
+    r += first_time(gvar_add("CLEANFILES", "$(nodist_" + cname() + "_SOURCES)"))
     return r
 
 def installdir(default="bin"):
@@ -376,7 +401,7 @@ def program(platform, test=False):
     r += gvar_add("check_PROGRAMS", "[+ name +]")
     r += gvar_add("TESTS", "[+ name +]")
     r += "[+ ELSE +]"
-    r += gvar_add(installdir() + "_PROGRAMS", "[+ name +]")
+    r += var_add(installdir() + "_PROGRAMS", "[+ name +]")
     r += "[+ IF mansection +]" + manpage() + "[+ ENDIF +]"
     r += "[+ ENDIF +]"
 
@@ -397,7 +422,7 @@ def program(platform, test=False):
 def data(platform):
     r  = gvar_add("EXTRA_DIST", platform_sources(platform))
     r += gvar_add("EXTRA_DIST", extra_dist())
-    r += gvar_add(installdir() + "_DATA", platform_sources(platform))
+    r += var_add(installdir() + "_DATA", platform_sources(platform))
     return r
 
 def script(platform):
@@ -405,7 +430,7 @@ def script(platform):
     r += gvar_add("check_SCRIPTS", "[+ name +]")
     r += gvar_add ("TESTS", "[+ name +]")
     r += "[+ ELSE +]"
-    r += gvar_add(installdir() + "_SCRIPTS", "[+ name +]")
+    r += var_add(installdir() + "_SCRIPTS", "[+ name +]")
     r += "[+ IF mansection +]" + manpage() + "[+ ENDIF +]"
     r += "[+ ENDIF +]"
 
@@ -418,33 +443,43 @@ chmod a+x [+ name +]
     r += gvar_add("dist_noinst_DATA", platform_sources(platform))
     return r
 
+def rules(target, closure):
+    # Create association lists for the benefit of first_time and vars_init.
+    r = "[+ (define seen-target '()) +]"
+    r += "[+ (define seen-vars '()) +]"
+    # Most output goes to a diversion.  This allows us to emit variable
+    # initializations before everything else.
+    r += "[+ (out-push-new) +]"
+
+    r += "[+ FOR " + target + " +]"
+    r += foreach_enabled_platform(
+        lambda p: under_platform_specific_conditionals(p, closure(p)))
+    # Remember that we've seen this target.
+    r += "[+ (set! seen-target (assoc-set! seen-target (get \".name\") 0)) +]"
+    r += "[+ ENDFOR +]"
+    r += "[+ (out-pop #t) +]"
+    return r
+
 def module_rules():
-    return "[+ FOR module +]" + foreach_enabled_platform(
-        lambda p: under_platform_specific_conditionals(p, module(p))) + "[+ ENDFOR +]"
+    return rules("module", module)
 
 def kernel_rules():
-    return "[+ FOR kernel +]" + foreach_enabled_platform(
-        lambda p: under_platform_specific_conditionals(p, kernel(p))) + "[+ ENDFOR +]"
+    return rules("kernel", kernel)
 
 def image_rules():
-    return "[+ FOR image +]" + foreach_enabled_platform(
-        lambda p: under_platform_specific_conditionals(p, image(p))) + "[+ ENDFOR +]"
+    return rules("image", image)
 
 def library_rules():
-    return "[+ FOR library +]" + foreach_enabled_platform(
-        lambda p: under_platform_specific_conditionals(p, library(p))) + "[+ ENDFOR +]"
+    return rules("library", library)
 
 def program_rules():
-    return "[+ FOR program +]" + foreach_enabled_platform(
-        lambda p: under_platform_specific_conditionals(p, program(p))) + "[+ ENDFOR +]"
+    return rules("program", program)
 
 def script_rules():
-    return "[+ FOR script +]" + foreach_enabled_platform(
-        lambda p: under_platform_specific_conditionals(p, script(p))) + "[+ ENDFOR +]"
+    return rules("script", script)
 
 def data_rules():
-    return "[+ FOR data +]" + foreach_enabled_platform(
-        lambda p: under_platform_specific_conditionals(p, data(p))) + "[+ ENDFOR +]"
+    return rules("data", data)
 
 print "[+ AutoGen5 template +]\n"
 a = module_rules()

=== modified file 'grub-core/Makefile.am'

Makefile.am +0 -1
@@ -51,7 +51,6 @@ grub_script.yy.c: grub_script.yy.h
 CLEANFILES += grub_script.yy.c grub_script.yy.h
 
 include $(srcdir)/Makefile.core.am
-include $(srcdir)/Makefile.gcry.am
 
 KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/cache.h
 KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/command.h
Signature · 2 lines
Regards
Vladimir 'φ-coder/phcoder' Serbinenko
#5 lore raw
Quoted 1 line · Vladimir 'φ-coder/phcoder' Serbinenko

Go ahead for both trunk and extras

Thanks. I've committed all this now. Note that this means that grub-extras is no longer compatible with 1.98; there were some modules where the contortions required to do that would have been too complicated, such as lua where some of the interfaces it was using in GRUB proper changed. I hope this doesn't inconvenience anyone too much (I know Robert has been hacking on the zfs module quite a bit), but it doesn't seem too unreasonable given that 1.99 is close to release. If you need 1.98-compatible code, I suggest either using the 1.98 tag in each module, or making a branch.

The grubinst question remains slightly open; rough consensus on IRC seems to be to rename it to grub-mkntldrimg and install it, but I haven't got round to this yet.

Signature · 1 line
Colin Watson                                       [[email protected]]
#6 lore raw

PATCH 1/1 Trunk: usbtrans.c - wrong max packet size for bulk transfer

In reply to Colin Watson

Hi,

I discovered problem which happens if bulk EP has shorter wMaxPacketSize value than control (zero) EP.
There was bug in usbtrans.c, see patch.

Another problem happens when bulk EP has wMaxPacketSize <= 16 - in this case transfer error happens because it is not possible to allocate sufficient number of TDs.
It can happen - according USB1.1 specification, any bulk EP can have wMaxPacketSize value equal to 8, 16, 32 or 64 (USB 2.0 capable bulk EP can have 512).
So I increased number of TDs in UHCI and OHCI driver to 640 - it should be enough for the worse case wMaxPacketSize=8, with some reserve for "background" communication.

I successfully tested included patch on UHCI with GARMIN OREGON 300 which has:
EP1 (OUT) wMaxPacketSize = 64
EP3 (IN) wMaxPacketSize = 16
(i.e. this device is related to both problems)

Regards
Ales

grub_patched/grub-core/bus/usb/ohci.c renamed from grub/grub-core/bus/usb/ohci.c +1 -1
diff -urB ./grub/grub-core/bus/usb/ohci.c ./grub_patched/grub-core/bus/usb/ohci.c
@@ -150,7 +150,7 @@
 #define GRUB_OHCI_RESET_CONNECT_CHANGE (1 << 16)
 #define GRUB_OHCI_CTRL_EDS 256
 #define GRUB_OHCI_BULK_EDS 510
-#define GRUB_OHCI_TDS 256
+#define GRUB_OHCI_TDS 640
 
 #define GRUB_OHCI_ED_ADDR_MASK 0x7ff
 
grub_patched/grub-core/bus/usb/uhci.c renamed from grub/grub-core/bus/usb/uhci.c +5 -4
diff -urB ./grub/grub-core/bus/usb/uhci.c ./grub_patched/grub-core/bus/usb/uhci.c
@@ -29,6 +29,7 @@
 #define GRUB_UHCI_IOMASK	(0x7FF << 5)
 
 #define N_QH  256
+#define N_TD  640
 
 typedef enum
   {
@@ -105,7 +106,7 @@
   /* N_QH Queue Heads.  */
   grub_uhci_qh_t qh;
 
-  /* 256 Transfer Descriptors.  */
+  /* N_TD Transfer Descriptors.  */
   grub_uhci_td_t td;
 
   /* Free Transfer Descriptors.  */
@@ -227,7 +228,7 @@
 
   /* The TD pointer of UHCI is only 32 bits, make sure this
      code works on on 64 bits architectures.  */
-  u->td = (grub_uhci_td_t) grub_memalign (4096, 4096*2);
+  u->td = (grub_uhci_td_t) grub_memalign (4096, 32*N_TD);
   if (! u->td)
     goto fail;
 
@@ -244,9 +245,9 @@
 
   /* Link all Transfer Descriptors in a list of available Transfer
      Descriptors.  */
-  for (i = 0; i < 256; i++)
+  for (i = 0; i < N_TD; i++)
     u->td[i].linkptr = (grub_uint32_t) (grub_addr_t) &u->td[i + 1];
-  u->td[255 - 1].linkptr = 0;
+  u->td[N_TD - 2].linkptr = 0;
   u->tdfree = u->td;
 
   /* Make sure UHCI is disabled!  */
grub_patched/grub-core/bus/usb/usbtrans.c renamed from grub/grub-core/bus/usb/usbtrans.c +1 -1
diff -urB ./grub/grub-core/bus/usb/usbtrans.c ./grub_patched/grub-core/bus/usb/usbtrans.c
@@ -228,7 +228,7 @@
   if (dev->initialized)
     {
       struct grub_usb_desc_endp *endpdesc;
-      endpdesc = grub_usb_get_endpdescriptor (dev, 0);
+      endpdesc = grub_usb_get_endpdescriptor (dev, endpoint);
 
       if (endpdesc)
 	max = endpdesc->maxpacket;
#7 lore raw

Re: [PATCH] Trunk: usbtrans.c - wrong max packet size for bulk transfer

grub_patched/grub-core/bus/usb/uhci.c line 233

Quoted 6 lines · Aleš Nesrsta

code works on on 64 bits architectures. */

grub_patched/grub-core/bus/usb/uhci.c renamed from grub/grub-core/bus/usb/uhci.c +1 -1
-  u->td = (grub_uhci_td_t) grub_memalign (4096, 4096*2);
+  u->td = (grub_uhci_td_t) grub_memalign (4096, 32*N_TD);
   if (! u->td)
     goto fail;

Could you use sizeof while on it?

- endpdesc = grub_usb_get_endpdescriptor (dev, 0);
+ endpdesc = grub_usb_get_endpdescriptor (dev, endpoint);
It's hard to see the context of this change. Could you use --diff-options=-p in the future? Other than that this patch is ok for trunk

Signature · 2 lines
Regards
Vladimir 'φ-coder/phcoder' Serbinenko
#8 lore raw

Re: [PATCH] Trunk: usbtrans.c - wrong max packet size for bulk transfer

Quoted 11 lines · Vladimir 'φ-coder/phcoder' Serbinenko

Review

Quoted 6 lines · Aleš Nesrsta

code works on on 64 bits architectures. */

(quoted diff) +1 -1
-  u->td = (grub_uhci_td_t) grub_memalign (4096, 4096*2);
+  u->td = (grub_uhci_td_t) grub_memalign (4096, 32*N_TD);
   if (! u->td)
     goto fail;

Could you use sizeof while on it?

(quoted diff) +1 -1
-      endpdesc = grub_usb_get_endpdescriptor (dev, 0);
+      endpdesc = grub_usb_get_endpdescriptor (dev, endpoint);
Quoted 2 lines

It's hard to see the context of this change. Could you use --diff-options=-p in the future? Other than that this patch is ok for trunk

Hi,
there is corrected patch (with sizeof and -p) for review before going to trunk.
Regards
Ales

grub_patched/grub-core/bus/usb/ohci.c renamed from grub/grub-core/bus/usb/ohci.c +1 -1
diff -purB ./grub/grub-core/bus/usb/ohci.c ./grub_patched/grub-core/bus/usb/ohci.c
@@ -150,7 +150,7 @@ typedef enum
 #define GRUB_OHCI_RESET_CONNECT_CHANGE (1 << 16)
 #define GRUB_OHCI_CTRL_EDS 256
 #define GRUB_OHCI_BULK_EDS 510
-#define GRUB_OHCI_TDS 256
+#define GRUB_OHCI_TDS 640
 
 #define GRUB_OHCI_ED_ADDR_MASK 0x7ff
 
grub_patched/grub-core/bus/usb/uhci.c renamed from grub/grub-core/bus/usb/uhci.c +6 -5
diff -purB ./grub/grub-core/bus/usb/uhci.c ./grub_patched/grub-core/bus/usb/uhci.c
@@ -29,6 +29,7 @@
 #define GRUB_UHCI_IOMASK	(0x7FF << 5)
 
 #define N_QH  256
+#define N_TD  640
 
 typedef enum
   {
@@ -105,7 +106,7 @@ struct grub_uhci
   /* N_QH Queue Heads.  */
   grub_uhci_qh_t qh;
 
-  /* 256 Transfer Descriptors.  */
+  /* N_TD Transfer Descriptors.  */
   grub_uhci_td_t td;
 
   /* Free Transfer Descriptors.  */
@@ -213,7 +214,7 @@ grub_uhci_pci_iter (grub_pci_device_t de
 
   /* The QH pointer of UHCI is only 32 bits, make sure this
      code works on on 64 bits architectures.  */
-  u->qh = (grub_uhci_qh_t) grub_memalign (4096, 4096);
+  u->qh = (grub_uhci_qh_t) grub_memalign (4096, sizeof(struct grub_uhci_qh)*N_QH);
   if (! u->qh)
     goto fail;
 
@@ -227,7 +228,7 @@ grub_uhci_pci_iter (grub_pci_device_t de
 
   /* The TD pointer of UHCI is only 32 bits, make sure this
      code works on on 64 bits architectures.  */
-  u->td = (grub_uhci_td_t) grub_memalign (4096, 4096*2);
+  u->td = (grub_uhci_td_t) grub_memalign (4096, sizeof(struct grub_uhci_td)*N_TD);
   if (! u->td)
     goto fail;
 
@@ -244,9 +245,9 @@ grub_uhci_pci_iter (grub_pci_device_t de
 
   /* Link all Transfer Descriptors in a list of available Transfer
      Descriptors.  */
-  for (i = 0; i < 256; i++)
+  for (i = 0; i < N_TD; i++)
     u->td[i].linkptr = (grub_uint32_t) (grub_addr_t) &u->td[i + 1];
-  u->td[255 - 1].linkptr = 0;
+  u->td[N_TD - 2].linkptr = 0;
   u->tdfree = u->td;
 
   /* Make sure UHCI is disabled!  */
grub_patched/grub-core/bus/usb/usbtrans.c renamed from grub/grub-core/bus/usb/usbtrans.c +1 -1
diff -purB ./grub/grub-core/bus/usb/usbtrans.c ./grub_patched/grub-core/bus/usb/usbtrans.c
@@ -228,7 +228,7 @@ grub_usb_bulk_setup_readwrite (grub_usb_
   if (dev->initialized)
     {
       struct grub_usb_desc_endp *endpdesc;
-      endpdesc = grub_usb_get_endpdescriptor (dev, 0);
+      endpdesc = grub_usb_get_endpdescriptor (dev, endpoint);
 
       if (endpdesc)
 	max = endpdesc->maxpacket;
#9 lore raw

Re: [PATCH] Trunk: usbtrans.c - wrong max packet size for bulk transfer

Quoted 18 lines · Aleš Nesrsta
Quoted 13 lines · Vladimir 'φ-coder/phcoder' Serbinenko

grub_patched/grub-core/bus/usb/uhci.c grub_uhci_pci_iter (grub_pci_device_t de · line 233

Quoted 7 lines · Aleš Nesrsta

code works on on 64 bits architectures. */

grub_patched/grub-core/bus/usb/uhci.c renamed from grub/grub-core/bus/usb/uhci.c +1 -1
-  u->td = (grub_uhci_td_t) grub_memalign (4096, 4096*2);
+  u->td = (grub_uhci_td_t) grub_memalign (4096, 32*N_TD);
   if (! u->td)
     goto fail;

Could you use sizeof while on it?

grub_patched/grub-core/bus/usb/usbtrans.c renamed from grub/grub-core/bus/usb/usbtrans.c +1 -1
-      endpdesc = grub_usb_get_endpdescriptor (dev, 0);
+      endpdesc = grub_usb_get_endpdescriptor (dev, endpoint);
Quoted 3 lines

It's hard to see the context of this change. Could you use --diff-options=-p in the future? Other than that this patch is ok for trunk

Quoted 7 lines

Hi,
there is corrected patch (with sizeof and -p) for review before going to trunk.
Regards
Ales

Go ahead

Quoted 7 lines

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

Signature · 2 lines
Regards
Vladimir 'φ-coder/phcoder' Serbinenko
#10 lore raw

Re: [PATCH] Trunk: usbtrans.c - wrong max packet size for bulk transfer

Quoted 8 lines · Vladimir 'φ-coder/phcoder' Serbinenko
Quoted 7 lines

Hi,
there is corrected patch (with sizeof and -p) for review before going to trunk.
Regards
Ales

Go ahead

Done, revision 2873.