/*
 *               Copyright (C) 2005, BroadOn Communications Corp.
 *
 *  These coded instructions, statements, and computer programs contain
 *  unpublished  proprietary information of BroadOn Communications Corp.,
 *  and  are protected by Federal copyright law. They may not be disclosed
 *  to  third  parties or copied or duplicated in any form, in whole or in
 *  part, without the prior written consent of BroadOn Communications Corp.
 *
 */

/*---------------------------------------------------------------------------*
 * 
 * OS thread header file for network stack
 * 
 *---------------------------------------------------------------------------*/

#ifndef __IOP_THREAD_H__
#define __IOP_THREAD_H__

#ifdef __cplusplus
extern "C" {
#endif


// Socket Layer RM Thread
#define NET_SOCK_STACK_SIZE     (4 * 1024)
#define NET_SOCK_MSGQ_SIZE      24

// Network Device Interface RM Thread
#define NET_IF_STACK_SIZE       (4 * 1024)
#define NET_IF_MSGQ_SIZE        32

// Network Device Xmit Thread
#define NET_XMIT_STACK_SIZE     (1 * 1024)
#define NET_XMIT_MSGQ_SIZE      2

// Alarm Management Thread
#define NET_ALARM_STACK_SIZE    (4 * 1024)
#define NET_ALARM_MSGQ_SIZE     48

#define NET_HIGHEST_PRIORITY    IOS_PRIORITY_NET
#define NET_ALARM_PRIORITY      (IOS_PRIORITY_NET-1)
#define NET_DEVIF_PRIORITY      (IOS_PRIORITY_NET-2)
#define NET_DEVXMIT_PRIORITY    (IOS_PRIORITY_NET-2)
#define NET_WORK_PRIORITY       (IOS_PRIORITY_NET-3)

typedef struct OSThread         OSThread;
typedef struct OSThreadQueue    OSThreadQueue;

struct OSThreadQueue
{
    OSThread*  head;
    OSThread*  tail;
};

struct OSThread
{
    IOSThreadId     threadId;
    u32             priority;
    s32             error;
    OSThread        *next;
    BOOL            interrupt;
#ifdef _DEBUG
    OSThreadQueue   *queue;
#endif // _DEBUG
};

void       OSInitThreadQueue   ( OSThreadQueue* queue );
OSThread*  OSGetCurrentThread  ( void );
s32        OSDisableScheduler  ( void );
s32        OSEnableScheduler   ( void );
void       OSYieldThread       ( void );
void       OSSleepThread       ( OSThreadQueue* queue );
void       OSWakeupThread      ( OSThreadQueue* queue );

void       OSInitThreadPool    ( void );
void       OSInitThread        ( IOSThreadId threadId, u32 priority );

#ifdef _DEBUG
void       OSDumpThread        ( void );
#endif // _DEBUG

#ifdef __cplusplus
}
#endif

#endif  // __IOP_THREAD_H__
