osc_func.h 14.5 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453
/*****************************************************************************
*  Copyright Statement:
*  --------------------
*  This software is protected by Copyright and the information contained
*  herein is confidential. The software may not be copied and the information
*  contained herein may not be used or disclosed except with the written
*  permission of MediaTek Inc. (C) 2005
*
*  BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
*  THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
*  RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
*  AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
*  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
*  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
*  NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
*  SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
*  SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
*  THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
*  NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
*  SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
*
*  BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
*  LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
*  AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
*  OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
*  MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
*
*  THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
*  WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
*  LAWS PRINCIPLES.  ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
*  RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
*  THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
*
*****************************************************************************/

/*****************************************************************************
 *
 * Filename:
 * ---------
 *	osc_platform.h
 *
 * Project:
 * --------
 *   Maui
 *
 * Description:
 * ------------
 * Header file for OSCAR (Operating System Call Adapter) platform dependent
 *
 * Author:
 * -------
 * -------
 *
 *============================================================================
 *             HISTORY
 * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
 *------------------------------------------------------------------------------
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *
 * removed!
 * removed!
 * removed!
 *------------------------------------------------------------------------------
 * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
 *============================================================================
 ****************************************************************************/

#ifndef __OSC_FUNC_H__
#define __OSC_FUNC_H__


/* INCLUDES ***********************************************************************/

#ifndef __OSC_TYPE_H__
#error "Should inlucde osc_type.h first!"
#endif //__OSC_TYPE_H__

/* MACROS *************************************************************************/

#define  OSC_Print_Msg  osc_platform_print_msg

/* GLOBAL DATA DECLARATION ********************************************************/

extern osc_struct_dd_hdr g_osc_timer_list;

extern osc_type_u32      g_osc_system_tick;

/* PUBLIC FUNCTION DECLARATION ****************************************************/

extern void                osc_platform_print_msg ( const char *format, ... );

extern void                OSC_Register_ISR ( 
                                       osc_enum_isr_src  src_idx, 
                                       osc_type_func_ptr isr_func );

extern void                OSC_Activate_ISR ( osc_enum_isr_src isr_idx );

extern void                OSC_Sys_Schedule_Enable ( osc_type_u32 bEnable);

extern osc_type_s32				 OSC_Sys_if_lisr (void);

extern osc_enum_bool			 OSC_If_OSCAR_Context(void); 

/* ---------------------------------------------------
Thread API
----------------------------------------------------*/
extern osc_type_s32 OSC_Thread_Create (
         osc_type_u8          *name,
         osc_type_u32         *stack_addr,
         osc_enum_state       state_init,
         osc_type_u32         priority,
         osc_type_u32         time_slice,
         osc_type_u32         stack_size,
         osc_type_func_ptr    entry_func,
         osc_type_void_ptr    entry_param,
         osc_type_void_ptr    *thread_return );

extern osc_type_s32 OSC_Thread_Delete (
         osc_struct_thread    *thread );

extern osc_type_s32 OSC_Thread_Suspend (
         osc_struct_thread    *thread,
         osc_type_u32         timeout );

extern osc_type_s32 OSC_Thread_Resume (
         osc_struct_thread    *thread );

extern osc_type_s32 OSC_Thread_Config (
         osc_struct_thread    *thread,
         osc_type_u32         flag,
         osc_type_void_ptr    value,
         osc_type_u32         priority,
         osc_type_u32         time_slice,
         osc_type_u32         time_left );

extern osc_type_s32 OSC_Thread_Query (
         osc_struct_thread    *thread,
         osc_type_u32         flag,
         osc_type_void_ptr    value,
         osc_type_u8          *name,
         osc_type_u32         *state,
         osc_type_u32         *priority,
         osc_type_u32         *time_slice,
         osc_type_u32         *time_left,
         osc_type_u32         *stack_size,
         osc_type_u32         *stack_addr,
         osc_type_u32         *stack_ptr );

extern osc_type_s32 OSC_Thread_Current (
         osc_type_void_ptr    *thread );

extern osc_type_s32 OSC_Thread_Activate_HISR (
				 osc_struct_thread 		*thread );

