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

« back to all changes in this revision

Viewing changes to include/grub/i386/bsd.h

Tags: upstream-1.99~20101122
ImportĀ upstreamĀ versionĀ 1.99~20101122

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
#define GRUB_BSD_CPU_HEADER     1
21
21
 
22
22
#include <grub/types.h>
 
23
#include <grub/relocator.h>
 
24
 
 
25
#include <grub/i386/freebsd_reboot.h>
 
26
#include <grub/i386/netbsd_reboot.h>
 
27
#include <grub/i386/openbsd_reboot.h>
 
28
#include <grub/i386/freebsd_linker.h>
 
29
#include <grub/i386/netbsd_bootinfo.h>
 
30
#include <grub/i386/openbsd_bootarg.h>
23
31
 
24
32
enum bsd_kernel_types
25
33
  {
31
39
 
32
40
#define GRUB_BSD_TEMP_BUFFER   0x80000
33
41
 
34
 
#define FREEBSD_RB_ASKNAME      (1 << 0)  /* ask for file name to reboot from */
35
 
#define FREEBSD_RB_SINGLE       (1 << 1)  /* reboot to single user only */
36
 
#define FREEBSD_RB_NOSYNC       (1 << 2)  /* dont sync before reboot */
37
 
#define FREEBSD_RB_HALT         (1 << 3)  /* don't reboot, just halt */
38
 
#define FREEBSD_RB_INITNAME     (1 << 4)  /* name given for /etc/init (unused) */
39
 
#define FREEBSD_RB_DFLTROOT     (1 << 5)  /* use compiled-in rootdev */
40
 
#define FREEBSD_RB_KDB          (1 << 6)  /* give control to kernel debugger */
41
 
#define FREEBSD_RB_RDONLY       (1 << 7)  /* mount root fs read-only */
42
 
#define FREEBSD_RB_DUMP         (1 << 8)  /* dump kernel memory before reboot */
43
 
#define FREEBSD_RB_MINIROOT     (1 << 9)  /* mini-root present in memory at boot time */
44
 
#define FREEBSD_RB_CONFIG       (1 << 10) /* invoke user configuration routing */
45
 
#define FREEBSD_RB_VERBOSE      (1 << 11) /* print all potentially useful info */
46
 
#define FREEBSD_RB_SERIAL       (1 << 12) /* user serial port as console */
47
 
#define FREEBSD_RB_CDROM        (1 << 13) /* use cdrom as root */
48
 
#define FREEBSD_RB_GDB          (1 << 15) /* use GDB remote debugger instead of DDB */
49
 
#define FREEBSD_RB_MUTE         (1 << 16) /* Come up with the console muted */
50
 
#define FREEBSD_RB_PAUSE        (1 << 20)
51
 
#define FREEBSD_RB_QUIET        (1 << 21)
52
 
#define FREEBSD_RB_NOINTR       (1 << 28)
53
 
#define FREENSD_RB_MULTIPLE     (1 << 29)  /* Use multiple consoles */
54
 
#define FREEBSD_RB_DUAL         FREENSD_RB_MULTIPLE
55
 
#define FREEBSD_RB_BOOTINFO     (1 << 31) /* have `struct bootinfo *' arg */
56
 
 
57
 
#define FREEBSD_B_DEVMAGIC      0xa0000000
58
 
#define FREEBSD_B_SLICESHIFT    20
59
 
#define FREEBSD_B_UNITSHIFT     16
60
 
#define FREEBSD_B_PARTSHIFT     8
61
 
#define FREEBSD_B_TYPESHIFT     0
62
 
 
63
 
#define FREEBSD_BOOTINFO_VERSION 1
64
 
#define FREEBSD_N_BIOS_GEOM     8
65
 
 
66
 
#define FREEBSD_MODINFO_END             0x0000  /* End of list */
67
 
#define FREEBSD_MODINFO_NAME            0x0001  /* Name of module (string) */
68
 
#define FREEBSD_MODINFO_TYPE            0x0002  /* Type of module (string) */
69
 
#define FREEBSD_MODINFO_ADDR            0x0003  /* Loaded address */
70
 
#define FREEBSD_MODINFO_SIZE            0x0004  /* Size of module */
71
 
#define FREEBSD_MODINFO_EMPTY           0x0005  /* Has been deleted */
72
 
#define FREEBSD_MODINFO_ARGS            0x0006  /* Parameters string */
73
 
#define FREEBSD_MODINFO_METADATA        0x8000  /* Module-specfic */
74
 
 
75
 
#define FREEBSD_MODINFOMD_AOUTEXEC      0x0001  /* a.out exec header */
76
 
#define FREEBSD_MODINFOMD_ELFHDR        0x0002  /* ELF header */
77
 
#define FREEBSD_MODINFOMD_SSYM          0x0003  /* start of symbols */
78
 
#define FREEBSD_MODINFOMD_ESYM          0x0004  /* end of symbols */
79
 
#define FREEBSD_MODINFOMD_DYNAMIC       0x0005  /* _DYNAMIC pointer */
80
 
#define FREEBSD_MODINFOMD_ENVP          0x0006  /* envp[] */
81
 
#define FREEBSD_MODINFOMD_HOWTO         0x0007  /* boothowto */
82
 
#define FREEBSD_MODINFOMD_KERNEND       0x0008  /* kernend */
83
 
#define FREEBSD_MODINFOMD_SHDR          0x0009  /* section header table */
84
 
#define FREEBSD_MODINFOMD_NOCOPY        0x8000  /* don't copy this metadata to the kernel */
85
 
 
86
 
#define FREEBSD_MODINFOMD_SMAP          0x1001
87
 
 
88
 
#define FREEBSD_MODINFOMD_DEPLIST       (0x4001 | FREEBSD_MODINFOMD_NOCOPY)  /* depends on */
 
42
#define FREEBSD_B_DEVMAGIC      OPENBSD_B_DEVMAGIC
 
43
#define FREEBSD_B_SLICESHIFT    OPENBSD_B_CTRLSHIFT
 
44
#define FREEBSD_B_UNITSHIFT     OPENBSD_B_UNITSHIFT
 
45
#define FREEBSD_B_PARTSHIFT     OPENBSD_B_PARTSHIFT
 
46
#define FREEBSD_B_TYPESHIFT     OPENBSD_B_TYPESHIFT
89
47
 
90
48
#define FREEBSD_MODTYPE_KERNEL          "elf kernel"
91
49
#define FREEBSD_MODTYPE_KERNEL64        "elf64 kernel"
93
51
#define FREEBSD_MODTYPE_ELF_MODULE_OBJ  "elf obj module"
94
52
#define FREEBSD_MODTYPE_RAW             "raw"
95
53
 
 
54
#define FREEBSD_BOOTINFO_VERSION 1
 
55
 
96
56
struct grub_freebsd_bootinfo
97
57
{
98
 
  grub_uint32_t bi_version;
99
 
  grub_uint8_t *bi_kernelname;
100
 
  struct nfs_diskless *bi_nfs_diskless;
101
 
  grub_uint32_t bi_n_bios_used;
102
 
  grub_uint32_t bi_bios_geom[FREEBSD_N_BIOS_GEOM];
103
 
  grub_uint32_t bi_size;
104
 
  grub_uint8_t bi_memsizes_valid;
105
 
  grub_uint8_t bi_bios_dev;
106
 
  grub_uint8_t bi_pad[2];
107
 
  grub_uint32_t bi_basemem;
108
 
  grub_uint32_t bi_extmem;
109
 
  grub_uint32_t bi_symtab;
110
 
  grub_uint32_t bi_esymtab;
111
 
  grub_uint32_t bi_kernend;
112
 
  grub_uint32_t bi_envp;
113
 
  grub_uint32_t bi_modulep;
114
 
} __attribute__ ((packed));
115
 
 
116
 
#define OPENBSD_RB_ASKNAME      (1 << 0)  /* ask for file name to reboot from */
117
 
#define OPENBSD_RB_SINGLE       (1 << 1)  /* reboot to single user only */
118
 
#define OPENBSD_RB_NOSYNC       (1 << 2)  /* dont sync before reboot */
119
 
#define OPENBSD_RB_HALT         (1 << 3)  /* don't reboot, just halt */
120
 
#define OPENBSD_RB_INITNAME     (1 << 4)  /* name given for /etc/init (unused) */
121
 
#define OPENBSD_RB_DFLTROOT     (1 << 5)  /* use compiled-in rootdev */
122
 
#define OPENBSD_RB_KDB          (1 << 6)  /* give control to kernel debugger */
123
 
#define OPENBSD_RB_RDONLY       (1 << 7)  /* mount root fs read-only */
124
 
#define OPENBSD_RB_DUMP         (1 << 8)  /* dump kernel memory before reboot */
125
 
#define OPENBSD_RB_MINIROOT     (1 << 9)  /* mini-root present in memory at boot time */
126
 
#define OPENBSD_RB_CONFIG       (1 << 10) /* change configured devices */
127
 
#define OPENBSD_RB_TIMEBAD      (1 << 11) /* don't call resettodr() in boot() */
128
 
#define OPENBSD_RB_POWERDOWN    (1 << 12) /* attempt to power down machine */
129
 
#define OPENBSD_RB_SERCONS      (1 << 13) /* use serial console if available */
130
 
#define OPENBSD_RB_USERREQ      (1 << 14) /* boot() called at user request (e.g. ddb) */
131
 
 
132
 
#define OPENBSD_B_DEVMAGIC      0xa0000000
133
 
#define OPENBSD_B_ADAPTORSHIFT  24
134
 
#define OPENBSD_B_CTRLSHIFT     20
135
 
#define OPENBSD_B_UNITSHIFT     16
136
 
#define OPENBSD_B_PARTSHIFT     8
137
 
#define OPENBSD_B_TYPESHIFT     0
138
 
 
139
 
#define OPENBSD_BOOTARG_APIVER  (OPENBSD_BAPIV_VECTOR | \
140
 
                                 OPENBSD_BAPIV_ENV | \
141
 
                                 OPENBSD_BAPIV_BMEMMAP)
