[2e2d441] | 1 | /* |
---|
[7d69fb3] | 2 | * Shared Network Test Initialization File |
---|
[2e2d441] | 3 | */ |
---|
| 4 | |
---|
[e599318] | 5 | #ifndef RTEMS_BSD_TEST_DEFAULT_INIT_H |
---|
| 6 | #define RTEMS_BSD_TEST_DEFAULT_INIT_H |
---|
| 7 | |
---|
[2e2d441] | 8 | #include <bsp.h> |
---|
[fafa9e2] | 9 | #include <assert.h> |
---|
[2e2d441] | 10 | #include <stdlib.h> |
---|
| 11 | #include <stdio.h> |
---|
[efd75d2] | 12 | #include <unistd.h> |
---|
| 13 | |
---|
[32fd702] | 14 | #include <rtems/printer.h> |
---|
[9abf1d3] | 15 | #include <rtems/test-info.h> |
---|
[fafa9e2] | 16 | #include <rtems/stackchk.h> |
---|
[e599318] | 17 | #include <rtems/bsd/bsd.h> |
---|
[71703fec] | 18 | |
---|
[efd75d2] | 19 | static void default_wait_for_link_up( const char *name ) |
---|
| 20 | { |
---|
| 21 | size_t seconds = 0; |
---|
| 22 | while ( true ) { |
---|
| 23 | bool link_active = false; |
---|
| 24 | assert(rtems_bsd_iface_link_state( name, &link_active ) == 0); |
---|
| 25 | if (link_active) { |
---|
| 26 | return; |
---|
| 27 | } |
---|
| 28 | sleep( 1 ); |
---|
| 29 | ++seconds; |
---|
| 30 | if (seconds > 10) { |
---|
| 31 | printf("error: %s: no active link\n", name); |
---|
| 32 | assert(seconds < 10); |
---|
| 33 | } |
---|
| 34 | } |
---|
| 35 | } |
---|
| 36 | |
---|
[6514d56] | 37 | /* |
---|
| 38 | * Work around the need for this declr and not being able to include sys/ioctl.h. |
---|
| 39 | * |
---|
| 40 | * rtems/bdbuf.h have a call to it |
---|
| 41 | */ |
---|
| 42 | int ioctl(int fd, unsigned long request, ...); |
---|
| 43 | |
---|
[fafa9e2] | 44 | static void default_set_self_prio( rtems_task_priority prio ) |
---|
| 45 | { |
---|
| 46 | rtems_status_code sc; |
---|
| 47 | |
---|
| 48 | sc = rtems_task_set_priority(RTEMS_SELF, prio, &prio); |
---|
| 49 | assert(sc == RTEMS_SUCCESSFUL); |
---|
| 50 | } |
---|
| 51 | |
---|
| 52 | static void default_on_exit( int exit_code, void *arg ) |
---|
| 53 | { |
---|
[92e9493] | 54 | rtems_printer printer; |
---|
| 55 | |
---|
| 56 | rtems_print_printer_printf(&printer); |
---|
| 57 | rtems_stack_checker_report_usage_with_plugin(&printer); |
---|
[fafa9e2] | 58 | |
---|
| 59 | if ( exit_code == 0 ) { |
---|
[b4937b0] | 60 | rtems_test_end(TEST_NAME); |
---|
[fafa9e2] | 61 | } |
---|
| 62 | } |
---|
| 63 | |
---|
[2e2d441] | 64 | rtems_task Init( |
---|
| 65 | rtems_task_argument ignored |
---|
| 66 | ) |
---|
| 67 | { |
---|
[fafa9e2] | 68 | rtems_status_code sc; |
---|
| 69 | |
---|
[b8c7bf9] | 70 | /* |
---|
| 71 | * Default the syslog priority to 'debug' to aid developers. |
---|
| 72 | */ |
---|
| 73 | rtems_bsd_setlogpriority("debug"); |
---|
| 74 | |
---|
[b4937b0] | 75 | rtems_test_begin(TEST_NAME, TEST_STATE); |
---|
[71703fec] | 76 | |
---|
[336762e] | 77 | /* |
---|
| 78 | * BSD must support the new "shared IRQ PIC implementation" at this point. |
---|
| 79 | * BSPs must also provide rtems_interrupt_server_initialize() which |
---|
| 80 | * just requires including irq-server.[ch] in their build. |
---|
| 81 | */ |
---|
| 82 | |
---|
[fafa9e2] | 83 | on_exit( default_on_exit, NULL ); |
---|
| 84 | |
---|
[d0ecc91] | 85 | #ifdef DEFAULT_EARLY_INITIALIZATION |
---|
| 86 | early_initialization(); |
---|
| 87 | #endif |
---|
| 88 | |
---|
[fafa9e2] | 89 | /* Let other tasks run to complete background work */ |
---|
| 90 | default_set_self_prio( RTEMS_MAXIMUM_PRIORITY - 1 ); |
---|
| 91 | |
---|
[e51bc97] | 92 | rtems_bsd_initialize(); |
---|
[3be460f] | 93 | |
---|
[fafa9e2] | 94 | /* Let the callout timer allocate its resources */ |
---|
| 95 | sc = rtems_task_wake_after( 2 ); |
---|
| 96 | assert(sc == RTEMS_SUCCESSFUL); |
---|
| 97 | |
---|
[efd75d2] | 98 | #if defined(TEST_WAIT_FOR_LINK) |
---|
| 99 | /* |
---|
| 100 | * Per test option to wait for the network interface. If the address |
---|
| 101 | * is static the PHY may take a while to connect and bring the |
---|
| 102 | * interface online. |
---|
| 103 | */ |
---|
| 104 | default_wait_for_link_up( TEST_WAIT_FOR_LINK ); |
---|
| 105 | #endif |
---|
| 106 | |
---|
[71703fec] | 107 | test_main(); |
---|
| 108 | /* should not return */ |
---|
| 109 | |
---|
[fafa9e2] | 110 | assert( 0 ); |
---|
[2e2d441] | 111 | } |
---|
| 112 | |
---|
[90873cc] | 113 | /* |
---|
| 114 | * Configure LibBSD. |
---|
| 115 | */ |
---|
| 116 | #define RTEMS_BSD_CONFIG_NET_PF_UNIX |
---|
[546b38d] | 117 | #define RTEMS_BSD_CONFIG_NET_IF_BRIDGE |
---|
[90873cc] | 118 | #define RTEMS_BSD_CONFIG_NET_IF_LAGG |
---|
| 119 | #define RTEMS_BSD_CONFIG_NET_IF_VLAN |
---|
| 120 | #define RTEMS_BSD_CONFIG_INIT |
---|
[f3f816c] | 121 | |
---|
[90873cc] | 122 | #include <machine/rtems-bsd-config.h> |
---|
[2e2d441] | 123 | |
---|
[90873cc] | 124 | /* |
---|
| 125 | * Configure RTEMS. |
---|
| 126 | */ |
---|
[3cde755] | 127 | #define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER |
---|
[2e2d441] | 128 | #define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER |
---|
[263c947] | 129 | #define CONFIGURE_APPLICATION_NEEDS_STUB_DRIVER |
---|
| 130 | #define CONFIGURE_APPLICATION_NEEDS_ZERO_DRIVER |
---|
[3cde755] | 131 | #define CONFIGURE_APPLICATION_NEEDS_LIBBLOCK |
---|
[263c947] | 132 | |
---|
[018fa32] | 133 | #define CONFIGURE_MAXIMUM_FILE_DESCRIPTORS 32 |
---|
[3cde755] | 134 | |
---|
[ab415f9] | 135 | #define CONFIGURE_MAXIMUM_USER_EXTENSIONS 1 |
---|
| 136 | |
---|
[795c5e6] | 137 | #define CONFIGURE_UNLIMITED_ALLOCATION_SIZE 32 |
---|
[3cde755] | 138 | #define CONFIGURE_UNLIMITED_OBJECTS |
---|
| 139 | #define CONFIGURE_UNIFIED_WORK_AREAS |
---|
| 140 | |
---|
[025d8f2] | 141 | #define CONFIGURE_STACK_CHECKER_ENABLED |
---|
| 142 | |
---|
[293fefa] | 143 | #define CONFIGURE_BDBUF_BUFFER_MAX_SIZE (64 * 1024) |
---|
| 144 | #define CONFIGURE_BDBUF_MAX_READ_AHEAD_BLOCKS 4 |
---|
| 145 | #define CONFIGURE_BDBUF_CACHE_MEMORY_SIZE (1 * 1024 * 1024) |
---|
| 146 | |
---|
[2e2d441] | 147 | #define CONFIGURE_RTEMS_INIT_TASKS_TABLE |
---|
| 148 | |
---|
[263c947] | 149 | #define CONFIGURE_INIT_TASK_STACK_SIZE (32 * 1024) |
---|
[a1e0a41] | 150 | #define CONFIGURE_INIT_TASK_INITIAL_MODES RTEMS_DEFAULT_MODES |
---|
[4b8bc5c] | 151 | #define CONFIGURE_INIT_TASK_ATTRIBUTES RTEMS_FLOATING_POINT |
---|
[a1e0a41] | 152 | |
---|
[2e2d441] | 153 | #define CONFIGURE_INIT |
---|
[9c99de7] | 154 | |
---|
[263c947] | 155 | #include <rtems/confdefs.h> |
---|
[4f6cf1e] | 156 | |
---|
[e599318] | 157 | #endif /* RTEMS_BSD_TEST_DEFAULT_INIT_H */ |
---|