OpenAMP: env: remove unused env funcitons
authorWendy Liang <jliang@xilinx.com>
Mon, 15 Aug 2016 22:03:05 +0000 (15:03 -0700)
committerWendy Liang <jliang@xilinx.com>
Thu, 13 Oct 2016 05:01:48 +0000 (22:01 -0700)
Remove the following env functions which have been replaced
by the libmetal functions:
 * locking
 * va to pa conversion and vice versa
 * interrupt handling

Signed-off-by: Wendy Liang <jliang@xilinx.com>
lib/include/openamp/env.h
lib/system/generic/env.c

index eeaccb43df923dd97d43e9fd2febde863224bc1d..a9fe72d4e64b868a4f921b8e93c6532a314089ec 100644 (file)
 
 #include <stdio.h>
 
-/**
- * -------------------------------------------------------------------------
- *
- * Dynamic memory management functions. The parameters
- * are similar to standard c functions.
- *
- *-------------------------------------------------------------------------
- **/
-
-/**
- * env_allocate_memory
- *
- * Allocates memory with the given size.
- *
- * @param size - size of memory to allocate
- *
- * @return - pointer to allocated memory
- */
-void *env_allocate_memory(unsigned int size);
-
-/**
- * env_free_memory
- *
- * Frees memory pointed by the given parameter.
- *
- * @param ptr - pointer to memory to free
- */
-void env_free_memory(void *ptr);
-
-/**
- *-----------------------------------------------------------------------------
- *
- *  Functions to convert physical address to virtual address and vice versa.
- *
- *-----------------------------------------------------------------------------
- */
-
-/**
- * env_map_vatopa
- *
- * Converts logical address to physical address
- *
- * @param address - pointer to logical address
- *
- * @return  - physical address
- */
-unsigned long env_map_vatopa(void *address);
-
-/**
- * env_map_patova
- *
- * Converts physical address to logical address
- *
- * @param address - pointer to physical address
- *
- * @return  - logical address
- *
- */
-void *env_map_patova(unsigned long address);
-
-/**
- *-----------------------------------------------------------------------------
- *
- *  Abstractions for OS lock primitives.
- *
- *-----------------------------------------------------------------------------
- */
-
-/**
- * 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.
- *
- * @param lock  - pointer to created sync lock object
- * @param state - initial state , lock or unlocked
- *
- * @returns - status of function execution
- */
-#define LOCKED                 0
-#define UNLOCKED               1
-
-int env_create_sync_lock(void **lock, int state);
-
-/**
- * env_create_sync_lock
- *
- * Deletes given sync lock object.
- *
- * @param lock  - sync lock to delete.
- *
- */
-
-void env_delete_sync_lock(void *lock);
-
-/**
- * env_acquire_sync_lock
- *
- * Tries to acquire the sync lock.
- *
- * @param lock  - sync lock to acquire.
- */
-void env_acquire_sync_lock(void *lock);
-
-/**
- * env_release_sync_lock
- *
- * Releases synchronization lock.
- *
- * @param lock  - sync lock to release.
- */
-void env_release_sync_lock(void *lock);
-
 /**
  * env_sleep_msec
  *
@@ -185,119 +71,6 @@ void env_release_sync_lock(void *lock);
  */
 void env_sleep_msec(int num_msec);
 
