sw_services: xilopenamp: Added freertos support to openamp library
Signed-off-by: Kinjal Pravinbhai Patel <patelki@xilinx.com> Acked-by: Anirudha Sarangi <anirudh@xilinx.com>
This commit is contained in:
parent
396482866c
commit
7cec02a399
4 changed files with 321 additions and 137 deletions
|
@ -43,7 +43,7 @@ OPTION psf_version = 2.1;
|
|||
BEGIN LIBRARY xilopenamp
|
||||
OPTION DRC = openamp_drc;
|
||||
OPTION COPYFILES = all;
|
||||
OPTION REQUIRES_OS = (standalone);
|
||||
OPTION REQUIRES_OS = (standalone, freertos821_xilinx);
|
||||
OPTION APP_LINKER_FLAGS = "-Wl,--start-group,-lxil,-lxilopenamp,-lgcc,-lc,--end-group";
|
||||
OPTION DESC = "Xilinx openamp Library ";
|
||||
OPTION VERSION = 1.0;
|
||||
|
|
|
@ -65,6 +65,24 @@ proc execs_generate {libhandle} {
|
|||
}
|
||||
|
||||
proc xgen_opts_file {libhandle} {
|
||||
set oslist [hsi::get_os];
|
||||
|
||||
if { [llength $oslist] != 1 } {
|
||||
return 0;
|
||||
}
|
||||
set os [lindex $oslist 0];
|
||||
set config_inc [::hsi::utils::open_include_file "amp_os.h"]
|
||||
puts $config_inc "/******************************************************************/"
|
||||
puts $config_inc ""
|
||||
puts $config_inc "/* Operating System definition */"
|
||||
if { $os == "freertos821_xilinx" } {
|
||||
puts $config_inc "#define USE_FREERTOS TRUE"
|
||||
} else {
|
||||
puts $config_inc "#define USE_BAREMETAL TRUE"
|
||||
}
|
||||
puts $config_inc ""
|
||||
puts $config_inc "/******************************************************************/"
|
||||
close $config_inc
|
||||
# Copy the include files to the include directory
|
||||
set srcdir src
|
||||
set dstdir [file join .. .. include]
|
||||
|
@ -73,8 +91,6 @@ proc xgen_opts_file {libhandle} {
|
|||
if { ! [file exists $dstdir] } {
|
||||
file mkdir $dstdir
|
||||
}
|
||||
puts "its openamp"
|
||||
|
||||
# Get list of files in the srcdir
|
||||
set sources [glob -join $srcdir *.h]
|
||||
|
||||
|
|
434
ThirdParty/sw_services/xilopenamp/src/bm_env.c
vendored
434
ThirdParty/sw_services/xilopenamp/src/bm_env.c
vendored
|
@ -86,28 +86,6 @@ int env_init() {
|
|||
int env_deinit() {
|
||||
return 0;
|
||||
}
|
||||
/**
|
||||
* env_allocate_memory - implementation
|
||||
*
|
||||
* @param size
|
||||
*/
|
||||
void *env_allocate_memory(unsigned int size)
|
||||
{
|
||||
return (malloc(size));
|
||||
}
|
||||
|
||||
/**
|
||||
* env_free_memory - implementation
|
||||
*
|
||||
* @param ptr
|
||||
*/
|
||||
void env_free_memory(void *ptr)
|
||||
{
|
||||
if (ptr != NULL)
|
||||
{
|
||||
free(ptr);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -217,116 +195,6 @@ void *env_map_patova(unsigned long address)
|
|||
{
|
||||
return platform_patova(address);
|
||||
}
|
||||
|
||||
/**
|
||||
* env_create_mutex
|
||||
*
|
||||
* Creates a mutex with the given initial count.
|
||||
*
|
||||
*/
|
||||
int env_create_mutex(void **lock, int count)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* env_delete_mutex
|
||||
*
|
||||
* Deletes the given lock
|
||||
*
|
||||
*/
|
||||
void env_delete_mutex(void *lock)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* env_lock_mutex
|
||||
*
|
||||
* Tries to acquire the lock, if lock is not available then call to
|
||||
* this function will suspend.
|
||||
*/
|
||||
void env_lock_mutex(void *lock)
|
||||
{
|
||||
env_disable_interrupts();
|
||||
}
|
||||
|
||||
/**
|
||||
* env_unlock_mutex
|
||||
*
|
||||
* Releases the given lock.
|
||||
*/
|
||||
|
||||
void env_unlock_mutex(void *lock)
|
||||
{
|
||||
env_restore_interrupts();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* env_create_sync_lock
|
||||
*
|
||||
* Creates a synchronization lock primitive. It is used
|
||||
* when signal has to be sent from the interrupt context to main
|
||||
* thread context.
|
||||
*/
|
||||
int env_create_sync_lock(void **lock , int state) {
|
||||
int *slock;
|
||||
|
||||
slock = (int *)malloc(sizeof(int));
|
||||
if(slock){
|
||||
*slock = state;
|
||||
*lock = slock;
|
||||
}
|
||||
else{
|
||||
*lock = NULL;
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* env_delete_sync_lock
|
||||
*
|
||||
* Deletes the given lock
|
||||
*
|
||||
*/
|
||||
void env_delete_sync_lock(void *lock){
|
||||
if(lock)
|
||||
free(lock);
|
||||
}
|
||||
|
||||
/**
|
||||
* env_acquire_sync_lock
|
||||
*
|
||||
* Tries to acquire the lock, if lock is not available then call to
|
||||
* this function waits for lock to become available.
|
||||
*/
|
||||
void env_acquire_sync_lock(void *lock){
|
||||
acquire_spin_lock(lock);
|
||||
}
|
||||
|
||||
/**
|
||||
* env_release_sync_lock
|
||||
*
|
||||
* Releases the given lock.
|
||||
*/
|
||||
|
||||
void env_release_sync_lock(void *lock){
|
||||
release_spin_lock(lock);
|
||||
}
|
||||
|
||||
/**
|
||||
* env_sleep_msec
|
||||
*
|
||||
* Suspends the calling thread for given time , in msecs.
|
||||
*/
|
||||
|
||||
void env_sleep_msec(int num_msec)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* env_disable_interrupts
|
||||
*
|
||||
|
@ -500,12 +368,311 @@ void bm_env_isr(int vector) {
|
|||
info = &isr_table[idx];
|
||||
if(info->vector == vector)
|
||||
{
|
||||
info->isr(info->vector , info->data);
|
||||
info->isr(info->vector , info->data, 0);
|
||||
env_enable_interrupt(info->vector , info->priority, info->type);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
#ifdef USE_FREERTOS
|
||||
/**
|
||||
* env_allocate_memory - implementation
|
||||
*
|
||||
* @param size
|
||||
*/
|
||||
void *env_allocate_memory(unsigned int size)
|
||||
{
|
||||
return (pvPortMalloc(size));
|
||||
}
|
||||
|
||||
/**
|
||||
* env_free_memory - implementation
|
||||
*
|
||||
* @param ptr
|
||||
*/
|
||||
void env_free_memory(void *ptr)
|
||||
{
|
||||
if (ptr != NULL)
|
||||
{
|
||||
vPortFree(ptr);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* env_create_mutex
|
||||
*
|
||||
* Creates a mutex with the given initial count.
|
||||
*
|
||||
*/
|
||||
int env_create_mutex(void **lock, int count)
|
||||
{
|
||||
*lock = xSemaphoreCreateMutex();
|
||||
if(*lock != NULL)
|
||||
return 0;
|
||||
else
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* env_delete_mutex
|
||||
*
|
||||
* Deletes the given lock
|
||||
*
|
||||
*/
|
||||
void env_delete_mutex(void *lock)
|
||||
{
|
||||
vSemaphoreDelete(lock );
|
||||
}
|
||||
|
||||
/**
|
||||
* env_lock_mutex
|
||||
*
|
||||
* Tries to acquire the lock, if lock is not available then call to
|
||||
* this function will suspend.
|
||||
*/
|
||||
extern unsigned int xInsideISR;
|
||||
void env_lock_mutex(void *lock)
|
||||
{
|
||||
portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE;
|
||||
if( xInsideISR != pdFALSE ) { /* define it as a global var and mark in ISR */
|
||||
xSemaphoreTakeFromISR(lock, &xHigherPriorityTaskWoken );
|
||||
portYIELD_FROM_ISR(xHigherPriorityTaskWoken);
|
||||
}
|
||||
else
|
||||
xSemaphoreTake( lock, portMAX_DELAY );
|
||||
}
|
||||
|
||||
/**
|
||||
* env_unlock_mutex
|
||||
*
|
||||
* Releases the given lock.
|
||||
*/
|
||||
void env_unlock_mutex(void *lock)
|
||||
{
|
||||
portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE;
|
||||
if( xInsideISR != pdFALSE ) {
|
||||
xSemaphoreGiveFromISR( lock, &xHigherPriorityTaskWoken );
|
||||
|
||||
portYIELD_FROM_ISR(xHigherPriorityTaskWoken);
|
||||
}
|
||||
else
|
||||
xSemaphoreGive(lock );
|
||||
}
|
||||
|
||||
/**
|
||||
* env_create_sync_lock
|
||||
*
|
||||
* Creates a synchronization lock primitive. It is used
|
||||
* when signal has to be sent from the interrupt context to main
|
||||
* thread context.
|
||||
*/
|
||||
int env_create_sync_lock(void **lock , int state) {
|
||||
|
||||
int xReturn = 0;
|
||||
*lock = xSemaphoreCreateBinary();
|
||||
if( *lock != NULL )
|
||||
{
|
||||
xReturn = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
xReturn = 0;
|
||||
}
|
||||
return xReturn;
|
||||
}
|
||||
|
||||
/**
|
||||
* env_delete_sync_lock
|
||||
*
|
||||
* Deletes the given lock
|
||||
*
|
||||
*/
|
||||
void env_delete_sync_lock(void *lock){
|
||||
vSemaphoreDelete(lock);
|
||||
}
|
||||
|
||||
/**
|
||||
* env_acquire_sync_lock
|
||||
*
|
||||
* Tries to acquire the lock, if lock is not available then call to
|
||||
* this function waits for lock to become available.
|
||||
*/
|
||||
void env_acquire_sync_lock(void *lock){
|
||||
|
||||
unsigned long ulReturn = 0;
|
||||
portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE;
|
||||
if( xInsideISR != pdFALSE ) {
|
||||
if( xSemaphoreTakeFromISR( lock, &xHigherPriorityTaskWoken ) == pdTRUE )
|
||||
portYIELD_FROM_ISR(xHigherPriorityTaskWoken);
|
||||
} else {
|
||||
xSemaphoreTake( lock, portMAX_DELAY );
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* env_release_sync_lock
|
||||
*
|
||||
* Releases the given lock.
|
||||
*/
|
||||
void env_release_sync_lock(void *lock){
|
||||
portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE;
|
||||
if( xInsideISR != pdFALSE ) {
|
||||
xSemaphoreGiveFromISR(lock, &xHigherPriorityTaskWoken );
|
||||
|
||||
portYIELD_FROM_ISR(xHigherPriorityTaskWoken);
|
||||
}
|
||||
else
|
||||
xSemaphoreGive(lock );
|
||||
}
|
||||
|
||||
/**
|
||||
* env_sleep_msec
|
||||
*
|
||||
* Suspends the calling thread for given time , in msecs.
|
||||
*/
|
||||
|
||||
void env_sleep_msec(int num_msec)
|
||||
{
|
||||
/* Block for 500ms. */
|
||||
int xDelay;
|
||||
xDelay = num_msec / portTICK_PERIOD_MS;
|
||||
if((num_msec % portTICK_PERIOD_MS)!=0)
|
||||
xDelay++;
|
||||
vTaskDelay( xDelay );
|
||||
|
||||
}
|
||||
#else
|
||||
/**
|
||||
* env_allocate_memory - implementation
|
||||
*
|
||||
* @param size
|
||||
*/
|
||||
void *env_allocate_memory(unsigned int size)
|
||||
{
|
||||
return (malloc(size));
|
||||
}
|
||||
|
||||
/**
|
||||
* env_free_memory - implementation
|
||||
*
|
||||
* @param ptr
|
||||
*/
|
||||
void env_free_memory(void *ptr)
|
||||
{
|
||||
if (ptr != NULL)
|
||||
{
|
||||
free(ptr);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* env_create_mutex
|
||||
*
|
||||
* Creates a mutex with the given initial count.
|
||||
*
|
||||
*/
|
||||
int env_create_mutex(void **lock, int count)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* env_delete_mutex
|
||||
*
|
||||
* Deletes the given lock
|
||||
*
|
||||
*/
|
||||
void env_delete_mutex(void *lock)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* env_lock_mutex
|
||||
*
|
||||
* Tries to acquire the lock, if lock is not available then call to
|
||||
* this function will suspend.
|
||||
*/
|
||||
void env_lock_mutex(void *lock)
|
||||
{
|
||||
env_disable_interrupts();
|
||||
}
|
||||
|
||||
/**
|
||||
* env_unlock_mutex
|
||||
*
|
||||
* Releases the given lock.
|
||||
*/
|
||||
|
||||
void env_unlock_mutex(void *lock)
|
||||
{
|
||||
env_restore_interrupts();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* env_create_sync_lock
|
||||
*
|
||||
* Creates a synchronization lock primitive. It is used
|
||||
* when signal has to be sent from the interrupt context to main
|
||||
* thread context.
|
||||
*/
|
||||
int env_create_sync_lock(void **lock , int state) {
|
||||
int *slock;
|
||||
|
||||
slock = (int *)malloc(sizeof(int));
|
||||
if(slock){
|
||||
*slock = state;
|
||||
*lock = slock;
|
||||
}
|
||||
else{
|
||||
*lock = NULL;
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* env_delete_sync_lock
|
||||
*
|
||||
* Deletes the given lock
|
||||
*
|
||||
*/
|
||||
void env_delete_sync_lock(void *lock){
|
||||
if(lock)
|
||||
free(lock);
|
||||
}
|
||||
|
||||
/**
|
||||
* env_acquire_sync_lock
|
||||
*
|
||||
* Tries to acquire the lock, if lock is not available then call to
|
||||
* this function waits for lock to become available.
|
||||
*/
|
||||
void env_acquire_sync_lock(void *lock){
|
||||
acquire_spin_lock(lock);
|
||||
}
|
||||
|
||||
/**
|
||||
* env_release_sync_lock
|
||||
*
|
||||
* Releases the given lock.
|
||||
*/
|
||||
|
||||
void env_release_sync_lock(void *lock){
|
||||
release_spin_lock(lock);
|
||||
}
|
||||
|
||||
/**
|
||||
* env_sleep_msec
|
||||
*
|
||||
* Suspends the calling thread for given time , in msecs.
|
||||
*/
|
||||
|
||||
void env_sleep_msec(int num_msec)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
static inline unsigned int xchg(void* plock, unsigned int lockVal)
|
||||
{
|
||||
|
@ -556,3 +723,4 @@ static void release_spin_lock(void *plock)
|
|||
|
||||
xchg(plock, 1);
|
||||
}
|
||||
#endif
|
|
@ -45,7 +45,7 @@ struct isr_info {
|
|||
int priority;
|
||||
int type;
|
||||
void *data;
|
||||
void (*isr)(int vector, void *data);
|
||||
void (*isr)(int vector, void *data, unsigned int intr_status);
|
||||
};
|
||||
|
||||
struct firmware_info {
|
||||
|
|
Loading…
Add table
Reference in a new issue