Add paging debug instrumentation

git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@2899 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
patacongo 2010-08-31 02:21:12 +00:00
parent 0cdc73b974
commit cd4dd3b038
11 changed files with 103 additions and 33 deletions

View File

@ -1247,3 +1247,6 @@
- Replace any occurrences of lib$(CONFIG_EXAMPLE)$(LIBEXT)
with libapp$(LIBEXT) in your Makefiles.
- Check any other occurrences of CONFIG_EXAMPLE.
* arch/arm/src/lpc313x/lpc313x_spi.c - Fix compilation error when
when CONFIG_DEBUG is enabled.

View File

@ -8,7 +8,7 @@
<tr align="center" bgcolor="#e4e4e4">
<td>
<h1><big><font color="#3c34ec"><i>NuttX RTOS</i></font></big></h1>
<p>Last Updated: August 28, 2010</p>
<p>Last Updated: August 30, 2010</p>
</td>
</tr>
</table>
@ -1864,7 +1864,7 @@ nuttx-5.9 2010-08-25 Gregory Nutt &lt;spudmonkey@racsa.co.cr&gt;
* configs/ntosd-dm320 and arch/arm/src/dm320 - Add support for the
Neuros production OSD (changes contributed by bf.nuttx).
pascal-2.0 2010-12-21 Gregory Nutt &lt;spudmonkey@racsa.co.cr&gt;
pascal-2.0 2009-12-21 Gregory Nutt &lt;spudmonkey@racsa.co.cr&gt;
* Updated to use standard C99 types in stdint.h and
stdbool.h. This change was necessary for compatibility
@ -1920,7 +1920,18 @@ nuttx-5.10 2010-xx-xx Gregory Nutt &lt;spudmonkey@racsa.co.cr&gt;
with libapp$(LIBEXT) in your Makefiles.
- Check any other occurrences of CONFIG_EXAMPLE.pascal-2.1 2010-xx-xx Gregory Nutt &lt;spudmonkey@racsa.co.cr&gt;
* arch/arm/src/lpc313x/lpc313x_spi.c - Fix compilation error when
when CONFIG_DEBUG is enabled.
pascal-2.1 2010-xx-xx Gregory Nutt &lt;spudmonkey@racsa.co.cr&gt;
buildroot-1.9 2010-xx-xx <spudmonkey@racsa.co.cr>
* configs/arm926t-defconfig-4.3.3: update arm926t-defconfig-4.2.4
* configs/arm926t-defconfig-nxflat: NXFLAT-only configuration for
arm926
* toolchain/gdb/gdb.mk - Remove ncurses dependency from gdb_target target.
</pre></ul>
<table width ="100%">

View File

@ -123,6 +123,7 @@ void up_dataabort(uint32_t *regs, uint32_t far, uint32_t fsr)
* fatal error.
*/
pglldbg("FSR: %08x FAR: %08x\n", fsr, far);
if ((fsr & FSR_MASK) != FSR_PAGE)
{
goto segfault;
@ -133,6 +134,7 @@ void up_dataabort(uint32_t *regs, uint32_t far, uint32_t fsr)
* (It has not yet been saved in the register context save area).
*/
pgllvdbg("VBASE: %08x VEND: %08x\n", PG_PAGED_VBASE, PG_PAGED_VEND);
if (far < PG_PAGED_VBASE || far >= PG_PAGED_VEND)
{
goto segfault;
@ -162,7 +164,7 @@ void up_dataabort(uint32_t *regs, uint32_t far, uint32_t fsr)
return;
segfault:
lldbg("Data abort at PC: %x FAR: %08x FSR: %08x\n", regs[REG_PC], far, fsr);
lldbg("Data abort. PC: %08x FAR: %08x FSR: %08x\n", regs[REG_PC], far, fsr);
PANIC(OSERR_ERREXCEPTION);
}
@ -178,7 +180,7 @@ void up_dataabort(uint32_t *regs)
/* Crash -- possibly showing diagnost debug information. */
lldbg("Data abort at %08x\n", regs[REG_PC]);
lldbg("Data abort. PC: %08x\n", regs[REG_PC]);
PANIC(OSERR_ERREXCEPTION);
}

View File

