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
22namespace simics {
23namespace 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
34 const uint8_t *start;
35 size_t len;
36};
37
38struct frags_t {
39 size_t len;
40 unsigned nfrags;
42};
43
44inline 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
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
#define MAX_FRAGS_FRAGS
Definition: frags.h:25
void frags_init_add(simics::types::frags_t *buf, const void *data, size_t len)
Definition: frags.h:54
void frags_extract(const frags_t *buf, void *vdst)
Definition: frags.h:44
Definition: pci_bus_interface.h:24
Definition: frags.h:33
size_t len
Definition: frags.h:35
const uint8_t * start
Definition: frags.h:34
Definition: frags.h:38
size_t len
Definition: frags.h:39
frags_frag_t fraglist[MAX_FRAGS_FRAGS]
Definition: frags.h:41
unsigned nfrags
Definition: frags.h:40