mirror of
https://git.proxmox.com/git/grub2
synced 2025-05-17 17:41:37 +00:00
extend --disk-module to AHCI and USB
This commit is contained in:
parent
d9675dbee3
commit
d1e517eb20
@ -1422,18 +1422,22 @@ static struct grub_usb_controller_dev usb_controller =
|
|||||||
.detect_dev = grub_ohci_detect_dev
|
.detect_dev = grub_ohci_detect_dev
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static void *fini_hnd;
|
||||||
|
|
||||||
GRUB_MOD_INIT(ohci)
|
GRUB_MOD_INIT(ohci)
|
||||||
{
|
{
|
||||||
COMPILE_TIME_ASSERT (sizeof (struct grub_ohci_td) == 32);
|
COMPILE_TIME_ASSERT (sizeof (struct grub_ohci_td) == 32);
|
||||||
COMPILE_TIME_ASSERT (sizeof (struct grub_ohci_ed) == 16);
|
COMPILE_TIME_ASSERT (sizeof (struct grub_ohci_ed) == 16);
|
||||||
grub_ohci_inithw ();
|
grub_ohci_inithw ();
|
||||||
grub_usb_controller_dev_register (&usb_controller);
|
grub_usb_controller_dev_register (&usb_controller);
|
||||||
grub_loader_register_preboot_hook (grub_ohci_fini_hw, grub_ohci_restore_hw,
|
fini_hnd = grub_loader_register_preboot_hook (grub_ohci_fini_hw,
|
||||||
GRUB_LOADER_PREBOOT_HOOK_PRIO_DISK);
|
grub_ohci_restore_hw,
|
||||||
|
GRUB_LOADER_PREBOOT_HOOK_PRIO_DISK);
|
||||||
}
|
}
|
||||||
|
|
||||||
GRUB_MOD_FINI(ohci)
|
GRUB_MOD_FINI(ohci)
|
||||||
{
|
{
|
||||||
grub_ohci_fini_hw (0);
|
grub_ohci_fini_hw (0);
|
||||||
|
grub_loader_unregister_preboot_hook (fini_hnd);
|
||||||
grub_usb_controller_dev_unregister (&usb_controller);
|
grub_usb_controller_dev_unregister (&usb_controller);
|
||||||
}
|
}
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
#include <grub/scsi.h>
|
#include <grub/scsi.h>
|
||||||
#include <grub/misc.h>
|
#include <grub/misc.h>
|
||||||
#include <grub/list.h>
|
#include <grub/list.h>
|
||||||
|
#include <grub/loader.h>
|
||||||
|
|
||||||
struct grub_ahci_cmd_head
|
struct grub_ahci_cmd_head
|
||||||
{
|
{
|
||||||
@ -296,6 +297,34 @@ grub_ahci_initialize (void)
|
|||||||
return grub_errno;
|
return grub_errno;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static grub_err_t
|
||||||
|
grub_ahci_fini_hw (int noreturn __attribute__ ((unused)))
|
||||||
|
{
|
||||||
|
struct grub_ahci_device *dev, *next;
|
||||||
|
|
||||||
|
for (dev = grub_ahci_devices; dev; dev = next)
|
||||||
|
{
|
||||||
|
next = dev->next;
|
||||||
|
dev->hba->ports[dev->num].command &= ~GRUB_AHCI_HBA_PORT_CMD_FRE;
|
||||||
|
while ((dev->hba->ports[dev->num].command & GRUB_AHCI_HBA_PORT_CMD_FR));
|
||||||
|
dev->hba->ports[dev->num].command &= ~GRUB_AHCI_HBA_PORT_CMD_ST;
|
||||||
|
while ((dev->hba->ports[dev->num].command & GRUB_AHCI_HBA_PORT_CMD_CR));
|
||||||
|
grub_dma_free (dev->command_list_chunk);
|
||||||
|
grub_dma_free (dev->command_table_chunk);
|
||||||
|
grub_dma_free (dev->rfis);
|
||||||
|
|
||||||
|
grub_free (dev);
|
||||||
|
}
|
||||||
|
grub_ahci_devices = NULL;
|
||||||
|
return GRUB_ERR_NONE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static grub_err_t
|
||||||
|
grub_ahci_restore_hw (void)
|
||||||
|
{
|
||||||
|
return grub_ahci_initialize ();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -533,6 +562,8 @@ static struct grub_ata_dev grub_ahci_dev =
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static void *fini_hnd;
|
||||||
|
|
||||||
GRUB_MOD_INIT(ahci)
|
GRUB_MOD_INIT(ahci)
|
||||||
{
|
{
|
||||||
/* To prevent two drivers operating on the same disks. */
|
/* To prevent two drivers operating on the same disks. */
|
||||||
@ -548,9 +579,16 @@ GRUB_MOD_INIT(ahci)
|
|||||||
|
|
||||||
/* AHCI devices are handled by scsi.mod. */
|
/* AHCI devices are handled by scsi.mod. */
|
||||||
grub_ata_dev_register (&grub_ahci_dev);
|
grub_ata_dev_register (&grub_ahci_dev);
|
||||||
|
|
||||||
|
fini_hnd = grub_loader_register_preboot_hook (grub_ahci_fini_hw,
|
||||||
|
grub_ahci_restore_hw,
|
||||||
|
GRUB_LOADER_PREBOOT_HOOK_PRIO_DISK);
|
||||||
}
|
}
|
||||||
|
|
||||||
GRUB_MOD_FINI(ahci)
|
GRUB_MOD_FINI(ahci)
|
||||||
{
|
{
|
||||||
|
grub_ahci_fini_hw (0);
|
||||||
|
grub_loader_unregister_preboot_hook (fini_hnd);
|
||||||
|
|
||||||
grub_ata_dev_unregister (&grub_ahci_dev);
|
grub_ata_dev_unregister (&grub_ahci_dev);
|
||||||
}
|
}
|
||||||
|
@ -77,7 +77,7 @@ if [ "${target_cpu}-${platform}" = "i386-pc" ] ; then
|
|||||||
elif [ "${platform}" = "ieee1275" ] || [ "${platform}" = "efi" ] ; then
|
elif [ "${platform}" = "ieee1275" ] || [ "${platform}" = "efi" ] ; then
|
||||||
disk_module=
|
disk_module=
|
||||||
else
|
else
|
||||||
disk_module=ata
|
disk_module=native
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Usage: usage
|
# Usage: usage
|
||||||
@ -114,7 +114,7 @@ Install GRUB on your drive.
|
|||||||
EOF
|
EOF
|
||||||
if [ "${target_cpu}-${platform}" = "i386-pc" ] ; then
|
if [ "${target_cpu}-${platform}" = "i386-pc" ] ; then
|
||||||
cat <<EOF
|
cat <<EOF
|
||||||
--disk-module=MODULE disk module to use
|
--disk-module=MODULE disk module to use (biosdisk or native)
|
||||||
EOF
|
EOF
|
||||||
fi
|
fi
|
||||||
if [ "${target_cpu}-${platform}" = "i386-ieee1275" ] || [ "${target_cpu}-${platform}" = "powerpc-ieee1275" ] ; then
|
if [ "${target_cpu}-${platform}" = "i386-ieee1275" ] || [ "${target_cpu}-${platform}" = "powerpc-ieee1275" ] ; then
|
||||||
@ -486,6 +486,14 @@ done
|
|||||||
# Device abstraction module, if any (lvm, raid).
|
# Device abstraction module, if any (lvm, raid).
|
||||||
devabstraction_module="`"$grub_probe" --device-map="${device_map}" --target=abstraction --device "${grub_device}"`"
|
devabstraction_module="`"$grub_probe" --device-map="${device_map}" --target=abstraction --device "${grub_device}"`"
|
||||||
|
|
||||||
|
if [ "x$disk_module" = xata ]; then
|
||||||
|
disk_module=pata
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "x$disk_module" = xnative ]; then
|
||||||
|
disk_module="pata ahci ohci uhci usbms"
|
||||||
|
fi
|
||||||
|
|
||||||
# The order in this list is critical. Be careful when modifying it.
|
# The order in this list is critical. Be careful when modifying it.
|
||||||
modules="$modules $disk_module"
|
modules="$modules $disk_module"
|
||||||
modules="$modules $fs_module $partmap_module $devabstraction_module"
|
modules="$modules $fs_module $partmap_module $devabstraction_module"
|
||||||
@ -519,7 +527,7 @@ if [ "x${devabstraction_module}" = "x" ] ; then
|
|||||||
# Strip partition number
|
# Strip partition number
|
||||||
grub_partition="`echo "${grub_drive}" | sed -e 's/^[^,]*[,)]//; s/)$//'`"
|
grub_partition="`echo "${grub_drive}" | sed -e 's/^[^,]*[,)]//; s/)$//'`"
|
||||||
grub_drive="`echo "${grub_drive}" | sed -e s/,[a-z0-9,]*//g`"
|
grub_drive="`echo "${grub_drive}" | sed -e s/,[a-z0-9,]*//g`"
|
||||||
if [ "$disk_module" = ata ] ; then
|
if [ "x$disk_module" != x ] && [ "x$disk_module" != xbiosdisk ]; then
|
||||||
# generic method (used on coreboot and ata mod)
|
# generic method (used on coreboot and ata mod)
|
||||||
uuid="`"$grub_probe" --device-map="${device_map}" --target=fs_uuid --device "${grub_device}"`"
|
uuid="`"$grub_probe" --device-map="${device_map}" --target=fs_uuid --device "${grub_device}"`"
|
||||||
if [ "x${uuid}" = "x" ] ; then
|
if [ "x${uuid}" = "x" ] ; then
|
||||||
|
Loading…
Reference in New Issue
Block a user