mirror of
https://github.com/apache/nuttx.git
synced 2025-01-12 19:48:33 +08:00
Compare commits
6 commits
e1ab83f3f5
...
37f862c3db
Author | SHA1 | Date | |
---|---|---|---|
|
37f862c3db | ||
|
a2d4d74af7 | ||
|
2149d89336 | ||
|
71a4e86718 | ||
|
63c8de5f03 | ||
|
5d227b43d9 |
19 changed files with 158 additions and 68 deletions
|
@ -727,6 +727,7 @@ else()
|
|||
OUTPUT nuttx.rel
|
||||
COMMAND
|
||||
${CMAKE_C_COMPILER} ARGS -r $<$<BOOL:${CONFIG_SIM_M32}>:-m32>
|
||||
$<$<BOOL:${CONFIG_HOST_LINUX}>:-Wl,-z,noexecstack>
|
||||
$<TARGET_OBJECTS:sim_head> $<$<NOT:$<BOOL:${APPLE}>>:-Wl,--start-group>
|
||||
${nuttx_libs_paths} $<$<NOT:$<BOOL:${APPLE}>>:-Wl,--end-group> -o
|
||||
nuttx.rel
|
||||
|
|
|
@ -1103,7 +1103,7 @@ static void imx9_lpi2c_setclock(struct imx9_lpi2c_priv_s *priv,
|
|||
&src_freq);
|
||||
|
||||
/* LPI2C output frequency = (Source Clock (Hz)/ 2^prescale) /
|
||||
* (CLKLO + 1 + CLKHI + 1 + ROUNDDOWN((2 + FILTSCL) / 2^prescale)
|
||||
* (CLKLO + 1 + CLKHI + 1 + ALIGN_DOWN((2 + FILTSCL)/2^prescale)
|
||||
*
|
||||
* Assume CLKLO = 2 * CLKHI, SETHOLD = CLKHI, DATAVD = CLKHI / 2
|
||||
*/
|
||||
|
|
|
@ -1161,7 +1161,7 @@ static void imxrt_lpi2c_setclock(struct imxrt_lpi2c_priv_s *priv,
|
|||
#endif
|
||||
|
||||
/* LPI2C output frequency = (Source Clock (Hz)/ 2^prescale) /
|
||||
* (CLKLO + 1 + CLKHI + 1 + ROUNDDOWN((2 + FILTSCL) / 2^prescale)
|
||||
* (CLKLO + 1 + CLKHI + 1 + ALIGN_DOWN((2 + FILTSCL)/2^prescale)
|
||||
*
|
||||
* Assume CLKLO = 2 * CLKHI, SETHOLD = CLKHI, DATAVD = CLKHI / 2
|
||||
*/
|
||||
|
|
|
@ -1010,7 +1010,7 @@ static void s32k1xx_lpi2c_setclock(struct s32k1xx_lpi2c_priv_s *priv,
|
|||
DEBUGASSERT(src_freq != 0);
|
||||
|
||||
/* LPI2C output frequency = (Source Clock (Hz)/ 2^prescale) /
|
||||
* (CLKLO + 1 + CLKHI + 1 + ROUNDDOWN((2 + FILTSCL) / 2^prescale)
|
||||
* (CLKLO + 1 + CLKHI + 1 + ALIGN_DOWN((2 + FILTSCL)/2^prescale)
|
||||
*
|
||||
* Assume CLKLO = 2 * CLKHI, SETHOLD = CLKHI, DATAVD = CLKHI / 2
|
||||
*/
|
||||
|
|
|
@ -990,7 +990,7 @@ static void s32k3xx_lpi2c_setclock(struct s32k3xx_lpi2c_priv_s *priv,
|
|||
DEBUGASSERT(src_freq != 0);
|
||||
|
||||
/* LPI2C output frequency = (Source Clock (Hz)/ 2^prescale) /
|
||||
* (CLKLO + 1 + CLKHI + 1 + ROUNDDOWN((2 + FILTSCL) / 2^prescale)
|
||||
* (CLKLO + 1 + CLKHI + 1 + ALIGN_DOWN((2 + FILTSCL)/2^prescale)
|
||||
*
|
||||
* Assume CLKLO = 2 * CLKHI, SETHOLD = CLKHI, DATAVD = CLKHI / 2
|
||||
*/
|
||||
|
|
|
@ -1122,7 +1122,7 @@ static void imx9_lpi2c_setclock(struct imx9_lpi2c_priv_s *priv,
|
|||
imx9_get_rootclock(priv->config->clk_root, &src_freq);
|
||||
|
||||
/* LPI2C output frequency = (Source Clock (Hz)/ 2^prescale) /
|
||||
* (CLKLO + 1 + CLKHI + 1 + ROUNDDOWN((2 + FILTSCL) / 2^prescale)
|
||||
* (CLKLO + 1 + CLKHI + 1 + ALIGN_DOWN((2 + FILTSCL)/2^prescale)
|
||||
*
|
||||
* Assume CLKLO = 2 * CLKHI, SETHOLD = CLKHI, DATAVD = CLKHI / 2
|
||||
*/
|
||||
|
|
|
@ -433,7 +433,12 @@ LDMODULEFLAGS = -r -T $(call CONVERT_PATH,$(TOPDIR)/libs/libc/modlib/gnu-elf.ld)
|
|||
CELFFLAGS = $(CFLAGS) -fvisibility=hidden
|
||||
CXXELFFLAGS = $(CXXFLAGS) -fvisibility=hidden
|
||||
|
||||
LDELFFLAGS = -r -e main
|
||||
LDELFFLAGS = -e main
|
||||
|
||||
ifeq ($(CONFIG_BINFMT_ELF_RELOCATABLE),y)
|
||||
LDELFFLAGS += -r
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_ARCH_RV32),y)
|
||||
LDELFFLAGS += --oformat elf32-littleriscv
|
||||
else
|
||||
|
|
|
@ -200,3 +200,7 @@ else()
|
|||
add_link_options(-Wl,--gc-sections)
|
||||
add_link_options(-Wl,-Ttext-segment=0x40000000)
|
||||
endif()
|
||||
|
||||
if(CONFIG_HOST_LINUX)
|
||||
add_link_options(-Wl,-z,noexecstack)
|
||||
endif()
|
||||
|
|
|
@ -31,18 +31,13 @@
|
|||
#include <errno.h>
|
||||
|
||||
#include <nuttx/kmalloc.h>
|
||||
#include <nuttx/nuttx.h>
|
||||
#include <nuttx/binfmt/binfmt.h>
|
||||
|
||||
#include "binfmt.h"
|
||||
|
||||
#if defined(CONFIG_ARCH_ADDRENV) && defined(CONFIG_BUILD_KERNEL) && !defined(CONFIG_BINFMT_DISABLE)
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#define ROUNDUP(x, y) (((x) + (y) - 1) / (y) * (y))
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
@ -98,8 +93,8 @@ int binfmt_copyactions(FAR const posix_spawn_file_actions_t **copy,
|
|||
|
||||
case SPAWN_FILE_ACTION_OPEN:
|
||||
open = (FAR struct spawn_open_file_action_s *)entry;
|
||||
size += ROUNDUP(SIZEOF_OPEN_FILE_ACTION_S(strlen(open->path)),
|
||||
sizeof(FAR void *));
|
||||
size += ALIGN_UP(SIZEOF_OPEN_FILE_ACTION_S(strlen(open->path)),
|
||||
sizeof(FAR void *));
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -155,8 +150,8 @@ int binfmt_copyactions(FAR const posix_spawn_file_actions_t **copy,
|
|||
strcpy(open->path, tmp->path);
|
||||
|
||||
buffer = (FAR char *)buffer +
|
||||
ROUNDUP(SIZEOF_OPEN_FILE_ACTION_S(strlen(tmp->path)),
|
||||
sizeof(FAR void *));
|
||||
ALIGN_UP(SIZEOF_OPEN_FILE_ACTION_S(strlen(tmp->path)),
|
||||
sizeof(FAR void *));
|
||||
break;
|
||||
|
||||
default:
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
#include <nuttx/init.h>
|
||||
#include <nuttx/kmalloc.h>
|
||||
#include <nuttx/fs/fs.h>
|
||||
#include <nuttx/nuttx.h>
|
||||
#include <nuttx/spinlock.h>
|
||||
|
||||
/****************************************************************************
|
||||
|
@ -112,11 +113,6 @@
|
|||
|
||||
#define MAXARCS (1 << 20)
|
||||
|
||||
/* General rounding functions. */
|
||||
|
||||
#define ROUNDDOWN(x, y) (((x) / (y)) * (y))
|
||||
#define ROUNDUP(x, y) ((((x) + (y) - 1) / (y)) * (y))
|
||||
|
||||
/* See profil(2) where this is described (incorrectly) */
|
||||
|
||||
#define SCALE_1_TO_1 0x10000
|
||||
|
@ -288,13 +284,13 @@ void moncontrol(int mode)
|
|||
|
||||
if (mode)
|
||||
{
|
||||
uintptr_t lowpc = ROUNDDOWN((uintptr_t)&_stext,
|
||||
uintptr_t lowpc = ALIGN_DOWN((uintptr_t)&_stext,
|
||||
HISTFRACTION * sizeof(HISTCOUNTER));
|
||||
uintptr_t highpc = ROUNDUP((uintptr_t)&_etext,
|
||||
HISTFRACTION * sizeof(HISTCOUNTER));
|
||||
uintptr_t highpc = ALIGN_UP((uintptr_t)&_etext,
|
||||
HISTFRACTION * sizeof(HISTCOUNTER));
|
||||
size_t textsize = highpc - lowpc;
|
||||
size_t kcountsize = ROUNDUP(textsize / HISTFRACTION,
|
||||
sizeof(*p->kcount));
|
||||
size_t kcountsize = ALIGN_UP(textsize / HISTFRACTION,
|
||||
sizeof(*p->kcount));
|
||||
int scale = kcountsize >= textsize ? SCALE_1_TO_1 :
|
||||
(float)kcountsize / textsize * SCALE_1_TO_1;
|
||||
FAR unsigned short *kcount = kmm_zalloc(kcountsize);
|
||||
|
@ -370,10 +366,10 @@ void monstartup(unsigned long lowpc, unsigned long highpc)
|
|||
* so the rest of the scaling (here and in gprof) stays in ints.
|
||||
*/
|
||||
|
||||
lowpc = ROUNDDOWN(lowpc, HISTFRACTION * sizeof(HISTCOUNTER));
|
||||
highpc = ROUNDUP(highpc, HISTFRACTION * sizeof(HISTCOUNTER));
|
||||
lowpc = ALIGN_DOWN(lowpc, HISTFRACTION * sizeof(HISTCOUNTER));
|
||||
highpc = ALIGN_UP(highpc, HISTFRACTION * sizeof(HISTCOUNTER));
|
||||
textsize = highpc - lowpc;
|
||||
fromssize = ROUNDUP(textsize / HASHFRACTION, sizeof(*p->froms));
|
||||
fromssize = ALIGN_UP(textsize / HASHFRACTION, sizeof(*p->froms));
|
||||
tolimit = textsize * ARCDENSITY / 100;
|
||||
|
||||
if (tolimit < MINARCS)
|
||||
|
|
|
@ -237,6 +237,13 @@ config NETDB_DNSSERVER_IPv4ADDR
|
|||
Default DNS server IPv4 address in host byte order. Default value
|
||||
10.0.0.1. This may be changed via dns_add_nameserver().
|
||||
|
||||
config NETDB_DNS_STREAM
|
||||
bool "DNS supports TCP transmission"
|
||||
depends on LIBC_NETDB
|
||||
default n
|
||||
---help---
|
||||
Enable support for DNS Name resolution over TCP.
|
||||
|
||||
if NETDB_DNSSERVER_IPv6
|
||||
|
||||
config NETDB_DNSSERVER_IPv6ADDR_1
|
||||
|
|
|
@ -170,7 +170,11 @@ void dns_restorelock(unsigned int count);
|
|||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef CONFIG_NETDB_DNS_STREAM
|
||||
int dns_bind(sa_family_t family);
|
||||
#else
|
||||
int dns_bind(sa_family_t family, bool stream);
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: dns_query
|
||||
|
|
|
@ -63,16 +63,28 @@
|
|||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef CONFIG_NETDB_DNS_STREAM
|
||||
int dns_bind(sa_family_t family)
|
||||
#else
|
||||
int dns_bind(sa_family_t family, bool stream)
|
||||
#endif
|
||||
{
|
||||
#ifdef CONFIG_NETDB_DNS_STREAM
|
||||
int stype = stream ? SOCK_STREAM : SOCK_DGRAM;
|
||||
#endif
|
||||
|
||||
struct timeval tv;
|
||||
int sd;
|
||||
int ret;
|
||||
|
||||
/* Create a new socket */
|
||||
|
||||
#ifndef CONFIG_NETDB_DNS_STREAM
|
||||
sd = socket(family, SOCK_DGRAM | SOCK_CLOEXEC, 0);
|
||||
#else
|
||||
sd = socket(family, stype | SOCK_CLOEXEC, 0);
|
||||
#endif
|
||||
|
||||
if (sd < 0)
|
||||
{
|
||||
ret = -get_errno();
|
||||
|
|
|
@ -124,6 +124,7 @@ struct dns_query_data_s
|
|||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_NETDB_DNS_STREAM
|
||||
static ssize_t stream_send(int fd, FAR const void *buf, size_t len)
|
||||
{
|
||||
ssize_t total = 0;
|
||||
|
@ -292,6 +293,7 @@ static ssize_t stream_recv_record(int fd, FAR void *buf, size_t len)
|
|||
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: dns_parse_name
|
||||
|
@ -380,11 +382,18 @@ static inline uint16_t dns_alloc_id(void)
|
|||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef CONFIG_NETDB_DNS_STREAM
|
||||
static int dns_send_query(int sd, FAR const char *name,
|
||||
FAR union dns_addr_u *uaddr, uint16_t rectype,
|
||||
FAR struct dns_query_info_s *qinfo,
|
||||
FAR uint8_t *buffer)
|
||||
#else
|
||||
static int dns_send_query(int sd, FAR const char *name,
|
||||
FAR union dns_addr_u *uaddr, uint16_t rectype,
|
||||
FAR struct dns_query_info_s *qinfo,
|
||||
FAR uint8_t *buffer,
|
||||
bool stream)
|
||||
#endif
|
||||
{
|
||||
FAR struct dns_header_s *hdr;
|
||||
FAR uint8_t *dest;
|
||||
|
@ -488,11 +497,13 @@ static int dns_send_query(int sd, FAR const char *name,
|
|||
return ret;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_NETDB_DNS_STREAM
|
||||
if (stream)
|
||||
{
|
||||
ret = stream_send_record(sd, buffer, dest - buffer);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
ret = send(sd, buffer, dest - buffer, 0);
|
||||
}
|
||||
|
@ -519,10 +530,16 @@ static int dns_send_query(int sd, FAR const char *name,
|
|||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef CONFIG_NETDB_DNS_STREAM
|
||||
static int dns_recv_response(int sd, FAR union dns_addr_u *addr, int naddr,
|
||||
FAR struct dns_query_info_s *qinfo,
|
||||
FAR uint32_t *ttl, FAR uint8_t *buffer)
|
||||
#else
|
||||
static int dns_recv_response(int sd, FAR union dns_addr_u *addr, int naddr,
|
||||
FAR struct dns_query_info_s *qinfo,
|
||||
FAR uint32_t *ttl, FAR uint8_t *buffer,
|
||||
bool stream, bool *should_try_stream)
|
||||
#endif
|
||||
{
|
||||
FAR uint8_t *nameptr;
|
||||
FAR uint8_t *namestart;
|
||||
|
@ -543,11 +560,13 @@ static int dns_recv_response(int sd, FAR union dns_addr_u *addr, int naddr,
|
|||
|
||||
/* Receive the response */
|
||||
|
||||
#ifdef CONFIG_NETDB_DNS_STREAM
|
||||
if (stream)
|
||||
{
|
||||
ret = stream_recv_record(sd, buffer, RECV_BUFFER_SIZE);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
ret = recv(sd, buffer, RECV_BUFFER_SIZE, 0);
|
||||
}
|
||||
|
@ -579,6 +598,7 @@ static int dns_recv_response(int sd, FAR union dns_addr_u *addr, int naddr,
|
|||
|
||||
/* Check for error */
|
||||
|
||||
#ifdef CONFIG_NETDB_DNS_STREAM
|
||||
if ((hdr->flags1 & DNS_FLAG1_TRUNC) != 0)
|
||||
{
|
||||
/* RFC 2181
|
||||
|
@ -601,6 +621,7 @@ static int dns_recv_response(int sd, FAR union dns_addr_u *addr, int naddr,
|
|||
*should_try_stream = true;
|
||||
return -EAGAIN;
|
||||
}
|
||||
#endif
|
||||
|
||||
if ((hdr->flags2 & DNS_FLAG2_ERR_MASK) != 0)
|
||||
{
|
||||
|
@ -851,7 +872,9 @@ static int dns_query_callback(FAR void *arg, FAR struct sockaddr *addr,
|
|||
int retries;
|
||||
int ret;
|
||||
int sd;
|
||||
#ifdef CONFIG_NETDB_DNS_STREAM
|
||||
bool stream = false;
|
||||
#endif
|
||||
|
||||
/* Loop while receive timeout errors occur and there are remaining
|
||||
* retries.
|
||||
|
@ -859,25 +882,37 @@ static int dns_query_callback(FAR void *arg, FAR struct sockaddr *addr,
|
|||
|
||||
for (retries = 0; retries < CONFIG_NETDB_DNSCLIENT_RETRIES; retries++)
|
||||
{
|
||||
#ifdef CONFIG_NETDB_DNS_STREAM
|
||||
bool should_try_stream;
|
||||
|
||||
try_stream:
|
||||
#endif
|
||||
#ifdef CONFIG_NET_IPv6
|
||||
if (dns_is_queryfamily(AF_INET6))
|
||||
{
|
||||
/* Send the IPv6 query */
|
||||
|
||||
#ifndef CONFIG_NETDB_DNS_STREAM
|
||||
sd = dns_bind(addr->sa_family);
|
||||
#else
|
||||
sd = dns_bind(addr->sa_family, stream);
|
||||
#endif
|
||||
if (sd < 0)
|
||||
{
|
||||
query->result = sd;
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifndef CONFIG_NETDB_DNS_STREAM
|
||||
ret = dns_send_query(sd, query->hostname,
|
||||
(FAR union dns_addr_u *)addr,
|
||||
DNS_RECTYPE_AAAA, &qdata->qinfo,
|
||||
qdata->buffer);
|
||||
#else
|
||||
ret = dns_send_query(sd, query->hostname,
|
||||
(FAR union dns_addr_u *)addr,
|
||||
DNS_RECTYPE_AAAA, &qdata->qinfo,
|
||||
qdata->buffer, stream);
|
||||
#endif
|
||||
if (ret < 0)
|
||||
{
|
||||
dns_query_error("ERROR: IPv6 dns_send_query failed",
|
||||
|
@ -887,25 +922,33 @@ try_stream:
|
|||
else
|
||||
{
|
||||
/* Obtain the IPv6 response */
|
||||
|
||||
#ifndef CONFIG_NETDB_DNS_STREAM
|
||||
ret = dns_recv_response(sd, &query->addr[next],
|
||||
CONFIG_NETDB_MAX_IPv6ADDR,
|
||||
&qdata->qinfo,
|
||||
&query->ttl, qdata->buffer);
|
||||
#else
|
||||
should_try_stream = false;
|
||||
ret = dns_recv_response(sd, &query->addr[next],
|
||||
CONFIG_NETDB_MAX_IPv6ADDR,
|
||||
&qdata->qinfo,
|
||||
&query->ttl, qdata->buffer,
|
||||
stream, &should_try_stream);
|
||||
#endif
|
||||
if (ret >= 0)
|
||||
{
|
||||
next += ret;
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef CONFIG_NETDB_DNS_STREAM
|
||||
if (!stream && should_try_stream)
|
||||
{
|
||||
stream = true;
|
||||
goto try_stream; /* Don't consume retry count */
|
||||
}
|
||||
|
||||
#endif
|
||||
dns_query_error("ERROR: IPv6 dns_recv_response failed",
|
||||
ret, (FAR union dns_addr_u *)addr);
|
||||
query->result = ret;
|
||||
|
@ -914,6 +957,7 @@ try_stream:
|
|||
|
||||
close(sd);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_NET_IPv4
|
||||
|
@ -921,17 +965,27 @@ try_stream:
|
|||
{
|
||||
/* Send the IPv4 query */
|
||||
|
||||
#ifndef CONFIG_NETDB_DNS_STREAM
|
||||
sd = dns_bind(addr->sa_family);
|
||||
#else
|
||||
sd = dns_bind(addr->sa_family, stream);
|
||||
#endif
|
||||
if (sd < 0)
|
||||
{
|
||||
query->result = sd;
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifndef CONFIG_NETDB_DNS_STREAM
|
||||
ret = dns_send_query(sd, query->hostname,
|
||||
(FAR union dns_addr_u *)addr,
|
||||
DNS_RECTYPE_A, &qdata->qinfo, qdata->buffer);
|
||||
#else
|
||||
ret = dns_send_query(sd, query->hostname,
|
||||
(FAR union dns_addr_u *)addr,
|
||||
DNS_RECTYPE_A, &qdata->qinfo, qdata->buffer,
|
||||
stream);
|
||||
#endif
|
||||
if (ret < 0)
|
||||
{
|
||||
dns_query_error("ERROR: IPv4 dns_send_query failed",
|
||||
|
@ -947,24 +1001,33 @@ try_stream:
|
|||
next = *query->naddr / 2;
|
||||
}
|
||||
|
||||
#ifndef CONFIG_NETDB_DNS_STREAM
|
||||
ret = dns_recv_response(sd, &query->addr[next],
|
||||
CONFIG_NETDB_MAX_IPv4ADDR,
|
||||
&qdata->qinfo,
|
||||
&query->ttl, qdata->buffer);
|
||||
#else
|
||||
should_try_stream = false;
|
||||
ret = dns_recv_response(sd, &query->addr[next],
|
||||
CONFIG_NETDB_MAX_IPv4ADDR,
|
||||
&qdata->qinfo,
|
||||
&query->ttl, qdata->buffer,
|
||||
stream, &should_try_stream);
|
||||
#endif
|
||||
if (ret >= 0)
|
||||
{
|
||||
next += ret;
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef CONFIG_NETDB_DNS_STREAM
|
||||
if (!stream && should_try_stream)
|
||||
{
|
||||
stream = true;
|
||||
goto try_stream; /* Don't consume retry count */
|
||||
}
|
||||
|
||||
#endif
|
||||
dns_query_error("ERROR: IPv4 dns_recv_response failed",
|
||||
ret, (FAR union dns_addr_u *)addr);
|
||||
query->result = ret;
|
||||
|
|
|
@ -41,8 +41,6 @@
|
|||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#define ROUNDUP(x, y) (((x) + (y) - 1) / (y) * (y))
|
||||
|
||||
#if defined(CONFIG_DEBUG_FEATURES) && defined(CONFIG_IOB_DEBUG)
|
||||
# define ioberr _err
|
||||
# define iobwarn _warn
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
#ifdef CONFIG_IOB_ALLOC
|
||||
# include <nuttx/kmalloc.h>
|
||||
#endif
|
||||
#include <nuttx/nuttx.h>
|
||||
#include <nuttx/mm/iob.h>
|
||||
|
||||
#include "iob.h"
|
||||
|
@ -333,7 +334,7 @@ FAR struct iob_s *iob_alloc_dynamic(uint16_t size)
|
|||
FAR struct iob_s *iob;
|
||||
size_t alignsize;
|
||||
|
||||
alignsize = ROUNDUP(sizeof(struct iob_s), CONFIG_IOB_ALIGNMENT) + size;
|
||||
alignsize = ALIGN_UP(sizeof(struct iob_s), CONFIG_IOB_ALIGNMENT) + size;
|
||||
|
||||
iob = kmm_memalign(CONFIG_IOB_ALIGNMENT, alignsize);
|
||||
if (iob)
|
||||
|
@ -344,8 +345,8 @@ FAR struct iob_s *iob_alloc_dynamic(uint16_t size)
|
|||
iob->io_bufsize = size; /* Total length of the iob buffer */
|
||||
iob->io_pktlen = 0; /* Total length of the packet */
|
||||
iob->io_free = iob_free_dynamic; /* Customer free callback */
|
||||
iob->io_data = (FAR uint8_t *)ROUNDUP((uintptr_t)(iob + 1),
|
||||
CONFIG_IOB_ALIGNMENT);
|
||||
iob->io_data = (FAR uint8_t *)ALIGN_UP((uintptr_t)(iob + 1),
|
||||
CONFIG_IOB_ALIGNMENT);
|
||||
}
|
||||
|
||||
return iob;
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <nuttx/nuttx.h>
|
||||
#include <nuttx/mm/iob.h>
|
||||
|
||||
#include "iob.h"
|
||||
|
@ -39,10 +40,10 @@
|
|||
/* Fix the I/O Buffer size with specified alignment size */
|
||||
|
||||
#ifdef CONFIG_IOB_ALLOC
|
||||
# define IOB_ALIGN_SIZE ROUNDUP(sizeof(struct iob_s) + CONFIG_IOB_BUFSIZE, \
|
||||
CONFIG_IOB_ALIGNMENT)
|
||||
# define IOB_ALIGN_SIZE ALIGN_UP(sizeof(struct iob_s) + CONFIG_IOB_BUFSIZE, \
|
||||
CONFIG_IOB_ALIGNMENT)
|
||||
#else
|
||||
# define IOB_ALIGN_SIZE ROUNDUP(sizeof(struct iob_s), CONFIG_IOB_ALIGNMENT)
|
||||
# define IOB_ALIGN_SIZE ALIGN_UP(sizeof(struct iob_s), CONFIG_IOB_ALIGNMENT)
|
||||
#endif
|
||||
|
||||
#define IOB_BUFFER_SIZE (IOB_ALIGN_SIZE * CONFIG_IOB_NBUFFERS + \
|
||||
|
@ -137,8 +138,8 @@ void iob_initialize(void)
|
|||
* aligned to the CONFIG_IOB_ALIGNMENT memory boundary
|
||||
*/
|
||||
|
||||
buf = ROUNDUP((uintptr_t)g_iob_buffer + offsetof(struct iob_s, io_data),
|
||||
CONFIG_IOB_ALIGNMENT) - offsetof(struct iob_s, io_data);
|
||||
buf = ALIGN_UP((uintptr_t)g_iob_buffer + offsetof(struct iob_s, io_data),
|
||||
CONFIG_IOB_ALIGNMENT) - offsetof(struct iob_s, io_data);
|
||||
|
||||
/* Get I/O buffer instance from the start address and add each I/O buffer
|
||||
* to the free list
|
||||
|
|
|
@ -53,6 +53,7 @@ static struct timespec g_clock_wall_time;
|
|||
static uint64_t g_clock_last_counter;
|
||||
static uint64_t g_clock_mask;
|
||||
static long g_clock_adjust;
|
||||
static spinlock_t g_clock_lock = SP_UNLOCKED;
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
|
@ -72,7 +73,7 @@ static int clock_get_current_time(FAR struct timespec *ts,
|
|||
time_t sec;
|
||||
int ret;
|
||||
|
||||
flags = enter_critical_section();
|
||||
flags = spin_lock_irqsave(&g_clock_lock);
|
||||
|
||||
ret = up_timer_gettick(&counter);
|
||||
if (ret < 0)
|
||||
|
@ -96,7 +97,7 @@ static int clock_get_current_time(FAR struct timespec *ts,
|
|||
ts->tv_sec = base->tv_sec + sec;
|
||||
|
||||
errout_in_critical_section:
|
||||
leave_critical_section(flags);
|
||||
spin_unlock_irqrestore(&g_clock_lock, flags);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -123,7 +124,7 @@ int clock_timekeeping_set_wall_time(FAR const struct timespec *ts)
|
|||
uint64_t counter;
|
||||
int ret;
|
||||
|
||||
flags = enter_critical_section();
|
||||
flags = spin_lock_irqsave(&g_clock_lock);
|
||||
|
||||
ret = up_timer_gettick(&counter);
|
||||
if (ret < 0)
|
||||
|
@ -137,7 +138,7 @@ int clock_timekeeping_set_wall_time(FAR const struct timespec *ts)
|
|||
g_clock_last_counter = counter;
|
||||
|
||||
errout_in_critical_section:
|
||||
leave_critical_section(flags);
|
||||
spin_unlock_irqrestore(&g_clock_lock, flags);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -188,7 +189,7 @@ int adjtime(FAR const struct timeval *delta, FAR struct timeval *olddelta)
|
|||
return -1;
|
||||
}
|
||||
|
||||
flags = enter_critical_section();
|
||||
flags = spin_lock_irqsave(&g_clock_lock);
|
||||
|
||||
adjust_usec = delta->tv_sec * USEC_PER_SEC + delta->tv_usec;
|
||||
|
||||
|
@ -199,7 +200,7 @@ int adjtime(FAR const struct timeval *delta, FAR struct timeval *olddelta)
|
|||
|
||||
g_clock_adjust = adjust_usec;
|
||||
|
||||
leave_critical_section(flags);
|
||||
spin_unlock_irqrestore(&g_clock_lock, flags);
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
@ -217,7 +218,7 @@ void clock_update_wall_time(void)
|
|||
time_t sec;
|
||||
int ret;
|
||||
|
||||
flags = enter_critical_section();
|
||||
flags = spin_lock_irqsave(&g_clock_lock);
|
||||
|
||||
ret = up_timer_gettick(&counter);
|
||||
if (ret < 0)
|
||||
|
@ -271,7 +272,7 @@ void clock_update_wall_time(void)
|
|||
g_clock_last_counter = counter;
|
||||
|
||||
errout_in_critical_section:
|
||||
leave_critical_section(flags);
|
||||
spin_unlock_irqrestore(&g_clock_lock, flags);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
|
@ -280,6 +281,9 @@ errout_in_critical_section:
|
|||
|
||||
void clock_inittimekeeping(FAR const struct timespec *tp)
|
||||
{
|
||||
irqstate_t flags;
|
||||
|
||||
flags = spin_lock_irqsave(&g_clock_lock);
|
||||
up_timer_getmask(&g_clock_mask);
|
||||
|
||||
if (tp)
|
||||
|
@ -292,6 +296,7 @@ void clock_inittimekeeping(FAR const struct timespec *tp)
|
|||
}
|
||||
|
||||
up_timer_gettick(&g_clock_last_counter);
|
||||
spin_unlock_irqrestore(&g_clock_lock, flags);
|
||||
}
|
||||
|
||||
#endif /* CONFIG_CLOCK_TIMEKEEPING */
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
|
||||
#include <nuttx/coredump.h>
|
||||
#include <nuttx/elf.h>
|
||||
#include <nuttx/nuttx.h>
|
||||
#include <nuttx/sched.h>
|
||||
|
||||
#include "sched/sched.h"
|
||||
|
@ -54,9 +55,6 @@
|
|||
|
||||
#define PROGRAM_ALIGNMENT 64
|
||||
|
||||
#define ROUNDUP(x, y) ((x + (y - 1)) / (y)) * (y)
|
||||
#define ROUNDDOWN(x ,y) (((x) / (y)) * (y))
|
||||
|
||||
/****************************************************************************
|
||||
* Private Types
|
||||
****************************************************************************/
|
||||
|
@ -166,8 +164,8 @@ static int elf_emit(FAR struct elf_dumpinfo_s *cinfo,
|
|||
|
||||
static int elf_emit_align(FAR struct elf_dumpinfo_s *cinfo)
|
||||
{
|
||||
off_t align = ROUNDUP(cinfo->stream->nput,
|
||||
ELF_PAGESIZE) - cinfo->stream->nput;
|
||||
off_t align = ALIGN_UP(cinfo->stream->nput,
|
||||
ELF_PAGESIZE) - cinfo->stream->nput;
|
||||
unsigned char null[256];
|
||||
off_t total = align;
|
||||
off_t ret = 0;
|
||||
|
@ -258,10 +256,10 @@ static int elf_get_note_size(int stksegs)
|
|||
{
|
||||
int total;
|
||||
|
||||
total = stksegs * (sizeof(Elf_Nhdr) + ROUNDUP(CONFIG_TASK_NAME_SIZE, 8) +
|
||||
sizeof(elf_prstatus_t));
|
||||
total += stksegs * (sizeof(Elf_Nhdr) + ROUNDUP(CONFIG_TASK_NAME_SIZE, 8) +
|
||||
sizeof(elf_prpsinfo_t));
|
||||
total = stksegs * (sizeof(Elf_Nhdr) + ALIGN_UP(CONFIG_TASK_NAME_SIZE, 8) +
|
||||
sizeof(elf_prstatus_t));
|
||||
total += stksegs * (sizeof(Elf_Nhdr) + ALIGN_UP(CONFIG_TASK_NAME_SIZE, 8) +
|
||||
sizeof(elf_prpsinfo_t));
|
||||
return total;
|
||||
}
|
||||
|
||||
|
@ -276,7 +274,7 @@ static int elf_get_note_size(int stksegs)
|
|||
static void elf_emit_tcb_note(FAR struct elf_dumpinfo_s *cinfo,
|
||||
FAR struct tcb_s *tcb)
|
||||
{
|
||||
char name[ROUNDUP(CONFIG_TASK_NAME_SIZE, 8)];
|
||||
char name[ALIGN_UP(CONFIG_TASK_NAME_SIZE, 8)];
|
||||
elf_prstatus_t status;
|
||||
elf_prpsinfo_t info;
|
||||
FAR uintptr_t *regs;
|
||||
|
@ -414,8 +412,8 @@ static void elf_emit_tcb_stack(FAR struct elf_dumpinfo_s *cinfo,
|
|||
(tcb->stack_base_ptr - tcb->stack_alloc_ptr);
|
||||
}
|
||||
|
||||
sp = ROUNDDOWN(buf, PROGRAM_ALIGNMENT);
|
||||
len = ROUNDUP(len + (buf - sp), PROGRAM_ALIGNMENT);
|
||||
sp = ALIGN_DOWN(buf, PROGRAM_ALIGNMENT);
|
||||
len = ALIGN_UP(len + (buf - sp), PROGRAM_ALIGNMENT);
|
||||
buf = sp;
|
||||
|
||||
elf_emit(cinfo, (FAR void *)buf, len);
|
||||
|
@ -546,17 +544,17 @@ static void elf_emit_tcb_phdr(FAR struct elf_dumpinfo_s *cinfo,
|
|||
(tcb->stack_base_ptr - tcb->stack_alloc_ptr);
|
||||
}
|
||||
|
||||
sp = ROUNDDOWN(phdr->p_vaddr, PROGRAM_ALIGNMENT);
|
||||
phdr->p_filesz = ROUNDUP(phdr->p_filesz +
|
||||
(phdr->p_vaddr - sp), PROGRAM_ALIGNMENT);
|
||||
sp = ALIGN_DOWN(phdr->p_vaddr, PROGRAM_ALIGNMENT);
|
||||
phdr->p_filesz = ALIGN_UP(phdr->p_filesz +
|
||||
(phdr->p_vaddr - sp), PROGRAM_ALIGNMENT);
|
||||
phdr->p_vaddr = sp;
|
||||
|
||||
phdr->p_type = PT_LOAD;
|
||||
phdr->p_offset = ROUNDUP(*offset, ELF_PAGESIZE);
|
||||
phdr->p_offset = ALIGN_UP(*offset, ELF_PAGESIZE);
|
||||
phdr->p_paddr = phdr->p_vaddr;
|
||||
phdr->p_memsz = phdr->p_filesz;
|
||||
phdr->p_flags = PF_X | PF_W | PF_R;
|
||||
*offset += ROUNDUP(phdr->p_memsz, ELF_PAGESIZE);
|
||||
*offset += ALIGN_UP(phdr->p_memsz, ELF_PAGESIZE);
|
||||
|
||||
elf_emit(cinfo, phdr, sizeof(*phdr));
|
||||
}
|
||||
|
@ -608,13 +606,13 @@ static void elf_emit_phdr(FAR struct elf_dumpinfo_s *cinfo,
|
|||
for (i = 0; i < memsegs; i++)
|
||||
{
|
||||
phdr.p_type = PT_LOAD;
|
||||
phdr.p_offset = ROUNDUP(offset, ELF_PAGESIZE);
|
||||
phdr.p_offset = ALIGN_UP(offset, ELF_PAGESIZE);
|
||||
phdr.p_vaddr = cinfo->regions[i].start;
|
||||
phdr.p_paddr = phdr.p_vaddr;
|
||||
phdr.p_filesz = cinfo->regions[i].end - cinfo->regions[i].start;
|
||||
phdr.p_memsz = phdr.p_filesz;
|
||||
phdr.p_flags = cinfo->regions[i].flags;
|
||||
offset += ROUNDUP(phdr.p_memsz, ELF_PAGESIZE);
|
||||
offset += ALIGN_UP(phdr.p_memsz, ELF_PAGESIZE);
|
||||
elf_emit(cinfo, &phdr, sizeof(phdr));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue