1
0
Fork 0
mirror of https://github.com/hermitcore/libhermit.git synced 2025-03-09 00:00:03 +01:00

start the integration of LwIP

This commit is contained in:
Stefan Lankes 2015-09-13 21:28:30 +02:00
parent 2e9fb73007
commit cde3d9dfba
9 changed files with 95 additions and 7 deletions

View file

@ -2,7 +2,8 @@ TERM = xterm
TOPDIR := $(shell pwd)
ARCH = x86
NAME = hermit
KERNDIRS = kernel mm libkern fs arch/$(ARCH)/kernel arch/$(ARCH)/mm
LWIPDIRS = lwip/src/arch lwip/src/api lwip/src/core lwip/src/core/ipv4 lwip/src/netif
KERNDIRS = kernel mm libkern fs arch/$(ARCH)/kernel arch/$(ARCH)/mm $(LWIPDIRS)
SUBDIRS = $(KERNDIRS)
GIT_VERSION := $(shell git describe --abbrev=6 --dirty --always --tags)
TODAY := $(shell date +'%Y%m%d')

View file

@ -44,6 +44,8 @@
extern "C" {
#endif
void NORETURN abort(void);
/** @brief General page allocator function
*
* This function allocates and maps whole pages.

View file

@ -107,11 +107,13 @@ typedef struct task {
/// previous task in the queue
struct task* prev;
/// TLS address
size_t tls_addr;
size_t tls_addr;
/// TLS mem size
size_t tls_mem_size;
size_t tls_mem_size;
/// TLS file size
size_t tls_file_size;
size_t tls_file_size;
/// LwIP error code
int lwip_err;
/// FPU state
union fpu_state fpu;
} task_t;

16
hermit/include/stdarg.h Executable file
View file

@ -0,0 +1,16 @@
#ifndef __ANSI_STDARG_H__
#define __ANSI_STDARG_H__
#include <hermit/stdarg.h>
#ifdef __cplusplus
extern "C" {
#endif
#define __VALIST va_list
#ifdef __cplusplus
}
#endif
#endif

14
hermit/include/stddef.h Executable file
View file

@ -0,0 +1,14 @@
#ifndef __ANSI_STDDEF_H__
#define __ANSI_STDDEF_H__
#include <hermit/stddef.h>
#ifdef __cplusplus
extern "C" {
#endif
#ifdef __cplusplus
}
#endif
#endif

14
hermit/include/string.h Executable file
View file

@ -0,0 +1,14 @@
#ifndef __ANSI_STRING_H__
#define __ANSI_STRING_H__
#include <hermit/string.h>
#ifdef __cplusplus
extern "C" {
#endif
#ifdef __cplusplus
}
#endif
#endif

View file

@ -39,6 +39,17 @@
#include <asm/irq.h>
#include <asm/page.h>
#include <lwip/init.h>
#include <lwip/sys.h>
#include <lwip/stats.h>
#include <lwip/udp.h>
#include <lwip/tcp.h>
#include <lwip/tcpip.h>
#include <lwip/dhcp.h>
#include <lwip/netifapi.h>
#include <lwip/timers.h>
#include <netif/etharp.h>
/*
* Note that linker symbols are not variables, they have no memory allocated for
* maintaining a value, rather their address is their value.
@ -104,6 +115,30 @@ static void print_status(void)
spinlock_unlock(&status_lock);
}
static void tcpip_init_done(void* arg)
{
sys_sem_t* sem = (sys_sem_t*)arg;
kprintf("LwIP's tcpip thread has task id %d\n", per_core(current_task)->id);
sys_sem_signal(sem);
}
static int init_netifs(void)
{
sys_sem_t sem;
if(sys_sem_new(&sem, 0) != ERR_OK)
LWIP_ASSERT("Failed to create semaphore", 0);
tcpip_init(tcpip_init_done, &sem);
sys_sem_wait(&sem);
kprintf("TCP/IP initialized.\n");
sys_sem_free(&sem);
return 0;
}
#if MAX_CORES > 1
int smp_main(void)
{
@ -138,6 +173,8 @@ static int initd(void* arg)
char* argv3[] = {"/bin/stream", NULL};
char* argv4[] = {"/bin/thr_hello", NULL};
init_netifs();
//create_kernel_task(NULL, foo, "foo1", NORMAL_PRIO);
//create_kernel_task(NULL, foo, "foo2", NORMAL_PRIO);
//create_user_task(NULL, "/bin/hello", argv1, NORMAL_PRIO);

View file

@ -42,8 +42,8 @@
* A task's id will be its position in this array.
*/
static task_t task_table[MAX_TASKS] = { \
[0] = {0, TASK_IDLE, 0, NULL, NULL, TASK_DEFAULT_FLAGS, 0, 0, 0, SPINLOCK_IRQSAVE_INIT, SPINLOCK_INIT, NULL, 0, NULL, NULL, 0, NULL, NULL, 0, 0, 0}, \
[1 ... MAX_TASKS-1] = {0, TASK_INVALID, 0, NULL, NULL, TASK_DEFAULT_FLAGS, 0, 0, 0, SPINLOCK_IRQSAVE_INIT, SPINLOCK_INIT, NULL, 0, NULL, NULL, 0, NULL, NULL, 0, 0, 0}};
[0] = {0, TASK_IDLE, 0, NULL, NULL, TASK_DEFAULT_FLAGS, 0, 0, 0, SPINLOCK_IRQSAVE_INIT, SPINLOCK_INIT, NULL, 0, NULL, NULL, 0, NULL, NULL, 0, 0, 0, 0}, \
[1 ... MAX_TASKS-1] = {0, TASK_INVALID, 0, NULL, NULL, TASK_DEFAULT_FLAGS, 0, 0, 0, SPINLOCK_IRQSAVE_INIT, SPINLOCK_INIT, NULL, 0, NULL, NULL, 0, NULL, NULL, 0, 0, 0, 0}};
static spinlock_irqsave_t table_lock = SPINLOCK_IRQSAVE_INIT;
@ -319,6 +319,7 @@ int clone_task(tid_t* id, entry_point_t ep, void* arg, uint8_t prio)
task_table[i].tls_addr = curr_task->tls_addr;
task_table[i].tls_mem_size = curr_task->tls_mem_size;
task_table[i].tls_file_size = curr_task->tls_file_size;
task_table[i].lwip_err = 0;
task_table[i].user_usage = curr_task->user_usage;
task_table[i].page_map = curr_task->page_map;
@ -402,6 +403,7 @@ int create_task(tid_t* id, entry_point_t ep, void* arg, uint8_t prio, uint32_t c
task_table[i].tls_addr = 0;
task_table[i].tls_mem_size = 0;
task_table[i].tls_file_size = 0;
task_table[i].lwip_err = 0;
spinlock_irqsave_init(&task_table[i].page_lock);
task_table[i].user_usage = (atomic_int64_t*) counter;

@ -1 +1 @@
Subproject commit 5b8b5d459e7dd890724515bbfad86c705234f9ec
Subproject commit 57ff67f87b9e02ee8ec1089a1e971b96f08555a4