#ifndef _INSTALLGRUB_H
#define _INSTALLGRUB_H
#ifdef __cplusplus
extern "C" {
#endif
#include <sys/multiboot.h>
#include "./../common/bblk_einfo.h"
#define SECTOR_SIZE (512)
typedef struct _device_data {
char *path;
char *path_p0;
uint8_t type;
int part_fd;
int disk_fd;
int slice;
int partition;
uint64_t start_sector;
char boot_sector[SECTOR_SIZE];
} ig_device_t;
typedef struct _stage2_data {
char *buf;
char *file;
char *extra;
multiboot_header_t *mboot;
uint32_t mboot_off;
uint32_t file_size;
uint32_t extra_size;
uint32_t buf_size;
uint32_t first_sector;
uint32_t pcfs_first_sectors[2];
} ig_stage2_t;
typedef struct _ig_data {
char stage1_buf[SECTOR_SIZE];
ig_stage2_t stage2;
ig_device_t device;
} ig_data_t;
enum ig_devtype_t {
IG_DEV_X86BOOTPAR = 1,
IG_DEV_SOLVTOC,
IG_DEV_EFI
};
#define is_bootpar(type) (type == IG_DEV_X86BOOTPAR)
#define is_efi(type) (type == IG_DEV_EFI)
#define STAGE2_MEMADDR (0x8000)
#define STAGE1_BPB_OFFSET (0x3)
#define STAGE1_BPB_SIZE (0x3B)
#define STAGE1_BOOT_DRIVE (0x40)
#define STAGE1_FORCE_LBA (0x41)
#define STAGE1_STAGE2_ADDRESS (0x42)
#define STAGE1_STAGE2_SECTOR (0x44)
#define STAGE1_STAGE2_SEGMENT (0x48)
#define STAGE2_BLOCKLIST (SECTOR_SIZE - 0x8)
#define STAGE2_INSTALLPART (SECTOR_SIZE + 0x8)
#define STAGE2_FORCE_LBA (SECTOR_SIZE + 0x11)
#define STAGE2_BLKOFF(type) \
(is_efi(type) ? 1024 : 50)
#define STAGE2_MAXSIZE (1ULL << 19)
#ifdef __cplusplus
}
#endif
#endif