Linux Audio

Check our new training course

Embedded Linux Audio

Check our new training course
with Creative Commons CC-BY-SA
lecture materials

Bootlin logo

Elixir Cross Referencer

Loading...
   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
 454
 455
 456
 457
 458
 459
 460
 461
 462
 463
 464
 465
 466
 467
 468
 469
 470
 471
 472
 473
 474
 475
 476
 477
 478
 479
 480
 481
 482
 483
 484
 485
 486
 487
 488
 489
 490
 491
 492
 493
 494
 495
 496
 497
 498
 499
 500
 501
 502
 503
 504
 505
 506
 507
 508
 509
 510
 511
 512
 513
 514
 515
 516
 517
 518
 519
 520
 521
 522
 523
 524
 525
 526
 527
 528
 529
 530
 531
 532
 533
 534
 535
 536
 537
 538
 539
 540
 541
 542
 543
 544
 545
 546
 547
 548
 549
 550
 551
 552
 553
 554
 555
 556
 557
 558
 559
 560
 561
 562
 563
 564
 565
 566
 567
 568
 569
 570
 571
 572
 573
 574
 575
 576
 577
 578
 579
 580
 581
 582
 583
 584
 585
 586
 587
 588
 589
 590
 591
 592
 593
 594
 595
 596
 597
 598
 599
 600
 601
 602
 603
 604
 605
 606
 607
 608
 609
 610
 611
 612
 613
 614
 615
 616
 617
 618
 619
 620
 621
 622
 623
 624
 625
 626
 627
 628
 629
 630
 631
 632
 633
 634
 635
 636
 637
 638
 639
 640
 641
 642
 643
 644
 645
 646
 647
 648
 649
 650
 651
 652
 653
 654
 655
 656
 657
 658
 659
 660
 661
 662
 663
 664
 665
 666
 667
 668
 669
 670
 671
 672
 673
 674
 675
 676
 677
 678
 679
 680
 681
 682
 683
 684
 685
 686
 687
 688
 689
 690
 691
 692
 693
 694
 695
 696
 697
 698
 699
 700
 701
 702
 703
 704
 705
 706
 707
 708
 709
 710
 711
 712
 713
 714
 715
 716
 717
 718
 719
 720
 721
 722
 723
 724
 725
 726
 727
 728
 729
 730
 731
 732
 733
 734
 735
 736
 737
 738
 739
 740
 741
 742
 743
 744
 745
 746
 747
 748
 749
 750
 751
 752
 753
 754
 755
 756
 757
 758
 759
 760
 761
 762
 763
 764
 765
 766
 767
 768
 769
 770
 771
 772
 773
 774
 775
 776
 777
 778
 779
 780
 781
 782
 783
 784
 785
 786
 787
 788
 789
 790
 791
 792
 793
 794
 795
 796
 797
 798
 799
 800
 801
 802
 803
 804
 805
 806
 807
 808
 809
 810
 811
 812
 813
 814
 815
 816
 817
 818
 819
 820
 821
 822
 823
 824
 825
 826
 827
 828
 829
 830
 831
 832
 833
 834
 835
 836
 837
 838
 839
 840
 841
 842
 843
 844
 845
 846
 847
 848
 849
 850
 851
 852
 853
 854
 855
 856
 857
 858
 859
 860
 861
 862
 863
 864
 865
 866
 867
 868
 869
 870
 871
 872
 873
 874
 875
 876
 877
 878
 879
 880
 881
 882
 883
 884
 885
 886
 887
 888
 889
 890
 891
 892
 893
 894
 895
 896
 897
 898
 899
 900
 901
 902
 903
 904
 905
 906
 907
 908
 909
 910
 911
 912
 913
 914
 915
 916
 917
 918
 919
 920
 921
 922
 923
 924
 925
 926
 927
 928
 929
 930
 931
 932
 933
 934
 935
 936
 937
 938
 939
 940
 941
 942
 943
 944
 945
 946
 947
 948
 949
 950
 951
 952
 953
 954
 955
 956
 957
 958
 959
 960
 961
 962
 963
 964
 965
 966
 967
 968
 969
 970
 971
 972
 973
 974
 975
 976
 977
 978
 979
 980
 981
 982
 983
 984
 985
 986
 987
 988
 989
 990
 991
 992
 993
 994
 995
 996
 997
 998
 999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
/*
 * simplelink.h - CC31xx/CC32xx Host Driver Implementation
 *
 * Copyright (C) 2017 Texas Instruments Incorporated - http://www.ti.com/
 *
 *
 *  Redistribution and use in source and binary forms, with or without
 *  modification, are permitted provided that the following conditions
 *  are met:
 *
 *  Redistributions of source code must retain the above copyright
 *  notice, this list of conditions and the following disclaimer.
 *
 *  Redistributions in binary form must reproduce the above copyright
 *  notice, this list of conditions and the following disclaimer in the
 *  documentation and/or other materials provided with the
 *  distribution.
 *
 *  Neither the name of Texas Instruments Incorporated nor the names of
 *  its contributors may be used to endorse or promote products derived
 *  from this software without specific prior written permission.
 *
 *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 *  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 *  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 *  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 *  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 *  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 *  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *
*/


