chain.c revision 199767f8919635c4928607450d9e0abb932109ce
/*
* This file and its contents are supplied under the terms of the
* Common Development and Distribution License ("CDDL"), version 1.0.
* You may only use this file in accordance with the terms of version
* 1.0 of the CDDL.
*
* A full copy of the text of the CDDL should have accompanied this
* source. A copy of the CDDL is also available via the Internet at
*/
/*
* Copyright 2015 Toomas Soome <tsoome@me.com>
*/
/*
* Chain loader to load BIOS boot block either from MBR or PBR.
*
* Note the boot block location 0000:7c000 conflicts with loader, so we need to
* read in to temporary space and relocate on exec, when btx is stopped.
*/
#include <stand.h>
#include "bootstrap.h"
#include "btxv86.h"
/*
* Read 512B to temporary location and set up relocation. Then
* exec relocator.
*/
#define SECTOR_SIZE (512)
static int
{
struct i386_devdesc *rootdev;
if (argc == 1) {
command_errmsg = "no device or file name specified";
return (CMD_ERROR);
}
if (argc != 2) {
command_errmsg = "invalid trailing arguments";
return (CMD_ERROR);
}
if (fd == -1) {
command_errmsg = "open failed";
return (CMD_ERROR);
}
command_errmsg = "stat failed";
return (CMD_ERROR);
}
command_errmsg = "can only use disk device";
return (CMD_ERROR);
}
command_errmsg = "can't determine root device";
return (CMD_ERROR);
}
command_errmsg = "failed to read disk";
return (CMD_ERROR);
}
command_errmsg = "wrong magic";
return (CMD_ERROR);
}
relocator_ds = 0;
relocator_es = 0;
relocator_fs = 0;
relocator_gs = 0;
relocator_ss = 0;
relocator_cs = 0;
relocator_sp = 0x7C00;
relocator_ip = 0x7C00;
dev_cleanup();
__exec((void *)0x600);
panic("exec returned");
return (CMD_ERROR); /* not reached */
}