mirror of
https://github.com/apache/nuttx.git
synced 2026-05-31 23:40:19 +08:00
arch/sim: add windows host simulate support
Signed-off-by: chao.an <anchao@xiaomi.com>
This commit is contained in:
@@ -76,7 +76,11 @@ endif
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
VPATH = :sim
|
VPATH = :sim
|
||||||
VPATH += :sim/posix
|
ifeq ($(CONFIG_WINDOWS_NATIVE),y)
|
||||||
|
VPATH += :sim/win
|
||||||
|
else
|
||||||
|
VPATH += :sim/posix
|
||||||
|
endif
|
||||||
DEPPATH = $(patsubst %,--dep-path %,$(subst :, ,$(VPATH)))
|
DEPPATH = $(patsubst %,--dep-path %,$(subst :, ,$(VPATH)))
|
||||||
|
|
||||||
CFLAGS += -fvisibility=default
|
CFLAGS += -fvisibility=default
|
||||||
|
|||||||
@@ -257,23 +257,3 @@ void vpnkit_send(unsigned char *buf, unsigned int buflen)
|
|||||||
|
|
||||||
DEBUG("a packet sent (size %u)", buflen);
|
DEBUG("a packet sent (size %u)", buflen);
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: vpnkit_ifup
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
void vpnkit_ifup(in_addr_t ifaddr)
|
|
||||||
{
|
|
||||||
DEBUG("vpnkit_ifup called");
|
|
||||||
}
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: vpnkit_ifdown
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
void vpnkit_ifdown(void)
|
|
||||||
{
|
|
||||||
DEBUG("vpnkit_ifdown called");
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -32,7 +32,10 @@
|
|||||||
#ifndef __ASSEMBLY__
|
#ifndef __ASSEMBLY__
|
||||||
# include <sys/types.h>
|
# include <sys/types.h>
|
||||||
# include <stdbool.h>
|
# include <stdbool.h>
|
||||||
# include <netinet/in.h>
|
# include <stdint.h>
|
||||||
|
# if defined(CONFIG_SIM_NETDEV_TAP)
|
||||||
|
# include <netinet/in.h>
|
||||||
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@@ -298,15 +301,13 @@ void vpnkit_init(void *priv,
|
|||||||
int vpnkit_avail(void);
|
int vpnkit_avail(void);
|
||||||
unsigned int vpnkit_read(unsigned char *buf, unsigned int buflen);
|
unsigned int vpnkit_read(unsigned char *buf, unsigned int buflen);
|
||||||
void vpnkit_send(unsigned char *buf, unsigned int buflen);
|
void vpnkit_send(unsigned char *buf, unsigned int buflen);
|
||||||
void vpnkit_ifup(in_addr_t ifaddr);
|
|
||||||
void vpnkit_ifdown(void);
|
|
||||||
|
|
||||||
# define netdev_init(priv,txcb,rxcb) vpnkit_init(priv,txcb,rxcb)
|
# define netdev_init(priv,txcb,rxcb) vpnkit_init(priv,txcb,rxcb)
|
||||||
# define netdev_avail() vpnkit_avail()
|
# define netdev_avail() vpnkit_avail()
|
||||||
# define netdev_read(buf,buflen) vpnkit_read(buf,buflen)
|
# define netdev_read(buf,buflen) vpnkit_read(buf,buflen)
|
||||||
# define netdev_send(buf,buflen) vpnkit_send(buf,buflen)
|
# define netdev_send(buf,buflen) vpnkit_send(buf,buflen)
|
||||||
# define netdev_ifup(ifaddr) vpnkit_ifup(ifaddr)
|
# define netdev_ifup(ifaddr) {}
|
||||||
# define netdev_ifdown() vpnkit_ifdown()
|
# define netdev_ifdown() {}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* up_netdriver.c ***********************************************************/
|
/* up_netdriver.c ***********************************************************/
|
||||||
|
|||||||
@@ -0,0 +1,98 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* arch/sim/src/sim/win/up_hostirq.c
|
||||||
|
*
|
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
* contributor license agreements. See the NOTICE file distributed with
|
||||||
|
* this work for additional information regarding copyright ownership. The
|
||||||
|
* ASF licenses this file to you 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.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Included Files
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <windows.h>
|
||||||
|
|
||||||
|
#include "up_internal.h"
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Public Data
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
volatile void *g_current_regs[CONFIG_SMP_NCPUS];
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Public Functions
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: up_irq_save
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Disable interrupts and returned the mask before disabling them.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
uint64_t up_irq_save(void)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: up_irq_restore
|
||||||
|
*
|
||||||
|
* Input Parameters:
|
||||||
|
* flags - the mask used to restore interrupts
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Re-enable interrupts using the specified mask in flags argument.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
void up_irq_restore(uint64_t flags)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: up_irqinitialize
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
void up_irqinitialize(void)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: up_enable_irq
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Enable the IRQ specified by 'irq'
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
void up_enable_irq(int irq)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: up_disable_irq
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Disable the IRQ specified by 'irq'
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
void up_disable_irq(int irq)
|
||||||
|
{
|
||||||
|
}
|
||||||
@@ -0,0 +1,89 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* arch/sim/src/sim/win/up_hostmemory.c
|
||||||
|
*
|
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
* contributor license agreements. See the NOTICE file distributed with
|
||||||
|
* this work for additional information regarding copyright ownership. The
|
||||||
|
* ASF licenses this file to you 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.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Included Files
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include <windows.h>
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Public Functions
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: host_alloc_heap
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Allocate executable memory for heap.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
void *host_alloc_heap(size_t sz)
|
||||||
|
{
|
||||||
|
return _aligned_malloc(sz, 8);
|
||||||
|
}
|
||||||
|
|
||||||
|
void *host_alloc_shmem(const char *name, size_t size, int master)
|
||||||
|
{
|
||||||
|
HANDLE handle;
|
||||||
|
void *mem;
|
||||||
|
|
||||||
|
handle = CreateFileMapping(INVALID_HANDLE_VALUE, NULL,
|
||||||
|
PAGE_READWRITE, 0, 0, name);
|
||||||
|
if (handle == NULL)
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
mem = MapViewOfFile(handle, FILE_MAP_ALL_ACCESS, 0, 0, size);
|
||||||
|
CloseHandle(handle);
|
||||||
|
|
||||||
|
return mem;
|
||||||
|
}
|
||||||
|
|
||||||
|
void host_free_shmem(void *mem)
|
||||||
|
{
|
||||||
|
UnmapViewOfFile(mem);
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t host_malloc_size(void *mem)
|
||||||
|
{
|
||||||
|
return _msize(mem);
|
||||||
|
}
|
||||||
|
|
||||||
|
void *host_memalign(size_t alignment, size_t size)
|
||||||
|
{
|
||||||
|
return _aligned_malloc(size, alignment);
|
||||||
|
}
|
||||||
|
|
||||||
|
void host_free(void *mem)
|
||||||
|
{
|
||||||
|
_aligned_free(mem);
|
||||||
|
}
|
||||||
|
|
||||||
|
void *host_realloc(void *oldmem, size_t size)
|
||||||
|
{
|
||||||
|
return _aligned_realloc(oldmem, size, 8);
|
||||||
|
}
|
||||||
|
|
||||||
|
void host_mallinfo(int *aordblks, int *uordblks)
|
||||||
|
{
|
||||||
|
}
|
||||||
@@ -0,0 +1,49 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* arch/sim/src/sim/win/up_hostmisc.c
|
||||||
|
*
|
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
* contributor license agreements. See the NOTICE file distributed with
|
||||||
|
* this work for additional information regarding copyright ownership. The
|
||||||
|
* ASF licenses this file to you 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.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Included Files
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include <windows.h>
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Public Functions
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: host_abort
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Abort the simulation
|
||||||
|
*
|
||||||
|
* Input Parameters:
|
||||||
|
* status - Exit status to set
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
void host_abort(int status)
|
||||||
|
{
|
||||||
|
ExitProcess(status);
|
||||||
|
}
|
||||||
|
|
||||||
|
int host_backtrace(void** array, int size)
|
||||||
|
{
|
||||||
|
return CaptureStackBackTrace(0, size, array, NULL);
|
||||||
|
}
|
||||||
@@ -0,0 +1,133 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* arch/sim/src/sim/win/up_hosttime.c
|
||||||
|
*
|
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
* contributor license agreements. See the NOTICE file distributed with
|
||||||
|
* this work for additional information regarding copyright ownership. The
|
||||||
|
* ASF licenses this file to you 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.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Included Files
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <stdbool.h>
|
||||||
|
#include <windows.h>
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Pre-processor Definitions
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#define POW10_9 (1000000000ull)
|
||||||
|
|
||||||
|
/* Number of 100ns-seconds between the beginning of the Windows epoch
|
||||||
|
* (Jan. 1, 1601) and the Unix epoch (Jan. 1, 1970)
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define DELTA_EPOCH_IN_100NS (0x19db1ded53e8000ull)
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Public Functions
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: host_gettime
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
uint64_t host_gettime(bool rtc)
|
||||||
|
{
|
||||||
|
static LARGE_INTEGER start;
|
||||||
|
LARGE_INTEGER counter;
|
||||||
|
LARGE_INTEGER freq;
|
||||||
|
FILETIME ftime;
|
||||||
|
|
||||||
|
if (rtc)
|
||||||
|
{
|
||||||
|
GetSystemTimeAsFileTime(&ftime);
|
||||||
|
|
||||||
|
return (((uint64_t)ftime.dwHighDateTime << 32 |
|
||||||
|
ftime.dwLowDateTime) - DELTA_EPOCH_IN_100NS) * 100;
|
||||||
|
}
|
||||||
|
|
||||||
|
QueryPerformanceFrequency(&freq);
|
||||||
|
QueryPerformanceCounter(&counter);
|
||||||
|
|
||||||
|
counter.QuadPart = counter.QuadPart * POW10_9 / freq.QuadPart;
|
||||||
|
|
||||||
|
if (start.QuadPart == 0)
|
||||||
|
{
|
||||||
|
start.QuadPart = counter.QuadPart;
|
||||||
|
}
|
||||||
|
|
||||||
|
return counter.QuadPart - start.QuadPart;
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: host_sleep
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
void host_sleep(uint64_t nsec)
|
||||||
|
{
|
||||||
|
LARGE_INTEGER due;
|
||||||
|
HANDLE timer;
|
||||||
|
|
||||||
|
/* Convert to 100 nanosecond interval,
|
||||||
|
* negative value indicates relative time
|
||||||
|
*/
|
||||||
|
|
||||||
|
due.QuadPart = -((nsec + 99) / 100);
|
||||||
|
|
||||||
|
timer = CreateWaitableTimer(NULL, TRUE, NULL);
|
||||||
|
if (timer != NULL)
|
||||||
|
{
|
||||||
|
SetWaitableTimer(timer, &due, 0, NULL, NULL, 0);
|
||||||
|
WaitForSingleObject(timer, INFINITE);
|
||||||
|
CloseHandle(timer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: host_sleepuntil
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
void host_sleepuntil(uint64_t nsec)
|
||||||
|
{
|
||||||
|
uint64_t now;
|
||||||
|
|
||||||
|
now = host_gettime(false);
|
||||||
|
if (nsec > now)
|
||||||
|
{
|
||||||
|
host_sleep(nsec - now);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: host_settimer
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Set up a timer to send periodic signals.
|
||||||
|
*
|
||||||
|
* Input Parameters:
|
||||||
|
* irq - a pointer where we save the host signal number for SIGALRM
|
||||||
|
*
|
||||||
|
* Returned Value:
|
||||||
|
* On success, (0) zero value is returned, otherwise a negative value.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
int host_settimer(int *irq)
|
||||||
|
{
|
||||||
|
return -ENOSYS;
|
||||||
|
}
|
||||||
@@ -0,0 +1,142 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* arch/sim/src/sim/win/up_simuart.c
|
||||||
|
*
|
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
* contributor license agreements. See the NOTICE file distributed with
|
||||||
|
* this work for additional information regarding copyright ownership. The
|
||||||
|
* ASF licenses this file to you 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.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Included Files
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include <stdbool.h>
|
||||||
|
#include <windows.h>
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Private Data
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
static HANDLE g_stdin_handle;
|
||||||
|
static HANDLE g_stdout_handle;
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Public Functions
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: simuart_start
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
void simuart_start(void)
|
||||||
|
{
|
||||||
|
DWORD mode;
|
||||||
|
|
||||||
|
g_stdin_handle = GetStdHandle(STD_INPUT_HANDLE);
|
||||||
|
if (GetConsoleMode(g_stdin_handle, &mode))
|
||||||
|
{
|
||||||
|
SetConsoleMode(g_stdin_handle, mode & ~(ENABLE_MOUSE_INPUT |
|
||||||
|
ENABLE_WINDOW_INPUT |
|
||||||
|
ENABLE_ECHO_INPUT |
|
||||||
|
ENABLE_LINE_INPUT));
|
||||||
|
FlushConsoleInputBuffer(g_stdin_handle);
|
||||||
|
}
|
||||||
|
|
||||||
|
g_stdout_handle = GetStdHandle(STD_OUTPUT_HANDLE);
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: simuart_open
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
int simuart_open(const char *pathname)
|
||||||
|
{
|
||||||
|
return -ENOSYS;
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: simuart_close
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
void simuart_close(int fd)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: simuart_putc
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
int simuart_putc(int fd, int ch)
|
||||||
|
{
|
||||||
|
DWORD nwritten;
|
||||||
|
|
||||||
|
if (WriteConsole(g_stdout_handle, &ch, 1, &nwritten, NULL))
|
||||||
|
{
|
||||||
|
return ch;
|
||||||
|
}
|
||||||
|
|
||||||
|
return -EIO;
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: simuart_getc
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
int simuart_getc(int fd)
|
||||||
|
{
|
||||||
|
unsigned char ch;
|
||||||
|
DWORD nread;
|
||||||
|
|
||||||
|
if (ReadConsole(g_stdin_handle, &ch, 1, &nread, 0))
|
||||||
|
{
|
||||||
|
return ch;
|
||||||
|
}
|
||||||
|
|
||||||
|
return -EIO;
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: simuart_getcflag
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
int simuart_getcflag(int fd, unsigned int *cflag)
|
||||||
|
{
|
||||||
|
return -ENOSYS;
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: simuart_setcflag
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
int simuart_setcflag(int fd, unsigned int cflag)
|
||||||
|
{
|
||||||
|
return -ENOSYS;
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: simuart_checkc
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
bool simuart_checkc(int fd)
|
||||||
|
{
|
||||||
|
DWORD size;
|
||||||
|
|
||||||
|
if (GetNumberOfConsoleInputEvents(g_stdin_handle, &size) && size > 1)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
#
|
||||||
|
# This file is autogenerated: PLEASE DO NOT EDIT IT.
|
||||||
|
#
|
||||||
|
# You can use "make menuconfig" to make any modifications to the installed .config file.
|
||||||
|
# You can then do "make savedefconfig" to generate a new defconfig file that includes your
|
||||||
|
# modifications.
|
||||||
|
#
|
||||||
|
CONFIG_ARCH="sim"
|
||||||
|
CONFIG_ARCH_BOARD="sim"
|
||||||
|
CONFIG_ARCH_BOARD_SIM=y
|
||||||
|
CONFIG_ARCH_CHIP="sim"
|
||||||
|
CONFIG_ARCH_FLOAT_H=y
|
||||||
|
CONFIG_ARCH_SIM=y
|
||||||
|
CONFIG_BOARDCTL_POWEROFF=y
|
||||||
|
CONFIG_BUILTIN=y
|
||||||
|
CONFIG_DEV_LOOP=y
|
||||||
|
CONFIG_DEV_ZERO=y
|
||||||
|
CONFIG_EXAMPLES_HELLO=y
|
||||||
|
CONFIG_FS_PROCFS=y
|
||||||
|
CONFIG_FS_PROCFS_EXCLUDE_MEMINFO=y
|
||||||
|
CONFIG_FS_TMPFS=y
|
||||||
|
CONFIG_HOST_X86=y
|
||||||
|
CONFIG_IDLETHREAD_STACKSIZE=4096
|
||||||
|
CONFIG_INIT_ENTRYPOINT="nsh_main"
|
||||||
|
CONFIG_NSH_ARCHINIT=y
|
||||||
|
CONFIG_NSH_BUILTIN_APPS=y
|
||||||
|
CONFIG_NSH_READLINE=y
|
||||||
|
CONFIG_SIM_STACKSIZE_ADJUSTMENT=10240
|
||||||
|
CONFIG_SYSTEM_NSH=y
|
||||||
|
CONFIG_TESTING_OSTEST=y
|
||||||
@@ -27,7 +27,11 @@ ifeq ($(CONFIG_LIBC_ARCH_ELF),y)
|
|||||||
CSRCS += arch_elf.c
|
CSRCS += arch_elf.c
|
||||||
endif
|
endif
|
||||||
ifeq ($(CONFIG_ARCH_SETJMP_H),y)
|
ifeq ($(CONFIG_ARCH_SETJMP_H),y)
|
||||||
ASRCS += arch_setjmp_x86.S
|
ifeq ($(CONFIG_HOST_WINDOWS),y)
|
||||||
|
ASRCS += arch_setjmp_x86.asm
|
||||||
|
else
|
||||||
|
ASRCS += arch_setjmp_x86.S
|
||||||
|
endif
|
||||||
endif
|
endif
|
||||||
else
|
else
|
||||||
ifeq ($(CONFIG_LIBC_ARCH_ELF),y)
|
ifeq ($(CONFIG_LIBC_ARCH_ELF),y)
|
||||||
@@ -42,7 +46,11 @@ ifeq ($(CONFIG_LIBC_ARCH_ELF),y)
|
|||||||
CSRCS += arch_elf.c
|
CSRCS += arch_elf.c
|
||||||
endif
|
endif
|
||||||
ifeq ($(CONFIG_ARCH_SETJMP_H),y)
|
ifeq ($(CONFIG_ARCH_SETJMP_H),y)
|
||||||
ASRCS += arch_setjmp_x86.S
|
ifeq ($(CONFIG_HOST_WINDOWS),y)
|
||||||
|
ASRCS += arch_setjmp_x86.asm
|
||||||
|
else
|
||||||
|
ASRCS += arch_setjmp_x86.S
|
||||||
|
endif
|
||||||
endif
|
endif
|
||||||
else ifeq ($(CONFIG_HOST_ARM),y)
|
else ifeq ($(CONFIG_HOST_ARM),y)
|
||||||
ifeq ($(CONFIG_ARCH_SETJMP_H),y)
|
ifeq ($(CONFIG_ARCH_SETJMP_H),y)
|
||||||
|
|||||||
@@ -0,0 +1,73 @@
|
|||||||
|
;***************************************************************************
|
||||||
|
; libs/libc/machine/sim/arch_setjmp_x86.asm
|
||||||
|
;
|
||||||
|
; Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
; contributor license agreements. See the NOTICE file distributed with
|
||||||
|
; this work for additional information regarding copyright ownership. The
|
||||||
|
; ASF licenses this file to you 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.
|
||||||
|
;
|
||||||
|
;***************************************************************************
|
||||||
|
|
||||||
|
;***************************************************************************
|
||||||
|
; Public Functions
|
||||||
|
;***************************************************************************
|
||||||
|
|
||||||
|
.model flat, c
|
||||||
|
.code
|
||||||
|
|
||||||
|
public setjmp
|
||||||
|
public longjmp
|
||||||
|
|
||||||
|
setjmp:
|
||||||
|
mov eax, dword ptr [esp+4]
|
||||||
|
mov dword ptr [eax], ebx
|
||||||
|
mov dword ptr [eax+4], esi
|
||||||
|
mov dword ptr [eax+8], edi
|
||||||
|
|
||||||
|
; Save the value of SP as will be after we return
|
||||||
|
|
||||||
|
lea ecx, dword ptr [esp+4]
|
||||||
|
mov dword ptr [eax+10h], ecx
|
||||||
|
|
||||||
|
; Save the return PC
|
||||||
|
|
||||||
|
mov ecx, dword ptr [esp]
|
||||||
|
mov dword ptr [eax+14h], ecx
|
||||||
|
|
||||||
|
; Save the framepointer
|
||||||
|
|
||||||
|
mov dword ptr [eax+0ch], ebp
|
||||||
|
|
||||||
|
; And return 0
|
||||||
|
|
||||||
|
xor eax, eax
|
||||||
|
ret
|
||||||
|
|
||||||
|
longjmp:
|
||||||
|
mov ecx, dword ptr [esp+4] ; jmpbuf in ecx.
|
||||||
|
mov eax, dword ptr [esp+8] ; Second argument is return value
|
||||||
|
|
||||||
|
; Save the return address now
|
||||||
|
|
||||||
|
mov edx, dword ptr [ecx+14h]
|
||||||
|
|
||||||
|
; Restore registers
|
||||||
|
|
||||||
|
mov ebx, dword ptr [ecx]
|
||||||
|
mov esi, dword ptr [ecx+4]
|
||||||
|
mov edi, dword ptr [ecx+8]
|
||||||
|
mov ebp, dword ptr [ecx+0ch]
|
||||||
|
mov esp, dword ptr [ecx+10h]
|
||||||
|
jmp dword ptr [ecx+14h]
|
||||||
|
|
||||||
|
end
|
||||||
@@ -12,3 +12,6 @@
|
|||||||
|
|
||||||
# macOS doesn't have X11
|
# macOS doesn't have X11
|
||||||
-Darwin,sim:touchscreen
|
-Darwin,sim:touchscreen
|
||||||
|
|
||||||
|
# Do not build Windows configs
|
||||||
|
-,sim:windows
|
||||||
|
|||||||
Reference in New Issue
Block a user