/*!
    \mainpage SimpleLink Driver

    \section intro_sec Introduction

 The SimpleLink(tm) CC31xx/CC32xx family allows to add Wi-Fi and networking capabilities
 to low-cost embedded products without having prior Wi-Fi, RF or networking expertise.\n
 The CC31xx/CC32xx is an ideal solution for microcontroller-based sensor and control
 applications such as home appliances, home automation and smart metering.\n
 The CC31xx/CC32xx has integrated a comprehensive TCP/IP network stack, Wi-Fi driver and
 security supplicant leading to easier portability to microcontrollers, to an
 ultra-low memory footprint, all without compromising the capabilities and robustness
 of the final application.



 \section modules_sec Module Names
 To make it simple, TI's SimpleLink CC31xx/CC32xx platform capabilities were divided into modules by topic (Silo).\n
 These capabilities range from basic device management through wireless
 network configuration, standard BSD socket and much more.\n
 Listed below are the various modules in the SimpleLink CC31xx/CC32xx driver:
     -# \ref Device     - Controls the behaviour of the CC31xx/CC32xx device (start/stop, events masking and obtaining specific device status)
     -# \ref FileSystem - Provides file system capabilities to TI's CC31XX that can be used by both the CC31XX device and the user.
     -# \ref NetApp     - Activates networking applications, such as: HTTP Server, DHCP Server, Ping, DNS and mDNS.
     -# \ref NetCfg     - Controls the configuration of the device addresses (i.e. IP and MAC addresses)
     -# \ref NetUtil    - Networking related commands and configuration
     -# \ref Socket     - Controls standard client/server sockets programming options and capabilities
     -# \ref Wlan       - Controls the use of the WiFi WLAN module including:
                            - Connection features, such as: profiles, policies, SmartConfig(tm)
                            - Advanced WLAN features, such as: scans, rx filters and rx statistics collection
     -# \ref UserEvents - Function prototypes for event callback handlers

    \section persistency_sec Persistency
            The SimpleLink(tm) device support few different persistency types for settings and configurations:\n
            - <b>Temporary</b>             -    Effective immediately but returned to default after reset\n
            - <b>System Persistent</b>     -    Effective immediately and kept after reset according\n
                                                to system persistent mode\n
            - <b>Persistent</b>            -    Effective immediately and kept after reset regardless the system persistent mode\n
            - <b>Optionally Persistent</b> -    Effective immediately and kept after reset according to a parameter in the API call\n
            - <b>Reset</b>                 -    Persistent but effective only after reset\n
            \n
            For all Set/Get function in this guide, the type of persistency per relevant parameters will be
            described as part of the function description\n

    \section    proting_sec     Porting Guide

 The porting of the SimpleLink host driver to any new platform is based on few simple steps.\n
 This guide takes you through this process step by step. Please follow the instructions
 carefully to avoid any problems during this process and to enable efficient and proper
 work with the device.\n
 Please notice that all modifications and porting adjustments of the driver should be
 made in the user.h header file only. Keeping this method ensure smoothly
transaction to new versions of the driver in the future!\n

The porting process consists of few simple steps:
-# Create user.h for the target platform
-# Select the capabilities set
-# Bind the device enable/disable line
-# Writing your interface communication driver
-# Choose your memory management model
-# OS adaptation
-# Set your asynchronous event handlers
-# Testing

For host interface details please refer to:
http://processors.wiki.ti.com/index.php/CC31xx_Host_Interface

Please see the rest of the page for more details about the different steps.

 \subsection     porting_step1   Step 1 - Create your own user.h file

 The first step is to create a <b><i>user.h</i></b> file that will include your configurations and
 adjustments. \n
 The file should be located in the porting directory (the porting directory is in the same level as the source directory)\n
 It is recommended to use the empty template provided as part of this driver or
 file of other platform such as MSP432 or CC32xx, from one of the wide range
 of example applications provided by Texas Instruments.

 \subsection    porting_step2   Step 2 - Bind the device enable/disable output line

 The CC31xx has two external hardware lines that can be used to enable/disable the device.
 - <b>nReset</b>
 - <b>nHib</b> - provides mechanism to enter the device into the least current consumption mode. In
 this mode the RTC value is kept.

 The driver manipulates the enable/disable line automatically during sl_Start / sl_Stop.\n
 Not connecting one these lines means that the driver could start only once (sl_Stop will not
 work correctly and might lead to failure latter on) and the internal provisioning mechanism
 could not be used.\n

 To bind these lines the following defines should be defined correctly:
 - <b>sl_DeviceEnable</b>
 - <b>sl_DeviceDisable</b>

 If some initializations required before the enable/disable macros are called the user can use also the following <i>optional</i> define
 - <b>sl_DeviceEnablePreamble</b>

 \subsection    porting_step4   Step 4 - Writing your interface communication driver

 The SimpleLink CC31xx has two standard communication interfaces
    - SPI
    - UART

 The device detects automatically the active interface during initialization. After the detection, the second interface could not be used.\n

 To wrap the driver for the communication channel the following functions should be implemented:
 -# sl_IfOpen
 -# sl_IfClose
 -# sl_IfRead
 -# sl_IfWrite
 -# sl_IfRegIntHdlr

 The way these functions are implemented has direct effect on the performances of the SimpleLink
 device on this target platform. DMA and Jitter Buffer should be considered.\n

 In some platforms the user need to mask the IRQ line when this interrupt could be masked. \n
 The driver can call the mask/unmask whenever is needed. To allow this functionality the
 user should implement also the following defines:
    - sl_IfMaskIntHdlr
    - sl_IfUnMaskIntHdlr

 By default the driver is writing the command in few transactions to allow zero-copy mechanism. \n
 To enable a Jitter buffer for improving the communication line utilization, the can implement
 also the following defines:
    - sl_IfStartWriteSequence
    - sl_IfEndWriteSequence

 \subsection     porting_step5   Step 5 - Choose your memory management model

 The SimpleLink driver support two memory models:
     - Static (default)
     - Dynamic

 To enable the dynamic memory, the following pre-processor define should be set: \n
 #define SL_MEMORY_MGMT_DYNAMIC

 And the following macros should be defined and supplied:
    - sl_Malloc
    - sl_Free

    Using the dynamic mode will allocate the required resources on sl_Start and release these resource on sl_Stop.

 \subsection     porting_step6   Step 6 - OS adaptation

 The SimpleLink driver could run on two kind of platforms:
     -# Non-Os / Single Threaded (default)
     -# Multi-Threaded

 When building a multi-threaded application. the following pre-processor define must be set: \n
 #define SL_PLATFORM_MULTI_THREADED

 If you choose to work in multi-threaded environment under operating system you will have to
 provide some basic adaptation routines to allow the driver to protect access to resources
 for different threads (locking object) and to allow synchronization between threads (sync objects).
 In additional the driver support running without dedicated thread allocated solely to the
 SimpleLink driver. If you choose to work in this mode, you should also supply a spawn method that
 will enable to run function on a temporary context.


 \subsection     porting_step7   Step 7 - Set your asynchronous event handlers routines

 The SimpleLink device generate asynchronous events in several situations.
 These asynchronous events could be masked.
 In order to catch these events you have to provide handler routines.
 Please notice that if you not provide a handler routine and the event is received,
 the driver will drop this event without any indication of this drop.


 \subsection     porting_step8   Step 8 - Run diagnostic tools to validate the correctness of your porting

 The driver is delivered with some porting diagnostic tools to simplify the porting validation process
 and to reduce issues latter. It is very important to follow carefully this process.

 The diagnostic process include:
     -# Validating interface communication driver
     -# Validating basic work with the device


    \section annex_step Annex Persistency
            The SimpleLink(tm) device support few different persistency types for settings and configurations:\n
            - <b>Temporary</b>             -    Effective immediately but returned to default after reset\n
            - <b>System Persistent</b>     -    Effective immediately and kept after reset according\n
                                           -    to system persistent mode\n
            - <b>Persistent</b>            -    Effective immediately and kept after reset regardless the system persistent mode\n
            - <b>Optionally Persistent</b> -    Effective immediately and kept after reset according to a parameter in the API call\n
            - <b>Reset</b>                 -    Persistent but effective only after reset\n

*/

#ifndef __SIMPLELINK_H__
#define __SIMPLELINK_H__

/* define the default types
 * If user wants to overwrite it,
 * he need to undef and define again */
#define _u8  unsigned char
#define _i8  signed char
#define _u16 unsigned short
#define _i16 signed short
#define _u32 unsigned long
#define _i32 signed long

#define _volatile volatile
#define _const    const

#include <ti/drivers/net/wifi/porting/user.h>