/* ---------------------------------------------------
Timer API
----------------------------------------------------*/
extern osc_type_s32 OSC_Timer_Create (
         osc_type_u8          *name,
         osc_enum_state       state_init,
         osc_type_u32         time_default,
         osc_type_u32         time_periodic,
         osc_type_func_ptr    expiry_func,
         osc_type_void_ptr    expiry_param,
         osc_type_void_ptr    *timer_return );

extern osc_type_s32 OSC_Timer_Delete (
         osc_struct_timer     *timer );

extern osc_type_s32 OSC_Timer_Config (
         osc_struct_timer     *timer,
         osc_type_u32         flag,
         osc_type_void_ptr    value,
         osc_type_u32         state,
         osc_type_u32         time_default,
         osc_type_u32         time_periodic,
         osc_type_func_ptr    expiry_func,
         osc_type_void_ptr    expiry_param );


extern osc_type_s32 OSC_Timer_Query (
         osc_struct_timer     *timer,
         osc_type_u32         flag,
         osc_type_void_ptr    value,
         osc_type_u8          *name,
         osc_type_u32         *state,
         osc_type_u32         *time_default,
         osc_type_u32         *time_periodic,
         osc_type_u32         *time_left,
         osc_struct_dd_hdr    *waiting_list );

extern osc_type_s32 OSC_Get_Current_Tick (
         osc_type_u32         *current_tick );

extern osc_type_s32 OSC_Adjust_Tick_Unit (
         osc_type_u32         ms_unit );

extern osc_type_s32 OSC_Adjust_Tick_Time (
         osc_type_s32         delta );

extern void OSC_Timer_HISR ( void );

/* ---------------------------------------------------
Semaphore API
----------------------------------------------------*/
extern osc_type_s32 OSC_Semaphore_Create (
         osc_type_u8          *name,
         osc_type_u32         count,
         osc_type_void_ptr    *sema_return );

extern osc_type_s32 OSC_Semaphore_Delete (
         osc_struct_sema      *sema );

extern osc_type_s32 OSC_Semaphore_Take (
         osc_struct_sema      *sema,
         osc_type_u32         timeout);

extern osc_type_s32 OSC_Semaphore_Give (
         osc_struct_sema      *sema );

extern osc_type_s32 OSC_Semaphore_Config (
         osc_struct_sema      *sema,
         osc_type_u32         flag,
         osc_type_void_ptr    value );

extern osc_type_s32 OSC_Semaphore_Query (
         osc_struct_sema      *sema,
         osc_type_u32         flag,
         osc_type_void_ptr    value,
         osc_type_u8          *name,
         osc_type_u32         *count_num,
         osc_type_u32         *count_left,
         osc_struct_dd_hdr    *owner_list,
         osc_struct_dd_hdr    *waiting_list );

/* ---------------------------------------------------
Enhmutex API
----------------------------------------------------*/
extern osc_type_s32 OSC_Enhmutex_Create (
         osc_type_u8          *name,
         osc_type_void_ptr    *enhmutex_return );

extern osc_type_s32 OSC_Enhmutex_Delete (
         osc_struct_enhmutex      *enhmutex );

extern osc_type_s32 OSC_Enhmutex_Take (
         osc_struct_enhmutex      *enhmutex,
         osc_type_u32         timeout);

extern osc_type_s32 OSC_Enhmutex_Give (
         osc_struct_enhmutex      *enhmutex );

extern osc_type_s32 OSC_Enhmutex_Config (
         osc_struct_enhmutex      *enhmutex,
         osc_type_u32         flag,
         osc_type_void_ptr    value );

extern osc_type_s32 OSC_Enhmutex_Query (
         osc_struct_enhmutex      *enhmutex,
         osc_type_u32         flag,
         osc_type_void_ptr    value,
         osc_type_u8          *name,
         osc_type_u32          *emtx_max_wprio,
         osc_type_u32         *emtx_suspension_count,
         osc_struct_thread    *emtx_ownerthread);

/* ---------------------------------------------------
Queue API
----------------------------------------------------*/
extern osc_type_s32 OSC_Queue_Create (
         osc_type_u8          *name,
         osc_type_u32         *queue_addr,
         osc_type_u32         queue_size,
         osc_type_u32         msg_size,
         osc_type_void_ptr    *queue_return );

extern osc_type_s32 OSC_Queue_Delete (
         osc_struct_queue     *queue );

