Feature Request: 32-bit mem write and 'setpci -s' type command in menu.lst

2009-10-22 Thread Nando
Hi everyone,

I wanted to ask if the following features could be added to grub?

1/ Ability to write to 32-bit memory space
===

I need to set my ICH8M chipset to enable the SMBUS, since the bios disables
it. Rather than add the code to the kernel, I'd prefer to do it in grub.
Grub4dos has such a facility but no such facility in grub's menu.lst. None
that I found anyway. I need to write to following to have access ot my ICS
PLL to be able to do overclocking:

write 0xFED93418 0xC330005

2/ Ability to do a setpci -s type command
==

Also, if possible, could a small subset of 'setpci' be incorporated as well?
I guess I could figure out the address I need to write to by calculation,
but would be nice if I could do the equivalent of the following in grub,
associated with a menu entry. This would help the DIY ViDock project that
needs to setup PCI Bridge windows prior to Windows load, something that many
bios doesn't do, neither does Windows.

setpci -s 00:02.0 40l=20

Comments?? Suggestions??

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


Re: Feature Request: 32-bit mem write and 'setpci -s' type command in menu.lst

2009-10-22 Thread Vladimir 'phcoder' Serbinenko
Nando wrote:
> Hi everyone,
>
> I wanted to ask if the following features could be added to grub?
>
> 1/ Ability to write to 32-bit memory space
> ===
>
> I need to set my ICH8M chipset to enable the SMBUS, since the bios
> disables it. Rather than add the code to the kernel, I'd prefer to do
> it in grub. Grub4dos has such a facility but no such facility in
> grub's menu.lst. 
We don't support grub legacy anymore. Switch to grub2
> None that I found anyway. I need to write to following to have access
> ot my ICS PLL to be able to do overclocking:
>
> write 0xFED93418 0xC330005
look at write_dword
>
> 2/ Ability to do a setpci -s type command
> ==
>
> Also, if possible, could a small subset of 'setpci' be incorporated as
> well? I guess I could figure out the address I need to write to by
> calculation, but would be nice if I could do the equivalent of the
> following in grub, associated with a menu entry. This would help the
> DIY ViDock project that needs to setup PCI Bridge windows prior to
> Windows load, something that many bios doesn't do, neither does Windows.
>
> setpci -s 00:02.0 40l=20
>
it's not implemented yet but is trivial to do. Would you send us a patch?
> Comments?? Suggestions??
>
> Nando
> 
>
> ___
> Grub-devel mailing list
> Grub-devel@gnu.org
> http://lists.gnu.org/mailman/listinfo/grub-devel
>   


-- 
Regards
Vladimir 'phcoder' Serbinenko
Personal git repository: http://repo.or.cz/w/grub2/phcoder.git 



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


Re: Feature Request: 32-bit mem write and 'setpci -s' type command in menu.lst

2009-10-23 Thread Nando
Hi Vlad,

Thank you for this! Just what I was looking for. With pciexbar I'll be able
to do the equivalent of setpci by calculating the addresses needing memory
writes.

Another question -  is there any "write_dump" sort of command where  I can
give an address, a file and it writes the binary data of the file at the
starting address up to the EOF marker? Would help overcome my mPCIe
whitelisting where i have a DOS workaround in place to do exactly that. I
see there is hexdump and dump but neither appear to provide such function.
If it doesn't exist, can a request be made to add it? eg:

write_dump ADDRESS FILE
eg: write_dump 0xF800  dump_file

Nando


On Thu, Oct 22, 2009 at 10:51 PM, Vladimir 'phcoder' Serbinenko <
phco...@gmail.com> wrote:

> > write 0xFED93418 0xC330005
> look at write_dword
> >
>
___
Grub-devel mailing list
Grub-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/grub-devel


Re: Feature Request: 32-bit mem write and 'setpci -s' type command in menu.lst

