Remove nested functions from PCI iterators.

* grub-core/bus/pci.c (grub_pci_iterate): Add hook_data argument,
passed to hook.  Update all callers to pass appropriate hook data.
* grub-core/bus/emu/pci.c (grub_pci_iterate): Likewise.
* include/grub/pci.h (grub_pci_iteratefunc_t): Add data argument.
Remove NESTED_FUNC_ATTR from here and from all users.
(grub_pci_iterate): Update prototype.
* grub-core/bus/cs5536.c (grub_cs5536_find: hook): Make static
instead of nested.  Rename to ...
(grub_cs5536_find_iter): ... this.
* grub-core/kern/efi/mm.c (stop_broadcom: find_card): Likewise.
* grub-core/kern/mips/loongson/init.c (init_pci: set_card):
Likewise.
* grub-core/kern/vga_init.c (grub_qemu_init_cirrus: find_card):
Likewise.
* grub-core/video/bochs.c (grub_video_bochs_setup: find_card):
Likewise.
* grub-core/video/cirrus.c (grub_video_cirrus_setup: find_card):
Likewise.
* grub-core/video/efi_uga.c (find_framebuf: find_card): Likewise.
* grub-core/video/radeon_fuloong2e.c
(grub_video_radeon_fuloong2e_setup: find_card): Likewise.
* grub-core/video/sis315pro.c (grub_video_sis315pro_setup:
find_card): Likewise.
* grub-core/video/sm712.c (grub_video_sm712_setup: find_card):
Likewise.
This commit is contained in:
Colin Watson 2013-01-13 01:10:41 +00:00
parent f8e98fee04
commit ca3a74469a
22 changed files with 411 additions and 327 deletions

View file

@ -1,3 +1,33 @@
2013-01-13 Colin Watson <cjwatson@ubuntu.com>
Remove nested functions from PCI iterators.
* grub-core/bus/pci.c (grub_pci_iterate): Add hook_data argument,
passed to hook. Update all callers to pass appropriate hook data.
* grub-core/bus/emu/pci.c (grub_pci_iterate): Likewise.
* include/grub/pci.h (grub_pci_iteratefunc_t): Add data argument.
Remove NESTED_FUNC_ATTR from here and from all users.
(grub_pci_iterate): Update prototype.
* grub-core/bus/cs5536.c (grub_cs5536_find: hook): Make static
instead of nested. Rename to ...
(grub_cs5536_find_iter): ... this.
* grub-core/kern/efi/mm.c (stop_broadcom: find_card): Likewise.
* grub-core/kern/mips/loongson/init.c (init_pci: set_card):
Likewise.
* grub-core/kern/vga_init.c (grub_qemu_init_cirrus: find_card):
Likewise.
* grub-core/video/bochs.c (grub_video_bochs_setup: find_card):
Likewise.
* grub-core/video/cirrus.c (grub_video_cirrus_setup: find_card):
Likewise.
* grub-core/video/efi_uga.c (find_framebuf: find_card): Likewise.
* grub-core/video/radeon_fuloong2e.c
(grub_video_radeon_fuloong2e_setup: find_card): Likewise.
* grub-core/video/sis315pro.c (grub_video_sis315pro_setup:
find_card): Likewise.
* grub-core/video/sm712.c (grub_video_sm712_setup: find_card):
Likewise.
2013-01-12 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/commands/verify.c: Mark messages for translating.

View file

