1253923Smarcel/*- 2263409Smarcel * Copyright (c) 2013,2014 Juniper Networks, Inc. 3253923Smarcel * All rights reserved. 4253923Smarcel * 5253923Smarcel * Redistribution and use in source and binary forms, with or without 6253923Smarcel * modification, are permitted provided that the following conditions 7253923Smarcel * are met: 8253923Smarcel * 1. Redistributions of source code must retain the above copyright 9253923Smarcel * notice, this list of conditions and the following disclaimer. 10253923Smarcel * 2. Redistributions in binary form must reproduce the above copyright 11253923Smarcel * notice, this list of conditions and the following disclaimer in the 12253923Smarcel * documentation and/or other materials provided with the distribution. 13253923Smarcel * 14253923Smarcel * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15253923Smarcel * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16253923Smarcel * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17253923Smarcel * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18253923Smarcel * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19253923Smarcel * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20253923Smarcel * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21253923Smarcel * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22253923Smarcel * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23253923Smarcel * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24253923Smarcel * SUCH DAMAGE. 25253923Smarcel * 26253923Smarcel * $FreeBSD$ 27253923Smarcel */ 28253923Smarcel 29253923Smarcel#ifndef _MKIMG_SCHEME_H_ 30253923Smarcel#define _MKIMG_SCHEME_H_ 31253923Smarcel 32263442Smarcel#include <sys/linker_set.h> 33263442Smarcel 34263487Smarcelenum alias { 35263487Smarcel ALIAS_NONE, /* Keep first! */ 36263487Smarcel /* start */ 37263672Smarcel ALIAS_EBR, 38263487Smarcel ALIAS_EFI, 39263672Smarcel ALIAS_FAT32, 40263487Smarcel ALIAS_FREEBSD, 41263487Smarcel ALIAS_FREEBSD_BOOT, 42263487Smarcel ALIAS_FREEBSD_NANDFS, 43263487Smarcel ALIAS_FREEBSD_SWAP, 44263487Smarcel ALIAS_FREEBSD_UFS, 45263487Smarcel ALIAS_FREEBSD_VINUM, 46263487Smarcel ALIAS_FREEBSD_ZFS, 47263487Smarcel ALIAS_MBR, 48263487Smarcel /* end */ 49263487Smarcel ALIAS_COUNT /* Keep last! */ 50263487Smarcel}; 51263487Smarcel 52263409Smarcelstruct mkimg_alias { 53263487Smarcel u_int alias; 54263461Smarcel uintptr_t type; 55263461Smarcel#define ALIAS_PTR2TYPE(p) (uintptr_t)(p) 56263461Smarcel#define ALIAS_INT2TYPE(i) (i) 57263461Smarcel#define ALIAS_TYPE2PTR(p) (void *)(p) 58263461Smarcel#define ALIAS_TYPE2INT(i) (i) 59263409Smarcel}; 60253923Smarcel 61263409Smarcelstruct mkimg_scheme { 62263440Smarcel const char *name; 63263440Smarcel const char *description; 64263409Smarcel struct mkimg_alias *aliases; 65272030Smarcel lba_t (*metadata)(u_int, lba_t); 66263440Smarcel#define SCHEME_META_IMG_START 1 67263440Smarcel#define SCHEME_META_IMG_END 2 68263440Smarcel#define SCHEME_META_PART_BEFORE 3 69263440Smarcel#define SCHEME_META_PART_AFTER 4 70268161Smarcel int (*write)(lba_t, void *); 71263466Smarcel u_int nparts; 72263466Smarcel u_int labellen; 73263537Smarcel u_int bootcode; 74263700Smarcel u_int maxsecsz; 75263409Smarcel}; 76263409Smarcel 77263409SmarcelSET_DECLARE(schemes, struct mkimg_scheme); 78263409Smarcel#define SCHEME_DEFINE(nm) DATA_SET(schemes, nm) 79263409Smarcel 80253923Smarcelint scheme_select(const char *); 81263409Smarcelstruct mkimg_scheme *scheme_selected(void); 82253923Smarcel 83263537Smarcelint scheme_bootcode(int fd); 84263382Smarcelint scheme_check_part(struct part *); 85253923Smarcelu_int scheme_max_parts(void); 86263829Smarcelu_int scheme_max_secsz(void); 87263844Smarcellba_t scheme_metadata(u_int, lba_t); 88268161Smarcelint scheme_write(lba_t); 89253923Smarcel 90253923Smarcel#endif /* _MKIMG_SCHEME_H_ */ 91