]> git.proxmox.com Git - mirror_edk2.git/blob - Tools/Java/Source/FrameworkTasks/org/tianocore/framework/tasks/CompressHeader.java
- Fixed EDKT240. Now the Blank.pad file for alignment purpose will no longer be needed.
[mirror_edk2.git] / Tools / Java / Source / FrameworkTasks / org / tianocore / framework / tasks / CompressHeader.java
1 /** @file
2 CompressHeader class.
3
4 This class is to generate the compressed section header.
5
6 Copyright (c) 2006, Intel Corporation
7 All rights reserved. This program and the accompanying materials
8 are licensed and made available under the terms and conditions of the BSD License
9 which accompanies this distribution. The full text of the license may be found at
10 http://opensource.org/licenses/bsd-license.php
11
12 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
13 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
14
15 **/
16
17 package org.tianocore.framework.tasks;
18
19 import org.apache.tools.ant.BuildException;
20 /**
21
22 Internal class: This class is to generate the compressed section header.
23
24 **/
25 public class CompressHeader {
26
27 /**
28 CommonSectionHeader
29
30 This class define the compressed header structor.
31
32 **/
33 public class CommonSectionHeader {
34 byte[] Size = new byte[3];
35 byte type;
36 }
37
38 ///
39 /// Section header.
40 ///
41 public CommonSectionHeader SectionHeader = new CommonSectionHeader();
42
43 ///
44 /// Length of uncompress section in byte.
45 ///
46 public int UncompressLen;
47 ///
48 /// Compress type.
49 ///
50 public byte CompressType;
51
52 ///
53 /// The size of compress header in byte.
54 ///
55 public int GetSize (){
56 return 9;
57 }
58
59 ///
60 /// Write class member to buffer.
61 ///
62 public void StructToBuffer (byte[] Buffer){
63 if (Buffer.length != GetSize()) {
64 throw new BuildException ("CompressHeader Buffer size is not correct!");
65 }
66 for (int i = 0; i < 3; i++){
67 Buffer[i] = SectionHeader.Size[i];
68 }
69 Buffer[3] = SectionHeader.type;
70 Buffer[4] = (byte)(UncompressLen & 0xff);
71 Buffer[5] = (byte)((UncompressLen & 0xff00)>>8);
72 Buffer[6] = (byte)((UncompressLen & 0xff0000)>>16);
73 Buffer[7] = (byte)((UncompressLen & 0xff000000)>>24);
74 Buffer[8] = CompressType;
75 }
76
77 }