~darkmuggle-deactivatedaccount/ubuntu/quantal/grub2/fix-872244

« back to all changes in this revision

Viewing changes to bus/usb/uhci.c

  • Committer: Bazaar Package Importer
  • Author(s): Colin Watson
  • Date: 2010-01-11 11:12:55 UTC
  • mfrom: (17.3.7 squeeze)
  • Revision ID: james.westby@ubuntu.com-20100111111255-lr8ebkqw5x41gq6j
Tags: 1.98~20100101-1ubuntu1
* Resynchronise with Debian. Remaining changes:
  - Adjust for default Ubuntu boot options ("quiet splash").
  - Default to hiding the menu; holding down Shift at boot will show it.
  - Set a monochromatic theme for Ubuntu.
  - Apply Ubuntu GRUB Legacy changes to legacy update-grub script: title,
    recovery mode, quiet option, tweak how memtest86+ is displayed, and
    use UUIDs where appropriate.
  - Conflict with grub (<< 0.97-54) as well as grub-legacy.
  - Fix backslash-escaping in merge_debconf_into_conf.
  - Remove "GNU/Linux" from default distributor string.
  - Add crashkernel= options if kdump and makedumpfile are available.
  - If other operating systems are installed, then automatically unhide
    the menu. Otherwise, if GRUB_HIDDEN_TIMEOUT is 0, then use keystatus
    if available to check whether Shift is pressed. If it is, show the
    menu, otherwise boot immediately. If keystatus is not available, then
    fall back to a short delay interruptible with Escape.
  - Allow Shift to interrupt 'sleep --interruptible'.
  - Don't display introductory message about line editing unless we're
    actually offering a shell prompt. Don't clear the screen just before
    booting if we never drew the menu in the first place.
  - Remove some verbose messages printed before reading the configuration
    file.
  - If the environment variable "quiet" is set to something other than 0,
    suppress progress messages as the kernel and initrd load. Set this for
    non-recovery kernel menu entries.
  - Add GRUB_DEFAULT=saved, as well as grub-set-default and grub-reboot
    utilities. Provides functionality essentially equivalent to GRUB
    Legacy's savedefault.
  - Keep the loopback file open so that subsequent changes to the "root"
    environment variable don't affect it.
  - Change prepare_grub_to_access_device to handle filesystems
    loop-mounted on file images.
  - Ignore devices loop-mounted from files in 10_linux.
  - Show the boot menu if the previous boot failed, that is if it failed
    to get to the end of one of the normal runlevels.
  - Handle RAID devices containing virtio components.
* Update savedefault patch from current Bazaar branch, fixing grub-reboot
  to have distinct behaviour from grub-set-default (LP: #497326).
* Fix grub-mkisofs compilation error with FORTIFY_SOURCE.
* Convert recordfail boilerplate in each menu entry to use a function.

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
#include <grub/usb.h>
24
24
#include <grub/usbtrans.h>
25
25
#include <grub/pci.h>
26
 
#include <grub/cpu/pci.h>
27
26
#include <grub/i386/io.h>
28
27
#include <grub/time.h>
29
28
 
138
137
/* Iterate over all PCI devices.  Determine if a device is an UHCI
139
138
   controller.  If this is the case, initialize it.  */
140
139
static int NESTED_FUNC_ATTR
141
 
grub_uhci_pci_iter (int bus, int device, int func,
 
140
grub_uhci_pci_iter (grub_pci_device_t dev,
142
141
                    grub_pci_id_t pciid __attribute__((unused)))
143
142
{
144
143
  grub_uint32_t class_code;
151
150
  struct grub_uhci *u;
152
151
  int i;
153
152
 
154
 
  addr = grub_pci_make_address (bus, device, func, 2);
 
153
  addr = grub_pci_make_address (dev, 2);
155
154
  class_code = grub_pci_read (addr) >> 8;
156
155
 
157
156
  interf = class_code & 0xFF;
163
162
    return 0;
164
163
 
165
164
  /* Determine IO base address.  */
166
 
  addr = grub_pci_make_address (bus, device, func, 8);
 
165
  addr = grub_pci_make_address (dev, 8);
167
166
  base = grub_pci_read (addr);
168
167
  /* Stop if there is no IO space base address defined.  */
169
168
  if (! (base & 1))
435
434
  grub_uhci_td_t td_prev = NULL;
436
435
  grub_usb_err_t err = GRUB_USB_ERR_NONE;
437
436
  int i;
 
437
  grub_uint64_t endtime;
438
438
 
439
439
  /* Allocate a queue head for the transfer queue.  */
440
440
  qh = grub_alloc_qh (u, GRUB_USB_TRANSACTION_TYPE_CONTROL);
483
483
 
484
484
  /* Wait until either the transaction completed or an error
485
485
     occurred.  */
 
486
  endtime = grub_get_time_ms () + 1000;
486
487
  for (;;)
487
488
    {
488
489
      grub_uhci_td_t errtd;
534
535
             updated.  */
535
536
          grub_dprintf ("uhci", "transaction fallthrough\n");
536
537
        }
 
538
      if (grub_get_time_ms () > endtime)
 
539
        {
 
540
          err = GRUB_USB_ERR_STALL;
 
541
          grub_dprintf ("uhci", "transaction timed out\n");
 
542
          goto fail;
 
543
        }
 
544
      grub_cpu_idle ();
537
545
    }
538
546
 
539
547
  grub_dprintf ("uhci", "transaction complete\n");
573
581
  struct grub_uhci *u = (struct grub_uhci *) dev->data;
574
582
  int reg;
575
583
  unsigned int status;
 
584
  grub_uint64_t endtime;
576
585
 
577
586
  grub_dprintf ("uhci", "enable=%d port=%d\n", enable, port);
578
587
 
595
604
  status = grub_uhci_readreg16 (u, reg);
596
605
  grub_uhci_writereg16 (u, reg, status & ~(1 << 9));
597
606
  grub_dprintf ("uhci", "reset completed\n");
 
607
  grub_millisleep (10);
598
608
 
599
609
  /* Enable the port.  */
600
610
  grub_uhci_writereg16 (u, reg, enable << 2);
602
612
 
603
613
  grub_dprintf ("uhci", "waiting for the port to be enabled\n");
604
614
 
605
 
  while (! (grub_uhci_readreg16 (u, reg) & (1 << 2)));
 
615
  endtime = grub_get_time_ms () + 1000;
 
616
  while (! (grub_uhci_readreg16 (u, reg) & (1 << 2)))
 
617
    if (grub_get_time_ms () > endtime)
 
618
      return grub_error (GRUB_ERR_IO, "UHCI Timed out");
606
619
 
607
620
  status = grub_uhci_readreg16 (u, reg);
608
621
  grub_dprintf ("uhci", ">3detect=0x%02x\n", status);