2009-10-23 Thread Vladimir 'phcoder' Serbinenko
Nando wrote:
> Hi Vlad,
>
> Thank you for this! Just what I was looking for. With pciexbar I'll be
> able to do the equivalent of setpci by calculating the addresses
> needing memory writes.
Except pciconf space
>
> Another question -  is there any "write_dump" sort of command where  I
> can give an address, a file and it writes the binary data of the file
> at the starting address up to the EOF marker? Would help overcome my
> mPCIe whitelisting where i have a DOS workaround in place to do
> exactly that. I see there is hexdump and dump but neither appear to
> provide such function. If it doesn't exist, can a request be made to
> add it? eg:
>
> write_dump ADDRESS FILE
> eg: write_dump 0xF800  dump_file
>
This has already been discussed and conclusion that it's too dangerous
to write to FS from grub2. If it's one time operation you can just boot
FreeDOS for it. IF it's not explain why do you need it on every boot
> Nando
>
>
> On Thu, Oct 22, 2009 at 10:51 PM, Vladimir 'phcoder' Serbinenko
> mailto:phco...@gmail.com>> wrote:
>
> > write 0xFED93418 0xC330005
> look at write_dword
> >
>
>
> 
>
> ___
> Grub-devel mailing list
> Grub-devel@gnu.org
> http://lists.gnu.org/mailman/listinfo/grub-devel
>   


-- 
Regards
Vladimir 'phcoder' Serbinenko
Personal git repository: http://repo.or.cz/w/grub2/phcoder.git 




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


Re: Feature Request: 32-bit mem write and 'setpci -s' type command in menu.lst

2009-10-24 Thread Nando
Hi Vlad,

> able to do the equivalent of setpci by calculating the addresses
> > needing memory writes.
>
Except pciconf space
>

Are you saying that write_dword will not write to pciconf space?


> >
> > write_dump ADDRESS FILE
> > eg: write_dump 0xF800  dump_file
> >
> This has already been discussed and conclusion that it's too dangerous
> to write to FS from grub2. If it's one time operation you can just boot
> FreeDOS for it. IF it's not explain why do you need it on every boot
>
>
I've like *read* a dump file into pciexbar memory space to overcome my wifi
whitelisting. Currently doing this via a grub2 DOS Image entry explained at
http://www.wimsbios.com/phpBB2/topic9388-135.html#53650 . To have such an
ability would mean I could just add another menuitem "Ubunto [reverse
whitelisting]" and bypass the need for the DOS bootimage. This ability would
be further enhanced if a compressed dump file could be used to speed up the
process.

So I guess it should be a request for:

- 'read_dump ADDRESS FILE' for mPCIe wifi whitelsting could be done within
grub2. .
- a 'setpci' type command  to do pci-e pci-port bridge window fixups,
amongst other things.

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


Re: Feature Request: 32-bit mem write and 'setpci -s' type command in menu.lst

2009-10-24 Thread Vladimir 'phcoder' Serbinenko
Nando wrote:
> Hi Vlad,
>
> > able to do the equivalent of setpci by calculating the addresses
> > needing memory writes.
>
> Except pciconf space
>
>
> Are you saying that write_dword will not write to pciconf space? 
pciconf space on x86 is acessible through inw/outw and not through memory
>  
>
> >
> > write_dump ADDRESS FILE
> > eg: write_dump 0xF800  dump_file
> >
> This has already been discussed and conclusion that it's too dangerous
> to write to FS from grub2. If it's one time operation you can just
> boot
> FreeDOS for it. IF it's not explain why do you need it on every boot
>
>
> I've like *read* a dump file into pciexbar memory space to overcome my
> wifi whitelisting. Currently doing this via a grub2 DOS Image entry
> explained at http://www.wimsbios.com/phpBB2/topic9388-135.html#53650 .
> To have such an ability would mean I could just add another menuitem
> "Ubunto [reverse whitelisting]" and bypass the need for the DOS
> bootimage. This ability would be further enhanced if a compressed dump
> file could be used to speed up the process.
>
> So I guess it should be a request for:
>
> - 'read_dump ADDRESS FILE' for mPCIe wifi whitelsting could be done
> within grub2. .
> - a 'setpci' type command  to do pci-e pci-port bridge window fixups,
> amongst other things.
>
Then I'm ok with it but this link doesn't provide technical info on how
it was done. It looks a bit like it's changing acpi tables, if it's the
case grub2 is already able to do this with 'acpi' command. What are
first bytes of dump?
> Nando
> 
>
> ___
> Grub-devel mailing list
> Grub-devel@gnu.org
> http://lists.gnu.org/mailman/listinfo/grub-devel
>   


-- 
Regards
Vladimir 'phcoder' Serbinenko
Personal git repository: http://repo.or.cz/w/grub2/phcoder.git 



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


Re: Feature Request: 32-bit mem write and 'setpci -s' type command in menu.lst

2009-10-24 Thread Bean
On Sat, Oct 24, 2009 at 4:42 PM, Nando  wrote:
> Hi Vlad,
>
>> > able to do the equivalent of setpci by calculating the addresses
>> > needing memory writes.
>>
>> Except pciconf space
>
> Are you saying that write_dword will not write to pciconf space?

