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, 39292341Semaste ALIAS_FAT16B, 40263672Smarcel ALIAS_FAT32, 41263487Smarcel ALIAS_FREEBSD, 42263487Smarcel ALIAS_FREEBSD_BOOT, 43263487Smarcel ALIAS_FREEBSD_NANDFS, 44263487Smarcel ALIAS_FREEBSD_SWAP, 45263487Smarcel ALIAS_FREEBSD_UFS, 46263487Smarcel ALIAS_FREEBSD_VINUM, 47263487Smarcel ALIAS_FREEBSD_ZFS, 48263487Smarcel ALIAS_MBR, 49287122Smarcel ALIAS_NTFS, 50263487Smarcel /* end */ 51263487Smarcel ALIAS_COUNT /* Keep last! */ 52263487Smarcel}; 53263487Smarcel 54263409Smarcelstruct mkimg_alias { 55263487Smarcel u_int alias; 56263461Smarcel uintptr_t type; 57263461Smarcel#define ALIAS_PTR2TYPE(p) (uintptr_t)(p) 58263461Smarcel#define ALIAS_INT2TYPE(i) (i) 59263461Smarcel#define ALIAS_TYPE2PTR(p) (void *)(p) 60263461Smarcel#define ALIAS_TYPE2INT(i) (i) 61263409Smarcel}; 62253923Smarcel 63263409Smarcelstruct mkimg_scheme { 64263440Smarcel const char *name; 65263440Smarcel const char *description; 66263409Smarcel struct mkimg_alias *aliases; 67272030Smarcel lba_t (*metadata)(u_int, lba_t); 68263440Smarcel#define SCHEME_META_IMG_START 1 69263440Smarcel#define SCHEME_META_IMG_END 2 70263440Smarcel#define SCHEME_META_PART_BEFORE 3 71263440Smarcel#define SCHEME_META_PART_AFTER 4 72268161Smarcel int (*write)(lba_t, void *); 73263466Smarcel u_int nparts; 74263466Smarcel u_int labellen; 75263537Smarcel u_int bootcode; 76263700Smarcel u_int maxsecsz; 77263409Smarcel}; 78263409Smarcel 79263409SmarcelSET_DECLARE(schemes, struct mkimg_scheme); 80263409Smarcel#define SCHEME_DEFINE(nm) DATA_SET(schemes, nm) 81263409Smarcel 82253923Smarcelint scheme_select(const char *); 83263409Smarcelstruct mkimg_scheme *scheme_selected(void); 84253923Smarcel 85263537Smarcelint scheme_bootcode(int fd); 86263382Smarcelint scheme_check_part(struct part *); 87253923Smarcelu_int scheme_max_parts(void); 88263829Smarcelu_int scheme_max_secsz(void); 89263844Smarcellba_t scheme_metadata(u_int, lba_t); 90268161Smarcelint scheme_write(lba_t); 91253923Smarcel 92253923Smarcel#endif /* _MKIMG_SCHEME_H_ */ 93