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

« back to all changes in this revision

Viewing changes to disk/dmraid_nvidia.c

  • Committer: Bazaar Package Importer
  • Author(s): Colin Watson, Colin Watson, Evan Broder, Mario Limonciello
  • Date: 2010-11-24 13:59:55 UTC
  • mfrom: (1.17.6 upstream) (17.6.15 experimental)
  • Revision ID: james.westby@ubuntu.com-20101124135955-r6ii5sepayr7jt53
Tags: 1.99~20101124-1ubuntu1
[ Colin Watson ]
* Resynchronise with Debian experimental.  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.
  - 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.
  - Suppress progress messages as the kernel and initrd load for
    non-recovery kernel menu entries.
  - 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.
  - Don't generate /boot/grub/device.map during grub-install or
    grub-mkconfig by default.
  - Adjust upgrade version checks for Ubuntu.
  - Don't display "GRUB loading" unless Shift is held down.
  - Adjust versions of grub-doc and grub-legacy-doc conflicts to tolerate
    our backport of the grub-doc split.
  - Fix LVM/RAID probing in the absence of /boot/grub/device.map.
  - Look for .mo files in /usr/share/locale-langpack as well, in
    preference.
  - Make sure GRUB_TIMEOUT isn't quoted unnecessarily.
  - Probe all devices in 'grub-probe --target=drive' if
    /boot/grub/device.map is missing.
  - Build-depend on qemu-kvm rather than qemu-system for grub-pc tests.
  - Use qemu rather than qemu-system-i386.
  - Program vesafb on BIOS systems rather than efifb.
  - Add a grub-rescue-efi-amd64 package containing a rescue CD-ROM image
    for EFI-AMD64.
  - On Wubi, don't ask for an install device, but just update wubildr
    using the diverted grub-install.
  - When embedding the core image in a post-MBR gap, check for and avoid
    sectors matching any of a list of known signatures.
  - Disable video_bochs and video_cirrus on PC BIOS systems, as probing
    PCI space seems to break on some systems.
* Downgrade "ACPI shutdown failed" error to a debug message, since it can
  cause spurious test failures.

[ Evan Broder ]
* Enable lua from grub-extras.
* Incorporate the bitop library into lua.
* Add enum_pci function to grub module in lua.
* Switch back to gfxpayload=keep by default, unless the video hardware
  is known to not support it.

