vaseboot/VasEBoot-core/lib/i386/reboot.c

65 lines
1.9 KiB
C

/*
* VAS_EBOOT -- GRand Unified Bootloader
* Copyright (C) 2011 Free Software Foundation, Inc.
*
* VAS_EBOOT is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* VAS_EBOOT is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with VAS_EBOOT. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef VAS_EBOOT_MACHINE_EFI
#include <VasEBoot/relocator.h>
#include <VasEBoot/cpu/relocator.h>
#include <VasEBoot/misc.h>
#include <VasEBoot/mm.h>
#include <VasEBoot/cpu/reboot.h>
#include <VasEBoot/i386/floppy.h>
void
VasEBoot_reboot (void)
{
struct VasEBoot_relocator *relocator = NULL;
VasEBoot_relocator_chunk_t ch;
VasEBoot_err_t err;
void *buf;
struct VasEBoot_relocator16_state state;
VasEBoot_uint16_t segment;
relocator = VasEBoot_relocator_new ();
if (!relocator)
while (1);
err = VasEBoot_relocator_alloc_chunk_align (relocator, &ch, 0x1000, 0x1000,
VasEBoot_reboot_end - VasEBoot_reboot_start,
16, VAS_EBOOT_RELOCATOR_PREFERENCE_NONE,
0);
if (err)
while (1);
buf = get_virtual_current_address (ch);
VasEBoot_memcpy (buf, VasEBoot_reboot_start, VasEBoot_reboot_end - VasEBoot_reboot_start);
segment = ((VasEBoot_addr_t) get_physical_target_address (ch)) >> 4;
state.gs = state.fs = state.es = state.ds = state.ss = segment;
state.sp = 0;
state.cs = segment;
state.ip = 0;
state.a20 = 0;
VasEBoot_stop_floppy ();
err = VasEBoot_relocator16_boot (relocator, state);
while (1);
}
#endif /* VAS_EBOOT_MACHINE_EFI */