Basic class DSP/bios api call

Source: Internet
Author: User

 

Basic class DSP/bios api call

I. Clock management CLK
(1) uns ncounts = clk_countspms (void)
Returns the counter value of the timer high-resolution clock per millisecond.
(2) lguns currtime = clk_gethtime (void)
The Return Value of the high-resolution clock exceeds 32 bits and returns to zero.
High-resolution clock is the DSP clock divided by (tddr + 1)
(3) lguns currtime = clk_getltime (void)
The Return Value of the low-resolution clock exceeds 32 bits and returns to zero.
A high-resolution clock is a DSP clock divided by (tddr + 1) and then divided by (PRD + 1)
(4) uns period = clk_getprd (void)
Returns the value of the CLK manager period register.

Ii. Cyclic function PRD
(1) lguns num = prd_getticks (void)
Returns the 32-bit cyclic function management Count value.
(2) void prd_start (prd_obj * period)
Start the PRD module counter. Generally, mode = one-shot
(3) void prd_stop (prd_obj * period)
Disable the PRD module counter
(4) void prd_tick (void)
Add 1 to the counter of the cycle module so that the cycle module manager can determine which periodic function can be run.

Iii. SWI
(1) void swi_andn (swi_obj * SWI, UNS mask) mask parameter
Compare the mailbox value with the mask and use the result to replace the previous mailbox value. If the value is 0, the software is interrupted and the initial mailbox value is restored.
(2) void swi_andn (swi_obj * SWI)
Reduce the email value by 1 and replace the previous email value with the result. If the value is 0, the software is interrupted and the initial mailbox value is restored.
(3) void swi_disable (void)
Disable software interruption
(4) void swi_enable (void)
Enable software interruption
(5) uns num = swi_getmbox (void)
Returns the value of the current SWI object in the executed email address. If the interruption has started, the DSP/BIOS will save the value first.
(6) uns key = swi_getpri (swi_obj * SWI)
Returns the priority of the specified SWI object.
(7) void swi_inc (swi_obj * SWI)
Add the email address of the specified SWI object to 1 and start the software interruption at the same time. Even if the user calls it multiple times, it will be executed once.
(8) void swi_or (swi_obj * SWI, UNS mask) mask parameter
Start the specified software interruption, and compare the mail value of the software interruption with the mask, and use the result to replace the previous mail value,
After the interruption is completed, the mailbox value is restored to the initial value. Generally, swi_getmbox is called to obtain the mailbox value that triggers the software interruption.
(9) void swi_post (swi_handle SWI)
The software of the specified SWI object is interrupted. This function is not affected by the mailbox value or the mailbox value.
Generally, when a software interruption is started at a low frequency, fill _ swi_post in the function settings column of the PRD object, and write the parameters for the software interruption to arg0.
(10) uns key = swi_raisepri (UNS mask)
Improves the priority of SWI software interruptions, generally
Key = swi_raisepri (swi_getpri (& swi_1 ));
-- Access Shared resouces --
Swi_restorepri (key)
(11) void swi_restorepri (UNS key)
Restore original priority
(12) swi_obj * SWI = swi_self (void)
Address of the software interruption of the currently executed SWI object

Iv. information output management log
(1) void log_disable (log_obj * log)
Disable the log function of the specified direction.
(2) void log_enable (log_obj * log)
Enable the log function of the specified direction
(3) void log_error (string format, Arg arg0)
Void log_message (string format, Arg arg0)
The previous function can write an event, data, or error message to the System Log according to the specified format string. This function is not affected by the TRC tracking management module.
The latter function is similar to the former function, but is affected by the TRC tracking management module.
(4) void log_event (log_obj * log, Arg arg0, Arg arg1, Arg arg2)
Write unformatted event messages to logs
(5) void log_printf (log_obj * log, string format, int arg0, int arg1)
The specified log window displays the message % d % x % o % S.
(6) void log_reset (log_obj * log)
Reset log Buffer

