2002-12-27 08:53:07 +00:00
|
|
|
/*
|
|
|
|
* PUPA -- Preliminary Universal Programming Architecture for GRUB
|
2004-02-24 17:21:53 +00:00
|
|
|
* Copyright (C) 2002,2003 Free Software Foundation, Inc.
|
2002-12-27 08:53:07 +00:00
|
|
|
*
|
|
|
|
* PUPA 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 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program 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 PUPA; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <pupa/loader.h>
|
|
|
|
#include <pupa/misc.h>
|
|
|
|
#include <pupa/mm.h>
|
|
|
|
#include <pupa/err.h>
|
|
|
|
|
|
|
|
static pupa_err_t (*pupa_loader_boot_func) (void);
|
|
|
|
static pupa_err_t (*pupa_loader_unload_func) (void);
|
|
|
|
|
|
|
|
static int pupa_loader_loaded;
|
|
|
|
|
|
|
|
void
|
2003-01-17 02:52:05 +00:00
|
|
|
pupa_loader_set (pupa_err_t (*boot) (void),
|
2002-12-27 08:53:07 +00:00
|
|
|
pupa_err_t (*unload) (void))
|
|
|
|
{
|
|
|
|
if (pupa_loader_loaded && pupa_loader_unload_func)
|
2003-11-16 16:36:39 +00:00
|
|
|
pupa_loader_unload_func ();
|
2002-12-27 08:53:07 +00:00
|
|
|
|
|
|
|
pupa_loader_boot_func = boot;
|
|
|
|
pupa_loader_unload_func = unload;
|
|
|
|
|
|
|
|
pupa_loader_loaded = 1;
|
|
|
|
}
|
|
|
|
|
2003-11-16 16:36:39 +00:00
|
|
|
void
|
|
|
|
pupa_loader_unset(void)
|
|
|
|
{
|
|
|
|
if (pupa_loader_loaded && pupa_loader_unload_func)
|
|
|
|
pupa_loader_unload_func ();
|
|
|
|
|
|
|
|
pupa_loader_boot_func = 0;
|
|
|
|
pupa_loader_unload_func = 0;
|
|
|
|
|
|
|
|
pupa_loader_loaded = 0;
|
|
|
|
}
|
|
|
|
|
2002-12-27 08:53:07 +00:00
|
|
|
pupa_err_t
|
|
|
|
pupa_loader_boot (void)
|
|
|
|
{
|
|
|
|
if (! pupa_loader_loaded)
|
|
|
|
return pupa_error (PUPA_ERR_NO_KERNEL, "no loaded kernel");
|
|
|
|
|
|
|
|
return (pupa_loader_boot_func) ();
|
|
|
|
}
|
|
|
|
|