support webnet and add netdev for XiUOS

This commit is contained in:
zhaoyun1215 2022-09-15 00:25:42 -07:00
parent 5f42111c38
commit 097118ba3b
15 changed files with 320 additions and 196 deletions

View File

@ -35,5 +35,9 @@ ifeq ($(CONFIG_ADD_XIZI_FETURES),y)
SRC_DIR += control_app SRC_DIR += control_app
endif endif
ifeq ($(CONFIG_APP_USING_WEBNET),y)
SRC_DIR += webnet
endif
include $(KERNEL_ROOT)/compiler.mk include $(KERNEL_ROOT)/compiler.mk
endif endif

View File

@ -1,5 +1,5 @@
menuconfig APP_USING_WEBNET menuconfig APP_USING_WEBNET
bool "WebNet: A lightweight, customizable, embeddable Web Server for RT-Thread" bool "WebNet: A lightweight, customizable, embeddable Web Server for XiUOS"
default n default n
if APP_USING_WEBNET if APP_USING_WEBNET
@ -25,31 +25,31 @@ if APP_USING_WEBNET
config WEBNET_USING_LOG config WEBNET_USING_LOG
bool "LOG: Enable output log support" bool "LOG: Enable output log support"
default n default y
config WEBNET_USING_AUTH config WEBNET_USING_AUTH
bool "AUTH: Enable basic HTTP authentication support" bool "AUTH: Enable basic HTTP authentication support"
default n default y
config WEBNET_USING_CGI config WEBNET_USING_CGI
bool "CGI: Enable Common Gateway Interface support" bool "CGI: Enable Common Gateway Interface support"
default n default y
config WEBNET_USING_ASP config WEBNET_USING_ASP
bool "ASP: Enable Active Server Pages support" bool "ASP: Enable Active Server Pages support"
default n default y
config WEBNET_USING_SSI config WEBNET_USING_SSI
bool "SSI: Enable Server Side Includes support" bool "SSI: Enable Server Side Includes support"
default n default y
config WEBNET_USING_INDEX config WEBNET_USING_INDEX
bool "INDEX: Enable list all the file in the directory support" bool "INDEX: Enable list all the file in the directory support"
default n default y
config WEBNET_USING_ALIAS config WEBNET_USING_ALIAS
bool "ALIAS: Enable alias support" bool "ALIAS: Enable alias support"
default n default y
config WEBNET_USING_DAV config WEBNET_USING_DAV
bool "DAV: Enable Web-based Distributed Authoring and Versioning support" bool "DAV: Enable Web-based Distributed Authoring and Versioning support"
@ -57,7 +57,7 @@ if APP_USING_WEBNET
config WEBNET_USING_UPLOAD config WEBNET_USING_UPLOAD
bool "UPLOAD: Enable upload file support" bool "UPLOAD: Enable upload file support"
default n default y
config WEBNET_USING_GZIP config WEBNET_USING_GZIP
bool "GZIP: Enable compressed file support by GZIP" bool "GZIP: Enable compressed file support by GZIP"
@ -65,11 +65,10 @@ if APP_USING_WEBNET
config WEBNET_CACHE_LEVEL config WEBNET_CACHE_LEVEL
int "CACHE: Configure cache level(0:disable 1:use Last-Modified 2:use Cache-Control)" int "CACHE: Configure cache level(0:disable 1:use Last-Modified 2:use Cache-Control)"
default 0 default 2
range 0 2 range 0 2
if WEBNET_CACHE_LEVEL = 2 if WEBNET_CACHE_LEVEL = 2
config WEBNET_CACHE_MAX_AGE config WEBNET_CACHE_MAX_AGE
int "Cache-Control time in seconds" int "Cache-Control time in seconds"
default 1800 default 1800
@ -80,7 +79,7 @@ if APP_USING_WEBNET
config WEBNET_USING_SAMPLES config WEBNET_USING_SAMPLES
bool "Enable webnet samples" bool "Enable webnet samples"
default n default y
select WEBNET_USING_ASP select WEBNET_USING_ASP
select WEBNET_USING_AUTH select WEBNET_USING_AUTH
select WEBNET_USING_CGI select WEBNET_USING_CGI

View File

@ -237,3 +237,10 @@ void PrivTaskexitCritical()
{ {
rt_exit_critical(); rt_exit_critical();
} }
/*********************tick**********************/
#ifdef APP_USING_WEBNET
int GetTick(){
return rt_tick_get()/RT_TICK_PER_SECOND;
}
#endif

View File

