1 /* =================================================================
5 * Relocation types for the PowerPC processor.
7 * =================================================================
8 * ####ECOSGPLCOPYRIGHTBEGIN####
9 * -------------------------------------------
10 * This file is part of eCos, the Embedded Configurable Operating
12 * Copyright (C) 2005 eCosCentric Ltd.
14 * eCos is free software; you can redistribute it and/or modify it
15 * under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 2 or (at your option)
19 * eCos is distributed in the hope that it will be useful, but
20 * WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22 * General Public License for more details.
24 * You should have received a copy of the GNU General Public License
25 * along with eCos; if not, write to the Free Software Foundation,
26 * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
28 * As a special exception, if other files instantiate templates or
29 * use macros or inline functions from this file, or you compile this
30 * file and link it with other works to produce a work based on this
31 * file, this file does not by itself cause the resulting work to be
32 * covered by the GNU General Public License. However the source code
33 * for this file must still be made available in accordance with
34 * section (3) of the GNU General Public License.
36 * This exception does not invalidate any other reasons why a work
37 * based on this file might be covered by the GNU General Public
40 * -------------------------------------------
41 * ####ECOSGPLCOPYRIGHTEND####
42 * =================================================================
43 * #####DESCRIPTIONBEGIN####
45 * Author(s): Anthony Tonizzo (atonizzo@gmail.com)
50 * ####DESCRIPTIONEND####
52 * =================================================================
55 #include <cyg/infra/diag.h> // For diagnostic printing.
56 #include <pkgconf/io_fileio.h>
61 #include <cyg/hal/hal_cache.h>
62 #include <cyg/hal/hal_io.h>
64 #include <pkgconf/objloader.h>
65 #include <cyg/objloader/elf.h>
66 #include <cyg/objloader/objelf.h>
68 #ifdef CYGPKG_HAL_POWERPC
70 cyg_ldr_flush_cache(void)
78 // sym_type Type of relocation to apply,
79 // mem Address in memory to modify (relocate).
82 cyg_ldr_relocate(cyg_int32 sym_type, cyg_uint32 mem, cyg_int32 sym_value)
84 cyg_int32 rel_offset, i;
86 // PPC uses rela, so we have to add the addend.
90 HAL_WRITE_UINT16(mem, _ha_(sym_value));
93 HAL_WRITE_UINT16(mem, _hi_(sym_value));
96 HAL_WRITE_UINT16(mem, _lo_(sym_value));
99 // Now it is time to seek the destination address of the call.
100 // We need to do something in case the user jumps more than 16MB.
101 rel_offset = (sym_value - mem) & 0x03FFFFFC;
102 HAL_READ_UINT32(mem, i);
104 HAL_WRITE_UINT32(mem, rel_offset | i);
107 HAL_WRITE_UINT32(mem, (sym_value - mem));
110 HAL_WRITE_UINT32(mem, sym_value);
113 ELFDEBUG("FIXME: Unknown relocation value!!!\n");
117 #endif // CYGPKG_HAL_POWERPC