Add logic to build the demo world as a ROMFS file system
This commit is contained in:
parent
5b6a6eff83
commit
8143701d47
2
graphics/traveler/.gitignore
vendored
2
graphics/traveler/.gitignore
vendored
@ -1,6 +1,8 @@
|
||||
/Make.dep
|
||||
/.depend
|
||||
/.built
|
||||
/trv_romfs.h
|
||||
/trv_romfs.img
|
||||
/*.asm
|
||||
/*.rel
|
||||
/*.lst
|
||||
|
@ -62,10 +62,25 @@ config GRAPHICS_TRAVELER_JOYDEV
|
||||
|
||||
comment "Debug options"
|
||||
|
||||
config GRAPHICS_TRAVELER_ROMFSDEMO
|
||||
bool "Build ROMFS demo world"
|
||||
default y
|
||||
depends on FS_ROMFS
|
||||
---help---
|
||||
The traveller code will do nothing unless you also provide a world
|
||||
data set for it to work on. The world/ sub-directory contains a
|
||||
demo world suitable for testing. If this option is selected, then
|
||||
the demo world is build as a mountable ROMFS file system. This new
|
||||
function is then exported that can be used to mount the demo world:
|
||||
|
||||
int trv_mount_world(int minor, FAR const char *mountpoint)
|
||||
|
||||
This function must be called somewhere in your board-specific start-
|
||||
up logic in order to mount the world at 'mountpoint'
|
||||
|
||||
config GRAPHICS_TRAVELER_PERFMON
|
||||
bool "Performance monitor"
|
||||
default y
|
||||
depends on FS_READABLE
|
||||
---help---
|
||||
Enable or disable performance monitoring instrumentation and output.
|
||||
|
||||
|
@ -37,6 +37,13 @@
|
||||
-include $(TOPDIR)/Make.defs
|
||||
include $(APPDIR)/Make.defs
|
||||
|
||||
# Directories
|
||||
|
||||
TRAVELER_DIR = $(APPDIR)/graphics/traveler
|
||||
TRAVELER_SRC = $(TRAVELER_DIR)/src
|
||||
TRAVELER_INC = $(TRAVELER_DIR)/include
|
||||
TRAVELER_DEMO = $(TRAVELER_DIR)/world
|
||||
|
||||
# Traveler built-in application info
|
||||
|
||||
APPNAME = traveler
|
||||
@ -52,6 +59,11 @@ CSRCS += trv_mem.c trv_paltbl.c trv_pcx.c trv_planefiles.c trv_planelists.c
|
||||
CSRCS += trv_pov.c trv_rayavoid.c trv_raycast.c trv_raycntl.c
|
||||
CSRCS += trv_rayprune.c trv_rayrend.c trv_texturefile.c trv_trigtbl.c
|
||||
CSRCS += trv_world.c
|
||||
|
||||
ifeq ($(CONFIG_GRAPHICS_TRAVELER_ROMFSDEMO),y)
|
||||
CSRCS += trv_romfs.c
|
||||
endif
|
||||
|
||||
MAINSRC = trv_main.c
|
||||
|
||||
ifeq ($(CONFIG_NX),y)
|
||||
@ -72,6 +84,11 @@ ifneq ($(CONFIG_BUILD_KERNEL),y)
|
||||
OBJS += $(MAINOBJ)
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_GRAPHICS_TRAVELER_ROMFSDEMO),y)
|
||||
ROMFS_IMG = trv_romfs.img
|
||||
ROMFS_HDR = trv_romfs.h
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_WINDOWS_NATIVE),y)
|
||||
BIN = ..\..\libapps$(LIBEXT)
|
||||
else
|
||||
@ -95,10 +112,10 @@ ifeq ($(WINTOOL),y)
|
||||
INCDIROPT = -w
|
||||
endif
|
||||
|
||||
CFLAGS += ${shell $(INCDIR) $(INCDIROPT) "$(CC)" $(APPDIR)/graphics/traveler/include}
|
||||
CFLAGS += ${shell $(INCDIR) $(INCDIROPT) "$(CC)" $(TRAVELER_INC)}
|
||||
|
||||
DEPPATH = --dep-path src
|
||||
VPATH = src
|
||||
DEPPATH = --dep-path . --dep-path src
|
||||
VPATH = .:src
|
||||
|
||||
# Common build
|
||||
|
||||
@ -111,7 +128,15 @@ $(AOBJS): %$(OBJEXT): %.S
|
||||
$(COBJS) $(MAINOBJ): %$(OBJEXT): %.c
|
||||
$(call COMPILE, $<, $@)
|
||||
|
||||
.built: $(OBJS)
|
||||
ifeq ($(CONFIG_GRAPHICS_TRAVELER_ROMFSDEMO),y)
|
||||
$(ROMFS_IMG):
|
||||
$(Q) genromfs -f $@ -d $(TRAVELER_DEMO) -V "DemoWorld"
|
||||
|
||||
$(ROMFS_HDR): $(ROMFS_IMG)
|
||||
$(Q) (xxd -i $< | sed -e "s/^unsigned/static const unsigned/g" >$@)
|
||||
endif
|
||||
|
||||
.built: $(ROMFS_HDR) $(OBJS)
|
||||
$(call ARCHIVE, $(BIN), $(OBJS))
|
||||
@touch .built
|
||||
|
||||
@ -145,6 +170,8 @@ depend: .depend
|
||||
|
||||
clean:
|
||||
$(call DELFILE, .built)
|
||||
$(call DELFILE, $(ROMFS_IMG))
|
||||
$(call DELFILE, $(ROMFS_HDR))
|
||||
$(call CLEAN)
|
||||
|
||||
distclean: clean
|
||||
|
106
graphics/traveler/trv_romfs.c
Normal file
106
graphics/traveler/trv_romfs.c
Normal file
@ -0,0 +1,106 @@
|
||||
/****************************************************************************
|
||||
* apps/graphics/traveler/trv_romfs.c
|
||||
* Mount the ROMFS demo world
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#ifdef CONFIG_GRAPHICS_TRAVELER_ROMFSDEMO
|
||||
|
||||
#include <sys/mount.h>
|
||||
#include <sys/types.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include <nuttx/fs/ramdisk.h>
|
||||
|
||||
#include "trv_romfs.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef CONFIG_FS_ROMFS
|
||||
# error You must select CONFIG_FS_ROMFS in your configuration file
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_DISABLE_MOUNTPOINT
|
||||
# error You must not disable mountpoints via CONFIG_DISABLE_MOUNTPOINT
|
||||
#endif
|
||||
|
||||
/* Describe the ROMFS file system */
|
||||
|
||||
#define SECTORSIZE 512
|
||||
#define NSECTORS(b) (((b)+SECTORSIZE-1)/SECTORSIZE)
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: trv_mount_world
|
||||
*
|
||||
* Description:
|
||||
* Mount the demo world as a ROMFS file system mounted at 'mountpoint'
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int trv_mount_world(int minor, FAR const char *mountpoint)
|
||||
{
|
||||
char devpath[16];
|
||||
int ret;
|
||||
|
||||
/* Create a ROM disk for the ROMFS filesystem */
|
||||
|
||||
ret = romdisk_register(minor, (FAR uint8_t *)trv_romfs_img,
|
||||
NSECTORS(trv_romfs_img_len), SECTORSIZE);
|
||||
if (ret < 0)
|
||||
{
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Get the ROM disk device name */
|
||||
|
||||
snprintf(devpath, 16, "/dev/ram%d", minor);
|
||||
|
||||
/* Mount the file system */
|
||||
|
||||
ret = mount(devpath, mountpoint, "romfs", MS_RDONLY, NULL);
|
||||
return ret;
|
||||
}
|
||||
|
||||
#endif /* CONFIG_GRAPHICS_TRAVELER_ROMFSDEMO */
|
Loading…
x
Reference in New Issue
Block a user