@ -222,6 +222,10 @@ void PrivTaskenterCritical();
void PrivTaskexitCritical(); void PrivTaskexitCritical();
/*********************tick**********************/
#ifdef APP_USING_WEBNET
int GetTick();
#endif
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -202,3 +202,24 @@ void PrivFree(void *pointer)
UserFree(pointer); UserFree(pointer);
} }
/*********************massage queue***********************/
mqd_t PrivMqueueSend(mqd_t mqdes, const char *msg_ptr, size_t msg_len, unsigned msg_prio)
{
return mq_send(mqdes, msg_ptr, msg_len, msg_prio);
}
mqd_t PrivMqueueCreate(const char *name, int oflag, mode_t mode, struct mq_attr *attr)
{
return mq_open(name, oflag, mode, attr);
}
int PrivMqueueReceive(mqd_t mqdes, char *msg_ptr, size_t msg_len, unsigned *msg_prio)
{
return mq_receive(mqdes, msg_ptr, msg_len, msg_prio);
}
/*********************tick**********************/
int GetTick(){
return CurrentTicksGain() / TICK_PER_SECOND;
}

View File

@ -28,6 +28,16 @@
#include <stdint.h> #include <stdint.h>
#include <time.h> #include <time.h>
#include <user_api.h> #include <user_api.h>
#include <mqueue.h>
#ifdef APP_USING_WEBNET
#include "sys_arch.h"
#include <lwip/sockets.h>
#include "lwip/sys.h"
#include <assert.h>
#include <string.h>
#include <iot-vfs_posix.h>
#endif
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
@ -92,6 +102,14 @@ extern "C" {
#define SERIAL_RB_BUFSZ 128 #define SERIAL_RB_BUFSZ 128
#endif #endif
#ifdef APP_USING_WEBNET
#define bool _Bool
#define FALSE 0
#define TRUE 1
#endif
struct PinDevIrq struct PinDevIrq
{ {
int irq_mode;//< RISING/FALLING/HIGH/LOW int irq_mode;//< RISING/FALLING/HIGH/LOW
@ -242,6 +260,16 @@ void *PrivRealloc(void *pointer, size_t size);
void *PrivCalloc(size_t count, size_t size); void *PrivCalloc(size_t count, size_t size);
void PrivFree(void *pointer); void PrivFree(void *pointer);
/*********************massage queue***********************/
mqd_t PrivMqueueSend(mqd_t mqdes, const char *msg_ptr, size_t msg_len, unsigned msg_prio);
mqd_t PrivMqueueCreate(const char *name, int oflag, mode_t mode,struct mq_attr *attr);
int PrivMqueueReceive(mqd_t mqdes, char *msg_ptr, size_t msg_len, unsigned *msg_prio);
/*********************tick**********************/
int GetTick();
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -69,6 +69,19 @@ typedef int pid_t;
#define SCHED_RR 2 #define SCHED_RR 2
#define SCHED_IDLE 5 #define SCHED_IDLE 5
/*from rt added by zy*/
#define DEFAULT_STACK_SIZE 4096
#define DEFAULT_PRIORITY KTASK_PRIORITY_MAX / 2
#define PTHREAD_CREATE_JOINABLE 0x00
#define PTHREAD_INHERIT_SCHED 1
/* function in pthread.c */
/*support webnet*/
int pthread_attr_init(pthread_attr_t *attr);
int pthread_attr_setschedparam(pthread_attr_t *attr,
struct sched_param const *param);
int pthread_attr_setstacksize(pthread_attr_t *attr, size_t stack_size);
/* function in pthread.c */ /* function in pthread.c */
int pthread_atfork(void (*prepare)(void), void (*parent)(void), void (*child)(void)); int pthread_atfork(void (*prepare)(void), void (*parent)(void), void (*child)(void));
int pthread_create(pthread_t *thread, const pthread_attr_t *attr, int pthread_create(pthread_t *thread, const pthread_attr_t *attr,

View File

@ -21,6 +21,45 @@
#include <string.h> #include <string.h>
#include <stdio.h> #include <stdio.h>
#include "include/pthread.h" #include "include/pthread.h"
#include <assert.h>
const pthread_attr_t pthread_default_attr =
{
0, /* stack base */
0,
DEFAULT_STACK_SIZE, /* stack size */
0,
PTHREAD_INHERIT_SCHED, /* Inherit parent prio/policy */
SCHED_FIFO, /* scheduler policy */
{
DEFAULT_PRIORITY, /* scheduler priority */
},
4096,
PTHREAD_CREATE_JOINABLE, /* detach state */
};
int pthread_attr_init(pthread_attr_t *attr)
{
assert(attr != NULL);
*attr = pthread_default_attr;
return 0;
}
int pthread_attr_setschedparam(pthread_attr_t *attr,
struct sched_param const *param)
{
assert(attr != NULL);
assert(param != NULL);
attr->schedparam.sched_priority = param->sched_priority;
return 0;
}
int pthread_attr_setstacksize(pthread_attr_t *attr, size_t stack_size)
{
assert(attr != NULL);
attr->stacksize = stack_size;
return 0;
}
int pthread_create(pthread_t *thread, const pthread_attr_t *attr, int pthread_create(pthread_t *thread, const pthread_attr_t *attr,
void *(*start_routine)(void *), void *arg) void *(*start_routine)(void *), void *arg)

View File

@ -61,6 +61,8 @@ MEMORY
m_text (RX) : ORIGIN = 0x60002400, LENGTH = 0x03FFDC00 m_text (RX) : ORIGIN = 0x60002400, LENGTH = 0x03FFDC00
m_data (RW) : ORIGIN = 0x20000000, LENGTH = 0x00020000 m_data (RW) : ORIGIN = 0x20000000, LENGTH = 0x00020000
m_data2 (RW) : ORIGIN = 0x20200000, LENGTH = 0x00060000 m_data2 (RW) : ORIGIN = 0x20200000, LENGTH = 0x00060000
m_sdram (RW) : ORIGIN = 0x80000000, LENGTH = 0x01E00000
m_nocache (RW) : ORIGIN = 0x81E00000, LENGTH = 0x00200000
} }
/* Define output sections */ /* Define output sections */

View File

@ -68,7 +68,7 @@ menuconfig BSP_USING_TOUCH
menuconfig BSP_USING_USB menuconfig BSP_USING_USB
bool "Using USB device" bool "Using USB device"
default n default y
select RESOURCES_USB select RESOURCES_USB
if BSP_USING_USB if BSP_USING_USB
source "$BSP_DIR/third_party_driver/usb/Kconfig" source "$BSP_DIR/third_party_driver/usb/Kconfig"

View File

@ -40,7 +40,7 @@ int semc_externsram_test(void)
KPrintf("\r\n SEMC SDRAM Example End.\r\n"); KPrintf("\r\n SEMC SDRAM Example End.\r\n");
} }
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_FUNC)|SHELL_CMD_PARAM_NUM(0),semc_externsram_test, semc_externsram_test, semc_externsram_test ); //SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_FUNC)|SHELL_CMD_PARAM_NUM(0),semc_externsram_test, semc_externsram_test, semc_externsram_test );
void SEMC_SDRAMReadWrite32Bit(void) void SEMC_SDRAMReadWrite32Bit(void)
{ {

View File

@ -335,6 +335,12 @@ KERNELPATHS += -I$(KERNEL_ROOT)/fs/devfs \
-I$(KERNEL_ROOT)/fs/shared/include # -I$(KERNEL_ROOT)/fs/shared/include #
endif endif
ifeq ($(CONFIG_APP_USING_WEBNET), y)
KERNELPATHS += -I$(KERNEL_ROOT)/../../APP_Framework/Applications/webnet/WebNet_XiUOS/inc \
-I$(KERNEL_ROOT)/../../APP_Framework/lib/cJSON \
-I$(KERNEL_ROOT)/../../Ubiquitous/XiZi/resources/ethernet/netdev/include #
endif
ifeq ($(CONFIG_FS_CH376), y) ifeq ($(CONFIG_FS_CH376), y)
KERNELPATHS +=-I$(KERNEL_ROOT)/fs/compatibility_ch376 # KERNELPATHS +=-I$(KERNEL_ROOT)/fs/compatibility_ch376 #
endif endif
@ -454,4 +460,3 @@ KERNELPATHS += -I$(KERNEL_ROOT)/kernel/include #
# @cp link.mk build/Makefile # @cp link.mk build/Makefile
# @$(MAKE) -C build COMPILE_TYPE="_kernel" TARGET=XiZi-$(BOARD)_kernel.elf LINK_FLAGS=LFLAGS # @$(MAKE) -C build COMPILE_TYPE="_kernel" TARGET=XiZi-$(BOARD)_kernel.elf LINK_FLAGS=LFLAGS
# @rm build/Makefile build/make.obj # @rm build/Makefile build/make.obj

View File

@ -7,5 +7,4 @@ LWIP_DIR += api
LWIP_DIR += arch LWIP_DIR += arch
LWIP_DIR += core LWIP_DIR += core
LWIP_DIR += netif LWIP_DIR += netif
include $(KERNEL_ROOT)/compiler.mk include $(KERNEL_ROOT)/compiler.mk

View File

@ -663,7 +663,9 @@ int lwip_inet_pton(int af, const char *src, void *dst);
#if LWIP_POSIX_SOCKETS_IO_NAMES #if LWIP_POSIX_SOCKETS_IO_NAMES
/** @ingroup socket */ /** @ingroup socket */
#ifndef APP_USING_WEBNET
#define read(s,mem,len) lwip_read(s,mem,len) #define read(s,mem,len) lwip_read(s,mem,len)
#endif
/** @ingroup socket */ /** @ingroup socket */
#define readv(s,iov,iovcnt) lwip_readv(s,iov,iovcnt) #define readv(s,iov,iovcnt) lwip_readv(s,iov,iovcnt)
/** @ingroup socket */ /** @ingroup socket */

View File

@ -1,4 +1,5 @@
SRC_DIR += cmd_lwip SRC_DIR += cmd_lwip
SRC_DIR += netdev
LWIP_DIR := LwIP LWIP_DIR := LwIP
include $(KERNEL_ROOT)/compiler.mk include $(KERNEL_ROOT)/compiler.mk