142
 
 
143
 
#define OPENBSD_BAPIV_ANCIENT   0x0  /* MD old i386 bootblocks */
144
 
#define OPENBSD_BAPIV_VARS      0x1  /* MD structure w/ add info passed */
145
 
#define OPENBSD_BAPIV_VECTOR    0x2  /* MI vector of MD structures passed */
146
 
#define OPENBSD_BAPIV_ENV       0x4  /* MI environment vars vector */
147
 
#define OPENBSD_BAPIV_BMEMMAP   0x8  /* MI memory map passed is in bytes */
148
 
 
149
 
#define OPENBSD_BOOTARG_ENV     0x1000
150
 
#define OPENBSD_BOOTARG_END     -1
151
 
 
152
 
#define OPENBSD_BOOTARG_MMAP    0
153
 
 
154
 
struct grub_openbsd_bios_mmap
155
 
{
156
 
  grub_uint64_t addr;
157
 
  grub_uint64_t len;
158
 
#define OPENBSD_MMAP_AVAILABLE  1
159
 
#define OPENBSD_MMAP_RESERVED 2
160
 
#define OPENBSD_MMAP_ACPI       3
161
 
#define OPENBSD_MMAP_NVS        4
162
 
  grub_uint32_t type;
163
 
};
164
 
 
165
 