[ Mario Limonciello ]
* Built part_msdos and vfat into bootx64.efi (LP: #677758)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* dmraid_nvidia.c - module to handle Nvidia fakeraid.  */
2
 
/*
3
 
 *  GRUB  --  GRand Unified Bootloader
4
 
 *  Copyright (C) 2006,2007,2008,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/disk.h>
22
 
#include <grub/mm.h>
23
 
#include <grub/err.h>
24
 
#include <grub/misc.h>
25
 
#include <grub/raid.h>
26
 
 
27
 
#define NV_SIGNATURES           4
28
 
 
29
 
#define NV_IDLE                 0
30
 
#define NV_SCDB_INIT_RAID       2
31
 
#define NV_SCDB_REBUILD_RAID    3
32
 
#define NV_SCDB_UPGRADE_RAID    4
33
 
#define NV_SCDB_SYNC_RAID       5
34
 
 
35
 
#define NV_LEVEL_UNKNOWN        0x00
36
 
#define NV_LEVEL_JBOD           0xFF
37
 
#define NV_LEVEL_0              0x80
38
 
#define NV_LEVEL_1              0x81
39
 
#define NV_LEVEL_3              0x83
40
 
#define NV_LEVEL_5              0x85
41
 
#define NV_LEVEL_10             0x8a
42
 
#define NV_LEVEL_1_0            0x8180
43
 
 
44
 
#define NV_ARRAY_FLAG_BOOT              1 /* BIOS use only.  */
45
 
#define NV_ARRAY_FLAG_ERROR             2 /* Degraded or offline.  */
46
 
#define NV_ARRAY_FLAG_PARITY_VALID      4 /* RAID-3/5 parity valid.  */
47
 
 
48
 
struct grub_nv_array
49
 
{
50
 
  grub_uint32_t version;
51
 
  grub_uint32_t signature[NV_SIGNATURES];
52
 
  grub_uint8_t raid_job_code;
53
 
  grub_uint8_t stripe_width;
54
 
  grub_uint8_t total_volumes;
55
 
  grub_uint8_t original_width;
56
 
  grub_uint32_t raid_level;
57
 
  grub_uint32_t stripe_block_size;
58
 
  grub_uint32_t stripe_block_size_bytes;
59
 
  grub_uint32_t stripe_block_size_log2;
60
 
  grub_uint32_t stripe_mask;
61
 
  grub_uint32_t stripe_size;
62
 
  grub_uint32_t stripe_size_bytes;
63
 
  grub_uint32_t raid_job_mask;
64
 
  grub_uint32_t original_capacity;
65
 
  grub_uint32_t flags;
66
 
};
67
 
 
68
 
#define NV_ID_LEN               8
69
 
#define NV_ID_STRING            "NVIDIA"
70
 
#define NV_VERSION              100
71
 
 
72
 
#define NV_PRODID_LEN           16
73
 
#define NV_PRODREV_LEN          4
74
 
 
75
 
struct grub_nv_super
76
 
{
77
 
  char vendor[NV_ID_LEN];       /* 0x00 - 0x07 ID string.  */
78
 
  grub_uint32_t size;           /* 0x08 - 0x0B Size of metadata in dwords.  */
79
 
  grub_uint32_t chksum;         /* 0x0C - 0x0F Checksum of this struct.  */
80
 
  grub_uint16_t version;        /* 0x10 - 0x11 NV version.  */
81
 
  grub_uint8_t unit_number;     /* 0x12 Disk index in array.  */
82
 
  grub_uint8_t reserved;        /* 0x13.  */
83
 
  grub_uint32_t capacity;       /* 0x14 - 0x17 Array capacity in sectors.  */
84
 
  grub_uint32_t sector_size;    /* 0x18 - 0x1B Sector size.  */
85
 
  char prodid[NV_PRODID_LEN];   /* 0x1C - 0x2B Array product ID.  */
86
 
  char prodrev[NV_PRODREV_LEN]; /* 0x2C - 0x2F Array product revision */
87
 
  grub_uint32_t unit_flags;     /* 0x30 - 0x33 Flags for this disk */
88
 
  struct grub_nv_array array;   /* Array information */
89
 
} __attribute__ ((packed));
90
 
 
91
 
static grub_err_t
92
 
grub_dmraid_nv_detect (grub_disk_t disk, struct grub_raid_array *array,
93
 
                       grub_disk_addr_t *start_sector)
94
 
{
95
 
  grub_disk_addr_t sector;
96
 
  struct grub_nv_super sb;
97
 
 
98
 
  if (disk->partition)
99
 
    return grub_error (GRUB_ERR_OUT_OF_RANGE, "skip partition");
100
 
 
101
 
  sector = grub_disk_get_size (disk) - 2;
102
 
 
103
 
  if (grub_disk_read (disk, sector, 0, sizeof (sb), &sb))
104
 
    return grub_errno;
105
 
 
106
 
  if (grub_memcmp (sb.vendor, NV_ID_STRING, 6))
107
 
    return grub_error (GRUB_ERR_OUT_OF_RANGE, "not raid");
108
 
 
109
 
  if (sb.version != NV_VERSION)
110
 
    return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
111
 
                       "unknown version: %d.%d", sb.version);
112
 
 
113
 
  switch (sb.array.raid_level)
114
 
    {
115
 
    case NV_LEVEL_0:
116
 
      array->level = 0;
117
 
      array->disk_size = sb.capacity / sb.array.total_volumes;
118
 
      break;
119
 
 
120
 
    case NV_LEVEL_1:
121
 
      array->level = 1;
122
 
      array->disk_size = sb.capacity;
123
 
      break;
124
 
 
125
 
    case NV_LEVEL_5:
126
 
      array->level = 5;
127
 
      array->layout = GRUB_RAID_LAYOUT_LEFT_ASYMMETRIC;
128
 
      array->disk_size = sb.capacity / (sb.array.total_volumes - 1);
129
 
      break;
130
 
 
131
 
    default:
132
 
      return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
133
 
                         "unsupported RAID level: %d", sb.array.raid_level);
134
 
    }
135
 
 
136
 
  array->name = NULL;
137
 
  array->number = 0;
138
 
  array->total_devs = sb.array.total_volumes;
139
 
  array->chunk_size = sb.array.stripe_block_size;
140
 
  array->index = sb.unit_number;
141
 
  array->uuid_len = sizeof (sb.array.signature);
142
 
  array->uuid = grub_malloc (sizeof (sb.array.signature));
143
 
  if (! array->uuid)
144
 
    return grub_errno;
145
 
 
146
 
  grub_memcpy (array->uuid, (char *) &sb.array.signature,
147
 
               sizeof (sb.array.signature));
148
 
 
149
 
  *start_sector = 0;
150
 
 
151
 
  return 0;
152
 
}
153
 
 
154
 
static struct grub_raid grub_dmraid_nv_dev =
155
 
{
156
 
  .name = "dmraid_nv",
157
 
  .detect = grub_dmraid_nv_detect,
158
 
  .next = 0
159
 
};
160
 
 
161
 
GRUB_MOD_INIT(dm_nv)
162
 
{
163
 
  grub_raid_register (&grub_dmraid_nv_dev);
164
 
}
165
 
 
166
 
GRUB_MOD_FINI(dm_nv)
167
 
{
168
 
  grub_raid_unregister (&grub_dmraid_nv_dev);
169
 
}