power management on coreboot
PATCH 1/1 power management on coreboot
This implements power management on coreboot. reboot is (AFAIK) fairly generic, but halt is hardware-specific (currently it only supports bochs and friends).
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."
2008-08-04 Robert Millan <[email protected]>
* conf/i386-coreboot.rmk (pkglib_MODULES): Add reboot.mod' and halt.mod'. (reboot_mod_SOURCES, reboot_mod_CFLAGS, reboot_mod_LDFLAGS) (halt_mod_SOURCES, halt_mod_CFLAGS, halt_mod_LDFLAGS): New variables.
* kern/i386/halt.c: New file. Standalone halt implementation.
* kern/i386/reboot.c: New file. Standalone reboot implementation.
* include/grub/i386/reboot.h: New file.
* include/grub/i386/halt.h: New file.
* term/i386/pc/at_keyboard.c (SHIFT_L, SHIFT_R, CTRL, ALT, CAPS_LOCK) (KEYBOARD_REG_DATA, KEYBOARD_REG_STATUS) (KEYBOARD_COMMAND_ISREADY, KEYBOARD_COMMAND_READ) (KEYBOARD_COMMAND_WRITE, KEYBOARD_COMMAND_REBOOT) (KEYBOARD_SCANCODE_SET1, KEYBOARD_ISMAKE, KEYBOARD_ISREADY) (KEYBOARD_SCANCODE, OLPC_UP, OLPC_DOWN, OLPC_LEFT, OLPC_RIGHT): Move macros from here ...
* include/grub/i386/at_keyboard.h: ... to here.
* commands/halt.c [!GRUB_MACHINE_IEEE1275 !GRUB_MACHINE_EFI]: Include `<grub/cpu/halt.h>'
* commands/reboot.c [!GRUB_MACHINE_IEEE1275 !GRUB_MACHINE_EFI]: Include `<grub/cpu/reboot.h>'
i386-coreboot.rmk +12 -1
@@ -95,7 +95,8 @@ pkglib_MODULES = _linux.mod linux.mod normal.mod \ _multiboot.mod multiboot.mod aout.mod \ play.mod cpuid.mod serial.mod ata.mod \ - memdisk.mod pci.mod lspci.mod + memdisk.mod pci.mod lspci.mod reboot.mod \ + halt.mod # For _linux.mod. _linux_mod_SOURCES = loader/i386/pc/linux.c
@@ -117,6 +118,16 @@ normal_mod_ASFLAGS = $(COMMON_ASFLAGS) normal_mod_LDFLAGS = $(COMMON_LDFLAGS) +# For reboot.mod. +reboot_mod_SOURCES = commands/reboot.c kern/i386/reboot.c +reboot_mod_CFLAGS = $(COMMON_CFLAGS) +reboot_mod_LDFLAGS = $(COMMON_LDFLAGS) + +# For halt.mod. +halt_mod_SOURCES = commands/halt.c kern/i386/halt.c +halt_mod_CFLAGS = $(COMMON_CFLAGS) +halt_mod_LDFLAGS = $(COMMON_LDFLAGS) + # For serial.mod. serial_mod_SOURCES = term/i386/pc/serial.c serial_mod_CFLAGS = $(COMMON_CFLAGS)
i386/halt.c +42 -0
42 lines not on this page · raw message
i386/reboot.c +31 -0
@@ -0,0 +1,31 @@ +/* +* 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/>. +*/ + +#include <grub/cpu/io.h> +#include <grub/cpu/at_keyboard.h> +#include <grub/misc.h> + +void +grub_reboot (void ) +{ +/* Use the keyboard controller to reboot. That's what keyboards were +designed for, isn't it? */ +grub_outb (KEYBOARD_COMMAND_REBOOT ,KEYBOARD_REG_STATUS ); + +grub_printf ("GRUB doesn't know how to reboot this machine yet!\n" ); +}
grub/i386/reboot.h +19 -0
@@ -0,0 +1,19 @@ +/* +* 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/>. +*/ + +extern void grub_reboot (void );
grub/i386/at_keyboard.h +57 -0
57 lines not on this page · raw message
grub/i386/halt.h +19 -0
@@ -0,0 +1,19 @@ +/* +* 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/>. +*/ + +extern void grub_halt (void );
halt.c +3 -0
@@ -25,6 +25,9 @@#include <grub/machine/kernel.h> #elif defined(GRUB_MACHINE_EFI )#include <grub/efi/efi.h> +#else +/* Platforms shipping standalone halt, such as coreboot. */ +#include <grub/cpu/halt.h> #endif static grub_err_t
reboot.c +3 -0
@@ -27,6 +27,9 @@#include <grub/efi/efi.h> #elif defined(GRUB_MACHINE_PCBIOS )#include <grub/machine/init.h> +#else +/* Platforms shipping standalone reboot, such as coreboot. */ +#include <grub/cpu/reboot.h> #endif
i386/pc/at_keyboard.c +2 -34
@@ -17,16 +17,12 @@*/ #include <grub/machine/console.h> -#include <grub/machine/machine.h> +#include <grub/cpu/at_keyboard.h> #include <grub/cpu/io.h> #include <grub/misc.h> #include <grub/term.h> -#define SHIFT_L 0x2a -#define SHIFT_R 0x36 -#define CTRL 0x1d -#define ALT 0x38 -#define CAPS_LOCK 0x3a +static short at_keyboard_status =0 ;#define KEYBOARD_STATUS_SHIFT_L (1 << 0)#define KEYBOARD_STATUS_SHIFT_R (1 << 1)
@@ -36,34 +32,6 @@#define KEYBOARD_STATUS_CTRL_R (1 << 5)#define KEYBOARD_STATUS_CAPS_LOCK (1 << 6) -#define KEYBOARD_REG_DATA 0x60 -#define KEYBOARD_REG_STATUS 0x64 - -/* Used for sending commands to the controller. */ -#define KEYBOARD_COMMAND_ISREADY (x) !((x) & 0x02) -#define KEYBOARD_COMMAND_READ 0x20 -#define KEYBOARD_COMMAND_WRITE 0x60 - -#define KEYBOARD_SCANCODE_SET1 0x40 - -#define KEYBOARD_ISMAKE (x) !((x) & 0x80) -#define KEYBOARD_ISREADY (x) (((x) & 0x01) == 0) -#define KEYBOARD_SCANCODE (x) ((x) & 0x7f) - -static short at_keyboard_status =0 ; - -#ifdef GRUB_MACHINE_IEEE1275 -#define OLPC_UP GRUB_TERM_UP -#define OLPC_DOWN GRUB_TERM_DOWN -#define OLPC_LEFT GRUB_TERM_LEFT -#define OLPC_RIGHT GRUB_TERM_RIGHT -#else -#define OLPC_UP '\0' -#define OLPC_DOWN '\0' -#define OLPC_LEFT '\0' -#define OLPC_RIGHT '\0' -#endif -static char keyboard_map[128 ] = {'\0' ,GRUB_TERM_ESC ,'1' ,'2' ,'3' ,'4' ,'5' ,'6' ,
i386/halt.c line 35
Quoted 3 lines · Robert Millan
i386/halt.c +3
-0+/* Bochs, QEMU, etc. */ +for (p = bochs_shutdown; *p || *(p-1 ); p++) +grub_outb (*p,0x8900 );
Ah, mistake here. This would continue if there's a \0 after the string terminator.
I guess I'll have to add an explicit call after the loop.
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."
Committed.
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."