1 #ifndef _VG_LITE_OS_H 2 #define _VG_LITE_OS_H 3 4 #include <stdint.h> 5 6 #if !defined(VG_DRIVER_SINGLE_THREAD) 7 8 #define vg_lite_os_set_event_state(event, state) (event)->signal = state 9 10 #define vg_lite_os_event_state(event) (event)->signal 11 12 #define vg_lite_os_config_event(event, sem_id, state) \ 13 { \ 14 (event)->semaphore_id = sem_id; \ 15 (event)->signal = state; \ 16 } 17 18 typedef struct vg_lite_os_async_event 19 { 20 uint32_t semaphore_id; /*! The Id of the semaphore assigned to this event */ 21 int32_t signal; /*! The command buffer status */ 22 } 23 vg_lite_os_async_event_t; 24 25 int32_t vg_lite_os_init_tls_array(void); 26 27 void vg_lite_os_deinit_tls_array(void); 28 29 /*! 30 @brief Set the value in a task’s thread local storage array. 31 */ 32 int32_t vg_lite_os_set_tls(void* tls); 33 34 /*! 35 @brief Get the current task’s thread local storage array. 36 */ 37 void * vg_lite_os_get_tls( ); 38 39 #endif /* not defined(VG_DRIVER_SINGLE_THREAD) */ 40 41 /*! 42 @brief Memory allocate. 43 */ 44 void * vg_lite_os_malloc(uint32_t size); 45 46 /*! 47 @brief Memory free. 48 */ 49 void vg_lite_os_free(void * memory); 50 51 #if !defined(VG_DRIVER_SINGLE_THREAD) 52 /*! 53 @brief Reset the value in a task’s thread local storage array. 54 */ 55 void vg_lite_os_reset_tls(); 56 #endif /* not defined(VG_DRIVER_SINGLE_THREAD) */ 57 58 /*! 59 @brief sleep a number of milliseconds. 60 */ 61 void vg_lite_os_sleep(uint32_t msec); 62 63 /*! 64 @brief initialize the os parameters. 65 */ 66 int32_t vg_lite_os_initialize(); 67 68 /*! 69 @brief deinitialize the os parameters. 70 */ 71 void vg_lite_os_deinitialize(); 72 73 #if !defined(VG_DRIVER_SINGLE_THREAD) 74 /*! 75 @brief Mutex semaphore take. 76 */ 77 int32_t vg_lite_os_lock(); 78 79 /*! 80 @brief Mutex semaphore give. 81 */ 82 int32_t vg_lite_os_unlock(); 83 84 /*! 85 @brief Submit the current command buffer to the command queue. 86 */ 87 int32_t vg_lite_os_submit(uint32_t context, uint32_t physical, uint32_t offset, uint32_t size, vg_lite_os_async_event_t *event); 88 89 /*! 90 @brief Wait for the current command buffer to be executed. 91 */ 92 int32_t vg_lite_os_wait(uint32_t timeout, vg_lite_os_async_event_t *event); 93 #endif /* not defined(VG_DRIVER_SINGLE_THREAD) */ 94 95 /*! 96 @brief IRQ Handler. 97 */ 98 void vg_lite_os_IRQHandler(void); 99 100 /*! 101 @brief Wait until an interrupt from the VGLite graphics hardware has been received. 102 */ 103 int32_t vg_lite_os_wait_interrupt(uint32_t timeout, uint32_t mask, uint32_t * value); 104 105 #if !defined(VG_DRIVER_SINGLE_THREAD) 106 /*! 107 @brief 108 */ 109 int32_t vg_lite_os_init_event(vg_lite_os_async_event_t *event, 110 uint32_t semaphore_id, 111 int32_t state); 112 113 /*! 114 @brief 115 */ 116 int32_t vg_lite_os_delete_event(vg_lite_os_async_event_t *event); 117 118 /*! 119 @brief 120 */ 121 int32_t vg_lite_os_wait_event(vg_lite_os_async_event_t *event); 122 123 /*! 124 @brief 125 */ 126 int32_t vg_lite_os_signal_event(vg_lite_os_async_event_t *event); 127 128 /*! 129 @brief 130 */ 131 int8_t vg_lite_os_query_context_switch(uint32_t context); 132 133 #endif /* not defined(VG_DRIVER_SINGLE_THREAD) */ 134 #endif 135