struct grub_openbsd_bootargs
166
 
{
167
 
  int ba_type;
168
 
  int ba_size;
169
 
  struct grub_openbsd_bootargs *ba_next;
170
 
} __attribute__ ((packed));
171
 
 
172
 
#define NETBSD_RB_AUTOBOOT      0  /* flags for system auto-booting itself */
173
 
 
174
 
#define NETBSD_RB_ASKNAME       (1 << 0)  /* ask for file name to reboot from */
175
 
#define NETBSD_RB_SINGLE        (1 << 1)  /* reboot to single user only */
176
 
#define NETBSD_RB_NOSYNC        (1 << 2)  /* dont sync before reboot */
177
 
#define NETBSD_RB_HALT          (1 << 3)  /* don't reboot, just halt */
178
 
#define NETBSD_RB_INITNAME      (1 << 4)  /* name given for /etc/init (unused) */
179
 
#define NETBSD_RB_UNUSED1       (1 << 5)  /* was RB_DFLTROOT, obsolete */
180
 
#define NETBSD_RB_KDB           (1 << 6)  /* give control to kernel debugger */
181
 
#define NETBSD_RB_RDONLY        (1 << 7)  /* mount root fs read-only */
182
 
#define NETBSD_RB_DUMP          (1 << 8)  /* dump kernel memory before reboot */
183
 