-/**
- * env_disable_interrupts
- *
- * Disables system interrupts
- *
- */
-void env_disable_interrupts();
-
-/**
- * env_restore_interrupts
- *
- * Enables system interrupts
- *
- */
-void env_restore_interrupts();
-
-/**
- * env_register_isr
- *
- * Registers interrupt handler for the given interrupt vector.
- *
- * @param vector - interrupt vector number
- * @param data   - private data
- * @param isr    - interrupt handler
- */
-
-void env_register_isr(int vector, void *data,
-                     void (*isr) (int vector, void *data));
-/**
- * env_register_isr_shared
- *
- * Registers interrupt handler for the given shared interrupt vector.
- *
- * @param vector - interrupt vector number
- * @param data   - private data
- * @param isr    - interrupt handler
- * @oaram name   - interrup handler name
- * @param shared - if the interrupt is a shared interrupt
- */
-
-void env_register_isr_shared(int vector, void *data,
-                     void (*isr) (int vector, void *data),
-                     char *name,
-                     int shared);
-
-void env_update_isr(int vector, void *data,
-                   void (*isr) (int vector, void *data),
-                   char *name,
-                   int shared);
-
-/**
- * env_enable_interrupt
- *
- * Enables the given interrupt.
- *
- * @param vector   - interrupt vector number
- * @param priority - interrupt priority
- * @param polarity - interrupt polarity
- */
-
-void env_enable_interrupt(unsigned int vector, unsigned int priority,
-                         unsigned int polarity);
-
-/**
- * env_disable_interrupt
- *
- * Disables the given interrupt.
- *
- * @param vector   - interrupt vector number
- */
-
-void env_disable_interrupt(unsigned int vector);
-
-/**
- * env_map_memory
- *
- * Enables memory mapping for given memory region.
- *
- * @param pa   - physical address of memory
- * @param va   - logical address of memory
- * @param size - memory size
- * param flags - flags for cache/uncached  and access type
- *
- * Currently only first byte of flag parameter is used and bits mapping is defined as follow;
- *
- * Cache bits
- * 0x0000_0001 = No cache
- * 0x0000_0010 = Write back
- * 0x0000_0100 = Write through
- * 0x0000_x000 = Not used
- *
- * Memory types
- *
- * 0x0001_xxxx = Memory Mapped
- * 0x0010_xxxx = IO Mapped
- * 0x0100_xxxx = Shared
- * 0x1000_xxxx = TLB
- */
-
-/* Macros for caching scheme used by the shared memory */
-#define UNCACHED                            (1 << 0)
-#define WB_CACHE                            (1 << 1)
-#define WT_CACHE                            (1 << 2)
-
-/* Memory Types */
-#define MEM_MAPPED                          (1 << 4)
-#define IO_MAPPED                           (1 << 5)
-#define SHARED_MEM                          (1 << 6)
-#define TLB_MEM                             (1 << 7)
-
-void env_map_memory(unsigned int pa, unsigned int va, unsigned int size,
-                   unsigned int flags);
-
 /**
  * env_get_timestamp
  *
@@ -307,22 +80,4 @@ void env_map_memory(unsigned int pa, unsigned int va, unsigned int size,
  */
 unsigned long long env_get_timestamp(void);
 
-/**
- * env_disable_cache
- * 
- * Disables system caches.
- *
- */
-void env_disable_cache(void);
-
-/**
- * env_flush_invalidate_all_caches
- * 
- * Flush and Invalidate all caches.
- *
- */
-void env_flush_invalidate_all_caches(void);
-
-typedef void LOCK;
-
 #endif                         /* _ENV_H_ */
index cd36edd993dfa26c62215d0529b64656bd40c65e..daf445263a0dd48e892ee24fb670f0082f7cccdf 100755 (executable)
  **************************************************************************/
 
 #include "openamp/env.h"
-#include "machine.h"
-#include "machine_system.h"
-
 #include <stdlib.h>
 #include <string.h>
 
