TianoCore EDK2 master
Loading...
Searching...
No Matches
Bra.h
1/* Bra.h -- Branch converters for executables
22013-01-18 : Igor Pavlov : Public domain */
3
4#ifndef __BRA_H
5#define __BRA_H
6
7#include "7zTypes.h"
8
9EXTERN_C_BEGIN
10
11/*
12These functions convert relative addresses to absolute addresses
13in CALL instructions to increase the compression ratio.
14
15 In:
16 data - data buffer
17 size - size of data
18 ip - current virtual Instruction Pinter (IP) value
19 state - state variable for x86 converter
20 encoding - 0 (for decoding), 1 (for encoding)
21
22 Out:
23 state - state variable for x86 converter
24
25 Returns:
26 The number of processed bytes. If you call these functions with multiple calls,
27 you must start next call with first byte after block of processed bytes.
28
29 Type Endian Alignment LookAhead
30
31 x86 little 1 4
32 ARMT little 2 2
33 ARM little 4 0
34 PPC big 4 0
35 SPARC big 4 0
36 IA64 little 16 0
37
38 size must be >= Alignment + LookAhead, if it's not last block.
39 If (size < Alignment + LookAhead), converter returns 0.
40
41 Example:
42
43 UInt32 ip = 0;
44 for ()
45 {
46 ; size must be >= Alignment + LookAhead, if it's not last block
47 SizeT processed = Convert(data, size, ip, 1);
48 data += processed;
49 size -= processed;
50 ip += processed;
51 }
52*/
53
54#define x86_Convert_Init(state) { state = 0; }
55SizeT
56x86_Convert (
57 Byte *data,
58 SizeT size,
59 UInt32 ip,
60 UInt32 *state,
61 int encoding
62 );
63
64SizeT
65ARM_Convert (
66 Byte *data,
67 SizeT size,
68 UInt32 ip,
69 int encoding
70 );
71
72SizeT
73ARMT_Convert (
74 Byte *data,
75 SizeT size,
76 UInt32 ip,
77 int encoding
78 );
79
80SizeT
81PPC_Convert (
82 Byte *data,
83 SizeT size,
84 UInt32 ip,
85 int encoding
86 );
87
88SizeT
89SPARC_Convert (
90 Byte *data,
91 SizeT size,
92 UInt32 ip,
93 int encoding
94 );
95
96SizeT
97IA64_Convert (
98 Byte *data,
99 SizeT size,
100 UInt32 ip,
101 int encoding
102 );
103
104EXTERN_C_END
105
106#endif