#ifdef    __cplusplus
extern "C"
{
#endif

/*!
    \defgroup UserEvents
    \short Function prototypes for event callback handlers

*/

/*! \attention  Async event activation notes\n
    Function prototypes for event callback handlers\n
    Event handler function names should be defined in the user.h file\n
    e.g.\n
    "#define slcb_WlanEvtHdlr   SLWlanEventHandler"\n
    Indicates all WLAN events are handled by User func "SLWlanEventHandler"\n
    Important notes:\n
    1. Event handlers cannot activate another SimpleLink API from the event's context
    2. Event's data is valid during event's context. Any application data
       which is required for the user application should be copied or marked
       into user's variables
    3. It is not recommended to delay the execution of the event callback handler

*/

/*!

    \addtogroup UserEvents
    @{

*/


/*****************************************************************************/
/* Macro declarations for Host Driver version                                */
/*****************************************************************************/
#define SL_DRIVER_VERSION   "3.0.1.46"
#define SL_MAJOR_VERSION_NUM    3L
#define SL_MINOR_VERSION_NUM    0L
#define SL_VERSION_NUM          1L
#define SL_SUB_VERSION_NUM      46L

/*****************************************************************************/
/* Macro declarations for predefined configurations                          */
/*****************************************************************************/


/* #define sl_Memcpy       memcpy */
#define sl_Memset(addr, val, len)      memset(addr, val, (size_t)len)
#define sl_Memcpy(dest, src, len)      memcpy(dest, src, (size_t)len)
#define sl_Memmove(dest, src, len)     memmove(dest, src, (size_t)len)

#define SL_MAX_SOCKETS      (_u8)(16)


/*****************************************************************************/
/* Types definitions                                                         */
/*****************************************************************************/

#ifndef NULL
#define NULL        (0)
#endif

#ifndef FALSE
#define FALSE       (0)
#endif

#ifndef TRUE
#define TRUE        (!FALSE)
#endif

typedef _u16  _SlOpcode_t;
typedef _u8   _SlArgSize_t;
typedef _i16   _SlDataSize_t;
typedef _i16   _SlReturnVal_t;

/*
 * This event status used to  block or continue the event propagation
 * through all the registered external libs/user application
 *
 */

 typedef enum {
    EVENT_PROPAGATION_BLOCK = 0,
    EVENT_PROPAGATION_CONTINUE
 } _SlEventPropogationStatus_e;


/*****************************************************************************/
/* Include files                                                             */
/*****************************************************************************/


/*
   objInclusion.h and user.h must be included before all api header files
   objInclusion.h must be the last arrangement just before including the API header files
   since it based on the other configurations to decide which object should be included
*/
#include "source/objInclusion.h"
#include "trace.h"
#include "fs.h"
#include "sl_socket.h"
#include "netapp.h"
#include "wlan.h"
#include "device.h"
#include "netcfg.h"
#include "netutil.h"
#include "errors.h"
#include "eventreg.h"
#include "wlanconfig.h"
/*!
    \cond DOXYGEN_IGNORE
*/
 /* In case of use dynamic event registration
  * redirect the event to the internal mechanism */
#if (defined(SL_RUNTIME_EVENT_REGISTERATION))

#define _SlDrvHandleFatalErrorEvents            _SlDeviceFatalErrorEvtHdlr
#define _SlDrvHandleGeneralEvents               _SlDeviceGeneralEvtHdlr
#define _SlDrvHandleWlanEvents                  _SlWlanEvtHdlr
#define _SlDrvHandleNetAppEvents                _SlNetAppEvtHdlr
#define _SlDrvHandleSockEvents                  _SlSockEvtHdlr
#define _SlDrvHandleHttpServerEvents            _SlNetAppHttpServerHdlr
#define _SlDrvHandleNetAppRequestEvents         _SlNetAppRequestHdlr
#define _SlDrvHandleNetAppRequestMemFreeEvents  _SlNetAppRequestMemFree
#define _SlDrvHandleSocketTriggerEvents         _SlSocketTriggerEventHandler

#else

 /* The fatal error events dispatcher which is
  * initialized to the user handler */
#ifdef slcb_DeviceFatalErrorEvtHdlr
#define _SlDrvHandleFatalErrorEvents slcb_DeviceFatalErrorEvtHdlr
#endif

 /* The general events dispatcher which is
  * initialized to the user handler */
#ifdef slcb_DeviceGeneralEvtHdlr
#define _SlDrvHandleGeneralEvents slcb_DeviceGeneralEvtHdlr
#endif

 /* The wlan events dispatcher which is
  * initialized to the user handler */
#ifdef slcb_WlanEvtHdlr
#define _SlDrvHandleWlanEvents slcb_WlanEvtHdlr
#endif

 /* The NetApp events dispatcher which is
  * initialized to the user handler */
#ifdef slcb_NetAppEvtHdlr
#define _SlDrvHandleNetAppEvents slcb_NetAppEvtHdlr
#endif

 /* The http server events dispatcher which is
  * initialized to the user handler if exists */
#ifdef slcb_NetAppHttpServerHdlr
#define _SlDrvHandleHttpServerEvents slcb_NetAppHttpServerHdlr
#endif

 /* The socket events dispatcher which is
  * initialized to the user handler */
#ifdef slcb_SockEvtHdlr
#define _SlDrvHandleSockEvents slcb_SockEvtHdlr
#endif


/* The netapp requests dispatcher which is
  * initialized to the user handler if exists */
#ifdef slcb_NetAppRequestHdlr
#define _SlDrvHandleNetAppRequestEvents slcb_NetAppRequestHdlr
#endif

/* The netapp request mem free requests dispatcher which is
* initialized to the user handler if exists */
#ifdef slcb_NetAppRequestMemFree
#define _SlDrvHandleNetAppRequestMemFreeEvents slcb_NetAppRequestMemFree
#endif

/* The netapp requests dispatcher which is
* initialized to the user handler if exists */
#ifdef slcb_SocketTriggerEventHandler
#define _SlDrvHandleSocketTriggerEvents slcb_SocketTriggerEventHandler
#endif


#endif

#define SL_CONCAT(x,y)  x ## y
#define SL_CONCAT2(x,y) SL_CONCAT(x,y)


#if (!defined(SL_RUNTIME_EVENT_REGISTERATION))

/*
 * The section below handles the external lib event registration
 * according to the desired events it specified in its API header file.
 * The external lib should be first installed by the user (see user.h)
 */
#ifdef SL_EXT_LIB_1

/* General Event Registration */
    #if SL_CONCAT2(SL_EXT_LIB_1, _NOTIFY_GENERAL_EVENT)
    extern _SlEventPropogationStatus_e SL_CONCAT2(SL_EXT_LIB_1, _GeneralEventHdl) (SlDeviceEvent_t *);
    #define SlExtLib1GeneralEventHandler   SL_CONCAT2(SL_EXT_LIB_1, _GeneralEventHdl)
    
    #undef EXT_LIB_REGISTERED_GENERAL_EVENTS
    #define EXT_LIB_REGISTERED_GENERAL_EVENTS
    #endif
    
    /* Wlan Event Registration */
    #if SL_CONCAT2(SL_EXT_LIB_1, _NOTIFY_WLAN_EVENT)
    extern _SlEventPropogationStatus_e SL_CONCAT2(SL_EXT_LIB_1, _WlanEventHdl) (SlWlanEvent_t *);
    #define SlExtLib1WlanEventHandler   SL_CONCAT2(SL_EXT_LIB_1, _WlanEventHdl)
    
    #undef EXT_LIB_REGISTERED_WLAN_EVENTS
    #define EXT_LIB_REGISTERED_WLAN_EVENTS
    #endif
    
    /* NetApp Event Registration */
    #if SL_CONCAT2(SL_EXT_LIB_1, _NOTIFY_NETAPP_EVENT)
    extern _SlEventPropogationStatus_e SL_CONCAT2(SL_EXT_LIB_1, _NetAppEventHdl) (SlNetAppEvent_t *);
    #define SlExtLib1NetAppEventHandler SL_CONCAT2(SL_EXT_LIB_1, _NetAppEventHdl)

    #undef EXT_LIB_REGISTERED_NETAPP_EVENTS
    #define EXT_LIB_REGISTERED_NETAPP_EVENTS
    #endif

    /* Http Server Event Registration */
    #if SL_CONCAT2(SL_EXT_LIB_1, _NOTIFY_HTTP_SERVER_EVENT)
    extern _SlEventPropogationStatus_e SL_CONCAT2(SL_EXT_LIB_1, _HttpServerEventHdl) (SlNetAppHttpServerEvent_t* , SlNetAppHttpServerResponse_t*);
    #define SlExtLib1HttpServerEventHandler SL_CONCAT2(SL_EXT_LIB_1, _HttpServerEventHdl)

    #undef EXT_LIB_REGISTERED_HTTP_SERVER_EVENTS
    #define EXT_LIB_REGISTERED_HTTP_SERVER_EVENTS
    #endif

    /* Socket Event Registration */
    #if SL_CONCAT2(SL_EXT_LIB_1, _NOTIFY_SOCK_EVENT)
    extern _SlEventPropogationStatus_e SL_CONCAT2(SL_EXT_LIB_1, _SockEventHdl) (SlSockEvent_t *);
    #define SlExtLib1SockEventHandler SL_CONCAT2(SL_EXT_LIB_1, _SockEventHdl)

    #undef EXT_LIB_REGISTERED_SOCK_EVENTS
    #define EXT_LIB_REGISTERED_SOCK_EVENTS
    #endif

    /* Fatal Error Event Registration */
    #if SL_CONCAT2(SL_EXT_LIB_1, _NOTIFY_FATAL_ERROR_EVENT)
    extern _SlEventPropogationStatus_e SL_CONCAT2(SL_EXT_LIB_1, _FatalErrorEventHdl) (SlDeviceEvent_t *);
    #define SlExtLib1FatalErrorEventHandler   SL_CONCAT2(SL_EXT_LIB_1, _FatalErrorEventHdl)
    
    #undef EXT_LIB_REGISTERED_FATAL_ERROR_EVENTS
    #define EXT_LIB_REGISTERED_FATAL_ERROR_EVENTS
    #endif

    /* NetApp requests events registration */
    #if SL_CONCAT2(SL_EXT_LIB_1, _NOTIFY_NETAPP_REQUEST_EVENT)
    extern _SlEventPropogationStatus_e SL_CONCAT2(SL_EXT_LIB_1, _NetAppRequestEventHdl) (SlNetAppRequest_t*, SlNetAppResponse_t *);
    #define SlExtLib1NetAppRequestEventHandler   SL_CONCAT2(SL_EXT_LIB_1, _NetAppRequestEventHdl)

    #undef EXT_LIB_REGISTERED_NETAPP_REQUEST_EVENTS
    #define EXT_LIB_REGISTERED_NETAPP_REQUEST_EVENTS
    #endif

#endif


#ifdef SL_EXT_LIB_2

    /* General Event Registration */
    #if SL_CONCAT2(SL_EXT_LIB_2, _NOTIFY_GENERAL_EVENT)
    extern _SlEventPropogationStatus_e SL_CONCAT2(SL_EXT_LIB_2, _GeneralEventHdl) (SlDeviceEvent_t *);
    #define SlExtLib2GeneralEventHandler   SL_CONCAT2(SL_EXT_LIB_2, _GeneralEventHdl)

    #undef EXT_LIB_REGISTERED_GENERAL_EVENTS
    #define EXT_LIB_REGISTERED_GENERAL_EVENTS
    #endif

    /* Wlan Event Registration */
    #if SL_CONCAT2(SL_EXT_LIB_2, _NOTIFY_WLAN_EVENT)
    extern _SlEventPropogationStatus_e SL_CONCAT2(SL_EXT_LIB_2, _WlanEventHdl) (SlWlanEvent_t *);
    #define SlExtLib2WlanEventHandler   SL_CONCAT2(SL_EXT_LIB_2, _WlanEventHdl)

    #undef EXT_LIB_REGISTERED_WLAN_EVENTS
    #define EXT_LIB_REGISTERED_WLAN_EVENTS
    #endif

    /* NetApp Event Registration */
    #if SL_CONCAT2(SL_EXT_LIB_2, _NOTIFY_NETAPP_EVENT)
    extern _SlEventPropogationStatus_e SL_CONCAT2(SL_EXT_LIB_2, _NetAppEventHdl) (SlNetAppEvent_t *);
    #define SlExtLib2NetAppEventHandler SL_CONCAT2(SL_EXT_LIB_2, _NetAppEventHdl)

    #undef EXT_LIB_REGISTERED_NETAPP_EVENTS
    #define EXT_LIB_REGISTERED_NETAPP_EVENTS
    #endif

    /* Http Server Event Registration */
    #if SL_CONCAT2(SL_EXT_LIB_2, _NOTIFY_HTTP_SERVER_EVENT)
    extern _SlEventPropogationStatus_e SL_CONCAT2(SL_EXT_LIB_2, _HttpServerEventHdl) (SlNetAppHttpServerEvent_t* , SlNetAppHttpServerResponse_t*);
    #define SlExtLib2HttpServerEventHandler SL_CONCAT2(SL_EXT_LIB_2, _HttpServerEventHdl)

    #undef EXT_LIB_REGISTERED_HTTP_SERVER_EVENTS
    #define EXT_LIB_REGISTERED_HTTP_SERVER_EVENTS
    #endif

    /* Socket Event Registration */
    #if SL_CONCAT2(SL_EXT_LIB_2, _NOTIFY_SOCK_EVENT)
    extern _SlEventPropogationStatus_e SL_CONCAT2(SL_EXT_LIB_2, _SockEventHdl) (SlSockEvent_t *);
    #define SlExtLib2SockEventHandler SL_CONCAT2(SL_EXT_LIB_2, _SockEventHdl)

    #undef EXT_LIB_REGISTERED_SOCK_EVENTS
    #define EXT_LIB_REGISTERED_SOCK_EVENTS
    #endif

    /* Fatal Error Event Registration */
    #if SL_CONCAT2(SL_EXT_LIB_2, _NOTIFY_FATAL_ERROR_EVENT)
    extern _SlEventPropogationStatus_e SL_CONCAT2(SL_EXT_LIB_2, _FatalErrorEventHdl) (SlDeviceEvent_t *);
    #define SlExtLib2FatalErrorEventHandler   SL_CONCAT2(SL_EXT_LIB_2, _FatalErrorEventHdl)

    #undef EXT_LIB_REGISTERED_FATAL_ERROR_EVENTS
    #define EXT_LIB_REGISTERED_FATAL_ERROR_EVENTS
    #endif

    /* NetApp requests events registration */
    #if SL_CONCAT2(SL_EXT_LIB_2, _NOTIFY_NETAPP_REQUEST_EVENT)
    extern _SlEventPropogationStatus_e SL_CONCAT2(SL_EXT_LIB_2, _NetAppRequestEventHdl) (SlNetAppRequest_t*, SlNetAppResponse_t *);
    #define SlExtLib1NetAppRequestEventHandler   SL_CONCAT2(SL_EXT_LIB_2, _NetAppRequestEventHdl)

    #undef EXT_LIB_REGISTERED_NETAPP_REQUEST_EVENTS
    #define EXT_LIB_REGISTERED_NETAPP_REQUEST_EVENTS
    #endif

#endif

#ifdef SL_EXT_LIB_3

  /* General Event Registration */
    #if SL_CONCAT2(SL_EXT_LIB_3, _NOTIFY_GENERAL_EVENT)
    extern _SlEventPropogationStatus_e SL_CONCAT2(SL_EXT_LIB_3, _GeneralEventHdl) (SlDeviceEvent_t *);
    #define SlExtLib3GeneralEventHandler   SL_CONCAT2(SL_EXT_LIB_3, _GeneralEventHdl)

    #undef EXT_LIB_REGISTERED_GENERAL_EVENTS
    #define EXT_LIB_REGISTERED_GENERAL_EVENTS
    #endif

    /* Wlan Event Registration */
    #if SL_CONCAT2(SL_EXT_LIB_3, _NOTIFY_WLAN_EVENT)
    extern _SlEventPropogationStatus_e SL_CONCAT2(SL_EXT_LIB_3, _WlanEventHdl) (SlWlanEvent_t *);
    #define SlExtLib3WlanEventHandler   SL_CONCAT2(SL_EXT_LIB_3, _WlanEventHdl)

    #undef EXT_LIB_REGISTERED_WLAN_EVENTS
    #define EXT_LIB_REGISTERED_WLAN_EVENTS
    #endif

    /* NetApp Event Registration */
    #if SL_CONCAT2(SL_EXT_LIB_3, _NOTIFY_NETAPP_EVENT)
    extern _SlEventPropogationStatus_e SL_CONCAT2(SL_EXT_LIB_3, _NetAppEventHdl) (SlNetAppEvent_t *);
    #define SlExtLib3NetAppEventHandler SL_CONCAT2(SL_EXT_LIB_3, _NetAppEventHdl)

    #undef EXT_LIB_REGISTERED_NETAPP_EVENTS
    #define EXT_LIB_REGISTERED_NETAPP_EVENTS
    #endif

    /* Http Server Event Registration */
    #if SL_CONCAT2(SL_EXT_LIB_3, _NOTIFY_HTTP_SERVER_EVENT)
    extern _SlEventPropogationStatus_e SL_CONCAT2(SL_EXT_LIB_3, _HttpServerEventHdl) (SlNetAppHttpServerEvent_t* , SlNetAppHttpServerResponse_t*);
    #define SlExtLib3HttpServerEventHandler SL_CONCAT2(SL_EXT_LIB_3, _HttpServerEventHdl)

    #undef EXT_LIB_REGISTERED_HTTP_SERVER_EVENTS
    #define EXT_LIB_REGISTERED_HTTP_SERVER_EVENTS
    #endif

    /* Socket Event Registration */
    #if SL_CONCAT2(SL_EXT_LIB_3, _NOTIFY_SOCK_EVENT)
    extern _SlEventPropogationStatus_e SL_CONCAT2(SL_EXT_LIB_3, _SockEventHdl) (SlSockEvent_t *);
    #define SlExtLib3SockEventHandler SL_CONCAT2(SL_EXT_LIB_3, _SockEventHdl)

    #undef EXT_LIB_REGISTERED_SOCK_EVENTS
    #define EXT_LIB_REGISTERED_SOCK_EVENTS
    #endif


    /* Fatal Error Event Registration */
    #if SL_CONCAT2(SL_EXT_LIB_3, _NOTIFY_FATAL_ERROR_EVENT)
    extern _SlEventPropogationStatus_e SL_CONCAT2(SL_EXT_LIB_3, _FatalErrorEventHdl) (SlDeviceEvent_t *);
    #define SlExtLib3FatalErrorEventHandler   SL_CONCAT2(SL_EXT_LIB_3, _FatalErrorEventHdl)

    #undef EXT_LIB_REGISTERED_FATAL_ERROR_EVENTS
    #define EXT_LIB_REGISTERED_FATAL_ERROR_EVENTS
    #endif

    /* NetApp requests events registration */
    #if SL_CONCAT2(SL_EXT_LIB_3, _NOTIFY_NETAPP_REQUEST_EVENT)
    extern _SlEventPropogationStatus_e SL_CONCAT2(SL_EXT_LIB_3, _NetAppRequestEventHdl) (SlNetAppRequest_t*, SlNetAppResponse_t *);
    #define SlExtLib1NetAppRequestEventHandler   SL_CONCAT2(SL_EXT_LIB_3, _NetAppRequestEventHdl)

    #undef EXT_LIB_REGISTERED_NETAPP_REQUEST_EVENTS
    #define EXT_LIB_REGISTERED_NETAPP_REQUEST_EVENTS
    #endif

#endif

#ifdef SL_EXT_LIB_4

    /* General Event Registration */
    #if SL_CONCAT2(SL_EXT_LIB_4, _NOTIFY_GENERAL_EVENT)
    extern _SlEventPropogationStatus_e SL_CONCAT2(SL_EXT_LIB_4, _GeneralEventHdl) (SlDeviceEvent_t *);
    #define SlExtLib4GeneralEventHandler   SL_CONCAT2(SL_EXT_LIB_4, _GeneralEventHdl)

    #undef EXT_LIB_REGISTERED_GENERAL_EVENTS
    #define EXT_LIB_REGISTERED_GENERAL_EVENTS
    #endif

    /* Wlan Event Registration */
    #if SL_CONCAT2(SL_EXT_LIB_4, _NOTIFY_WLAN_EVENT)
    extern _SlEventPropogationStatus_e SL_CONCAT2(SL_EXT_LIB_4, _WlanEventHdl) (SlWlanEvent_t *);
    #define SlExtLib4WlanEventHandler   SL_CONCAT2(SL_EXT_LIB_4, _WlanEventHdl)

    #undef EXT_LIB_REGISTERED_WLAN_EVENTS
    #define EXT_LIB_REGISTERED_WLAN_EVENTS
    #endif

    /* NetApp Event Registration */
    #if SL_CONCAT2(SL_EXT_LIB_4, _NOTIFY_NETAPP_EVENT)
    extern _SlEventPropogationStatus_e SL_CONCAT2(SL_EXT_LIB_4, _NetAppEventHdl) (SlNetAppEvent_t *);
    #define SlExtLib4NetAppEventHandler SL_CONCAT2(SL_EXT_LIB_4, _NetAppEventHdl)

    #undef EXT_LIB_REGISTERED_NETAPP_EVENTS
    #define EXT_LIB_REGISTERED_NETAPP_EVENTS
    #endif

    /* Http Server Event Registration */
    #if SL_CONCAT2(SL_EXT_LIB_4, _NOTIFY_HTTP_SERVER_EVENT)
    extern _SlEventPropogationStatus_e SL_CONCAT2(SL_EXT_LIB_4, _HttpServerEventHdl) (SlNetAppHttpServerEvent_t* , SlNetAppHttpServerResponse_t*);
    #define SlExtLib4HttpServerEventHandler SL_CONCAT2(SL_EXT_LIB_4, _HttpServerEventHdl)

    #undef EXT_LIB_REGISTERED_HTTP_SERVER_EVENTS
    #define EXT_LIB_REGISTERED_HTTP_SERVER_EVENTS
    #endif

    /* Socket Event Registration */
    #if SL_CONCAT2(SL_EXT_LIB_4, _NOTIFY_SOCK_EVENT)
    extern _SlEventPropogationStatus_e SL_CONCAT2(SL_EXT_LIB_4, _SockEventHdl) (SlSockEvent_t *);
    #define SlExtLib4SockEventHandler SL_CONCAT2(SL_EXT_LIB_4, _SockEventHdl)

    #undef EXT_LIB_REGISTERED_SOCK_EVENTS
    #define EXT_LIB_REGISTERED_SOCK_EVENTS
    #endif

    /* Fatal Error Event Registration */
    #if SL_CONCAT2(SL_EXT_LIB_4, _NOTIFY_FATAL_ERROR_EVENT)
    extern _SlEventPropogationStatus_e SL_CONCAT2(SL_EXT_LIB_4, _FatalErrorEventHdl) (SlDeviceEvent_t *);
    #define SlExtLib4FatalErrorEventHandler   SL_CONCAT2(SL_EXT_LIB_4, _FatalErrorEventHdl)

    #undef EXT_LIB_REGISTERED_FATAL_ERROR_EVENTS
    #define EXT_LIB_REGISTERED_FATAL_ERROR_EVENTS
    #endif

    /* NetApp requests events registration */
    #if SL_CONCAT2(SL_EXT_LIB_4, _NOTIFY_NETAPP_REQUEST_EVENT)
    extern _SlEventPropogationStatus_e SL_CONCAT2(SL_EXT_LIB_4, _NetAppRequestEventHdl) (SlNetAppRequest_t*, SlNetAppResponse_t *);
    #define SlExtLib1NetAppRequestEventHandler   SL_CONCAT2(SL_EXT_LIB_4, _NetAppRequestEventHdl)

    #undef EXT_LIB_REGISTERED_NETAPP_REQUEST_EVENTS
    #define EXT_LIB_REGISTERED_NETAPP_REQUEST_EVENTS
    #endif

#endif

#ifdef SL_EXT_LIB_5

    /* General Event Registration */
    #if SL_CONCAT2(SL_EXT_LIB_5, _NOTIFY_GENERAL_EVENT)
    extern _SlEventPropogationStatus_e SL_CONCAT2(SL_EXT_LIB_5, _GeneralEventHdl) (SlDeviceEvent_t *);
    #define SlExtLib5GeneralEventHandler   SL_CONCAT2(SL_EXT_LIB_5, _GeneralEventHdl)

    #undef EXT_LIB_REGISTERED_GENERAL_EVENTS
    #define EXT_LIB_REGISTERED_GENERAL_EVENTS
    #endif

    /* Wlan Event Registration */
    #if SL_CONCAT2(SL_EXT_LIB_5, _NOTIFY_WLAN_EVENT)
    extern _SlEventPropogationStatus_e SL_CONCAT2(SL_EXT_LIB_5, _WlanEventHdl) (SlWlanEvent_t *);
    #define SlExtLib5WlanEventHandler   SL_CONCAT2(SL_EXT_LIB_5, _WlanEventHdl)

    #undef EXT_LIB_REGISTERED_WLAN_EVENTS
    #define EXT_LIB_REGISTERED_WLAN_EVENTS
    #endif

    /* NetApp Event Registration */
    #if SL_CONCAT2(SL_EXT_LIB_5, _NOTIFY_NETAPP_EVENT)
    extern _SlEventPropogationStatus_e SL_CONCAT2(SL_EXT_LIB_5, _NetAppEventHdl) (SlNetAppEvent_t *);
    #define SlExtLib5NetAppEventHandler SL_CONCAT2(SL_EXT_LIB_5, _NetAppEventHdl)

    #undef EXT_LIB_REGISTERED_NETAPP_EVENTS
    #define EXT_LIB_REGISTERED_NETAPP_EVENTS
    #endif

    /* Http Server Event Registration */
    #if SL_CONCAT2(SL_EXT_LIB_5, _NOTIFY_HTTP_SERVER_EVENT)
    extern _SlEventPropogationStatus_e SL_CONCAT2(SL_EXT_LIB_5, _HttpServerEventHdl) (SlNetAppHttpServerEvent_t* , SlNetAppHttpServerResponse_t*);
    #define SlExtLib5HttpServerEventHandler SL_CONCAT2(SL_EXT_LIB_5, _HttpServerEventHdl)

    #undef EXT_LIB_REGISTERED_HTTP_SERVER_EVENTS
    #define EXT_LIB_REGISTERED_HTTP_SERVER_EVENTS
    #endif

    /* Socket Event Registration */
    #if SL_CONCAT2(SL_EXT_LIB_5, _NOTIFY_SOCK_EVENT)
    extern _SlEventPropogationStatus_e SL_CONCAT2(SL_EXT_LIB_5, _SockEventHdl) (SlSockEvent_t *);
    #define SlExtLib5SockEventHandler SL_CONCAT2(SL_EXT_LIB_5, _SockEventHdl)

    #undef EXT_LIB_REGISTERED_SOCK_EVENTS
    #define EXT_LIB_REGISTERED_SOCK_EVENTS
    #endif

    /* Fatal Error Event Registration */
    #if SL_CONCAT2(SL_EXT_LIB_5, _NOTIFY_FATAL_ERROR_EVENT)
    extern _SlEventPropogationStatus_e SL_CONCAT2(SL_EXT_LIB_5, _FatalErrorEventHdl) (SlDeviceEvent_t *);
    #define SlExtLib5FatalErrorEventHandler   SL_CONCAT2(SL_EXT_LIB_5, _FatalErrorEventHdl)

    #undef EXT_LIB_REGISTERED_FATAL_ERROR_EVENTS
    #define EXT_LIB_REGISTERED_FATAL_ERROR_EVENTS
    #endif

    /* NetApp requests events registration */
    #if SL_CONCAT2(SL_EXT_LIB_5, _NOTIFY_NETAPP_REQUEST_EVENT)
    extern _SlEventPropogationStatus_e SL_CONCAT2(SL_EXT_LIB_5, _NetAppRequestEventHdl) (SlNetAppRequest_t*, SlNetAppResponse_t *);
    #define SlExtLib1NetAppRequestEventHandler   SL_CONCAT2(SL_EXT_LIB_5, _NetAppRequestEventHdl)

    #undef EXT_LIB_REGISTERED_NETAPP_REQUEST_EVENTS
    #define EXT_LIB_REGISTERED_NETAPP_REQUEST_EVENTS
    #endif

#endif

#if defined(EXT_LIB_REGISTERED_FATAL_ERROR_EVENTS)
extern void _SlDrvHandleFatalErrorEvents(SlDeviceEvent_t *slFatalErrorEvent);
#endif

#if defined(EXT_LIB_REGISTERED_GENERAL_EVENTS)
extern void _SlDrvHandleGeneralEvents(SlDeviceEvent_t *slGeneralEvent);
#endif

#if defined(EXT_LIB_REGISTERED_WLAN_EVENTS)
extern void _SlDrvHandleWlanEvents(SlWlanEvent_t *slWlanEvent);
#endif

#if defined (EXT_LIB_REGISTERED_NETAPP_EVENTS)
extern void _SlDrvHandleNetAppEvents(SlNetAppEvent_t *slNetAppEvent);
#endif

#if defined(EXT_LIB_REGISTERED_HTTP_SERVER_EVENTS)
extern void _SlDrvHandleHttpServerEvents(SlNetAppHttpServerEvent_t *slHttpServerEvent, SlNetAppHttpServerResponse_t *slHttpServerResponse);
#endif

#if defined(EXT_LIB_REGISTERED_SOCK_EVENTS)
extern void _SlDrvHandleSockEvents(SlSockEvent_t *slSockEvent);
#endif

#if defined(EXT_LIB_REGISTERED_NETAPP_REQUEST_EVENTS)
extern void _SlDrvHandleNetAppRequestEvents(SlNetAppRequest_t *pNetAppRequest, SlNetAppResponse_t *pNetAppResponse);
#endif

#endif //#if (defined(SL_RUNTIME_EVENT_REGISTERATION))

typedef _SlReturnVal_t (*_SlSpawnEntryFunc_t)(void* pValue);

#define SL_SPAWN_FLAG_FROM_SL_IRQ_HANDLER    (0x1)
#define SL_SPAWN_FLAG_FROM_CMD_CTX           (0x2)
#define SL_SPAWN_FLAG_FROM_CMD_PROCESS       (0x3)

#ifdef SL_PLATFORM_MULTI_THREADED
    #include "source/spawn.h"
#else
    #include "source/nonos.h"
#endif

/*!
    \endcond
*/


/* Async functions description*/


/*!
    \brief Fatal Error event for inspecting fatal error

    \param[out]      pSlFatalErrorEvent   pointer to SlDeviceFatal_t
    \return None
    \sa
    \note
    \warning
    \par    Example
    \code
        For pSlDeviceFatal->Id = SL_DEVICE_EVENT_FATAL_DEVICE_ABORT
                Indicates a severe error occured and the device stopped
        Use pSlDeviceFatal->Data.DeviceAssert fields
                    - Code: An idication of the abort type
                    - Value: The abort data


        For pSlDeviceFatal->Id = SL_DEVICE_EVENT_FATAL_NO_CMD_ACK
                Indicates that the command sent to the device had no ack
        Use pSlDeviceFatal->Data.NoCmdAck fields
                    - Code: An idication of the cmd opcode

        For pSlDeviceFatal->Id = SL_DEVICE_EVENT_FATAL_CMD_TIMEOUT
                Indicates that the command got a timeout while waiting for its async response
        Use pSlDeviceFatal->Data.CmdTimeout fields
                    - Code: An idication of the asyncevent opcode


        For pSlDeviceFatal->Id = SL_DEVICE_EVENT_FATAL_DRIVER_ABORT
                Indicates a severe error occured in the driver
        Use pSlDeviceFatal->Data.DeviceAssert fields
                    - None.

        For pSlDeviceFatal->Id = SL_DEVICE_EVENT_FATAL_SYNC_LOSS
                Indicates a sync loss with the device
        Use pSlDeviceFatal->Data.DeviceAssert fields
                    - None.
    \endcode
    \code
        Example for fatal error
             printf(Abort type =%d Abort Data=0x%x\n\n",
                   pSlDeviceFatal->Data.deviceReport.AbortType,
                   pSlDeviceFatal->Data.deviceReport.AbortData);
    \endcode
*/
#if (defined(slcb_DeviceFatalErrorEvtHdlr))
extern void slcb_DeviceFatalErrorEvtHdlr(SlDeviceFatal_t *pSlFatalErrorEvent);
#endif


/*!
    \brief General async event for inspecting general events

    \param[out]      pSlDeviceEvent   pointer to SlDeviceEvent_t
    \return None
    \sa
    \note
    \warning
    \par    Example
    \code
          For pSlDeviceEvent->Id = SL_DEVICE_EVENT_RESET_REQUEST
          Use pSlDeviceEvent->Data.ResetRequest fields
                  - Status: An error code indication from the device
                  - Source: The sender originator which is based on SlDeviceSource_e enum

          For pSlDeviceEvent->Id = SL_DEVICE_EVENT_ERROR
          Use pSlDeviceEvent->Data.Error fields
                  - Code: An error code indication from the device
                  - Source: The sender originator which is based on SlErrorSender_e enum
    \endcode
    \code
        Example for error event:
            printf(General Event Handler - ID=%d Sender=%d\n\n",
                   pSlDeviceEvent->Data.Error.Code,  // the error code
                   pSlDeviceEvent->Data.Error.Source); // the error source
    \endcode

*/
#if (defined(slcb_DeviceGeneralEvtHdlr))
extern void slcb_DeviceGeneralEvtHdlr(SlDeviceEvent_t *pSlDeviceEvent);
#endif

/*!
    \brief WLAN Async event handler

    \param[out]      pSlWlanEvent   pointer to SlWlanEvent_t data
    \return None
    \sa
    \note
    \warning
    \par             Example
    \code
         For pSlWlanEvent->Id = SL_WLAN_EVENT_CONNECT, STA connection indication event
         Use pSlWlanEvent->Data.Connect main fields
                 - SsidLen
                 - SsidName
                 - Bssid

         For pSlWlanEvent->Id = SL_WLAN_EVENT_P2P_CONNECT, P2P client connection indication event
         Use pSlWlanEvent->Data.P2PConnect main fields
                 - SsidLen
                 - SsidName
                 - Bssid
                 - GoDeviceNameLen
                 - GoDeviceName

         For pSlWlanEvent->Id = SL_WLAN_EVENT_DISCONNECT, STA client disconnection event
         Use pSlWlanEvent->Data.Disconnect main fields:
                 - SsidLen
                 - SsidName
                 - Bssid
                 - ReasonCode

         For pSlWlanEvent->Id = SL_WLAN_EVENT_P2P_DISCONNECT, P2P client disconnection event
         Use pSlWlanEvent->Data.P2PDisconnect main fields:
                 - SsidLen
                 - SsidName
                 - Bssid
                 - ReasonCode
                 - GoDeviceNameLen
                 - GoDeviceName

         For pSlWlanEvent->Id = SL_WLAN_EVENT_STA_ADDED, AP connected STA
         Use pSlWlanEvent->Data.STAAdded fields:
                 - Mac

         For pSlWlanEvent->Id = SL_WLAN_EVENT_STA_REMOVED, AP disconnected STA
         Use pSlWlanEvent->Data.STARemoved fields:
                 - Mac

         For pSlWlanEvent->Id = SL_WLAN_EVENT_P2P_CLIENT_ADDED, P2P(Go) connected P2P(Client)
         Use pSlWlanEvent->Data.P2PClientAdded fields:
                 - Mac
                 - GoDeviceNameLen
                 - GoDeviceName
                 - OwnSsidLen
                 - OwnSsid

         For pSlWlanEvent->Id = SL_WLAN_EVENT_P2P_CLIENT_REMOVED, P2P(Go) disconnected P2P(Client)
         Use pSlWlanEvent->Data.P2PClientRemoved fields:
                 - Mac
                 - GoDeviceNameLen
                 - GoDeviceName
                 - OwnSsidLen
                 - OwnSsid

         For pSlWlanEvent->Id = SL_WLAN_P2P_DEV_FOUND_EVENT
         Use pSlWlanEvent->Data.P2PDevFound fields:
                - GoDeviceNameLen
                - GoDeviceName
                - Mac
                - WpsMethod

         For pSlWlanEvent->Id = SL_WLAN_EVENT_P2P_REQUEST
         Use pSlWlanEvent->Data.P2PRequest fields
                - GoDeviceNameLen
                - GoDeviceName
                - Mac
                - WpsMethod

         For pSlWlanEvent->Id = SL_WLAN_EVENT_P2P_CONNECTFAIL, P2P only
         Use pSlWlanEvent->Data.P2PConnectFail fields:
                    - Status

         For pSlWlanEvent->Id = SL_WLAN_EVENT_PROVISIONING_STATUS
         Use pSlWlanEvent->Data.ProvisioningStatus fields
                  - Status

         For pSlWlanEvent->Id = SL_WLAN_EVENT_PROVISIONING_PROFILE_ADDED
         Use pSlWlanEvent->Data.ProvisioningProfileAdded fields:
                 - Status
                 - SsidLen
                 - Ssid
                 - Reserved
        For pSlWlanEvent->Id = SL_WLAN_EVENT_LINK_QUALITY_TRIGGER
        Use pSlWlanEvent->Data.LinkQualityTrigger fields:
                 - Data
                 - TriggerId

    \endcode
*/
#if (defined(slcb_WlanEvtHdlr))
extern void slcb_WlanEvtHdlr(SlWlanEvent_t* pSlWlanEvent);
#endif


/*!
    \brief NETAPP Async event handler

    \param[out]      pSlNetAppEvent   pointer to SlNetAppEvent_t data
    \return None
    \sa
    \note
    \warning
    \par    Example
    \code
        For pSlNetAppEvent->Id = SL_NETAPP_EVENT_IPV4_ACQUIRED/SL_NETAPP_EVENT_IPV6_ACQUIRED
        Use pSlNetAppEvent->Data.ipAcquiredV4 (V6) fields
           - ip
           - gateway
           - dns

        For pSlNetAppEvent->Id = SL_NETAPP_IP_LEASED_EVENT, AP or P2P go dhcp lease event
        Use pSlNetAppEvent->Data.ipLeased  fields
           - ip_address
           - lease_time
           - mac

        For pSlNetApp->Id = SL_NETAPP_IP_RELEASED_EVENT, AP or P2P go dhcp ip release event
        Use pSlNetAppEvent->Data.ipReleased fields
            - ip_address
            - mac
            - reason
    \endcode
*/
#if (defined(slcb_NetAppEvtHdlr))
extern void slcb_NetAppEvtHdlr(SlNetAppEvent_t* pSlNetAppEvent);
#endif

/*!
    \brief Socket Async event handler

    \param[out]      pSlSockEvent   pointer to SlSockEvent_t data
    \return None
    \sa
    \note
    \warning
    \par             Example
    \code
             For pSlSockEvent->Event = SL_SOCKET_TX_FAILED_EVENT
             Use pSlSockEvent->SockTxFailData fields
                    - sd
                    - status
             For pSlSockEvent->Event = SL_SOCKET_ASYNC_EVENT
             Use pSlSockEvent->SockAsyncData fields
                    - sd
                    - type
                        - SL_SSL_ACCEPT
                        - SL_WLAN_RX_FRAGMENTATION_TOO_BIG
                        - SL_OTHER_SIDE_CLOSE_SSL_DATA_NOT_ENCRYPTED
                    - val
    \endcode

*/
#if (defined(slcb_SockEvtHdlr))
extern void slcb_SockEvtHdlr(SlSockEvent_t* pSlSockEvent);
#endif

/*!
    \brief HTTP server async event

    \param[out] pSlHttpServerEvent   Pointer to SlNetAppHttpServerEvent_t
    \param[in]  pSlHttpServerResponse Pointer to SlNetAppHttpServerResponse_t

    \return     None
    \sa         slcb_NetAppRequestHdlr
    \note
    \warning
    \par        Example
    \code
          For pSlHttpServerResponse->Event = SL_NETAPP_HTTPGETTOKENVALUE_EVENT
          Use pSlHttpServerEvent->EventData fields
                - httpTokenName
                - data
                - len
          And pSlHttpServerResponse->ResponseData fields
                - data
                - len

          For pSlHttpServerEvent->Event = SL_NETAPP_HTTPPOSTTOKENVALUE_EVENT
          Use pSlHttpServerEvent->EventData.httpPostData fields
                - action
                - token_name
                - token_value
          And pSlHttpServerResponse->ResponseData fields:
                - data
                - len
    \endcode
*/
#if (defined(slcb_NetAppHttpServerHdlr))
extern void slcb_NetAppHttpServerHdlr(SlNetAppHttpServerEvent_t *pSlHttpServerEvent, SlNetAppHttpServerResponse_t *pSlHttpServerResponse);
#endif

/*!
    \brief General netapp async event

    \param[out] pNetAppRequest   Pointer to SlNetAppRequest_t
    \param[in]  pNetAppResponse Pointer to SlNetAppResponse_t

    \return     None
    \sa         slcb_NetAppHttpServerHdlr
    \note
    \warning
    \par        Example
    \code
        TBD
    \endcode
*/
#if (defined(slcb_NetAppRequestHdlr))
extern void slcb_NetAppRequestHdlr(SlNetAppRequest_t *pNetAppRequest, SlNetAppResponse_t *pNetAppResponse);
#endif

/*!
    \brief A handler for freeing the memory of the NetApp response.

    \param[in,out] buffer        Pointer to the buffer to free

    \return        None
    \sa
    \note
    \warning
    \par           Example
    \code
        TBD
    \endcode
*/
#if (defined(slcb_NetAppRequestMemFree))
extern void slcb_NetAppRequestMemFree (_u8 *buffer);
#endif

/*!
    \brief      Get the timer counter value (timestamp).\n
                The timer must count from zero to its MAX value.
                For non-os application, this routine must be implemented.
    \param      None
    \return     Returns 32-bit timer counter value (ticks unit)
    \sa
    \note
    \note       belongs to \ref porting_sec
    \warning
*/
#if defined (slcb_GetTimestamp)
extern _u32 slcb_GetTimestamp(void);
#endif


/*!
    \brief      Socket trigger routine.
                This routine will notify the application that a netwrok activity has 
                been completed on the required socket/s.
    
    \param[out] pSlSockTriggerEvent   pointer to SlSockTriggerEvent_t data
    \return     None.
    \sa
    \note
    \note       belongs to \ref porting_sec
    \warning
*/
#if (defined(slcb_SocketTriggerEventHandler))
extern void slcb_SocketTriggerEventHandler(SlSockTriggerEvent_t* pSlSockTriggerEvent);
#endif


/*!
 Close the Doxygen group.
 @}

 */

#ifdef  __cplusplus
}
#endif /* __cplusplus */

#endif    /*  __SIMPLELINK_H__ */