@ -29,28 +29,39 @@
GRUB_MOD_LICENSE ("GPLv3+");
int
grub_cs5536_find (grub_pci_device_t *devp)
/* Context for grub_cs5536_find. */
struct grub_cs5536_find_ctx
{
int found = 0;
auto int NESTED_FUNC_ATTR hook (grub_pci_device_t dev,
grub_pci_id_t pciid);
grub_pci_device_t *devp;
int found;
};
int NESTED_FUNC_ATTR hook (grub_pci_device_t dev,
grub_pci_id_t pciid)
/* Helper for grub_cs5536_find. */
static int
grub_cs5536_find_iter (grub_pci_device_t dev, grub_pci_id_t pciid, void *data)
{
struct grub_cs5536_find_ctx *ctx = data;
if (pciid == GRUB_CS5536_PCIID)
{
*devp = dev;
found = 1;
*ctx->devp = dev;
ctx->found = 1;
return 1;
}
return 0;
}
grub_pci_iterate (hook);
int
grub_cs5536_find (grub_pci_device_t *devp)
{
struct grub_cs5536_find_ctx ctx = {
.devp = devp,
.found = 0
};
return found;
grub_pci_iterate (grub_cs5536_find_iter, &ctx);
return ctx.found;
}
grub_uint64_t

View file

@ -32,7 +32,7 @@ grub_pci_make_address (grub_pci_device_t dev, int reg)
}
void
grub_pci_iterate (grub_pci_iteratefunc_t hook)
grub_pci_iterate (grub_pci_iteratefunc_t hook, void *hook_data)
{
struct pci_device_iterator *iter;
struct pci_slot_match slot;
@ -43,7 +43,7 @@ grub_pci_iterate (grub_pci_iteratefunc_t hook)
slot.func = PCI_MATCH_ANY;
iter = pci_slot_match_iterator_create (&slot);
while ((dev = pci_device_next (iter)))
hook (dev, dev->vendor_id | (dev->device_id << 16));
hook (dev, dev->vendor_id | (dev->device_id << 16), hook_data);
pci_iterator_destroy (iter);
}

View file

@ -98,7 +98,7 @@ grub_pci_make_address (grub_pci_device_t dev, int reg)
}
void
grub_pci_iterate (grub_pci_iteratefunc_t hook)
grub_pci_iterate (grub_pci_iteratefunc_t hook, void *hook_data)
{
grub_pci_device_t dev;
grub_pci_address_t addr;
@ -125,7 +125,7 @@ grub_pci_iterate (grub_pci_iteratefunc_t hook)
continue;
}
if (hook (dev, id))
if (hook (dev, id, hook_data))
return;
/* Probe only func = 0 if the device if not multifunction */

View file

