]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Library/LzmaCustomDecompressLib/Sdk/C/Bra.h
ecf7b0c44759eb074cf7da2aa32f26f726c81415
[mirror_edk2.git] / MdeModulePkg / Library / LzmaCustomDecompressLib / Sdk / C / Bra.h
1 /* Bra.h -- Branch converters for executables
2 2013-01-18 : Igor Pavlov : Public domain */
3
4 #ifndef __BRA_H
5 #define __BRA_H
6
7 #include "7zTypes.h"
8
9 EXTERN_C_BEGIN
10
11 /*
12 These functions convert relative addresses to absolute addresses
13 in 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; }
55 SizeT x86_Convert(Byte *data, SizeT size, UInt32 ip, UInt32 *state, int encoding);
56 SizeT ARM_Convert(Byte *data, SizeT size, UInt32 ip, int encoding);
57 SizeT ARMT_Convert(Byte *data, SizeT size, UInt32 ip, int encoding);
58 SizeT PPC_Convert(Byte *data, SizeT size, UInt32 ip, int encoding);
59 SizeT SPARC_Convert(Byte *data, SizeT size, UInt32 ip, int encoding);
60 SizeT IA64_Convert(Byte *data, SizeT size, UInt32 ip, int encoding);
61
62 EXTERN_C_END
63
64 #endif