mkimg.h revision 266176
1263382Smarcel/*-
2263382Smarcel * Copyright (c) 2014 Juniper Networks, Inc.
3263382Smarcel * All rights reserved.
4263382Smarcel *
5263382Smarcel * Redistribution and use in source and binary forms, with or without
6263382Smarcel * modification, are permitted provided that the following conditions
7263382Smarcel * are met:
8263382Smarcel * 1. Redistributions of source code must retain the above copyright
9263382Smarcel *    notice, this list of conditions and the following disclaimer.
10263382Smarcel * 2. Redistributions in binary form must reproduce the above copyright
11263382Smarcel *    notice, this list of conditions and the following disclaimer in the
12263382Smarcel *    documentation and/or other materials provided with the distribution.
13263382Smarcel *
14263382Smarcel * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15263382Smarcel * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16263382Smarcel * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17263382Smarcel * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18263382Smarcel * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19263382Smarcel * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20263382Smarcel * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21263382Smarcel * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22263382Smarcel * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23263382Smarcel * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24263382Smarcel * SUCH DAMAGE.
25263382Smarcel *
26263382Smarcel * $FreeBSD: head/usr.bin/mkimg/mkimg.h 266176 2014-05-15 19:19:57Z marcel $
27263382Smarcel */
28263382Smarcel
29263382Smarcel#ifndef _MKIMG_MKIMG_H_
30263382Smarcel#define	_MKIMG_MKIMG_H_
31263382Smarcel
32263442Smarcel#include <sys/queue.h>
33263442Smarcel
34263382Smarcelstruct part {
35263382Smarcel	STAILQ_ENTRY(part) link;
36263414Smarcel	char	*alias;		/* Partition type alias. */
37263382Smarcel	char	*contents;	/* Contents/size specification. */
38263382Smarcel	u_int	kind;		/* Content kind. */
39263382Smarcel#define	PART_UNDEF	0
40263382Smarcel#define	PART_KIND_FILE	1
41263382Smarcel#define	PART_KIND_PIPE	2
42263382Smarcel#define	PART_KIND_SIZE	3
43263382Smarcel	u_int	index;		/* Partition index (0-based). */
44263461Smarcel	uintptr_t type;		/* Scheme-specific partition type. */
45263653Smarcel	lba_t	block;		/* Block-offset of partition in image. */
46263653Smarcel	lba_t	size;		/* Size in blocks of partition. */
47263466Smarcel	char	*label;		/* Partition label. */
48263382Smarcel};
49263382Smarcel
50263382Smarcelextern STAILQ_HEAD(partlisthead, part) partlist;
51263382Smarcelextern u_int nparts;
52263382Smarcel
53263831Smarcelextern u_int verbose;
54263831Smarcel
55263709Smarcelextern u_int ncyls;
56263709Smarcelextern u_int nheads;
57263709Smarcelextern u_int nsecs;
58263709Smarcelextern u_int secsz;	/* Logical block size. */
59263709Smarcelextern u_int blksz;	/* Physical block size. */
60263653Smarcel
61263844Smarcelstatic inline lba_t
62263844Smarcelround_block(lba_t n)
63263844Smarcel{
64263844Smarcel	lba_t b = blksz / secsz;
65263844Smarcel	return ((n + b - 1) & ~(b - 1));
66263844Smarcel}
67263844Smarcel
68266176Smarcel#if !defined(SPARSE_WRITE)
69266176Smarcel#define	sparse_write	write
70266176Smarcel#else
71266176Smarcelssize_t sparse_write(int, const void *, size_t);
72266176Smarcel#endif
73263653Smarcel
74263382Smarcel#endif /* _MKIMG_MKIMG_H_ */
75