@ -454,8 +454,9 @@ grub_ehci_reset (struct grub_ehci *e)
}
/* PCI iteration function... */
static int NESTED_FUNC_ATTR
grub_ehci_pci_iter (grub_pci_device_t dev, grub_pci_id_t pciid)
static int
grub_ehci_pci_iter (grub_pci_device_t dev, grub_pci_id_t pciid,
void *data __attribute__ ((unused)))
{
grub_uint8_t release;
grub_uint32_t class_code;
@ -1814,7 +1815,7 @@ grub_ehci_detect_dev (grub_usb_controller_t dev, int port, int *changed)
static void
grub_ehci_inithw (void)
{
grub_pci_iterate (grub_ehci_pci_iter);
grub_pci_iterate (grub_ehci_pci_iter, NULL);
}
static grub_err_t

View file

@ -213,9 +213,9 @@ grub_ohci_writereg32 (struct grub_ohci *o,
/* Iterate over all PCI devices. Determine if a device is an OHCI
controller. If this is the case, initialize it. */
static int NESTED_FUNC_ATTR
grub_ohci_pci_iter (grub_pci_device_t dev,
grub_pci_id_t pciid)
static int
grub_ohci_pci_iter (grub_pci_device_t dev, grub_pci_id_t pciid,
void *data __attribute__ ((unused)))
{
grub_uint32_t interf;
grub_uint32_t base;
@ -477,7 +477,7 @@ grub_ohci_pci_iter (grub_pci_device_t dev,
static void
grub_ohci_inithw (void)
{
grub_pci_iterate (grub_ohci_pci_iter);
grub_pci_iterate (grub_ohci_pci_iter, NULL);
}

View file

@ -185,9 +185,10 @@ grub_uhci_portstatus (grub_usb_controller_t dev,
/* Iterate over all PCI devices. Determine if a device is an UHCI
controller. If this is the case, initialize it. */
static int NESTED_FUNC_ATTR
static int
grub_uhci_pci_iter (grub_pci_device_t dev,
grub_pci_id_t pciid __attribute__((unused)))
grub_pci_id_t pciid __attribute__((unused)),
void *data __attribute__ ((unused)))
{
grub_uint32_t class_code;
grub_uint32_t class;
@ -351,7 +352,7 @@ grub_uhci_pci_iter (grub_pci_device_t dev,
static void
grub_uhci_inithw (void)
{
grub_pci_iterate (grub_uhci_pci_iter);
grub_pci_iterate (grub_uhci_pci_iter, NULL);
}
static grub_uhci_td_t

View file

@ -23,6 +23,7 @@
#include <grub/pci.h>
#include <grub/command.h>
#include <grub/i18n.h>
#include <grub/mm.h>
GRUB_MOD_LICENSE ("GPLv3+");
@ -40,8 +41,9 @@ static struct grub_video_patch
{0, 0, 0, 0, 0}
};
static int NESTED_FUNC_ATTR
scan_card (grub_pci_device_t dev, grub_pci_id_t pciid)
static int
scan_card (grub_pci_device_t dev, grub_pci_id_t pciid,
void *data __attribute__ ((unused)))
{
grub_pci_address_t addr;
@ -93,7 +95,7 @@ grub_cmd_fixvideo (grub_command_t cmd __attribute__ ((unused)),
int argc __attribute__ ((unused)),
char *argv[] __attribute__ ((unused)))
{
grub_pci_iterate (scan_card);
grub_pci_iterate (scan_card, NULL);
return 0;
}

View file

@ -22,6 +22,7 @@
#include <grub/misc.h>
#include <grub/extcmd.h>
#include <grub/i18n.h>
#include <grub/mm.h>
GRUB_MOD_LICENSE ("GPLv3+");
@ -126,8 +127,9 @@ static const struct grub_arg_option options[] =
static int iospace;
static int NESTED_FUNC_ATTR
grub_lspci_iter (grub_pci_device_t dev, grub_pci_id_t pciid)
static int
grub_lspci_iter (grub_pci_device_t dev, grub_pci_id_t pciid,
void *data __attribute__ ((unused)))
{
grub_uint32_t class;
const char *sclass;
@ -218,7 +220,7 @@ grub_cmd_lspci (grub_extcmd_context_t ctxt,
char **args __attribute__ ((unused)))
{
iospace = ctxt->state[0].set;
grub_pci_iterate (grub_lspci_iter);
grub_pci_iterate (grub_lspci_iter, NULL);
return GRUB_ERR_NONE;
}

View file

@ -83,8 +83,9 @@ 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)
static int
grub_setpci_iter (grub_pci_device_t dev, grub_pci_id_t pciid,
void *data __attribute__ ((unused)))
{
grub_uint32_t regval = 0;
grub_pci_address_t addr;
@ -320,7 +321,7 @@ grub_cmd_setpci (grub_extcmd_context_t ctxt, int argc, char **argv)
return grub_error (GRUB_ERR_BAD_ARGUMENT,
"option -v isn't valid for writes");
grub_pci_iterate (grub_setpci_iter);
grub_pci_iterate (grub_setpci_iter, NULL);
return GRUB_ERR_NONE;
}

View file

@ -254,9 +254,10 @@ init_port (struct grub_ahci_device *dev)
return 1;
}
static int NESTED_FUNC_ATTR
static int
grub_ahci_pciinit (grub_pci_device_t dev,
grub_pci_id_t pciid __attribute__ ((unused)))
grub_pci_id_t pciid __attribute__ ((unused)),
void *data __attribute__ ((unused)))
{
grub_pci_address_t addr;
grub_uint32_t class;
@ -394,7 +395,7 @@ grub_ahci_pciinit (grub_pci_device_t dev,
static grub_err_t
grub_ahci_initialize (void)
{
grub_pci_iterate (grub_ahci_pciinit);
grub_pci_iterate (grub_ahci_pciinit, NULL);
return grub_errno;
}

View file

@ -338,9 +338,10 @@ grub_pata_device_initialize (int port, int device, int addr)
}
#ifndef GRUB_MACHINE_MIPS_QEMU_MIPS
static int NESTED_FUNC_ATTR
static int
grub_pata_pciinit (grub_pci_device_t dev,
grub_pci_id_t pciid)
grub_pci_id_t pciid,
void *data __attribute__ ((unused)))
{
static int compat_use[2] = { 0 };
grub_pci_address_t addr;
@ -446,7 +447,7 @@ grub_pata_pciinit (grub_pci_device_t dev,
static grub_err_t
grub_pata_initialize (void)
{
grub_pci_iterate (grub_pata_pciinit);
grub_pci_iterate (grub_pata_pciinit, NULL);
return 0;
}
#else

View file

@ -109,14 +109,10 @@ grub_efi_free_pages (grub_efi_physical_address_t address,
#if defined (__i386__) || defined (__x86_64__)
static void
stop_broadcom (void)
{
auto int NESTED_FUNC_ATTR find_card (grub_pci_device_t dev,
grub_pci_id_t pciid);
int NESTED_FUNC_ATTR find_card (grub_pci_device_t dev,
grub_pci_id_t pciid)
/* Helper for stop_broadcom. */
static int
find_card (grub_pci_device_t dev, grub_pci_id_t pciid,
void *data __attribute__ ((unused)))
{
grub_pci_address_t addr;
grub_uint8_t cap;
@ -139,7 +135,10 @@ stop_broadcom (void)
return 0;
}
grub_pci_iterate (find_card);
static void
stop_broadcom (void)
{
grub_pci_iterate (find_card, NULL);
}
#endif

View file

@ -49,11 +49,10 @@ grub_machine_mmap_iterate (grub_memory_hook_t hook)
return GRUB_ERR_NONE;
}
static void
init_pci (void)
{
auto int NESTED_FUNC_ATTR set_card (grub_pci_device_t dev, grub_pci_id_t pciid);
int NESTED_FUNC_ATTR set_card (grub_pci_device_t dev, grub_pci_id_t pciid)
/* Helper for init_pci. */
static int
set_card (grub_pci_device_t dev, grub_pci_id_t pciid,
void *data __attribute__ ((unused)))
{
grub_pci_address_t addr;
/* FIXME: autoscan for BARs and devices. */
@ -88,6 +87,9 @@ init_pci (void)
return 0;
}
static void
init_pci (void)
{
*((volatile grub_uint32_t *) GRUB_CPU_LOONGSON_PCI_HIT1_SEL_LO) = 0x8000000c;
*((volatile grub_uint32_t *) GRUB_CPU_LOONGSON_PCI_HIT1_SEL_HI) = 0xffffffff;
@ -110,7 +112,7 @@ init_pci (void)
*((volatile grub_uint32_t *) (GRUB_MACHINE_PCI_CONTROLLER_HEADER
+ GRUB_PCI_REG_ADDRESS_REG1)) = 0;
grub_pci_iterate (set_card);
grub_pci_iterate (set_card, NULL);
}
void

View file

@ -18,6 +18,7 @@
#ifndef __mips__
#include <grub/pci.h>
#include <grub/mm.h>
#endif
#include <grub/machine/kernel.h>
#include <grub/misc.h>
@ -87,12 +88,11 @@ load_palette (void)
grub_vga_palette_write (i, colors[i].r, colors[i].g, colors[i].b);
}
void
grub_qemu_init_cirrus (void)
{
#ifndef __mips__
auto int NESTED_FUNC_ATTR find_card (grub_pci_device_t dev, grub_pci_id_t pciid);
int NESTED_FUNC_ATTR find_card (grub_pci_device_t dev, grub_pci_id_t pciid __attribute__ ((unused)))
/* Helper for grub_qemu_init_cirrus. */
static int
find_card (grub_pci_device_t dev, grub_pci_id_t pciid __attribute__ ((unused)),
void *data __attribute__ ((unused)))
{
grub_pci_address_t addr;
grub_uint32_t class;
@ -117,8 +117,13 @@ grub_qemu_init_cirrus (void)
return 1;
}
#endif
grub_pci_iterate (find_card);
void
grub_qemu_init_cirrus (void)
{
#ifndef __mips__
grub_pci_iterate (find_card, NULL);
#endif
grub_outb (GRUB_VGA_IO_MISC_COLOR,

View file

@ -199,6 +199,29 @@ grub_video_bochs_set_palette (unsigned int start, unsigned int count,
return grub_video_fb_set_palette (start, count, palette_data);
}
/* Helper for grub_video_bochs_setup. */
static int
find_card (grub_pci_device_t dev, grub_pci_id_t pciid, void *data)
{
int *found = data;
grub_pci_address_t addr;
grub_uint32_t class;
addr = grub_pci_make_address (dev, GRUB_PCI_REG_CLASS);
class = grub_pci_read (addr);
if (((class >> 16) & 0xffff) != 0x0300 || pciid != 0x11111234)
return 0;
*found = 1;
addr = grub_pci_make_address (dev, GRUB_PCI_REG_ADDRESS_REG0);
framebuffer.base = grub_pci_read (addr) & GRUB_PCI_ADDR_MEM_MASK;
framebuffer.dev = dev;
return 1;
}
static grub_err_t
grub_video_bochs_setup (unsigned int width, unsigned int height,
grub_video_mode_type_t mode_type,
@ -210,27 +233,6 @@ grub_video_bochs_setup (unsigned int width, unsigned int height,
int pitch, bytes_per_pixel;
grub_size_t page_size; /* The size of a page in bytes. */
auto int NESTED_FUNC_ATTR find_card (grub_pci_device_t dev, grub_pci_id_t pciid);
int NESTED_FUNC_ATTR find_card (grub_pci_device_t dev, grub_pci_id_t pciid)
{
grub_pci_address_t addr;
grub_uint32_t class;
addr = grub_pci_make_address (dev, GRUB_PCI_REG_CLASS);
class = grub_pci_read (addr);
if (((class >> 16) & 0xffff) != 0x0300 || pciid != 0x11111234)
return 0;
found = 1;
addr = grub_pci_make_address (dev, GRUB_PCI_REG_ADDRESS_REG0);
framebuffer.base = grub_pci_read (addr) & GRUB_PCI_ADDR_MEM_MASK;
framebuffer.dev = dev;
return 1;
}
/* Decode depth from mode_type. If it is zero, then autodetect. */
depth = (mode_type & GRUB_VIDEO_MODE_TYPE_DEPTH_MASK)
>> GRUB_VIDEO_MODE_TYPE_DEPTH_POS;
@ -280,7 +282,7 @@ grub_video_bochs_setup (unsigned int width, unsigned int height,
if (page_size > BOCHS_APERTURE_SIZE)
return grub_error (GRUB_ERR_IO, "Not enough video memory for this mode");
grub_pci_iterate (find_card);
grub_pci_iterate (find_card, &found);
if (!found)
return grub_error (GRUB_ERR_IO, "Couldn't find graphics card");

View file

@ -235,19 +235,11 @@ grub_video_cirrus_set_palette (unsigned int start, unsigned int count,
return grub_video_fb_set_palette (start, count, palette_data);
}
static grub_err_t
grub_video_cirrus_setup (unsigned int width, unsigned int height,
grub_video_mode_type_t mode_type,
grub_video_mode_type_t mode_mask)
{
int depth;
grub_err_t err;
int found = 0;
int pitch, bytes_per_pixel;
auto int NESTED_FUNC_ATTR find_card (grub_pci_device_t dev, grub_pci_id_t pciid);
int NESTED_FUNC_ATTR find_card (grub_pci_device_t dev, grub_pci_id_t pciid)
/* Helper for grub_video_cirrus_setup. */
static int
find_card (grub_pci_device_t dev, grub_pci_id_t pciid, void *data)
{
int *found = data;
grub_pci_address_t addr;
grub_uint32_t class;
@ -257,7 +249,7 @@ grub_video_cirrus_setup (unsigned int width, unsigned int height,
if (((class >> 16) & 0xffff) != 0x0300 || pciid != 0x00b81013)
return 0;
found = 1;
*found = 1;
addr = grub_pci_make_address (dev, GRUB_PCI_REG_ADDRESS_REG0);
framebuffer.base = grub_pci_read (addr) & GRUB_PCI_ADDR_MEM_MASK;
@ -266,6 +258,16 @@ grub_video_cirrus_setup (unsigned int width, unsigned int height,
return 1;
}
static grub_err_t
grub_video_cirrus_setup (unsigned int width, unsigned int height,
grub_video_mode_type_t mode_type,
grub_video_mode_type_t mode_mask)
{
int depth;
grub_err_t err;
int found = 0;
int pitch, bytes_per_pixel;
/* Decode depth from mode_type. If it is zero, then autodetect. */
depth = (mode_type & GRUB_VIDEO_MODE_TYPE_DEPTH_MASK)
>> GRUB_VIDEO_MODE_TYPE_DEPTH_POS;
@ -314,7 +316,7 @@ grub_video_cirrus_setup (unsigned int width, unsigned int height,
if (framebuffer.page_size > CIRRUS_APERTURE_SIZE)
return grub_error (GRUB_ERR_IO, "Not enough video memory for this mode");
grub_pci_iterate (find_card);
grub_pci_iterate (find_card, &found);
if (!found)
return grub_error (GRUB_ERR_IO, "Couldn't find graphics card");

View file

@ -81,17 +81,19 @@ find_line_len (grub_uint32_t *fb_base, grub_uint32_t *line_len)
return 0;
}
/* Context for find_framebuf. */
struct find_framebuf_ctx
{
grub_uint32_t *fb_base;
grub_uint32_t *line_len;
int found;
};
/* Helper for find_framebuf. */
static int
find_framebuf (grub_uint32_t *fb_base, grub_uint32_t *line_len)
{
int found = 0;
auto int NESTED_FUNC_ATTR find_card (grub_pci_device_t dev,
grub_pci_id_t pciid);
int NESTED_FUNC_ATTR find_card (grub_pci_device_t dev,
grub_pci_id_t pciid)
find_card (grub_pci_device_t dev, grub_pci_id_t pciid, void *data)
{
struct find_framebuf_ctx *ctx = data;
grub_pci_address_t addr;
addr = grub_pci_make_address (dev, GRUB_PCI_REG_CLASS);
@ -132,11 +134,11 @@ find_framebuf (grub_uint32_t *fb_base, grub_uint32_t *line_len)
"VMEM" : "MMIO"), i,
(unsigned long long) base64);
if ((old_bar1 & GRUB_PCI_ADDR_MEM_PREFETCH) && (! found))
if ((old_bar1 & GRUB_PCI_ADDR_MEM_PREFETCH) && (! ctx->found))
{
*fb_base = base64;
if (find_line_len (fb_base, line_len))
found++;
*ctx->fb_base = base64;
if (find_line_len (ctx->fb_base, ctx->line_len))
ctx->found++;
}
if (type == GRUB_PCI_ADDR_MEM_TYPE_64)
@ -147,11 +149,20 @@ find_framebuf (grub_uint32_t *fb_base, grub_uint32_t *line_len)
}
}
return found;
return ctx->found;
}
grub_pci_iterate (find_card);
return found;
static int
find_framebuf (grub_uint32_t *fb_base, grub_uint32_t *line_len)
{
struct find_framebuf_ctx ctx = {
.fb_base = fb_base,
.line_len = line_len,
.found = 0
};
grub_pci_iterate (find_card, &ctx);
return ctx.found;
}
static int

View file

@ -60,18 +60,12 @@ grub_video_radeon_fuloong2e_video_fini (void)
return grub_video_fb_fini ();
}
static grub_err_t
grub_video_radeon_fuloong2e_setup (unsigned int width, unsigned int height,
unsigned int mode_type, unsigned int mode_mask __attribute__ ((unused)))
{
int depth;
grub_err_t err;
int found = 0;
#ifndef TEST
auto int NESTED_FUNC_ATTR find_card (grub_pci_device_t dev, grub_pci_id_t pciid);
int NESTED_FUNC_ATTR find_card (grub_pci_device_t dev, grub_pci_id_t pciid)
/* Helper for grub_video_radeon_fuloong2e_setup. */
static int
find_card (grub_pci_device_t dev, grub_pci_id_t pciid, void *data)
{
int *found = data;
grub_pci_address_t addr;
grub_uint32_t class;
@ -82,7 +76,7 @@ grub_video_radeon_fuloong2e_setup (unsigned int width, unsigned int height,
|| pciid != 0x515a1002)
return 0;
found = 1;
*found = 1;
addr = grub_pci_make_address (dev, GRUB_PCI_REG_ADDRESS_REG0);
framebuffer.base = grub_pci_read (addr);
@ -90,7 +84,17 @@ grub_video_radeon_fuloong2e_setup (unsigned int width, unsigned int height,
return 1;
}
#endif
static grub_err_t
grub_video_radeon_fuloong2e_setup (unsigned int width, unsigned int height,
unsigned int mode_type, unsigned int mode_mask __attribute__ ((unused)))
{
int depth;
grub_err_t err;
int found = 0;
#ifndef TEST
/* Decode depth from mode_type. If it is zero, then autodetect. */
depth = (mode_type & GRUB_VIDEO_MODE_TYPE_DEPTH_MASK)
>> GRUB_VIDEO_MODE_TYPE_DEPTH_POS;
@ -100,7 +104,7 @@ grub_video_radeon_fuloong2e_setup (unsigned int width, unsigned int height,
return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
"Only 640x480x16 is supported");
grub_pci_iterate (find_card);
grub_pci_iterate (find_card, &found);
if (!found)
return grub_error (GRUB_ERR_IO, "Couldn't find graphics card");
#endif

View file

@ -88,20 +88,12 @@ grub_video_sis315pro_video_fini (void)
#include "sis315_init.c"
static grub_err_t
grub_video_sis315pro_setup (unsigned int width, unsigned int height,
unsigned int mode_type,
unsigned int mode_mask __attribute__ ((unused)))
{
int depth;
grub_err_t err;
int found = 0;
unsigned i;
#ifndef TEST
auto int NESTED_FUNC_ATTR find_card (grub_pci_device_t dev, grub_pci_id_t pciid);
int NESTED_FUNC_ATTR find_card (grub_pci_device_t dev, grub_pci_id_t pciid)
/* Helper for grub_video_sis315pro_setup. */
static int
find_card (grub_pci_device_t dev, grub_pci_id_t pciid, void *data)
{
int *found = data;
grub_pci_address_t addr;
grub_uint32_t class;
@ -112,7 +104,7 @@ grub_video_sis315pro_setup (unsigned int width, unsigned int height,
|| pciid != GRUB_SIS315PRO_PCIID)
return 0;
found = 1;
*found = 1;
addr = grub_pci_make_address (dev, GRUB_PCI_REG_ADDRESS_REG0);
framebuffer.base = grub_pci_read (addr) & GRUB_PCI_ADDR_MEM_MASK;
@ -125,7 +117,19 @@ grub_video_sis315pro_setup (unsigned int width, unsigned int height,
return 1;
}
#endif
static grub_err_t
grub_video_sis315pro_setup (unsigned int width, unsigned int height,
unsigned int mode_type,
unsigned int mode_mask __attribute__ ((unused)))
{
int depth;
grub_err_t err;
int found = 0;
unsigned i;
#ifndef TEST
/* Decode depth from mode_type. If it is zero, then autodetect. */
depth = (mode_type & GRUB_VIDEO_MODE_TYPE_DEPTH_MASK)
>> GRUB_VIDEO_MODE_TYPE_DEPTH_POS;
@ -135,7 +139,7 @@ grub_video_sis315pro_setup (unsigned int width, unsigned int height,
return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
"Only 640x480x8 is supported");
grub_pci_iterate (find_card);
grub_pci_iterate (find_card, &found);
if (!found)
return grub_error (GRUB_ERR_IO, "Couldn't find graphics card");
#endif

View file

@ -360,19 +360,12 @@ grub_sm712_write_dda_lookup (int idx, grub_uint8_t compare, grub_uint16_t dda,
GRUB_SM712_CR_DDA_LOOKUP_REG1_START + idx);
}
static grub_err_t
grub_video_sm712_setup (unsigned int width, unsigned int height,
unsigned int mode_type, unsigned int mode_mask __attribute__ ((unused)))
{
unsigned i;
#if !defined (TEST) && !defined(GENINIT)
int depth;
grub_err_t err;
int found = 0;
auto int NESTED_FUNC_ATTR find_card (grub_pci_device_t dev, grub_pci_id_t pciid);
int NESTED_FUNC_ATTR find_card (grub_pci_device_t dev, grub_pci_id_t pciid)
/* Helper for grub_video_sm712_setup. */
static int
find_card (grub_pci_device_t dev, grub_pci_id_t pciid, void *data)
{
int *found = data;
grub_pci_address_t addr;
grub_uint32_t class;
@ -383,7 +376,7 @@ grub_video_sm712_setup (unsigned int width, unsigned int height,
|| pciid != GRUB_SM712_PCIID)
return 0;
found = 1;
*found = 1;
addr = grub_pci_make_address (dev, GRUB_PCI_REG_ADDRESS_REG0);
framebuffer.base = grub_pci_read (addr);
@ -391,6 +384,17 @@ grub_video_sm712_setup (unsigned int width, unsigned int height,
return 1;
}
#endif
static grub_err_t
grub_video_sm712_setup (unsigned int width, unsigned int height,
unsigned int mode_type, unsigned int mode_mask __attribute__ ((unused)))
{
unsigned i;
#if !defined (TEST) && !defined(GENINIT)
int depth;
grub_err_t err;
int found = 0;
/* Decode depth from mode_type. If it is zero, then autodetect. */
depth = (mode_type & GRUB_VIDEO_MODE_TYPE_DEPTH_MASK)
@ -401,7 +405,7 @@ grub_video_sm712_setup (unsigned int width, unsigned int height,
return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
"Only 1024x600x16 is supported");
grub_pci_iterate (find_card);
grub_pci_iterate (find_card, &found);
if (!found)
return grub_error (GRUB_ERR_IO, "Couldn't find graphics card");
/* Fill mode info details. */

View file

@ -132,13 +132,14 @@ grub_pci_get_function (grub_pci_device_t dev)
#include <grub/cpu/pci.h>
#endif
typedef int NESTED_FUNC_ATTR (*grub_pci_iteratefunc_t)
(grub_pci_device_t dev, grub_pci_id_t pciid);
typedef int (*grub_pci_iteratefunc_t)
(grub_pci_device_t dev, grub_pci_id_t pciid, void *data);
grub_pci_address_t EXPORT_FUNC(grub_pci_make_address) (grub_pci_device_t dev,
int reg);
void EXPORT_FUNC(grub_pci_iterate) (grub_pci_iteratefunc_t hook);
void EXPORT_FUNC(grub_pci_iterate) (grub_pci_iteratefunc_t hook,
void *hook_data);
struct grub_pci_dma_chunk;