forked from trou/debit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bitstream_parser.h
95 lines (76 loc) · 2.48 KB
/
bitstream_parser.h
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
/*
* Copyright (C) 2006, 2007 Jean-Baptiste Note <jean-baptiste.note@m4x.org>
*
* This file is part of debit.
*
* Debit is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Debit is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with debit. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _BITSTREAM_PARSER_H
#define _BITSTREAM_PARSER_H
#include <stdint.h>
#include <glib.h>
#include "bitheader.h"
/* This structure holds the final results of the parsing phase.
Actually it should be split in two, separating data (mapped files
&al), from the rest.
*/
typedef struct _bitstream_parsed {
/* First header informations */
parsed_header_t header;
/* (virtex-II) chip type info -- from bitstream data */
const void *chip_struct;
/* frames */
const gchar ***frames;
GArray *frame_array;
/* mmapped file information */
GMappedFile *file;
} bitstream_parsed_t;
int alloc_wbitstream(bitstream_parsed_t *bitstream);
void free_wbitstream(bitstream_parsed_t *parser);
bitstream_parsed_t *parse_bitstream(const gchar*filename);
void free_bitstream(bitstream_parsed_t *bitstream);
typedef void (*frame_iterator_t)(const char *frame,
guint type,
guint index,
guint frameidx,
void *data);
/****
* Bitstream frame indexing
****/
void iterate_over_frames(const bitstream_parsed_t *parsed,
frame_iterator_t iter, void *data);
void
iterate_over_frames_far(const bitstream_parsed_t *parsed,
frame_iterator_t iter, void *dat);
typedef struct _frame_record {
guint32 far;
guint32 offset;
unsigned framelen;
const char *frame;
} frame_record_t;
typedef void (*frame_unk_iterator_t)(const frame_record_t *frame,
void *data);
void iterate_over_unk_frames(const bitstream_parsed_t *parsed,
frame_unk_iterator_t iter, void *itdat);
/* for v2 */
void
typed_frame_name(char *buf, unsigned buf_len,
const unsigned type,
const unsigned index,
const unsigned frameid);
/* for v4, v5 */
int
snprintf_far(char *buf, const size_t buf_len,
const uint32_t hwfar);
#endif /* _BITSTREAM_PARSER_H */