forked from xuos/xiuos
New IPC interface, lwip sends data to rndis
This commit is contained in:
parent
84ab3dff35
commit
aaceb82386
|
@ -1,3 +1,3 @@
|
||||||
SRC_DIR := components
|
SRC_DIR := components usb_service
|
||||||
|
|
||||||
include $(KERNEL_ROOT)/compiler.mk
|
include $(KERNEL_ROOT)/compiler.mk
|
||||||
|
|
|
@ -36,6 +36,7 @@ INC_DIR = -I$(KERNEL_ROOT)/services/drivers/usb/ \
|
||||||
-I$(KERNEL_ROOT)/services/drivers/usb/components/osal \
|
-I$(KERNEL_ROOT)/services/drivers/usb/components/osal \
|
||||||
-I$(KERNEL_ROOT)/services/drivers/usb/components/port \
|
-I$(KERNEL_ROOT)/services/drivers/usb/components/port \
|
||||||
-I$(KERNEL_ROOT)/services/drivers/usb/components/port/xhci \
|
-I$(KERNEL_ROOT)/services/drivers/usb/components/port/xhci \
|
||||||
|
-I$(KERNEL_ROOT)/services/drivers/usb/usb_service \
|
||||||
-I$(KERNEL_ROOT)/services//semaphore \
|
-I$(KERNEL_ROOT)/services//semaphore \
|
||||||
-I$(KERNEL_ROOT)/services/lib/ipc \
|
-I$(KERNEL_ROOT)/services/lib/ipc \
|
||||||
-I$(KERNEL_ROOT)/services/lib/memory \
|
-I$(KERNEL_ROOT)/services/lib/memory \
|
||||||
|
|
|
@ -0,0 +1,10 @@
|
||||||
|
include $(KERNEL_ROOT)/services/drivers/usb/components/usb.mk
|
||||||
|
|
||||||
|
objs = usb_host.o
|
||||||
|
|
||||||
|
all: ${objs}
|
||||||
|
@echo "generate $^"
|
||||||
|
|
||||||
|
%.o: %.c
|
||||||
|
@echo "cc $^"
|
||||||
|
@${cc} ${cflags} ${c_useropts} ${INC_DIR} -o $@ -c $^
|
|
@ -0,0 +1,13 @@
|
||||||
|
#include "libipc.h"
|
||||||
|
#include "rndis_service.h"
|
||||||
|
|
||||||
|
IPC_INTERFACE(Ipc_usbh_rndis_eth_tx, 2, dataptr, tot_len, *(size_t *)tot_len, sizeof(size_t));
|
||||||
|
int ipc_usbh_rndis_eth_tx(struct Session* session, void *dataptr, size_t tot_len){
|
||||||
|
return IPC_CALL(Ipc_usbh_rndis_eth_tx)(session, dataptr, &tot_len);
|
||||||
|
}
|
||||||
|
|
||||||
|
IPC_INTERFACE(Ipc_usbh_rndis_eth_control, 3, cmd, args, len, sizeof(int), *(size_t *)len, sizeof(size_t));
|
||||||
|
int ipc_usbh_rndis_eth_control(struct Session* session, int cmd, void *args, size_t len){
|
||||||
|
return IPC_CALL(Ipc_usbh_rndis_eth_control)(session, &cmd, args, &len);
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
#ifndef RNDIS_SERVICE_H_
|
||||||
|
#define RNDIS_SERVICE_H_
|
||||||
|
|
||||||
|
#include "libipc.h"
|
||||||
|
|
||||||
|
IPC_SERVICES(IpcRndisServer, Ipc_usbh_rndis_eth_tx, Ipc_usbh_rndis_eth_control);
|
||||||
|
|
||||||
|
int ipc_usbh_rndis_eth_tx(struct Session* session, void *dataptr, size_t tot_len);
|
||||||
|
int ipc_usbh_rndis_eth_control(struct Session* session, int cmd, void *args, size_t len);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
|
@ -1,6 +1,37 @@
|
||||||
#include "usb_host.h"
|
#include "usb_host.h"
|
||||||
|
#include "usyscall.h"
|
||||||
|
#include "libipc.h"
|
||||||
int main(){
|
#include "rndis_service.h"
|
||||||
return 0;
|
|
||||||
}
|
/* IPC rndis server */
|
||||||
|
int IPC_DO_SERVE_FUNC(Ipc_usbh_rndis_eth_tx)(void *dataptr, size_t *tot_len){
|
||||||
|
return usbh_rndis_eth_tx(dataptr, *tot_len);
|
||||||
|
}
|
||||||
|
|
||||||
|
int IPC_DO_SERVE_FUNC(Ipc_usbh_rndis_eth_control)(int *cmd, void *args, size_t *len){
|
||||||
|
return usbh_rndis_eth_control(*cmd, args, *len);
|
||||||
|
}
|
||||||
|
|
||||||
|
IPC_SERVER_INTERFACE(Ipc_usbh_rndis_eth_tx, 2);
|
||||||
|
IPC_SERVER_INTERFACE(Ipc_usbh_rndis_eth_control, 3);
|
||||||
|
|
||||||
|
IPC_SERVER_REGISTER_INTERFACES(IpcRndisServer, 2, Ipc_usbh_rndis_eth_tx, Ipc_usbh_rndis_eth_control);
|
||||||
|
|
||||||
|
int ipc_rndis_server_init(void)
|
||||||
|
{
|
||||||
|
if (register_server("RndisServer") < 0) {
|
||||||
|
printf("register server name: %s failed.\n", "RndisServer");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
ipc_server_loop(&IpcRndisServer);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* usb main*/
|
||||||
|
int main(){
|
||||||
|
ipc_rndis_server_init();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,8 @@
|
||||||
#ifndef USB_HOST_H_
|
#ifndef USB_HOST_H_
|
||||||
#define USB_HOST_H_
|
#define USB_HOST_H_
|
||||||
|
#include <usb_osal.h>
|
||||||
|
|
||||||
|
int usbh_rndis_eth_tx(void *dataptr, size_t tot_len);
|
||||||
|
int usbh_rndis_eth_control(int cmd, void *args, size_t len);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -53,10 +53,12 @@ arch_usyscall = $(KERNEL_ROOT)/services/app/arch_usyscall.o
|
||||||
session = $(KERNEL_ROOT)/services/app/session.o
|
session = $(KERNEL_ROOT)/services/app/session.o
|
||||||
libipc = $(KERNEL_ROOT)/services/app/libipc.o
|
libipc = $(KERNEL_ROOT)/services/app/libipc.o
|
||||||
libsem = $(KERNEL_ROOT)/services/app/libsemaphore.o
|
libsem = $(KERNEL_ROOT)/services/app/libsemaphore.o
|
||||||
|
librndis = $(KERNEL_ROOT)/services/net/net_server/rndis_service.o
|
||||||
|
|
||||||
lwip: COMPILER lwip_server.o | bin
|
lwip: COMPILER lwip_server.o | bin
|
||||||
@${ld} ${user_ldflags} -e main -o $@ ${sys} ${api} ${core} ${ipv4} ${netif} lwip_server.o ${libserial} ${printf} ${libmem} ${usyscall} ${arch_usyscall} ${session} ${libipc} ${libsem} ${board_specs}
|
@${ld} ${user_ldflags} -e main -o $@ ${librndis} ${sys} ${api} ${core} ${ipv4} ${netif} lwip_server.o ${libserial} ${printf} ${libmem} ${usyscall} ${arch_usyscall} ${session} ${libipc} ${libsem} ${board_specs}
|
||||||
@${objdump} -S $@ > $@.asm
|
@${objdump} -S $@ > $@.asm
|
||||||
@$(ar) -r liblwip.a ${sys} ${api} ${core} ${ipv4} ${netif}
|
@$(ar) -r liblwip.a ${librndis} ${sys} ${api} ${core} ${ipv4} ${netif}
|
||||||
@mv *.o bin
|
@mv *.o bin
|
||||||
@mv $@ $(KERNEL_ROOT)/services/app
|
@mv $@ $(KERNEL_ROOT)/services/app
|
||||||
@mv $@.asm $(KERNEL_ROOT)/services/app
|
@mv $@.asm $(KERNEL_ROOT)/services/app
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
include $(KERNEL_ROOT)/services/net/net_server/lwip.mk
|
include $(KERNEL_ROOT)/services/net/net_server/lwip.mk
|
||||||
objs += sys_arch.o ethernetif.o
|
objs += sys_arch.o ethernetif.o
|
||||||
|
objs += $(KERNEL_ROOT)/services/drivers/usb/usb_service/rndis_service.o
|
||||||
|
|
||||||
|
|
||||||
arch: ${objs}
|
arch: ${objs}
|
||||||
|
|
|
@ -20,10 +20,15 @@
|
||||||
#include "lwip/ethip6.h"
|
#include "lwip/ethip6.h"
|
||||||
#include "lwip/etharp.h"
|
#include "lwip/etharp.h"
|
||||||
#include "libserial.h"
|
#include "libserial.h"
|
||||||
|
#include "rndis_service.h"
|
||||||
|
|
||||||
/* Define those to better describe your network interface. */
|
/* Define those to better describe your network interface. */
|
||||||
#define IFNAME0 'e'
|
#define IFNAME0 'e'
|
||||||
#define IFNAME1 'n'
|
#define IFNAME1 'n'
|
||||||
|
|
||||||
|
/* IPC rndis client */
|
||||||
|
struct Session *g_session_rndis = NULL;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* In this function, the hardware should be initialized.
|
* In this function, the hardware should be initialized.
|
||||||
* Called from ethernetif_init().
|
* Called from ethernetif_init().
|
||||||
|
@ -80,6 +85,21 @@ void print_packet_data(const char *packet_data, int length) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This function should do the actual transmission of the packet.
|
||||||
|
*
|
||||||
|
* @param dataptr pointer to the actual data in the buffer
|
||||||
|
* @param tot_len the length of this buffer
|
||||||
|
* @return ERR_OK if the send is success
|
||||||
|
* any other err_t on error
|
||||||
|
*/
|
||||||
|
int usbh_rndis_eth_tx(void *dataptr, size_t tot_len)
|
||||||
|
{
|
||||||
|
struct Session* session = g_session_rndis;
|
||||||
|
return ipc_usbh_rndis_eth_tx(session, dataptr, tot_len);;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This function should do the actual transmission of the packet. The packet is
|
* This function should do the actual transmission of the packet. The packet is
|
||||||
* contained in the pbuf that is passed to the function. This pbuf
|
* contained in the pbuf that is passed to the function. This pbuf
|
||||||
|
@ -104,8 +124,11 @@ static err_t low_level_output(struct netif *netif, struct pbuf *p)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
pbuf_copy_partial(p, buf, p->tot_len, 0);
|
pbuf_copy_partial(p, buf, p->tot_len, 0);
|
||||||
|
|
||||||
print_packet_data(buf, p->tot_len);
|
print_packet_data(buf, p->tot_len);
|
||||||
|
|
||||||
|
usbh_rndis_eth_tx(buf, p->tot_len);
|
||||||
|
|
||||||
return ERR_OK;
|
return ERR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -149,6 +172,26 @@ void ethernetif_input(struct netif *netif)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* In this function, get session info.
|
||||||
|
* Called from ethernetif_init().
|
||||||
|
*
|
||||||
|
* @return lwIP error code
|
||||||
|
*/
|
||||||
|
int ipc_rndis_client_init(void)
|
||||||
|
{
|
||||||
|
struct Session *session;
|
||||||
|
|
||||||
|
session = mem_malloc(sizeof(struct Session));
|
||||||
|
if(connect_session(session, "RndisServer", 4096) < 0) {
|
||||||
|
printf("connect session failed\n");
|
||||||
|
return ERR_IF;
|
||||||
|
}
|
||||||
|
g_session_rndis = session;
|
||||||
|
|
||||||
|
return ERR_OK;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Should be called at the beginning of the program to set up the
|
* Should be called at the beginning of the program to set up the
|
||||||
* network interface. It calls the function low_level_init() to do the
|
* network interface. It calls the function low_level_init() to do the
|
||||||
|
@ -190,6 +233,7 @@ err_t ethernetif_init(struct netif *netif)
|
||||||
/* initialize the hardware */
|
/* initialize the hardware */
|
||||||
low_level_init(netif);
|
low_level_init(netif);
|
||||||
|
|
||||||
|
ipc_rndis_client_init();
|
||||||
return ERR_OK;
|
return ERR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -41,4 +41,5 @@ INC_DIR = -I$(KERNEL_ROOT)/services/net/libnet \
|
||||||
-I$(KERNEL_ROOT)/services/lib/serial \
|
-I$(KERNEL_ROOT)/services/lib/serial \
|
||||||
-I$(KERNEL_ROOT)/services/lib/usyscall \
|
-I$(KERNEL_ROOT)/services/lib/usyscall \
|
||||||
-I$(KERNEL_ROOT)/services/boards/$(BOARD) \
|
-I$(KERNEL_ROOT)/services/boards/$(BOARD) \
|
||||||
-I$(KERNEL_ROOT)/services/app
|
-I$(KERNEL_ROOT)/services/app \
|
||||||
|
-I$(KERNEL_ROOT)/services/drivers/usb/usb_service
|
||||||
|
|
Loading…
Reference in New Issue