Hi,

write_dword can write to MMIO space. In fact, my initial reason to add
this command is to adjust the video card gart address for EFI.

-- 
Bean

gitgrub home: http://github.com/grub/grub/
my fork page: http://github.com/bean123/grub/


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


Re: Feature Request: 32-bit mem write and 'setpci -s' type command in menu.lst

2009-10-24 Thread Seth Goldberg



Quoting Vladimir 'phcoder' Serbinenko, who wrote the following on Sat, 24...:


Nando wrote:

Hi Vlad,

   > able to do the equivalent of setpci by calculating the addresses
   > needing memory writes.

Except pciconf space


Are you saying that write_dword will not write to pciconf space?

pciconf space on x86 is acessible through inw/outw and not through memory


 All modern systems equipped with PCI Express support memory-mapped config 
space access.  If we do implement a pciconf command, it should support 
accessing extended config space as well, via the MMCFG region (we'll need to 
look up the base address of such a region in the ACPI MCFG table).


 --S


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


Re: Feature Request: 32-bit mem write and 'setpci -s' type command in menu.lst

2009-12-22 Thread Vladimir 'φ-coder/phcoder' Serbinenko
Nando wrote:
> Hi Vlad,
>
> > able to do the equivalent of setpci by calculating the addresses
> > needing memory writes.
>
> Except pciconf space
>
>
> Are you saying that write_dword will not write to pciconf space? 
>  
>
> >
> > write_dump ADDRESS FILE
> > eg: write_dump 0xF800  dump_file
> >
> This has already been discussed and conclusion that it's too dangerous
> to write to FS from grub2. If it's one time operation you can just
> boot
> FreeDOS for it. IF it's not explain why do you need it on every boot
>
>
> I've like *read* a dump file into pciexbar memory space to overcome my
> wifi whitelisting. Currently doing this via a grub2 DOS Image entry
> explained at http://www.wimsbios.com/phpBB2/topic9388-135.html#53650 .
> To have such an ability would mean I could just add another menuitem
> "Ubunto [reverse whitelisting]" and bypass the need for the DOS
> bootimage. This ability would be further enhanced if a compressed dump
> file could be used to speed up the process.
>
> So I guess it should be a request for:
>
> - 'read_dump ADDRESS FILE' for mPCIe wifi whitelsting could be done
> within grub2. .
> - a 'setpci' type command  to do pci-e pci-port bridge window fixups,
> amongst other things.
>
MEM I/O isn't necessarily just a normal memory space. Most of the times
it isn't. So writing by dwords, words or bytes won't lead to the same
result. You could say: add an option to specify how to write to MM I/O
but it may happen that some registers need byte and other ones dword writes
> Nando
> 
>
> ___
> Grub-devel mailing list
> Grub-devel@gnu.org
> http://lists.gnu.org/mailman/listinfo/grub-devel
>   


-- 
Regards
Vladimir 'φ-coder/phcoder' Serbinenko




signature.asc
Description: OpenPGP digital signature
___
Grub-devel mailing list
Grub-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/grub-devel


[PATCH] Re: Feature Request: 32-bit mem write and 'setpci -s' type command in menu.lst

2009-12-22 Thread Vladimir 'φ-coder/phcoder' Serbinenko
Nando wrote:
> Hi everyone,
>
>
> 2/ Ability to do a setpci -s type command
> ==
>
> Also, if possible, could a small subset of 'setpci' be incorporated as
> well? I guess I could figure out the address I need to write to by
> calculation, but would be nice if I could do the equivalent of the
> following in grub, associated with a menu entry. This would help the
> DIY ViDock project that needs to setup PCI Bridge windows prior to
> Windows load, something that many bios doesn't do, neither does Windows.
>
> setpci -s 00:02.0 40l=20
>
I attach two patches. One iorw.diff for reading/writing I/O space.
Another one setpci.diff is self-explanatory. But it depends on pciclean
patch I posted today.


-- 
Regards
Vladimir 'φ-coder/phcoder' Serbinenko

