source: rtems/cpukit/libdl/rtl-obj-comp.h @ 3feb372

4.115
Last change on this file since 3feb372 was ae5fe7e6, checked in by Chris Johns <chrisj@…>, on 10/27/14 at 01:09:41

cpukit: Add libdl with the Runtime Loader (RTL) code.

This is a merge of the RTL project.

  • Property mode set to 100644
File size: 4.0 KB
Line 
1/*
2 *  COPYRIGHT (c) 2012 Chris Johns <chrisj@rtems.org>
3 *
4 *  The license and distribution terms for this file may be
5 *  found in the file LICENSE in this distribution or at
6 *  http://www.rtems.com/license/LICENSE.
7 */
8/**
9 * @file
10 *
11 * @ingroup rtems_rtl
12 *
13 * @brief RTEMS Run-Time Linker Object File Compression manages a
14 *        compressed stream of data.
15 *
16 * This is a simple interface to the object file cache to stream data from
17 * from a compressed object file. There is no ability to seek with the
18 * data from a compressed file. The module exists to allocate the output
19 * buffer when the loader starts and use the cache buffers will have been
20 * allocated.
21 */
22
23#if !defined (_RTEMS_RTL_OBJ_COMP_H_)
24#define _RTEMS_RTL_OBJ_COMP_H_
25
26#include <rtems/rtl/rtl-obj-cache.h>
27
28#ifdef __cplusplus
29extern "C" {
30#endif /* __cplusplus */
31
32/**
33 * The amount of input data read at a time from the file.
34 */
35#define RTEMS_RTL_DECOMP_INPUT_SIZE (256)
36
37/**
38 * The types of supported compression.
39 */
40#define RTEMS_RTL_COMP_NONE (0)
41#define RTEMS_RTL_COMP_LZ77 (1)
42
43/**
44 * The compressed file.
45 */
46typedef struct rtems_rtl_obj_cpmp_s
47{
48  rtems_rtl_obj_cache_t* cache;       /**< The cache provides the input
49                                       *   buffer. */
50  int                    fd;          /**< The file descriptor. */
51  int                    compression; /**< The type of compression. */
52  off_t                  offset;      /**< The base offset of the buffer. */
53  size_t                 size;        /**< The size of the output buffer. */
54  size_t                 level;       /**< The amount of data in the buffer. */
55  uint8_t*               buffer;      /**< The buffer */
56  uint32_t               read;        /**< The amount of data read. */
57} rtems_rtl_obj_comp_t;
58
59/**
60 * Return the input level.
61 */
62static inline uint32_t rtems_rtl_obj_comp_input (rtems_rtl_obj_comp_t* comp)
63{
64  return comp->read;
65}
66
67/**
68 * Open a compressor allocating the output buffer.
69 *
70 * @param comp The compressor  to initialise.
71 * @param size The size of the compressor's output buffer.
72 * @retval true The compressor is open.
73 * @retval false The compressor is not open. The RTL error is set.
74 */
75bool rtems_rtl_obj_comp_open (rtems_rtl_obj_comp_t*  comp,
76                              size_t                 size);
77
78/**
79 * Close a compressor.
80 *
81 * @param comp The compressor to close.
82 */
83void rtems_rtl_obj_comp_close (rtems_rtl_obj_comp_t* comp);
84
85/**
86 * Set the cache and offset in the file the compressed stream starts.
87 *
88 * @param comp The compressor to set the offset in.
89 * @param cache The cache to read the file in by.
90 * @param fd The file descriptor. Must be an open file.
91 * @param compression The type of compression being streamed.
92 * @param offset The offset in the file the compressed stream starts.
93 */
94void rtems_rtl_obj_comp_set (rtems_rtl_obj_comp_t*  comp,
95                             rtems_rtl_obj_cache_t* cache,
96                             int                    fd,
97                             int                    compression,
98                             off_t                  offset);
99
100/**
101 * Read decompressed data. The length contains the amount of data that should
102 * be available in the cache and referenced by the buffer handle. It must be
103 * less than or equal to the size of the cache. This call will return the
104 * amount of data that is available. It can be less than you ask if the offset
105 * and size is past the end of the file.
106 *
107 * @param comp The compressor to read data from.
108 * @param buffer The buffer the output is written too.
109 * @param length The length of data to read. Can be modified to a
110 *               lesser value and true is still returned so check it.
111 * @retval true The data referenced is in the cache.
112 * @retval false The read failed and the RTL error has been set.
113 */
114bool rtems_rtl_obj_comp_read (rtems_rtl_obj_comp_t* comp,
115                              void*                 buffer,
116                              size_t                length);
117
118#ifdef __cplusplus
119}
120#endif /* __cplusplus */
121
122#endif
Note: See TracBrowser for help on using the repository browser.