grub/kern/handler.c
bean 7e9ca17ace 2009-03-04 Bean <bean123ch@gmail.com>
* configure.ac: Only test -mcmodel=large option in x86_64-efi, also add
	another option -mno-red-zone.

	* commands/handler.c: Change module description.

	* kern/handler.c: Add missing space at the end of description line.

	* kern/list.c: Likewise.
2009-03-04 05:56:31 +00:00

64 lines
1.9 KiB
C

/* handler.c - grub handler function */
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2009 Free Software Foundation, Inc.
*
* GRUB 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.
*
* GRUB 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 GRUB. If not, see <http://www.gnu.org/licenses/>.
*/
#include <grub/handler.h>
grub_handler_class_t grub_handler_class_list;
void
grub_handler_register (grub_handler_class_t class, grub_handler_t handler)
{
int first_handler = (class->handler_list == 0);
grub_list_push (GRUB_AS_LIST_P (&class->handler_list),
GRUB_AS_LIST (handler));
if (first_handler)
{
grub_list_push (GRUB_AS_LIST_P (&grub_handler_class_list),
GRUB_AS_LIST (class));
grub_handler_set_current (class, handler);
}
}
void
grub_handler_unregister (grub_handler_class_t class, grub_handler_t handler)
{
grub_list_remove (GRUB_AS_LIST_P (&class->handler_list),
GRUB_AS_LIST (handler));
if (class->handler_list == 0)
grub_list_remove (GRUB_AS_LIST_P (&grub_handler_class_list),
GRUB_AS_LIST (class));
}
grub_err_t
grub_handler_set_current (grub_handler_class_t class, grub_handler_t handler)
{
if (class->cur_handler && class->cur_handler->fini)
if ((class->cur_handler->fini) () != GRUB_ERR_NONE)
return grub_errno;
if (handler->init)
if ((handler->init) () != GRUB_ERR_NONE)
return grub_errno;
class->cur_handler = handler;
return GRUB_ERR_NONE;
}