diff -uNr elilo-3.6-orig/Makefile elilo-3.6/Makefile --- elilo-3.6-orig/Makefile 2006-05-27 19:55:33.000000000 +0100 +++ elilo-3.6/Makefile 2006-05-28 14:38:53.000000000 +0100 @@ -71,6 +71,8 @@ all: check_gcc $(SUBDIRS) $(TARGETS) +FILES += power_up.o + elilo.efi: elilo.so elilo.so: $(FILES) diff -uNr elilo-3.6-orig/io.h elilo-3.6/io.h --- elilo-3.6-orig/io.h 1970-01-01 01:00:00.000000000 +0100 +++ elilo-3.6/io.h 2006-05-07 20:08:14.000000000 +0100 @@ -0,0 +1,84 @@ +/* + * io.h: + * + * Copyright (c) 2006 James McKenzie , + * This program 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 2 of the License, or + * (at your option) any later version. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + */ + +/* + * $Id: elilo-powerup.patch,v 1.1 2007/07/21 18:06:24 pete Exp $ + */ + +/* + * $Log: elilo-powerup.patch,v $ + * Revision 1.1 2007/07/21 18:06:24 pete + * added resources for appletv / mac mini + * + * Revision 1.1 2006/05/02 19:22:56 james + * *** empty log message *** + * + */ + +#ifndef __IO_H__ +#define __IO_H__ + + +/* IO port input/output */ +#if 0 + +/* XXX we should be able to use the EFI functions for these, but they don't + * link under gnu-efi. */ +#define out_8(val, port) outp((port), (val)) +#define out_16(val, port) outpw((port), (val)) +#define out_32(val, port) outpd((port), (val)) + +#define in_8(port) inp((port)) +#define in_16(port) inpw((port)) +#define in_32(port) inpd((port)) + +#endif + +static inline void out_8(UINT8 value, UINT16 port) { + __asm__ __volatile__ ("out" "b" " %" "b" "0,%" "w" "1"::"a" (value), + "Nd" (port)); +} + +static inline void out_16(UINT16 value, UINT16 port) { + __asm__ __volatile__ ("out" "w" " %" "w" "0,%" "w" "1"::"a" (value), + "Nd" (port)); +} + +static inline void out_32(UINT32 value, UINT16 port) { + __asm__ __volatile__ ("out" "l" " %" "0,%" "w" "1"::"a" (value), + "Nd" (port)); +} + +static inline UINT8 in_8(UINT16 port) { + UINT8 _v; + __asm__ __volatile__ ("in" "b" " %" "w" "1,%" "" "0":"=a" (_v):"Nd" (port)); + return _v; +} + +static inline UINT16 in_16(UINT16 port) { + UINT16 _v; + __asm__ __volatile__ ("in" "w" " %" "w" "1,%" "" "0":"=a" (_v):"Nd" (port)); + return _v; +} + +static inline UINT32 in_32(UINT16 port) { + UINT32 _v; + __asm__ __volatile__ ("in" "l" " %" "w" "1,%" "" "0":"=a" (_v):"Nd" (port)); + return _v; +} + +#endif /* __IO_H__ */ diff -uNr elilo-3.6-orig/power_up.c elilo-3.6/power_up.c --- elilo-3.6-orig/power_up.c 1970-01-01 01:00:00.000000000 +0100 +++ elilo-3.6/power_up.c 2006-05-07 20:08:14.000000000 +0100 @@ -0,0 +1,101 @@ +/* + * power_up.c: + * Instruct the 82801GBH controller to always power on. + * + */ + +static const char rcsid[] = "$Id: elilo-powerup.patch,v 1.1 2007/07/21 18:06:24 pete Exp $"; + +#include +#include + +#include "io.h" + +#define PCI_VENDOR_ID 0x00 +#define PCI_DEVICE_ID 0x02 + +#define PCI_VENDOR_ID_INTEL 0x8086 +#define PCI_DEVICE_ID_INTEL_82801GBM 0x27b9 + +#define REG_GEN_PMCON_3 0xa4 +#define REG_GEN_PMCON_3_AFTERG3_EN 0x01 +#define REG_GEN_PMCON_3_PWR_FLR 0x02 +#define REG_GEN_PMCON_3_RTC_PWR_STS 0x04 + +/* PCI config read/write */ +static uint8_t +conf1_read_8 (int bus, int devfn, int off) +{ + int addr = 0xcfc + (off & 3); + out_32 (0x80000000 | (bus << 16) | (devfn << 8) | (off & ~3), 0x0cf8); + return in_8 (addr); +} + +#if 0 /* not used */ +static uint16_t +conf1_read_16 (int bus, int devfn, int off) +{ + int addr = 0xcfc + (off & 3); + out_32 (0x80000000 | (bus << 16) | (devfn << 8) | (off & ~3), 0x0cf8); + return in_16 (addr); +} +#endif + +static uint32_t +conf1_read_32 (int bus, int devfn, int off) +{ + int addr = 0xcfc + (off & 3); + out_32 (0x80000000 | (bus << 16) | (devfn << 8) | (off & ~3), 0x0cf8); + return in_32 (addr); +} + +static void +conf1_write_8 (int bus, int devfn, int off, uint8_t val) +{ + int addr = 0xcfc + (off & 3); + out_32 (0x80000000 | (bus << 16) | (devfn << 8) | (off & ~3), 0x0cf8); + out_8 (val, addr); +} + +/* set_always_power_on + * Configure the machine to always power up when power is available. */ +void +set_always_power_on (void) +{ + int bus = 0; + int slot; + int fn = 0; + int devfn; + + Print (L"Setting always-power-on behaviour via 82801GBM LPC:\n"); + + for (slot = 0; slot < 0x20; ++slot) + { + devfn = (slot << 3) | fn; + + if (conf1_read_32 (bus, devfn, PCI_VENDOR_ID) == + ((PCI_DEVICE_ID_INTEL_82801GBM << 16) | PCI_VENDOR_ID_INTEL)) + { + + int val = conf1_read_8 (bus, devfn, REG_GEN_PMCON_3); + Print (L" 82801GBM LPC found at %x:%x.%x\n", bus, slot, + fn); + Print + (L" AC wake with power was %a, RTC battery is %a, and has been %a.\n", + (val & REG_GEN_PMCON_3_AFTERG3_EN) ? "off" : "on ", + (val & REG_GEN_PMCON_3_RTC_PWR_STS) ? "bad " : "good", + (val & REG_GEN_PMCON_3_PWR_FLR) ? "bad " : "good"); + + Print (L" Setting AC wake with power... "); + conf1_write_8 (bus, devfn, REG_GEN_PMCON_3, 0); + val = conf1_read_8 (bus, devfn, REG_GEN_PMCON_3); + Print (L"done\n"); + Print (L" AC wake with power is now %a\n", + (val & REG_GEN_PMCON_3_AFTERG3_EN) ? "off" : "on "); + + return; + } + + } + Print (L" 82801GBM LPC not found; unable to set to always-power-on\n"); +} diff -uNr elilo-3.6-orig/elilo.c elilo-3.6/elilo.c --- elilo-3.6-orig/elilo.c 2005-12-02 18:09:42.000000000 +0000 +++ elilo-3.6/elilo.c 2006-05-28 14:34:48.000000000 +0100 @@ -441,6 +441,11 @@ */ BS->SetWatchdogTimer(0, 0x0, 0, NULL); + { + extern void set_always_power_on (void); + set_always_power_on (); + } + /* initialize memory allocator */ if (alloc_init() == -1) return EFI_LOAD_ERROR;