Re: [PATCH] New frame buffer detection algorithm and loadrom command for efi platform

2009-04-04 Thread Bean
On Fri, Mar 27, 2009 at 12:21 AM, Bean bean12...@gmail.com wrote:
 On Fri, Mar 27, 2009 at 12:09 AM, step21 f...@terrorpop.de wrote:
 hi,
 why did you scrap ivt.bin loading ... seems much more complicated now.
 I'm not sure if I remeber right, but I think ivt.bin worked best for me ...

 Hi,

 The latest patch support loading file again, but only int10.bin, not
 the whole ivt. In fact, I add a shell script grub-dumpbios that does
 the job:

 sudo grub-dumpbios -o /boot/

 It would then save vbios.bin and int10.bin to /boot/ directory, in grub2:

 loadbios /boot/vbios.bin /boot/int10.bin

Committed.

-- 
Bean


___
Grub-devel mailing list
Grub-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/grub-devel


Re: [PATCH] New frame buffer detection algorithm and loadrom command for efi platform

2009-03-26 Thread Bean
Hi,

This is another update, it contains the following changes with regards
to the previous one:

1, Move loadbios command to commands/efi directory.
2, loadbios support an optional second parameter which is the int10
vector dump file.
3, The linux command enables frame buffer by default, so you don't
need video= option anymore.
4. New command fix_video to fix video register issue with efi. With
this, you can boot to console mode with agp enabled.
5, New shell script grub-dumpbios which can be used to generate the
bios dump from pc mode.

As the commands usage have changed in the previous patches, here is a
summary of what you should do with this latest patch:

1, Boot without bios dump.

This is the commands to use:

search --set /vmlinuz
fix_video
fakebios
linux /vmlinuz root=/dev/sdb1
initrd /initrd.img

2, Boot with bios dump.

First, boot to pc mode, then use script grub-dumpbios to generate the
dump files:

sudo grub-dumpbios -o /boot/

video bios dump is in vbios.bin, int10 vector is in int10.bin. /boot/
is the output directory.

Then, use the following commands in grub2:
search --set /vmlinuz
fix_video
loadbios /boot/vbios.bin /boot/int10.bin
linux /vmlinuz root=/dev/sdb1
initrd /initrd.img

Moreover, if you're booting 2.6.27-28, amd64 kernel, you need to add
noefi option.

