Presentation is loading. Please wait.

Presentation is loading. Please wait.

TMS320C6000 DSP Integration Workshop Chapter 12 IOM and Frameworks Copyright © 2005 Texas Instruments. All rights reserved. Technical Training Organization.

Similar presentations


Presentation on theme: "TMS320C6000 DSP Integration Workshop Chapter 12 IOM and Frameworks Copyright © 2005 Texas Instruments. All rights reserved. Technical Training Organization."— Presentation transcript:

1 TMS320C6000 DSP Integration Workshop Chapter 12 IOM and Frameworks Copyright © 2005 Texas Instruments. All rights reserved. Technical Training Organization T TO

2 Objectives  System Block Diagram  Standard I/O (SIO) - Using Streams  Device Drivers (IOM)  Reference Frameworks (RF)  Lab 12/12a – Using SIO and Modifying an IOM Driver Technical Training Organization T TO

3 00101 alg DSP Grow Your Own...   app + sched + I/O + comm + algA n + algB n +...   app + sched + I/O + algA n + algB n +...   app + sched + algA n + algB n +...   app + algA + algB +... app + alg alg   too costly to develop   too costly to enhance   too costly to maintain application alg application alg scheduler application alg scheduler I/O application Technical Training Organization T TO

4 System System Software H/W (Peripherals) Algorithm Program = Code + Data Embedded System = Program + Mem. Management + Init + H/W + I/O …` XDAISXDAIS ?   Data   Init   Mem. Mgmt. System Software   XDAIS provides a common interface to Algorithms   But, what common interface exists for hardware?   Let’s break it into two pieces: interface + driver Technical Training Organization T TO Interface first…

5 BIOS I/O Interface Models DSP/BIOS provided communications interface I/O Mini-Driver (IOM) SIOPIPGIO DSP/BIOS Thread Types TSK or SWI SWI TSK or SWI Any mini-driver can be used with any DSP/BIOS I/O model Technical Training Organization T TO  All models pass pointers to buffers instead of copying data.  SIO and GIO provide blocking functions; PIP does not.  SIO is the most flexible and easiest to use with IOM drivers. Let’s look at our lab’s system architecture…

6 Lab12 – Example SIO/Driver Architecture User-Defined Device Driver DIO Class Driver TSK SIO Processing Thread DSP/BIOS SIO-Stream Interface McBSPEDMAcodec Technical Training Organization T TO I/O Mini Driver (IOM) Let’s take a closer look at SIO…

7 SIO Concepts Technical Training Organization T TO So, what does our code look like to create/use streams? IOM Driver TSK Application IN OUT “Streams” issue FULL buffer reclaim FULL buffer issue EMPTY buffer reclaim EMPTY buffer issue…reclaim… reclaim… issue…  Communications protocol: issue = give a buffer, reclaim = take a buffer  TSK and IOM use a common interface (SIO) and are independent  Reclaim blocks (pends) until buffer is ready (has been issued)  Pointers to the buffers are passed, not the buffers themselves (efficiency)  Multiple buffers can be issued – SIO maintains the queue

8 1. SIO – Creating the Streams /* inStream and outStream are SIO handles created in main */ SIO_Handle inStream, outStream; void createStreams() { SIO_Attrs attrs; SIO_Attrs attrs; attrs = SIO_ATTRS; attrs = SIO_ATTRS; attrs.align = BUFALIGN; attrs.align = BUFALIGN; attrs.model = SIO_ISSUERECLAIM; attrs.model = SIO_ISSUERECLAIM; attrs.segid = ISRAM; attrs.segid = ISRAM; /* open the I/O streams */ /* open the I/O streams */ inStream = SIO_create("/dioCodec", SIO_INPUT, BUFFSIZE*4, &attrs); inStream = SIO_create("/dioCodec", SIO_INPUT, BUFFSIZE*4, &attrs); outStream = SIO_create("/dioCodec", SIO_OUTPUT, BUFFSIZE*4, &attrs); outStream = SIO_create("/dioCodec", SIO_OUTPUT, BUFFSIZE*4, &attrs);} /* inStream and outStream are SIO handles created in main */ SIO_Handle inStream, outStream; void createStreams() { SIO_Attrs attrs; SIO_Attrs attrs; attrs = SIO_ATTRS; attrs = SIO_ATTRS; attrs.align = BUFALIGN; attrs.align = BUFALIGN; attrs.model = SIO_ISSUERECLAIM; attrs.model = SIO_ISSUERECLAIM; attrs.segid = ISRAM; attrs.segid = ISRAM; /* open the I/O streams */ /* open the I/O streams */ inStream = SIO_create("/dioCodec", SIO_INPUT, BUFFSIZE*4, &attrs); inStream = SIO_create("/dioCodec", SIO_INPUT, BUFFSIZE*4, &attrs); outStream = SIO_create("/dioCodec", SIO_OUTPUT, BUFFSIZE*4, &attrs); outStream = SIO_create("/dioCodec", SIO_OUTPUT, BUFFSIZE*4, &attrs);} SIO Handles Attributes of the streams Create the streams with specific parameters: hookup, type, size, attr.

9 2. SIO – Allocate Buffers and Prime Streams void primeStreams() { Ptr rcvPing, rcvPong, xmtPing, xmtPong; /* Allocate buffers for the SIO buffer exchanges */ /* Allocate buffers for the SIO buffer exchanges */ rcvPing = (Ptr)MEM_calloc(0, BUFFSIZE*4, BUFALIGN); rcvPing = (Ptr)MEM_calloc(0, BUFFSIZE*4, BUFALIGN); rcvPong = (Ptr)MEM_calloc(0, BUFFSIZE*4, BUFALIGN); rcvPong = (Ptr)MEM_calloc(0, BUFFSIZE*4, BUFALIGN); xmtPing = (Ptr)MEM_calloc(0, BUFFSIZE*4, BUFALIGN); xmtPing = (Ptr)MEM_calloc(0, BUFFSIZE*4, BUFALIGN); xmtPong = (Ptr)MEM_calloc(0, BUFFSIZE*4, BUFALIGN); xmtPong = (Ptr)MEM_calloc(0, BUFFSIZE*4, BUFALIGN); /* Issue the first & second empty buffers to the input stream */ /* Issue the first & second empty buffers to the input stream */ SIO_issue(inStream, rcvPing, BUFFSIZE*4, NULL); SIO_issue(inStream, rcvPing, BUFFSIZE*4, NULL); SIO_issue(inStream, rcvPong, BUFFSIZE*4, NULL); SIO_issue(inStream, rcvPong, BUFFSIZE*4, NULL); /* Issue the first & second empty buffers to the output stream */ /* Issue the first & second empty buffers to the output stream */ SIO_issue(outStream, xmtPing, BUFFSIZE*4, NULL); SIO_issue(outStream, xmtPing, BUFFSIZE*4, NULL); SIO_issue(outStream, xmtPong, BUFFSIZE*4, NULL); SIO_issue(outStream, xmtPong, BUFFSIZE*4, NULL);} void primeStreams() { Ptr rcvPing, rcvPong, xmtPing, xmtPong; /* Allocate buffers for the SIO buffer exchanges */ /* Allocate buffers for the SIO buffer exchanges */ rcvPing = (Ptr)MEM_calloc(0, BUFFSIZE*4, BUFALIGN); rcvPing = (Ptr)MEM_calloc(0, BUFFSIZE*4, BUFALIGN); rcvPong = (Ptr)MEM_calloc(0, BUFFSIZE*4, BUFALIGN); rcvPong = (Ptr)MEM_calloc(0, BUFFSIZE*4, BUFALIGN); xmtPing = (Ptr)MEM_calloc(0, BUFFSIZE*4, BUFALIGN); xmtPing = (Ptr)MEM_calloc(0, BUFFSIZE*4, BUFALIGN); xmtPong = (Ptr)MEM_calloc(0, BUFFSIZE*4, BUFALIGN); xmtPong = (Ptr)MEM_calloc(0, BUFFSIZE*4, BUFALIGN); /* Issue the first & second empty buffers to the input stream */ /* Issue the first & second empty buffers to the input stream */ SIO_issue(inStream, rcvPing, BUFFSIZE*4, NULL); SIO_issue(inStream, rcvPing, BUFFSIZE*4, NULL); SIO_issue(inStream, rcvPong, BUFFSIZE*4, NULL); SIO_issue(inStream, rcvPong, BUFFSIZE*4, NULL); /* Issue the first & second empty buffers to the output stream */ /* Issue the first & second empty buffers to the output stream */ SIO_issue(outStream, xmtPing, BUFFSIZE*4, NULL); SIO_issue(outStream, xmtPing, BUFFSIZE*4, NULL); SIO_issue(outStream, xmtPong, BUFFSIZE*4, NULL); SIO_issue(outStream, xmtPong, BUFFSIZE*4, NULL);} Allocate the buffers using MEM_calloc() Issue 1 st and 2 nd empty buffers to INPUT stream Issue 1 st and 2 nd empty buffers to OUTPUT stream Create pointers to the buffers

10 3. TSK Code Using SIO void processBuffer(void) { short *source; short *dest; createStreams();primeStreams(); while(1) { SIO_reclaim(inStream,(Ptr *)&source, NULL); SIO_reclaim(inStream,(Ptr *)&source, NULL); SIO_reclaim(outStream,(Ptr *)&dest, NULL); SIO_reclaim(outStream,(Ptr *)&dest, NULL); // *** PROCESS *** SIO_issue(outStream, dest, BUFFSIZE*4,NULL); SIO_issue(outStream, dest, BUFFSIZE*4,NULL); SIO_issue(inStream, source, BUFFSIZE*4,NULL); SIO_issue(inStream, source, BUFFSIZE*4,NULL); }} void processBuffer(void) { short *source; short *dest; createStreams();primeStreams(); while(1) { SIO_reclaim(inStream,(Ptr *)&source, NULL); SIO_reclaim(inStream,(Ptr *)&source, NULL); SIO_reclaim(outStream,(Ptr *)&dest, NULL); SIO_reclaim(outStream,(Ptr *)&dest, NULL); // *** PROCESS *** SIO_issue(outStream, dest, BUFFSIZE*4,NULL); SIO_issue(outStream, dest, BUFFSIZE*4,NULL); SIO_issue(inStream, source, BUFFSIZE*4,NULL); SIO_issue(inStream, source, BUFFSIZE*4,NULL); }} Create dummy pointers for the buffer exchange Create and prime the streams (reference previous code) Reclaim FULL buffer from input stream (pends until ready, then process it) Reclaim EMPTY buffer from output stream (pends until ready, then fill it up) Issue FULL buffer to the output stream (and send it out) Issue EMPTY buffer to the input stream (to be re-filled again)

11 Objectives System Block Diagram Standard I/O (SIO) - Using Streams  Device Drivers (IOM)  Reference Frameworks (RF)  Lab 12/12a – Using SIO and Modifying an IOM Driver Technical Training Organization T TO

12 Lab12 – Example SIO/Driver Architecture User-Defined Device Driver DIO Class Driver TSK SIO Processing Thread DSP/BIOS SIO-Stream Interface McBSPEDMAcodec Technical Training Organization T TO I/O Mini Driver (IOM) Let’s take a closer look at IOM…

13 IOM Driver Files Technical Training Organization T TO DSK 6416 IOM Driver Files (from DDK) DSK 6416 IOM Driver Files (from DDK) dsk6416_aic23.cdsk6416_codec_devParams.cc6x1x_edma_mcbsp.cdsk6416_edma_aic23.c  Generic McBSP driver for the TMS320C6x1x series. Uses the EDMA.  AIC23 codec driver implementation specific to the DSK6416 board.  Defines the default parameters used for DSK6416_EDMA_AIC23 IOM driver  Driver for the aic23 codec on the 6416 DSK. Requires the generic TMS320C6x1x McBSP driver.  To add channel sorting to the EDMA, we need to modify the last two files which contain the EDMA structures/initialization.  We will modify these files, then create our own library (output a.lib file instead of.out) – myDriver.lib – to use in our project. IOM files contain functions and data structures… Note: 6713 DSK files are the same other than the generic driver

14 Mini-Driver Interface (IOM) IOM Interface Consists Of: Functions:   init function   IOM_mdBindDev   IOM_mdUnBindDev   IOM_mdControlChan   IOM_mdCreateChan   IOM_mdDeleteChan   IOM_mdSubmitChan   interrupt routine (isr) Data Structures:   BIOS Device Table   IOM function table   Dev param’s   Global Data Pointer (device inst. obj.)   Channel Params   Channel Instance Obj.   IOM_Packet (aka IOP) Technical Training Organization T TO What platforms does the DDK support ?  You will get a chance to examine several of these functions in the lab

15 Driver Developer Kit (DDK) Platform* Video Capture / Display PCIEMACMcBSPMcASP H/W UART S/W UART Utopia 6711 DSK External AD535 (External) 6713 DSK AIC VT TEB PCM DSK AIC23 3rd Party Solution DM642 EVM DDK v1.0 DDK v1.1 DDK v1.2 DDK v1.0 DDK v1.1 DDK v1.2   Provided Royalty Free (for use on TI DSP’s)   Requires CCS v2.2 or greater   To download, go to and select Software  Peripheral Drivers. * We have only included C6000 systems in this table Technical Training Organization T TO

16 Objectives System Block Diagram Standard I/O (SIO) - Using Streams Device Drivers (IOM)  Reference Frameworks (RF)  Lab 12/12a – Using SIO and Modifying an IOM Driver Technical Training Organization T TO

17 Reference Frameworks System H/W (Peripherals) Algorithm XDAISXDAIS IOMIOM Reference Frameworks   Application Framework for systems which integrate:   XDAIS algorithms   IOM Drivers   Statically or Dynamically instantiates XDAIS algorithms   Provides the ALGRF module which uses BIOS Memory Management   Uses IOM to talk to codecs (or other hardware) One problem RF's solve... Technical Training Organization T TO

18 Blank Page Syndrome   Who wants to start this way? Technical Training Organization T TO

19 An Application Blueprint   Does something useful   Is easy to adapt and change   Creates modules that can be reused   Includes documentation and comments   Written in portable, high-level language   Has a well standardized file structure   Uses various tools together (BIOS, IOM, RTA, etc)   Is NOT a blank page Technical Training Organization T TO

20 Reference Framework Characteristics  Good Starterware  Design-ready, reusable, C language source code  Not demo code  A complete “generic” application running on TI DSK’s  Supplied with “FIR type” eXpressDSP compliant algorithms  Criteria to enable appropriate selection of RF level  System Budgeting  Memory footprint  Instruction cycles  Adaptation guide for adding algorithms, channels, and drivers  An API Reference Manual for new (library) modules  Consistent documentation in RF application notes  SPRA79x  eXpressDSP for Dummies  RF1, RF3, RF5: Licensed with every TMS320 device - royalty free

21 Reference Frameworks Design ParameterRF1RF3RF5RF6 Static Configuration Dynamic Object Creation Static Memory Management Dynamic Memory Allocation Recommended # of Channels 1 to 31 to 10+1 to 100 Recommended # of XDAIS Algos 1 to 31 to 10+1 to 100 Absolute Minimum Footprint Single/Multi Rate Operation singlemulti Thread Preemption and Blocking Implements Control Functionality Supports HWIHWI, SWIHWI, SWI, TSK Implements DSPLink (DSP  GPP) Total Memory Footprint (less algos) 3.5KW11KW25KWtbd Processor Family Supported C5000 C5000 C6000 None Currently Planned, but not yet available Compact Flexible Connected Extensive Looking at RF3... Technical Training Organization T TO

22 RF3 Design   Reference Frameworks are modularly designed to allow for flexible adaptation Threads FIRVOL FIR_TIVOL_TI PLIO LIO DSP/BIOSCSL Hardware Application ALGRF control Application Customizing Thread Customizing   # of channels   # of algorithms   Application control Algorithm Customizing Dev Driver Customizing Hardware Customizing Technical Training Organization T TO

23 RF3 Block Diagram ( out of the box ) SWI Audio 1 Split SWI Join SWI In Out PIP IOM SWI Audio 0 FIRVol FIRVol Control Thread (swiControl) Memory Host (GEL) clkControl   IOM Drivers for input/output   Two processing threads with generic algorithms   Split/Join threads used to simulate stereo codec. ( On C6416/C6713 DSKs, how could we save cycles on split/join?) PIP Technical Training Organization T TO

24 Threads FIR FIR_TI PLIO LIO DSP/BIOSCSL Hardware Application ALGMIN Application Customizing Algorithm Customizing Dev Driver Customizing Hardware Customizing Thread Customizing   # of channels   # of algorithms   Application control RF1 Design Technical Training Organization T TO

25 Objectives System Block Diagram Standard I/O (SIO) - Using Streams Device Drivers (IOM) Reference Frameworks (RF)  Lab 12/12a – Using SIO and Modifying an IOM Driver Technical Training Organization T TO

26 Lab12/12a – SIO and IOM CPUEDMA RCVCHAN gBufferRcv ADC DAC McBSP0 Rcv Xmt XMTCHAN gBufferXmt COPY + PongPong PongPong PingPing PingPing Flash LEDs and Load XDAIS Filter DIP_1 DIP_2   Drop in an IOM driver and modify TSK to use SIO   Modify IOM driver to perform channel sorting Technical Training Organization T TO

27 ti Technical Training Organization Technical Training Organization T TO

28 Abstracting Hardware App CodecMcBSPEDMA ISR   Application gets data from H/W (codec) through an interrupt service routine (ISR)   Buffer management is not defined   Every application has a customized interface to H/W   Strictly limits the portability of the Application as it is tied to a specific piece of H/W Technical Training Organization T TO

29 IOM Abstracting Hardware with Drivers App CodecMcBSPEDMA ISR SWI or TSK SIO or PIP   Device Drivers standardize the interface between the Application and the H/W   Uses a BIOS SIO (or PIP) as the buffer manager   The Application programmer only has to know the interface (no matter what H/W is connected)   The H/W can be changed without changing the Application (only need to change IOM included in project)   Therefore, Drivers (SIO/PIP and IOM) insulate the Application from the Hardware’s details Technical Training Organization T TO

30 System The IOM Interface H/W (Peripherals) Algorithm XDAISXDAIS IOMIOM IOM and XDAIS provide common interfaces   With standardized interfaces to Algorithms and H/W, the system software (i.e. framework) can also be standardized   This “standard” framework can be used as a starting point for many different Applications   Data   Init   Mem. Mgmt. System Software Technical Training Organization T TO

31 Why Use a Device Driver?   Universal Interface to All I/O Devices   Application uses the same API for different devices   Isolates Application From the Details of Device Operation   Minimize changes to your application for different devices   Improves Code Maintenance and Portability   Formalizes the interface between the application and devices   Breaks interface code into layers; usually only the lowest layer need change when porting application   Encourages Code Re-use   Write once, Use often Application Read buffer A/D Device Driver Technical Training Organization T TO

32 What does a Device Driver Provide? Application Read buffer A/D Device Driver Abstraction   Map generic functions to a set of h/w specific set of functions   Common set of data objects   Defined Methodology Buffer Management   Size   Quantity   Flexibility Synchronization   Blocking   Non-blocking with Callback Technical Training Organization T TO

33 1. Abstraction What do you want to do?   Write   Read   Init   Etc. Example Device-Specific Functions:   A2D_read(), or   MIC_read(),   Etc. What happens if I use the following device specific function in my application code? myfxn() { A2D_read(*buffer); filter(*buffer);... Every time you change drivers, you must rewrite your application code Technical Training Organization T TO

34 1. Abstraction (IOM_Fxns) Alternatively, if I use a General I/O function … mix(){ GIO_read(myDevice,*buf); filter(*buf);... Device driver’s include a function table (IOM_Fxns) that:   Isolates application code from   Hardware specific functions GIO_read→A2D_read GIO_write→A2D_write GIO_init→A2D_bind … etc. myDevice Fxn Table Technical Training Organization T TO

35 2. Buffer Management Device Drivers Provide an Interface Standard For Passing and Managing Data Buffers:   Size of Buffers   Number of Buffers   Method of Passing Buffers   Error Handling Technical Training Organization T TO

36 3. Synchronization (Signaling)  How Does the Application Know When the I/O Operation Has Completed?  How Does the Driver Signal the Application?  In Other Words, How Does Application Code and Drivers Synchronize With Each Other?  Two Methods of Synchronization:  “Sync” Functions (Blocking)  “Async” Functions (Non-blocking/callback) Technical Training Organization T TO

37 Blocking (Sync Function) Application Read Device Driver Application TSK_A Read buffer Device Driver A/D TSK_A TSK_B Running Ready I/O Not Ready Blocked! I/O Ready Ready!   Synchronous function calls force the calling function to wait.   If TSK_A reads from a driver (which isn’t ready), the device driver will block itself (and TSK_A) while waiting for data, thus allowing lower priority tasks to operate.   When the I/O operation is complete, the driver notifies TSK_A the data is ready via a SEMaphore post. Blocked Technical Training Organization T TO

38 Non-blocking Application WriteRead Application SWI Read buffer Device Driver SWI_A SWI_B I/O Not Ready I/O Ready Process! Callback A/D Ready or Blocked   Asynchronous function calls initiate a function call without waiting?   Even though I/O may not be ready as soon as a read operation is submitted, SWI_A continues processing. (Obviously this other processing cannot be dependent upon the data requested.)   As part of the data read request, SWI_A includes a “follow-up” function (or SWI, etc.) to be run whenever data is ready.   When data becomes available, the device driver’s interrupt function (ISR) calls the “callback” (i.e. follow-up) function specified by SWI_A. Read request w/ follow-up fxn Process buffer Driver calls back to application when data’s ready Technical Training Organization T TO

39 Non-blocking (Async Function) Application WriteRead Application SWI Read buffer Device Driver SWI_A SWI_B I/O Not Ready I/O Ready Process! Callback A/D Ready or Blocked   Asynchronous function calls initiate a function call without waiting Process buffer Technical Training Organization T TO

40 Non-blocking (Async Function) Application WriteRead Application SWI Read buffer Device Driver SWI_A SWI_B I/O Not Ready I/O Ready Process! Callback A/D Ready or Blocked   Asynchronous function calls initiate a function call without waiting   Even though I/O may not be ready as soon as a read operation is submitted, SWI_A continues processing. (Obviously, this other processing cannot be dependent upon the data requested.)   As part of the data read request, SWI_A includes a “follow-up” function (or SWI, etc.) to be run after data is ready.   When data becomes available, the device driver’s interrupt function (ISR) calls the “callback” (i.e. follow-up) function specified by SWI_A. Process buffer Technical Training Organization T TO

41 Sync vs. Async Functions read requested HWI data available TSK while(1) { Read data(); Process data(); } blocks with SEM_pend SEM_post SWI_1 Read data(); immediately returns SWI_2 process data(); callback fxn (SWI_post) Technical Training Organization T TO

42 BIOS Device Driver Summary Abstraction   Specific set of functions   Specific set of data objects   Methodology Buffer Management   Size   Quantity   Flexibility Synchronization   Blocking   Non-blocking with callback Device Driver (consists of 2 layers) Common Set of Requirements Class Driver Specific Functions Needed for H/W Device Mini-Driver Technical Training Organization T TO

43 BIOS I/O Models DSP/BIOS provided Class Drivers Mini-Driver (IOM) SIOPIPGIO DSP/BIOS Thread Types TSK or SWI SWI TSK or SWI Any mini-driver (IOM) can be used with any DSP/BIOS I/O model   Application Programmer c hooses the preferred class driver   Interface is consistent regardless of which device (i.e. mini-driver) connected   Software interface doesn’t change, even if you change the device/mini-driver Technical Training Organization T TO

44 BIOS I/O Models Summary YesNo Non-Streaming Interface YesNo Issue/No Reclaim/Yes Blocking APIs Yes Works With SWI YesNoYesWorks With TSK YesNo Customized APIs NoneIn DDKIn CCS 2.2Uses Adapter GIOPIPSIO Technical Training Organization T TO

45 Device Channels SIO TSK Mini-driver DIO SIO DIO 1 mini-driver 2 channels GIO TSK Mini- driver 1 mini-driver 1 channel Technical Training Organization T TO

46 Mini-Driver Interface (IOM)  Maximum Reuse and Portability  One I/O mini-driver (IOM) interface to support all TI Class drivers.  IOM Interface Consists Of: Functions:   init function   IOM_mdBindDev   IOM_mdUnBindDev   IOM_mdControlChan   IOM_mdCreateChan   IOM_mdDeleteChan   IOM_mdSubmitChan   interrupt routine (isr) Data Structures:   BIOS Device Table   IOM function table   Dev param’s   Global Data Pointer (device inst. obj.)   Channel Params   Channel Instance Obj.   IOM_Packet (aka IOP) Technical Training Organization T TO

47 Outline  Intro. to Device Drivers  DSP/BIOS Class Drivers  An Example  Code Flow  Buffer Flow  Layering Device Drivers  The Device Driver Developer’s Kit Technical Training Organization T TO

48 Example walk-thru  Use McBSP/AD50 sample-by-sample mini-driver to read data  Application uses a TSK to read the data  Uses the provided SIO/DIO Class Driver to connect the TSK to the mini-driver  Outline 1. Static Configuration 2. Building the App with the mini-driver 3. Application Initialization 4. Task Activities (Create/Execute/Delete) ‘C5402 McBSP AD50 TSK read buffer process buffer Technical Training Organization T TO

49 1. Static Configuration  Registering the mini-driver  Setting up DIO  Creating the TSK  You don’t really have to do this, it is a piece of the application Technical Training Organization T TO

50 1. Static Configuration (Registration) Technical Training Organization T TO

51 1. Static Configuration (Registration) namefxnsdevidparamstypedevp /codec_DSK5402_AD50_FXN0x0 IOM_Fxns0x0 DEV Table Technical Training Organization T TO

52 1. Static Configuration (DIO) Technical Training Organization T TO

53 1. Static Configuration (DIO) namefxnsdevidparamstypedevp /codec_DSK5402_AD50_FXN0x0 IOM_Fxns0x0 /dio_codec_DIO_tskDynamicFxns0x0 DEV_Fxns0x0 Device Table Technical Training Organization T TO

54 1. Static Configuration (TSK) Technical Training Organization T TO

55 2. Building the App with the Mini-driver  Including the library  Including the necessary header files Technical Training Organization T TO

56 3. Application Initialization (BIOS_init) Calls all Platform_Device_init’s   DSK5402_MCBSP_AD50_init (usually an empty function)   Dev. Driver module init. BIOS_init Reset Dev. Table IOM_Fxns DSK5402_MCBSP_AD50_FXNS = { mdBindDev, IOM_UNBINDDEVNOTIMPL, mdControlChan, mdCreateChan, mdDeleteChan, mdSubmitChan }; codec...   BIOS_init calls bind for each IOM device mdBindDev( dgp, devid, dparams )   initialize parameters   acquire resources   initialize h/w   plug ISRs   create/initialize global data structure Technical Training Organization T TO

57 3. Application Initialization (main) BIOS_init main   other non driver init   return (to BIOS) Technical Training Organization T TO

58 Task Create Phase BIOS_init main tsk 1. 1.Create Streams 2. 2.Allocate Buffers 3. 3.Prime Streams tsk_function(…) { SIO_create() C E D SIO_create 1. 1.Create SIO Object 2. 2.Create IOP Packets 3. 3.Open Adapter DIO_open 1. 1.Create DIO Object 2. 2.Create Queues 3. 3.Create MD Chan mdCreateChan 1. 1.Create Queue 2. 2.Create Chan Object 3. 3.Enable Interrupts Technical Training Organization T TO

59 IOM Packets typedef struct DEV_Frame {/* frame object */ QUE_Elem link;/* queue link */ Ptr addr;/* buffer address */ Uns size;/* buffer size */ Arg misc;/* miscellaneous item */ Arg arg;/* user argument */ /* these fields are used by IOM... */ Uns cmd;/* command for mini-driver */ Int status;/* status of command */ } DEV_Frame;... typedef DEV_Frame IOM_Packet;... dev.h iom.h Technical Training Organization T TO

60 Channel Object typedef struct ChanObj { Boolinuse; /* TRUE => channel is open */ Intmode; /* IOM_INPUT or IOM_OUTPUT only */ IOM_Packet*dataPacket; /* active I/O packet */ QUE_ObjpendList; /* list of packets for I/O */ Uns*bufptr;/* pointer in current buffer */ Unsbufcnt; /* samples left to handle */ IOM_TiomCallbackcbFxn; /* to notify client */ PtrcbArg;/* info for client */ } ChanObj, *ChanHandle; Technical Training Organization T TO

61 Task Create Phase BIOS_init main tsk 1. 1.Create Streams 2. 2.Allocate Buffers 3. 3.Prime Streams … MEM_alloc() C E D Technical Training Organization T TO

62 Task Create Phase BIOS_init main tsk 1. 1.Allocate Buffers 2. 2.Create Streams 3. 3.Prime Streams SIO_issue 1. 1.Put *buf in IOP 2. 2.Queue IOP 3. 3.Call Adapter DIO_issue 1. 1.Dequeue IOP 2. 2.Pass IOP to MD mdSubmitChan 1. 1.Queue IOP or fill w/Data … SIO_issue(); C E D Technical Training Organization T TO

63 Task Execute Phase BIOS_init main tsk 1. 1.Allocate Buffers 2. 2.Create Streams 3. 3.Prime Streams 1. 1.Reclaim Full Buf 2. 2.Process 3. 3.Issue Empty Buf SIO_reclaim 1. 1.Call adapter 2. 2.Deque IOP 3. 3.Extract buf info from IOP & ret DIO_reclaim 1. 1.Pend on SEM 2. 2.Return to SIO isr 1. 1.Fill buf with data 2. 2.When buf is full, call Callback with arg and IOP … while(!terminate) { SIO_reclaim(); C E D Callback 1. 1.Queue IOP 2. 2.Post Sem Technical Training Organization T TO

64 Task Execute Phase BIOS_init main tsk 1. 1.Allocate Buffers 2. 2.Create Streams 3. 3.Prime Streams 1. 1.Reclaim Full Buf 2. 2.Process 3. 3.Issue Empty Buf … while(!terminate) { SIO_reclaim() DSP_stuff C E D Technical Training Organization T TO

65 Task Execute Phase BIOS_init main tsk 1. 1.Allocate Buffers 2. 2.Create Streams 3. 3.Prime Streams 1. 1.Reclaim Full Buf 2. 2.Process 3. 3.Issue Empty Buf … while(!terminate) { SIO_reclaim() DSP_stuff() SIO_issue() SIO_issue 1. 1.Packetize buf 2. 2.Queue IOP 3. 3.Call Adapter DIO_issue 1. 1.Dequeue IOP 2. 2.Pass IOP to MD mdSubmitChan 1. 1.Queue IOP or fill w/Data C E D Technical Training Organization T TO

66 Task Delete Phase BIOS_init main tsk 1. 1.Allocate Buffers 2. 2.Create Streams 3. 3.Prime Streams 1. 1.Reclaim Full Buf 2. 2.Process 3. 3.Issue Empty Buf 1. 1.Delete … while(!terminate) { SIO_reclaim() DSP_stuff() SIO_issue() } SIO_reclaim() SIO_delete() MEM_free()... } C E D Technical Training Organization T TO

67 Outline  Intro. to Device Drivers  The Device Driver Developer’s Kit  An Example  Code Flow  Buffer Flow  The Other Class Drivers  Layering Device Drivers Technical Training Organization T TO

68 Buffer Flow BIOS_init main tsk 1. 1.Allocate Buffers 2. 2.Create Streams 3. 3.Prime Streams 1. 1.Reclaim Full Buf 2. 2.Process 3. 3.Issue Empty Buf App change this stuff to all tsk code??? task_function() { SIO_create() MEM_alloc() SIO_issue() while(!terminate) { SIO_reclaim() DSP_stuff() SIO_issue() } SIO_delete() MEM_free() } SIO IOP Technical Training Organization T TO

69 SIO Buffer Flow BIOS_init main tsk 1. 1.Allocate Buffers 2. 2.Create Streams 3. 3.Prime Streams 1. 1.Reclaim Full Buf 2. 2.Process 3. 3.Issue Empty Buf App IOP buf0buf1 task_function() { SIO_create() MEM_alloc() SIO_issue() while(!terminate) { SIO_reclaim() DSP_stuff() SIO_issue() } SIO_delete() MEM_free() } Technical Training Organization T TO

70 SIO Buffer Flow BIOS_init main tsk 1. 1.Allocate Buffers 2. 2.Create Streams 3. 3.Prime Streams 1. 1.Reclaim Full Buf 2. 2.Process 3. 3.Issue Empty Buf App DIO IOP buf0 IOP buf1 task_function() { SIO_create() MEM_alloc() SIO_issue() while(!terminate) { SIO_reclaim() DSP_stuff() SIO_issue() } SIO_delete() MEM_free() } Technical Training Organization T TO

71 SIO Buffer Flow BIOS_init main tsk 1. 1.Allocate Buffers 2. 2.Create Streams 3. 3.Prime Streams 1. 1.Reclaim Full Buf 2. 2.Process 3. 3.Issue Empty Buf App DIO MD IOP buf1 IOP buf0 task_function() { SIO_create() MEM_alloc() SIO_issue() while(!terminate) { SIO_reclaim() DSP_stuff() SIO_issue() } SIO_delete() MEM_free() } Technical Training Organization T TO

72 SIO Buffer Flow BIOS_init main tsk 1. 1.Allocate Buffers 2. 2.Create Streams 3. 3.Prime Streams 1. 1.Reclaim Full Buf 2. 2.Process 3. 3.Issue Empty Buf App DIO MD IOP buf1 IOP buf0 ISR BLOCK buf0 task_function() { SIO_create() MEM_alloc() SIO_issue() while(!terminate) { SIO_reclaim() DSP_stuff() SIO_issue() } SIO_delete() MEM_free() } Technical Training Organization T TO

73 SIO Buffer Flow BIOS_init main tsk 1. 1.Allocate Buffers 2. 2.Create Streams 3. 3.Prime Streams 1. 1.Reclaim Full Buf 2. 2.Process 3. 3.Issue Empty Buf App DIO MD IOP buf0 IOP buf0 ISR BLOCK IOP buf1 Callback task_function() { SIO_create() MEM_alloc() SIO_issue() while(!terminate) { SIO_reclaim() DSP_stuff() SIO_issue() } SIO_delete() MEM_free() } Technical Training Organization T TO

74 SIO Buffer Flow BIOS_init main tsk 1. 1.Allocate Buffers 2. 2.Create Streams 3. 3.Prime Streams 1. 1.Reclaim Full Buf 2. 2.Process 3. 3.Issue Empty Buf App DIO MD IOP buf0 IOP buf1 ISR BLOCK task_function() { SIO_create() MEM_alloc() SIO_issue() while(!terminate) { SIO_reclaim() DSP_stuff() SIO_issue() } SIO_delete() MEM_free() } Technical Training Organization T TO

75 SIO Buffer Flow BIOS_init main tsk 1. 1.Allocate Buffers 2. 2.Create Streams 3. 3.Prime Streams 1. 1.Reclaim Full Buf 2. 2.Process 3. 3.Issue Empty Buf App DIO MD IOP buf1 ISR IOP buf0 task_function() { SIO_create() MEM_alloc() SIO_issue() while(!terminate) { SIO_reclaim() DSP_stuff() SIO_issue() } SIO_delete() MEM_free() } Technical Training Organization T TO

76 SIO Buffer Flow BIOS_init main tsk 1. 1.Allocate Buffers 2. 2.Create Streams 3. 3.Prime Streams 1. 1.Reclaim Full Buf 2. 2.Process 3. 3.Issue Empty Buf App DIO MD IOP buf1 ISR IOP buf0 task_function() { SIO_create() MEM_alloc() SIO_issue() while(!terminate) { SIO_reclaim() DSP_stuff() SIO_issue() } SIO_delete() MEM_free() } Technical Training Organization T TO

77 SIO Buffer Flow BIOS_init main tsk 1. 1.Allocate Buffers 2. 2.Create Streams 3. 3.Prime Streams 1. 1.Reclaim Full Buf 2. 2.Process buf Issue Empty Buf App DIO MD IOP buf1 ISR IOP buf0 task_function() { SIO_create() MEM_alloc() SIO_issue() while(!terminate) { SIO_reclaim() DSP_stuff() SIO_issue() } SIO_delete() MEM_free() } Technical Training Organization T TO

78 Buffer Flow BIOS_init main tsk 1. 1.Allocate Buffers 2. 2.Create Streams 3. 3.Prime Streams 1. 1.Reclaim Full Buf 2. 2.Process buf Issue Empty Buf DIO MD IOP buf1 ISR SIO App IOP buf0 task_function() { SIO_create() MEM_alloc() SIO_issue() while(!terminate) { SIO_reclaim() DSP_stuff() SIO_issue() } SIO_delete() MEM_free() } Technical Training Organization T TO

79 Buffer Flow BIOS_init main tsk 1. 1.Allocate Buffers 2. 2.Create Streams 3. 3.Prime Streams 1. 1.Reclaim Full Buf 2. 2.Process buf Issue Empty Buf MD IOP buf1 ISR SIO App DIO IOP buf0 task_function() { SIO_create() MEM_alloc() SIO_issue() while(!terminate) { SIO_reclaim() DSP_stuff() SIO_issue() } SIO_delete() MEM_free() } Technical Training Organization T TO

80 Buffer Flow BIOS_init main tsk 1. 1.Allocate Buffers 2. 2.Create Streams 3. 3.Prime Streams 1. 1.Reclaim Full Buf 2. 2.Process buf Issue Empty Buf MD IOP buf1 ISR SIO App DIO IOP buf0 task_function() { SIO_create() MEM_alloc() SIO_issue() while(!terminate) { SIO_reclaim() DSP_stuff() SIO_issue() } SIO_delete() MEM_free() } Technical Training Organization T TO

81 Buffer Flow BIOS_init main tsk 1. 1.Allocate Buffers 2. 2.Create Streams 3. 3.Prime Streams 1. 1.Reclaim Full Buf 2. 2.Process buf Issue Empty Buf MD IOP buf1 ISR SIO App DIO IOP buf0 BLOCK buf1 task_function() { SIO_create() MEM_alloc() SIO_issue() while(!terminate) { SIO_reclaim() DSP_stuff() SIO_issue() } SIO_delete() MEM_free() } Technical Training Organization T TO

82 Outline  Intro. to Device Drivers  DSP/BIOS Class Drivers  An Example  Layering Device Drivers  The Device Driver Developer’s Kit Technical Training Organization T TO

83 DSP/BIOS McBSP Codec Driver  Generic McBSP-DMA Data Mover  Implemented as a stand-alone mini-driver  Multi-channel  Reusable across codecs  Codec Specific Part of Mini-Driver  Handles codec specific bind, channel open  AIC23, PCM3002, AD50, AD535 Application/Framework Device Driver PIP PIO Adapter SIO DIO Adapter GIO Class Driver Codec-Specific Part of Mini-Driver Generic McBSP-DMA Data Mover Mini- Driver Technical Training Organization T TO

84 Mini-Driver Interface Bindings  Only mdSubmitChan and mdCreateChan Calls Are Handled by the Codec-Specific Portion of the Mini-Driver  So That’s All You Have To Write! mdBindDevmdCreateChan mdControlChanmdDeleteChan mdSubmitChanmdUnbindDev Codec-Specific Part of Mini-Driver Generic McBSP-DMA Data Mover IOM Interface Technical Training Organization T TO

85 DSP/BIOS McASP Codec Driver  Generic McASP-EDMA mini-driver  Supports 1-N serializers  Reusable across codecs  Minimal codec-specific code required  Will support 6713 DSK daughter card codec Application/Framework Device Driver PIP PIO Adapter SIO DIO Adapter GIO Class Driver Mini- Driver Codec-Specific Part of Mini-Driver Generic McASP-DMA Data Mover Technical Training Organization T TO

86 UART Drivers  GIO APIs for character-based I/O  UART Drivers that support standard  Hardware UART Mini-Driver  Software UART Mini-Driver - Simulated using McBSP and DMA  Configurable parameters  Baud rate, stop bits, parity bits, … Application/Framework Device Driver PIP PIO Adapter SIO DIO Adapter GIO Class Driver Mini- Driver Device-Specific Part of UART Mini-Driver Generic UART Mini-Driver Technical Training Organization T TO

87  Frame-based only drivers  Video capture  Video display  Supports multiple video ports  Supports video encoders & decoders on the DM642 EVM Video Port Driver Application/Framework Device Driver Class Driver Mini- Driver GIO FVID Class Driver Wrapper Encoder/Decoder Specific Part of Mini-Driver Generic Video Port-DMA Data Mover Technical Training Organization T TO

88 PCI Driver  Designed as data mover driver  Enables access to devices connected to the PCI bus (shared memory, custom ASICs, …)  Support bus mastering and DMA on to the PCI bus  Requires host driver to initialize PCI bus configuration  Windows PCI Host Driver  Provided for Valley Tech C6416 board, Possibly DM642 EVM (www.valleytech.com) Shared Memory DSP PCI Peripheral CSL PCI Mini-Driver Shared Memory Mini-Driver Class Driver Technical Training Organization T TO

89 MMC Driver  Multimedia Card Driver  Raw data interface to MMC flash memory  FAT File System  SDS is productizing IA FAT File System for the mass market  The Fat File System is NOT included in the DDK  Must be purchased as a separately licensed module DSP MMC Peripheral CSL MMC Mini-Driver GIO Class Driver FAT File System Technical Training Organization T TO

90 USB Driver  Client-Side Only Driver  Host USB Driver Provided in DDK (Thesycon UBIO)  Development version only with 12-hour timeout USB Host DSP USB Peripheral CSL USB Mini-Driver Class Driver CSL Codec Mini-Driver Class Driver Application/Framework Codec Device Technical Training Organization T TO

91 Outline  Intro. to Device Drivers  DSP/BIOS Class Drivers  An Example  Layering Device Drivers  The Device Driver Developer’s Kit Technical Training Organization T TO

92 DDK Overview  What Is the DDK?  Why a New Driver Model?  Why Is the DDK Required?  DDK Driver Support  DDK Directory Structure  DDK Documentation Technical Training Organization T TO

93 What is the DDK?  Device Driver Developer’s Kit  Productized Drivers for TI DSP Peripherals  Simple Example Applications That Use These Drivers  Documentation on Using Existing Drivers and How to Develop New Drivers  A Downloadable Product Available at No Cost or Run-time Royalties  Available on Update Advisor and TI Developer’s Village Technical Training Organization T TO

94 Why a New Driver Model?  LIO Was the Starting Point  Oriented Towards a More Diverse Set of Peripherals  UART, PCI, Video, etc.  Ability to Provide Domain Specific APIs  Frame Video Drivers  IAG File System  DSP/BIOS Integration  Initialization from BIOS_init()  Configuration From GConf Technical Training Organization T TO

95 Why is the DDK Required?  TI DSPs Are Including More Complex Peripherals:  PCI, USB, Ethernet MAC, Multimedia Cards, McASP, Utopia II, Video Ports, …  OEMs Want to Focus Their Expertise on Applications -- Not TI Peripherals:  Device Drivers Are Not a Point of Differentiation  Device Driver Development Is a Gating Item for Application Integration and Test  Debugging Device Drivers Can Be Very Time Consuming  The DDK Provides ‘Off-the-shelf’ Tested Device Driver Software  Makes Selling a TI DSP Solution Simpler by Eliminating Objections About Driver Programming Effort Technical Training Organization T TO

96 DDK Driver Support DDK v1.0 DDK v1.1   Provided Royalty Free   Requires CCS v2.2 or greater   Search for “DDK” on the TI website to download the kit Technical Training Organization T TO

97 C:\tiddkappsdocsincludelibsrc   Installed Within CCS Directory   All DDK Content Goes Here   Example Applications   Documentation   Header Files   Class and Mini-Driver Libraries   Driver Source Code DDK Top-Level Directory Structure Technical Training Organization T TO

98 appsaudiomediamiscportuart   Audio Driver Applications   MMC Driver Applications   UART Driver Applications   PCI Driver Applications   UART Driver Applications DDK Application Directory Structure ddk Technical Training Organization T TO

99 appsaudiomediamiscportuart   Audio Driver Applications   MMC Driver Applications   UART Driver Applications   PCI Driver Applications   UART Driver Applications DDK Application Directory Structure dsk5402_dma_ad50 dsk6x11_edma_ad535 teb6416_edma_pcm3002 pip_echo.c swi_echo.c tsk_echo.c Technical Training Organization T TO

100 appsaudiomediamiscportuart   Audio Driver Applications   MMC Driver Applications   UART Driver Applications   PCI Driver Applications   UART Driver Applications DDK Application Directory Structure dsk5402_dma_ad50 dsk6x11_edma_ad535 teb6416_edma_pcm3002 pip_echo54.cdb pip_echo54.pjt pip_echo54cfg.cmd readme.txt tsk_echo54.cdb tsk_echo54.pjt tsk_echo54cfg.cmd : Technical Training Organization T TO

101 srcclassaudio   Audio Driver Source Code   UART Driver Source Code uart   Class Driver Source Code DDK Driver Source Directory Structure : dsk5402_dma_ad50 dsk6x11_edma_ad535 teb6416_edma_pcm3002 ad50.c dsk5402_dma_ad50.c dsk5402_dma_ad50.pjt readme.txt build.bat build5000.bat build6000.bat ddk : Technical Training Organization T TO

102 C:\tiddkappsdocsincludelibsrc   Installed Within CCS Directory   All DDK Content Goes Here   Example Applications   Documentation   Header Files   Class and Mini-Driver Libraries   Driver Source Code DDK Top-Level Directory Structure Technical Training Organization T TO

103 DDK Documentation Doc #DSPDeviceBoard SPRA882AllUARTAll SPRA858C5000McBSP/DMAAll C5000 SPRA857C5509AIC23 CodecC5509 DSK SPRA854C5402AD50 CodecC5402 DSK SPRA855C5416PCM3002 CodecC5416 DSK SPRA856C5510AIC23 CodecC5510 DSK SPRA881C5509MMCC5509 DSK SPRA845C6416PCIVT1423 SPRA846C6x1xMcBSP/EDMAAll C6000 SPRA850C6x11AD535 CodecC6711 DSK SPRA849C6416PCM3002C6416 TEB SPRA870C6x1xMcASP/EDMAMDS Mozart SPRU616DSP/BIOS Driver Developer's Guide   Every Device Driver Has a Corresponding Piece of Documentation (App Note) Usage, Architecture, Data Sheet   Every Device Driver Has a Readme File


Download ppt "TMS320C6000 DSP Integration Workshop Chapter 12 IOM and Frameworks Copyright © 2005 Texas Instruments. All rights reserved. Technical Training Organization."

Similar presentations


Ads by Google