extern osc_type_s32 OSC_Queue_Write (
         osc_struct_queue     *queue,
         osc_type_u32         msg_size,
         osc_type_void_ptr    msg_buff,
         osc_type_u32         action );

extern osc_type_s32 OSC_Queue_Read (
         osc_struct_queue     *queue,
         osc_enum_bool        need_wait,
         osc_type_void_ptr    msg_buff, 
         osc_type_u32         *return_size );

extern osc_type_s32 OSC_Queue_Config (
         osc_struct_queue     *pool,
         osc_type_u32         flag,
         osc_type_void_ptr    value );

extern osc_type_s32 OSC_Queue_Query (
         osc_struct_queue     *queue,
         osc_type_u32         flag,
         osc_type_void_ptr    value,
         osc_type_u8          *name,
         osc_type_u32         *queue_size,
         osc_type_u32         *queue_addr,
         osc_type_u32         *msg_size,
         osc_type_u32         *msg_num_total,
         osc_struct_dd_hdr    *msg_free_list,
         osc_struct_dd_hdr    *msg_used_list,
         osc_struct_dd_hdr    *waiting_list );

/* ---------------------------------------------------
Event API
----------------------------------------------------*/
extern osc_type_s32 OSC_Event_Create (
         osc_type_u8          *name,
         osc_type_void_ptr    *event_return );

extern osc_type_s32 OSC_Event_Delete (
         osc_struct_event     *event );

extern osc_type_s32 OSC_Event_Write (
         osc_struct_event     *event,
         osc_type_u32         event_flag,
         osc_type_u32         action );

extern osc_type_s32 OSC_Event_Read (
         osc_struct_event     *event,
         osc_type_u32         timeout,
         osc_type_u32         event_flag,
         osc_type_u32         action,
         osc_type_u32         *event_flag_actual );

extern osc_type_s32 OSC_Event_Config (
         osc_struct_event     *event,
         osc_type_u32         flag,
         osc_type_void_ptr    value );

extern osc_type_s32 OSC_Event_Query (
         osc_struct_event     *event,
         osc_type_u32         flag,
         osc_type_void_ptr    value,
         osc_type_u8          *name,
         osc_type_u32         *event_flag,
         osc_struct_dd_hdr    *waiting_list );

/* ---------------------------------------------------
Buffer API
----------------------------------------------------*/
extern osc_type_s32 OSC_Buffer_Create (
         osc_type_u8          *name,
         osc_type_u32         *pool_addr,
         osc_type_u32         pool_size,
         osc_type_u32         block_size,
         osc_type_void_ptr    *return_pool );

extern osc_type_s32 OSC_Buffer_Delete (
         osc_struct_buffer    *pool );

extern osc_type_s32 OSC_Buffer_Alloc (
         osc_struct_buffer    *pool,
         osc_type_void_ptr    *block_addr );

extern osc_type_s32 OSC_Buffer_Free (
         osc_type_void_ptr    block_addr );

extern osc_type_s32 OSC_Buffer_Config (
         osc_struct_buffer    *pool,
         osc_type_u32         flag,
         osc_type_void_ptr    value );

extern osc_type_s32 OSC_Buffer_Query (
         osc_struct_buffer    *pool,
         osc_type_u32         flag,
         osc_type_void_ptr    value,
         osc_type_u8          *name,
         osc_type_u32         *pool_size,
         osc_type_u32         *pool_addr,
         osc_type_u32         *block_size,
         osc_type_u32         *block_num_total,
         osc_struct_dd_hdr    *block_free_list, 
         osc_struct_dd_hdr    *block_used_list );

extern osc_type_s32 OSC_Buffer_Query_Used_List ( 
             osc_struct_buffer *pool, 
             osc_type_u32 index,
             osc_type_void_ptr *block_addr );

/* ---------------------------------------------------
Critical Section API
----------------------------------------------------*/
extern osc_type_s32 OSC_Critical_Section_Initialize (
             void *pcs );


extern osc_type_s32 OSC_Critical_Section_Delete (
             void *pcs );

extern osc_type_s32 OSC_Critical_Section_Enter (
             void *pcs );

extern osc_type_s32 OSC_Critical_Section_Try_Enter (
             void *pcs, osc_enum_bool *try_result );


extern osc_type_s32 OSC_Critical_Section_Leave (
             void *pcs );

#endif //__OSC_FUNC_H__