--- grub-0.97.orig/stage2/builtins.c 2005-02-15 16:58:23.000000000 -0500 +++ grub-0.97/stage2/builtins.c 2009-05-04 21:05:56.000000000 -0400 @@ -49,6 +49,8 @@ # include #endif +#include "netboot/linux-asm-io.h" + /* The type of kernel loaded. */ kernel_t kernel_type; /* The boot device. */ @@ -3376,6 +3378,23 @@ static struct builtin builtin_savedefaul #ifdef SUPPORT_SERIAL + +#define CONFIG_CMD(bus, device_fn, where) (0x80000000 | (bus << 16) | (device_fn << 8) | (where & ~3)) + +static void pcibios_write_config_word (unsigned int bus, unsigned int device_fn, + unsigned int where, unsigned short value) +{ + outl(CONFIG_CMD(bus,device_fn,where), 0xCF8); + outw(value, 0xCFC + (where&2)); +} + +static void pcibios_write_config_dword (unsigned int bus, unsigned int device_fn, + unsigned int where, unsigned int value) +{ + outl(CONFIG_CMD(bus,device_fn,where), 0xCF8); + outl(value, 0xCFC); +} + /* serial */ static int serial_func (char *arg, int flags) @@ -3501,6 +3520,16 @@ serial_func (char *arg, int flags) arg = skip_to (0, arg); } + /* program 0x1060 to 06:02.0 BAR 0 */ + pcibios_write_config_dword (0x06, 0x10, 0x10, 0x1060); + /* program 0x1068 to 06:02.1 BAR 0 */ + pcibios_write_config_dword (0x06, 0x11, 0x10, 0x1068); + + /* enable I/O Space for 06:02.0 */ + pcibios_write_config_word (0x06, 0x10, 0x04, 0x0401); + /* enable I/O Space for 06:02.1 */ + pcibios_write_config_word (0x06, 0x11, 0x04, 0x0401); + /* Initialize the serial unit. */ if (! serial_hw_init (port, speed, word_len, parity, stop_bit_len)) {