=== added file 'commands/setpci.c'
--- commands/setpci.c	1970-01-01 00:00:00 +
+++ commands/setpci.c	2009-12-22 15:42:45 +
@@ -0,0 +1,340 @@
+/* lspci.c - List PCI devices.  */
+/*
+ *  GRUB  --  GRand Unified Bootloader
+ *  Copyright (C) 2008, 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 .
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+struct pci_register
+{
+  const char *name;
+  grub_uint16_t addr;
+  unsigned size;
+};
+
+struct pci_register pci_registers[] =
+  {
+{"VENDOR_ID",   GRUB_PCI_REG_VENDOR  , 2},
+{"DEVICE_ID",   GRUB_PCI_REG_DEVICE  , 2},
+{"COMMAND", GRUB_PCI_REG_COMMAND , 2},
+{"STATUS",  GRUB_PCI_REG_STATUS  , 2},
+{"REVISION",GRUB_PCI_REG_REVISION, 1},
+{"CLASS_PROG",  GRUB_PCI_REG_CLASS + 1   , 1},
+{"CLASS_DEVICE",GRUB_PCI_REG_CLASS + 2   , 2},
+{"CACHE_LINE_SIZE", GRUB_PCI_REG_CACHELINE   , 1},
+{"LATENCY_TIMER",   GRUB_PCI_REG_LAT_TIMER   , 1},
+{"HEADER_TYPE", GRUB_PCI_REG_HEADER_TYPE , 1},
+{"BIST",GRUB_PCI_REG_BIST, 1},
+{"BASE_ADDRESS_0",  GRUB_PCI_REG_ADDRESS_REG0, 4},
+{"BASE_ADDRESS_1",  GRUB_PCI_REG_ADDRESS_REG1, 4},
+{"BASE_ADDRESS_2",  GRUB_PCI_REG_ADDRESS_REG2, 4},
+{"BASE_ADDRESS_3",  GRUB_PCI_REG_ADDRESS_REG3, 4},
+{"BASE_ADDRESS_4",  GRUB_PCI_REG_ADDRESS_REG4, 4},
+{"BASE_ADDRESS_5",  GRUB_PCI_REG_ADDRESS_REG5, 4},
+{"CARDBUS_CIS", GRUB_PCI_REG_CIS_POINTER , 4},
+{"SUBVENDOR_ID",GRUB_PCI_REG_SUBVENDOR   , 2},
+{"SUBSYSTEM_ID",GRUB_PCI_REG_SUBSYSTEM   , 2},
+{"ROM_ADDRESS", GRUB_PCI_REG_ROM_ADDRESS , 4},
+{"CAP_POINTER", GRUB_PCI_REG_CAP_POINTER , 1},
+{"INTERRUPT_LINE",  GRUB_PCI_REG_IRQ_LINE, 1},
+{"INTERRUPT_PIN",   GRUB_PCI_REG_IRQ_PIN , 1},
+{"MIN_GNT", GRUB_PCI_REG_MIN_GNT , 1},
+{"MAX_LAT", GRUB_PCI_REG_MIN_GNT , 1},
+  };
+
+static const struct grub_arg_option options[] =
+  {
+{0, 'd', 0, "Select device by vendor and device IDs.",
+ "[vendor]:[device]", ARG_TYPE_STRING},
+{0, 's', 0, "Select device by its position on the bus.",
+ "[bus]:[slot][.func]", ARG_TYPE_STRING},
+{0, 'v', 0, "Save read value into variable VARNAME.",
+ "VARNAME", ARG_TYPE_STRING},
+{0, 0, 0, 0, 0, 0}
+  };
+
+static grub_uint32_t pciid_check_mask, pciid_check_value;
+static int bus, device, function;
+static int check_bus, check_device, check_function;
+static grub_uint32_t write_mask, regwrite;
+static int regsize;
+static grub_uint16_t regaddr;
+static const char *varname;
+
+static int NESTED_FUNC_ATTR
+grub_setpci_iter (grub_pci_device_t dev, grub_pci_id_t pciid)
+{
+  grub_uint32_t regval = 0;
+  grub_pci_address_t addr;
+
+  if ((pciid & pciid_check_mask) != pciid_check_value)
+return 0;
+
+  if (check_bus && grub_pci_get_bus (dev) != bus)
+return 0;
+
+  if (check_device && grub_pci_get_device (dev) != device)
+return 0;
+
+  if (check_function && grub_pci_get_function (dev) != device)
+return 0;
+
+  addr = grub_pci_make_address (dev, regaddr);
+
+  switch (regsize)
+{
+case 1:
+  regval = grub_pci_read_byte (addr);
+  break;
+
+case 2:
+  regval = grub_pci_read_word (addr);
+  break;
+
+case 4:
+  regval = grub_pci_read (addr);
+  break;
+}
+
+  if (varname)
+{
+  char buf[sizeof ("")];
+  grub_sprintf (buf, "%x", regval);
+  grub_env_set (varname, buf);
+  return 1;
+}
+
+  if (!write_mask)
+