~ubuntu-branches/ubuntu/trusty/grub2/trusty

« back to all changes in this revision

Viewing changes to .pc/efi_disk_cache.patch/include/grub/disk.h

  • Committer: Package Import Robot
  • Author(s): Colin Watson
  • Date: 2014-01-16 15:18:04 UTC
  • mfrom: (17.6.38 experimental)
  • Revision ID: package-import@ubuntu.com-20140116151804-3foouk7fpqcq3sxx
Tags: 2.02~beta2-2
* Convert patch handling to git-dpm.
* Add bi-endian support to ELF parser (Tomohiro B Berry).
* Adjust restore_mkdevicemap.patch to mark get_kfreebsd_version as static,
  to appease "gcc -Werror=missing-prototypes".
* Cherry-pick from upstream:
  - Change grub-macbless' manual page section to 8.
* Install grub-glue-efi, grub-macbless, grub-render-label, and
  grub-syslinux2cfg.
* grub-shell: Pass -no-pad to xorriso when building floppy images.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 *  GRUB  --  GRand Unified Bootloader
3
 
 *  Copyright (C) 2002,2003,2004,2005,2006,2007,2008,2009  Free Software Foundation, Inc.
4
 
 *
5
 
 *  GRUB is free software: you can redistribute it and/or modify
6
 
 *  it under the terms of the GNU General Public License as published by
7
 
 *  the Free Software Foundation, either version 3 of the License, or
8
 
 *  (at your option) any later version.
9
 
 *
10
 
 *  GRUB is distributed in the hope that it will be useful,
11
 
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 
 *  GNU General Public License for more details.
14
 
 *
15
 
 *  You should have received a copy of the GNU General Public License
16
 
 *  along with GRUB.  If not, see <http://www.gnu.org/licenses/>.
17
 
 */
18
 
 
19
 
#ifndef GRUB_DISK_HEADER
20
 
#define GRUB_DISK_HEADER        1
21
 
 
22
 
#include <grub/symbol.h>
23
 
#include <grub/err.h>
24
 
#include <grub/types.h>
25
 
#include <grub/device.h>
26
 
 
27
 
/* These are used to set a device id. When you add a new disk device,
28
 
   you must define a new id for it here.  */
29
 
enum grub_disk_dev_id
30
 
  {
31
 
    GRUB_DISK_DEVICE_BIOSDISK_ID,
32
 
    GRUB_DISK_DEVICE_OFDISK_ID,
33
 
    GRUB_DISK_DEVICE_LOOPBACK_ID,
34
 
    GRUB_DISK_DEVICE_EFIDISK_ID,
35
 
    GRUB_DISK_DEVICE_DISKFILTER_ID,
36
 
    GRUB_DISK_DEVICE_HOST_ID,
37
 
    GRUB_DISK_DEVICE_ATA_ID,
38
 
    GRUB_DISK_DEVICE_MEMDISK_ID,
39
 
    GRUB_DISK_DEVICE_NAND_ID,
40
 
    GRUB_DISK_DEVICE_SCSI_ID,
41
 
    GRUB_DISK_DEVICE_CRYPTODISK_ID,
42
 
    GRUB_DISK_DEVICE_ARCDISK_ID,
43
 
    GRUB_DISK_DEVICE_HOSTDISK_ID,
44
 
  };
45
 
 
46
 
struct grub_disk;
47
 
#ifdef GRUB_UTIL
48
 
struct grub_disk_memberlist;
49
 
#endif
50
 
 
51
 
typedef enum
52
 
  { 
53
 
    GRUB_DISK_PULL_NONE,
54
 
    GRUB_DISK_PULL_REMOVABLE,
55
 
    GRUB_DISK_PULL_RESCAN,
56
 
    GRUB_DISK_PULL_MAX
57
 
  } grub_disk_pull_t;
58
 
 
59
 
/* Disk device.  */
60
 
struct grub_disk_dev
61
 
{
62
 
  /* The device name.  */
63
 
  const char *name;
64
 
 
65
 
  /* The device id used by the cache manager.  */
66
 
  enum grub_disk_dev_id id;
67
 
 
68
 
  /* Call HOOK with each device name, until HOOK returns non-zero.  */
69
 
  int (*iterate) (int (*hook) (const char *name),
70
 
                  grub_disk_pull_t pull);
71
 
 
72
 
  /* Open the device named NAME, and set up DISK.  */
73
 
  grub_err_t (*open) (const char *name, struct grub_disk *disk);
74
 
 
75
 
  /* Close the disk DISK.  */
76
 
  void (*close) (struct grub_disk *disk);
77
 
 
78
 
  /* Read SIZE sectors from the sector SECTOR of the disk DISK into BUF.  */
79
 
  grub_err_t (*read) (struct grub_disk *disk, grub_disk_addr_t sector,
80
 
                      grub_size_t size, char *buf);
81
 
 
82
 
  /* Write SIZE sectors from BUF into the sector SECTOR of the disk DISK.  */
83
 
  grub_err_t (*write) (struct grub_disk *disk, grub_disk_addr_t sector,
84
 
                       grub_size_t size, const char *buf);
85
 
 
86
 
#ifdef GRUB_UTIL
87
 
  struct grub_disk_memberlist *(*memberlist) (struct grub_disk *disk);
88
 
  const char * (*raidname) (struct grub_disk *disk);
89
 
#endif
90
 
 
91
 
  /* The next disk device.  */
92
 
  struct grub_disk_dev *next;
93
 
};
94
 
