1/**
2 * \file
3 * \brief Header file for the driver's part of the PCI memory management
4 */
5
6/*
7 * Copyright (c) 2007, 2008, 2010, ETH Zurich.
8 * All rights reserved.
9 *
10 * This file is distributed under the terms in the attached LICENSE file.
11 * If you do not find this file, copies can be found by writing to:
12 * ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group.
13 */
14
15#ifndef LIB_MEM_H_
16#define LIB_MEM_H_
17
18/* XXX: FIXME: this structure is used by both the PCI server and drivers
19 *
20 * Not all fields are valid for all locations, and many are only
21 * filled in after calling map_device() in the driver.
22 */
23struct device_mem {
24    uint8_t type; // 0 = memory BAR, 1 = IO BAR
25    void *vaddr;  // assigned by the device driver when calling map_device()
26    genpaddr_t paddr; // physical base address of device
27    struct capref phys_cap; // array of phys caps (only if type == 0 and in PCI server)
28    struct capref frame_cap; // array of frame caps
29    struct capref io_cap; // IO cap (only valid if type == 1)
30    uint8_t bits;    // size of a single cap in bits
31    size_t bytes;    // size of entire region in bytes
32    struct memobj *memobj;   // valid after map_device()
33    struct vregion *vregion; // valid after map_device()
34    uint8_t bar_nr; // BAR number
35};
36
37errval_t map_device(struct device_mem *mem);
38errval_t map_bars(struct device_mem *bars, int nr_mapped_bars);
39
40#endif // LIB_MEM_H_
41
42