Commit 87ca0152 authored by Jens Korinth's avatar Jens Korinth
Browse files

WIP: Activate Zynq ioctls, create devices automatically

parent 31ff5b5c
......@@ -158,6 +158,7 @@ void platform_deinit(platform_ctx_t *ctx)
deinit_platform(ctx);
free(ctx);
LOG(LPLL_INIT, "so long & thanks for all the fish, bye");
platform_logging_deinit();
}
platform_res_t platform_enum_devices(platform_ctx_t *ctx,
......
......@@ -50,7 +50,7 @@ platform_res_t default_read_ctl(platform_devctx_t const *devctx,
length, (u64)addr, (u64)flags);
struct tlkm_copy_cmd cmd = {
.length = length,
.user_addr = (void *)data,
.user_addr = data,
.dev_addr = addr,
};
if ((ret = ioctl(devctx->fd_ctrl, TLKM_DEV_IOCTL_READ, &cmd))) {
......
//
// Copyright (C) 2018 Jens Korinth, TU Darmstadt
//
// This file is part of Tapasco (TAPASCO).
//
// Tapasco is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Tapasco is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with Tapasco. If not, see <http://www.gnu.org/licenses/>.
//
/**
* @file platform_init.c
* @brief Basic init routines for libplatform.
* @author J. Korinth, TU Darmstadt (jk@esa.cs.tu-darmstadt.de)
**/
platform_res_t *_platform_init(const char *const version, platform_devctx_t **ctx)
{
platform_logging_init();
LOG(LPLL_INIT, "version: %s, expected version: %s", platform_version(),
version);
if (platform_check_version(version) != PLATFORM_SUCCESS) {
ERR("version mismatch: found %s, expected: %s",
platform_version(), version);
return PERR_VERSION_MISMATCH;
}
platform_res_t const r = platform_context_init(ctx);
if (r != PLATFORM_SUCCESS) {
ERR("could not initialize platform device context: %s (%d)",
platform_strerror(r), r);
return r;
}
return PLATFORM_SUCCESS;
}
void platform_deinit(platform_context_t *ctx)
{
platform_context_deinit(ctx);
}
......@@ -147,5 +147,5 @@ void platform_logging_deinit(void)
}
#else // NDEBUG
int platform_logging_init(void) { return 1; }
void platform_logging_exit(void) {}
void platform_logging_deinit(void) {}
#endif // NDEBUG
......@@ -55,6 +55,7 @@ int tlkm_bus_init(void)
device);
LOG(TLKM_LF_BUS, "TaPaSCo device '%s' (%04x:%04x)", d->name,
d->vendor_id, d->product_id);
tlkm_device_create(d, TLKM_ACCESS_MONITOR);
}
if ((ret = tlkm_init())) {
ERR("failed to initialize ioctl file: %d", ret);
......
......@@ -168,8 +168,11 @@ long zynq_ioctl_read(struct tlkm_device_inst *inst, struct tlkm_dev_cmd *cmd)
ptr = dev->gp_map[0] + (cmd->dev_addr - ZYNQ_PLATFORM_GP0_BASE);
} else if (cmd->dev_addr & ZYNQ_PLATFORM_STATUS_BASE) {
ptr = dev->tapasco_status + (cmd->dev_addr - ZYNQ_PLATFORM_STATUS_BASE);
} else {
DEVERR(inst->dev_id, "invalid address: 0x%08llx", cmd->dev_addr);
return -ENXIO;
}
if (ptr && (ret = copy_to_user((void __user *)cmd->user_addr, ptr, cmd->length))) {
if ((ret = copy_to_user((void __user *)cmd->user_addr, ptr, cmd->length))) {
DEVERR(inst->dev_id, "could not copy all bytes to user space: %ld", ret);
ret = -EAGAIN;
}
......@@ -190,6 +193,9 @@ long zynq_ioctl_write(struct tlkm_device_inst *inst, struct tlkm_dev_cmd *cmd)
ptr = dev->gp_map[0] + (cmd->dev_addr - ZYNQ_PLATFORM_GP0_BASE);
} else if (cmd->dev_addr & ZYNQ_PLATFORM_STATUS_BASE) {
ptr = dev->tapasco_status + (cmd->dev_addr - ZYNQ_PLATFORM_STATUS_BASE);
} else {
DEVERR(inst->dev_id, "invalid address: 0x%08llx", cmd->dev_addr);
return -ENXIO;
}
if (ptr && copy_from_user(ptr, (void __user *)cmd->user_addr, cmd->length)) {
DEVERR(inst->dev_id, "could not copy all bytes from user space");
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment