source: svn/newcon3bcm2_21bu/BSEAV/api/src/nexus/bsettop_os.h @ 22

Last change on this file since 22 was 22, checked in by phkim, 11 years ago
  1. phkim
  2. newcon3sk 를 kctv 로 브랜치 함
  • Property svn:executable set to *
File size: 7.9 KB
Line 
1/***************************************************************************
2 *     Copyright (c) 2004-2009, Broadcom Corporation
3 *     All Rights Reserved
4 *     Confidential Property of Broadcom Corporation
5 *
6 *  THIS SOFTWARE MAY ONLY BE USED SUBJECT TO AN EXECUTED SOFTWARE LICENSE
7 *  AGREEMENT  BETWEEN THE USER AND BROADCOM.  YOU HAVE NO RIGHT TO USE OR
8 *  EXPLOIT THIS MATERIAL EXCEPT SUBJECT TO THE TERMS OF SUCH AN AGREEMENT.
9 *
10 * $brcm_Workfile: bsettop_os.h $
11 * $brcm_Revision: 3 $
12 * $brcm_Date: 8/18/09 6:38p $
13 *
14 * Module Description:
15 *
16 * Revision History:
17 *
18 * $brcm_Log: /BSEAV/api/src/nexus/bsettop_os.h $
19 *
20 * 3   8/18/09 6:38p katrep
21 * PR56109: Use calllbacks instead of using events for callbacks to the
22 * app.
23 *
24 * 2   6/4/08 11:24a rjlewis
25 * PR40352: extra functions needed for VxWorks.
26 *
27 * 1   3/31/08 6:04p jgarrett
28 * PR 40606: Creating bsettop_os for nexus
29 *
30 ***************************************************************************/
31#ifndef BSETTOP_OS_H__
32#define BSETTOP_OS_H__
33
34/*=**********************************************
35Provides additional operating system functionality
36beyond BKNI. Each OS needs to implement these functions.
37
38These functions run without respect to any thunk layer, therefore
39they can be executed by high or low level settop api code.
40*************************************************/
41
42#include "bstd.h"
43#include "bsettop_types.h"
44#include "b_os_lib.h"
45
46#ifdef __cplusplus
47extern "C" {
48#endif
49
50/* the following interface is used to set one shot timer callbacks */
51typedef B_SchedulerTimerId b_timer_t;
52typedef void (*b_timer_callback_t)(void *cntx);
53
54/* Init/uninit os services */
55bresult b_os_init(void);
56bresult b_os_uninit(void);
57
58/* this function is used to acquire global lock */
59void b_lock(void);
60/* this function is uses to release global lock (lock must be held by the current task before function is called) */
61void b_unlock(void);
62/* this function returns trus if current task is holds the lock, the sole purpose of this function is to be used with conjunction with BDBG_ASSERT, e.g. BDBG_ASSERT(b_lock_assert()); */
63bool b_lock_assert(void);
64#define B_LOCK_ASSERT() BDBG_ASSERT(b_lock_assert())
65
66/**
67Request a timer callback to occur no sooner than the specified in milliseconds.
68It may come any amount of time later. If this function called within SettopApi core
69callback would be called with global mutex (b_lock) held. Otherwise no particular
70mutex held and it's user responsibility to call necessary synchronization functions.
71**/
72b_timer_t b_timer_schedule(unsigned delay /* ms */, b_timer_callback_t callback, void *cntx);
73
74/**
75Cancel a timer callback.
76**/
77void b_timer_cancel(b_timer_t timer);
78
79
80typedef B_Time b_time_t;
81
82/**
83Get the current time.
84The value of b_time_t is platform dependent. However, you can obtain a platform-independent
85time diff by using b_time_diff.
86**/
87void b_time_get(b_time_t *time); /* this functions returns current system time (timestamp) */
88
89/**
90Returns difference in milliseconds between two timestamps obtained with b_time_get.
91
92It's recomended that code would use this function in a way that it could return
93only positive values (where applicable, it helps in handling wraparound conditions)
94
95TODO: Regarding the above comment, we need to define specific behavior for wraparound.
96This either handles wrap-around and always returns a positive value, or it does not.
97**/
98long b_time_diff(const b_time_t *future,  const b_time_t *past);
99
100/**
101This function flushes and invalidates data cache in a specified memory region.
102
103This function is used before a DMA output (write) operation to be sure that the DMA uses the flushed data.
104This function is also used before a DMA input (read) operation to be sure that when the data is read it
105comes from the newly DMAed data (and not stale data found in the cache).
106
107Note: the implementation ensures that both a flush AND an invailidate operation is performed.
108**/
109void b_cacheflush(const void *addr, size_t nbytes);
110
111/*
112Summary:
113The following two functions convert from b_lock state to idle state, and vice versa.
114
115Description:
116Both function is place for a race conditione (they don't swap locks atomically)
117so critical state might need to be reexamined after function call.
118*/
119void b_lock2idle(void);
120void b_idle2lock(void);
121
122/*
123Summary:
124The following two functions convert from b_lock state to slow state, and vice versa.
125
126Description:
127Both function is place for a race conditione (they don't swap locks atomically)
128so critical state might need to be reexamined after function call.
129*/
130void b_lock2slow(void);
131void b_slow2lock(void);
132
133
134/*
135The b_event interface provides for receiving a task-context callback function when a KNI event is fired.
136
137The callback function is called with b_lock already held.
138
139The caller should execute the callback with the absolute minimum amount of time. All events
140are serialized. You should never convert from lock2idle or lock2slow in an event callback because it will
141cause all other event processing to block.
142
143It is possible to call b_event_unregister from inside an event.
144
145It is required that all b_event functions are called with b_lock held.
146*/
147
148typedef void (*b_event_callback_t)(void *cntx);
149
150typedef B_SchedulerEventId b_event_id_t;
151
152b_event_id_t b_event_register(B_EventHandle event, b_event_callback_t callback, void *cntx);
153void b_event_unregister(b_event_id_t id);
154
155/*
156The b_callback interface provides for receiving a task-context callback function when a KNI event is fired.
157
158
159The caller should execute the callback with the absolute minimum amount of time. All callbacks
160are serialized by scheduler.
161*/
162typedef void (*b_callback_t)(void *cntx,int param2);
163
164typedef B_SchedulerCallbackHandle b_calllback_id_t;
165
166b_calllback_id_t b_callback_create(void *pInstanceHandle, b_callback_t function,void *cntx,int param);
167void b_callback_destroy(b_calllback_id_t callback);
168void b_callback_fire(b_calllback_id_t callback);
169void b_callback_stop(void *pInstanceHandle);
170
171
172/***********************
173*
174* b_task api - used for starting tasks in different environments
175*
176*/
177typedef struct b_task *b_task_t;
178typedef void *(*b_task_func)(void *data);
179
180/**
181Summary:
182Params for b_start_task. This is optional.
183**/
184typedef struct b_task_params
185{
186    unsigned priority;   /* 0 is highest, 100 is lowest. this is a hint and should
187        not be considered a system-critical setting. */
188    size_t stack_size; /* if 0, then default */
189    const char *name; /* optional. used for debug. may be truncated depending on system capabilities. */
190} b_task_params;
191
192/**
193Summary:
194Set b_task_params defaults.
195**/
196void b_task_params_init(b_task_params *params);
197
198/**
199Summary:
200Create a new task and call the function with the data parameter.
201**/
202bresult b_start_task(
203    b_task_t *handle,   /* [out] new thread handle, passed to b_stop_task when finished */
204    const b_task_params *params, /* param structure containing priority, task name, and stack size. */
205    b_task_func func,   /* function to be called by new thread. when this func returns, the
206        thread is done processing. */
207    void *data          /* data to be passed to func */
208    );
209
210/**
211Summary:
212Clean up a finished task.
213Description:
214It is very important to realize that this function is not guaranteed to stop the task.
215It assumes that the function has already exited or will exit on its own.
216The application should set whatever conditions are required in order to make the
217task function exit.
218b_stop_task will block until the function is actually stopped and then it
219will clean up whatever resources were allocated for the task.
220**/
221void b_stop_task(b_task_t handle);
222
223#ifdef __vxworks
224
225/**
226Summary:
227Return the size of a file.
228Description:
229Some OSs don't have support for large files.  This provides size for a large file.
230**/
231off_t b_file_size(int desc);
232
233/**
234Summary:
235Seek to location in long file.
236Description:
237Some OSs don't have support for large files.  This provides a seek operation on a long file.
238**/
239off_t b_file_seek(int desc, off_t offset, int whence);
240
241#endif
242
243#ifdef __cplusplus
244}
245#endif
246
247#endif /* BSETTOP_OS_H__ */
Note: See TracBrowser for help on using the repository browser.