| 1 | /**************************************************************************** |
|---|
| 2 | * Copyright (c) 2006 DST Technologies Inc. All Rights Reserved. |
|---|
| 3 | * |
|---|
| 4 | * Module: OS LOCAL |
|---|
| 5 | * |
|---|
| 6 | * Description: OS APIs for Core internal use |
|---|
| 7 | * Informations in this file apply to all OSes in use. |
|---|
| 8 | * |
|---|
| 9 | * Notes: This module contains local APIs for |
|---|
| 10 | * - Processes |
|---|
| 11 | * - NVM |
|---|
| 12 | * - Video memory mapping |
|---|
| 13 | * - PCI bus |
|---|
| 14 | * - IRQ |
|---|
| 15 | ***************************************************************************/ |
|---|
| 16 | #ifndef OS_PRIVATE_H_ |
|---|
| 17 | #define OS_PRIVATE_H_ |
|---|
| 18 | |
|---|
| 19 | /*========================== |
|---|
| 20 | * OS include |
|---|
| 21 | *=========================*/ |
|---|
| 22 | #include "dsthalcommon.h" |
|---|
| 23 | #include <sys/types.h> |
|---|
| 24 | #include <sys/ipc.h> |
|---|
| 25 | #include <sys/sem.h> |
|---|
| 26 | #include <sys/mman.h> |
|---|
| 27 | #include <sys/signal.h> |
|---|
| 28 | #include <sys/wait.h> |
|---|
| 29 | #include <sys/shm.h> |
|---|
| 30 | #include <sys/msg.h> |
|---|
| 31 | #include <sys/ioctl.h> |
|---|
| 32 | #include <fcntl.h> |
|---|
| 33 | #include <stdlib.h> |
|---|
| 34 | #include <unistd.h> |
|---|
| 35 | #include <errno.h> |
|---|
| 36 | #include <stdlib.h> |
|---|
| 37 | #include <sys/time.h> |
|---|
| 38 | #include <sys/resource.h> |
|---|
| 39 | #include <pthread.h> |
|---|
| 40 | #include <sched.h> |
|---|
| 41 | |
|---|
| 42 | #define INVALID_KHANDLE -1 |
|---|
| 43 | |
|---|
| 44 | #define DEBUG_OS 1 |
|---|
| 45 | |
|---|
| 46 | /*========================== |
|---|
| 47 | * Shared prototypes |
|---|
| 48 | *=========================*/ |
|---|
| 49 | DS_S32 Os_KmodGetHandle (DS_U32 ChipIndex); |
|---|
| 50 | void Os_KmodReleaseHandle (DS_S32 Handle); |
|---|
| 51 | DS_U32 Os_PerformIoctl (DS_U32 Func, void *RetBuf); |
|---|
| 52 | key_t Os_GetNameValue (DS_S8 *Name, DS_S8 NumVal); |
|---|
| 53 | |
|---|
| 54 | #if !DEBUG_OS |
|---|
| 55 | #define INFO_MSG(...) |
|---|
| 56 | #define DBG_MSG(...) |
|---|
| 57 | #else |
|---|
| 58 | #define INFO_MSG printf |
|---|
| 59 | #define DBG_MSG printf |
|---|
| 60 | #endif |
|---|
| 61 | |
|---|
| 62 | |
|---|
| 63 | /*========================== |
|---|
| 64 | * TASK Control Block |
|---|
| 65 | *=========================*/ |
|---|
| 66 | typedef enum tag_DS_TASK_STATUS |
|---|
| 67 | { |
|---|
| 68 | DS_TSTAT_READY = 0x0000, |
|---|
| 69 | DS_TSTAT_PEND = 0x0001, |
|---|
| 70 | DS_TSTAT_DELAY = 0x0002, |
|---|
| 71 | DS_TSTAT_SUSPEND = 0x0004, |
|---|
| 72 | DS_TSTAT_TIMEOUT = 0x0008, |
|---|
| 73 | DS_TSTAT_INH_PRI = 0x0010, |
|---|
| 74 | DS_TSTAT_DEAD = 0x0080, |
|---|
| 75 | DS_TSTAT_RDY_MSK = 0x008f |
|---|
| 76 | } DS_TASK_STATUS; |
|---|
| 77 | |
|---|
| 78 | typedef struct tag_DS_TASK_T |
|---|
| 79 | { |
|---|
| 80 | DS_U32 taskId; // task id (from pthread) |
|---|
| 81 | int pid; // Process ID (from kernel) |
|---|
| 82 | |
|---|
| 83 | DS_U8 priority; // task priority |
|---|
| 84 | DS_U8 status; // task status |
|---|
| 85 | DS_U32 stacksize; // task stack size |
|---|
| 86 | char name[256]; // task name max is 10 char! |
|---|
| 87 | |
|---|
| 88 | void (*funcPtr)(DS_U32); |
|---|
| 89 | DS_U32 arg; |
|---|
| 90 | |
|---|
| 91 | // First task control block in list of tasks waiting on this task (for deletion purposes) |
|---|
| 92 | struct tag_DS_TASK_T *first_susp; |
|---|
| 93 | |
|---|
| 94 | // Next task control block in list of tasks waiting on object |
|---|
| 95 | struct tag_DS_TASK_T *nxt_susp; |
|---|
| 96 | |
|---|
| 97 | // Next task control block in list |
|---|
| 98 | struct tag_DS_TASK_T *nxt_task; |
|---|
| 99 | |
|---|
| 100 | // the task waits this objects: |
|---|
| 101 | DS_U32 *waiting; |
|---|
| 102 | } DS_TASK_T; // Task Debug DB |
|---|
| 103 | |
|---|
| 104 | |
|---|
| 105 | void link_susp_task(DS_TASK_T ** list_head, DS_TASK_T * new_entry); |
|---|
| 106 | void unlink_susp_task(DS_TASK_T **list_head, DS_TASK_T * entry); |
|---|
| 107 | int signal_for_my_task(DS_TASK_T **list_head, int pend_order); |
|---|
| 108 | |
|---|
| 109 | DS_TASK_T *taskFind(DS_U32 taskId, int lock); |
|---|
| 110 | |
|---|
| 111 | #endif /* OS_PRIVATE_H_ */ |
|---|