[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] Enable grub_cpu_idle for i386 to halt the CPU
From: |
Marco Gerards |
Subject: |
Re: [PATCH] Enable grub_cpu_idle for i386 to halt the CPU |
Date: |
Wed, 13 Aug 2008 11:34:22 +0200 |
User-agent: |
Gnus/5.110006 (No Gnus v0.6) Emacs/21.4 (gnu/linux) |
David Fries <address@hidden> writes:
> Enable grub_cpu_idle for i386 to halt the CPU and modify the menu code
> to make use of it. This will save power when booting.
> Or maybe I should say it will keep the CPU from running so hot when
> the timer is counting down.
>
> It isn't safe to call halt in protected mode as interrupts are
> disabled. I assume it is becaus the interrupts handlers aren't setup
> to work in protected mode. But interrupts are enabled in real mode,
> and the timer is running, so the only two things of interest in the
> menu countdown is time has elapsed or a key is pressed, which both
> produce interrupts and are checked. I assume any other call to
> grub_cpu_idle will have an interrupt or the timer to wake it up.
>
> As grub_cpu_idle is exported instead of inline, some of the utility
> programs failed to compile because the symbol wasn't defined. I
> created util/user-stub.c for common stub functions instead of adding
> it to multiple utility program source files.
Why didn't you use util/misc.c?
> --
> David Fries <address@hidden>
> http://fries.net/~david/ (PGP encryption key available)
>
>
> Index: conf/common.rmk
> ===================================================================
> --- conf/common.rmk (revision 1798)
> +++ conf/common.rmk (working copy)
> @@ -5,6 +5,7 @@
> util/grub-probe.c_DEPENDENCIES = grub_probe_init.h
> grub_probe_SOURCES = util/grub-probe.c \
> util/biosdisk.c util/misc.c util/getroot.c \
> + util/user-stub.c \
> kern/device.c kern/disk.c kern/err.c kern/misc.c \
> kern/parser.c kern/partition.c kern/file.c \
> \
> @@ -96,7 +97,9 @@
>
> # for grub-editenv
> bin_UTILITIES += grub-editenv
> -grub_editenv_SOURCES = util/grub-editenv.c lib/envblk.c util/misc.c
> kern/misc.c kern/err.c
> +grub_editenv_SOURCES = util/grub-editenv.c lib/envblk.c util/misc.c \
> + util/user-stub.c \
> + kern/misc.c kern/err.c
> CLEANFILES += grub-editenv
>
> # for grub-pe2elf
> Index: conf/i386-pc.rmk
> ===================================================================
> --- conf/i386-pc.rmk (revision 1798)
> +++ conf/i386-pc.rmk (working copy)
> @@ -91,7 +91,8 @@
> # For grub-setup.
> util/i386/pc/grub-setup.c_DEPENDENCIES = grub_setup_init.h
> grub_setup_SOURCES = util/i386/pc/grub-setup.c util/biosdisk.c \
> - util/misc.c util/getroot.c kern/device.c kern/disk.c \
> + util/misc.c util/getroot.c util/user-stub.c \
> + kern/device.c kern/disk.c \
> kern/err.c kern/misc.c kern/parser.c kern/partition.c \
> kern/file.c kern/fs.c kern/env.c fs/fshelp.c \
> \
> Index: conf/common.mk
Please do not add .mk changes in a patch, it is a generated file :-)
> ===================================================================
> --- conf/common.mk (revision 1798)
> +++ conf/common.mk (working copy)
> @@ -6,6 +6,7 @@
> util/grub-probe.c_DEPENDENCIES = grub_probe_init.h
> grub_probe_SOURCES = util/grub-probe.c \
> util/biosdisk.c util/misc.c util/getroot.c \
> + util/user-stub.c \
> kern/device.c kern/disk.c kern/err.c kern/misc.c \
> kern/parser.c kern/partition.c kern/file.c \
> \
> @@ -17,11 +18,11 @@
> partmap/pc.c partmap/apple.c partmap/gpt.c \
> kern/fs.c kern/env.c fs/fshelp.c \
> disk/lvm.c disk/raid.c grub_probe_init.c
> -CLEANFILES += grub-probe$(EXEEXT) grub_probe-util_grub_probe.o
> grub_probe-util_biosdisk.o grub_probe-util_misc.o grub_probe-util_getroot.o
> grub_probe-kern_device.o grub_probe-kern_disk.o grub_probe-kern_err.o
> grub_probe-kern_misc.o grub_probe-kern_parser.o grub_probe-kern_partition.o
> grub_probe-kern_file.o grub_probe-fs_affs.o grub_probe-fs_cpio.o
> grub_probe-fs_ext2.o grub_probe-fs_fat.o grub_probe-fs_hfs.o
> grub_probe-fs_hfsplus.o grub_probe-fs_iso9660.o grub_probe-fs_udf.o
> grub_probe-fs_jfs.o grub_probe-fs_minix.o grub_probe-fs_ntfs.o
> grub_probe-fs_ntfscomp.o grub_probe-fs_reiserfs.o grub_probe-fs_sfs.o
> grub_probe-fs_ufs.o grub_probe-fs_xfs.o grub_probe-fs_afs.o
> grub_probe-partmap_pc.o grub_probe-partmap_apple.o grub_probe-partmap_gpt.o
> grub_probe-kern_fs.o grub_probe-kern_env.o grub_probe-fs_fshelp.o
> grub_probe-disk_lvm.o grub_probe-disk_raid.o grub_probe-grub_probe_init.o
> -MOSTLYCLEANFILES += grub_probe-util_grub_probe.d grub_probe-util_biosdisk.d
> grub_probe-util_misc.d grub_probe-util_getroot.d grub_probe-kern_device.d
> grub_probe-kern_disk.d grub_probe-kern_err.d grub_probe-kern_misc.d
> grub_probe-kern_parser.d grub_probe-kern_partition.d grub_probe-kern_file.d
> grub_probe-fs_affs.d grub_probe-fs_cpio.d grub_probe-fs_ext2.d
> grub_probe-fs_fat.d grub_probe-fs_hfs.d grub_probe-fs_hfsplus.d
> grub_probe-fs_iso9660.d grub_probe-fs_udf.d grub_probe-fs_jfs.d
> grub_probe-fs_minix.d grub_probe-fs_ntfs.d grub_probe-fs_ntfscomp.d
> grub_probe-fs_reiserfs.d grub_probe-fs_sfs.d grub_probe-fs_ufs.d
> grub_probe-fs_xfs.d grub_probe-fs_afs.d grub_probe-partmap_pc.d
> grub_probe-partmap_apple.d grub_probe-partmap_gpt.d grub_probe-kern_fs.d
> grub_probe-kern_env.d grub_probe-fs_fshelp.d grub_probe-disk_lvm.d
> grub_probe-disk_raid.d grub_probe-grub_probe_init.d
> +CLEANFILES += grub-probe$(EXEEXT) grub_probe-util_grub_probe.o
> grub_probe-util_biosdisk.o grub_probe-util_misc.o grub_probe-util_getroot.o
> grub_probe-util_user_stub.o grub_probe-kern_device.o grub_probe-kern_disk.o
> grub_probe-kern_err.o grub_probe-kern_misc.o grub_probe-kern_parser.o
> grub_probe-kern_partition.o grub_probe-kern_file.o grub_probe-fs_affs.o
> grub_probe-fs_cpio.o grub_probe-fs_ext2.o grub_probe-fs_fat.o
> grub_probe-fs_hfs.o grub_probe-fs_hfsplus.o grub_probe-fs_iso9660.o
> grub_probe-fs_udf.o grub_probe-fs_jfs.o grub_probe-fs_minix.o
> grub_probe-fs_ntfs.o grub_probe-fs_ntfscomp.o grub_probe-fs_reiserfs.o
> grub_probe-fs_sfs.o grub_probe-fs_ufs.o grub_probe-fs_xfs.o
> grub_probe-fs_afs.o grub_probe-partmap_pc.o grub_probe-partmap_apple.o
> grub_probe-partmap_gpt.o grub_probe-kern_fs.o grub_probe-kern_env.o
> grub_probe-fs_fshelp.o grub_probe-disk_lvm.o grub_probe-disk_raid.o
> grub_probe-grub_probe_init.o
> +MOSTLYCLEANFILES += grub_probe-util_grub_probe.d grub_probe-util_biosdisk.d
> grub_probe-util_misc.d grub_probe-util_getroot.d grub_probe-util_user_stub.d
> grub_probe-kern_device.d grub_probe-kern_disk.d grub_probe-kern_err.d
> grub_probe-kern_misc.d grub_probe-kern_parser.d grub_probe-kern_partition.d
> grub_probe-kern_file.d grub_probe-fs_affs.d grub_probe-fs_cpio.d
> grub_probe-fs_ext2.d grub_probe-fs_fat.d grub_probe-fs_hfs.d
> grub_probe-fs_hfsplus.d grub_probe-fs_iso9660.d grub_probe-fs_udf.d
> grub_probe-fs_jfs.d grub_probe-fs_minix.d grub_probe-fs_ntfs.d
> grub_probe-fs_ntfscomp.d grub_probe-fs_reiserfs.d grub_probe-fs_sfs.d
> grub_probe-fs_ufs.d grub_probe-fs_xfs.d grub_probe-fs_afs.d
> grub_probe-partmap_pc.d grub_probe-partmap_apple.d grub_probe-partmap_gpt.d
> grub_probe-kern_fs.d grub_probe-kern_env.d grub_probe-fs_fshelp.d
> grub_probe-disk_lvm.d grub_probe-disk_raid.d grub_probe-grub_probe_init.d
>
> -grub-probe: $(grub_probe_DEPENDENCIES) grub_probe-util_grub_probe.o
> grub_probe-util_biosdisk.o grub_probe-util_misc.o grub_probe-util_getroot.o
> grub_probe-kern_device.o grub_probe-kern_disk.o grub_probe-kern_err.o
> grub_probe-kern_misc.o grub_probe-kern_parser.o grub_probe-kern_partition.o
> grub_probe-kern_file.o grub_probe-fs_affs.o grub_probe-fs_cpio.o
> grub_probe-fs_ext2.o grub_probe-fs_fat.o grub_probe-fs_hfs.o
> grub_probe-fs_hfsplus.o grub_probe-fs_iso9660.o grub_probe-fs_udf.o
> grub_probe-fs_jfs.o grub_probe-fs_minix.o grub_probe-fs_ntfs.o
> grub_probe-fs_ntfscomp.o grub_probe-fs_reiserfs.o grub_probe-fs_sfs.o
> grub_probe-fs_ufs.o grub_probe-fs_xfs.o grub_probe-fs_afs.o
> grub_probe-partmap_pc.o grub_probe-partmap_apple.o grub_probe-partmap_gpt.o
> grub_probe-kern_fs.o grub_probe-kern_env.o grub_probe-fs_fshelp.o
> grub_probe-disk_lvm.o grub_probe-disk_raid.o grub_probe-grub_probe_init.o
> - $(CC) -o $@ grub_probe-util_grub_probe.o grub_probe-util_biosdisk.o
> grub_probe-util_misc.o grub_probe-util_getroot.o grub_probe-kern_device.o
> grub_probe-kern_disk.o grub_probe-kern_err.o grub_probe-kern_misc.o
> grub_probe-kern_parser.o grub_probe-kern_partition.o grub_probe-kern_file.o
> grub_probe-fs_affs.o grub_probe-fs_cpio.o grub_probe-fs_ext2.o
> grub_probe-fs_fat.o grub_probe-fs_hfs.o grub_probe-fs_hfsplus.o
> grub_probe-fs_iso9660.o grub_probe-fs_udf.o grub_probe-fs_jfs.o
> grub_probe-fs_minix.o grub_probe-fs_ntfs.o grub_probe-fs_ntfscomp.o
> grub_probe-fs_reiserfs.o grub_probe-fs_sfs.o grub_probe-fs_ufs.o
> grub_probe-fs_xfs.o grub_probe-fs_afs.o grub_probe-partmap_pc.o
> grub_probe-partmap_apple.o grub_probe-partmap_gpt.o grub_probe-kern_fs.o
> grub_probe-kern_env.o grub_probe-fs_fshelp.o grub_probe-disk_lvm.o
> grub_probe-disk_raid.o grub_probe-grub_probe_init.o $(LDFLAGS)
> $(grub_probe_LDFLAGS)
> +grub-probe: $(grub_probe_DEPENDENCIES) grub_probe-util_grub_probe.o
> grub_probe-util_biosdisk.o grub_probe-util_misc.o grub_probe-util_getroot.o
> grub_probe-util_user_stub.o grub_probe-kern_device.o grub_probe-kern_disk.o
> grub_probe-kern_err.o grub_probe-kern_misc.o grub_probe-kern_parser.o
> grub_probe-kern_partition.o grub_probe-kern_file.o grub_probe-fs_affs.o
> grub_probe-fs_cpio.o grub_probe-fs_ext2.o grub_probe-fs_fat.o
> grub_probe-fs_hfs.o grub_probe-fs_hfsplus.o grub_probe-fs_iso9660.o
> grub_probe-fs_udf.o grub_probe-fs_jfs.o grub_probe-fs_minix.o
> grub_probe-fs_ntfs.o grub_probe-fs_ntfscomp.o grub_probe-fs_reiserfs.o
> grub_probe-fs_sfs.o grub_probe-fs_ufs.o grub_probe-fs_xfs.o
> grub_probe-fs_afs.o grub_probe-partmap_pc.o grub_probe-partmap_apple.o
> grub_probe-partmap_gpt.o grub_probe-kern_fs.o grub_probe-kern_env.o
> grub_probe-fs_fshelp.o grub_probe-disk_lvm.o grub_probe-disk_raid.o
> grub_probe-grub_probe_init.o
> + $(CC) -o $@ grub_probe-util_grub_probe.o grub_probe-util_biosdisk.o
> grub_probe-util_misc.o grub_probe-util_getroot.o grub_probe-util_user_stub.o
> grub_probe-kern_device.o grub_probe-kern_disk.o grub_probe-kern_err.o
> grub_probe-kern_misc.o grub_probe-kern_parser.o grub_probe-kern_partition.o
> grub_probe-kern_file.o grub_probe-fs_affs.o grub_probe-fs_cpio.o
> grub_probe-fs_ext2.o grub_probe-fs_fat.o grub_probe-fs_hfs.o
> grub_probe-fs_hfsplus.o grub_probe-fs_iso9660.o grub_probe-fs_udf.o
> grub_probe-fs_jfs.o grub_probe-fs_minix.o grub_probe-fs_ntfs.o
> grub_probe-fs_ntfscomp.o grub_probe-fs_reiserfs.o grub_probe-fs_sfs.o
> grub_probe-fs_ufs.o grub_probe-fs_xfs.o grub_probe-fs_afs.o
> grub_probe-partmap_pc.o grub_probe-partmap_apple.o grub_probe-partmap_gpt.o
> grub_probe-kern_fs.o grub_probe-kern_env.o grub_probe-fs_fshelp.o
> grub_probe-disk_lvm.o grub_probe-disk_raid.o grub_probe-grub_probe_init.o
> $(LDFLAGS) $(grub_probe_LDFLAGS)
>
> grub_probe-util_grub_probe.o: util/grub-probe.c
> $(util/grub-probe.c_DEPENDENCIES)
> $(CC) -Iutil -I$(srcdir)/util $(CPPFLAGS) $(CFLAGS) -DGRUB_UTIL=1
> $(grub_probe_CFLAGS) -MD -c -o $@ $<
> @@ -39,6 +40,10 @@
> $(CC) -Iutil -I$(srcdir)/util $(CPPFLAGS) $(CFLAGS) -DGRUB_UTIL=1
> $(grub_probe_CFLAGS) -MD -c -o $@ $<
> -include grub_probe-util_getroot.d
>
> +grub_probe-util_user_stub.o: util/user-stub.c
> $(util/user-stub.c_DEPENDENCIES)
> + $(CC) -Iutil -I$(srcdir)/util $(CPPFLAGS) $(CFLAGS) -DGRUB_UTIL=1
> $(grub_probe_CFLAGS) -MD -c -o $@ $<
> +-include grub_probe-util_user_stub.d
> +
> grub_probe-kern_device.o: kern/device.c $(kern/device.c_DEPENDENCIES)
> $(CC) -Ikern -I$(srcdir)/kern $(CPPFLAGS) $(CFLAGS) -DGRUB_UTIL=1
> $(grub_probe_CFLAGS) -MD -c -o $@ $<
> -include grub_probe-kern_device.d
> @@ -429,12 +434,14 @@
>
> # for grub-editenv
> bin_UTILITIES += grub-editenv
> -grub_editenv_SOURCES = util/grub-editenv.c lib/envblk.c util/misc.c
> kern/misc.c kern/err.c
> -CLEANFILES += grub-editenv$(EXEEXT) grub_editenv-util_grub_editenv.o
> grub_editenv-lib_envblk.o grub_editenv-util_misc.o grub_editenv-kern_misc.o
> grub_editenv-kern_err.o
> -MOSTLYCLEANFILES += grub_editenv-util_grub_editenv.d
> grub_editenv-lib_envblk.d grub_editenv-util_misc.d grub_editenv-kern_misc.d
> grub_editenv-kern_err.d
> +grub_editenv_SOURCES = util/grub-editenv.c lib/envblk.c util/misc.c \
> + util/user-stub.c \
> + kern/misc.c kern/err.c
> +CLEANFILES += grub-editenv$(EXEEXT) grub_editenv-util_grub_editenv.o
> grub_editenv-lib_envblk.o grub_editenv-util_misc.o
> grub_editenv-util_user_stub.o grub_editenv-kern_misc.o grub_editenv-kern_err.o
> +MOSTLYCLEANFILES += grub_editenv-util_grub_editenv.d
> grub_editenv-lib_envblk.d grub_editenv-util_misc.d
> grub_editenv-util_user_stub.d grub_editenv-kern_misc.d grub_editenv-kern_err.d
>
> -grub-editenv: $(grub_editenv_DEPENDENCIES) grub_editenv-util_grub_editenv.o
> grub_editenv-lib_envblk.o grub_editenv-util_misc.o grub_editenv-kern_misc.o
> grub_editenv-kern_err.o
> - $(CC) -o $@ grub_editenv-util_grub_editenv.o grub_editenv-lib_envblk.o
> grub_editenv-util_misc.o grub_editenv-kern_misc.o grub_editenv-kern_err.o
> $(LDFLAGS) $(grub_editenv_LDFLAGS)
> +grub-editenv: $(grub_editenv_DEPENDENCIES) grub_editenv-util_grub_editenv.o
> grub_editenv-lib_envblk.o grub_editenv-util_misc.o
> grub_editenv-util_user_stub.o grub_editenv-kern_misc.o grub_editenv-kern_err.o
> + $(CC) -o $@ grub_editenv-util_grub_editenv.o grub_editenv-lib_envblk.o
> grub_editenv-util_misc.o grub_editenv-util_user_stub.o
> grub_editenv-kern_misc.o grub_editenv-kern_err.o $(LDFLAGS)
> $(grub_editenv_LDFLAGS)
>
> grub_editenv-util_grub_editenv.o: util/grub-editenv.c
> $(util/grub-editenv.c_DEPENDENCIES)
> $(CC) -Iutil -I$(srcdir)/util $(CPPFLAGS) $(CFLAGS) -DGRUB_UTIL=1
> $(grub_editenv_CFLAGS) -MD -c -o $@ $<
> @@ -448,6 +455,10 @@
> $(CC) -Iutil -I$(srcdir)/util $(CPPFLAGS) $(CFLAGS) -DGRUB_UTIL=1
> $(grub_editenv_CFLAGS) -MD -c -o $@ $<
> -include grub_editenv-util_misc.d
>
> +grub_editenv-util_user_stub.o: util/user-stub.c
> $(util/user-stub.c_DEPENDENCIES)
> + $(CC) -Iutil -I$(srcdir)/util $(CPPFLAGS) $(CFLAGS) -DGRUB_UTIL=1
> $(grub_editenv_CFLAGS) -MD -c -o $@ $<
> +-include grub_editenv-util_user_stub.d
> +
> grub_editenv-kern_misc.o: kern/misc.c $(kern/misc.c_DEPENDENCIES)
> $(CC) -Ikern -I$(srcdir)/kern $(CPPFLAGS) $(CFLAGS) -DGRUB_UTIL=1
> $(grub_editenv_CFLAGS) -MD -c -o $@ $<
> -include grub_editenv-kern_misc.d
> Index: conf/i386-pc.mk
> ===================================================================
> --- conf/i386-pc.mk (revision 1798)
> +++ conf/i386-pc.mk (working copy)
> @@ -310,7 +310,8 @@
> # For grub-setup.
> util/i386/pc/grub-setup.c_DEPENDENCIES = grub_setup_init.h
> grub_setup_SOURCES = util/i386/pc/grub-setup.c util/biosdisk.c \
> - util/misc.c util/getroot.c kern/device.c kern/disk.c \
> + util/misc.c util/getroot.c util/user-stub.c \
> + kern/device.c kern/disk.c \
> kern/err.c kern/misc.c kern/parser.c kern/partition.c \
> kern/file.c kern/fs.c kern/env.c fs/fshelp.c \
> \
> @@ -324,11 +325,11 @@
> disk/raid.c disk/lvm.c \
> util/raid.c util/lvm.c \
> grub_setup_init.c
> -CLEANFILES += grub-setup$(EXEEXT) grub_setup-util_i386_pc_grub_setup.o
> grub_setup-util_biosdisk.o grub_setup-util_misc.o grub_setup-util_getroot.o
> grub_setup-kern_device.o grub_setup-kern_disk.o grub_setup-kern_err.o
> grub_setup-kern_misc.o grub_setup-kern_parser.o grub_setup-kern_partition.o
> grub_setup-kern_file.o grub_setup-kern_fs.o grub_setup-kern_env.o
> grub_setup-fs_fshelp.o grub_setup-fs_affs.o grub_setup-fs_cpio.o
> grub_setup-fs_ext2.o grub_setup-fs_fat.o grub_setup-fs_hfs.o
> grub_setup-fs_hfsplus.o grub_setup-fs_iso9660.o grub_setup-fs_udf.o
> grub_setup-fs_jfs.o grub_setup-fs_minix.o grub_setup-fs_ntfs.o
> grub_setup-fs_ntfscomp.o grub_setup-fs_reiserfs.o grub_setup-fs_sfs.o
> grub_setup-fs_ufs.o grub_setup-fs_xfs.o grub_setup-fs_afs.o
> grub_setup-partmap_pc.o grub_setup-partmap_gpt.o grub_setup-disk_raid.o
> grub_setup-disk_lvm.o grub_setup-util_raid.o grub_setup-util_lvm.o
> grub_setup-grub_setup_init.o
> -MOSTLYCLEANFILES += grub_setup-util_i386_pc_grub_setup.d
> grub_setup-util_biosdisk.d grub_setup-util_misc.d grub_setup-util_getroot.d
> grub_setup-kern_device.d grub_setup-kern_disk.d grub_setup-kern_err.d
> grub_setup-kern_misc.d grub_setup-kern_parser.d grub_setup-kern_partition.d
> grub_setup-kern_file.d grub_setup-kern_fs.d grub_setup-kern_env.d
> grub_setup-fs_fshelp.d grub_setup-fs_affs.d grub_setup-fs_cpio.d
> grub_setup-fs_ext2.d grub_setup-fs_fat.d grub_setup-fs_hfs.d
> grub_setup-fs_hfsplus.d grub_setup-fs_iso9660.d grub_setup-fs_udf.d
> grub_setup-fs_jfs.d grub_setup-fs_minix.d grub_setup-fs_ntfs.d
> grub_setup-fs_ntfscomp.d grub_setup-fs_reiserfs.d grub_setup-fs_sfs.d
> grub_setup-fs_ufs.d grub_setup-fs_xfs.d grub_setup-fs_afs.d
> grub_setup-partmap_pc.d grub_setup-partmap_gpt.d grub_setup-disk_raid.d
> grub_setup-disk_lvm.d grub_setup-util_raid.d grub_setup-util_lvm.d
> grub_setup-grub_setup_init.d
> +CLEANFILES += grub-setup$(EXEEXT) grub_setup-util_i386_pc_grub_setup.o
> grub_setup-util_biosdisk.o grub_setup-util_misc.o grub_setup-util_getroot.o
> grub_setup-util_user_stub.o grub_setup-kern_device.o grub_setup-kern_disk.o
> grub_setup-kern_err.o grub_setup-kern_misc.o grub_setup-kern_parser.o
> grub_setup-kern_partition.o grub_setup-kern_file.o grub_setup-kern_fs.o
> grub_setup-kern_env.o grub_setup-fs_fshelp.o grub_setup-fs_affs.o
> grub_setup-fs_cpio.o grub_setup-fs_ext2.o grub_setup-fs_fat.o
> grub_setup-fs_hfs.o grub_setup-fs_hfsplus.o grub_setup-fs_iso9660.o
> grub_setup-fs_udf.o grub_setup-fs_jfs.o grub_setup-fs_minix.o
> grub_setup-fs_ntfs.o grub_setup-fs_ntfscomp.o grub_setup-fs_reiserfs.o
> grub_setup-fs_sfs.o grub_setup-fs_ufs.o grub_setup-fs_xfs.o
> grub_setup-fs_afs.o grub_setup-partmap_pc.o grub_setup-partmap_gpt.o
> grub_setup-disk_raid.o grub_setup-disk_lvm.o grub_setup-util_raid.o
> grub_setup-util_lvm.o grub_setup-grub_setup_init.o
> +MOSTLYCLEANFILES += grub_setup-util_i386_pc_grub_setup.d
> grub_setup-util_biosdisk.d grub_setup-util_misc.d grub_setup-util_getroot.d
> grub_setup-util_user_stub.d grub_setup-kern_device.d grub_setup-kern_disk.d
> grub_setup-kern_err.d grub_setup-kern_misc.d grub_setup-kern_parser.d
> grub_setup-kern_partition.d grub_setup-kern_file.d grub_setup-kern_fs.d
> grub_setup-kern_env.d grub_setup-fs_fshelp.d grub_setup-fs_affs.d
> grub_setup-fs_cpio.d grub_setup-fs_ext2.d grub_setup-fs_fat.d
> grub_setup-fs_hfs.d grub_setup-fs_hfsplus.d grub_setup-fs_iso9660.d
> grub_setup-fs_udf.d grub_setup-fs_jfs.d grub_setup-fs_minix.d
> grub_setup-fs_ntfs.d grub_setup-fs_ntfscomp.d grub_setup-fs_reiserfs.d
> grub_setup-fs_sfs.d grub_setup-fs_ufs.d grub_setup-fs_xfs.d
> grub_setup-fs_afs.d grub_setup-partmap_pc.d grub_setup-partmap_gpt.d
> grub_setup-disk_raid.d grub_setup-disk_lvm.d grub_setup-util_raid.d
> grub_setup-util_lvm.d grub_setup-grub_setup_init.d
>
> -grub-setup: $(grub_setup_DEPENDENCIES) grub_setup-util_i386_pc_grub_setup.o
> grub_setup-util_biosdisk.o grub_setup-util_misc.o grub_setup-util_getroot.o
> grub_setup-kern_device.o grub_setup-kern_disk.o grub_setup-kern_err.o
> grub_setup-kern_misc.o grub_setup-kern_parser.o grub_setup-kern_partition.o
> grub_setup-kern_file.o grub_setup-kern_fs.o grub_setup-kern_env.o
> grub_setup-fs_fshelp.o grub_setup-fs_affs.o grub_setup-fs_cpio.o
> grub_setup-fs_ext2.o grub_setup-fs_fat.o grub_setup-fs_hfs.o
> grub_setup-fs_hfsplus.o grub_setup-fs_iso9660.o grub_setup-fs_udf.o
> grub_setup-fs_jfs.o grub_setup-fs_minix.o grub_setup-fs_ntfs.o
> grub_setup-fs_ntfscomp.o grub_setup-fs_reiserfs.o grub_setup-fs_sfs.o
> grub_setup-fs_ufs.o grub_setup-fs_xfs.o grub_setup-fs_afs.o
> grub_setup-partmap_pc.o grub_setup-partmap_gpt.o grub_setup-disk_raid.o
> grub_setup-disk_lvm.o grub_setup-util_raid.o grub_setup-util_lvm.o
> grub_setup-grub_setup_init.o
> - $(CC) -o $@ grub_setup-util_i386_pc_grub_setup.o
> grub_setup-util_biosdisk.o grub_setup-util_misc.o grub_setup-util_getroot.o
> grub_setup-kern_device.o grub_setup-kern_disk.o grub_setup-kern_err.o
> grub_setup-kern_misc.o grub_setup-kern_parser.o grub_setup-kern_partition.o
> grub_setup-kern_file.o grub_setup-kern_fs.o grub_setup-kern_env.o
> grub_setup-fs_fshelp.o grub_setup-fs_affs.o grub_setup-fs_cpio.o
> grub_setup-fs_ext2.o grub_setup-fs_fat.o grub_setup-fs_hfs.o
> grub_setup-fs_hfsplus.o grub_setup-fs_iso9660.o grub_setup-fs_udf.o
> grub_setup-fs_jfs.o grub_setup-fs_minix.o grub_setup-fs_ntfs.o
> grub_setup-fs_ntfscomp.o grub_setup-fs_reiserfs.o grub_setup-fs_sfs.o
> grub_setup-fs_ufs.o grub_setup-fs_xfs.o grub_setup-fs_afs.o
> grub_setup-partmap_pc.o grub_setup-partmap_gpt.o grub_setup-disk_raid.o
> grub_setup-disk_lvm.o grub_setup-util_raid.o grub_setup-util_lvm.o
> grub_setup-grub_setup_init.o $(LDFLAGS) $(grub_setup_LDFLAGS)
> +grub-setup: $(grub_setup_DEPENDENCIES) grub_setup-util_i386_pc_grub_setup.o
> grub_setup-util_biosdisk.o grub_setup-util_misc.o grub_setup-util_getroot.o
> grub_setup-util_user_stub.o grub_setup-kern_device.o grub_setup-kern_disk.o
> grub_setup-kern_err.o grub_setup-kern_misc.o grub_setup-kern_parser.o
> grub_setup-kern_partition.o grub_setup-kern_file.o grub_setup-kern_fs.o
> grub_setup-kern_env.o grub_setup-fs_fshelp.o grub_setup-fs_affs.o
> grub_setup-fs_cpio.o grub_setup-fs_ext2.o grub_setup-fs_fat.o
> grub_setup-fs_hfs.o grub_setup-fs_hfsplus.o grub_setup-fs_iso9660.o
> grub_setup-fs_udf.o grub_setup-fs_jfs.o grub_setup-fs_minix.o
> grub_setup-fs_ntfs.o grub_setup-fs_ntfscomp.o grub_setup-fs_reiserfs.o
> grub_setup-fs_sfs.o grub_setup-fs_ufs.o grub_setup-fs_xfs.o
> grub_setup-fs_afs.o grub_setup-partmap_pc.o grub_setup-partmap_gpt.o
> grub_setup-disk_raid.o grub_setup-disk_lvm.o grub_setup-util_raid.o
> grub_setup-util_lvm.o grub_setup-grub_setup_init.o
> + $(CC) -o $@ grub_setup-util_i386_pc_grub_setup.o
> grub_setup-util_biosdisk.o grub_setup-util_misc.o grub_setup-util_getroot.o
> grub_setup-util_user_stub.o grub_setup-kern_device.o grub_setup-kern_disk.o
> grub_setup-kern_err.o grub_setup-kern_misc.o grub_setup-kern_parser.o
> grub_setup-kern_partition.o grub_setup-kern_file.o grub_setup-kern_fs.o
> grub_setup-kern_env.o grub_setup-fs_fshelp.o grub_setup-fs_affs.o
> grub_setup-fs_cpio.o grub_setup-fs_ext2.o grub_setup-fs_fat.o
> grub_setup-fs_hfs.o grub_setup-fs_hfsplus.o grub_setup-fs_iso9660.o
> grub_setup-fs_udf.o grub_setup-fs_jfs.o grub_setup-fs_minix.o
> grub_setup-fs_ntfs.o grub_setup-fs_ntfscomp.o grub_setup-fs_reiserfs.o
> grub_setup-fs_sfs.o grub_setup-fs_ufs.o grub_setup-fs_xfs.o
> grub_setup-fs_afs.o grub_setup-partmap_pc.o grub_setup-partmap_gpt.o
> grub_setup-disk_raid.o grub_setup-disk_lvm.o grub_setup-util_raid.o
> grub_setup-util_lvm.o grub_setup-grub_setup_init.o $(LDFLAGS)
> $(grub_setup_LDFLAGS)
>
> grub_setup-util_i386_pc_grub_setup.o: util/i386/pc/grub-setup.c
> $(util/i386/pc/grub-setup.c_DEPENDENCIES)
> $(CC) -Iutil/i386/pc -I$(srcdir)/util/i386/pc $(CPPFLAGS) $(CFLAGS)
> -DGRUB_UTIL=1 $(grub_setup_CFLAGS) -MD -c -o $@ $<
> @@ -346,6 +347,10 @@
> $(CC) -Iutil -I$(srcdir)/util $(CPPFLAGS) $(CFLAGS) -DGRUB_UTIL=1
> $(grub_setup_CFLAGS) -MD -c -o $@ $<
> -include grub_setup-util_getroot.d
>
> +grub_setup-util_user_stub.o: util/user-stub.c
> $(util/user-stub.c_DEPENDENCIES)
> + $(CC) -Iutil -I$(srcdir)/util $(CPPFLAGS) $(CFLAGS) -DGRUB_UTIL=1
> $(grub_setup_CFLAGS) -MD -c -o $@ $<
> +-include grub_setup-util_user_stub.d
> +
> grub_setup-kern_device.o: kern/device.c $(kern/device.c_DEPENDENCIES)
> $(CC) -Ikern -I$(srcdir)/kern $(CPPFLAGS) $(CFLAGS) -DGRUB_UTIL=1
> $(grub_setup_CFLAGS) -MD -c -o $@ $<
> -include grub_setup-kern_device.d
> Index: kern/i386/pc/startup.S
> ===================================================================
> --- kern/i386/pc/startup.S (revision 1798)
> +++ kern/i386/pc/startup.S (working copy)
> @@ -1502,8 +1502,28 @@
> popl %ebx
> popl %ebp
> ret
> -
> +
> +
> /*
> + * void grub_cpu_idle (void)
> + * Change to real mode to enable interrupts and hlt until the next interrupt.
> + */
> +FUNCTION(grub_cpu_idle)
> + pushl %ebp
> +
> + call prot_to_real /* enter real mode */
> + .code16
> +
> + hlt
> +
> + DATA32 call real_to_prot
> + .code32
> +
> + popl %ebp
> + ret
> +
> +
> +/*
> * grub_getrtsecs()
> * if a seconds value can be read, read it and return it (BCD),
> * otherwise return 0xFF
> Index: NEWS
> ===================================================================
> --- NEWS (revision 1798)
> +++ NEWS (working copy)
> @@ -1,5 +1,8 @@
> New in 1.97 - :
>
> +* Enable grub_cpu_idle for i386 to halt the CPU and modify the menu code
> + to make use of it. This will save power when booting.
> +
> * When booting from PXE, PXE can be used to load files.
>
> * High resolution timer support.
> Index: include/grub/i386/time.h
> ===================================================================
> --- include/grub/i386/time.h (revision 1798)
> +++ include/grub/i386/time.h (working copy)
> @@ -19,11 +19,9 @@
> #ifndef KERNEL_CPU_TIME_HEADER
> #define KERNEL_CPU_TIME_HEADER 1
>
> -static __inline void
> -grub_cpu_idle (void)
> -{
> - /* FIXME: this can't work until we handle interrupts. */
> -/* __asm__ __volatile__ ("hlt"); */
> -}
> +/* Call into assembly to change to real mode and enable interrupts so it
> + can halt until the next interrupt is received. */
> +void
> +EXPORT_FUNC(grub_cpu_idle) (void);
>
> #endif /* ! KERNEL_CPU_TIME_HEADER */
> Index: ChangeLog
> ===================================================================
> --- ChangeLog (revision 1798)
> +++ ChangeLog (working copy)
> @@ -1,3 +1,18 @@
> +2008-08-10 David Fries <address@hidden>
> +
> + Enable hlt in grub_cpu_idle so it can be idle when called.
> + * kern/i386/pc/startup.S: grub_cpu_idle, halt with interrupts
> + * include/grub/i386/time.h: export function grub_cpu_idle.
> + * normal/menu.c: Sleep in halt (if supported), until a second elapsed
> + or a key is pressed.
> + * util/user-stub.c: New file. The utilities link against part of the
> + kernel. This new file is intended to be a dumping place for functions
> + that are requierd by parts of the kernel included, but not found in
> + those places.
> + * conf/common.rmk: Make use of user-stub.c in grub_probe and
> + grub-editenv.
> + * conf/i386-pc.rmk: Make use of user-stub.c in grub-setup.
Our changelogs describe changes, not the effects. Please keep
descriptions very short. I would like to refer you to:
http://www.gnu.org/prep/standards/html_node/Change-Logs.html
Furthermore, you can look at the current changelog to see how it
works.
> 2008-08-09 Christian Franke <address@hidden>
>
> * Makefile.in: Add `target_os' and `enable_grub_pe2elf'.
> Index: normal/menu.c
> ===================================================================
> --- normal/menu.c (revision 1798)
> +++ normal/menu.c (working copy)
> @@ -24,6 +24,7 @@
> #include <grub/time.h>
> #include <grub/env.h>
> #include <grub/script.h>
> +#include <grub/cpu/time.h>
>
> static grub_uint8_t grub_color_menu_normal;
> static grub_uint8_t grub_color_menu_highlight;
> @@ -381,6 +382,12 @@
> saved_time = current_time;
> print_timeout (timeout, offset, 1);
> }
> + /* Sleep until a second has passed or a key is pressed. */
> + do
> + {
> + grub_cpu_idle ();
> + }while (grub_get_rtc () - saved_time < GRUB_TICKS_PER_SECOND &&
> + grub_checkkey () == -1);
This doesn't match our coding style. I would write something like:
while (grub_get_rtc () - saved_time < GRUB_TICKS_PER_SECOND
&& grub_checkkey () == -1)
grub_cpu_idle ();
(it's easier to format a while, I think)
> }
>
> if (timeout == 0)
> Index: DISTLIST
> ===================================================================
> --- DISTLIST (revision 1798)
> +++ DISTLIST (working copy)
> @@ -358,6 +358,7 @@
> util/raid.c
> util/resolve.c
> util/unifont2pff.rb
> +util/user-stub.c
> util/update-grub.in
> util/update-grub_lib.in
> video/bitmap.c
> Index: util/user-stub.c
> ===================================================================
> --- util/user-stub.c (revision 0)
> +++ util/user-stub.c (revision 0)
> @@ -0,0 +1,32 @@
> +/*
> + * 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/>.
> + */
> +
> +/* Provide user space stubs for the utility programs to compile against.
> + They are not included in the pieces of the kernel linked in to the
> + utility programs, but are unresolved symbols for the parts that are. */
> +
> +#include <config.h>
> +#include <stdio.h>
> +#include <time.h>
> +
> +void
> +grub_cpu_idle ()
> +{
> + struct timespec req={0,1};
> + nanosleep (&req, NULL);
> +}
>
>
> _______________________________________________
> Grub-devel mailing list
> address@hidden
> http://lists.gnu.org/mailman/listinfo/grub-devel
Re: [PATCH] Enable grub_cpu_idle for i386 to halt the CPU,
Marco Gerards <=