2N/A/*
2N/A * GRUB -- GRand Unified Bootloader
2N/A * Copyright (C) 2009 Free Software Foundation, Inc.
2N/A *
2N/A * GRUB 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 * GRUB 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 GRUB. If not, see <http://www.gnu.org/licenses/>.
2N/A */
2N/A
2N/A#ifndef GRUB_RELOCATOR_PRIVATE_HEADER
2N/A#define GRUB_RELOCATOR_PRIVATE_HEADER 1
2N/A
2N/A#include <grub/types.h>
2N/A#include <grub/err.h>
2N/A#include <grub/mm_private.h>
2N/A
2N/Aextern grub_size_t grub_relocator_align;
2N/Aextern grub_size_t grub_relocator_forward_size;
2N/Aextern grub_size_t grub_relocator_backward_size;
2N/Aextern grub_size_t grub_relocator_jumper_size;
2N/A
2N/Avoid
2N/Agrub_cpu_relocator_init (void);
2N/Agrub_err_t
2N/Agrub_relocator_prepare_relocs (struct grub_relocator *rel,
2N/A grub_addr_t addr,
2N/A void **relstart, grub_size_t *relsize);
2N/Avoid grub_cpu_relocator_forward (void *rels, void *src, void *tgt,
2N/A grub_size_t size);
2N/Avoid grub_cpu_relocator_backward (void *rels, void *src, void *tgt,
2N/A grub_size_t size);
2N/Avoid grub_cpu_relocator_jumper (void *rels, grub_addr_t addr);
2N/A
2N/A/* Remark: GRUB_RELOCATOR_FIRMWARE_REQUESTS_QUANT_LOG = 1 or 2
2N/A aren't supported. */
2N/A#ifdef GRUB_MACHINE_IEEE1275
2N/A#define GRUB_RELOCATOR_HAVE_FIRMWARE_REQUESTS 1
2N/A#define GRUB_RELOCATOR_FIRMWARE_REQUESTS_QUANT_LOG 0
2N/A#elif defined (GRUB_MACHINE_EFI)
2N/A#define GRUB_RELOCATOR_HAVE_FIRMWARE_REQUESTS 1
2N/A#define GRUB_RELOCATOR_FIRMWARE_REQUESTS_QUANT_LOG 12
2N/A#else
2N/A#define GRUB_RELOCATOR_HAVE_FIRMWARE_REQUESTS 0
2N/A#endif
2N/A
2N/A#if GRUB_RELOCATOR_HAVE_FIRMWARE_REQUESTS && GRUB_RELOCATOR_FIRMWARE_REQUESTS_QUANT_LOG != 0
2N/A#define GRUB_RELOCATOR_HAVE_LEFTOVERS 1
2N/A#else
2N/A#define GRUB_RELOCATOR_HAVE_LEFTOVERS 0
2N/A#endif
2N/A
2N/A#if GRUB_RELOCATOR_HAVE_FIRMWARE_REQUESTS
2N/A#define GRUB_RELOCATOR_FIRMWARE_REQUESTS_QUANT (1 << GRUB_RELOCATOR_FIRMWARE_REQUESTS_QUANT_LOG)
2N/A#endif
2N/A
2N/Astruct grub_relocator_mmap_event
2N/A{
2N/A enum {
2N/A IN_REG_START = 0,
2N/A IN_REG_END = 1,
2N/A REG_BEG_START = 2,
2N/A REG_BEG_END = REG_BEG_START | 1,
2N/A#if GRUB_RELOCATOR_HAVE_FIRMWARE_REQUESTS
2N/A REG_FIRMWARE_START = 4,
2N/A REG_FIRMWARE_END = REG_FIRMWARE_START | 1,
2N/A /* To track the regions already in heap. */
2N/A FIRMWARE_BLOCK_START = 6,
2N/A FIRMWARE_BLOCK_END = FIRMWARE_BLOCK_START | 1,
2N/A#endif
2N/A#if GRUB_RELOCATOR_HAVE_LEFTOVERS
2N/A REG_LEFTOVER_START = 8,
2N/A REG_LEFTOVER_END = REG_LEFTOVER_START | 1,
2N/A#endif
2N/A COLLISION_START = 10,
2N/A COLLISION_END = COLLISION_START | 1
2N/A } type;
2N/A grub_phys_addr_t pos;
2N/A union
2N/A {
2N/A struct
2N/A {
2N/A grub_mm_region_t reg;
2N/A grub_mm_header_t hancestor;
2N/A grub_mm_region_t *regancestor;
2N/A grub_mm_header_t head;
2N/A };
2N/A#if GRUB_RELOCATOR_HAVE_FIRMWARE_REQUESTS
2N/A struct grub_relocator_fw_leftover *leftover;
2N/A#endif
2N/A };
2N/A};
2N/A
2N/A/* Return 0 on failure, 1 on success. The failure here
2N/A can be very time-expensive, so please make sure fill events is accurate. */
2N/A#if GRUB_RELOCATOR_HAVE_FIRMWARE_REQUESTS
2N/Aint grub_relocator_firmware_alloc_region (grub_phys_addr_t start,
2N/A grub_size_t size);
2N/Aunsigned grub_relocator_firmware_fill_events (struct grub_relocator_mmap_event *events);
2N/Aunsigned grub_relocator_firmware_get_max_events (void);
2N/Avoid grub_relocator_firmware_free_region (grub_phys_addr_t start,
2N/A grub_size_t size);
2N/A#endif
2N/A
2N/A#endif