2N/A/*
2N/A * Copyright (C) 2008 Free Software Foundation, Inc.
2N/A *
2N/A * This program is free software: you can redistribute it and/or modify
2N/A * it under the terms of the GNU General Public License as published by
2N/A * the Free Software Foundation, either version 3 of the License, or
2N/A * (at your option) any later version.
2N/A *
2N/A * This program is distributed in the hope that it will be useful,
2N/A * but WITHOUT ANY WARRANTY; without even the implied warranty of
2N/A * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2N/A * GNU General Public License for more details.
2N/A *
2N/A * You should have received a copy of the GNU General Public License
2N/A * along with this program. If not, see <http://www.gnu.org/licenses/>.
2N/A */
2N/A
2N/A#include <grub/file.h>
2N/A#include <grub/err.h>
2N/A#include <grub/dl.h>
2N/A#include <grub/misc.h>
2N/A#include <grub/aout.h>
2N/A
2N/AGRUB_MOD_LICENSE ("GPLv3+");
2N/A
2N/Aint
2N/Agrub_aout_get_type (union grub_aout_header *header)
2N/A{
2N/A int magic;
2N/A
2N/A magic = AOUT_GETMAGIC (header->aout32);
2N/A if ((magic == AOUT32_OMAGIC) || (magic == AOUT32_NMAGIC) ||
2N/A (magic == AOUT32_ZMAGIC) || (magic == AOUT32_QMAGIC))
2N/A return AOUT_TYPE_AOUT32;
2N/A else if ((magic == AOUT64_OMAGIC) || (magic == AOUT64_NMAGIC) ||
2N/A (magic == AOUT64_ZMAGIC))
2N/A return AOUT_TYPE_AOUT64;
2N/A else
2N/A return AOUT_TYPE_NONE;
2N/A}
2N/A
2N/Agrub_err_t
2N/Agrub_aout_load (grub_file_t file, int offset,
2N/A void *load_addr,
2N/A int load_size, grub_size_t bss_size)
2N/A{
2N/A if ((grub_file_seek (file, offset)) == (grub_off_t) - 1)
2N/A return grub_errno;
2N/A
2N/A if (!load_size)
2N/A load_size = file->size - offset;
2N/A
2N/A grub_file_read (file, load_addr, load_size);
2N/A
2N/A if (grub_errno)
2N/A return grub_errno;
2N/A
2N/A if (bss_size)
2N/A grub_memset ((char *) load_addr + load_size, 0, bss_size);
2N/A
2N/A return GRUB_ERR_NONE;
2N/A}