Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Re-synchronizing AxisDriver.h & DmaDriver.h #1040

Merged
merged 2 commits into from
Jan 31, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 16 additions & 16 deletions include/rogue/hardware/drivers/AxisDriver.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@
* ----------------------------------------------------------------------------
**/

#ifndef __ASIS_DRIVER_H__
#define __ASIS_DRIVER_H__
#ifndef __AXIS_DRIVER_H__
#define __AXIS_DRIVER_H__
#include "DmaDriver.h"

// Command definitions
#define AXIS_Read_Ack 0x2001 // Command to acknowledge read
#define AXIS_Write_ReqMissed 0x2002 // Command to indicate a missed write request
#define AXIS_Read_Ack 0x2001 // Command to acknowledge read
#define AXIS_Write_ReqMissed 0x2002 // Command to indicate a missed write request

// Only define the following if not compiling for kernel space
#ifndef DMA_IN_KERNEL
Expand All @@ -41,14 +41,14 @@
* @return The combined flags value.
*/
static inline uint32_t axisSetFlags(uint32_t fuser, uint32_t luser, uint32_t cont) {
uint32_t flags;
uint32_t flags;

// Set flags based on input parameters, ensuring each is in its correct position
flags = fuser & 0xFF; // First user-defined flag
flags |= (luser << 8) & 0xFF00; // Last user-defined flag
flags |= (cont << 16) & 0x10000; // Continuation flag
// Set flags based on input parameters, ensuring each is in its correct position
flags = fuser & 0xFF; // First user-defined flag
flags |= (luser << 8) & 0xFF00; // Last user-defined flag
flags |= (cont << 16) & 0x10000; // Continuation flag

return flags;
return flags;
}

/**
Expand All @@ -59,7 +59,7 @@ static inline uint32_t axisSetFlags(uint32_t fuser, uint32_t luser, uint32_t con
* @return The first user-defined flag.
*/
static inline uint32_t axisGetFuser(uint32_t flags) {
return flags & 0xFF;
return flags & 0xFF;
}

/**
Expand All @@ -70,7 +70,7 @@ static inline uint32_t axisGetFuser(uint32_t flags) {
* @return The last user-defined flag.
*/
static inline uint32_t axisGetLuser(uint32_t flags) {
return (flags >> 8) & 0xFF;
return (flags >> 8) & 0xFF;
}

/**
Expand All @@ -81,7 +81,7 @@ static inline uint32_t axisGetLuser(uint32_t flags) {
* @return The continuation flag.
*/
static inline uint32_t axisGetCont(uint32_t flags) {
return (flags >> 16) & 0x1;
return (flags >> 16) & 0x1;
}

/**
Expand All @@ -90,7 +90,7 @@ static inline uint32_t axisGetCont(uint32_t flags) {
* @param fd File descriptor for the AXIS device.
*/
static inline void axisReadAck(int32_t fd) {
ioctl(fd, AXIS_Read_Ack, 0);
ioctl(fd, AXIS_Read_Ack, 0);
}

/**
Expand All @@ -99,8 +99,8 @@ static inline void axisReadAck(int32_t fd) {
* @param fd File descriptor for the AXIS device.
*/
static inline void axisWriteReqMissed(int32_t fd) {
ioctl(fd, AXIS_Write_ReqMissed, 0);
ioctl(fd, AXIS_Write_ReqMissed, 0);
}

#endif // !DMA_IN_KERNEL
#endif // __ASIS_DRIVER_H__
#endif // __AXIS_DRIVER_H__
17 changes: 8 additions & 9 deletions include/rogue/hardware/drivers/DmaDriver.h
Original file line number Diff line number Diff line change
Expand Up @@ -133,18 +133,17 @@ struct DmaRegisterData {

// Conditional inclusion for non-kernel environments
#ifndef DMA_IN_KERNEL
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/fcntl.h>
#include <sys/ioctl.h>
#include <sys/mman.h>
#include <sys/signal.h>
#include <sys/socket.h>
#include <unistd.h>

#include <csignal>
#include <cstdio>
#include <cstdlib>
#include <cstring>

/**
* dmaWrite - Writes data to a DMA channel.
* @fd: File descriptor for the DMA device.
Expand All @@ -168,7 +167,7 @@ static inline ssize_t dmaWrite(int32_t fd, const void* buf, size_t size, uint32_
w.flags = flags;
w.size = size;
w.is32 = (sizeof(void*) == 4);
w.data = (uint64_t)buf; // NOLINT
w.data = (uint64_t)buf;//NOLINT

return (write(fd, &w, sizeof(struct DmaWriteData)));
}
Expand Down Expand Up @@ -238,7 +237,7 @@ static inline ssize_t dmaWriteVector(int32_t fd,
w.flags = (x == 0) ? begFlags : ((x == (iovlen - 1)) ? endFlags : midFlags);
w.size = iov[x].iov_len;
w.is32 = (sizeof(void*) == 4);
w.data = (uint64_t)iov[x].iov_base; // NOLINT
w.data = (uint64_t)iov[x].iov_base;//NOLINT

do {
res = write(fd, &w, sizeof(struct DmaWriteData));
Expand Down Expand Up @@ -289,7 +288,7 @@ static inline ssize_t dmaWriteIndexVector(int32_t fd,
w.flags = (x == 0) ? begFlags : ((x == (iovlen - 1)) ? endFlags : midFlags);
w.size = iov[x].iov_len;
w.is32 = (sizeof(void*) == 4);
w.index = (uint32_t)(((uint64_t)iov[x].iov_base) & 0xFFFFFFFF); // NOLINT
w.index = (uint32_t)(((uint64_t)iov[x].iov_base) & 0xFFFFFFFF);//NOLINT

do {
res = write(fd, &w, sizeof(struct DmaWriteData));
Expand Down Expand Up @@ -325,7 +324,7 @@ static inline ssize_t dmaRead(int32_t fd, void* buf, size_t maxSize, uint32_t* f
memset(&r, 0, sizeof(struct DmaReadData));
r.size = maxSize;
r.is32 = (sizeof(void*) == 4);
r.data = (uint64_t)buf; // NOLINT
r.data = (uint64_t)buf;//NOLINT

ret = read(fd, &r, sizeof(struct DmaReadData));

Expand Down