lwipports.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. /* Copyright (C) 2016 RDA Technologies Limited and/or its affiliates("RDA").
  2. * All rights reserved.
  3. *
  4. * This software is supplied "AS IS" without any warranties.
  5. * RDA assumes no responsibility or liability for the use of the software,
  6. * conveys no license or title under any patent, copyright, or mask work
  7. * right to the product. RDA reserves the right to make changes in the
  8. * software without notification. RDA also make no representation or
  9. * warranty that such application will be suitable for the specified use
  10. * without further testing or modification.
  11. */
  12. #ifndef _LWIPPORTS_H_
  13. #define _LWIPPORTS_H_
  14. #include <stdarg.h>
  15. #include <stdlib.h>
  16. #include <stdio.h>
  17. #include <string.h>
  18. #include "osi_api.h"
  19. #define RESOLV_NETWORK_ERROR 0x01
  20. #define LWIP_RAND() ((uint32_t)rand())
  21. #ifdef __GNUC__
  22. #define UNUSED_PARAM __attribute__((unused))
  23. #else /* not a GCC */
  24. #define UNUSED_PARAM
  25. #endif /* GCC */
  26. #define UNUSED_P(p) ((void)p)
  27. #include "cfw.h"
  28. #include "cfw_event.h"
  29. #define X8_F "02x"
  30. #define U16_F "hu"
  31. #define S16_F "hd"
  32. #define X16_F "hx"
  33. #define U32_F "lu"
  34. #define S32_F "ld"
  35. #define X32_F "lx"
  36. #define SZT_F "ld"
  37. typedef struct
  38. {
  39. uint32_t sem_id;
  40. uint32_t is_vail;
  41. uint32_t is_timeout;
  42. uint32_t wait_count;
  43. } sys_sem_t, *sys_sem_ptr;
  44. typedef struct
  45. {
  46. uint32_t id;
  47. uint32_t is_vail;
  48. } sys_mbox_t, *sys_mbox_ptr;
  49. typedef struct
  50. {
  51. uint32_t id;
  52. uint32_t user_id;
  53. } sys_mutex_t;
  54. #define sys_thread_t uint32_t
  55. #define sys_prot_t uint32_t
  56. #define sys_msleep osiThreadSleep
  57. #define SYS_ARCH_DECL_PROTECT(x) uint32_t x
  58. #define SYS_ARCH_PROTECT(x) x = osiEnterCritical()
  59. #define SYS_ARCH_UNPROTECT(x) osiExitCritical(x)
  60. typedef void (*lwip_thread_fn)(void *arg);
  61. typedef void (*sys_timeout_handler)(void *arg);
  62. void sys_timeout(uint32_t msecs, sys_timeout_handler handler, void *arg);
  63. void sys_untimeout(sys_timeout_handler handler, void *arg);
  64. void sys_settime(uint32_t sec, uint32_t frac);
  65. uint32_t sys_get_srand(void);
  66. osiTimer_t *sys_CreateWakeupTimer(osiCallback_t cb);
  67. bool sys_StartWakeupTimer(void *timer, uint32_t ms);
  68. bool sys_StopWakeupTimer(void *timer);
  69. void sys_DeleteWakeupTimer(void *timer);
  70. #endif