2016-04-29 14:52:09 +02:00
|
|
|
/** @file
|
|
|
|
* @brief Network initialization
|
|
|
|
*
|
|
|
|
* Initialize the network IP stack. Create two fibers, one for reading data
|
|
|
|
* from applications (Tx fiber) and one for reading data from IP stack
|
|
|
|
* and passing that data to applications (Rx fiber).
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright (c) 2016 Intel Corporation
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
2016-05-02 09:20:56 +02:00
|
|
|
#ifdef CONFIG_NETWORK_IP_STACK_DEBUG_CORE
|
2016-04-29 14:52:09 +02:00
|
|
|
#define DEBUG 1
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <nanokernel.h>
|
|
|
|
#include <toolchain.h>
|
|
|
|
#include <sections.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <errno.h>
|
|
|
|
|
2016-05-03 08:34:45 +02:00
|
|
|
/* Stack for the rx fiber.
|
2016-04-29 14:52:09 +02:00
|
|
|
*/
|
|
|
|
#if !defined(CONFIG_NET_RX_STACK_SIZE)
|
|
|
|
#define CONFIG_NET_RX_STACK_SIZE 1024
|
|
|
|
#endif
|
2016-05-03 08:34:45 +02:00
|
|
|
static char __noinit __stack rx_fiber_stack[CONFIG_NET_RX_STACK_SIZE];
|
2016-04-29 14:52:09 +02:00
|
|
|
static struct nano_fifo rx_queue;
|
|
|
|
|
|
|
|
static void net_rx_fiber(int unused1, int unused2)
|
|
|
|
{
|
|
|
|
while (0) {
|
|
|
|
/* FIXME - implementation missing */
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void init_rx_queue(void)
|
|
|
|
{
|
|
|
|
nano_fifo_init(&rx_queue);
|
|
|
|
|
|
|
|
fiber_start(rx_fiber_stack, sizeof(rx_fiber_stack),
|
|
|
|
net_rx_fiber, 0, 0, 7, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int network_initialization(void)
|
|
|
|
{
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int net_init(void)
|
|
|
|
{
|
|
|
|
static uint8_t initialized;
|
|
|
|
|
|
|
|
if (initialized)
|
|
|
|
return -EALREADY;
|
|
|
|
|
|
|
|
initialized = 1;
|
|
|
|
|
|
|
|
init_rx_queue();
|
|
|
|
|
|
|
|
return network_initialization();
|
|
|
|
}
|