From 0ce61456e7e976022b9d56050e2ab79e611bb1f5 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Wed, 5 Mar 2014 14:25:49 -0600 Subject: Add configuration ettings for the on-demand paging option --- nuttx/arch/Kconfig | 128 +++++++++++++++++++++++++++++++++ nuttx/arch/arm/Kconfig | 8 --- nuttx/configs/ea3131/Kconfig | 28 +++++++- nuttx/configs/ea3131/src/up_fillpage.c | 56 +++++++-------- nuttx/configs/ea3152/Kconfig | 28 +++++++- nuttx/configs/ea3152/src/up_fillpage.c | 56 +++++++-------- nuttx/include/nuttx/page.h | 8 +-- nuttx/tools/cfgdefine.c | 1 + 8 files changed, 243 insertions(+), 70 deletions(-) diff --git a/nuttx/arch/Kconfig b/nuttx/arch/Kconfig index e36975355..54acc2aa7 100644 --- a/nuttx/arch/Kconfig +++ b/nuttx/arch/Kconfig @@ -145,6 +145,134 @@ config ARCH_NAND_HWECC bool default n +menuconfig PAGING + bool "On-demand paging" + default n + depends on ARCH_HAVE_MMU && !ARCH_ROMPGTABLE + ---help--- + If set =y in your configation file, this setting will enable the on-demand + paging feature as described in http://www.nuttx.org/NuttXDemandPaging.html. + +if PAGING + +config PAGING_PAGESIZE + int "Page size (bytes)" + default 4096 + ---help--- + The size of one managed page. This must be a value supported by the + processor's memory management unit + +config PAGING_NLOCKED + int "Number of locked pages" + default 48 + ---help--- + This is the number of locked pages in the memory map. + +config PAGING_CUSTOM_BASE + bool "Custom paging base address" + default n + ---help--- + By default, the page begins at RAM_START/VSTART. That base address + can be changed if this value is selected. + +if PAGING_CUSTOM_BASE + +config PAGING_LOCKED_PBASE + hex "Physical base address" + +config PAGING_LOCKED_VBASE + hex "Virtual base address" + +endif # PAGING_CUSTOM_BASE + +config PAGING_NPPAGED + int "Number of physical pages" + default 256 + ---help--- + This is the number of physical pages available to support the paged + text region. + +config PAGING_NVPAGED + int "Number of virtual pages" + default 1024 + ---help--- + This actual size of the virtual paged text region (in pages). This + is also the number of virtual pages required to span the entire + paged region. The on-demand paging feature is intended to support + only the case where the virtual paged text area is much larger the + available physical pages. Otherwise, why would you enable on-demand paging? + +config PAGING_NDATA + int "Number of data pages" + default 256 + ---help--- + This is the number of data pages in the memory map. The data region + will extend to the end of RAM unless overridden by a setting in the + configuration file. + + NOTE: In some architectures, it may be necessary to take some memory + from the end of RAM for page tables or other system usage. The + configuration settings and linker directives must be cognizant of + that: PAGING_NDATA should be defined to prevent the data region from + extending all the way to the end of memory. + +config PAGING_DEFPRIO + int "Page fill worker thread priority" + default 100 + ---help--- + The default, minimum priority of the page fill worker thread. The + priority of the page fill work thread will be boosted boosted + dynamically so that it matches the priority of the task on behalf + of which it performs the fill. This defines the minimum priority + that will be used. Default: 100. + +config PAGING_STACKSIZE + int "Page fill worker thread stack size" + default 1024 + ---help--- + Defines the size of the allocated stack for the page fill worker + thread. Default: 1024. + +config PAGING_BLOCKINGFILL + bool "Blocking fill" + default n + ---help--- + The architecture specific up_fillpage() function may be blocking + or non-blocking. If defined, this setting indicates that the + up_fillpage() implementation will block until the transfer is + completed. Default: Undefined (non-blocking). + +config PAGING_WORKPERIOD + int "Work period (usec)" + default 500000 + ---help--- + The page fill worker thread will wake periodically even if there + is no mapping to do. This selection controls that wake-up period + (in microseconds). This wake-up a failsafe that will handle any + cases where a single is lost (that would really be a bug and + shouldn't happen!) and also supports timeouts for case of non- + blocking, asynchronous fills (see CONFIG_PAGING_TIMEOUT_TICKS). + +config PAGING_TIMEOUT + bool "Paging timeout" + default n + ---help--- + If defined, the implementation will monitor the (asynchronous) page + fill logic. If the fill takes longer than than a timeout value, + then a fatal error will be declared. Default: No timeouts monitored + +config PAGING_TIMEOUT_TICKS + int "Paging timeout ticks" + default 10 + depends on PAGING_TIMEOUT + ---help--- + If PAGING_TIMEOUT is defined, then implementation will monitor the + (asynchronous) page fill logic. If the fill takes longer than this + number if microseconds, then a fatal error will be declared. + Default: No timeouts monitored + +endif # PAGING + config ARCH_IRQPRIO bool "Prioritized interrupt support" default n diff --git a/nuttx/arch/arm/Kconfig b/nuttx/arch/arm/Kconfig index b991a348c..3678e5c63 100644 --- a/nuttx/arch/arm/Kconfig +++ b/nuttx/arch/arm/Kconfig @@ -306,14 +306,6 @@ config ARCH_ROMPGTABLE ---help--- Support a fixed memory mapping use a (read-only) page table in ROM/FLASH. -config PAGING - bool "On-demand paging" - default n - depends on ARCH_HAVE_MMU && !ARCH_ROMPGTABLE - ---help--- - If set =y in your configation file, this setting will enable the on-demand - paging feature as described in http://www.nuttx.org/NuttXDemandPaging.html. - config DEBUG_HARDFAULT bool "Verbose Hard-Fault Debug" default n diff --git a/nuttx/configs/ea3131/Kconfig b/nuttx/configs/ea3131/Kconfig index ee64802dd..6db78472b 100644 --- a/nuttx/configs/ea3131/Kconfig +++ b/nuttx/configs/ea3131/Kconfig @@ -4,4 +4,30 @@ # if ARCH_BOARD_EA3131 -endif + +if PAGING + +config EA3131_PAGING_MINOR + int "Page device minor number" + default 0 + +config EA3131_PAGING_MOUNTPT + string "Page device mount point" + default "/mnt/pgsrc" + +config EA3131_PAGING_BINOFFSET + int "Volume offset" + default 0 + +config EA3131_PAGING_SDSLOT + int "SD page device slot number" + default 0 + depends on MMCSD + +config EA3131_PAGING_SPIPORT + int "SD SPI port number" + default 0 + depends on SPI + +endif # PAGING +endif # ARCH_BOARD_EA3131 diff --git a/nuttx/configs/ea3131/src/up_fillpage.c b/nuttx/configs/ea3131/src/up_fillpage.c index 35ba20656..43660ad18 100644 --- a/nuttx/configs/ea3131/src/up_fillpage.c +++ b/nuttx/configs/ea3131/src/up_fillpage.c @@ -53,7 +53,7 @@ # include # include # include -# ifdef CONFIG_PAGING_SDSLOT +# ifdef CONFIG_EA3131_PAGING_SDSLOT # include # include # include @@ -80,14 +80,14 @@ #ifdef CONFIG_ARCH_BOARD_EA3131 # define HAVE_SD 1 # define HAVE_SPINOR 1 -# if defined(CONFIG_PAGING_SDSLOT) && CONFIG_PAGING_SDSLOT != 0 +# if defined(CONFIG_EA3131_PAGING_SDSLOT) && CONFIG_EA3131_PAGING_SDSLOT != 0 # error "Only one SD slot" -# undef CONFIG_PAGING_SDSLOT +# undef CONFIG_EA3131_PAGING_SDSLOT # endif #else /* Add configuration for new LPC31XX boards here */ # error "Unrecognized LPC31XX board" -# undef CONFIG_PAGING_SDSLOT +# undef CONFIG_EA3131_PAGING_SDSLOT # undef HAVE_SD # undef HAVE_SPINOR #endif @@ -113,9 +113,9 @@ /* Can't support SD if the board does not support SD (duh) */ -# if defined(CONFIG_PAGING_SDSLOT) && !defined(HAVE_SD) +# if defined(CONFIG_EA3131_PAGING_SDSLOT) && !defined(HAVE_SD) # error "This board does not support SD" -# undef CONFIG_PAGING_SDSLOT +# undef CONFIG_EA3131_PAGING_SDSLOT # endif /* Can't support SD if mountpoints are disabled or if SDIO support @@ -123,25 +123,25 @@ */ # if defined(CONFIG_DISABLE_MOUNTPOINT) || !defined(CONFIG_LPC31_MCI) -# ifdef CONFIG_PAGING_SDSLOT +# ifdef CONFIG_EA3131_PAGING_SDSLOT # error "Mountpoints and/or MCI disabled" # endif -# undef CONFIG_PAGING_SDSLOT +# undef CONFIG_EA3131_PAGING_SDSLOT # undef HAVE_SD # endif /* A mountpoint for the FAT file system must be provided */ -# if !defined(CONFIG_PAGING_MOUNTPT) && defined(CONFIG_PAGING_SDSLOT) -# error "No CONFIG_PAGING_MOUNTPT provided" -# undef CONFIG_PAGING_SDSLOT +# if !defined(CONFIG_EA3131_PAGING_MOUNTPT) && defined(CONFIG_EA3131_PAGING_SDSLOT) +# error "No CONFIG_EA3131_PAGING_MOUNTPT provided" +# undef CONFIG_EA3131_PAGING_SDSLOT # undef HAVE_SD # endif /* If no minor number is provided, default to zero */ -# ifndef CONFIG_PAGING_MINOR -# define CONFIG_PAGING_MINOR 0 +# ifndef CONFIG_EA3131_PAGING_MINOR +# define CONFIG_EA3131_PAGING_MINOR 0 # endif #endif /* CONFIG_PAGING_BINPATH */ @@ -160,14 +160,14 @@ * of the NuttX binary image. */ -# ifndef CONFIG_PAGING_BINOFFSET -# define CONFIG_PAGING_BINOFFSET 0 +# ifndef CONFIG_EA3131_PAGING_BINOFFSET +# define CONFIG_EA3131_PAGING_BINOFFSET 0 # endif /* Make sure that some value is defined for the SPI port number */ -# ifndef CONFIG_PAGING_SPIPORT -# define CONFIG_PAGING_SPIPORT 0 +# ifndef CONFIG_EA3131_PAGING_SPIPORT +# define CONFIG_EA3131_PAGING_SPIPORT 0 # endif #endif @@ -232,7 +232,7 @@ static struct pg_source_s g_pgsrc; #if defined(CONFIG_PAGING_BINPATH) static inline void lpc31_initsrc(void) { -#ifdef CONFIG_PAGING_SDSLOT +#ifdef CONFIG_EA3131_PAGING_SDSLOT FAR struct sdio_dev_s *sdio; int ret; #endif @@ -241,7 +241,7 @@ static inline void lpc31_initsrc(void) if (!g_pgsrc.initialized) { -#ifdef CONFIG_PAGING_SDSLOT +#ifdef CONFIG_EA3131_PAGING_SDSLOT char devname[16]; #endif @@ -249,16 +249,16 @@ static inline void lpc31_initsrc(void) /* No, do we need to mount an SD device? */ -#ifdef CONFIG_PAGING_SDSLOT +#ifdef CONFIG_EA3131_PAGING_SDSLOT /* Yes.. First, get an instance of the SDIO interface */ - sdio = sdio_initialize(CONFIG_PAGING_SDSLOT); + sdio = sdio_initialize(CONFIG_EA3131_PAGING_SDSLOT); DEBUGASSERT(sdio != NULL); /* Then bind the SDIO interface to the SD driver */ - ret = mmcsd_slotinitialize(CONFIG_PAGING_MINOR, sdio); + ret = mmcsd_slotinitialize(CONFIG_EA3131_PAGING_MINOR, sdio); DEBUGASSERT(ret == OK); /* Then let's guess and say that there is a card in the slot. @@ -269,11 +269,11 @@ static inline void lpc31_initsrc(void) /* Now mount the file system */ - snprintf(devname, 16, "/dev/mmcsd%d", CONFIG_PAGING_MINOR); - ret = mount(devname, CONFIG_PAGING_MOUNTPT, "vfat", MS_RDONLY, NULL); + snprintf(devname, 16, "/dev/mmcsd%d", CONFIG_EA3131_PAGING_MINOR); + ret = mount(devname, CONFIG_EA3131_PAGING_MOUNTPT, "vfat", MS_RDONLY, NULL); DEBUGASSERT(ret == OK); -#endif /* CONFIG_PAGING_SDSLOT */ +#endif /* CONFIG_EA3131_PAGING_SDSLOT */ /* Open the selected path for read-only access */ @@ -305,7 +305,7 @@ static inline void lpc31_initsrc(void) /* First get an instance of the SPI device interface */ - spi = up_spiinitialize(CONFIG_PAGING_SPIPORT); + spi = up_spiinitialize(CONFIG_EA3131_PAGING_SPIPORT); DEBUGASSERT(spi != NULL); /* Then bind the SPI interface to the MTD driver */ @@ -329,7 +329,7 @@ static inline void lpc31_initsrc(void) DEBUGASSERT(ret >= 0); capacity = g_pgsrc.geo.erasesize*g_pgsrc.geo.neraseblocks; pgllvdbg("capacity: %d\n", capacity); - DEBUGASSERT(capacity >= (CONFIG_PAGING_BINOFFSET + PG_TEXT_VSIZE)); + DEBUGASSERT(capacity >= (CONFIG_EA3131_PAGING_BINOFFSET + PG_TEXT_VSIZE)); #endif /* We are now initialized */ @@ -454,7 +454,7 @@ int up_fillpage(FAR struct tcb_s *tcb, FAR void *vpage) * virtual address. File offset 0 corresponds to PG_LOCKED_VBASE. */ - offset = (off_t)tcb->xcp.far - PG_LOCKED_VBASE + CONFIG_PAGING_BINOFFSET; + offset = (off_t)tcb->xcp.far - PG_LOCKED_VBASE + CONFIG_EA3131_PAGING_BINOFFSET; /* Read the page at the correct offset into the SPI FLASH device */ diff --git a/nuttx/configs/ea3152/Kconfig b/nuttx/configs/ea3152/Kconfig index c23751a3d..38108f924 100644 --- a/nuttx/configs/ea3152/Kconfig +++ b/nuttx/configs/ea3152/Kconfig @@ -4,4 +4,30 @@ # if ARCH_BOARD_EA3152 -endif + +if PAGING + +config EA3152_PAGING_MINOR + int "Page device minor number" + default 0 + +config EA3152_PAGING_MOUNTPT + string "Page device mount point" + default "/mnt/pgsrc" + +config EA3152_PAGING_BINOFFSET + int "Volume offset" + default 0 + +config EA3152_PAGING_SDSLOT + int "SD page device slot number" + default 0 + depends on MMCSD + +config EA3152_PAGING_SPIPORT + int "SD SPI port number" + default 0 + depends on SPI + +endif # PAGING +endif # ARCH_BOARD_EA3152 diff --git a/nuttx/configs/ea3152/src/up_fillpage.c b/nuttx/configs/ea3152/src/up_fillpage.c index 3b9f02a88..23a19b849 100644 --- a/nuttx/configs/ea3152/src/up_fillpage.c +++ b/nuttx/configs/ea3152/src/up_fillpage.c @@ -53,7 +53,7 @@ # include # include # include -# ifdef CONFIG_PAGING_SDSLOT +# ifdef CONFIG_EA3152_PAGING_SDSLOT # include # include # include @@ -80,14 +80,14 @@ #ifdef CONFIG_ARCH_BOARD_EA3152 # define HAVE_SD 1 # define HAVE_SPINOR 1 -# if defined(CONFIG_PAGING_SDSLOT) && CONFIG_PAGING_SDSLOT != 0 +# if defined(CONFIG_EA3152_PAGING_SDSLOT) && CONFIG_EA3152_PAGING_SDSLOT != 0 # error "Only one SD slot" -# undef CONFIG_PAGING_SDSLOT +# undef CONFIG_EA3152_PAGING_SDSLOT # endif #else /* Add configuration for new LPC31XX boards here */ # error "Unrecognized LPC31XX board" -# undef CONFIG_PAGING_SDSLOT +# undef CONFIG_EA3152_PAGING_SDSLOT # undef HAVE_SD # undef HAVE_SPINOR #endif @@ -113,9 +113,9 @@ /* Can't support SD if the board does not support SD (duh) */ -# if defined(CONFIG_PAGING_SDSLOT) && !defined(HAVE_SD) +# if defined(CONFIG_EA3152_PAGING_SDSLOT) && !defined(HAVE_SD) # error "This board does not support SD" -# undef CONFIG_PAGING_SDSLOT +# undef CONFIG_EA3152_PAGING_SDSLOT # endif /* Can't support SD if mountpoints are disabled or if SDIO support @@ -123,25 +123,25 @@ */ # if defined(CONFIG_DISABLE_MOUNTPOINT) || !defined(CONFIG_LPC31_MCI) -# ifdef CONFIG_PAGING_SDSLOT +# ifdef CONFIG_EA3152_PAGING_SDSLOT # error "Mountpoints and/or MCI disabled" # endif -# undef CONFIG_PAGING_SDSLOT +# undef CONFIG_EA3152_PAGING_SDSLOT # undef HAVE_SD # endif /* A mountpoint for the FAT file system must be provided */ -# if !defined(CONFIG_PAGING_MOUNTPT) && defined(CONFIG_PAGING_SDSLOT) -# error "No CONFIG_PAGING_MOUNTPT provided" -# undef CONFIG_PAGING_SDSLOT +# if !defined(CONFIG_EA3152_PAGING_MOUNTPT) && defined(CONFIG_EA3152_PAGING_SDSLOT) +# error "No CONFIG_EA3152_PAGING_MOUNTPT provided" +# undef CONFIG_EA3152_PAGING_SDSLOT # undef HAVE_SD # endif /* If no minor number is provided, default to zero */ -# ifndef CONFIG_PAGING_MINOR -# define CONFIG_PAGING_MINOR 0 +# ifndef CONFIG_EA3152_PAGING_MINOR +# define CONFIG_EA3152_PAGING_MINOR 0 # endif #endif /* CONFIG_PAGING_BINPATH */ @@ -160,14 +160,14 @@ * of the NuttX binary image. */ -# ifndef CONFIG_PAGING_BINOFFSET -# define CONFIG_PAGING_BINOFFSET 0 +# ifndef CONFIG_EA3152_PAGING_BINOFFSET +# define CONFIG_EA3152_PAGING_BINOFFSET 0 # endif /* Make sure that some value is defined for the SPI port number */ -# ifndef CONFIG_PAGING_SPIPORT -# define CONFIG_PAGING_SPIPORT 0 +# ifndef CONFIG_EA3152_PAGING_SPIPORT +# define CONFIG_EA3152_PAGING_SPIPORT 0 # endif #endif @@ -232,7 +232,7 @@ static struct pg_source_s g_pgsrc; #if defined(CONFIG_PAGING_BINPATH) static inline void lpc31_initsrc(void) { -#ifdef CONFIG_PAGING_SDSLOT +#ifdef CONFIG_EA3152_PAGING_SDSLOT FAR struct sdio_dev_s *sdio; int ret; #endif @@ -241,7 +241,7 @@ static inline void lpc31_initsrc(void) if (!g_pgsrc.initialized) { -#ifdef CONFIG_PAGING_SDSLOT +#ifdef CONFIG_EA3152_PAGING_SDSLOT char devname[16]; #endif @@ -249,16 +249,16 @@ static inline void lpc31_initsrc(void) /* No, do we need to mount an SD device? */ -#ifdef CONFIG_PAGING_SDSLOT +#ifdef CONFIG_EA3152_PAGING_SDSLOT /* Yes.. First, get an instance of the SDIO interface */ - sdio = sdio_initialize(CONFIG_PAGING_SDSLOT); + sdio = sdio_initialize(CONFIG_EA3152_PAGING_SDSLOT); DEBUGASSERT(sdio != NULL); /* Then bind the SDIO interface to the SD driver */ - ret = mmcsd_slotinitialize(CONFIG_PAGING_MINOR, sdio); + ret = mmcsd_slotinitialize(CONFIG_EA3152_PAGING_MINOR, sdio); DEBUGASSERT(ret == OK); /* Then let's guess and say that there is a card in the slot. @@ -269,11 +269,11 @@ static inline void lpc31_initsrc(void) /* Now mount the file system */ - snprintf(devname, 16, "/dev/mmcsd%d", CONFIG_PAGING_MINOR); - ret = mount(devname, CONFIG_PAGING_MOUNTPT, "vfat", MS_RDONLY, NULL); + snprintf(devname, 16, "/dev/mmcsd%d", CONFIG_EA3152_PAGING_MINOR); + ret = mount(devname, CONFIG_EA3152_PAGING_MOUNTPT, "vfat", MS_RDONLY, NULL); DEBUGASSERT(ret == OK); -#endif /* CONFIG_PAGING_SDSLOT */ +#endif /* CONFIG_EA3152_PAGING_SDSLOT */ /* Open the selected path for read-only access */ @@ -305,7 +305,7 @@ static inline void lpc31_initsrc(void) /* First get an instance of the SPI device interface */ - spi = up_spiinitialize(CONFIG_PAGING_SPIPORT); + spi = up_spiinitialize(CONFIG_EA3152_PAGING_SPIPORT); DEBUGASSERT(spi != NULL); /* Then bind the SPI interface to the MTD driver */ @@ -329,7 +329,7 @@ static inline void lpc31_initsrc(void) DEBUGASSERT(ret >= 0); capacity = g_pgsrc.geo.erasesize*g_pgsrc.geo.neraseblocks; pgllvdbg("capacity: %d\n", capacity); - DEBUGASSERT(capacity >= (CONFIG_PAGING_BINOFFSET + PG_TEXT_VSIZE)); + DEBUGASSERT(capacity >= (CONFIG_EA3152_PAGING_BINOFFSET + PG_TEXT_VSIZE)); #endif /* We are now initialized */ @@ -454,7 +454,7 @@ int up_fillpage(FAR struct tcb_s *tcb, FAR void *vpage) * virtual address. File offset 0 corresponds to PG_LOCKED_VBASE. */ - offset = (off_t)tcb->xcp.far - PG_LOCKED_VBASE + CONFIG_PAGING_BINOFFSET; + offset = (off_t)tcb->xcp.far - PG_LOCKED_VBASE + CONFIG_EA3152_PAGING_BINOFFSET; /* Read the page at the correct offset into the SPI FLASH device */ diff --git a/nuttx/include/nuttx/page.h b/nuttx/include/nuttx/page.h index b0366a130..4d2353a60 100644 --- a/nuttx/include/nuttx/page.h +++ b/nuttx/include/nuttx/page.h @@ -118,8 +118,8 @@ /* CONFIG_PAGING_NPPAGED - This is the number of physical pages available to * support the paged text region. - * CONFIG_PAGING_NVPAGED - This actual size of the paged text region (in - * pages). This is also the number of virtual pages required to support + * CONFIG_PAGING_NVPAGED - This actual size of the virtual paged text region (in + * pages). This is also the number of virtual pages required to span * the entire paged region. The on-demand paging feature is intended to * support only the case where the virtual paged text area is much larger * the available physical pages. Otherwise, why would you enable on-demand @@ -202,8 +202,8 @@ /* CONFIG_PAGING_DEFPRIO - The default, minimum priority of the page fill * worker thread. The priority of the page fill work thread will be boosted - * boosted dynmically so that it matches the priority of the task on behalf - * of which it peforms the fill. This defines the minimum priority that + * boosted dynamically so that it matches the priority of the task on behalf + * of which it performs the fill. This defines the minimum priority that * will be used. Default: 50. * CONFIG_PAGING_STACKSIZE - Defines the size of the allocated stack * for the page fill worker thread. Default: 1024. diff --git a/nuttx/tools/cfgdefine.c b/nuttx/tools/cfgdefine.c index 9dbd0262b..e25301aca 100644 --- a/nuttx/tools/cfgdefine.c +++ b/nuttx/tools/cfgdefine.c @@ -67,6 +67,7 @@ static const char *dequote_list[] = "CONFIG_EXECFUNCS_SYMTAB", /* Symbol table used by exec[l|v] */ "CONFIG_PASS1_BUILDIR", /* Pass1 build directory */ "CONFIG_PASS1_TARGET", /* Pass1 build target */ + "CONFIG_PASS1_OBJECT", /* Pass1 build object */ "CONFIG_DEBUG_OPTLEVEL", /* Custom debug level */ /* NxWidgets/NxWM */ -- cgit v1.2.3