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:
parent
f8e98fee04
commit
ca3a74469a
22 changed files with 411 additions and 327 deletions
|
@ -235,6 +235,29 @@ grub_video_cirrus_set_palette (unsigned int start, unsigned int count,
|
|||
return grub_video_fb_set_palette (start, count, palette_data);
|
||||
}
|
||||
|
||||
/* 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;
|
||||
|
||||
addr = grub_pci_make_address (dev, GRUB_PCI_REG_CLASS);
|
||||
class = grub_pci_read (addr);
|
||||
|
||||
if (((class >> 16) & 0xffff) != 0x0300 || pciid != 0x00b81013)
|
||||
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_cirrus_setup (unsigned int width, unsigned int height,
|
||||
grub_video_mode_type_t mode_type,
|
||||
|
@ -245,27 +268,6 @@ grub_video_cirrus_setup (unsigned int width, unsigned int height,
|
|||
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)
|
||||
{
|
||||
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 != 0x00b81013)
|
||||
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;
|
||||
|
@ -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");
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue