vaseboot/VasEBoot-core/lib/i386/pc/biosnum.c

48 lines
1.4 KiB
C

/*
* VAS_EBOOT -- GRand Unified Bootloader
* Copyright (C) 2009 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/>.
*/
#include <VasEBoot/env.h>
#include <VasEBoot/misc.h>
#include <VasEBoot/disk.h>
#include <VasEBoot/machine/biosnum.h>
static int
VasEBoot_get_root_biosnumber_default (void)
{
const char *biosnum;
int ret = -1;
VasEBoot_device_t dev;
biosnum = VasEBoot_env_get ("biosnum");
if (biosnum)
return VasEBoot_strtoul (biosnum, 0, 0);
dev = VasEBoot_device_open (0);
if (dev && dev->disk && dev->disk->dev
&& dev->disk->dev->id == VAS_EBOOT_DISK_DEVICE_BIOSDISK_ID)
ret = (int) dev->disk->id;
if (dev)
VasEBoot_device_close (dev);
return ret;
}
int (*VasEBoot_get_root_biosnumber) (void) = VasEBoot_get_root_biosnumber_default;