5. Memory Management mem
(1) void * ADDR = mem_alloc (INT segid, UNS size, UNS align)
Specify the bucket to allocate consecutive blocks and return the start address.
Segid = bucket ID or ID
Number of characters in size
The align boundary condition is only a power of 0 or 2. If align is 0 or 1, there is no constraint.
(2) void * ADDR = mem_calloc (segid, size, align)
Allocate memory and initialize to 0
(3) int segid = mem_define (PTR base, UNS length, mem_attrs * attrs)
Define a new bucket. The returned value is the ID of the bucket.
If the ATTR parameter is null, It is configured according to the default parameter. The parameter of the segment is specified by the Type mem_attrs struct.
This function is only used in the main function.
Base: base address of the new segment
Length: Segment Length
Attrs: Segment attribute
(4) bool status = mem_free (segid, ADDR, size)
The applied dynamic memory cannot be called in Swi and Hwi.
Before calling, use the lck api to check the memory block locking status.
(5) void mem_redefine (segid, base, length)
Redefines a bucket and can only be called in main
(6) bool status = mem_stat (INT segid, mem_stat * statbuf)
Segid bucket ID
Statbuf status cache zone pointer
Struct mem_stat {
UNS size; // the size of the bucket.
Uns used; // number of used items
UNS length; // the maximum length of a continuous storage block.
}
Similarly, if the segid is valid, mem_stat returns true.
It cannot be used in SWI or Hwi. The locking condition should be determined.
(7) void * ADDR = mem_valloc (INT segid, UNS size, UNS align, char value)
First apply for memory, initialize to the specified value

Vi. C6000 dedicated module C64x
(1) uns oldmask = c64_diableier (UNS mask)
Disable the actual blocked interrupt of the corresponding interrupt Return Value
(2) void c64_enableier (UNS oldmask)
Enable corresponding interruptions

UNS oldmask;
Oldmask = c64_disableier (0x1); // disable int0
C64_enableier (oldmask); // enable int0
(3) void c64_plug (INT vecid, FXN, int dmachan)
Insert an interrupt vector
Int vecid: the interrupt sequence number.
FXN: function pointer for service interruption
Int dmachan: the DMA channel used by the insert operation.
Write ISFP to the interrupt service table ist. If ist is in external Ram, CPU replication replaces DMA, And the DMA is-1
In-chip RAM, ist uses the DMA mode, which is 0, 1, and 2. Users must ensure that the DMA channel is valid during function calls.

VII. statistics module STS
(1) void sts_add (sts_obj * STS, lgint value)
Use the data we provide to update parameters such as total, count, and Max of STS statistic objects.
Input a 32-bit parameter, count plus 1, total accumulate passed 32-bit parameter, Max record the maximum value of the transferred Parameter
(2) void sts_delta (sta_obj * STS, lgint value)
Each object contains an initial value specified by the configuration file or set by the sts_set function.
Sts_delta calculates the difference between the current passed parameter and the previous initial value, and then calls sts_add to update the accumulated statistical value.
Generally used together with sts_set
Eg:
Sts_set (& STs, clk_gethtime ());
Sts_delta (& STs, clk_gethtime ());
(3) void sts_reset (sts_obj * STS)
Reset the accumulate value in the statistical object. Set count and total to 0. Max to the maximum negative value.
(4) void sts_set (sts_obj * STS, lgint value)
Monitoring or statistical program execution time

8. statistical module TRC
(1) trc_logclk logging timer interruption
(2) The start of the trc_logprd log recording cycle time slot and Cycle Function
(3) trc_logswi logging the startup and completion of software interruptions
(4) The trc_logtsk logging task is in the preparation, start, stop, continue, stop, and other events.
(5) collect Hwi statistics from trc_stshwi
(6) count the frames of the trc_stspip write pipeline and read Pipeline
(7) statistics on the number of CLK time slots during trc_stsprd execution
(8) trc_stsswi SWI execution time statistics
(9) Statistics on trc_ststsk tsk execution time should be collected from tsk preparation to tsk deltatime calling.
(10) Call trc_user0 and trc_user1 and trc_query together with the device that executes and ignores the result
(11) trc_gblhost performs all the hidden instruments. This bit can start or stop collecting all enabled tracing types.
(12) trc_gbltarg performs all the hidden instruments. This bit can only be set by the target program.

