Skip to content
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
5 changes: 5 additions & 0 deletions docs/api-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ usable either directly or transparently through `dmdevfs`/`/dev`.

## IOCTL commands (`dmfmc_ioctl_cmd_t`)

Commands are numbered from `DMDRVI_IOCTL_CUSTOM_BASE` so they do not
collide with the standard `DMDRVI_IOCTL_*` commands. Any command outside this
range (e.g. the `DMDRVI_IOCTL_BLOCK_GET_INFO` / `DMDRVI_IOCTL_MONITOR_GET_POLICY`
probes sent by dmdevfs) is answered with `-ENOTTY`.

| Command | `arg` type | Meaning |
|---------|-----------|---------|
| `dmfmc_ioctl_cmd_get_memory_start` | `void **` | Direct pointer to the mapped memory. |
Expand Down
6 changes: 5 additions & 1 deletion include/dmfmc_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#define DMFMC_TYPES_H

#include <stdint.h>
#include "dmdrvi_ioctl.h"
#include <stdbool.h>
#include <stddef.h>

Expand Down Expand Up @@ -185,7 +186,10 @@ typedef enum
*/
typedef enum
{
dmfmc_ioctl_cmd_get_memory_start = 1, /**< arg = void** - direct pointer to the mapped memory */
/* Private commands start at DMDRVI_IOCTL_CUSTOM_BASE (dmdrvi_ioctl.h)
* so they never collide with the standard DMDRVI_IOCTL_* commands (network,
* block, monitor) that dmdevfs and other generic clients send to any node. */
dmfmc_ioctl_cmd_get_memory_start = DMDRVI_IOCTL_CUSTOM_BASE, /**< arg = void** - direct pointer to the mapped memory */
dmfmc_ioctl_cmd_get_memory_size, /**< arg = uint32_t* - size in bytes of the mapped memory */
dmfmc_ioctl_cmd_get_configured_frequency, /**< arg = uint32_t* - SDCLK frequency actually configured (Hz) */
dmfmc_ioctl_cmd_get_heap_context, /**< arg = dmheap_context_t** - heap context, or NULL if not used as heap */
Expand Down
10 changes: 6 additions & 4 deletions src/dmfmc.c
Original file line number Diff line number Diff line change
Expand Up @@ -503,10 +503,12 @@ dmod_dmdrvi_dif_api_declaration(2.0, dmfmc, int, _ioctl, ( dmdrvi_context_t cont
return -EINVAL;
}

if (command >= dmfmc_ioctl_cmd_max)
/* Not an error: generic clients (e.g. dmdevfs probing every node for the
* block/monitor classes) send standard DMDRVI_IOCTL_* commands the FMC
* does not implement - answer -ENOTTY quietly, as dmdrvi expects. */
if (command < dmfmc_ioctl_cmd_get_memory_start || command >= dmfmc_ioctl_cmd_max)
{
DMOD_LOG_ERROR("Invalid ioctl command %d\n", command);
return -EINVAL;
return -ENOTTY;
}

switch (command)
Expand Down Expand Up @@ -555,7 +557,7 @@ dmod_dmdrvi_dif_api_declaration(2.0, dmfmc, int, _ioctl, ( dmdrvi_context_t cont
return configure(context);

default:
return -EINVAL;
return -ENOTTY;
}
}

Expand Down
2 changes: 2 additions & 0 deletions src/port/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,10 @@ dmod_add_library(${DMOD_MODULE_NAME} ${DMOD_MODULE_VERSION}
${COMMON_SOURCES}
)

# dmdrvi: dmfmc_types.h pulls in dmdrvi_ioctl.h (DMDRVI_IOCTL_CUSTOM_BASE)
dmod_link_modules(${DMOD_MODULE_NAME}
dmclk_port
dmdrvi
)

target_include_directories(${DMOD_MODULE_NAME} BEFORE PRIVATE
Expand Down
Loading