=== modified file 'grub_lib.c'
--- grub_lib.c	2010-09-21 18:00:15 +0000
+++ grub_lib.c	2010-10-27 19:25:37 +0000
@@ -27,6 +27,7 @@
 #include <grub/normal.h>
 #include <grub/file.h>
 #include <grub/device.h>
+#include <grub/pci.h>
 
 /* Updates the globals grub_errno and grub_msg, leaving their values on the 
    top of the stack, and clears grub_errno. When grub_errno is zero, grub_msg
@@ -251,6 +252,38 @@
 }
 
 static int
+grub_lua_enum_pci (lua_State *state)
+{
+  auto int NESTED_FUNC_ATTR enum_pci (grub_pci_device_t dev, grub_pci_id_t pciid);
+  int NESTED_FUNC_ATTR enum_pci (grub_pci_device_t dev, grub_pci_id_t pciid)
+  {
+    int result;
+    grub_pci_address_t addr;
+    grub_uint32_t class;
+
+    lua_pushvalue (state, 1);
+    lua_pushinteger (state, grub_pci_get_bus (dev));
+    lua_pushinteger (state, grub_pci_get_device (dev));
+    lua_pushinteger (state, grub_pci_get_function (dev));
+    lua_pushinteger (state, pciid);
+
+    addr = grub_pci_make_address (dev, GRUB_PCI_REG_CLASS);
+    class = grub_pci_read (addr);
+    lua_pushinteger (state, class);
+
+    lua_call (state, 5, 1);
+    result = lua_tointeger (state, -1);
+    lua_pop (state, 1);
+
+    return result;
+  }
+
+  luaL_checktype (state, 1, LUA_TFUNCTION);
+  grub_pci_iterate (enum_pci);
+  return push_result (state);
+}
+
+static int
 grub_lua_file_open (lua_State *state)
 {
   grub_file_t file;
@@ -446,6 +479,7 @@
     {"setenv", grub_lua_setenv},
     {"enum_device", grub_lua_enum_device},
     {"enum_file", grub_lua_enum_file},
+    {"enum_pci", grub_lua_enum_pci},
     {"file_open", grub_lua_file_open},
     {"file_close", grub_lua_file_close},
     {"file_seek", grub_lua_file_seek},