@ -105,6 +105,9 @@ void up_prefetchabort(uint32_t *regs)
* virtual addresses.
*/
pglldbg("VADDR: %08x VBASE: %08x VEND: %08x\n",
regs[REG_PC], PG_PAGED_VBASE, PG_PAGED_VEND);
if (regs[REG_R15] >= PG_PAGED_VBASE && regs[REG_R15] < PG_PAGED_VEND)
{
/* Save the offending PC as the fault address in the TCB of the currently
@ -133,7 +136,7 @@ void up_prefetchabort(uint32_t *regs)
else
#endif
{
lldbg("Prefetch abort at %08x\n", regs[REG_PC]);
lldbg("Prefetch abort. PC: %08x\n", regs[REG_PC]);
PANIC(OSERR_ERREXCEPTION);
}
}

View File

@ -1,7 +1,7 @@
/************************************************************************************
* arm/arm/src/lpc313x/lpc313x_spi.c
*
* Copyright (C) 2009 Gregory Nutt. All rights reserved.
* Copyright (C) 2009-2010 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
*
* Redistribution and use in source and binary forms, with or without
@ -568,8 +568,7 @@ static uint8_t spi_status(FAR struct spi_dev_s *dev, enum spi_dev_e devid)
static uint16_t spi_send(FAR struct spi_dev_s *dev, uint16_t wd)
{
FAR struct lpc313x_spidev_s *priv = (FAR struct lpc313x_spidev_s *)dev;
DEBUGASSERT(priv && priv->spibase);
DEBUGASSERT(priv);
spi_writeword(priv, wd);
return spi_readword(priv);

View File

@ -301,6 +301,7 @@ CONFIG_APP_DIR=examples/nsh
CONFIG_DEBUG=n
CONFIG_DEBUG_VERBOSE=n
CONFIG_DEBUG_SYMBOLS=n
CONFIG_DEBUG_PAGING=n
CONFIG_MM_REGIONS=1
CONFIG_ARCH_LOWPUTC=y
CONFIG_RR_INTERVAL=200
@ -407,12 +408,12 @@ CONFIG_SIG_SIGWORK=4
#
CONFIG_PAGING=y
CONFIG_PAGING_PAGESIZE=1024
CONFIG_PAGING_NLOCKED=36
CONFIG_PAGING_NLOCKED=48
#CONFIG_PAGING_LOCKED_PBASE
#CONFIG_PAGING_LOCKED_VBASE
CONFIG_PAGING_NPPAGED=96
CONFIG_PAGING_NVPAGED=384
CONFIG_PAGING_NDATA=44
CONFIG_PAGING_NDATA=32
#CONFIG_PAGING_DEFPRIO
CONFIG_PAGING_STACKSIZE=2048
CONFIG_PAGING_BLOCKINGFILL=y

View File

@ -42,20 +42,35 @@
* address space: 0x1102 8000. The virtual space is broken up into three
* regions:
*
* locked - Pages locked in memory. Start: 0x1102 8000 Size: 36Kb
* paged - Pages in nonvolatile store. Start: 0x1103 1000 Size: 384Kb
* data - .data/.bss/heap. Start: 0x1109 1000 Size: 44Kb
* PHYSICAL VIRTUAL
* NAME DESCRIPTION SIZE START SIZE START
* -------- -------------------------- ----- ----------- ------- -----------
* locked Pages locked in memory. 48Kb 0x1102 8000 48Kb 0x1102 8000
* paged Pages in nonvolatile store. 96Kb 0x1103 4000 384Kb 0x1103 4000
* data .data/.bss/heap. 32Kb 0x1104 c000 32Kb 0x1109 4000
* Reserved for page table 16Kb 0x1105 4000 16Kb 0x1109 c000
* -------- -------------------------- ----- ----------- ------- -----------
* 192Kb 0x1105 8000 480Kb 0x110a 0000
*
* These region sizes must match the size in pages specified for each region
* in the NuttX configuration file: CONFIG_PAGING_NLOCKED, CONFIG_PAGING_NVPAGED,
* and CONFIG_PAGING_NDATA.
*
* NOTE 1: The locked region is really big here so that you can enable lots of
* debug output without overflowing the locked region. 32Kb would probably be
* plenty if this were a real, optimized application.
*
* NOTE 2: Different compilers will compile the code to different sizes. If you
* get a link time error saying that the locked region is full, you may have to
* re-organize this memory layout (here and in defconfig) to make the locked
* region even bigger.
*/
MEMORY
{
locked (rx) : ORIGIN = 0x11029080, LENGTH = 36K - 4224
paged (rx) : ORIGIN = 0x11031000, LENGTH = 384K
data (rw) : ORIGIN = 0x11091000, LENGTH = 44K
locked (rx) : ORIGIN = 0x11029080, LENGTH = 48K - 4224
paged (rx) : ORIGIN = 0x11034000, LENGTH = 384K
data (rw) : ORIGIN = 0x11094000, LENGTH = 44K
}
OUTPUT_ARCH(arm)
@ -65,18 +80,19 @@ SECTIONS
.locked : {
_slocked = ABSOLUTE(.);
*(.vectors)
locked.r (.text .text.*)
locked.r (.fixup)
locked.r (.gnu.warning)
locked.r (.rodata .rodata.*)
locked.r (.gnu.linkonce.t.*)
locked.r (.glue_7)
locked.r (.glue_7t)
locked.r (.got)
locked.r (.gcc_except_table)
locked.r (.gnu.linkonce.r.*)
up_head.o locked.r (.text .text.*)
up_head.o locked.r (.fixup)
up_head.o locked.r (.gnu.warning)
up_head.o locked.r (.rodata .rodata.*)
up_head.o locked.r (.gnu.linkonce.t.*)
up_head.o locked.r (.glue_7)
up_head.o locked.r (.glue_7t)
up_head.o locked.r (.got)
up_head.o locked.r (.gcc_except_table)
up_head.o locked.r (.gnu.linkonce.r.*)
_elocked = ABSOLUTE(.);
} >locked
_eronly = ABSOLUTE(.);
.paged : {
@ -94,8 +110,6 @@ SECTIONS
_epaged = ABSOLUTE(.);
} > paged
_eronly = ABSOLUTE(.);
.data : {
_sdata = ABSOLUTE(.);
*(.data .data.*)

View File

@ -112,12 +112,14 @@
#ifdef CONFIG_PAGING_BLOCKINGFILL
int up_fillpage(FAR _TCB *tcb, FAR void *vpage)
{
pglldbg("TCB: %p vpage: %d far: %08x\n", tcb, vpage, tcb->xcp.far);
# warning "Not implemented"
return -ENOSYS;
}
#else
int up_fillpage(FAR _TCB *tcb, FAR void *vpage, up_pgcallback_t pg_callback)
{
pglldbg("TCB: %p vpage: %d far: %08x\n", tcb, vpage, tcb->xcp.far);
# warning "Not implemented"
return -ENOSYS;
}

View File

@ -1,7 +1,7 @@
/****************************************************************************
* examples/nsh/nsh_main.c
*
* Copyright (C) 2007-2009 Gregory Nutt. All rights reserved.
* Copyright (C) 2007-2010 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
*
* Redistribution and use in source and binary forms, with or without
@ -958,10 +958,17 @@ static inline int nsh_nice(FAR struct nsh_vtbl_s *vtbl, FAR char **ppcmd, FAR ch
* Name: user_initialize
****************************************************************************/
/* In order to support user_initialize if CONFIG_PAGING is defined, this
* function (and only this function) would need to get moved to the locked
* text region.
*/
#ifndef CONFIG_PAGING
void user_initialize(void)
{
/* stub */
}
#endif
/****************************************************************************
* Name: user_start

View File

@ -39,8 +39,8 @@
#include <nuttx/config.h>
#include <debug.h>
#include <errno.h>
#include <debug.h>
#include <nuttx/arch.h>
#include <nuttx/sched.h>
@ -132,6 +132,7 @@ void pg_miss(void)
* always present in memory.
*/
pglldbg("Blocking TCB: %p PID: %d\n", ftcb, ftcb->pid);
DEBUGASSERT(g_pgworker != ftcb->pid);
/* Block the currently executing task
@ -158,6 +159,8 @@ void pg_miss(void)
{
/* Reprioritize the page fill worker thread */
pgllvdbg("New worker priority. %d->%d\n",
wtcb->sched_priority, ftcb->sched_priority);
sched_setpriority(wtcb, ftcb->sched_priority);
}
@ -168,6 +171,7 @@ void pg_miss(void)
if (!g_pftcb)
{
pglldbg("Signaling worker. PID: %d\n", g_pgworker);
kill(g_pgworker, SIGWORK);
}
}

