mirror of
https://github.com/apache/nuttx.git
synced 2026-05-10 07:18:49 +08:00
Fixes for compile of rwbuffer.c
This commit is contained in:
@@ -0,0 +1,127 @@
|
||||
############################################################################
|
||||
# configs/sim/mtdrwb/Make.defs
|
||||
#
|
||||
# Copyright (C) 2014 Gregory Nutt. All rights reserved.
|
||||
# Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in
|
||||
# the documentation and/or other materials provided with the
|
||||
# distribution.
|
||||
# 3. Neither the name NuttX nor the names of its contributors may be
|
||||
# used to endorse or promote products derived from this software
|
||||
# without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
############################################################################
|
||||
|
||||
include ${TOPDIR}/.config
|
||||
include ${TOPDIR}/tools/Config.mk
|
||||
|
||||
HOSTOS = ${shell uname -o 2>/dev/null || echo "Other"}
|
||||
|
||||
ifeq ($(CONFIG_DEBUG_SYMBOLS),y)
|
||||
ARCHOPTIMIZATION = -g
|
||||
endif
|
||||
|
||||
ifneq ($(CONFIG_DEBUG_NOOPT),y)
|
||||
ARCHOPTIMIZATION += -O2
|
||||
endif
|
||||
|
||||
ARCHCPUFLAGS = -fno-builtin
|
||||
ARCHCPUFLAGSXX = -fno-builtin -fno-exceptions -fno-rtti
|
||||
ARCHPICFLAGS = -fpic
|
||||
ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow
|
||||
ARCHWARNINGSXX = -Wall -Wshadow
|
||||
ARCHDEFINES =
|
||||
ARCHINCLUDES = -I. -isystem $(TOPDIR)/include
|
||||
ARCHINCLUDESXX = -I. -isystem $(TOPDIR)/include -isystem $(TOPDIR)/include/cxx
|
||||
ARCHSCRIPT =
|
||||
|
||||
ifeq ($(CONFIG_SIM_M32),y)
|
||||
ARCHCPUFLAGS += -m32
|
||||
ARCHCPUFLAGSXX += -m32
|
||||
endif
|
||||
|
||||
CROSSDEV =
|
||||
CC = $(CROSSDEV)gcc
|
||||
CXX = $(CROSSDEV)g++
|
||||
CPP = $(CROSSDEV)gcc -E
|
||||
LD = $(CROSSDEV)ld
|
||||
AR = $(CROSSDEV)ar rcs
|
||||
NM = $(CROSSDEV)nm
|
||||
OBJCOPY = $(CROSSDEV)objcopy
|
||||
OBJDUMP = $(CROSSDEV)objdump
|
||||
|
||||
CFLAGS = $(ARCHWARNINGS) $(ARCHOPTIMIZATION) \
|
||||
$(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRADEFINES) -pipe
|
||||
CXXFLAGS = $(ARCHWARNINGSXX) $(ARCHOPTIMIZATION) \
|
||||
$(ARCHCPUFLAGSXX) $(ARCHINCLUDESXX) $(ARCHDEFINES) $(EXTRADEFINES) -pipe
|
||||
CPPFLAGS = $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRADEFINES)
|
||||
AFLAGS = $(CFLAGS) -D__ASSEMBLY__
|
||||
|
||||
|
||||
# ELF module definitions
|
||||
|
||||
CELFFLAGS = $(CFLAGS)
|
||||
CXXELFFLAGS = $(CXXFLAGS)
|
||||
|
||||
LDELFFLAGS = -r -e main
|
||||
ifeq ($(WINTOOL),y)
|
||||
LDELFFLAGS += -T "${shell cygpath -w $(TOPDIR)/configs/$(CONFIG_ARCH_BOARD)/scripts/gnu-elf.ld}"
|
||||
else
|
||||
LDELFFLAGS += -T $(TOPDIR)/configs/$(CONFIG_ARCH_BOARD)/scripts/gnu-elf.ld
|
||||
endif
|
||||
|
||||
|
||||
OBJEXT = .o
|
||||
LIBEXT = .a
|
||||
|
||||
ifeq ($(HOSTOS),Cygwin)
|
||||
EXEEXT = .exe
|
||||
else
|
||||
EXEEXT =
|
||||
endif
|
||||
|
||||
LDLINKFLAGS = $(ARCHSCRIPT) # Link flags used with $(LD)
|
||||
CCLINKFLAGS = $(ARCHSCRIPT) # Link flags used with $(CC)
|
||||
LDFLAGS = $(ARCHSCRIPT) # For backward compatibility, same as CCLINKFLAGS
|
||||
|
||||
ifeq ($(CONFIG_DEBUG_SYMBOLS),y)
|
||||
LDLINKFLAGS += -g
|
||||
CCLINKFLAGS += -g
|
||||
LDFLAGS += -g
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_SIM_M32),y)
|
||||
LDLINKFLAGS += -melf_i386
|
||||
CCLINKFLAGS += -m32
|
||||
LDFLAGS += -m32
|
||||
endif
|
||||
|
||||
|
||||
MKDEP = $(TOPDIR)/tools/mkdeps.sh
|
||||
|
||||
HOSTCC = gcc
|
||||
HOSTINCLUDES = -I.
|
||||
HOSTCFLAGS = $(ARCHWARNINGS) $(ARCHOPTIMIZATION) \
|
||||
$(ARCHCPUFLAGS) $(HOSTINCLUDES) $(ARCHDEFINES) $(EXTRADEFINES) -pipe
|
||||
HOSTLDFLAGS =
|
||||
File diff suppressed because it is too large
Load Diff
Executable
+45
@@ -0,0 +1,45 @@
|
||||
#!/bin/bash
|
||||
# confisgs/sim/mtdrwb/setenv.sh
|
||||
#
|
||||
# Copyright (C) 2014 Gregory Nutt. All rights reserved.
|
||||
# Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in
|
||||
# the documentation and/or other materials provided with the
|
||||
# distribution.
|
||||
# 3. Neither the name NuttX nor the names of its contributors may be
|
||||
# used to endorse or promote products derived from this software
|
||||
# without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
|
||||
if [ "$(basename $0)" = "setenv.sh" ] ; then
|
||||
echo "You must source this script, not run it!" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -z ${PATH_ORIG} ]; then export PATH_ORIG=${PATH}; fi
|
||||
|
||||
#export NUTTX_BIN=
|
||||
#export PATH=${NUTTX_BIN}:/sbin:/usr/sbin:${PATH_ORIG}
|
||||
|
||||
echo "PATH : ${PATH}"
|
||||
+2
-2
@@ -74,10 +74,10 @@ ifneq ($(CONFIG_NFILE_DESCRIPTORS),0)
|
||||
|
||||
ifneq ($(CONFIG_DISABLE_MOUNTPOINT),y)
|
||||
CSRCS += ramdisk.c
|
||||
ifneq ($(CONFIG_DRVR_WRITEBUFFER),y)
|
||||
ifeq ($(CONFIG_DRVR_WRITEBUFFER),y)
|
||||
CSRCS += rwbuffer.c
|
||||
else
|
||||
ifneq ($(CONFIG_DRVR_READAHEAD),y)
|
||||
ifeq ($(CONFIG_DRVR_READAHEAD),y)
|
||||
CSRCS += rwbuffer.c
|
||||
endif
|
||||
endif
|
||||
|
||||
+14
-15
@@ -395,7 +395,7 @@ int rwb_invalidate_writebuffer(FAR struct rwbuffer_s *rwb,
|
||||
{
|
||||
int ret;
|
||||
|
||||
if (rwb->wrmaxblocks > 0 && wrnblocks > 0)
|
||||
if (rwb->wrmaxblocks > 0 && rwb->wrnblocks > 0)
|
||||
{
|
||||
off_t wrbend;
|
||||
off_t invend;
|
||||
@@ -445,7 +445,7 @@ int rwb_invalidate_writebuffer(FAR struct rwbuffer_s *rwb,
|
||||
offset = block - rwb->wrblockstart;
|
||||
src = rwb->wrbuffer + offset * rwb->blocksize;
|
||||
|
||||
ret = rwb->wrflush(rwb->dev, block, nblocks, src);
|
||||
ret = rwb->wrflush(rwb->dev, src, block, nblocks);
|
||||
if (ret < 0)
|
||||
{
|
||||
fdbg("ERROR: wrflush failed: %d\n", ret);
|
||||
@@ -531,7 +531,7 @@ int rwb_invalidate_readahead(FAR struct rwbuffer_s *rwb,
|
||||
{
|
||||
int ret;
|
||||
|
||||
if (rwb->rhmaxblocks > 0 && rhnblocks > 0)
|
||||
if (rwb->rhmaxblocks > 0 && rwb->rhnblocks > 0)
|
||||
{
|
||||
off_t rhbend;
|
||||
off_t invend;
|
||||
@@ -667,7 +667,7 @@ int rwb_initialize(FAR struct rwbuffer_s *rwb)
|
||||
#endif /* CONFIG_DRVR_WRITEBUFFER */
|
||||
|
||||
#ifdef CONFIG_DRVR_READAHEAD
|
||||
if (rhmaxblocks > 0)
|
||||
if (rwb->rhmaxblocks > 0)
|
||||
{
|
||||
fvdbg("Initialize the read-ahead buffer\n");
|
||||
|
||||
@@ -719,7 +719,7 @@ void rwb_uninitialize(FAR struct rwbuffer_s *rwb)
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_DRVR_READAHEAD
|
||||
if (rhmaxblocks > 0)
|
||||
if (rwb->rhmaxblocks > 0)
|
||||
{
|
||||
sem_destroy(&rwb->rhsem);
|
||||
if (rwb->rhbuffer)
|
||||
@@ -738,6 +738,7 @@ int rwb_read(FAR struct rwbuffer_s *rwb, off_t startblock, uint32_t nblocks,
|
||||
FAR uint8_t *rdbuffer)
|
||||
{
|
||||
uint32_t remaining;
|
||||
int ret = OK;
|
||||
|
||||
fvdbg("startblock=%ld nblocks=%ld rdbuffer=%p\n",
|
||||
(long)startblock, (long)nblocks, rdbuffer);
|
||||
@@ -766,7 +767,7 @@ int rwb_read(FAR struct rwbuffer_s *rwb, off_t startblock, uint32_t nblocks,
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_DRVR_READAHEAD
|
||||
if (rhmaxblocks > 0)
|
||||
if (rwb->rhmaxblocks > 0)
|
||||
{
|
||||
/* Loop until we have read all of the requested blocks */
|
||||
|
||||
@@ -777,7 +778,7 @@ int rwb_read(FAR struct rwbuffer_s *rwb, off_t startblock, uint32_t nblocks,
|
||||
|
||||
if (rwb->rhnblocks > 0)
|
||||
{
|
||||
off_t startblock = startblock;
|
||||
off_t block = startblock;
|
||||
size_t nbufblocks = 0;
|
||||
off_t bufferend;
|
||||
|
||||
@@ -788,9 +789,7 @@ int rwb_read(FAR struct rwbuffer_s *rwb, off_t startblock, uint32_t nblocks,
|
||||
|
||||
bufferend = rwb->rhblockstart + rwb->rhnblocks;
|
||||
|
||||
while ((startblock >= rwb->rhblockstart) &&
|
||||
(startblock < bufferend) &&
|
||||
(remaining > 0))
|
||||
while (block >= rwb->rhblockstart && block < bufferend && remaining > 0)
|
||||
{
|
||||
/* This is one more that we will read from the read ahead
|
||||
* buffer.
|
||||
@@ -815,7 +814,7 @@ int rwb_read(FAR struct rwbuffer_s *rwb, off_t startblock, uint32_t nblocks,
|
||||
|
||||
if (remaining > 0)
|
||||
{
|
||||
int ret = rwb_rhreload(rwb, startblock);
|
||||
ret = rwb_rhreload(rwb, startblock);
|
||||
if (ret < 0)
|
||||
{
|
||||
fdbg("ERROR: Failed to fill the read-ahead buffer: %d\n", ret);
|
||||
@@ -853,10 +852,10 @@ int rwb_read(FAR struct rwbuffer_s *rwb, off_t startblock, uint32_t nblocks,
|
||||
int rwb_write(FAR struct rwbuffer_s *rwb, off_t startblock,
|
||||
size_t nblocks, FAR const uint8_t *wrbuffer)
|
||||
{
|
||||
int ret;
|
||||
int ret = OK;
|
||||
|
||||
#ifdef CONFIG_DRVR_READAHEAD
|
||||
if (rhmaxblocks > 0)
|
||||
if (rwb->rhmaxblocks > 0)
|
||||
{
|
||||
/* If the new write data overlaps any part of the read buffer, then
|
||||
* flush the data from the read buffer. We could attempt some more
|
||||
@@ -891,7 +890,7 @@ int rwb_write(FAR struct rwbuffer_s *rwb, off_t startblock,
|
||||
|
||||
/* Then transfer the data directly to the media */
|
||||
|
||||
ret = rwb->wrflush(rwb->dev, startblock, nblocks, wrbuffer);
|
||||
ret = rwb->wrflush(rwb->dev, wrbuffer, startblock, nblocks);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -912,7 +911,7 @@ int rwb_write(FAR struct rwbuffer_s *rwb, off_t startblock,
|
||||
* flush callback.
|
||||
*/
|
||||
|
||||
ret = rwb->wrflush(rwb->dev, startblock, nblocks, wrbuffer);
|
||||
ret = rwb->wrflush(rwb->dev, wrbuffer, startblock, nblocks);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user