File: main.c

package info (click to toggle)
wolfssl 5.8.4-1
  • links: PTS
  • area: main
  • in suites: forky, sid
  • size: 117,604 kB
  • sloc: ansic: 1,584,954; asm: 481,206; sh: 11,586; cs: 6,596; xml: 3,878; perl: 3,291; makefile: 2,058; ada: 1,891; javascript: 748; python: 636; cpp: 131; ruby: 118; objc: 80; tcl: 73
file content (94 lines) | stat: -rw-r--r-- 2,953 bytes parent folder | download | duplicates (5)
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
/* main.c */

#include "main.h"

/* SD card open/close utility functions */
#include "util.h"

#if !BSPCFG_ENABLE_IO_SUBSYSTEM
#error This application requires BSPCFG_ENABLE_IO_SUBSYSTEM defined \
    non-zero in user_config.h. Please recompile BSP with this option.
#endif

#ifndef BSP_DEFAULT_IO_CHANNEL_DEFINED
#error This application requires BSP_DEFAULT_IO_CHANNEL to be not NULL. \
    Please set corresponding BSPCFG_ENABLE_TTYx to non-zero in \
    user_config.h and recompile BSP with this option.
#endif

TASK_TEMPLATE_STRUCT MQX_template_list[] =
{
    /*  Task number, Entry point, Stack, Pri, String, Auto? */
    {MAIN_TASK,   Main_task,   20000,  9,   "main", MQX_AUTO_START_TASK},
    {0,           0,           0,     0,   0,      0,                 }
};

#if defined BSP_SDCARD_ESDHC_CHANNEL
    #if ! BSPCFG_ENABLE_ESDHC
        #error This application requires BSPCFG_ENABLE_ESDHC defined \
            non-zero in user_config.h. Please recompile libraries with \
            this option.
    #endif

#elif defined BSP_SDCARD_SDHC_CHANNEL
    #if ! BSPCFG_ENABLE_SDHC
        #error This application requires BSPCFG_ENABLE_SDHC defined \
            non-zero in user_config.h. Please recompile libraries with \
            this option.
    #endif
#endif

#if defined (BSP_SDCARD_SPI_CHANNEL)
    #define SDCARD_COM_CHANNEL BSP_SDCARD_SPI_CHANNEL
#elif defined (BSP_SDCARD_ESDHC_CHANNEL)
    #define SDCARD_COM_CHANNEL BSP_SDCARD_ESDHC_CHANNEL
#elif defined (BSP_SDCARD_SDHC_CHANNEL)
    #define SDCARD_COM_CHANNEL BSP_SDCARD_SDHC_CHANNEL
#else
    #error "SDCARD low level communication device not defined!"
#endif

/* func_args from test.h */
typedef struct func_args {
    int    argc;
    char** argv;
    int    return_code;
} func_args;

/*TASK*-----------------------------------------------------------------
 * Function Name  : Main_task
 * Comments       :
 *    This task opens the SD card device and runs the
 *    wolfCrypt test functions located in test.c.
 *END------------------------------------------------------------------*/

void Main_task(uint32_t initial_data)
{
    int          ret = 0;
    func_args    args;
    char         filesystem_name[] = "a:";
    char         partman_name[]    = "pm:";
    MQX_FILE_PTR com_handle, sdcard_handle, filesystem_handle, partman_handle;

    ret = sdcard_open(&com_handle, &sdcard_handle, &partman_handle,
                      &filesystem_handle, partman_name, filesystem_name);
    if (ret != 0) {
        printf("error: sdcard_open(), ret = %d\n", ret);
        _mqx_exit(1);
    }
    printf("SD card installed to %s\n", filesystem_name);

    wolfcrypt_test(&args);

    ret = sdcard_close(&sdcard_handle, &partman_handle,
                       &filesystem_handle, partman_name, filesystem_name);
    if (ret != 0) {
        printf("error: sdcard_close(), ret = %d\n", ret);
        _mqx_exit(1);
    }
    printf("SD card uninstalled.\n");

    _mqx_exit(0);

}