iPXE
pnm.h
Go to the documentation of this file.
1 #ifndef _IPXE_PNM_H
2 #define _IPXE_PNM_H
3 
4 /** @file
5  *
6  * Portable anymap format (PNM)
7  *
8  */
9 
10 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
11 
12 #include <stdint.h>
13 #include <ipxe/uaccess.h>
14 #include <ipxe/image.h>
15 
16 /** PNM signature */
17 struct pnm_signature {
18  /** Magic byte ('P') */
19  char magic;
20  /** PNM type */
21  char type;
22  /** Whitespace */
23  char space;
24 } __attribute__ (( packed ));
25 
26 /** PNM magic byte */
27 #define PNM_MAGIC 'P'
28 
29 /** PNM context */
30 struct pnm_context {
31  /** PNM type */
32  struct pnm_type *type;
33  /** Current byte offset */
34  size_t offset;
35  /** Maximum length of ASCII values */
36  size_t ascii_len;
37  /** Maximum pixel value */
38  unsigned int max;
39 };
40 
41 /** Default maximum length of ASCII values */
42 #define PNM_ASCII_LEN 16
43 
44 /** PNM type */
45 struct pnm_type {
46  /** PNM type */
47  char type;
48  /** Number of scalar values per pixel */
50  /** Number of pixels per composite value */
52  /** Flags */
54  /** Extract scalar value
55  *
56  * @v image PNM image
57  * @v pnm PNM context
58  * @ret value Value, or negative error
59  */
60  int ( * scalar ) ( struct image *image, struct pnm_context *pnm );
61  /** Convert composite value to 24-bit RGB
62  *
63  * @v composite Composite value
64  * @v index Pixel index within this composite value
65  * @ret rgb 24-bit RGB value
66  */
67  uint32_t ( * rgb ) ( uint32_t composite, unsigned int index );
68 };
69 
70 /** PNM flags */
71 enum pnm_flags {
72  /** Bitmap format
73  *
74  * If set, this flag indicates that:
75  *
76  * - the maximum scalar value is predefined as being equal to
77  * (2^packing-1), and is not present within the file, and
78  *
79  * - the maximum length of ASCII values is 1.
80  */
81  PNM_BITMAP = 0x01,
82 };
83 
84 extern struct image_type pnm_image_type __image_type ( PROBE_NORMAL );
85 
86 #endif /* _IPXE_PNM_H */
#define __attribute__(x)
Definition: compiler.h:10
char space
Whitespace.
Definition: pnm.h:23
int(* scalar)(struct image *image, struct pnm_context *pnm)
Extract scalar value.
Definition: pnm.h:60
uint8_t flags
Flags.
Definition: pnm.h:53
struct image_type pnm_image_type __image_type(PROBE_NORMAL)
An executable image type.
Definition: image.h:76
#define PROBE_NORMAL
Normal image probe priority.
Definition: image.h:137
char type
PNM type.
Definition: pnm.h:21
An executable image.
Definition: image.h:24
unsigned int max
Maximum pixel value.
Definition: pnm.h:38
Access to external ("user") memory.
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)
pnm_flags
PNM flags.
Definition: pnm.h:71
Executable images.
size_t ascii_len
Maximum length of ASCII values.
Definition: pnm.h:36
uint8_t packing
Number of pixels per composite value.
Definition: pnm.h:51
unsigned char uint8_t
Definition: stdint.h:10
PNM type.
Definition: pnm.h:45
unsigned int uint32_t
Definition: stdint.h:12
struct pnm_type * type
PNM type.
Definition: pnm.h:32
PNM signature.
Definition: pnm.h:17
char type
PNM type.
Definition: pnm.h:47
char magic
Magic byte ('P')
Definition: pnm.h:19
Bitmap format.
Definition: pnm.h:81
uint64_t index
Index of the first segment within the content.
Definition: pccrc.h:21
uint8_t depth
Number of scalar values per pixel.
Definition: pnm.h:49
size_t offset
Current byte offset.
Definition: pnm.h:34
uint32_t(* rgb)(uint32_t composite, unsigned int index)
Convert composite value to 24-bit RGB.
Definition: pnm.h:67
PNM context.
Definition: pnm.h:30