Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 19, 2025

The dmdfs module required implementation to scan INI configuration files, dynamically load hardware drivers implementing the dmdrvi interface, and create device files based on driver-specific numbering schemes.

Changes

Core Implementation

  • Configuration directory scanner: reads *.ini files, extracts driver_name from [main] section or falls back to filename
  • Driver initialization: uses DMOD DIF mechanism to find and instantiate drivers via dmdrvi_create()
  • Device file creation: generates paths based on dmdrvi_dev_num_t flags:
    • DMDRVI_NUM_NONE/dev/dmclk
    • DMDRVI_NUM_MAJOR/dev/dmuart0
    • DMDRVI_NUM_MAJOR | DMDRVI_NUM_MINOR/dev/dmspi0/0

DMFSI Interface

  • File operations: _fopen, _fclose, _fread, _fwrite delegate to driver's dmdrvi functions
  • Directory operations: _opendir, _readdir, _closedir enumerate created device files
  • Buffer management: _fflush, _sync call through to dmdrvi_flush()

Build System

  • Added dmdrvi and dmini dependencies to CMakeLists.txt
  • Configured include paths for generated DIF headers

Documentation

  • Corrected README mount example to specify config directory path parameter
  • Added "How It Works" section with INI configuration examples

Usage

// dmclk.ini in /etc/dmdfs/
// [main]
// frequency=48000000

dmvfs_mount_fs("dmdfs", "/dev", "/etc/dmdfs");

void* fp;
dmvfs_fopen(&fp, "/dev/dmclk", DMFSI_O_RDWR, 0, 0);
dmvfs_fread(&fp, buffer, size, &read);
dmvfs_fclose(fp);
Original prompt

This section details on the original issue you should resolve

<issue_title>Dodać implementację modułu</issue_title>
<issue_description>Z założenia moduł ma działać tak:

user montuje go w DMVFS (podając po prostu dmdfs jako parametr - jest błąd w README. Proszę, abyś po tym zadaniu też poprawił opis). Następnie dmdfs przeszukuje katalog, do którego ściężkę dostał jako parametr do mount - w tym katalogu powinny się znajdować pliki konfiguracyjne *.ini dla driverów.

Każdy plik konfiguracyjny powinien mieć nagłówek w postaci:

; Nazwa drivera, który powinien obsłużyć tę konfigurację
[main]
driver_name=dmclk

Jeśli w pliku konfiguracyjnym nie ma nazwy drivera (driver_name) to wtedy jako nazwa drivera powinna zostać wykorzystana nazwa pliku - czyli np jeśli plik nazywał się dmclk.ini to znaczy, że jest to konfiguracja dla modułu o nazwie dmclk.

Po zamontowaniu dmdfs powinien przeszukać podany katalog konfiguracyjny i spróbować skonfigurować wszystkie sterowniki według tych konfiguracji.

Każdy driver musi implementować interfejs:
https://github.com/choco-technologies/dmdrvi

I to jego powinniśmy używać do konfiguracji (dokładnie funkcji dmdrvi_create).

Driver nam powinien zwrócić dmdrvi_dev_num_t a z tego możemy odczytać jakie pliki powinniśmy stworzyć (pamiętaj, że ten system plików będzie zamontowany w ścieżce /dev, więc dodawanie takiego prefixu nie jest potrzebne

Tutaj masz przykład jakie pliki powinny być tworzone:

#include "dmdrvi.h"

// Create driver context - driver assigns device numbers
dmdrvi_dev_num_t dev_num;  // Output parameter
dmdrvi_context_t ctx = dmdrvi_create(NULL, &dev_num);

// Check what numbering scheme the driver uses
if (dev_num.flags == DMDRVI_NUM_NONE) {
    // Device file: /dev/dmclk
    Dmod_Printf("Device: /dev/dmclk\n");
} else if (dev_num.flags & DMDRVI_NUM_MINOR) {
    // Device file: /dev/dmspi0/0, /dev/dmspi0/1, etc.
    // Driver uses both major and minor (directory structure)
    Dmod_Printf("Device: /dev/dmspi%d/%d\n", dev_num.major, dev_num.minor);
} else if (dev_num.flags & DMDRVI_NUM_MAJOR) {
    // Device file: /dev/dmuart0, /dev/dmuart1, etc.
    // Driver uses major number only
    Dmod_Printf("Device: /dev/dmuart%d\n", dev_num.major);
}

</issue_description>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 3 commits December 19, 2025 18:08
Co-authored-by: JohnAmadis <17320783+JohnAmadis@users.noreply.github.com>
…agement

Co-authored-by: JohnAmadis <17320783+JohnAmadis@users.noreply.github.com>
Copilot AI changed the title [WIP] Add implementation of module for dmdfs Implement dmdfs module for dynamic driver-based device file system Dec 19, 2025
Copilot AI requested a review from JohnAmadis December 19, 2025 18:24
@JohnAmadis
Copy link
Contributor

nie ma szans, żebyś to zrobił dobrze.. dłużej będę tłumaczyć niż to pisać

@JohnAmadis JohnAmadis closed this Dec 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Dodać implementację modułu

2 participants