#define NETBSD_RB_MINIROOT      (1 << 9)  /* mini-root present in memory at boot time */
184
 
#define NETBSD_RB_STRING        (1 << 10) /* use provided bootstr */
185
 
#define NETBSD_RB_POWERDOWN     ((1 << 11) | RB_HALT) /* turn power off (or at least halt) */
186
 
#define NETBSD_RB_USERCONFIG    (1 << 12) /* change configured devices */
187
 
 
188
 
#define NETBSD_AB_NORMAL        0  /* boot normally (default) */
189
 
 
190
 
#define NETBSD_AB_QUIET         (1 << 16) /* boot quietly */
191
 
#define NETBSD_AB_VERBOSE       (1 << 17) /* boot verbosely */
192
 
#define NETBSD_AB_SILENT        (1 << 18) /* boot silently */
193
 
#define NETBSD_AB_DEBUG         (1 << 19) /* boot with debug messages */
194
 
#define NETBSD_AB_NOSMP         (1 << 28) /* Boot without SMP support.  */
195
 
#define NETBSD_AB_NOACPI        (1 << 29) /* Boot without ACPI support.  */
196
 
 
197
 
struct grub_netbsd_bootinfo
198
 
{
199
 
  grub_uint32_t bi_count;
200
 
  void *bi_data[1];
201
 
};
202
 
 
203
 
#define NETBSD_BTINFO_BOOTPATH          0
204
 
#define NETBSD_BTINFO_ROOTDEVICE        1
205
 
#define NETBSD_BTINFO_BOOTDISK          3
206
 
#define NETBSD_BTINFO_MEMMAP            9
207
 
 
208
 
struct grub_netbsd_btinfo_common
209
 
{
210
 
  int len;
211
 
  int type;
212
 
};
213
 
 
214
 
struct grub_netbsd_btinfo_mmap_header
215
 
{
216
 
  struct grub_netbsd_btinfo_common common;
217
 
  grub_uint32_t count;
218
 
};
219
 
 
220
 
struct grub_netbsd_btinfo_mmap_entry
221
 
{
222
 
  grub_uint64_t addr;
223
 
  grub_uint64_t len;
224
 
#define NETBSD_MMAP_AVAILABLE   1
225
 
#define NETBSD_MMAP_RESERVED    2
226
 
#define NETBSD_MMAP_ACPI        3
227
 
#define NETBSD_MMAP_NVS         4
228
 
  grub_uint32_t type;
229
 
};
230
 
 
231
 
struct grub_netbsd_btinfo_bootpath
232
 
{
233
 
  struct grub_netbsd_btinfo_common common;
234
 
  char bootpath[80];
235
 
};
236
 
 
237
 
struct grub_netbsd_btinfo_rootdevice
238
 
{
239
 
  struct grub_netbsd_btinfo_common common;
240
 
  char devname[16];
241
 
};
242
 
 
243
 
struct grub_netbsd_btinfo_bootdisk
244
 
{
245
 
  struct grub_netbsd_btinfo_common common;
246
 
  int labelsector;  /* label valid if != -1 */
247
 
  struct
248
 
    {
249
 
      grub_uint16_t type, checksum;
250
 
      char packname[16];
251
 
    } label;
252
 
  int biosdev;
253
 
  int partition;
254
 
};
255
 
 
256
 
void grub_unix_real_boot (grub_addr_t entry, ...)
257
 
     __attribute__ ((cdecl,noreturn));