View File

@ -160,6 +160,7 @@ static void pg_callback(FAR _TCB *tcb, int result)
{
/* Verify that g_pftcb is non-NULL */
pgllvdbg("g_pftcb: %p\n", g_pftcb);
if (g_pftcb)
{
FAR _TCB *htcb = (FAR _TCB *)g_waitingforfill.head;
@ -185,6 +186,8 @@ static void pg_callback(FAR _TCB *tcb, int result)
if (priority > wtcb->sched_priority)
{
pgllvdbg("New worker priority. %d->%d\n",
wtcb->sched_priority, priority);
sched_setpriority(wtcb, priority);
}
@ -197,9 +200,10 @@ static void pg_callback(FAR _TCB *tcb, int result)
g_fillresult = result;
}
/* Signal the page fill worker thread (in any event) */
/* Signal the page fill worker thread (in any event) */
kill(g_pgworker, SIGWORK);
pglldbg("Signaling worker. PID: %d\n", g_pgworker);
kill(g_pgworker, SIGWORK);
}
#endif
@ -246,6 +250,7 @@ static inline bool pg_dequeue(void)
/* Remove the TCB from the head of the list (if any) */
g_pftcb = (FAR _TCB *)dq_remfirst((dq_queue_t*)&g_waitingforfill);
pgllvdbg("g_pftcb: %p\n", g_pftcb);
if (g_pftcb != NULL)
{
/* Call the architecture-specific function up_checkmapping() to see if
@ -291,6 +296,8 @@ static inline bool pg_dequeue(void)
/* Reduce the priority of the page fill worker thread */
pgllvdbg("New worker priority. %d->%d\n",
wtcb->sched_priority, priority);
sched_setpriority(wtcb, priority);
}
@ -305,6 +312,7 @@ static inline bool pg_dequeue(void)
* virtual address space -- just restart it.
*/
pglldbg("Restarting TCB: %p\n", g_pftcb);
up_unblock_task(g_pftcb);
}
}
@ -360,6 +368,7 @@ static inline bool pg_startfill(void)
* a page in-use, un-map it, and make it available.
*/
pgllvdbg("Call up_allocpage(%p)\n", g_pftcb);
result = up_allocpage(g_pftcb, &vpage);
DEBUGASSERT(result == OK);
@ -376,6 +385,7 @@ static inline bool pg_startfill(void)
* status of the fill will be provided by return value from up_fillpage().
*/
pgllvdbg("Call up_fillpage(%p)\n", g_pftcb);
result = up_fillpage(g_pftcb, vpage);
DEBUGASSERT(result == OK);
#else
@ -388,6 +398,7 @@ static inline bool pg_startfill(void)
* This callback will probably from interrupt level.
*/
pgllvdbg("Call up_fillpage(%p)\n", g_pftcb);
result = up_fillpage(g_pftcb, vpage, pg_callback);
DEBUGASSERT(result == OK);
@ -412,6 +423,8 @@ static inline bool pg_startfill(void)
#endif /* CONFIG_PAGING_BLOCKINGFILL */
return true;
}
pglldbg("Queue empty\n");
return false;
}
@ -443,6 +456,8 @@ static inline void pg_alldone(void)
{
FAR _TCB *wtcb = (FAR _TCB *)g_readytorun.head;
g_pftcb = NULL;
pgllvdbg("New worker priority. %d->%d\n",
wtcb->sched_priority, CONFIG_PAGING_DEFPRIO);
sched_setpriority(wtcb, CONFIG_PAGING_DEFPRIO);
}
@ -477,6 +492,7 @@ static inline void pg_fillcomplete(void)
* received the fill ready-to-run.
*/
pglldbg("Restarting TCB: %p\n", g_pftcb);
up_unblock_task(g_pftcb);
}
@ -520,6 +536,7 @@ int pg_worker(int argc, char *argv[])
* fill completions should occur while this thread sleeps.
*/
pglldbg("Started\n");
flags = irqsave();
for (;;)
{
@ -567,6 +584,7 @@ int pg_worker(int argc, char *argv[])
* task that was blocked waiting for this page fill.
*/
pglldbg("Restarting TCB: %p\n", g_pftcb);
up_unblock_task(g_pftcb);;
/* Yes .. Start the next asynchronous fill. Check the return
@ -574,6 +592,7 @@ int pg_worker(int argc, char *argv[])
* no fill was started).
*/
pgllvdbg("Calling pg_startfill\n");
if (!pg_startfill())
{
/* No fill was started. This can mean only that all queued
@ -581,6 +600,7 @@ int pg_worker(int argc, char *argv[])
* nothing more to do.
*/
pgllvdbg("Call pg_alldone()\n");
pg_alldone();
}
}
@ -592,7 +612,7 @@ int pg_worker(int argc, char *argv[])
#ifdef CONFIG_PAGING_TIMEOUT_TICKS
else
{
dbg("Timeout!\n");
lldbg("Timeout!\n");
ASSERT(g_system_timer - g_starttime < CONFIG_PAGING_TIMEOUT_TICKS);
}
#endif
@ -610,6 +630,7 @@ int pg_worker(int argc, char *argv[])
* g_pftcb).
*/
pgllvdbg("Calling pg_startfill\n");
(void)pg_startfill();
}
#else
@ -624,6 +645,7 @@ int pg_worker(int argc, char *argv[])
* (false means that no fill was perforemd).
*/
pgllvdbg("Calling pg_startfill\n");
if (!pg_startfill())
{
/* Break out of the loop -- there is nothing more to do */
@ -638,11 +660,13 @@ int pg_worker(int argc, char *argv[])
* returns true.
*/
pgllvdbg("Restarting TCB: %p\n", g_pftcb);
up_unblock_task(g_pftcb);;
}
/* All queued fills have been processed */
pgllvdbg("Call pg_alldone()\n");
pg_alldone();
#endif
}