/* * Copyright (c) 2016, ETH Zurich. * All rights reserved. * * This file is distributed under the terms in the attached LICENSE file. * If you do not find this file, copies can be found by writing to: * ETH Zurich D-INFK, Universitaetstrasse 6, CH-8092 Zurich. Attn: Systems Group. */ #include #include #include #include #include #include #include #include "queue_manager.h" #define DRIVER_DEBUG(x...) debug_printf("[ioat] " x) /** * Driver initialization function. This function is called by the driver domain * (see also 'create_handler' in ddomain_service.c). * Typically through a request from the device manager. * * The init function is supposed to set `dev` to the exported service iref. * The init function may use `bfi->dstate` to store additional state about the device. * * \param[in] bfi The instance of this driver. * \param[in] name The name of this driver instance. * \param[in] flags Additional flags (The exact flags supported is device/driver specific). * \param[in] c Capabilities (for registers etc.) as provided by the device manager. * The exact layout of the `c` is device specific. * \param[out] dev The service iref over which the device can be contacted. * * \retval SYS_ERR_OK Device initialized successfully. * \retval LIB_ERR_MALLOC_FAIL Unable to allocate memory for the driver. */ static errval_t init(struct bfdriver_instance* bfi, const char* name, uint64_t flags, struct capref* caps, size_t caps_len, char** args, size_t args_len, iref_t* dev) { errval_t err; DRIVER_DEBUG("%s:%d: %s\n", __FUNCTION__, __LINE__, bfi->driver->name); /* TODO: obtain these values */ struct capref devcap = NULL_CAP; uint64_t id = 0x0; /* */ struct device_queue *q = calloc(1, sizeof(*q)); if (q == NULL) { return LIB_ERR_MALLOC_FAIL; } err = dqm_init_queue(devcap, id, QUEUE_TYPE_IOAT_DMA, q); if (err_is_fail(err)) { return err; } err = dqm_add_queue(q); assert(err_is_ok(err)); // 1. Initialize the device: // 2. Export service to talk to the device: // 3. Set iref of your exported service (this is reported back to Kaluga) *dev = 0x00; return SYS_ERR_OK; } /** * Instructs driver to attach to the device. * This function is only called if the driver has previously detached * from the device (see also detach). * * \note After detachment the driver can not assume anything about the * configuration of the device. * * \param[in] bfi The instance of this driver. * \retval SYS_ERR_OK Device initialized successfully. */ static errval_t attach(struct bfdriver_instance* bfi) { DRIVER_DEBUG("%s:%d: %s\n", __FUNCTION__, __LINE__, bfi->driver->name); return SYS_ERR_OK; } /** * Instructs driver to detach from the device. * The driver must yield any control over to the device after this function returns. * The device may be left in any state. * * \param[in] bfi The instance of this driver. * \retval SYS_ERR_OK Device initialized successfully. */ static errval_t detach(struct bfdriver_instance* bfi) { DRIVER_DEBUG("%s:%d: %s\n", __FUNCTION__, __LINE__, bfi->driver->name); return SYS_ERR_OK; } /** * Instructs the driver to go in a particular sleep state. * Supported states are platform/device specific. * * \param[in] bfi The instance of this driver. * \retval SYS_ERR_OK Device initialized successfully. */ static errval_t set_sleep_level(struct bfdriver_instance* bfi, uint32_t level) { DRIVER_DEBUG("%s:%d: %s\n", __FUNCTION__, __LINE__, bfi->driver->name); return SYS_ERR_OK; } /** * Destroys this driver instance. The driver will yield any * control over the device and free any state allocated. * * \param[in] bfi The instance of this driver. * \retval SYS_ERR_OK Device initialized successfully. */ static errval_t destroy(struct bfdriver_instance* bfi) { DRIVER_DEBUG("%s:%d: %s\n", __FUNCTION__, __LINE__, bfi->driver->name); return SYS_ERR_OK; } /** * Registers the driver module with the system. * * To link this particular module in your driver domain, * add it to the addModules list in the Hakefile. */ DEFINE_MODULE(ioat, init, attach, detach, set_sleep_level, destroy);