/* * VasEBoot -- GRand Unified Bootloader * Copyright (C) 2009 Free Software Foundation, Inc. * * VasEBoot 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. * * VasEBoot 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 VasEBoot. If not, see . */ #ifndef VasEBoot_RELOCATOR_PRIVATE_HEADER #define VasEBoot_RELOCATOR_PRIVATE_HEADER 1 #include #include #include extern VasEBoot_size_t VasEBoot_relocator_align; extern VasEBoot_size_t VasEBoot_relocator_forward_size; extern VasEBoot_size_t VasEBoot_relocator_backward_size; extern VasEBoot_size_t VasEBoot_relocator_jumper_size; void VasEBoot_cpu_relocator_init (void); VasEBoot_err_t VasEBoot_relocator_prepare_relocs (struct VasEBoot_relocator *rel, VasEBoot_addr_t addr, void **relstart, VasEBoot_size_t *relsize); void VasEBoot_cpu_relocator_forward (void *rels, void *src, void *tgt, VasEBoot_size_t size); void VasEBoot_cpu_relocator_backward (void *rels, void *src, void *tgt, VasEBoot_size_t size); void VasEBoot_cpu_relocator_jumper (void *rels, VasEBoot_addr_t addr); /* Remark: VasEBoot_RELOCATOR_FIRMWARE_REQUESTS_QUANT_LOG = 1 or 2 aren't supported. */ #ifdef VasEBoot_MACHINE_IEEE1275 #define VasEBoot_RELOCATOR_HAVE_FIRMWARE_REQUESTS 1 #define VasEBoot_RELOCATOR_FIRMWARE_REQUESTS_QUANT_LOG 0 #elif defined (VasEBoot_MACHINE_EFI) #define VasEBoot_RELOCATOR_HAVE_FIRMWARE_REQUESTS 1 #define VasEBoot_RELOCATOR_FIRMWARE_REQUESTS_QUANT_LOG 12 #else #define VasEBoot_RELOCATOR_HAVE_FIRMWARE_REQUESTS 0 #endif #if VasEBoot_RELOCATOR_HAVE_FIRMWARE_REQUESTS && VasEBoot_RELOCATOR_FIRMWARE_REQUESTS_QUANT_LOG != 0 #define VasEBoot_RELOCATOR_HAVE_LEFTOVERS 1 #else #define VasEBoot_RELOCATOR_HAVE_LEFTOVERS 0 #endif #if VasEBoot_RELOCATOR_HAVE_FIRMWARE_REQUESTS #define VasEBoot_RELOCATOR_FIRMWARE_REQUESTS_QUANT (1 << VasEBoot_RELOCATOR_FIRMWARE_REQUESTS_QUANT_LOG) #endif struct VasEBoot_relocator_mmap_event { enum { IN_REG_START = 0, IN_REG_END = 1, REG_BEG_START = 2, REG_BEG_END = REG_BEG_START | 1, #if VasEBoot_RELOCATOR_HAVE_FIRMWARE_REQUESTS REG_FIRMWARE_START = 4, REG_FIRMWARE_END = REG_FIRMWARE_START | 1, /* To track the regions already in heap. */ FIRMWARE_BLOCK_START = 6, FIRMWARE_BLOCK_END = FIRMWARE_BLOCK_START | 1, #endif #if VasEBoot_RELOCATOR_HAVE_LEFTOVERS REG_LEFTOVER_START = 8, REG_LEFTOVER_END = REG_LEFTOVER_START | 1, #endif COLLISION_START = 10, COLLISION_END = COLLISION_START | 1 } type; VasEBoot_phys_addr_t pos; union { struct { VasEBoot_mm_region_t reg; VasEBoot_mm_header_t hancestor; VasEBoot_mm_region_t *regancestor; VasEBoot_mm_header_t head; }; #if VasEBoot_RELOCATOR_HAVE_FIRMWARE_REQUESTS struct VasEBoot_relocator_fw_leftover *leftover; #endif }; }; /* Return 0 on failure, 1 on success. The failure here can be very time-expensive, so please make sure fill events is accurate. */ #if VasEBoot_RELOCATOR_HAVE_FIRMWARE_REQUESTS int VasEBoot_relocator_firmware_alloc_region (VasEBoot_phys_addr_t start, VasEBoot_size_t size); unsigned VasEBoot_relocator_firmware_fill_events (struct VasEBoot_relocator_mmap_event *events); unsigned VasEBoot_relocator_firmware_get_max_events (void); void VasEBoot_relocator_firmware_free_region (VasEBoot_phys_addr_t start, VasEBoot_size_t size); #endif #endif