ppt-1_ device drivers & dp brds
TRANSCRIPT
![Page 1: PPT-1_ DEVICE DRIVERS & DP BRDS](https://reader033.vdocument.in/reader033/viewer/2022061118/5469c41faf79598c5f8b4b13/html5/thumbnails/1.jpg)
INTRODUCTION TO DEVICE DRIVERS
![Page 2: PPT-1_ DEVICE DRIVERS & DP BRDS](https://reader033.vdocument.in/reader033/viewer/2022061118/5469c41faf79598c5f8b4b13/html5/thumbnails/2.jpg)
INDEX
• Device drivers basics• Types of drivers• Driver Implementation Concepts• Introduction to DP Boards & Drivers• Details of DP-MM-1105• Details of DP-cPCI-3096• Details of DP-IP-4221• Details of DP-cPCI-4509
![Page 3: PPT-1_ DEVICE DRIVERS & DP BRDS](https://reader033.vdocument.in/reader033/viewer/2022061118/5469c41faf79598c5f8b4b13/html5/thumbnails/3.jpg)
Device driver basics
![Page 4: PPT-1_ DEVICE DRIVERS & DP BRDS](https://reader033.vdocument.in/reader033/viewer/2022061118/5469c41faf79598c5f8b4b13/html5/thumbnails/4.jpg)
Basics of device driver
• What is a device driver ?
• Why we need device driver ?
• Where device drivers are located ?
• What are the types of device drivers ?
![Page 5: PPT-1_ DEVICE DRIVERS & DP BRDS](https://reader033.vdocument.in/reader033/viewer/2022061118/5469c41faf79598c5f8b4b13/html5/thumbnails/5.jpg)
Basics of device driver
• Specialized device specific software that controls the device and exports usable interface for other programs to interact with the device.
• OS cannot be expected to know about the details of each device so, to control the device, device specific software (device driver) is necessary.
• Device drivers are modules that can be plugged into the Linux kernel dynamically.
![Page 6: PPT-1_ DEVICE DRIVERS & DP BRDS](https://reader033.vdocument.in/reader033/viewer/2022061118/5469c41faf79598c5f8b4b13/html5/thumbnails/6.jpg)
Device driver in kernel
![Page 7: PPT-1_ DEVICE DRIVERS & DP BRDS](https://reader033.vdocument.in/reader033/viewer/2022061118/5469c41faf79598c5f8b4b13/html5/thumbnails/7.jpg)
Types of device drivers
![Page 8: PPT-1_ DEVICE DRIVERS & DP BRDS](https://reader033.vdocument.in/reader033/viewer/2022061118/5469c41faf79598c5f8b4b13/html5/thumbnails/8.jpg)
Types of device drivers
• Character drivers
• Block drivers
• Network drivers
![Page 9: PPT-1_ DEVICE DRIVERS & DP BRDS](https://reader033.vdocument.in/reader033/viewer/2022061118/5469c41faf79598c5f8b4b13/html5/thumbnails/9.jpg)
CHARACTER DRIVERS
![Page 10: PPT-1_ DEVICE DRIVERS & DP BRDS](https://reader033.vdocument.in/reader033/viewer/2022061118/5469c41faf79598c5f8b4b13/html5/thumbnails/10.jpg)
Character driver concepts
• Char devices are accessed using files called device files (or) node files (or) special files.
• Char device files are located at the location /dev/
• Identified by c in first column of output of “ls -l” command.
• Major & Minor Number : – The major number identifies the driver associated
with the device.– The minor number is used by the kernel to
determine exactly which device is being referred to.
![Page 11: PPT-1_ DEVICE DRIVERS & DP BRDS](https://reader033.vdocument.in/reader033/viewer/2022061118/5469c41faf79598c5f8b4b13/html5/thumbnails/11.jpg)
Character driver concepts
Internal representation of device number
• The dev_t type (defined in <linux/types.h>) is used to hold device numbers—both the major and minor parts.
• To obtain the major or minor parts of a dev_t, use:– MAJOR(dev_t dev);– MINOR(dev_t dev);
![Page 12: PPT-1_ DEVICE DRIVERS & DP BRDS](https://reader033.vdocument.in/reader033/viewer/2022061118/5469c41faf79598c5f8b4b13/html5/thumbnails/12.jpg)
Character driver concepts
Data Structures:
1. struct file_operations
• Connects driver operations to device numbers• Defined in <linux/fs.h>• It’s a collection of function pointers• Each member points to the specific function in the driver• Fields of the file_operations structure
– ssize_t (*read) (struct file *, char __user *, size_t, loff_t *);
– ssize_t (*write) (struct file *, const char __user *, size_t, loff_t *);
![Page 13: PPT-1_ DEVICE DRIVERS & DP BRDS](https://reader033.vdocument.in/reader033/viewer/2022061118/5469c41faf79598c5f8b4b13/html5/thumbnails/13.jpg)
Character driver concepts
– int (*ioctl) (struct inode *, struct file *, unsigned int, unsigned long);
– int (*open) (struct inode *, struct file *);– int (*release) (struct inode *, struct file *);
struct file_operations dpxxxx_fops =
{
.read = dpxxxx_read,
.write = dpxxxx_write,
.ioctl = dpxxxx_ioctl,
.open = dpxxxx_open,
.release = dpxxxx_release
};
![Page 14: PPT-1_ DEVICE DRIVERS & DP BRDS](https://reader033.vdocument.in/reader033/viewer/2022061118/5469c41faf79598c5f8b4b13/html5/thumbnails/14.jpg)
Character driver concepts
2. struct file
• Defined in <linux/fs.h>.• Different from file pointer of user space program.• Every open file in the system has an associated struct file in
kernel space.• Driver doesn’t create but only use this structure.• Field of struct file
– mode_t f_mode;– loff_t f_pos;– unsigned int f_flags;– struct file_operations *f_op;– void *private_data;– struct dentry *f_dentry;
![Page 15: PPT-1_ DEVICE DRIVERS & DP BRDS](https://reader033.vdocument.in/reader033/viewer/2022061118/5469c41faf79598c5f8b4b13/html5/thumbnails/15.jpg)
Character driver concepts
3. struct inode
• The inode structure is used by the kernel internally to represent files.
• There can be numerous file structures representing multiple open descriptors on a single file, but they all point to a single inode structure.
• Following two fields of this structure are of interest for writing driver code:– dev_t i_rdev– struct cdev *i_cdev
![Page 16: PPT-1_ DEVICE DRIVERS & DP BRDS](https://reader033.vdocument.in/reader033/viewer/2022061118/5469c41faf79598c5f8b4b13/html5/thumbnails/16.jpg)
Character driver concepts
Char Device Registration & Release:
• Function to register a char device driver:– int register_chrdev(unsigned int major, const char *name,
struct file_operations *fops);
• Function to release a char device driver:– int unregister_chrdev(unsigned int major, const char *name);
![Page 17: PPT-1_ DEVICE DRIVERS & DP BRDS](https://reader033.vdocument.in/reader033/viewer/2022061118/5469c41faf79598c5f8b4b13/html5/thumbnails/17.jpg)
BLOCK DRIVERS
![Page 18: PPT-1_ DEVICE DRIVERS & DP BRDS](https://reader033.vdocument.in/reader033/viewer/2022061118/5469c41faf79598c5f8b4b13/html5/thumbnails/18.jpg)
Block driver concepts
• Provides access to devices that transfer randomly accessible data in fixed-size blocks—disk drives.
• Block : A block is a fixed-size chunk of data, the size being determined by the kernel.(normal size –4096 bytes).
• Sector : A sector is a small block whose size is usually determined by the underlying hardware. The kernel expects to be dealing with devices that implement 512-byte sectors.
![Page 19: PPT-1_ DEVICE DRIVERS & DP BRDS](https://reader033.vdocument.in/reader033/viewer/2022061118/5469c41faf79598c5f8b4b13/html5/thumbnails/19.jpg)
Block driver concepts
Block Driver Registration:
• int register_blkdev(unsigned int major, const char *name);– To register block driver in the kernel.– Declared in <linux/fs.h>
• int unregister_blkdev(unsigned int major, const char *name);– For canceling a block driver registration.
![Page 20: PPT-1_ DEVICE DRIVERS & DP BRDS](https://reader033.vdocument.in/reader033/viewer/2022061118/5469c41faf79598c5f8b4b13/html5/thumbnails/20.jpg)
Block driver concepts
Data Structures:
1. struct block_device_operations
• Used to make driver operations available to the system
• Declared in <linux/fs.h>• Structure fields
• int (*open)(struct inode *inode, struct file *filp);• int (*release)(struct inode *inode, struct file *filp);• int (*ioctl)(struct inode *inode, struct file *filp, unsigned int
cmd,unsigned long arg);• int (*media_changed) (struct gendisk *gd);• int (*revalidate_disk) (struct gendisk *gd);• struct module *owner;
![Page 21: PPT-1_ DEVICE DRIVERS & DP BRDS](https://reader033.vdocument.in/reader033/viewer/2022061118/5469c41faf79598c5f8b4b13/html5/thumbnails/21.jpg)
Block driver concepts
2. struct gendisk
• Kernel’s representation of an individual disk device.
• Declared in <linux/genhd.h>• Structure fields
– int major;– int first_minor;– int minors;– char disk_name[32];– struct block_device_operations *fops;– struct request_queue *queue;
![Page 22: PPT-1_ DEVICE DRIVERS & DP BRDS](https://reader033.vdocument.in/reader033/viewer/2022061118/5469c41faf79598c5f8b4b13/html5/thumbnails/22.jpg)
Block driver concepts
– int flags;– sector_t capacity;– void *private_data;
• Kernel Functions to work with gendisk structure– struct gendisk *alloc_disk(int minors);– void del_gendisk(struct gendisk *gd);– void add_disk(struct gendisk *gd);
![Page 23: PPT-1_ DEVICE DRIVERS & DP BRDS](https://reader033.vdocument.in/reader033/viewer/2022061118/5469c41faf79598c5f8b4b13/html5/thumbnails/23.jpg)
Block driver concepts
Request Function :
• Core function of every block driver.• Prototype:
– void request(request_queue_t *queue);
• Associated with request queue.• Runs atomically.• Asynchronous to user space process.
![Page 24: PPT-1_ DEVICE DRIVERS & DP BRDS](https://reader033.vdocument.in/reader033/viewer/2022061118/5469c41faf79598c5f8b4b13/html5/thumbnails/24.jpg)
Block driver concepts
Request Queue :
• A queue of block I/O requests• Keep track of outstanding block I/O requests.• Stores parameters that describes kinds of requests
the device is able to service:– Maximum size.– Maximum no. of segments may go into a request.– Hardware sector size.– Alignment requirements.
• Implements a plug-in interface to allow the use of multiple I/O schedulers (or elevators).
![Page 25: PPT-1_ DEVICE DRIVERS & DP BRDS](https://reader033.vdocument.in/reader033/viewer/2022061118/5469c41faf79598c5f8b4b13/html5/thumbnails/25.jpg)
NETWORK DRIVERS
![Page 26: PPT-1_ DEVICE DRIVERS & DP BRDS](https://reader033.vdocument.in/reader033/viewer/2022061118/5469c41faf79598c5f8b4b13/html5/thumbnails/26.jpg)
Network driver concepts
Features
• Necessary for data communication.
• No special files.
• Block drivers operate only in response to requests from the kernel, whereas network drivers receive packets asynchronously from the outside.
• Should support administrative tasks.– Set addresses.– Modify transmission parameters.– Maintain traffic and error statistics.
![Page 27: PPT-1_ DEVICE DRIVERS & DP BRDS](https://reader033.vdocument.in/reader033/viewer/2022061118/5469c41faf79598c5f8b4b13/html5/thumbnails/27.jpg)
Driver Implementation Concepts
![Page 28: PPT-1_ DEVICE DRIVERS & DP BRDS](https://reader033.vdocument.in/reader033/viewer/2022061118/5469c41faf79598c5f8b4b13/html5/thumbnails/28.jpg)
Two ways of implementing drivers
• Traditional ”built-in” drivers– compiled into the kernel– loaded when the kernel boots– always loaded, can not be removed– programming interface somewhat limited
• Loadable kernel module drivers– can be loaded and unloaded on demand– a more general programming interface– Can be designed, written and installed long after kernel has
been compiled and OS installed
![Page 29: PPT-1_ DEVICE DRIVERS & DP BRDS](https://reader033.vdocument.in/reader033/viewer/2022061118/5469c41faf79598c5f8b4b13/html5/thumbnails/29.jpg)
Kernel space - User space interaction methods
• Real Time FIFO• Device File• IOCTL Layer
– copy_from_user– copy_to_user
![Page 30: PPT-1_ DEVICE DRIVERS & DP BRDS](https://reader033.vdocument.in/reader033/viewer/2022061118/5469c41faf79598c5f8b4b13/html5/thumbnails/30.jpg)
Control Flow diagram
applicationapplication
IOCTL LayerIOCTL Layer
User Space
Kernel Space
KernelKernelDriver ModuleDriver Module
Hardware DeviceHardware Device
FIFO FIFO
![Page 31: PPT-1_ DEVICE DRIVERS & DP BRDS](https://reader033.vdocument.in/reader033/viewer/2022061118/5469c41faf79598c5f8b4b13/html5/thumbnails/31.jpg)
Introduction to DP Boards & Drivers
![Page 32: PPT-1_ DEVICE DRIVERS & DP BRDS](https://reader033.vdocument.in/reader033/viewer/2022061118/5469c41faf79598c5f8b4b13/html5/thumbnails/32.jpg)
DP Boards
DP Boards are categorized as follows:
1. Data Acquisition Boards (DP-MM-1105)2. Input/Output Boards (DP-cPCI-3096) 3. Communication Boards (DP-IP-4221)4. Relay Boards (DP-cPCI-4509)
![Page 33: PPT-1_ DEVICE DRIVERS & DP BRDS](https://reader033.vdocument.in/reader033/viewer/2022061118/5469c41faf79598c5f8b4b13/html5/thumbnails/33.jpg)
DP Drivers
• DP Drivers are Character drivers• General driver API Calls
– DPxxxx_FindNoOfBoards– DPxxxx_Open (DPxxxx_RTOpen) – DPxxxx_Close (DPxxxx_RTClose)– DPxxxx_GetErrorMessage– DPxxxx_GetDriverVersion
![Page 34: PPT-1_ DEVICE DRIVERS & DP BRDS](https://reader033.vdocument.in/reader033/viewer/2022061118/5469c41faf79598c5f8b4b13/html5/thumbnails/34.jpg)
DP-MM-1105
![Page 35: PPT-1_ DEVICE DRIVERS & DP BRDS](https://reader033.vdocument.in/reader033/viewer/2022061118/5469c41faf79598c5f8b4b13/html5/thumbnails/35.jpg)
DP-MM-1105 Features
Fast analog input M-Module
16 bit, Analog to Digital Conversion
8 differential voltage inputs or 16 single ended voltage inputs
Programmable gain 1, 10,100 or 1000
512 Entry Scan RAM for Scan Sequencing
1 K Sample FIFO for converted data
Numerically controlled Oscillator for flexible scan frequency
Digitally isolated channel to system for high linearity
![Page 36: PPT-1_ DEVICE DRIVERS & DP BRDS](https://reader033.vdocument.in/reader033/viewer/2022061118/5469c41faf79598c5f8b4b13/html5/thumbnails/36.jpg)
DP-MM-1105 API Calls
• DP1105_DetectMModules()• DP1105_Open() (or) DP1105_RTOpen()• DP1105_Close() (or) DP1105_RTClose() • DP1105_ConfigureADC()• DP1105_UpdateScanList()• DP1105_StartAcquisition()• DP1105_Trigger()• DP1105_StopAcquisition()• DP1105_GetRecentSample()• DP1105_BulkRead()
![Page 37: PPT-1_ DEVICE DRIVERS & DP BRDS](https://reader033.vdocument.in/reader033/viewer/2022061118/5469c41faf79598c5f8b4b13/html5/thumbnails/37.jpg)
DP-MM-1105 API Calls
• DP1105_ReadBuffer ()• DP1105_CheckStatus()• DP1105_ReadCalibrationTable()• DP1105_WriteCalibrationTable()• DP1105_Calibrate ()• DP1105_GetErrorMessage()• DP1105_CalibrateSingleEnded()• DP1105_EnableInterrupt()• DP1105_GetDrvVer()• DP1105_GetFifo()
![Page 38: PPT-1_ DEVICE DRIVERS & DP BRDS](https://reader033.vdocument.in/reader033/viewer/2022061118/5469c41faf79598c5f8b4b13/html5/thumbnails/38.jpg)
DP-MM-1105 Configuration
DP1105_CONFIGURATION Structure. Input type – (1 – Single ended, 0 – Differential).
Pacer Source – (0 – Internal, 1 – External, 2 – Software Pacer).
Pace Frequency – If Internal Pacer source is selected (in Hz).
Trigger type – (0 – Internal Trigger (through software), 1 – External Trigger).
Continuous Trigger type – (No Continuous Trigger – 0, Timer Trigger Enable –1, Continuous Internal Trigger Enable – 2).
External Trigger Signal type (0 – Positive Edge sensitive, 1 – Negative Edge sensitive).
Time Period – Time period between two successive triggers if Timer Trigger is enabled (In multiples of 100 microseconds).
Buffer size – The internal buffer size (in number of samples).
Source Type – The Parameter specifies the Voltage and Current type. Possible values are 1 and 2.
![Page 39: PPT-1_ DEVICE DRIVERS & DP BRDS](https://reader033.vdocument.in/reader033/viewer/2022061118/5469c41faf79598c5f8b4b13/html5/thumbnails/39.jpg)
Input / Output Modules General Features
• Self Test Facility
• Interrupt types
– Input Interrupt
– State Change Interrupt
– Board Strobe Interrupt
– Group Strobe Interrupt
• Ability to Read Back
– Actual Data
– Interrupt Interrupt data
– State Change Input data
– Strobed Input data
• Primary Latch & Secondary Latch for Output Channels• Programmable Debounce Time Feature• Some of the DP I/O Modules are (3096 3069, 3015)
![Page 40: PPT-1_ DEVICE DRIVERS & DP BRDS](https://reader033.vdocument.in/reader033/viewer/2022061118/5469c41faf79598c5f8b4b13/html5/thumbnails/40.jpg)
DP-cPCI-3096
![Page 41: PPT-1_ DEVICE DRIVERS & DP BRDS](https://reader033.vdocument.in/reader033/viewer/2022061118/5469c41faf79598c5f8b4b13/html5/thumbnails/41.jpg)
DP-cPCI-3096 Features
• 48 Channel Isolated Digital Input / Interrupt • 48 Channel Isolated Digital Open Collector Output with
200mA Sink Current • Isolation in group of 16 channels • Jumper selectable input levels of 5, 12, 24 & 48V DC • Time programmable debounce for input • Programmable interrupt (Maskable, Edge selectable). • Build-in self test for each group.• Additional 48 Input and 48 Output channel through
rear I/O• Relay coil flyback protection for output channels• Hot swap compliant
![Page 42: PPT-1_ DEVICE DRIVERS & DP BRDS](https://reader033.vdocument.in/reader033/viewer/2022061118/5469c41faf79598c5f8b4b13/html5/thumbnails/42.jpg)
DP-cPCI-3096 API Calls
• DPcPCI3096_FindDevices• DPcPCI3096_Open (or) DPcPCI3096_RTOpen• DPcPCI3096_Close (or) DPcPCI3096_RTClose• DPcPCI3096_ConfigMode • DPcPCI3096_SetDebounceTime • DPcPCI3096_SelfTest • DPcPCI3096_GroupStatus • DPcPCI3096_MaskGroup • DPCPCI3096_MaskChannel • DPcPCI3096_GroupEdgeSelect• DPcPCI3096_ChannelEdgeSelect
![Page 43: PPT-1_ DEVICE DRIVERS & DP BRDS](https://reader033.vdocument.in/reader033/viewer/2022061118/5469c41faf79598c5f8b4b13/html5/thumbnails/43.jpg)
DP-cPCI-3096 API Calls
• DPcPCI3096_StrobeGroup • DPcPCI3096_BoardStrobe • DPcPCI3096_ClearInterrupt • DPcPCI3096_ClearAllInterrupts • DPcPCI3096_WriteGroupData • DPcPCI3096_EnableOutput • DPcPCI3096_ReadbackInput • DPcPCI3096_ReadInterruptStatus • DPcPCI3096_ReadbackOutput • DPcPCI3096_Reset • DPCPCI3096_GetErrorMsg
![Page 44: PPT-1_ DEVICE DRIVERS & DP BRDS](https://reader033.vdocument.in/reader033/viewer/2022061118/5469c41faf79598c5f8b4b13/html5/thumbnails/44.jpg)
DP-IP-4221
![Page 45: PPT-1_ DEVICE DRIVERS & DP BRDS](https://reader033.vdocument.in/reader033/viewer/2022061118/5469c41faf79598c5f8b4b13/html5/thumbnails/45.jpg)
DP-IP-4221 Features
• Provides eight asynchronous serial communication ports from a single IP carrier slot.
• Provides programmable Baud rates, character-sizes, stop bits, and parity.
• Each serial port is equipped with 128-byte FIFO buffers each on transmit and receive lines, minimizing CPU interaction for improved system performance.
![Page 46: PPT-1_ DEVICE DRIVERS & DP BRDS](https://reader033.vdocument.in/reader033/viewer/2022061118/5469c41faf79598c5f8b4b13/html5/thumbnails/46.jpg)
DP-IP-4221 API Calls
• DPIP4221_FindDevices• DPIP4221_Open • DPIP4221_Close • DPIP4221_SetBaudRate • DPIP4221_SetWordLength • DPIP4221_SetStopBit • DPIP4221_SetParity • DPIP4221_SetMode • DPIP4221_SetModemControl • DPIP4221_GetRxFIFOCount
![Page 47: PPT-1_ DEVICE DRIVERS & DP BRDS](https://reader033.vdocument.in/reader033/viewer/2022061118/5469c41faf79598c5f8b4b13/html5/thumbnails/47.jpg)
DP-IP-4221 API Calls
• DPIP4221_GetTxFIFOCount • DPIP4221_LoopBackMode • DPIP4221_TransmitData • DPIP4221_ReceiveData • DPIP4221_FlushFIFO
![Page 48: PPT-1_ DEVICE DRIVERS & DP BRDS](https://reader033.vdocument.in/reader033/viewer/2022061118/5469c41faf79598c5f8b4b13/html5/thumbnails/48.jpg)
DP-cPCI-4509
![Page 49: PPT-1_ DEVICE DRIVERS & DP BRDS](https://reader033.vdocument.in/reader033/viewer/2022061118/5469c41faf79598c5f8b4b13/html5/thumbnails/49.jpg)
DP-cPCI-4509 Features
• High voltage switching of up to 220V AC/ DC• Relays can be operated individually, or in groups of
16 relays each• Relay status provided through read back• Rugged connectors for field terminations• Hot swap feature
![Page 50: PPT-1_ DEVICE DRIVERS & DP BRDS](https://reader033.vdocument.in/reader033/viewer/2022061118/5469c41faf79598c5f8b4b13/html5/thumbnails/50.jpg)
DP-cPCI-4509 API Calls
• DPcPCI4509_FindDevices• DPCPCI4509_Open• DPCPCI4509_Close• DPcPCI4509_SetRelay• DPcPCI4509_SetGroup• DPcPCI4509_SetTrigger• DPcPCI4509_ReadSetValue• DPcPCI4509_ReadRelay• DPcPCI4509_ReadGroup• DPcPCI4509_GetErrorMsg
![Page 51: PPT-1_ DEVICE DRIVERS & DP BRDS](https://reader033.vdocument.in/reader033/viewer/2022061118/5469c41faf79598c5f8b4b13/html5/thumbnails/51.jpg)
Question(?) Time
![Page 52: PPT-1_ DEVICE DRIVERS & DP BRDS](https://reader033.vdocument.in/reader033/viewer/2022061118/5469c41faf79598c5f8b4b13/html5/thumbnails/52.jpg)
THANK YOU