The Peripheral Driver Module (PDM) is a driver module designed to provide a generic framework for peripheral access. It simplifies the process of accessing and managing peripherals by defining a unified set of interfaces and models, making it more standardized.
PDM mainly consists of the following components:
- PDM Core: The core entry point of the driver, responsible for registering the PDM bus, initializing the PDM master device, initializing sub-modules, and registering peripheral drivers.
- PDM Adapter: A generic peripheral adapter type that provides a unified peripheral access model.
- PDM Device: A generic peripheral abstraction model that offers a unified peripheral device model.
Ensure you have the following tools and libraries installed:
make
gcc
kernel headers
andkernel build system
-
Clone the Repository
git clone https://github.com/yourusername/pdm.git cd pdm
-
Local Compilation
-
Compile:
make
-
Clean:
make clean
This will compile the PDM module and generate the
pdm.ko
file. -
-
Cross-Compilation (for embedded systems)
-
Set up cross-compilation environment variables:
export ARCH=arm export CROSS_COMPILE=arm-linux-gnueabi- export KERNELDIR="/path/to/your/kernel/build/directory"
-
Execute the cross-compilation command:
make
-
-
Compilation Options
-
Logging Management The driver supports configuration of log printing options
-
Global Log Switch: To disable all log printing, use the following command during compilation:
make osa_log_enable=0
-
Enable File Name, Line Number, and Function Name Logging: To enable logging with file name, line number, and function name information, use the following command during compilation:
make osa_log_enable=1 osa_log_with_function=1 osa_log_with_file_line=1
-
-
-
Install the Module:
By default, the module will be installed in the
_install
directory under the current directory. You can specify another installation directory by setting theDESTDIR
environment variable.sudo make install DESTDIR="/path/to/install/directory"
If
DESTDIR
is not specified, it defaults to the_install
directory under the current directory. -
Load the Module:
sudo insmod pdm.ko
-
Verify Successful Module Loading:
lsmod | grep pdm
If the
pdm
module appears in the list, the module has been loaded successfully.
-
Unload the Module:
sudo rmmod pdm
-
Clean Up the Installation Directory:
sudo make uninstall DESTDIR="/path/to/install/directory"
If
DESTDIR
is not specified, it defaults to cleaning up the_install
directory under the current directory.
The PDM module supports debugging via `debugfs` and `procfs`. After loading the module, you can find related debug files in the `/sys/kernel/debug/pdm` and `/proc/pdm` directory.
To be completed.
The PDM module is licensed under the GPL license. For more information, see the LICENSE file.
Contributions and suggestions are welcome!
If you have any questions or suggestions, please contact:
- Author: wanguo
- Email: [email protected]
Thank you for using and supporting this project!
- GitHub: https://github.com/wanguo99/PDM