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
30
ChangeLog
30
ChangeLog
|
@ -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>
|
2013-01-12 Vladimir Serbinenko <phcoder@gmail.com>
|
||||||
|
|
||||||
* grub-core/commands/verify.c: Mark messages for translating.
|
* grub-core/commands/verify.c: Mark messages for translating.
|
||||||
|
|
|
@ -29,28 +29,39 @@
|
||||||
|
|
||||||
GRUB_MOD_LICENSE ("GPLv3+");
|
GRUB_MOD_LICENSE ("GPLv3+");
|
||||||
|
|
||||||
int
|
/* Context for grub_cs5536_find. */
|
||||||
grub_cs5536_find (grub_pci_device_t *devp)
|
struct grub_cs5536_find_ctx
|
||||||
{
|
{
|
||||||
int found = 0;
|
grub_pci_device_t *devp;
|
||||||
auto int NESTED_FUNC_ATTR hook (grub_pci_device_t dev,
|
int found;
|
||||||
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;
|
||||||
|
|
||||||
int NESTED_FUNC_ATTR hook (grub_pci_device_t dev,
|
|
||||||
grub_pci_id_t pciid)
|
|
||||||
{
|
|
||||||
if (pciid == GRUB_CS5536_PCIID)
|
if (pciid == GRUB_CS5536_PCIID)
|
||||||
{
|
{
|
||||||
*devp = dev;
|
*ctx->devp = dev;
|
||||||
found = 1;
|
ctx->found = 1;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
return 0;
|
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
|
grub_uint64_t
|
||||||
|
|
|
@ -32,7 +32,7 @@ grub_pci_make_address (grub_pci_device_t dev, int reg)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
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_device_iterator *iter;
|
||||||
struct pci_slot_match slot;
|
struct pci_slot_match slot;
|
||||||
|
@ -43,7 +43,7 @@ grub_pci_iterate (grub_pci_iteratefunc_t hook)
|
||||||
slot.func = PCI_MATCH_ANY;
|
slot.func = PCI_MATCH_ANY;
|
||||||
iter = pci_slot_match_iterator_create (&slot);
|
iter = pci_slot_match_iterator_create (&slot);
|
||||||
while ((dev = pci_device_next (iter)))
|
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);
|
pci_iterator_destroy (iter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -98,7 +98,7 @@ grub_pci_make_address (grub_pci_device_t dev, int reg)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
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_device_t dev;
|
||||||
grub_pci_address_t addr;
|
grub_pci_address_t addr;
|
||||||
|
@ -125,7 +125,7 @@ grub_pci_iterate (grub_pci_iteratefunc_t hook)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hook (dev, id))
|
if (hook (dev, id, hook_data))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* Probe only func = 0 if the device if not multifunction */
|
/* Probe only func = 0 if the device if not multifunction */
|
||||||
|
|
|
@ -454,8 +454,9 @@ grub_ehci_reset (struct grub_ehci *e)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* PCI iteration function... */
|
/* PCI iteration function... */
|
||||||
static int NESTED_FUNC_ATTR
|
static int
|
||||||
grub_ehci_pci_iter (grub_pci_device_t dev, grub_pci_id_t pciid)
|
grub_ehci_pci_iter (grub_pci_device_t dev, grub_pci_id_t pciid,
|
||||||
|
void *data __attribute__ ((unused)))
|
||||||
{
|
{
|
||||||
grub_uint8_t release;
|
grub_uint8_t release;
|
||||||
grub_uint32_t class_code;
|
grub_uint32_t class_code;
|
||||||
|
@ -1814,7 +1815,7 @@ grub_ehci_detect_dev (grub_usb_controller_t dev, int port, int *changed)
|
||||||
static void
|
static void
|
||||||
grub_ehci_inithw (void)
|
grub_ehci_inithw (void)
|
||||||
{
|
{
|
||||||
grub_pci_iterate (grub_ehci_pci_iter);
|
grub_pci_iterate (grub_ehci_pci_iter, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static grub_err_t
|
static grub_err_t
|
||||||
|
|
|
@ -213,9 +213,9 @@ grub_ohci_writereg32 (struct grub_ohci *o,
|
||||||
|
|
||||||
/* Iterate over all PCI devices. Determine if a device is an OHCI
|
/* Iterate over all PCI devices. Determine if a device is an OHCI
|
||||||
controller. If this is the case, initialize it. */
|
controller. If this is the case, initialize it. */
|
||||||
static int NESTED_FUNC_ATTR
|
static int
|
||||||
grub_ohci_pci_iter (grub_pci_device_t dev,
|
grub_ohci_pci_iter (grub_pci_device_t dev, grub_pci_id_t pciid,
|
||||||
grub_pci_id_t pciid)
|
void *data __attribute__ ((unused)))
|
||||||
{
|
{
|
||||||
grub_uint32_t interf;
|
grub_uint32_t interf;
|
||||||
grub_uint32_t base;
|
grub_uint32_t base;
|
||||||
|
@ -477,7 +477,7 @@ grub_ohci_pci_iter (grub_pci_device_t dev,
|
||||||
static void
|
static void
|
||||||
grub_ohci_inithw (void)
|
grub_ohci_inithw (void)
|
||||||
{
|
{
|
||||||
grub_pci_iterate (grub_ohci_pci_iter);
|
grub_pci_iterate (grub_ohci_pci_iter, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -185,9 +185,10 @@ grub_uhci_portstatus (grub_usb_controller_t dev,
|
||||||
|
|
||||||
/* Iterate over all PCI devices. Determine if a device is an UHCI
|
/* Iterate over all PCI devices. Determine if a device is an UHCI
|
||||||
controller. If this is the case, initialize it. */
|
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_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_code;
|
||||||
grub_uint32_t class;
|
grub_uint32_t class;
|
||||||
|
@ -351,7 +352,7 @@ grub_uhci_pci_iter (grub_pci_device_t dev,
|
||||||
static void
|
static void
|
||||||
grub_uhci_inithw (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
|
static grub_uhci_td_t
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
#include <grub/pci.h>
|
#include <grub/pci.h>
|
||||||
#include <grub/command.h>
|
#include <grub/command.h>
|
||||||
#include <grub/i18n.h>
|
#include <grub/i18n.h>
|
||||||
|
#include <grub/mm.h>
|
||||||
|
|
||||||
GRUB_MOD_LICENSE ("GPLv3+");
|
GRUB_MOD_LICENSE ("GPLv3+");
|
||||||
|
|
||||||
|
@ -40,8 +41,9 @@ static struct grub_video_patch
|
||||||
{0, 0, 0, 0, 0}
|
{0, 0, 0, 0, 0}
|
||||||
};
|
};
|
||||||
|
|
||||||
static int NESTED_FUNC_ATTR
|
static int
|
||||||
scan_card (grub_pci_device_t dev, grub_pci_id_t pciid)
|
scan_card (grub_pci_device_t dev, grub_pci_id_t pciid,
|
||||||
|
void *data __attribute__ ((unused)))
|
||||||
{
|
{
|
||||||
grub_pci_address_t addr;
|
grub_pci_address_t addr;
|
||||||
|
|
||||||
|
@ -93,7 +95,7 @@ grub_cmd_fixvideo (grub_command_t cmd __attribute__ ((unused)),
|
||||||
int argc __attribute__ ((unused)),
|
int argc __attribute__ ((unused)),
|
||||||
char *argv[] __attribute__ ((unused)))
|
char *argv[] __attribute__ ((unused)))
|
||||||
{
|
{
|
||||||
grub_pci_iterate (scan_card);
|
grub_pci_iterate (scan_card, NULL);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
#include <grub/misc.h>
|
#include <grub/misc.h>
|
||||||
#include <grub/extcmd.h>
|
#include <grub/extcmd.h>
|
||||||
#include <grub/i18n.h>
|
#include <grub/i18n.h>
|
||||||
|
#include <grub/mm.h>
|
||||||
|
|
||||||
GRUB_MOD_LICENSE ("GPLv3+");
|
GRUB_MOD_LICENSE ("GPLv3+");
|
||||||
|
|
||||||
|
@ -126,8 +127,9 @@ static const struct grub_arg_option options[] =
|
||||||
|
|
||||||
static int iospace;
|
static int iospace;
|
||||||
|
|
||||||
static int NESTED_FUNC_ATTR
|
static int
|
||||||
grub_lspci_iter (grub_pci_device_t dev, grub_pci_id_t pciid)
|
grub_lspci_iter (grub_pci_device_t dev, grub_pci_id_t pciid,
|
||||||
|
void *data __attribute__ ((unused)))
|
||||||
{
|
{
|
||||||
grub_uint32_t class;
|
grub_uint32_t class;
|
||||||
const char *sclass;
|
const char *sclass;
|
||||||
|
@ -218,7 +220,7 @@ grub_cmd_lspci (grub_extcmd_context_t ctxt,
|
||||||
char **args __attribute__ ((unused)))
|
char **args __attribute__ ((unused)))
|
||||||
{
|
{
|
||||||
iospace = ctxt->state[0].set;
|
iospace = ctxt->state[0].set;
|
||||||
grub_pci_iterate (grub_lspci_iter);
|
grub_pci_iterate (grub_lspci_iter, NULL);
|
||||||
return GRUB_ERR_NONE;
|
return GRUB_ERR_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -83,8 +83,9 @@ static int regsize;
|
||||||
static grub_uint16_t regaddr;
|
static grub_uint16_t regaddr;
|
||||||
static const char *varname;
|
static const char *varname;
|
||||||
|
|
||||||
static int NESTED_FUNC_ATTR
|
static int
|
||||||
grub_setpci_iter (grub_pci_device_t dev, grub_pci_id_t pciid)
|
grub_setpci_iter (grub_pci_device_t dev, grub_pci_id_t pciid,
|
||||||
|
void *data __attribute__ ((unused)))
|
||||||
{
|
{
|
||||||
grub_uint32_t regval = 0;
|
grub_uint32_t regval = 0;
|
||||||
grub_pci_address_t addr;
|
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,
|
return grub_error (GRUB_ERR_BAD_ARGUMENT,
|
||||||
"option -v isn't valid for writes");
|
"option -v isn't valid for writes");
|
||||||
|
|
||||||
grub_pci_iterate (grub_setpci_iter);
|
grub_pci_iterate (grub_setpci_iter, NULL);
|
||||||
return GRUB_ERR_NONE;
|
return GRUB_ERR_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -254,9 +254,10 @@ init_port (struct grub_ahci_device *dev)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int NESTED_FUNC_ATTR
|
static int
|
||||||
grub_ahci_pciinit (grub_pci_device_t dev,
|
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_pci_address_t addr;
|
||||||
grub_uint32_t class;
|
grub_uint32_t class;
|
||||||
|
@ -394,7 +395,7 @@ grub_ahci_pciinit (grub_pci_device_t dev,
|
||||||
static grub_err_t
|
static grub_err_t
|
||||||
grub_ahci_initialize (void)
|
grub_ahci_initialize (void)
|
||||||
{
|
{
|
||||||
grub_pci_iterate (grub_ahci_pciinit);
|
grub_pci_iterate (grub_ahci_pciinit, NULL);
|
||||||
return grub_errno;
|
return grub_errno;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -338,9 +338,10 @@ grub_pata_device_initialize (int port, int device, int addr)
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef GRUB_MACHINE_MIPS_QEMU_MIPS
|
#ifndef GRUB_MACHINE_MIPS_QEMU_MIPS
|
||||||
static int NESTED_FUNC_ATTR
|
static int
|
||||||
grub_pata_pciinit (grub_pci_device_t dev,
|
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 };
|
static int compat_use[2] = { 0 };
|
||||||
grub_pci_address_t addr;
|
grub_pci_address_t addr;
|
||||||
|
@ -446,7 +447,7 @@ grub_pata_pciinit (grub_pci_device_t dev,
|
||||||
static grub_err_t
|
static grub_err_t
|
||||||
grub_pata_initialize (void)
|
grub_pata_initialize (void)
|
||||||
{
|
{
|
||||||
grub_pci_iterate (grub_pata_pciinit);
|
grub_pci_iterate (grub_pata_pciinit, NULL);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
|
|
@ -109,15 +109,11 @@ grub_efi_free_pages (grub_efi_physical_address_t address,
|
||||||
|
|
||||||
#if defined (__i386__) || defined (__x86_64__)
|
#if defined (__i386__) || defined (__x86_64__)
|
||||||
|
|
||||||
static void
|
/* Helper for stop_broadcom. */
|
||||||
stop_broadcom (void)
|
static int
|
||||||
|
find_card (grub_pci_device_t dev, grub_pci_id_t pciid,
|
||||||
|
void *data __attribute__ ((unused)))
|
||||||
{
|
{
|
||||||
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_pci_address_t addr;
|
||||||
grub_uint8_t cap;
|
grub_uint8_t cap;
|
||||||
grub_uint16_t pm_state;
|
grub_uint16_t pm_state;
|
||||||
|
@ -137,9 +133,12 @@ stop_broadcom (void)
|
||||||
grub_pci_write_word (addr, pm_state);
|
grub_pci_write_word (addr, pm_state);
|
||||||
grub_pci_read_word (addr);
|
grub_pci_read_word (addr);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
grub_pci_iterate (find_card);
|
static void
|
||||||
|
stop_broadcom (void)
|
||||||
|
{
|
||||||
|
grub_pci_iterate (find_card, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -49,12 +49,11 @@ grub_machine_mmap_iterate (grub_memory_hook_t hook)
|
||||||
return GRUB_ERR_NONE;
|
return GRUB_ERR_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
/* Helper for init_pci. */
|
||||||
init_pci (void)
|
static int
|
||||||
|
set_card (grub_pci_device_t dev, grub_pci_id_t pciid,
|
||||||
|
void *data __attribute__ ((unused)))
|
||||||
{
|
{
|
||||||
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)
|
|
||||||
{
|
|
||||||
grub_pci_address_t addr;
|
grub_pci_address_t addr;
|
||||||
/* FIXME: autoscan for BARs and devices. */
|
/* FIXME: autoscan for BARs and devices. */
|
||||||
switch (pciid)
|
switch (pciid)
|
||||||
|
@ -86,8 +85,11 @@ init_pci (void)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return 0;
|
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_LO) = 0x8000000c;
|
||||||
*((volatile grub_uint32_t *) GRUB_CPU_LOONGSON_PCI_HIT1_SEL_HI) = 0xffffffff;
|
*((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
|
*((volatile grub_uint32_t *) (GRUB_MACHINE_PCI_CONTROLLER_HEADER
|
||||||
+ GRUB_PCI_REG_ADDRESS_REG1)) = 0;
|
+ GRUB_PCI_REG_ADDRESS_REG1)) = 0;
|
||||||
|
|
||||||
grub_pci_iterate (set_card);
|
grub_pci_iterate (set_card, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
|
|
||||||
#ifndef __mips__
|
#ifndef __mips__
|
||||||
#include <grub/pci.h>
|
#include <grub/pci.h>
|
||||||
|
#include <grub/mm.h>
|
||||||
#endif
|
#endif
|
||||||
#include <grub/machine/kernel.h>
|
#include <grub/machine/kernel.h>
|
||||||
#include <grub/misc.h>
|
#include <grub/misc.h>
|
||||||
|
@ -87,13 +88,12 @@ load_palette (void)
|
||||||
grub_vga_palette_write (i, colors[i].r, colors[i].g, colors[i].b);
|
grub_vga_palette_write (i, colors[i].r, colors[i].g, colors[i].b);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
grub_qemu_init_cirrus (void)
|
|
||||||
{
|
|
||||||
#ifndef __mips__
|
#ifndef __mips__
|
||||||
auto int NESTED_FUNC_ATTR find_card (grub_pci_device_t dev, grub_pci_id_t pciid);
|
/* Helper for grub_qemu_init_cirrus. */
|
||||||
int NESTED_FUNC_ATTR find_card (grub_pci_device_t dev, grub_pci_id_t pciid __attribute__ ((unused)))
|
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_pci_address_t addr;
|
||||||
grub_uint32_t class;
|
grub_uint32_t class;
|
||||||
|
|
||||||
|
@ -116,9 +116,14 @@ grub_qemu_init_cirrus (void)
|
||||||
| GRUB_PCI_COMMAND_IO_ENABLED);
|
| GRUB_PCI_COMMAND_IO_ENABLED);
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
grub_pci_iterate (find_card);
|
void
|
||||||
|
grub_qemu_init_cirrus (void)
|
||||||
|
{
|
||||||
|
#ifndef __mips__
|
||||||
|
grub_pci_iterate (find_card, NULL);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
grub_outb (GRUB_VGA_IO_MISC_COLOR,
|
grub_outb (GRUB_VGA_IO_MISC_COLOR,
|
||||||
|
|
|
@ -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);
|
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
|
static grub_err_t
|
||||||
grub_video_bochs_setup (unsigned int width, unsigned int height,
|
grub_video_bochs_setup (unsigned int width, unsigned int height,
|
||||||
grub_video_mode_type_t mode_type,
|
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;
|
int pitch, bytes_per_pixel;
|
||||||
grub_size_t page_size; /* The size of a page in bytes. */
|
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. */
|
/* Decode depth from mode_type. If it is zero, then autodetect. */
|
||||||
depth = (mode_type & GRUB_VIDEO_MODE_TYPE_DEPTH_MASK)
|
depth = (mode_type & GRUB_VIDEO_MODE_TYPE_DEPTH_MASK)
|
||||||
>> GRUB_VIDEO_MODE_TYPE_DEPTH_POS;
|
>> 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)
|
if (page_size > BOCHS_APERTURE_SIZE)
|
||||||
return grub_error (GRUB_ERR_IO, "Not enough video memory for this mode");
|
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)
|
if (!found)
|
||||||
return grub_error (GRUB_ERR_IO, "Couldn't find graphics card");
|
return grub_error (GRUB_ERR_IO, "Couldn't find graphics card");
|
||||||
|
|
||||||
|
|
|
@ -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);
|
return grub_video_fb_set_palette (start, count, palette_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
static grub_err_t
|
/* Helper for grub_video_cirrus_setup. */
|
||||||
grub_video_cirrus_setup (unsigned int width, unsigned int height,
|
static int
|
||||||
grub_video_mode_type_t mode_type,
|
find_card (grub_pci_device_t dev, grub_pci_id_t pciid, void *data)
|
||||||
grub_video_mode_type_t mode_mask)
|
|
||||||
{
|
{
|
||||||
int depth;
|
int *found = data;
|
||||||
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)
|
|
||||||
{
|
|
||||||
grub_pci_address_t addr;
|
grub_pci_address_t addr;
|
||||||
grub_uint32_t class;
|
grub_uint32_t class;
|
||||||
|
|
||||||
|
@ -257,14 +249,24 @@ grub_video_cirrus_setup (unsigned int width, unsigned int height,
|
||||||
if (((class >> 16) & 0xffff) != 0x0300 || pciid != 0x00b81013)
|
if (((class >> 16) & 0xffff) != 0x0300 || pciid != 0x00b81013)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
found = 1;
|
*found = 1;
|
||||||
|
|
||||||
addr = grub_pci_make_address (dev, GRUB_PCI_REG_ADDRESS_REG0);
|
addr = grub_pci_make_address (dev, GRUB_PCI_REG_ADDRESS_REG0);
|
||||||
framebuffer.base = grub_pci_read (addr) & GRUB_PCI_ADDR_MEM_MASK;
|
framebuffer.base = grub_pci_read (addr) & GRUB_PCI_ADDR_MEM_MASK;
|
||||||
framebuffer.dev = dev;
|
framebuffer.dev = dev;
|
||||||
|
|
||||||
return 1;
|
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. */
|
/* Decode depth from mode_type. If it is zero, then autodetect. */
|
||||||
depth = (mode_type & GRUB_VIDEO_MODE_TYPE_DEPTH_MASK)
|
depth = (mode_type & GRUB_VIDEO_MODE_TYPE_DEPTH_MASK)
|
||||||
|
@ -314,7 +316,7 @@ grub_video_cirrus_setup (unsigned int width, unsigned int height,
|
||||||
if (framebuffer.page_size > CIRRUS_APERTURE_SIZE)
|
if (framebuffer.page_size > CIRRUS_APERTURE_SIZE)
|
||||||
return grub_error (GRUB_ERR_IO, "Not enough video memory for this mode");
|
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)
|
if (!found)
|
||||||
return grub_error (GRUB_ERR_IO, "Couldn't find graphics card");
|
return grub_error (GRUB_ERR_IO, "Couldn't find graphics card");
|
||||||
|
|
||||||
|
|
|
@ -81,17 +81,19 @@ find_line_len (grub_uint32_t *fb_base, grub_uint32_t *line_len)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
/* Context for find_framebuf. */
|
||||||
find_framebuf (grub_uint32_t *fb_base, grub_uint32_t *line_len)
|
struct find_framebuf_ctx
|
||||||
{
|
{
|
||||||
int found = 0;
|
grub_uint32_t *fb_base;
|
||||||
|
grub_uint32_t *line_len;
|
||||||
|
int found;
|
||||||
|
};
|
||||||
|
|
||||||
auto int NESTED_FUNC_ATTR find_card (grub_pci_device_t dev,
|
/* Helper for find_framebuf. */
|
||||||
grub_pci_id_t pciid);
|
static int
|
||||||
|
find_card (grub_pci_device_t dev, grub_pci_id_t pciid, void *data)
|
||||||
int NESTED_FUNC_ATTR find_card (grub_pci_device_t dev,
|
{
|
||||||
grub_pci_id_t pciid)
|
struct find_framebuf_ctx *ctx = data;
|
||||||
{
|
|
||||||
grub_pci_address_t addr;
|
grub_pci_address_t addr;
|
||||||
|
|
||||||
addr = grub_pci_make_address (dev, GRUB_PCI_REG_CLASS);
|
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,
|
"VMEM" : "MMIO"), i,
|
||||||
(unsigned long long) base64);
|
(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;
|
*ctx->fb_base = base64;
|
||||||
if (find_line_len (fb_base, line_len))
|
if (find_line_len (ctx->fb_base, ctx->line_len))
|
||||||
found++;
|
ctx->found++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type == GRUB_PCI_ADDR_MEM_TYPE_64)
|
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);
|
static int
|
||||||
return found;
|
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
|
static int
|
||||||
|
|
|
@ -60,18 +60,12 @@ grub_video_radeon_fuloong2e_video_fini (void)
|
||||||
return grub_video_fb_fini ();
|
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
|
#ifndef TEST
|
||||||
auto int NESTED_FUNC_ATTR find_card (grub_pci_device_t dev, grub_pci_id_t pciid);
|
/* Helper for grub_video_radeon_fuloong2e_setup. */
|
||||||
int NESTED_FUNC_ATTR find_card (grub_pci_device_t dev, grub_pci_id_t pciid)
|
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_pci_address_t addr;
|
||||||
grub_uint32_t class;
|
grub_uint32_t class;
|
||||||
|
|
||||||
|
@ -82,15 +76,25 @@ grub_video_radeon_fuloong2e_setup (unsigned int width, unsigned int height,
|
||||||
|| pciid != 0x515a1002)
|
|| pciid != 0x515a1002)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
found = 1;
|
*found = 1;
|
||||||
|
|
||||||
addr = grub_pci_make_address (dev, GRUB_PCI_REG_ADDRESS_REG0);
|
addr = grub_pci_make_address (dev, GRUB_PCI_REG_ADDRESS_REG0);
|
||||||
framebuffer.base = grub_pci_read (addr);
|
framebuffer.base = grub_pci_read (addr);
|
||||||
framebuffer.dev = dev;
|
framebuffer.dev = dev;
|
||||||
|
|
||||||
return 1;
|
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. */
|
/* Decode depth from mode_type. If it is zero, then autodetect. */
|
||||||
depth = (mode_type & GRUB_VIDEO_MODE_TYPE_DEPTH_MASK)
|
depth = (mode_type & GRUB_VIDEO_MODE_TYPE_DEPTH_MASK)
|
||||||
>> GRUB_VIDEO_MODE_TYPE_DEPTH_POS;
|
>> 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,
|
return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
|
||||||
"Only 640x480x16 is supported");
|
"Only 640x480x16 is supported");
|
||||||
|
|
||||||
grub_pci_iterate (find_card);
|
grub_pci_iterate (find_card, &found);
|
||||||
if (!found)
|
if (!found)
|
||||||
return grub_error (GRUB_ERR_IO, "Couldn't find graphics card");
|
return grub_error (GRUB_ERR_IO, "Couldn't find graphics card");
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -88,20 +88,12 @@ grub_video_sis315pro_video_fini (void)
|
||||||
|
|
||||||
#include "sis315_init.c"
|
#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
|
#ifndef TEST
|
||||||
auto int NESTED_FUNC_ATTR find_card (grub_pci_device_t dev, grub_pci_id_t pciid);
|
/* Helper for grub_video_sis315pro_setup. */
|
||||||
int NESTED_FUNC_ATTR find_card (grub_pci_device_t dev, grub_pci_id_t pciid)
|
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_pci_address_t addr;
|
||||||
grub_uint32_t class;
|
grub_uint32_t class;
|
||||||
|
|
||||||
|
@ -112,7 +104,7 @@ grub_video_sis315pro_setup (unsigned int width, unsigned int height,
|
||||||
|| pciid != GRUB_SIS315PRO_PCIID)
|
|| pciid != GRUB_SIS315PRO_PCIID)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
found = 1;
|
*found = 1;
|
||||||
|
|
||||||
addr = grub_pci_make_address (dev, GRUB_PCI_REG_ADDRESS_REG0);
|
addr = grub_pci_make_address (dev, GRUB_PCI_REG_ADDRESS_REG0);
|
||||||
framebuffer.base = grub_pci_read (addr) & GRUB_PCI_ADDR_MEM_MASK;
|
framebuffer.base = grub_pci_read (addr) & GRUB_PCI_ADDR_MEM_MASK;
|
||||||
|
@ -124,8 +116,20 @@ grub_video_sis315pro_setup (unsigned int width, unsigned int height,
|
||||||
framebuffer.dev = dev;
|
framebuffer.dev = dev;
|
||||||
|
|
||||||
return 1;
|
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. */
|
/* Decode depth from mode_type. If it is zero, then autodetect. */
|
||||||
depth = (mode_type & GRUB_VIDEO_MODE_TYPE_DEPTH_MASK)
|
depth = (mode_type & GRUB_VIDEO_MODE_TYPE_DEPTH_MASK)
|
||||||
>> GRUB_VIDEO_MODE_TYPE_DEPTH_POS;
|
>> 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,
|
return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
|
||||||
"Only 640x480x8 is supported");
|
"Only 640x480x8 is supported");
|
||||||
|
|
||||||
grub_pci_iterate (find_card);
|
grub_pci_iterate (find_card, &found);
|
||||||
if (!found)
|
if (!found)
|
||||||
return grub_error (GRUB_ERR_IO, "Couldn't find graphics card");
|
return grub_error (GRUB_ERR_IO, "Couldn't find graphics card");
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -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);
|
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)
|
#if !defined (TEST) && !defined(GENINIT)
|
||||||
int depth;
|
/* Helper for grub_video_sm712_setup. */
|
||||||
grub_err_t err;
|
static int
|
||||||
int found = 0;
|
find_card (grub_pci_device_t dev, grub_pci_id_t pciid, void *data)
|
||||||
|
{
|
||||||
auto int NESTED_FUNC_ATTR find_card (grub_pci_device_t dev, grub_pci_id_t pciid);
|
int *found = data;
|
||||||
int NESTED_FUNC_ATTR find_card (grub_pci_device_t dev, grub_pci_id_t pciid)
|
|
||||||
{
|
|
||||||
grub_pci_address_t addr;
|
grub_pci_address_t addr;
|
||||||
grub_uint32_t class;
|
grub_uint32_t class;
|
||||||
|
|
||||||
|
@ -383,14 +376,25 @@ grub_video_sm712_setup (unsigned int width, unsigned int height,
|
||||||
|| pciid != GRUB_SM712_PCIID)
|
|| pciid != GRUB_SM712_PCIID)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
found = 1;
|
*found = 1;
|
||||||
|
|
||||||
addr = grub_pci_make_address (dev, GRUB_PCI_REG_ADDRESS_REG0);
|
addr = grub_pci_make_address (dev, GRUB_PCI_REG_ADDRESS_REG0);
|
||||||
framebuffer.base = grub_pci_read (addr);
|
framebuffer.base = grub_pci_read (addr);
|
||||||
framebuffer.dev = dev;
|
framebuffer.dev = dev;
|
||||||
|
|
||||||
return 1;
|
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. */
|
/* Decode depth from mode_type. If it is zero, then autodetect. */
|
||||||
depth = (mode_type & GRUB_VIDEO_MODE_TYPE_DEPTH_MASK)
|
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,
|
return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
|
||||||
"Only 1024x600x16 is supported");
|
"Only 1024x600x16 is supported");
|
||||||
|
|
||||||
grub_pci_iterate (find_card);
|
grub_pci_iterate (find_card, &found);
|
||||||
if (!found)
|
if (!found)
|
||||||
return grub_error (GRUB_ERR_IO, "Couldn't find graphics card");
|
return grub_error (GRUB_ERR_IO, "Couldn't find graphics card");
|
||||||
/* Fill mode info details. */
|
/* Fill mode info details. */
|
||||||
|
|
|
@ -132,13 +132,14 @@ grub_pci_get_function (grub_pci_device_t dev)
|
||||||
#include <grub/cpu/pci.h>
|
#include <grub/cpu/pci.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef int NESTED_FUNC_ATTR (*grub_pci_iteratefunc_t)
|
typedef int (*grub_pci_iteratefunc_t)
|
||||||
(grub_pci_device_t dev, grub_pci_id_t pciid);
|
(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,
|
grub_pci_address_t EXPORT_FUNC(grub_pci_make_address) (grub_pci_device_t dev,
|
||||||
int reg);
|
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;
|
struct grub_pci_dma_chunk;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue