SystemC Library API Reference Manual
Reference documentation for the Simics SystemC Library.
Loading...
Searching...
No Matches
frags.h
Go to the documentation of this file.
1
// -*- mode: C++; c-file-style: "virtutech-c++" -*-
2
3
/*
4
© 2016 Intel Corporation
5
6
This software and the related documents are Intel copyrighted materials, and
7
your use of them is governed by the express license under which they were
8
provided to you ("License"). Unless the License provides otherwise, you may
9
not use, modify, copy, publish, distribute, disclose or transmit this software
10
or the related documents without Intel's prior written permission.
11
12
This software and the related documents are provided as is, with no express or
13
implied warranties, other than those that are expressly stated in the License.
14
*/
15
16
#ifndef SIMICS_TYPES_FRAGS_H
17
#define SIMICS_TYPES_FRAGS_H
18
19
#include <stdint.h>
20
#include <string.h>
21
22
namespace
simics
{
23
namespace
types {
24
25
#define MAX_FRAGS_FRAGS 8
26
27
/* This is a stand-alone subset of the Simics frags_t struct
28
it is copied from simics/util/frags.h and for internal use only
29
User should use the two functions to extract and form the frags_t
30
struct instead of operate on the bare struct.
31
*/
32
33
struct
frags_frag_t
{
34
const
uint8_t *
start
;
35
size_t
len
;
36
};
37
38
struct
frags_t
{
39
size_t
len
;
40
unsigned
nfrags
;
41
frags_frag_t
fraglist
[
MAX_FRAGS_FRAGS
];
42
};
43
44
inline
void
frags_extract
(
const
frags_t
*buf,
void
*vdst) {
45
uint8_t *dst =
static_cast<
uint8_t*
>
(vdst);
46
// No need to use an explicit iterator, since this is a very
47
// simple special case
48
for
(
unsigned
i = 0; i < buf->
nfrags
; i++) {
49
memcpy(dst, buf->
fraglist
[i].
start
, buf->
fraglist
[i].
len
);
50
dst += buf->
fraglist
[i].
len
;
51
}
52
}
53
54
inline
void
frags_init_add
(
simics::types::frags_t
*buf,
55
const
void
*data,
size_t
len) {
56
buf->
len
= len;
57
buf->
nfrags
= 1;
58
buf->
fraglist
[0].
start
= (
const
uint8_t *)data;
59
buf->
fraglist
[0].
len
= len;
60
}
61
62
}
// namespace types
63
}
// namespace simics
64
65
#endif
MAX_FRAGS_FRAGS
#define MAX_FRAGS_FRAGS
Definition:
frags.h:25
simics::types::frags_init_add
void frags_init_add(simics::types::frags_t *buf, const void *data, size_t len)
Definition:
frags.h:54
simics::types::frags_extract
void frags_extract(const frags_t *buf, void *vdst)
Definition:
frags.h:44
simics
Definition:
adapter.h:80
simics::types::frags_frag_t
Definition:
frags.h:33
simics::types::frags_frag_t::len
size_t len
Definition:
frags.h:35
simics::types::frags_frag_t::start
const uint8_t * start
Definition:
frags.h:34
simics::types::frags_t
Definition:
frags.h:38
simics::types::frags_t::len
size_t len
Definition:
frags.h:39
simics::types::frags_t::fraglist
frags_frag_t fraglist[MAX_FRAGS_FRAGS]
Definition:
frags.h:41
simics::types::frags_t::nfrags
unsigned nfrags
Definition:
frags.h:40