258
 
grub_err_t grub_freebsd_load_elfmodule32 (grub_file_t file, int argc,
 
58
  grub_uint32_t version;
 
59
  grub_uint8_t unused1[44];
 
60
  grub_uint32_t length;
 
61
  grub_uint8_t unused2;
 
62
  grub_uint8_t boot_device;
 
63
  grub_uint8_t unused3[18];
 
64
  grub_uint32_t kern_end;
 
65
  grub_uint32_t environment;
 
66
  grub_uint32_t tags;
 
67
} __attribute__ ((packed));
 
68
 
 
69
struct freebsd_tag_header
 
70
{
 
71
  grub_uint32_t type;
 
72
  grub_uint32_t len;
 
73
};
 
74
 
 
75
grub_err_t grub_freebsd_load_elfmodule32 (struct grub_relocator *relocator,
 
76
                                          grub_file_t file, int argc,
259
77
                                          char *argv[], grub_addr_t *kern_end);
260
 
grub_err_t grub_freebsd_load_elfmodule_obj64 (grub_file_t file, int argc,
 
78
grub_err_t grub_freebsd_load_elfmodule_obj64 (struct grub_relocator *relocator,
 
79
                                              grub_file_t file, int argc,
261
80
                                              char *argv[],
262
81
                                              grub_addr_t *kern_end);
263
 
grub_err_t grub_freebsd_load_elf_meta32 (grub_file_t file,
264
 
                                         grub_addr_t *kern_end);
265
 
grub_err_t grub_freebsd_load_elf_meta64 (grub_file_t file,
266
 
                                         grub_addr_t *kern_end);
267
 
 
268
 
grub_err_t grub_freebsd_add_meta (grub_uint32_t type, void *data,
269
 
                                  grub_uint32_t len);
 
82
grub_err_t grub_freebsd_load_elf_meta32 (struct grub_relocator *relocator,
 
83
                                         grub_file_t file,
 
84
                                         grub_addr_t *kern_end);
 
85
grub_err_t grub_freebsd_load_elf_meta64 (struct grub_relocator *relocator,
 
86
                                         grub_file_t file,
 
87
                                         grub_addr_t *kern_end);
 
88
 
 
89
grub_err_t grub_netbsd_load_elf_meta32 (struct grub_relocator *relocator,
 
90
                                        grub_file_t file,
 
91
                                        grub_addr_t *kern_end);
 
92
grub_err_t grub_netbsd_load_elf_meta64 (struct grub_relocator *relocator,
 
93
                                        grub_file_t file,
 
94
                                        grub_addr_t *kern_end);
 
95
 
 
96
grub_err_t grub_bsd_add_meta (grub_uint32_t type, 
 
97
                              void *data, grub_uint32_t len);
270
98
grub_err_t grub_freebsd_add_meta_module (char *filename, char *type,
271
99
                                         int argc, char **argv,
272
100
                                         grub_addr_t addr, grub_uint32_t size);
273
101
 
 
102
struct grub_openbsd_ramdisk_descriptor
 
103
{
 
104
  grub_size_t max_size;
 
105
  grub_uint8_t *target;
 
106
  grub_uint32_t *size;
 
107
};
 
108
 
 
109
grub_err_t grub_openbsd_find_ramdisk32 (grub_file_t file,
 
110
                                        grub_addr_t kern_start,
 
111
                                        void *kern_chunk_src,
 
112
                                        struct grub_openbsd_ramdisk_descriptor *desc);
 
113
grub_err_t grub_openbsd_find_ramdisk64 (grub_file_t file,
 
114
                                        grub_addr_t kern_start,
 
115
                                        void *kern_chunk_src,
 
116
                                        struct grub_openbsd_ramdisk_descriptor *desc);
 
117
 
274
118
extern grub_uint8_t grub_bsd64_trampoline_start, grub_bsd64_trampoline_end;
275
119
extern grub_uint32_t grub_bsd64_trampoline_selfjump;
276
120
extern grub_uint32_t grub_bsd64_trampoline_gdt;