blob: e1823329ff457d83bba8a76a2876e63770cee4a2 (
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
|
/** @file
CompressHeader class.
This class is to generate the compressed section header.
Copyright (c) 2006, Intel Corporation
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
package org.tianocore.framework.tasks;
import org.apache.tools.ant.BuildException;
/**
Internal class: This class is to generate the compressed section header.
**/
public class CompressHeader {
/**
CommonSectionHeader
This class define the compressed header structor.
**/
public class CommonSectionHeader {
byte[] Size = new byte[3];
byte type;
}
///
/// Section header.
///
public CommonSectionHeader SectionHeader = new CommonSectionHeader();
///
/// Length of uncompress section in byte.
///
public int UncompressLen;
///
/// Compress type.
///
public byte CompressType;
///
/// The size of compress header in byte.
///
public int GetSize (){
return 9;
}
///
/// Write class member to buffer.
///
public void StructToBuffer (byte[] Buffer){
if (Buffer.length != GetSize()) {
throw new BuildException ("CompressHeader Buffer size is not correct!");
}
for (int i = 0; i < 3; i++){
Buffer[i] = SectionHeader.Size[i];
}
Buffer[3] = SectionHeader.type;
Buffer[4] = (byte)(UncompressLen & 0xff);
Buffer[5] = (byte)((UncompressLen & 0xff00)>>8);
Buffer[6] = (byte)((UncompressLen & 0xff0000)>>16);
Buffer[7] = (byte)((UncompressLen & 0xff000000)>>24);
Buffer[8] = CompressType;
}
}
|