-static void acquire_spin_lock(void *plock);
-static void release_spin_lock(void *plock);
-
-/* Max supprted ISR counts */
-#define ISR_COUNT                       4
-/**
- * Structure to keep track of registered ISR's.
- */
-struct isr_info {
-       int vector;
-       int priority;
-       int type;
-       char *name;
-       int shared;
-       void *data;
-       void (*isr)(int vector, void *data);
-};
-struct isr_info isr_table[ISR_COUNT];
-static int intr_count = 0;
-/* Flag to show status of global interrupts. 0 for disabled and 1 for enabled. This
- * is added to prevent recursive global interrupts enablement/disablement.
- */
-static int intr_enable_flag = 1;
-
-/**
- * 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_map_vatopa - implementation
- *
- * @param address
- */
-unsigned long env_map_vatopa(void *address)
-{
-       return platform_vatopa(address);
-}
-
-/**
- * env_map_patova - implementation
- *
- * @param address
- */
-void *env_map_patova(unsigned long address)
-{
-       return platform_patova(address);
-}
-
-/**
- * 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
  *
@@ -183,187 +57,6 @@ void env_sleep_msec(int num_msec)
 
 }
 
-/**
- * env_disable_interrupts
- *
- * Disables system interrupts
- *
- */
-void env_disable_interrupts()
-{
-       if (intr_enable_flag == 1) {
-               disable_global_interrupts();
-               intr_enable_flag = 0;
-       }
-}
-
-/**
- * env_restore_interrupts
- *
- * Enables system interrupts
- *
- */
-void env_restore_interrupts()
-{
-       if (intr_enable_flag == 0) {
-               restore_global_interrupts();
-               intr_enable_flag = 1;
-       }
-}
-
-/**
- * env_register_isr_shared
- *
- * Registers interrupt handler for the given interrupt vector.
- *
- * @param vector - interrupt vector number
- * @param isr    - interrupt handler
- * @param name   - interrupt name
- * @param shared - if the interrupt is shared or not
- */
-void env_register_isr_shared(int vector, void *data,
-                     void (*isr) (int vector, void *data),
-                     char *name,
-                     int shared)
-{
-       env_disable_interrupts();
-
-       if (intr_count < ISR_COUNT) {
-               /* Save interrupt data */
-               isr_table[intr_count].vector = vector;
-               isr_table[intr_count].data = data;
-               isr_table[intr_count].name = name;
-               isr_table[intr_count].shared = shared;
-               isr_table[intr_count++].isr = isr;
-       }
-
-       env_restore_interrupts();
-}
-/**
- * env_register_isr
- *
- * Registers interrupt handler for the given interrupt vector.
- *
- * @param vector - interrupt vector number
- * @param isr    - interrupt handler
- */
-void env_register_isr(int vector, void *data,
-                     void (*isr) (int vector, void *data))
-{
-       env_register_isr_shared(vector, data, isr, 0, 0);
-}
-
-void env_update_isr(int vector, void *data,
-                   void (*isr) (int vector, void *data),
-                   char *name,
-                   int shared)
-{
-       int idx;
-       struct isr_info *info;
-
-       env_disable_interrupts();
-
-       for (idx = 0; idx < ISR_COUNT; idx++) {
-               info = &isr_table[idx];
-               if (info->vector == vector) {
-                       if (name && strcmp(info->name, name)) {
-                               continue;
-                       }
-                       info->data = data;
-                       info->isr = isr;
-                       info->shared = shared;
-                       break;
-               }
-       }
-
-       env_restore_interrupts();
-}
-
-/**
- * env_enable_interrupt
- *
- * Enables the given interrupt
- *
- * @param vector   - interrupt vector number
- * @param priority - interrupt priority
- * @param polarity - interrupt polarity
- */
-
-void env_enable_interrupt(unsigned int vector, unsigned int priority,
-                         unsigned int polarity)
-{
-       int idx;
-
-       env_disable_interrupts();
-
-       for (idx = 0; idx < ISR_COUNT; idx++) {
-               if (isr_table[idx].vector == (int)vector) {
-                       isr_table[idx].priority = priority;
-                       isr_table[idx].type = polarity;
-                       platform_interrupt_enable(vector, polarity, priority);
-                       break;
-               }
-       }
-
-       env_restore_interrupts();
-}
-
-/**
- * env_disable_interrupt
- *
- * Disables the given interrupt
- *
- * @param vector   - interrupt vector number
- */
-
-void env_disable_interrupt(unsigned int vector)
-{
-       platform_interrupt_disable(vector);
-}
-
-/**
- * env_map_memory
- *
- * Enables memory mapping for given memory region.
- *
- * @param pa   - physical address of memory
- * @param va   - logical address of memory
- * @param size - memory size
- * param flags - flags for cache/uncached  and access type
- */
-
-void env_map_memory(unsigned int pa, unsigned int va, unsigned int size,
-                   unsigned int flags)
-{
-       platform_map_mem_region(va, pa, size, flags);
-}
-
-/**
- * env_disable_cache
- *
- * Disables system caches.
- *
- */
-
-void env_disable_cache(void)
-{
-       platform_cache_all_flush_invalidate();
-       platform_cache_disable();
-}
-
-/**
- * env_flush_invalidate_all_caches
- *
- * Flush and Invalidate all caches.
- *
- */
-
-void env_flush_invalidate_all_caches(void)
-{
-       platform_cache_all_flush_invalidate();
-}
-
-
 /**
  * 
  * env_get_timestamp
@@ -379,48 +72,3 @@ unsigned long long env_get_timestamp(void)
        return 0;
 }
 
-/*========================================================= */
-/* Util data / functions for BM */
-
-void bm_env_isr(int vector)
-{
-       int idx;
-       struct isr_info *info;
-
-       env_disable_interrupt(vector);
-       for (idx = 0; idx < ISR_COUNT; idx++) {
-               info = &isr_table[idx];
-               if (info->vector == vector) {
-                       info->isr(info->vector, info->data);
-                       env_enable_interrupt(info->vector, info->priority,
-                                            info->type);
-                       if (!info->shared)
-                               break;
-               }
-       }
-}
-
-/**
- *
- * acquire_spin_lock
- *
- */
-static void acquire_spin_lock(void *plock)
-{
-       const unsigned int lockVal = 0;
-       volatile unsigned int retVal;
-
-       do {
-               retVal = xchg(plock, lockVal);
-       } while (retVal == lockVal);
-}
-
-/**
- * release_spin_lock
- */
-static void release_spin_lock(void *plock)
-{
-       MEM_BARRIER();
-
-       xchg(plock, 1);
-}