]> git.kernelconcepts.de Git - karo-tx-redboot.git/blob - packages/services/objloader/v2_0/src/relocate_i386.c
unified MX27, MX25, MX37 trees
[karo-tx-redboot.git] / packages / services / objloader / v2_0 / src / relocate_i386.c
1 /* =================================================================
2  *
3  *      relocate_i386.c
4  *
5  *      Relocation types for the i386 processor.
6  *
7  * ================================================================= 
8  * ####ECOSGPLCOPYRIGHTBEGIN####
9  * -------------------------------------------
10  * This file is part of eCos, the Embedded Configurable Operating
11  * System.
12  * Copyright (C) 2005 eCosCentric LTD.
13  * Copyright (C) 2005 Andrew Lunn <andrew.lunn@ascom.ch>.
14  * 
15  * eCos is free software; you can redistribute it and/or modify it
16  * under the terms of the GNU General Public License as published by
17  * the Free Software Foundation; either version 2 or (at your option)
18  * any later version.
19  * 
20  * eCos is distributed in the hope that it will be useful, but
21  * WITHOUT ANY WARRANTY; without even the implied warranty of
22  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
23  * General Public License for more details.
24  * 
25  * You should have received a copy of the GNU General Public License
26  * along with eCos; if not, write to the Free Software Foundation,
27  * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
28  * 
29  * As a special exception, if other files instantiate templates or
30  * use macros or inline functions from this file, or you compile this
31  * file and link it with other works to produce a work based on this
32  * file, this file does not by itself cause the resulting work to be
33  * covered by the GNU General Public License. However the source code
34  * for this file must still be made available in accordance with
35  * section (3) of the GNU General Public License.
36  * 
37  * This exception does not invalidate any other reasons why a work
38  * based on this file might be covered by the GNU General Public
39  * License.
40  *
41  * -------------------------------------------
42  * ####ECOSGPLCOPYRIGHTEND####
43  * =================================================================
44  * #####DESCRIPTIONBEGIN####
45  * 
46  *  Author(s):    Anthony Tonizzo (atonizzo@gmail.com), andrew.lunn@ascom.ch
47  *  Date:         2005-07-07
48  *  Purpose:      
49  *  Description:  
50  *               
51  * ####DESCRIPTIONEND####
52  * 
53  * =================================================================
54  */
55
56 #include <cyg/infra/diag.h>     // For diagnostic printing.
57 #include <cyg/hal/hal_cache.h>
58 #include <cyg/hal/hal_io.h>
59
60 #include <pkgconf/objloader.h>
61 #include <cyg/objloader/elf.h>
62 #include <cyg/objloader/objelf.h>
63
64 #if defined(CYGPKG_HAL_I386) || defined(CYGPKG_HAL_SYNTH_I386)
65 void
66 cyg_ldr_flush_cache(void)
67 {
68     HAL_DCACHE_SYNC();
69     HAL_ICACHE_SYNC();
70 }
71
72 // in:
73 // 
74 // sym_type  Type of relocation to apply,
75 // mem       Address in memory to modify (relocate).
76 // sym_value 
77 cyg_int32 
78 cyg_ldr_relocate(cyg_int32 sym_type, cyg_uint32 mem, cyg_int32 sym_value)
79 {
80   cyg_int32  i;
81   
82   // PPC uses rela, so we have to add the addend.
83   switch(sym_type)
84     {
85       case R_386_32:
86         HAL_READ_UINT32(mem , i);
87         HAL_WRITE_UINT32(mem, i + sym_value );
88       return 0;
89       case R_386_PC32:
90         HAL_READ_UINT32(mem , i);
91         HAL_WRITE_UINT32(mem,  i + sym_value - mem);
92         return 0;
93       default:
94         ELFDEBUG("FIXME: Unknown relocation value!!!\n");
95         return -1;
96     }
97 }
98 #endif // CYGPKG_HAL_I386 || CYGPKG_HAL_SYNTH_I386
99
100