-- 
Bean
diff --git a/commands/efi/fixvideo.c b/commands/efi/fixvideo.c
new file mode 100644
index 000..61f8d7b
--- /dev/null
+++ b/commands/efi/fixvideo.c
@@ -0,0 +1,106 @@
+/* fixvideo.c - fix video problem in efi */
+/*
+ *  GRUB  --  GRand Unified Bootloader
+ *  Copyright (C) 2009  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/dl.h
+#include grub/misc.h
+#include grub/file.h
+#include grub/pci.h
+#include grub/command.h
+
+static struct grub_video_patch
+{
+  const char *name;
+  grub_uint32_t pci_id;
+  grub_uint32_t mmio_bar;
+  grub_uint32_t mmio_dispa;
+  grub_uint32_t mmio_dispb;
+} video_patches[] =
+  {
+{Intel 965GM, 0x2a028086, 0, 0x7019C, 0x7119C}, /* DSPBSURF  */
+{0, 0, 0, 0, 0}
+  };
+
+static int NESTED_FUNC_ATTR
+scan_card (int bus, int dev, int func, grub_pci_id_t pciid)
+{
+  grub_pci_address_t addr;
+
+  addr = grub_pci_make_address (bus, dev, func, 2);
+  if (grub_pci_read_byte (addr + 3) == 0x3)
+{
+  struct grub_video_patch *p = video_patches;
+
+  while (p-name)
+	{
+	  if (p-pci_id == pciid)
+	{
+	  grub_target_addr_t base;
+
+	  grub_printf (Found graphic card: %s\n, p-name);
+	  addr += 8 + p-mmio_bar * 4;
+	  base = grub_pci_read (addr);
+	  if ((! base) || (base  GRUB_PCI_ADDR_SPACE_IO) ||
+		  (base  GRUB_PCI_ADDR_MEM_PREFETCH))
+		grub_printf (Invalid MMIO bar %d\n, p-mmio_bar);
+	  else
+		{
+		  grub_uint32_t v;
+
+		  base = GRUB_PCI_ADDR_MEM_MASK;
+		  v = *((volatile grub_uint32_t *) (base + p-mmio_dispa));
+		  *((volatile grub_uint32_t *) (base + p-mmio_dispb)) = v;
+		  if (*((volatile grub_uint32_t *) (base + p-mmio_dispb))
+		  != v)
+		grub_printf (Set MMIO fails\n);
+		}
+
+	  return 1;
+	}
+	  p++;
+	}
+
+  grub_printf (Unknown graphic card: %x\n, pciid);
+}
+
+  return 0;
+}
+
+static grub_err_t
+grub_cmd_fixvideo (grub_command_t cmd __attribute__ ((unused)),
+		   int argc __attribute__ ((unused)),
+		   char *argv[] __attribute__ ((unused)))
+{
+  grub_pci_iterate (scan_card);
+  return 0;
+}
+
+static grub_command_t cmd_fixvideo;
+
+GRUB_MOD_INIT(fixvideo)
+{
+  (void) mod;			/* To stop warning. */
+  cmd_fixvideo = grub_register_command (fix_video, grub_cmd_fixvideo,
+	0, Fix video problem.);
+
+}
+
+GRUB_MOD_FINI(fixvideo)
+{
+  grub_unregister_command (cmd_fixvideo);
+}
diff --git a/commands/efi/loadbios.c b/commands/efi/loadbios.c
new file mode 100644
index 000..d0a5a69
--- /dev/null
+++ b/commands/efi/loadbios.c
@@ -0,0 +1,211 @@
+/* loadbios.c - command to load a bios dump  */
+/*
+ *  GRUB  --  GRand Unified Bootloader
+ *  Copyright (C) 2009  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 

Re: [PATCH] New frame buffer detection algorithm and loadrom command for efi platform

2009-03-26 Thread step21
hi,
why did you scrap ivt.bin loading ... seems much more complicated now.
I'm not sure if I remeber right, but I think ivt.bin worked best for me ...

2009/3/26 Bean bean12...@gmail.com:
 Hi,

 This is another update, it contains the following changes with regards
 to the previous one:

 1, Move loadbios command to commands/efi directory.
 2, loadbios support an optional second parameter which is the int10
 vector dump file.
 3, The linux command enables frame buffer by default, so you don't
 need video= option anymore.
 4. New command fix_video to fix video register issue with efi. With
 this, you can boot to console mode with agp enabled.
 5, New shell script grub-dumpbios which can be used to generate the
 bios dump from pc mode.

 As the commands usage have changed in the previous patches, here is a
 summary of what you should do with this latest patch:

 1, Boot without bios dump.

 This is the commands to use:

 search --set /vmlinuz
 fix_video
 fakebios
 linux /vmlinuz root=/dev/sdb1
 initrd /initrd.img

 2, Boot with bios dump.

 First, boot to pc mode, then use script grub-dumpbios to generate the
 dump files:

 sudo grub-dumpbios -o /boot/

 video bios dump is in vbios.bin, int10 vector is in int10.bin. /boot/
 is the output directory.

 Then, use the following commands in grub2:
 search --set /vmlinuz
 fix_video
 loadbios /boot/vbios.bin /boot/int10.bin
 linux /vmlinuz root=/dev/sdb1
 initrd /initrd.img

 Moreover, if you're booting 2.6.27-28, amd64 kernel, you need to add
 noefi option.

 --
 Bean

 ___
 Grub-devel mailing list
 Grub-devel@gnu.org
 http://lists.gnu.org/mailman/listinfo/grub-devel




___
Grub-devel mailing list
Grub-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/grub-devel


Re: [PATCH] New frame buffer detection algorithm and loadrom command for efi platform

2009-03-26 Thread Bean
On Fri, Mar 27, 2009 at 12:09 AM, step21 f...@terrorpop.de wrote:
 hi,
 why did you scrap ivt.bin loading ... seems much more complicated now.
 I'm not sure if I remeber right, but I think ivt.bin worked best for me ...

Hi,

The latest patch support loading file again, but only int10.bin, not
the whole ivt. In fact, I add a shell script grub-dumpbios that does
the job:

sudo grub-dumpbios -o /boot/

It would then save vbios.bin and int10.bin to /boot/ directory, in grub2:

loadbios /boot/vbios.bin /boot/int10.bin

-- 
Bean


___
Grub-devel mailing list
Grub-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/grub-devel


Re: [PATCH] New frame buffer detection algorithm and loadrom command for efi platform

2009-03-25 Thread Bean
Hi,

The new patch have some adjustment:

1, The loadbios code is moved out of linux.c, it's in a standalone
module loadbios.mod, you could use:

fakebios

or

loadbios /VBIOS.bin

Both will fake acpi and dmi information, loadbios loads video bios rom
from external file as well.

2, loadbios doesn't load ivt.bin anymore, you need to set INT13 with
command write_dword in module memrw. First, use hexdump to get the
INT13 vector from pc boot:

sudo hexdump /dev/mem -e '1/4 0x%x\n' -s 0x40 -n 4

Result is something like this:
0xc014

The high word should always be 0xc000.

In grub2, use write_dword to change INT13:

write_dword 0x40 0xc014

-- 
Bean


loadbios_2.diff
Description: Binary data
___
Grub-devel mailing list
Grub-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/grub-devel


Re: [PATCH] New frame buffer detection algorithm and loadrom command for efi platform

2009-03-24 Thread Peter Cros
Hi,
svn rev 2043 patched loadrom.diff on imac81 with ati fglrx.

I find loadrom needs time when called in menuentry, otherwise linux load
fails or loadrom fails. So I had to use sleep.
Then it works very nicely.
--
insmod sleep

menuentry loadrom hd0,4 sda4 {
search --set /ivt.bin
loadrom /bios.bin /ivt.bin
sleep 1
root=hd0,4
linux /vmlinuz root=/dev/sda4 video=vesafb
initrd /initrd.img
}

This is not apparent from command line with manual entry pauses.
-

2009/3/21 Bean bean12...@gmail.com

 Hi,

 This patch improves the frame buffer detection algorithm. It uses pci
 to find the video memory base, then scan it for frame buffer.

 It also add a loadrom command which can be used to enable accel
 graphic driver. The idea is that you can grab the video bios dump, and
 optionally the IVT from pc mode, then load them in efi.

 To grab bios dump:
 sudo dd if=/dev/mem of=bios.bin bs=65536 skip=12 count=1

 You can also include the system bios by changing the count to 4.

 To grab IVT dump:
 sudo dd if=/dev/mem of=ivt.bin bs=1024 count=1

 Then, to load them in grub-efi (ivt.bin is optionally):
 loadrom /bios.bin /ivt.bin

 Here are some of the findings concerning different video cards:

 Old 32-bit efi model, intel card:
 Works with intel driver, no need to load vbios or ivt.

 New 64-bit efi model, intel card:
 Works with intel driver, needs to load vbios.

 New 64-bit efi model, nvidia card:
 Works with nvidia driver, no needs to load vbios or ivt. However, the
 backlight value is set too low so desktop is barely visible. You need
 to use a small tool to adjust backlight. The nv driver doesn't work.

 New 64-bit efi model, ati radeon card:
 Works with fglrx driver, needs to load vbios and ivt. The radeonhd
 driver doesn't work.

 --
 Bean

 ___
 Grub-devel mailing list
 Grub-devel@gnu.org
 http://lists.gnu.org/mailman/listinfo/grub-devel




-- 
Cros (pxw)
___
Grub-devel mailing list
Grub-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/grub-devel


[PATCH] New frame buffer detection algorithm and loadrom command for efi platform

2009-03-21 Thread Bean
Hi,

This patch improves the frame buffer detection algorithm. It uses pci
to find the video memory base, then scan it for frame buffer.

It also add a loadrom command which can be used to enable accel
graphic driver. The idea is that you can grab the video bios dump, and
optionally the IVT from pc mode, then load them in efi.

To grab bios dump:
sudo dd if=/dev/mem of=bios.bin bs=65536 skip=12 count=1

You can also include the system bios by changing the count to 4.

To grab IVT dump:
sudo dd if=/dev/mem of=ivt.bin bs=1024 count=1

Then, to load them in grub-efi (ivt.bin is optionally):
loadrom /bios.bin /ivt.bin

Here are some of the findings concerning different video cards:

Old 32-bit efi model, intel card:
Works with intel driver, no need to load vbios or ivt.

New 64-bit efi model, intel card:
Works with intel driver, needs to load vbios.

New 64-bit efi model, nvidia card:
Works with nvidia driver, no needs to load vbios or ivt. However, the
backlight value is set too low so desktop is barely visible. You need
to use a small tool to adjust backlight. The nv driver doesn't work.

New 64-bit efi model, ati radeon card:
Works with fglrx driver, needs to load vbios and ivt. The radeonhd
driver doesn't work.

-- 
Bean


loadrom.diff
Description: Binary data
___
Grub-devel mailing list
Grub-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/grub-devel


Re: [PATCH] New frame buffer detection algorithm and loadrom command for efi platform

2009-03-21 Thread step21
nice ... will try to test this asap.

2009/3/21 Bean bean12...@gmail.com:
 Hi,

 This patch improves the frame buffer detection algorithm. It uses pci
 to find the video memory base, then scan it for frame buffer.

 It also add a loadrom command which can be used to enable accel
 graphic driver. The idea is that you can grab the video bios dump, and
 optionally the IVT from pc mode, then load them in efi.

 To grab bios dump:
 sudo dd if=/dev/mem of=bios.bin bs=65536 skip=12 count=1

 You can also include the system bios by changing the count to 4.

 To grab IVT dump:
 sudo dd if=/dev/mem of=ivt.bin bs=1024 count=1

 Then, to load them in grub-efi (ivt.bin is optionally):
 loadrom /bios.bin /ivt.bin

 Here are some of the findings concerning different video cards:

 Old 32-bit efi model, intel card:
 Works with intel driver, no need to load vbios or ivt.

 New 64-bit efi model, intel card:
 Works with intel driver, needs to load vbios.

 New 64-bit efi model, nvidia card:
 Works with nvidia driver, no needs to load vbios or ivt. However, the
 backlight value is set too low so desktop is barely visible. You need
 to use a small tool to adjust backlight. The nv driver doesn't work.

 New 64-bit efi model, ati radeon card:
 Works with fglrx driver, needs to load vbios and ivt. The radeonhd
 driver doesn't work.

 --
 Bean

 ___
 Grub-devel mailing list
 Grub-devel@gnu.org
 http://lists.gnu.org/mailman/listinfo/grub-devel




___
Grub-devel mailing list
Grub-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/grub-devel


Re: [PATCH] New frame buffer detection algorithm and loadrom command for efi platform

2009-03-21 Thread Bean
On Sat, Mar 21, 2009 at 11:49 PM, step21 f...@terrorpop.de wrote:
 nice ... will try to test this asap.

Hi,

Oh btw, there is still problem concerning the nvidia card, intel and
ati cards should be all right.

-- 
Bean


___
Grub-devel mailing list
Grub-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/grub-devel


Re: [PATCH] New frame buffer detection algorithm and loadrom command for efi platform

2009-03-21 Thread Robert Millan
On Sat, Mar 21, 2009 at 06:38:12PM +0800, Bean wrote:
 Hi,
 
 This patch improves the frame buffer detection algorithm. It uses pci
 to find the video memory base, then scan it for frame buffer.

With this detection code getting increasingly more sophisticated, wouldn't
this be a good time to make it a video backend?  (i.e. video/efi.c)

Even if it won't be complete enough for gfxterm yet, it's much better than
doing it in i386/efi/linux.c IMHO.

The code to obtain framebuffer address from video backends is pretty simple.
It's already in i386/linux.c and could be easily integrated into
i386/efi/linux.c.

-- 
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.


___
Grub-devel mailing list
Grub-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/grub-devel