boot/loader: Fix the 'crc' command to the intended code.
[dragonfly.git] / sys / boot / common / boot2.h
blob89ab80e388b0560b4f2c6ad19fb9620f1336db3d
1 /*
2 * Copyright (c) 2009 The DragonFly Project. All rights reserved.
4 * This code is derived from software contributed to The DragonFly Project
5 * by Matthew Dillon <dillon@backplane.com>
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in
15 * the documentation and/or other materials provided with the
16 * distribution.
17 * 3. Neither the name of The DragonFly Project nor the names of its
18 * contributors may be used to endorse or promote products derived
19 * from this software without specific, prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25 * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26 * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
27 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
29 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
30 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
31 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 * SUCH DAMAGE.
35 * boot2 encapsulated ABI. The boot2 standalone code provides these functions
36 * to the boot2 add-on modules (ufsread.c and hammer2.c).
39 #ifndef _BOOT_COMMON_BOOT2_H_
40 #define _BOOT_COMMON_BOOT2_H_
43 #include <sys/param.h>
44 #include <sys/dtype.h>
45 #include <sys/dirent.h>
46 #include <stdarg.h>
47 #include <stddef.h>
48 #include <stdint.h>
49 #include <machine/bootinfo.h>
50 #include <machine/elf.h>
53 * We only need a 32 bit ino_t for UFS-only boot code. We have to squeeze
54 * space usage, else we'd just use 64 bits across the board.
56 #if defined(HAMMERFS) || defined(HAMMER2FS)
57 typedef uint64_t boot2_ino_t;
58 #else
59 typedef uint32_t boot2_ino_t;
60 #endif
62 struct boot2_fsapi {
63 int (*fsinit)(void);
64 boot2_ino_t (*fslookup)(const char *);
65 ssize_t (*fsread)(boot2_ino_t, void *, size_t);
69 * secbuf needs to be big enough for the label reads
70 * (32 and 64 bit disklabels).
72 struct boot2_dmadat {
73 char secbuf[DEV_BSIZE*4];
74 /* extended by *fsread() modules */
77 extern uint32_t fs_off;
78 extern int no_io_error;
79 extern int ls;
80 extern struct boot2_dmadat *boot2_dmadat;
82 extern int dskread(void *, unsigned, unsigned);
83 extern void printf(const char *,...);
84 extern void putchar(int);
85 extern int strcmp(const char *s1, const char *s2);
86 extern void memcpy(void *d, const void *s, int len);
88 #ifdef UFS
89 extern const struct boot2_fsapi boot2_ufs_api;
90 #endif
91 #ifdef HAMMERFS
92 extern const struct boot2_fsapi boot2_hammer_api;
93 #endif
94 #ifdef HAMMER2FS
95 extern const struct boot2_fsapi boot2_hammer2_api;
96 #endif
98 #endif