typedef struct grub_disk_dev *grub_disk_dev_t;
95
 
 
96
 
extern grub_disk_dev_t EXPORT_VAR (grub_disk_dev_list);
97
 
 
98
 
struct grub_partition;
99
 
 
100
 
/* Disk.  */
101
 
struct grub_disk
102
 
{
103
 
  /* The disk name.  */
104
 
  const char *name;
105
 
 
106
 
  /* The underlying disk device.  */
107
 
  grub_disk_dev_t dev;
108
 
 
109
 
  /* The total number of sectors.  */
110
 
  grub_uint64_t total_sectors;
111
 
 
112
 
  /* Logarithm of sector size.  */
113
 
  unsigned int log_sector_size;
114
 
 
115
 
  /* The id used by the disk cache manager.  */
116
 
  unsigned long id;
117
 
 
118
 
  /* The partition information. This is machine-specific.  */
119
 
  struct grub_partition *partition;
120
 
 
121
 
  /* Called when a sector was read. OFFSET is between 0 and
122
 
     the sector size minus 1, and LENGTH is between 0 and the sector size.  */
123
 
  void NESTED_FUNC_ATTR (*read_hook) (grub_disk_addr_t sector,
124
 
                     unsigned offset, unsigned length);
125
 
 
126
 
  /* Device-specific data.  */
127
 
  void *data;
128
 
};
129
 
typedef struct grub_disk *grub_disk_t;
130
 
 
131
 
#ifdef GRUB_UTIL
132
 
struct grub_disk_memberlist
133
 
{
134
 
  grub_disk_t disk;
135
 
  struct grub_disk_memberlist *next;
136
 
};
137
 
typedef struct grub_disk_memberlist *grub_disk_memberlist_t;
138
 
#endif
139
 
 
140
 
/* The sector size.  */
141
 
#define GRUB_DISK_SECTOR_SIZE   0x200
142
 
#define GRUB_DISK_SECTOR_BITS   9
143
 
 
144
 
/* The maximum number of disk caches.  */
145
 
#define GRUB_DISK_CACHE_NUM     1021
146
 
 
147
 
/* The size of a disk cache in 512B units. Must be at least as big as the
148
 
   largest supported sector size, currently 16K.  */
149
 
#define GRUB_DISK_CACHE_BITS    6
150
 
#define GRUB_DISK_CACHE_SIZE    (1 << GRUB_DISK_CACHE_BITS)
151
 
 
152
 
/* Return value of grub_disk_get_size() in case disk size is unknown. */
153
 
#define GRUB_DISK_SIZE_UNKNOWN   0xffffffffffffffffULL
154
 
 
155
 
/* This is called from the memory manager.  */
156
 
void grub_disk_cache_invalidate_all (void);
157
 
 
158
 
void EXPORT_FUNC(grub_disk_dev_register) (grub_disk_dev_t dev);
159
 
void EXPORT_FUNC(grub_disk_dev_unregister) (grub_disk_dev_t dev);
160
 
static inline int
161
 
grub_disk_dev_iterate (int (*hook) (const char *name))
162
 
{
163
 
  grub_disk_dev_t p;
164
 
  grub_disk_pull_t pull;
165
 
 
166
 
  for (pull = 0; pull < GRUB_DISK_PULL_MAX; pull++)
167
 
    for (p = grub_disk_dev_list; p; p = p->next)
168
 
      if (p->iterate && (p->iterate) (hook, pull))
169
 
        return 1;
170
 
 
171
 
  return 0;
172
 
}
173
 
 
174
 
grub_disk_t EXPORT_FUNC(grub_disk_open) (const char *name);
175
 
void EXPORT_FUNC(grub_disk_close) (grub_disk_t disk);
176
 
grub_err_t EXPORT_FUNC(grub_disk_read) (grub_disk_t disk,
177
 
                                        grub_disk_addr_t sector,
178
 
                                        grub_off_t offset,
179
 
                                        grub_size_t size,
180
 
                                        void *buf);
181
 
grub_err_t EXPORT_FUNC(grub_disk_write) (grub_disk_t disk,
182
 
                                         grub_disk_addr_t sector,
183
 
                                         grub_off_t offset,
184
 
                                         grub_size_t size,
185
 
                                         const void *buf);
186
 
 
187
 
grub_uint64_t EXPORT_FUNC(grub_disk_get_size) (grub_disk_t disk);
188
 
 
189
 
#if DISK_CACHE_STATS
190
 
void
191
 
EXPORT_FUNC(grub_disk_cache_get_performance) (unsigned long *hits, unsigned long *misses);
192
 
#endif
193
 
 
194
 
extern void (* EXPORT_VAR(grub_disk_firmware_fini)) (void);
195
 
extern int EXPORT_VAR(grub_disk_firmware_is_tainted);
196
 
 
197
 
#if defined (GRUB_UTIL)
198
 
void grub_lvm_init (void);
199
 
void grub_ldm_init (void);
200
 
void grub_mdraid09_init (void);
201
 
void grub_mdraid1x_init (void);
202
 
void grub_diskfilter_init (void);
203
 
void grub_lvm_fini (void);
204
 
void grub_ldm_fini (void);
205
 
void grub_mdraid09_fini (void);
206
 
void grub_mdraid1x_fini (void);
207
 
void grub_diskfilter_fini (void);
208
 
#endif
209
 
 
210
 
#endif /* ! GRUB_DISK_HEADER */