1/*
2 * Copyright (c) 2018, ETH Zurich.
3 * All rights reserved.
4 *
5 * This file is distributed under the terms in the attached LICENSE file.
6 * If you do not find this file, copies can be found by writing to:
7 * ETH Zurich D-INFK, Universitaetsstrasse 6, CH8092 Zurich.
8 * Attn: Systems Group.
9 */
10
11#ifndef DRIVERKIT_HWMODEL_H
12#define DRIVERKIT_HWMODEL_H 1
13
14#include <barrelfish/types.h>
15#include <errors/errno.h>
16
17struct dmem;
18
19errval_t
20driverkit_hwmodel_allocate(size_t bytes, int32_t dstnode,  int32_t * nodes,
21                           uint8_t alloc_bits, genpaddr_t *retaddr);
22errval_t driverkit_hwmodel_ram_alloc(struct capref *dst,
23                                     size_t bytes, int32_t dstnode,
24                                     int32_t *nodes);
25
26errval_t driverkit_hwmodel_frame_alloc(struct capref *dst,
27                                       size_t bytes, int32_t dstnode,
28                                       int32_t *nodes);
29
30errval_t driverkit_hwmodel_get_map_conf_addr(int32_t mem_nodeid, genpaddr_t addr,
31                                             gensize_t size, int32_t nodeid,
32                                             char *ret_conf, size_t ret_conf_size,
33                                             lvaddr_t *ret_addr);
34
35errval_t driverkit_hwmodel_get_map_conf(struct capref dst,
36                                        int32_t nodeid,
37                                        char *ret_conf_buf, size_t ret_conf_size,
38                                        lvaddr_t *ret_addr);
39
40
41
42errval_t driverkit_hwmodel_vspace_map(int32_t nodeid, struct capref frame,
43                                      vregion_flags_t flags, struct dmem *dmem);
44
45errval_t driverkit_hwmodel_vspace_map_fixed(int32_t nodeid,
46                                            genvaddr_t addr,
47                                            struct capref frame,
48                                            vregion_flags_t flags,
49                                            struct dmem *dmem);
50
51
52
53/**
54 * Allocate space to map frame in address space nodeid.
55 */
56errval_t driverkit_hwmodel_vspace_alloc(struct capref frame,
57                                        int32_t nodeid, genvaddr_t *addr);
58errval_t driverkit_hwmode_vspace_get_vaddr(struct capref frame,
59                                           int32_t nodeid, genvaddr_t *addr,
60                                           bool *already_mapped);
61
62int32_t driverkit_hwmodel_get_my_node_id(void);
63int32_t driverkit_hwmodel_lookup_dram_node_id(void);
64int32_t driverkit_hwmodel_lookup_pcibus_node_id(void);
65int32_t driverkit_hwmodel_lookup_node_id(const char *path);
66
67errval_t driverkit_hwmodel_reverse_resolve(struct capref dst,
68                                     int32_t nodeid,
69                                     genpaddr_t *ret_addr);
70
71
72
73
74/**
75 * SKB interface helpers
76 */
77struct hwmodel_name {
78    int32_t nodeid;
79    uint64_t address;
80};
81
82// Parse the output generated by write_regions in decoding_net4.pl
83void driverkit_parse_namelist(char *in, struct hwmodel_name *names, int *conversions);
84
85
86// Disable using the model for allocation
87#define DISABLE_MODEL
88
89//#define HWMODEL_QUERY_DEBUG_ENABLED 1
90#if defined(HWMODEL_QUERY_DEBUG_ENABLED)
91#define HWMODEL_QUERY_DEBUG(x...) do { printf("MODELQUERY: " x); printf("\n"); } while(0)
92
93#else
94#define HWMODEL_QUERY_DEBUG(x...) ((void)0)
95#endif
96
97
98
99
100#endif // DRIVERKIT_HWMODEL_H
101