summaryrefslogtreecommitdiff
path: root/cesar/hal/arch/dlink/dlink.h
blob: 38c8045ac336718db516df26d774c1af0fab65a3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#ifndef hal_arch_dlink_dlink_h
#define hal_arch_dlink_dlink_h
/* Cesar project {{{
 *
 * Copyright (C) 2012 Spidcom
 *
 * <<<Licence>>>
 *
 * }}} */
/**
 * \file    hal/arch/dlink/dlink.h
 * \brief   Handle dynamic link patch section
 * \ingroup hal_arch_dlink
 *
 * Function to modify call instruction of the copied ILRAM section from RAM to
 * ILRAM and callbacks to point to the function in ILRAM.
 */

/**
 * Copy the code from RAM to local RAM and fix call offset.
 * \param  ils  the ilram destination start address
 * \param  ile  the ilram destination end address
 * \param  rams  the begin of instructions from RAM to copy
 * \param  rame  the end of instructions from RAM to copy
 *
 * This function should modify the call instructions which points to an
 * address function which are outside the copied instructions.
 *
 * \note: SPARC call instruction:
 *    bits 31-30 = 0b01 = Call
 *    bits 29-0 = PC relative shifted address.
 *
 * The new address is PC + <relative @> * 4
 */
void
hal_arch_dlink_copy_ram_to_ilram (
    unsigned long *ils, unsigned long *ile,
    unsigned long *rams, unsigned long *rame);

/**
 * Modify SPARC call instruction in RAM memory to point to ILRAM.
 * \param  sw  the source word to start to read from
 * \param  endw  the end word to stop
 * \param  zb  the begin zone to modify the call instruction
 * \param  ze  the end zone to modify the call instruction
 * \param  zn  the new zone base address to use
 *
 * This function should modify the call instructions which points to an
 * address function which has moved from RAM to ILRAM.
 *
 * \note: SPARC call instruction:
 *    bits 31-30 = 0b01 = Call
 *    bits 29-0 = PC relative shifted address.
 *
 * The new address is PC + <relative @> * 4
 */
void
hal_arch_dlink_patch_ram_call_inst (
    unsigned long *sw, unsigned long *endw,
    unsigned long *zb, unsigned long *ze, unsigned long *zn);

/**
 * Patch callbacks section
 * \param  sw  the source word to start to read from
 * \param  endw  the end word to stop
 * \param  zb  the begin zone to modify the call instruction
 * \param  ze  the end zone to modify the call instruction
 * \param  zn  the new zone base address to use
 *
 * Search addresses which can be in ILRAM2 and modify the associated
 * callbacks.
 */
void
hal_arch_dlink_patch_callbacks (
    unsigned long *sw, unsigned long *endw,
    unsigned long *zb, unsigned long *ze, unsigned long *zn);

#endif /* hal_arch_dlink_dlink_h */