libs/lbc: remove CHAR_BIT = 16 support

For CEVA platform CHAR_BIT is 16, and will do lots of extra work
when use IPC.
We will not support this platform anymore, so remove all the b2c operations.

Signed-off-by: ligd <liguiding1@xiaomi.com>
This commit is contained in:
ligd
2021-12-08 12:20:35 +08:00
committed by Xiang Xiao
parent db6dd623c6
commit 5b369c5cec
18 changed files with 77 additions and 627 deletions
+4 -5
View File
@@ -79,20 +79,19 @@ FAR void *up_addrenv_pa_to_va(uintptr_t pa)
{ {
if (pa - addrenv[i].pa < addrenv[i].size) if (pa - addrenv[i].pa < addrenv[i].size)
{ {
return (FAR void *)(addrenv[i].va + return (FAR void *)(addrenv[i].va + pa - addrenv[i].pa);
B2C(pa - addrenv[i].pa));
} }
} }
} }
return (FAR void *)B2C(pa); return (FAR void *)pa;
} }
uintptr_t up_addrenv_va_to_pa(FAR void *va_) uintptr_t up_addrenv_va_to_pa(FAR void *va_)
{ {
FAR struct simple_addrenv_node_s *node; FAR struct simple_addrenv_node_s *node;
FAR const struct simple_addrenv_s *addrenv; FAR const struct simple_addrenv_s *addrenv;
uintptr_t va = C2B((uintptr_t)va_); uintptr_t va = (uintptr_t)va_;
uint32_t i; uint32_t i;
list_for_every_entry(&g_addrenv_list, node, list_for_every_entry(&g_addrenv_list, node,
@@ -101,7 +100,7 @@ uintptr_t up_addrenv_va_to_pa(FAR void *va_)
addrenv = node->addrenv; addrenv = node->addrenv;
for (i = 0; addrenv[i].size; i++) for (i = 0; addrenv[i].size; i++)
{ {
uintptr_t tmp = C2B(addrenv[i].va); uintptr_t tmp = addrenv[i].va;
if (va - tmp < addrenv[i].size) if (va - tmp < addrenv[i].size)
{ {
return addrenv[i].pa + (va - tmp); return addrenv[i].pa + (va - tmp);
-2
View File
@@ -50,13 +50,11 @@
static inline void clk_write(uint32_t reg, uint32_t value) static inline void clk_write(uint32_t reg, uint32_t value)
{ {
reg = reg / (CHAR_BIT / 8);
*((volatile uint32_t *) (reg)) = value; *((volatile uint32_t *) (reg)) = value;
} }
static inline uint32_t clk_read(uint32_t reg) static inline uint32_t clk_read(uint32_t reg)
{ {
reg = reg / (CHAR_BIT / 8);
return *((volatile uint32_t *) (reg)); return *((volatile uint32_t *) (reg));
} }
+2 -2
View File
@@ -538,8 +538,8 @@ static int rptun_dev_start(FAR struct remoteproc *rproc)
metal_phys_addr_t pa0; metal_phys_addr_t pa0;
metal_phys_addr_t pa1; metal_phys_addr_t pa1;
align0 = B2C(rsc->rpmsg_vring0.align); align0 = rsc->rpmsg_vring0.align;
align1 = B2C(rsc->rpmsg_vring1.align); align1 = rsc->rpmsg_vring1.align;
tbsz = ALIGN_UP(sizeof(struct rptun_rsc_s), MAX(align0, align1)); tbsz = ALIGN_UP(sizeof(struct rptun_rsc_s), MAX(align0, align1));
v0sz = ALIGN_UP(vring_size(rsc->rpmsg_vring0.num, align0), align0); v0sz = ALIGN_UP(vring_size(rsc->rpmsg_vring0.num, align0), align0);
+8 -10
View File
@@ -245,7 +245,7 @@ static void uart_rpmsg_dmasend(FAR struct uart_dev_s *dev)
memset(msg, 0, sizeof(*msg)); memset(msg, 0, sizeof(*msg));
space = C2B(space - sizeof(*msg)); space = space - sizeof(*msg);
if (len > space) if (len > space)
{ {
@@ -254,13 +254,12 @@ static void uart_rpmsg_dmasend(FAR struct uart_dev_s *dev)
if (len > xfer->length) if (len > xfer->length)
{ {
cmem2bmem(msg->data, 0, xfer->buffer, xfer->length); memcpy(msg->data, xfer->buffer, xfer->length);
cmem2bmem(msg->data + B2C_OFF(xfer->length), B2C_REM(xfer->length), memcpy(msg->data, xfer->nbuffer, len - xfer->length);
xfer->nbuffer, len - xfer->length);
} }
else else
{ {
cmem2bmem(msg->data, 0, xfer->buffer, len); memcpy(msg->data, xfer->buffer, len);
} }
msg->count = len; msg->count = len;
@@ -268,7 +267,7 @@ static void uart_rpmsg_dmasend(FAR struct uart_dev_s *dev)
msg->header.result = -ENXIO; msg->header.result = -ENXIO;
msg->header.cookie = (uintptr_t)dev; msg->header.cookie = (uintptr_t)dev;
rpmsg_send_nocopy(&priv->ept, msg, sizeof(*msg) + B2C(len)); rpmsg_send_nocopy(&priv->ept, msg, sizeof(*msg) + len);
} }
static void uart_rpmsg_dmareceive(FAR struct uart_dev_s *dev) static void uart_rpmsg_dmareceive(FAR struct uart_dev_s *dev)
@@ -286,13 +285,12 @@ static void uart_rpmsg_dmareceive(FAR struct uart_dev_s *dev)
if (len > xfer->length) if (len > xfer->length)
{ {
bmem2cmem(xfer->buffer, msg->data, 0, xfer->length); memcpy(xfer->buffer, msg->data, xfer->length);
bmem2cmem(xfer->nbuffer, msg->data + B2C_OFF(xfer->length), memcpy(xfer->nbuffer, msg->data, len - xfer->length);
B2C_REM(xfer->length), len - xfer->length);
} }
else else
{ {
bmem2cmem(xfer->buffer, msg->data, 0, len); memcpy(xfer->buffer, msg->data, len);
} }
xfer->nbytes = len; xfer->nbytes = len;
+21 -38
View File
@@ -44,9 +44,7 @@
#define SYSLOG_RPMSG_WORK_DELAY MSEC2TICK(CONFIG_SYSLOG_RPMSG_WORK_DELAY) #define SYSLOG_RPMSG_WORK_DELAY MSEC2TICK(CONFIG_SYSLOG_RPMSG_WORK_DELAY)
#define SYSLOG_RPMSG_COUNT(h, t, size) ((B2C_OFF(h)>=(t)) ? \ #define SYSLOG_RPMSG_COUNT(h, t, size) (((h)>=(t)) ? (h)-(t) : (size)-((t)-(h)))
B2C_OFF(h)-(t) : \
(size)-((t)-B2C_OFF(h)))
#define SYSLOG_RPMSG_SPACE(h, t, size) ((size) - 1 - SYSLOG_RPMSG_COUNT(h, t, size)) #define SYSLOG_RPMSG_SPACE(h, t, size) ((size) - 1 - SYSLOG_RPMSG_COUNT(h, t, size))
/**************************************************************************** /****************************************************************************
@@ -117,11 +115,6 @@ static void syslog_rpmsg_work(FAR void *priv_)
flags = enter_critical_section(); flags = enter_critical_section();
if (B2C_REM(priv->head))
{
priv->head += C2B(1) - B2C_REM(priv->head);
}
space -= sizeof(*msg); space -= sizeof(*msg);
len = SYSLOG_RPMSG_COUNT(priv->head, priv->tail, priv->size); len = SYSLOG_RPMSG_COUNT(priv->head, priv->tail, priv->size);
len_end = priv->size - priv->tail; len_end = priv->size - priv->tail;
@@ -147,30 +140,24 @@ static void syslog_rpmsg_work(FAR void *priv_)
leave_critical_section(flags); leave_critical_section(flags);
msg->header.command = SYSLOG_RPMSG_TRANSFER; msg->header.command = SYSLOG_RPMSG_TRANSFER;
msg->count = C2B(len); msg->count = len;
rpmsg_send_nocopy(&priv->ept, msg, sizeof(*msg) + len); rpmsg_send_nocopy(&priv->ept, msg, sizeof(*msg) + len);
} }
static void syslog_rpmsg_putchar(FAR struct syslog_rpmsg_s *priv, int ch, static void syslog_rpmsg_putchar(FAR struct syslog_rpmsg_s *priv, int ch,
bool last) bool last)
{ {
if (B2C_REM(priv->head) == 0) priv->buffer[priv->head] = ch & 0xff;
{
priv->buffer[B2C_OFF(priv->head)] = 0;
}
priv->buffer[B2C_OFF(priv->head)] |= (ch & 0xff) <<
(8 * B2C_REM(priv->head));
priv->head += 1; priv->head += 1;
if (priv->head >= C2B(priv->size)) if (priv->head >= (priv->size))
{ {
priv->head = 0; priv->head = 0;
} }
/* Allow overwrite */ /* Allow overwrite */
if (priv->head == C2B(priv->tail)) if (priv->head == (priv->tail))
{ {
priv->buffer[priv->tail] = 0; priv->buffer[priv->tail] = 0;
@@ -350,35 +337,31 @@ void syslog_rpmsg_init_early(FAR void *buffer, size_t size)
char prev; char prev;
char cur; char cur;
size_t i; size_t i;
size_t j;
priv->buffer = buffer; priv->buffer = buffer;
priv->size = size; priv->size = size;
prev = (priv->buffer[size - 1] >> (CHAR_BIT - 8)) & 0xff; prev = priv->buffer[size - 1];
for (i = 0; i < size; i++) for (i = 0; i < size; i++)
{ {
for (j = 0; j * 8 < CHAR_BIT; j++) cur = priv->buffer[i];
if (!isascii(cur))
{ {
cur = (priv->buffer[i] >> j * 8) & 0xff; memset(priv->buffer, 0, size);
break;
if (!isascii(cur))
{
memset(priv->buffer, 0, size);
break;
}
else if (prev && !cur)
{
priv->head = C2B(i) + j;
}
else if (!prev && cur)
{
priv->tail = i;
}
prev = cur;
} }
else if (prev && !cur)
{
priv->head = i;
}
else if (!prev && cur)
{
priv->tail = i;
}
prev = cur;
} }
if (i != size) if (i != size)
+32 -32
View File
@@ -147,7 +147,7 @@ static int rpmsgfs_read_handler(FAR struct rpmsg_endpoint *ept,
cookie->result = header->result; cookie->result = header->result;
if (cookie->result > 0) if (cookie->result > 0)
{ {
memcpy(cookie->data, rsp->buf, B2C(cookie->result)); memcpy(cookie->data, rsp->buf, cookie->result);
} }
nxsem_post(&cookie->sem); nxsem_post(&cookie->sem);
@@ -168,7 +168,7 @@ static int rpmsgfs_readdir_handler(FAR struct rpmsg_endpoint *ept,
cookie->result = header->result; cookie->result = header->result;
if (cookie->result >= 0) if (cookie->result >= 0)
{ {
nbstr2cstr(entry->d_name, rsp->name, NAME_MAX); strncpy(entry->d_name, rsp->name, NAME_MAX);
entry->d_name[NAME_MAX] = '\0'; entry->d_name[NAME_MAX] = '\0';
entry->d_type = rsp->type; entry->d_type = rsp->type;
} }
@@ -193,7 +193,7 @@ static int rpmsgfs_statfs_handler(FAR struct rpmsg_endpoint *ept,
{ {
buf->f_type = rsp->buf.f_type; buf->f_type = rsp->buf.f_type;
buf->f_namelen = rsp->buf.f_namelen; buf->f_namelen = rsp->buf.f_namelen;
buf->f_bsize = B2C(rsp->buf.f_bsize); buf->f_bsize = rsp->buf.f_bsize;
buf->f_blocks = rsp->buf.f_blocks; buf->f_blocks = rsp->buf.f_blocks;
buf->f_bfree = rsp->buf.f_bfree; buf->f_bfree = rsp->buf.f_bfree;
buf->f_bavail = rsp->buf.f_bavail; buf->f_bavail = rsp->buf.f_bavail;
@@ -226,11 +226,11 @@ static int rpmsgfs_stat_handler(FAR struct rpmsg_endpoint *ept,
buf->st_uid = rsp->buf.st_uid; buf->st_uid = rsp->buf.st_uid;
buf->st_gid = rsp->buf.st_gid; buf->st_gid = rsp->buf.st_gid;
buf->st_rdev = rsp->buf.st_rdev; buf->st_rdev = rsp->buf.st_rdev;
buf->st_size = B2C(rsp->buf.st_size); buf->st_size = rsp->buf.st_size;
buf->st_atime = rsp->buf.st_atime; buf->st_atime = rsp->buf.st_atime;
buf->st_mtime = rsp->buf.st_mtime; buf->st_mtime = rsp->buf.st_mtime;
buf->st_ctime = rsp->buf.st_ctime; buf->st_ctime = rsp->buf.st_ctime;
buf->st_blksize = B2C(rsp->buf.st_blksize); buf->st_blksize = rsp->buf.st_blksize;
buf->st_blocks = rsp->buf.st_blocks; buf->st_blocks = rsp->buf.st_blocks;
} }
@@ -344,7 +344,7 @@ int rpmsgfs_client_open(FAR void *handle, FAR const char *pathname,
size_t len; size_t len;
len = sizeof(*msg); len = sizeof(*msg);
len += B2C(strlen(pathname) + 1); len += strlen(pathname) + 1;
msg = rpmsg_get_tx_payload_buffer(&priv->ept, &space, true); msg = rpmsg_get_tx_payload_buffer(&priv->ept, &space, true);
if (!msg) if (!msg)
@@ -356,7 +356,7 @@ int rpmsgfs_client_open(FAR void *handle, FAR const char *pathname,
msg->flags = flags; msg->flags = flags;
msg->mode = mode; msg->mode = mode;
cstr2bstr(msg->pathname, pathname); strcpy(msg->pathname, pathname);
return rpmsgfs_send_recv(priv, RPMSGFS_OPEN, false, return rpmsgfs_send_recv(priv, RPMSGFS_OPEN, false,
(struct rpmsgfs_header_s *)msg, len, NULL); (struct rpmsgfs_header_s *)msg, len, NULL);
@@ -384,7 +384,7 @@ ssize_t rpmsgfs_client_read(FAR void *handle, int fd,
struct rpmsgfs_read_s msg = struct rpmsgfs_read_s msg =
{ {
.fd = fd, .fd = fd,
.count = C2B(count - read), .count = count - read,
}; };
ret = rpmsgfs_send_recv(handle, RPMSGFS_READ, true, ret = rpmsgfs_send_recv(handle, RPMSGFS_READ, true,
@@ -394,8 +394,8 @@ ssize_t rpmsgfs_client_read(FAR void *handle, int fd,
break; break;
} }
read += B2C(ret); read += ret;
buf += B2C(ret); buf += ret;
} }
return read ? read : ret; return read ? read : ret;
@@ -427,7 +427,7 @@ ssize_t rpmsgfs_client_write(FAR void *handle, int fd,
} }
msg->fd = fd; msg->fd = fd;
msg->count = C2B(space); msg->count = space;
memcpy(msg->buf, buf + written, space); memcpy(msg->buf, buf + written, space);
ret = rpmsgfs_send_recv(priv, RPMSGFS_WRITE, false, ret = rpmsgfs_send_recv(priv, RPMSGFS_WRITE, false,
@@ -438,7 +438,7 @@ ssize_t rpmsgfs_client_write(FAR void *handle, int fd,
break; break;
} }
written += B2C(ret); written += ret;
} }
return written ? written : ret; return written ? written : ret;
@@ -450,7 +450,7 @@ off_t rpmsgfs_client_lseek(FAR void *handle, int fd,
struct rpmsgfs_lseek_s msg = struct rpmsgfs_lseek_s msg =
{ {
.fd = fd, .fd = fd,
.offset = C2B(offset), .offset = offset,
.whence = whence, .whence = whence,
}; };
@@ -459,7 +459,7 @@ off_t rpmsgfs_client_lseek(FAR void *handle, int fd,
ret = rpmsgfs_send_recv(handle, RPMSGFS_LSEEK, true, ret = rpmsgfs_send_recv(handle, RPMSGFS_LSEEK, true,
(struct rpmsgfs_header_s *)&msg, sizeof(msg), NULL); (struct rpmsgfs_header_s *)&msg, sizeof(msg), NULL);
return ret < 0 ? ret : B2C(ret); return ret < 0 ? ret : ret;
} }
int rpmsgfs_client_ioctl(FAR void *handle, int fd, int rpmsgfs_client_ioctl(FAR void *handle, int fd,
@@ -530,7 +530,7 @@ FAR void *rpmsgfs_client_opendir(FAR void *handle, FAR const char *name)
int ret; int ret;
len = sizeof(*msg); len = sizeof(*msg);
len += B2C(strlen(name) + 1); len += strlen(name) + 1;
msg = rpmsg_get_tx_payload_buffer(&priv->ept, &space, true); msg = rpmsg_get_tx_payload_buffer(&priv->ept, &space, true);
if (!msg) if (!msg)
@@ -540,7 +540,7 @@ FAR void *rpmsgfs_client_opendir(FAR void *handle, FAR const char *name)
DEBUGASSERT(len <= space); DEBUGASSERT(len <= space);
cstr2bstr(msg->pathname, name); strcpy(msg->pathname, name);
ret = rpmsgfs_send_recv(priv, RPMSGFS_OPENDIR, false, ret = rpmsgfs_send_recv(priv, RPMSGFS_OPENDIR, false,
(struct rpmsgfs_header_s *)msg, len, NULL); (struct rpmsgfs_header_s *)msg, len, NULL);
@@ -636,7 +636,7 @@ int rpmsgfs_client_statfs(FAR void *handle, FAR const char *path,
size_t len; size_t len;
len = sizeof(*msg); len = sizeof(*msg);
len += B2C(strlen(path) + 1); len += strlen(path) + 1;
msg = rpmsg_get_tx_payload_buffer(&priv->ept, &space, true); msg = rpmsg_get_tx_payload_buffer(&priv->ept, &space, true);
if (!msg) if (!msg)
@@ -646,7 +646,7 @@ int rpmsgfs_client_statfs(FAR void *handle, FAR const char *path,
DEBUGASSERT(len <= space); DEBUGASSERT(len <= space);
cstr2bstr(msg->pathname, path); strcpy(msg->pathname, path);
return rpmsgfs_send_recv(priv, RPMSGFS_STATFS, false, return rpmsgfs_send_recv(priv, RPMSGFS_STATFS, false,
(struct rpmsgfs_header_s *)msg, len, buf); (struct rpmsgfs_header_s *)msg, len, buf);
@@ -660,7 +660,7 @@ int rpmsgfs_client_unlink(FAR void *handle, FAR const char *pathname)
size_t len; size_t len;
len = sizeof(*msg); len = sizeof(*msg);
len += B2C(strlen(pathname) + 1); len += strlen(pathname) + 1;
msg = rpmsg_get_tx_payload_buffer(&priv->ept, &space, true); msg = rpmsg_get_tx_payload_buffer(&priv->ept, &space, true);
if (!msg) if (!msg)
@@ -670,7 +670,7 @@ int rpmsgfs_client_unlink(FAR void *handle, FAR const char *pathname)
DEBUGASSERT(len <= space); DEBUGASSERT(len <= space);
cstr2bstr(msg->pathname, pathname); strcpy(msg->pathname, pathname);
return rpmsgfs_send_recv(priv, RPMSGFS_UNLINK, false, return rpmsgfs_send_recv(priv, RPMSGFS_UNLINK, false,
(struct rpmsgfs_header_s *)msg, len, NULL); (struct rpmsgfs_header_s *)msg, len, NULL);
@@ -685,7 +685,7 @@ int rpmsgfs_client_mkdir(FAR void *handle, FAR const char *pathname,
size_t len; size_t len;
len = sizeof(*msg); len = sizeof(*msg);
len += B2C(strlen(pathname) + 1); len += strlen(pathname) + 1;
msg = rpmsg_get_tx_payload_buffer(&priv->ept, &space, true); msg = rpmsg_get_tx_payload_buffer(&priv->ept, &space, true);
if (!msg) if (!msg)
@@ -694,7 +694,7 @@ int rpmsgfs_client_mkdir(FAR void *handle, FAR const char *pathname,
} }
msg->mode = mode; msg->mode = mode;
cstr2bstr(msg->pathname, pathname); strcpy(msg->pathname, pathname);
return rpmsgfs_send_recv(priv, RPMSGFS_MKDIR, false, return rpmsgfs_send_recv(priv, RPMSGFS_MKDIR, false,
(struct rpmsgfs_header_s *)msg, len, NULL); (struct rpmsgfs_header_s *)msg, len, NULL);
@@ -708,7 +708,7 @@ int rpmsgfs_client_rmdir(FAR void *handle, FAR const char *pathname)
size_t len; size_t len;
len = sizeof(*msg); len = sizeof(*msg);
len += B2C(strlen(pathname) + 1); len += strlen(pathname) + 1;
msg = rpmsg_get_tx_payload_buffer(&priv->ept, &space, true); msg = rpmsg_get_tx_payload_buffer(&priv->ept, &space, true);
if (!msg) if (!msg)
@@ -718,7 +718,7 @@ int rpmsgfs_client_rmdir(FAR void *handle, FAR const char *pathname)
DEBUGASSERT(len <= space); DEBUGASSERT(len <= space);
cstr2bstr(msg->pathname, pathname); strcpy(msg->pathname, pathname);
return rpmsgfs_send_recv(priv, RPMSGFS_RMDIR, false, return rpmsgfs_send_recv(priv, RPMSGFS_RMDIR, false,
(struct rpmsgfs_header_s *)msg, len, NULL); (struct rpmsgfs_header_s *)msg, len, NULL);
@@ -734,8 +734,8 @@ int rpmsgfs_client_rename(FAR void *handle, FAR const char *oldpath,
uint32_t space; uint32_t space;
len = sizeof(*msg); len = sizeof(*msg);
oldlen = B2C((strlen(oldpath) + 1 + 0x7) & ~0x7); oldlen = (strlen(oldpath) + 1 + 0x7) & ~0x7;
len += oldlen + B2C(strlen(newpath) + 1); len += oldlen + strlen(newpath) + 1;
msg = rpmsg_get_tx_payload_buffer(&priv->ept, &space, true); msg = rpmsg_get_tx_payload_buffer(&priv->ept, &space, true);
if (!msg) if (!msg)
@@ -745,8 +745,8 @@ int rpmsgfs_client_rename(FAR void *handle, FAR const char *oldpath,
DEBUGASSERT(len <= space); DEBUGASSERT(len <= space);
cstr2bstr(msg->pathname, oldpath); strcpy(msg->pathname, oldpath);
cstr2bstr(msg->pathname + oldlen, newpath); strcpy(msg->pathname + oldlen, newpath);
return rpmsgfs_send_recv(priv, RPMSGFS_RENAME, false, return rpmsgfs_send_recv(priv, RPMSGFS_RENAME, false,
(struct rpmsgfs_header_s *)msg, len, NULL); (struct rpmsgfs_header_s *)msg, len, NULL);
@@ -761,7 +761,7 @@ int rpmsgfs_client_stat(FAR void *handle, FAR const char *path,
size_t len; size_t len;
len = sizeof(*msg); len = sizeof(*msg);
len += B2C(strlen(path) + 1); len += strlen(path) + 1;
msg = rpmsg_get_tx_payload_buffer(&priv->ept, &space, true); msg = rpmsg_get_tx_payload_buffer(&priv->ept, &space, true);
if (!msg) if (!msg)
@@ -771,7 +771,7 @@ int rpmsgfs_client_stat(FAR void *handle, FAR const char *path,
DEBUGASSERT(len <= space); DEBUGASSERT(len <= space);
cstr2bstr(msg->pathname, path); strcpy(msg->pathname, path);
return rpmsgfs_send_recv(priv, RPMSGFS_STAT, false, return rpmsgfs_send_recv(priv, RPMSGFS_STAT, false,
(struct rpmsgfs_header_s *)msg, len, buf); (struct rpmsgfs_header_s *)msg, len, buf);
@@ -800,7 +800,7 @@ int rpmsgfs_client_chstat(FAR void *handle, FAR const char *path,
size_t len; size_t len;
len = sizeof(*msg); len = sizeof(*msg);
len += B2C(strlen(path) + 1); len += strlen(path) + 1;
msg = rpmsg_get_tx_payload_buffer(&priv->ept, &space, true); msg = rpmsg_get_tx_payload_buffer(&priv->ept, &space, true);
if (!msg) if (!msg)
@@ -812,7 +812,7 @@ int rpmsgfs_client_chstat(FAR void *handle, FAR const char *path,
msg->flags = flags; msg->flags = flags;
memcpy(&msg->buf, buf, sizeof(*buf)); memcpy(&msg->buf, buf, sizeof(*buf));
cstr2bstr(msg->pathname, path); strcpy(msg->pathname, path);
return rpmsgfs_send_recv(priv, RPMSGFS_CHSTAT, false, return rpmsgfs_send_recv(priv, RPMSGFS_CHSTAT, false,
(struct rpmsgfs_header_s *)msg, len, NULL); (struct rpmsgfs_header_s *)msg, len, NULL);
-109
View File
@@ -1,109 +0,0 @@
/****************************************************************************
* include/nuttx/b2c.h
*
* 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.
*
****************************************************************************/
#ifndef __INCLUDE_NUTTX_B2C_H
#define __INCLUDE_NUTTX_B2C_H
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <sys/types.h>
#include <string.h>
#include <limits.h>
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
#if CHAR_BIT == 8
# define CHAR_BYTE 1
# define CHAR_SHIFT 0
#elif CHAR_BIT == 16
# define CHAR_BYTE 2
# define CHAR_SHIFT 1
#elif CHAR_BIT == 32
# define CHAR_BYTE 4
# define CHAR_SHIFT 2
#else
# error unsupported CHAR_BIT value
#endif
/* Macros convert between chars and bytes */
#define B2C(x) (((x) + CHAR_BYTE - 1) >> CHAR_SHIFT)
#define C2B(x) ((x) << CHAR_SHIFT)
#define B2C_OFF(x) ((x) >> CHAR_SHIFT)
#define C2B_OFF(x) ((x) << CHAR_SHIFT)
#define B2C_REM(x) ((x) - C2B_OFF(B2C_OFF(x)))
#define B2C_SHIFT(x) ((x) - CHAR_SHIFT)
#define C2B_SHIFT(x) ((x) + CHAR_SHIFT)
/****************************************************************************
* Public Function Prototypes
****************************************************************************/
/* Functions convert between chars and bytes */
#if CHAR_BIT != 8
size_t bstrnlen(FAR const char *src, size_t maxlen);
FAR char *ancstr2bstr(FAR const char *src, size_t maxlen);
FAR char *anbstr2cstr(FAR const char *src, size_t maxlen);
void ncstr2bstr(FAR char *dst, FAR const char *src, size_t maxlen);
void nbstr2cstr(FAR char *dst, FAR const char *src, size_t maxlen);
void cmem2bmem(FAR void *dst, size_t rem, FAR const void *src, size_t len);
void bmem2cmem(FAR void *dst, FAR const void *src, size_t rem, size_t len);
# define cstr2bstr(dst, src) ncstr2bstr(dst, src, SIZE_MAX)
# define bstr2cstr(dst, src) nbstr2cstr(dst, src, SIZE_MAX)
#else
# define bstrnlen(src, maxlen) strnlen(src, maxlen)
# define ancstr2bstr(src, maxlen) strndup(src, maxlen)
# define anbstr2cstr(src, maxlen) strndup(src, maxlen)
# define ncstr2bstr(dst, src, maxlen) strncpy(dst, src, maxlen)
# define nbstr2cstr(dst, src, maxlen) strncpy(dst, src, maxlen)
# define cmem2bmem(dst, rem, src, len) memcpy((FAR char *)(dst) + rem, src, len)
# define bmem2cmem(dst, src, rem, len) memcpy(dst, (FAR char *)(src) + rem, len)
# define cstr2bstr(dst, src) strcpy(dst, src)
# define bstr2cstr(dst, src) strcpy(dst, src)
#endif
#define bstrlen(src) bstrnlen(src, SIZE_MAX)
#define acstr2bstr(src) ancstr2bstr(src, SIZE_MAX)
#define abstr2cstr(src) anbstr2cstr(src, SIZE_MAX)
#endif /* __INCLUDE_NUTTX_B2C_H */
+1 -1
View File
@@ -265,7 +265,7 @@ struct rptun_addrenv_s
size_t size; size_t size;
}; };
struct aligned_data(B2C(8)) rptun_rsc_s struct aligned_data(8) rptun_rsc_s
{ {
struct resource_table rsc_tbl_hdr; struct resource_table rsc_tbl_hdr;
unsigned int offset[2]; unsigned int offset[2];
-6
View File
@@ -29,12 +29,6 @@
#include <stddef.h> #include <stddef.h>
/* Non-standard support for cases where CHAR_BIT != 8 carried in strings.h
* only for convenience. See include/nuttx/b2c.h.
*/
#include <nuttx/b2c.h>
/**************************************************************************** /****************************************************************************
* Pre-processor Definitions * Pre-processor Definitions
****************************************************************************/ ****************************************************************************/
-2
View File
@@ -29,8 +29,6 @@ CSRCS += lib_strerror.c lib_strncasecmp.c lib_strncat.c lib_strncmp.c
CSRCS += lib_strndup.c lib_strcasestr.c lib_strpbrk.c lib_strrchr.c CSRCS += lib_strndup.c lib_strcasestr.c lib_strpbrk.c lib_strrchr.c
CSRCS += lib_strspn.c lib_strstr.c lib_strtok.c lib_strtokr.c CSRCS += lib_strspn.c lib_strstr.c lib_strtok.c lib_strtokr.c
CSRCS += lib_strsep.c lib_strerrorr.c lib_explicit_bzero.c lib_strsignal.c CSRCS += lib_strsep.c lib_strerrorr.c lib_explicit_bzero.c lib_strsignal.c
CSRCS += lib_anbstr2cstr.c lib_ancstr2bstr.c lib_bmem2cmem.c
CSRCS += lib_bstrnlen.c lib_cmem2bmem.c lib_nbstr2cstr.c lib_ncstr2bstr.c
CSRCS += lib_index.c lib_rindex.c CSRCS += lib_index.c lib_rindex.c
ifneq ($(CONFIG_LIBC_ARCH_MEMCHR),y) ifneq ($(CONFIG_LIBC_ARCH_MEMCHR),y)
-54
View File
@@ -1,54 +0,0 @@
/****************************************************************************
* libs/libc/string/lib_anbstr2cstr.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 <nuttx/config.h>
#include <stdlib.h>
#include <string.h>
#include "libc.h"
#if CHAR_BIT != 8
/****************************************************************************
* Public Functions
****************************************************************************/
FAR char *anbstr2cstr(FAR const char *src, size_t maxlen)
{
FAR char *dst;
size_t len;
len = bstrnlen(src, maxlen);
dst = lib_malloc(C2B(len + 1));
if (dst)
{
dst[C2B(len + 1) - 1] = 0;
bmem2cmem(dst, src, 0, len);
}
return dst;
}
#endif
-54
View File
@@ -1,54 +0,0 @@
/****************************************************************************
* libs/libc/string/lib_ancstr2bstr.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 <nuttx/config.h>
#include <stdlib.h>
#include <string.h>
#include "libc.h"
#if CHAR_BIT != 8
/****************************************************************************
* Public Functions
****************************************************************************/
FAR char *ancstr2bstr(FAR const char *src, size_t maxlen)
{
FAR char *dst;
size_t len;
len = strnlen(src, maxlen);
dst = lib_malloc(B2C(len + 1));
if (dst)
{
dst[B2C(len + 1) - 1] = 0;
cmem2bmem(dst, 0, src, len);
}
return dst;
}
#endif
-59
View File
@@ -1,59 +0,0 @@
/****************************************************************************
* libs/libc/string/lib_bmem2cmem.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 <nuttx/config.h>
#include <stdlib.h>
#if !defined(CONFIG_ENDIAN_BIG) && CHAR_BIT != 8
/****************************************************************************
* Public Functions
****************************************************************************/
void bmem2cmem(FAR void *dst_, FAR const void *src_, size_t rem, size_t len)
{
char *dst = dst_;
const char *src = src_;
while (1)
{
int i;
for (i = 8 * rem; i < CHAR_BIT; i += 8)
{
if (len-- == 0)
{
return;
}
*dst++ = (*src >> i) & 0xff;
}
rem = 0;
src++;
}
}
#endif
-55
View File
@@ -1,55 +0,0 @@
/****************************************************************************
* libs/libc/string/lib_bstrnlen.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 <nuttx/config.h>
#include <stdlib.h>
#if !defined(CONFIG_ENDIAN_BIG) && CHAR_BIT != 8
/****************************************************************************
* Public Functions
****************************************************************************/
size_t bstrnlen(FAR const char *src, size_t maxlen)
{
size_t len = 0;
while (1)
{
int i;
for (i = 0; i < CHAR_BIT; i += 8, len++)
{
if (maxlen-- == 0 || ((*src >> i) & 0xff) == 0)
{
return len;
}
}
src++;
}
}
#endif
-63
View File
@@ -1,63 +0,0 @@
/****************************************************************************
* libs/libc/string/lib_cmem2bmem.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 <nuttx/config.h>
#include <stdlib.h>
#if !defined(CONFIG_ENDIAN_BIG) && CHAR_BIT != 8
/****************************************************************************
* Public Functions
****************************************************************************/
void cmem2bmem(FAR void *dst_, size_t rem, FAR const void *src_, size_t len)
{
char *dst = dst_;
const char *src = src_;
while (1)
{
int i;
for (i = 8 * rem; i < CHAR_BIT; i += 8)
{
if (len-- == 0)
{
return;
}
else if (i == 8 * rem)
{
*dst = 0;
}
*dst |= (*src++ & 0xff) << i;
}
rem = 0;
dst++;
}
}
#endif
-59
View File
@@ -1,59 +0,0 @@
/****************************************************************************
* libs/libc/string/lib_nbstr2cstr.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 <nuttx/config.h>
#include <stdlib.h>
#if !defined(CONFIG_ENDIAN_BIG) && CHAR_BIT != 8
/****************************************************************************
* Public Functions
****************************************************************************/
void nbstr2cstr(FAR char *dst, FAR const char *src, size_t maxlen)
{
while (1)
{
int i;
for (i = 0; i < CHAR_BIT; i += 8)
{
if (maxlen-- == 0)
{
return;
}
*dst = (*src >> i) & 0xff;
if (*dst++ == 0)
{
return;
}
}
src++;
}
}
#endif
-67
View File
@@ -1,67 +0,0 @@
/****************************************************************************
* libs/libc/string/lib_ncstr2bstr.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 <nuttx/config.h>
#include <stdlib.h>
#if !defined(CONFIG_ENDIAN_BIG) && CHAR_BIT != 8
/****************************************************************************
* Public Functions
****************************************************************************/
void ncstr2bstr(FAR char *dst, FAR const char *src, size_t maxlen)
{
while (1)
{
int i;
for (i = 0; i < CHAR_BIT; i += 8)
{
char tmp;
if (maxlen-- == 0)
{
return;
}
else if (i == 0)
{
*dst = 0;
}
tmp = *src++ & 0xff;
if (tmp == 0)
{
return;
}
*dst |= tmp << i;
}
dst++;
}
}
#endif
+9 -9
View File
@@ -63,8 +63,8 @@
* REVISIT: We could do better on machines with 16-bit addressing. * REVISIT: We could do better on machines with 16-bit addressing.
*/ */
# define MM_MIN_SHIFT B2C_SHIFT( 4) /* 16 bytes */ # define MM_MIN_SHIFT ( 4) /* 16 bytes */
# define MM_MAX_SHIFT B2C_SHIFT(15) /* 32 Kb */ # define MM_MAX_SHIFT (15) /* 32 Kb */
#elif defined(CONFIG_HAVE_LONG_LONG) #elif defined(CONFIG_HAVE_LONG_LONG)
/* Four byte offsets; Pointers may be 4 or 8 bytes /* Four byte offsets; Pointers may be 4 or 8 bytes
@@ -72,19 +72,19 @@
*/ */
# if UINTPTR_MAX <= UINT32_MAX # if UINTPTR_MAX <= UINT32_MAX
# define MM_MIN_SHIFT B2C_SHIFT( 4) /* 16 bytes */ # define MM_MIN_SHIFT ( 4) /* 16 bytes */
# elif UINTPTR_MAX <= UINT64_MAX # elif UINTPTR_MAX <= UINT64_MAX
# define MM_MIN_SHIFT B2C_SHIFT( 5) /* 32 bytes */ # define MM_MIN_SHIFT ( 5) /* 32 bytes */
# endif # endif
# define MM_MAX_SHIFT B2C_SHIFT(22) /* 4 Mb */ # define MM_MAX_SHIFT (22) /* 4 Mb */
#else #else
/* Four byte offsets; Pointers must be 4 bytes. /* Four byte offsets; Pointers must be 4 bytes.
* sizeof(struct mm_freenode_s) is 16 bytes. * sizeof(struct mm_freenode_s) is 16 bytes.
*/ */
# define MM_MIN_SHIFT B2C_SHIFT( 4) /* 16 bytes */ # define MM_MIN_SHIFT ( 4) /* 16 bytes */
# define MM_MAX_SHIFT B2C_SHIFT(22) /* 4 Mb */ # define MM_MAX_SHIFT (22) /* 4 Mb */
#endif #endif
/* All other definitions derive from these two */ /* All other definitions derive from these two */
@@ -137,9 +137,9 @@ struct mm_allocnode_s
/* What is the size of the allocnode? */ /* What is the size of the allocnode? */
#ifdef CONFIG_MM_SMALL #ifdef CONFIG_MM_SMALL
# define SIZEOF_MM_ALLOCNODE B2C(4) # define SIZEOF_MM_ALLOCNODE (4)
#else #else
# define SIZEOF_MM_ALLOCNODE B2C(8) # define SIZEOF_MM_ALLOCNODE (8)
#endif #endif
#define CHECK_ALLOCNODE_SIZE \ #define CHECK_ALLOCNODE_SIZE \