~hamo/ubuntu/precise/grub2/grub2.hi_res

« back to all changes in this revision

Viewing changes to grub-core/bus/pci.c

  • Committer: Bazaar Package Importer
  • Author(s): Colin Watson, Colin Watson, Robert Millan, Updated translations
  • Date: 2010-11-22 12:24:56 UTC
  • mfrom: (1.26.4 upstream) (17.3.36 sid)
  • mto: (17.3.43 sid)
  • mto: This revision was merged to the branch mainline in revision 89.
  • Revision ID: james.westby@ubuntu.com-20101122122456-y82z3sfb7k4zfdcc
Tags: 1.99~20101122-1
[ Colin Watson ]
* New Bazaar snapshot.  Too many changes to list in full, but some of the
  more user-visible ones are as follows:
  - GRUB script:
    + Function parameters, "break", "continue", "shift", "setparams",
      "return", and "!".
    + "export" command supports multiple variable names.
    + Multi-line quoted strings support.
    + Wildcard expansion.
  - sendkey support.
  - USB hotunplugging and USB serial support.
  - Rename CD-ROM to cd on BIOS.
  - Add new --boot-directory option to grub-install, grub-reboot, and
    grub-set-default; the old --root-directory option is still accepted
    but was often confusing.
  - Basic btrfs detection/UUID support (but no file reading yet).
  - bash-completion for utilities.
  - If a device is listed in device.map, always assume that it is
    BIOS-visible rather than using extra layers such as LVM or RAID.
  - Add grub-mknetdir script (closes: #550658).
  - Remove deprecated "root" command.
  - Handle RAID devices containing virtio components.
  - GRUB Legacy configuration file support (via grub-menulst2cfg).
  - Keyboard layout support (via grub-mklayout and grub-kbdcomp).
  - Check generated grub.cfg for syntax errors before saving.
  - Pause execution for at most ten seconds if any errors are displayed,
    so that the user has a chance to see them.
  - Support submenus.
  - Write embedding zone using Reed-Solomon, so that it's robust against
    being partially overwritten (closes: #550702, #591416, #593347).
  - GRUB_DISABLE_LINUX_RECOVERY and GRUB_DISABLE_NETBSD_RECOVERY merged
    into a single GRUB_DISABLE_RECOVERY variable.
  - Fix loader memory allocation failure (closes: #551627).
  - Don't call savedefault on recovery entries (closes: #589325).
  - Support triple-indirect blocks on ext2 (closes: #543924).
  - Recognise DDF1 fake RAID (closes: #603354).

[ Robert Millan ]
* Use dpkg architecture wildcards.

[ Updated translations ]
* Slovenian (Vanja Cvelbar).  Closes: #604003
* Dzongkha (dawa pemo via Tenzin Dendup).  Closes: #604102

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* pci.c - Generic PCI interfaces.  */
 
2
/*
 
3
 *  GRUB  --  GRand Unified Bootloader
 
4
 *  Copyright (C) 2007,2009  Free Software Foundation, Inc.
 
5
 *
 
6
 *  GRUB is free software: you can redistribute it and/or modify
 
7
 *  it under the terms of the GNU General Public License as published by
 
8
 *  the Free Software Foundation, either version 3 of the License, or
 
9
 *  (at your option) any later version.
 
10
 *
 
11
 *  GRUB is distributed in the hope that it will be useful,
 
12
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
14
 *  GNU General Public License for more details.
 
15
 *
 
16
 *  You should have received a copy of the GNU General Public License
 
17
 *  along with GRUB.  If not, see <http://www.gnu.org/licenses/>.
 
18
 */
 
19
 
 
20
#include <grub/dl.h>
 
21
#include <grub/pci.h>
 
22
#include <grub/mm.h>
 
23
 
 
24
/* FIXME: correctly support 64-bit architectures.  */
 
25
/* #if GRUB_TARGET_SIZEOF_VOID_P == 4 */
 
26
struct grub_pci_dma_chunk *
 
27
grub_memalign_dma32 (grub_size_t align, grub_size_t size)
 
28
{
 
29
  return grub_memalign (align, size);
 
30
}
 
31
 
 
32
void
 
33
grub_dma_free (struct grub_pci_dma_chunk *ch)
 
34
{
 
35
  grub_free (ch);
 
36
}
 
37
/* #endif */
 
38
 
 
39
#ifdef GRUB_MACHINE_MIPS_YEELOONG
 
40
volatile void *
 
41
grub_dma_get_virt (struct grub_pci_dma_chunk *ch)
 
42
{
 
43
  return (void *) ((((grub_uint32_t) ch) & 0x1fffffff) | 0xa0000000);
 
44
}
 
45
 
 
46
grub_uint32_t
 
47
grub_dma_get_phys (struct grub_pci_dma_chunk *ch)
 
48
{
 
49
  return (((grub_uint32_t) ch) & 0x1fffffff) | 0x80000000;
 
50
}
 
51
#else
 
52
 
 
53
volatile void *
 
54
grub_dma_get_virt (struct grub_pci_dma_chunk *ch)
 
55
{
 
56
  return (void *) ch;
 
57
}
 
58
 
 
59
grub_uint32_t
 
60
grub_dma_get_phys (struct grub_pci_dma_chunk *ch)
 
61
{
 
62
  return (grub_uint32_t) (grub_addr_t) ch;
 
63
}
 
64
 
 
65
#endif
 
66
 
 
67
grub_pci_address_t
 
68
grub_pci_make_address (grub_pci_device_t dev, int reg)
 
69
{
 
70
  return (1 << 31) | (dev.bus << 16) | (dev.device << 11)
 
71
    | (dev.function << 8) | reg;
 
72
}
 
73
 
 
74
void
 
75
grub_pci_iterate (grub_pci_iteratefunc_t hook)
 
76
{
 
77
  grub_pci_device_t dev;
 
78
  grub_pci_address_t addr;
 
79
  grub_pci_id_t id;
 
80
  grub_uint32_t hdr;
 
81
 
 
82
  for (dev.bus = 0; dev.bus < GRUB_PCI_NUM_BUS; dev.bus++)
 
83
    {
 
84
      for (dev.device = 0; dev.device < GRUB_PCI_NUM_DEVICES; dev.device++)
 
85
        {
 
86
          for (dev.function = 0; dev.function < 8; dev.function++)
 
87
            {
 
88
              addr = grub_pci_make_address (dev, GRUB_PCI_REG_PCI_ID);
 
89
              id = grub_pci_read (addr);
 
90
 
 
91
              /* Check if there is a device present.  */
 
92
              if (id >> 16 == 0xFFFF)
 
93
                continue;
 
94
 
 
95
#ifdef GRUB_MACHINE_MIPS_YEELOONG
 
96
              /* Skip ghosts.  */
 
97
              if (id == GRUB_YEELOONG_OHCI_PCIID
 
98
                  && dev.function == GRUB_YEELOONG_OHCI_GHOST_FUNCTION)
 
99
                continue;
 
100
              if (id == GRUB_YEELOONG_EHCI_PCIID
 
101
                  && dev.function == GRUB_YEELOONG_EHCI_GHOST_FUNCTION)
 
102
                continue;
 
103
#endif
 
104
 
 
105
              if (hook (dev, id))
 
106
                return;
 
107
 
 
108
              /* Probe only func = 0 if the device if not multifunction */
 
109
              if (dev.function == 0)
 
110
                {
 
111
                  addr = grub_pci_make_address (dev, GRUB_PCI_REG_CACHELINE);
 
112
                  hdr = grub_pci_read (addr);
 
113
                  if (!(hdr & 0x800000))
 
114
                    break;
 
115
                }
 
116
            }
 
117
        }
 
118
    }
 
119
}