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