#ifndef _INSTALLBOOT_H
#define _INSTALLBOOT_H
#if HAVE_NBTOOL_CONFIG_H
#include "nbtool_config.h"
#include "../../sys/sys/bootblock.h"
#else
#include <sys/bootblock.h>
#include <sys/endian.h>
#endif
#include <sys/stat.h>
#include <stdint.h>
typedef enum {
IB_VERBOSE = 1<<0,
IB_NOWRITE = 1<<1,
IB_CLEAR = 1<<2,
IB_EDIT = 1<<3,
IB_FORCE = 1<<4,
IB_ALPHASUM = 1<<8,
IB_APPEND = 1<<9,
IB_SUNSUM = 1<<10,
IB_STAGE1START= 1<<11,
IB_STAGE2START= 1<<12,
IB_COMMAND = 1<<13,
IB_RESETVIDEO = 1<<14,
IB_CONSOLE = 1<<15,
IB_CONSPEED = 1<<16,
IB_TIMEOUT = 1<<17,
IB_PASSWORD = 1<<18,
IB_KEYMAP = 1<<19,
IB_CONSADDR = 1<<20,
IB_MODULES = 1<<21,
IB_BOOTCONF = 1<<22,
IB_BOARD = 1<<23,
IB_DTB= 1<<24,
IB_MEDIA = 1<<25,
} ib_flags;
typedef enum {
MF_UBOOT = 1<<0,
} m_flags;
typedef struct {
ib_flags flags;
struct ib_mach *machine;
struct ib_fs *fstype;
const char *filesystem;
int fsfd;
struct stat fsstat;
const char *stage1;
int s1fd;
struct stat s1stat;
uint64_t s1start;
const char *stage2;
uint64_t s2start;
uint32_t sectorsize;
const char *uboot_paths;
const char *command;
const char *console;
int conspeed;
int consaddr;
const char *password;
int timeout;
const char *keymap;
const char *board;
const char *dtb;
const char *media;
void *mach_data;
} ib_params;
typedef struct {
uint64_t block;
uint32_t blocksize;
} ib_block;
struct ib_mach {
const char *name;
int (*setboot) (ib_params *);
int (*clearboot) (ib_params *);
int (*editboot) (ib_params *);
void (*usage) (ib_params *);
ib_flags valid_flags;
m_flags mach_flags;
};
struct ib_fs {
const char *name;
int (*match) (ib_params *);
int (*findstage2) (ib_params *, uint32_t *, ib_block *);
uint32_t blocksize;
uint32_t needswap;
off_t sblockloc;
off_t offset;
};
typedef enum {
BBINFO_BIG_ENDIAN = 0,
BBINFO_LITTLE_ENDIAN = 1,
} bbinfo_endian;
struct bbinfo_params {
const char *magic;
uint32_t offset;
uint32_t blocksize;
uint32_t maxsize;
uint32_t headeroffset;
bbinfo_endian endian;
};
extern struct ib_mach * const machines[];
extern struct ib_fs fstypes[];
uint16_t compute_sunsum(const uint16_t *);
int set_sunsum(ib_params *, uint16_t *, uint16_t);
int no_setboot(ib_params *);
int no_clearboot(ib_params *);
int no_editboot(ib_params *);
int shared_bbinfo_clearboot(ib_params *, struct bbinfo_params *,
int (*)(ib_params *, struct bbinfo_params *, uint8_t *));
int shared_bbinfo_setboot(ib_params *, struct bbinfo_params *,
int (*)(ib_params *, struct bbinfo_params *, uint8_t *));
int cd9660_match(ib_params *);
int cd9660_findstage2(ib_params *, uint32_t *, ib_block *);
int ext2fs_match(ib_params *);
int ext2fs_findstage2(ib_params *, uint32_t *, ib_block *);
int ffs_match(ib_params *);
int ffs_findstage2(ib_params *, uint32_t *, ib_block *);
int raid_match(ib_params *);
int hardcode_stage2(ib_params *, uint32_t *, ib_block *);
int raw_match(ib_params *);
int raw_findstage2(ib_params *, uint32_t *, ib_block *);
extern struct ib_mach ib_mach_alpha;
extern struct ib_mach ib_mach_amd64;
extern struct ib_mach ib_mach_amiga;
extern struct ib_mach ib_mach_evbarm;
extern struct ib_mach ib_mach_evbmips;
extern struct ib_mach ib_mach_ews4800mips;
extern struct ib_mach ib_mach_hp300;
extern struct ib_mach ib_mach_hppa;
extern struct ib_mach ib_mach_i386;
extern struct ib_mach ib_mach_landisk;
extern struct ib_mach ib_mach_macppc;
extern struct ib_mach ib_mach_news68k;
extern struct ib_mach ib_mach_newsmips;
extern struct ib_mach ib_mach_next68k;
extern struct ib_mach ib_mach_pmax;
extern struct ib_mach ib_mach_riscv;
extern struct ib_mach ib_mach_sparc;
extern struct ib_mach ib_mach_sparc64;
extern struct ib_mach ib_mach_sun2;
extern struct ib_mach ib_mach_sun3;
extern struct ib_mach ib_mach_vax;
extern struct ib_mach ib_mach_x68k;
#endif