IX. Task Management tsk Task Management Module
(1) void tsk_checkstacks (tsk_handle oldtask, tsk_handle newtask)
Whether it is a new task or an old task, if the last position of the stack is not identified by rg_stackstamp, tsk_checkstacks will
The error sys_abort may occur because the previous Task Stack Overflow or invalid storage occupies the stack of the new task.
Generally, tsk_checkstacks (tsk_self (), tsk_self () is used to check the stack.
Define the switch function so that the stack check function is automatically called during Task Switching:
Void myswitchfxn (tsk_handle oldtask, tsk_handle newtask)
{

...
Tsk_checkstacks (oldtask, newtask );
...
}
(2) tsk_handle task = tsk_create (FXN, tsk_attrs * ATTR, Arg [Arg,]...)
Create a task object that calls the function FXN, return the handle of the new object, and return NULL if a failure occurs.
The call to this function is a dynamic creation, while the creation in the configuration tool is a static creation, the effect is the same.
Static task object. The creation function is automatically called in the bios_start function. The bios_start function is after the main function,
Run the SDK before the background IDL loop. The dynamically created task is in ready state. Function parameters cannot exceed 8.
When the task object function FXN returns, the tsk_exit function is automatically called.
Resolution: tsk_attrs * attrs task parameter pointer
Struct tsk_attrs {
Int priority;
PTR stack;
UNS stacksize;
# Ifdef _ 64 _ // imitate c55 series. To check
UNS sysstacksize;
# Endif
UNS stackseg;
PTR environ;
String name;
Bool exitflag;
}
(3) void tsk_delete (tsk_handle task)
Delete the task from all internal queues and call mem_free to release the task object and stack.
Only tasks in the terminated state can be deleted. You can also call the delete hook function.
Void mydeletefxn (tsk_handle task );
(4) void tsk_deltatime (tsk_handle task)
Time Difference from task preparation to function execution
If this function is not called, the statistics object will not be updated even if the task statistics accumulator option is enabled.
Generally, the tsk_settime function is used to record the start point. This function records the end point.
(5) void tsk_settime (tsk_handle task)
Set the initial statistical value
Void task ()
{
-- Do some startup work --
Tsk_settime (tsk_self );
For (;;){
Sio_get (...);
-- Process data --
Tsk_deltatime (tsk_self );
}
}
If streaming Io is not ready, this API function will block (BLOCKED) and switch tasks. After a period of time, streaming Io data
Ready. At this time, the ready signal is sent, and the task is set to ready. At this time, tsk_settime record the time.
(6) void tsk_disable (void)
Disable the kernel scheduling mechanism globally and run busy-shutting-down. Only the current task is feasible, and all other tasks are forbidden.
This function does not prohibit interruption, so you need to call this function before the interruption starts to ensure that task switching does not occur when the interruption occurs.
It can be nested, but if you call tsk_disable several times, you have to call tsk_enable several times accordingly.
(7) void tsk_enable (void)
Enable kernel scheduling globally
(8) void tsk_exit (void)
Terminate the current task. If all tasks are terminated, the DSP/BIOS calls sys_exit to terminate the program.
This function is automatically called whenever a task returns from a top-level function.
You can register an exit helper function void myexitfxn (void)
In this way, the auxiliary function is called before the task is set to tsk_terminated mode.
(9) PTR environ = tsk_getenv (tsk_handle task)
Returns the task environment pointer pointing to the structure of a global attribute that can be accessed by the task.
If the program defines multiple hook objects, the hook_getenv function can obtain the set environment pointer.
(10) void tsk_setenv (tsk_handle task, PTR environ)
Sets the environment pointer of the specified task.
If the program defines multiple hook objects, the hook_setenv function can set an independent environment pointer for the combination of each hook and task object.
(11) int errno = tsk_geterr (tsk_handle task)
Each task object has a storage unit containing the task error code. The initial value is sys_ OK.
(12) void tsk_seterr (tsk_handle task, int errno)
Change error code
(13) string name = tsk_getname (tsk_handle task)
The name of the returned task.
For static objects, allocate Task Name on target must be enabled.
For dynamic objects, tsk_getname returns the attrs. Name field
(14) int priority = tsk_getpri (tsk_handle task)
Return priority
(15) int oldpri = tsk_setpri (tsk_handle task, int newpri)
Set priority
Set priority for tsk_blocked status tasks, the priority is changed, but the status is not changed;
For tasks in the tsk_ready status, the running status may change.
(16) sts_handle STS = tsk_getsts (tsk_handle task)
Get the statistics object handle for viewing data
(17) void tsk_sleep (UNS nticks)
The number of times the task is paused. The number of times this clock may be less than the actual pause clock (alarm clock)
(18) void tsk_itick (void)
Add 1 to the alarm clock so that the task paused by the tsk_sleep or sem_pend function can be restored to ready.
Some paused tasks may time out as the alarm clock increases to get ready.
(19) void tsk_tick (void)
Add 1 to the alarm clock so that the task paused by the tsk_sleep or sem_pend function can be restored to ready.
Some paused tasks may time out as the alarm clock increases to get ready.
It can be called in the interrupt service program and the current task. The latter is very useful in controlling timeout.
(20) uns currtime = tsk_time (void)
Returns the current value of the system alarm clock. (Only One approximate system clock can be obtained due to latency)
(21) tsk_handle currtask = tsk_self (void)
Returns the handle of the current task object.
(22) void tsk_stat (tsk_handle task, tsk_stat * statbuf)
Returns the attribute parameters and status information of a task.
Struct tsk_stat {
Tsk_attrs attrs; // task Parameters
Tsk_mode mode; // task execution mode
PTR sp; // current stack pointer of the task
Uns used; // The maximum value used by the Task Stack
}
Note: tasks have a lower priority than Hwi and SWI interrupt. Therefore, when a task is interrupted, tsk_running is returned,
The task continues to run after the interruption is completed.
(23) void tsk_yield (void)
Force Task Switching. Note that tasks can be interrupted. However, tasks must be switched between them, that is,
Even if a high-priority task is ready, it cannot be executed unless it is switched.
This function is used for synchronization between tasks.

10. Task Management hook function Management Module
The hook module administrator is a group of objects that involve hook functions. During DSP/BIOS initialization, each hook object is assigned a digital identifier.
Each hook module has an initialization function that runs before the hook function is called. When the initialization function is called, the DSP/BIOS Kernel
The identifier of the hook object is passed to the initialization function as a parameter.
The data of the hook object is stored in. BSS.
 
The relationship between hook attribute settings is as follows:
Initialization function: tsk_create
Delete function: tsk_delete
Exit function: tsk_exit
In addition, there are call switch functions, switch functions, call ready functions, and ready functions.
 
11. DSPs/BIOS background management IDL Module
The IDL module manages the lowest level of threads in an application. In addition to functions compiled by the user, the IDL module executes DSP/bios api functions,
The DSP/BIOS kernel uses these functions to handle host communication and CPU load computing.
When the RTA control panel of the DSP/BIOS analysis tool is activated, the application contains an IDL object of idl_cpuload, which calls
The CPU usage function. In addition, the linl_datapump function processes data exchange with the host in the background, such as rtdx and HST.
The execution status chart of the program module is the result of rta_dispatch function processing.
(1) void idl_run (void)
Call all IDL functions defined in the IDL module in turn, and return after all IDL functions are executed once. Because the IDL functions have completed the host and target
The data exchange function of the system. All IDL functions must be called regularly.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.