1/*
2 * Copyright (c) 2014, ETH Zurich. All rights reserved.
3 *
4 * This file is distributed under the terms in the attached LICENSE file.
5 * If you do not find this file, copies can be found by writing to:
6 * ETH Zurich D-INFK, Universitaetsstrasse 6, CH-8092 Zurich. Attn: Systems Group.
7 */
8
9#include <barrelfish/barrelfish.h>
10
11#include <pci/pci.h>
12#include <pci/devids.h>
13
14#include <dma/dma.h>
15#include <dma/dma_device.h>
16#include <dma/ioat/ioat_dma.h>
17#include <dma/ioat/ioat_dma_device.h>
18
19#include "device.h"
20#include "ioat_mgr_service.h"
21#include "debug.h"
22
23static uint8_t device_count = 0;
24struct ioat_dma_device **devices;
25static uint8_t device_next = 0;
26static struct pci_addr pci_addr;
27
28
29#if 0
30static void pci_dev_init_service(void *arg, struct device_mem *bar_info,
31                                 int nr_mapped_bars)
32{
33    errval_t err;
34
35    DEV_DEBUG("Initialize device @ [%016lx] with %u bars\n", bar_info->paddr,
36              nr_mapped_bars);
37
38    if (nr_mapped_bars != 1) {
39        DEV_ERR("number of mapped bars is wrong. Skipping initialization\n");
40        return;
41    }
42
43    /* initialize the device */
44    err = ioat_dma_device_init(bar_info->frame_cap, &pci_addr,
45                               &devices[device_count]);
46    if (err_is_fail(err)) {
47        DEV_ERR("Could not initialize the device: %s\n", err_getstring(err));
48        return;
49    }
50
51    device_count++;
52}
53
54static void pci_dev_init_manager(void *arg, struct device_mem *bar_info,
55                                 int nr_mapped_bars)
56{
57    errval_t err;
58
59    DEV_DEBUG("Initialize device @ [%016lx] with %u bars\n", bar_info->paddr,
60              nr_mapped_bars);
61
62    if (nr_mapped_bars != 1) {
63        DEV_ERR("number of mapped bars is wrong. Skipping initialization\n");
64        return;
65    }
66
67    err = ioat_mgr_svc_add_device(bar_info->frame_cap);
68    if (err_is_fail(err)) {
69        DEV_ERR("Device coult not be added to the manager: %s\n",
70                err_getstring(err));
71    }
72}
73#endif
74
75
76