git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@3236 35acf78f-673a-0410-8e92-d51de3d6d3f4
parent
e2868efe16
commit
698e37b41c
|
@ -72,6 +72,7 @@ SRC = ${PORTSRC} \
|
||||||
${PLATFORMSRC} \
|
${PLATFORMSRC} \
|
||||||
$(BOARDSRC) \
|
$(BOARDSRC) \
|
||||||
${CHIBIOS}/os/various/shell.c \
|
${CHIBIOS}/os/various/shell.c \
|
||||||
|
${CHIBIOS}/os/various/chprintf.c \
|
||||||
main.c
|
main.c
|
||||||
|
|
||||||
# List ASM source files here
|
# List ASM source files here
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
#include "hal.h"
|
#include "hal.h"
|
||||||
#include "test.h"
|
#include "test.h"
|
||||||
#include "shell.h"
|
#include "shell.h"
|
||||||
|
#include "chprintf.h"
|
||||||
|
|
||||||
#define SHELL_WA_SIZE THD_WA_SIZE(4096)
|
#define SHELL_WA_SIZE THD_WA_SIZE(4096)
|
||||||
#define CONSOLE_WA_SIZE THD_WA_SIZE(4096)
|
#define CONSOLE_WA_SIZE THD_WA_SIZE(4096)
|
||||||
|
@ -35,24 +36,76 @@ static Thread *cdtp;
|
||||||
static Thread *shelltp1;
|
static Thread *shelltp1;
|
||||||
static Thread *shelltp2;
|
static Thread *shelltp2;
|
||||||
|
|
||||||
void cmd_test(BaseChannel *chp, int argc, char *argv[]) {
|
static void cmd_mem(BaseChannel *chp, int argc, char *argv[]) {
|
||||||
|
size_t n, size;
|
||||||
|
|
||||||
|
(void)argv;
|
||||||
|
if (argc > 0) {
|
||||||
|
chprintf(chp, "Usage: mem\r\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
n = chHeapStatus(NULL, &size);
|
||||||
|
chprintf(chp, "core free memory : %u bytes\r\n", chCoreStatus());
|
||||||
|
chprintf(chp, "heap fragments : %u\r\n", n);
|
||||||
|
chprintf(chp, "heap free total : %u bytes\r\n", size);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void cmd_threads(BaseChannel *chp, int argc, char *argv[]) {
|
||||||
|
static const char *states[] = {
|
||||||
|
"READY",
|
||||||
|
"CURRENT",
|
||||||
|
"SUSPENDED",
|
||||||
|
"WTSEM",
|
||||||
|
"WTMTX",
|
||||||
|
"WTCOND",
|
||||||
|
"SLEEPING",
|
||||||
|
"WTEXIT",
|
||||||
|
"WTOREVT",
|
||||||
|
"WTANDEVT",
|
||||||
|
"SNDMSGQ",
|
||||||
|
"SNDMSG",
|
||||||
|
"WTMSG",
|
||||||
|
"WTQUEUE",
|
||||||
|
"FINAL"
|
||||||
|
};
|
||||||
Thread *tp;
|
Thread *tp;
|
||||||
|
|
||||||
(void)argv;
|
(void)argv;
|
||||||
if (argc > 0) {
|
if (argc > 0) {
|
||||||
shellPrintLine(chp, "Usage: test");
|
chprintf(chp, "Usage: threads\r\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
chprintf(chp, " addr stack prio refs state time\r\n");
|
||||||
|
tp = chRegFirstThread();
|
||||||
|
do {
|
||||||
|
chprintf(chp, "%.8lx %.8lx %4lu %4lu %9s %lu\r\n",
|
||||||
|
(uint32_t)tp, (uint32_t)tp->p_ctx.esp,
|
||||||
|
(uint32_t)tp->p_prio, (uint32_t)(tp->p_refs - 1),
|
||||||
|
states[tp->p_state], (uint32_t)tp->p_time);
|
||||||
|
tp = chRegNextThread(tp);
|
||||||
|
} while (tp != NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void cmd_test(BaseChannel *chp, int argc, char *argv[]) {
|
||||||
|
Thread *tp;
|
||||||
|
|
||||||
|
(void)argv;
|
||||||
|
if (argc > 0) {
|
||||||
|
chprintf(chp, "Usage: test\r\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
tp = chThdCreateFromHeap(NULL, TEST_WA_SIZE, chThdGetPriority(),
|
tp = chThdCreateFromHeap(NULL, TEST_WA_SIZE, chThdGetPriority(),
|
||||||
TestThread, chp);
|
TestThread, chp);
|
||||||
if (tp == NULL) {
|
if (tp == NULL) {
|
||||||
shellPrintLine(chp, "out of memory");
|
chprintf(chp, "out of memory\r\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
chThdWait(tp);
|
chThdWait(tp);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const ShellCommand commands[] = {
|
static const ShellCommand commands[] = {
|
||||||
|
{"mem", cmd_mem},
|
||||||
|
{"threads", cmd_threads},
|
||||||
{"test", cmd_test},
|
{"test", cmd_test},
|
||||||
{NULL, NULL}
|
{NULL, NULL}
|
||||||
};
|
};
|
||||||
|
@ -76,9 +129,10 @@ static msg_t console_thread(void *arg) {
|
||||||
|
|
||||||
(void)arg;
|
(void)arg;
|
||||||
while (!chThdShouldTerminate()) {
|
while (!chThdShouldTerminate()) {
|
||||||
puts((char *)chMsgWait());
|
Thread *tp = chMsgWait();
|
||||||
|
puts((char *)chMsgGet(tp));
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
chMsgRelease(RDY_OK);
|
chMsgRelease(tp, RDY_OK);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,6 +72,7 @@ SRC = ${PORTSRC} \
|
||||||
${PLATFORMSRC} \
|
${PLATFORMSRC} \
|
||||||
$(BOARDSRC) \
|
$(BOARDSRC) \
|
||||||
${CHIBIOS}/os/various/shell.c \
|
${CHIBIOS}/os/various/shell.c \
|
||||||
|
${CHIBIOS}/os/various/chprintf.c \
|
||||||
main.c
|
main.c
|
||||||
|
|
||||||
# List ASM source files here
|
# List ASM source files here
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
#include "hal.h"
|
#include "hal.h"
|
||||||
#include "test.h"
|
#include "test.h"
|
||||||
#include "shell.h"
|
#include "shell.h"
|
||||||
|
#include "chprintf.h"
|
||||||
|
|
||||||
#define SHELL_WA_SIZE THD_WA_SIZE(4096)
|
#define SHELL_WA_SIZE THD_WA_SIZE(4096)
|
||||||
#define CONSOLE_WA_SIZE THD_WA_SIZE(4096)
|
#define CONSOLE_WA_SIZE THD_WA_SIZE(4096)
|
||||||
|
@ -35,20 +36,16 @@ static Thread *shelltp2;
|
||||||
|
|
||||||
static void cmd_mem(BaseChannel *chp, int argc, char *argv[]) {
|
static void cmd_mem(BaseChannel *chp, int argc, char *argv[]) {
|
||||||
size_t n, size;
|
size_t n, size;
|
||||||
char buf[52];
|
|
||||||
|
|
||||||
(void)argv;
|
(void)argv;
|
||||||
if (argc > 0) {
|
if (argc > 0) {
|
||||||
shellPrintLine(chp, "Usage: mem");
|
chprintf(chp, "Usage: mem\r\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
n = chHeapStatus(NULL, &size);
|
n = chHeapStatus(NULL, &size);
|
||||||
sprintf(buf, "core free memory : %i bytes", chCoreStatus());
|
chprintf(chp, "core free memory : %u bytes\r\n", chCoreStatus());
|
||||||
shellPrintLine(chp, buf);
|
chprintf(chp, "heap fragments : %u\r\n", n);
|
||||||
sprintf(buf, "heap fragments : %i", n);
|
chprintf(chp, "heap free total : %u bytes\r\n", size);
|
||||||
shellPrintLine(chp, buf);
|
|
||||||
sprintf(buf, "heap free total : %i bytes", size);
|
|
||||||
shellPrintLine(chp, buf);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void cmd_threads(BaseChannel *chp, int argc, char *argv[]) {
|
static void cmd_threads(BaseChannel *chp, int argc, char *argv[]) {
|
||||||
|
@ -63,25 +60,26 @@ static void cmd_threads(BaseChannel *chp, int argc, char *argv[]) {
|
||||||
"WTEXIT",
|
"WTEXIT",
|
||||||
"WTOREVT",
|
"WTOREVT",
|
||||||
"WTANDEVT",
|
"WTANDEVT",
|
||||||
|
"SNDMSGQ",
|
||||||
"SNDMSG",
|
"SNDMSG",
|
||||||
"WTMSG",
|
"WTMSG",
|
||||||
|
"WTQUEUE",
|
||||||
"FINAL"
|
"FINAL"
|
||||||
};
|
};
|
||||||
Thread *tp;
|
Thread *tp;
|
||||||
char buf[60];
|
|
||||||
|
|
||||||
(void)argv;
|
(void)argv;
|
||||||
if (argc > 0) {
|
if (argc > 0) {
|
||||||
shellPrintLine(chp, "Usage: threads");
|
chprintf(chp, "Usage: threads\r\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
shellPrintLine(chp, " addr stack prio refs state time");
|
chprintf(chp, " addr stack prio refs state time\r\n");
|
||||||
tp = chRegFirstThread();
|
tp = chRegFirstThread();
|
||||||
do {
|
do {
|
||||||
sprintf(buf, "%8p %8p %4i %4i %9s %i",
|
chprintf(chp, "%.8lx %.8lx %4lu %4lu %9s %lu\r\n",
|
||||||
tp, tp->p_ctx.esp, tp->p_prio, tp->p_refs - 1,
|
(uint32_t)tp, (uint32_t)tp->p_ctx.r13,
|
||||||
states[tp->p_state], tp->p_time);
|
(uint32_t)tp->p_prio, (uint32_t)(tp->p_refs - 1),
|
||||||
shellPrintLine(chp, buf);
|
states[tp->p_state], (uint32_t)tp->p_time);
|
||||||
tp = chRegNextThread(tp);
|
tp = chRegNextThread(tp);
|
||||||
} while (tp != NULL);
|
} while (tp != NULL);
|
||||||
}
|
}
|
||||||
|
@ -91,13 +89,13 @@ static void cmd_test(BaseChannel *chp, int argc, char *argv[]) {
|
||||||
|
|
||||||
(void)argv;
|
(void)argv;
|
||||||
if (argc > 0) {
|
if (argc > 0) {
|
||||||
shellPrintLine(chp, "Usage: test");
|
chprintf(chp, "Usage: test\r\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
tp = chThdCreateFromHeap(NULL, TEST_WA_SIZE, chThdGetPriority(),
|
tp = chThdCreateFromHeap(NULL, TEST_WA_SIZE, chThdGetPriority(),
|
||||||
TestThread, chp);
|
TestThread, chp);
|
||||||
if (tp == NULL) {
|
if (tp == NULL) {
|
||||||
shellPrintLine(chp, "out of memory");
|
chprintf(chp, "out of memory\r\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
chThdWait(tp);
|
chThdWait(tp);
|
||||||
|
|
|
@ -25,8 +25,13 @@
|
||||||
* @addtogroup PPC_CORE
|
* @addtogroup PPC_CORE
|
||||||
* @{
|
* @{
|
||||||
*/
|
*/
|
||||||
/** @cond never */
|
|
||||||
|
|
||||||
|
#include "chconf.h"
|
||||||
|
|
||||||
|
#define FALSE 0
|
||||||
|
#define TRUE 1
|
||||||
|
|
||||||
|
#if !defined(__DOXYGEN__)
|
||||||
/*
|
/*
|
||||||
* INTC registers address.
|
* INTC registers address.
|
||||||
*/
|
*/
|
||||||
|
@ -72,6 +77,9 @@ IVOR10:
|
||||||
mtspr 336, %r3 /* TSR register. */
|
mtspr 336, %r3 /* TSR register. */
|
||||||
|
|
||||||
/* System tick handler invocation.*/
|
/* System tick handler invocation.*/
|
||||||
|
#if CH_DBG_SYSTEM_STATE_CHECK
|
||||||
|
bl dbg_check_lock
|
||||||
|
#endif
|
||||||
bl chSysTimerHandlerI
|
bl chSysTimerHandlerI
|
||||||
bl chSchIsPreemptionRequired
|
bl chSchIsPreemptionRequired
|
||||||
cmpli cr0, %r3, 0
|
cmpli cr0, %r3, 0
|
||||||
|
@ -138,6 +146,9 @@ IVOR4:
|
||||||
stw %r3, 0(%r3) /* Writing any value should do. */
|
stw %r3, 0(%r3) /* Writing any value should do. */
|
||||||
|
|
||||||
/* Verifies if a reschedule is required.*/
|
/* Verifies if a reschedule is required.*/
|
||||||
|
#if CH_DBG_SYSTEM_STATE_CHECK
|
||||||
|
bl dbg_check_lock
|
||||||
|
#endif
|
||||||
bl chSchIsPreemptionRequired
|
bl chSchIsPreemptionRequired
|
||||||
cmpli cr0, %r3, 0
|
cmpli cr0, %r3, 0
|
||||||
beq cr0, .ctxrestore
|
beq cr0, .ctxrestore
|
||||||
|
@ -145,6 +156,9 @@ IVOR4:
|
||||||
|
|
||||||
/* Context restore.*/
|
/* Context restore.*/
|
||||||
.ctxrestore:
|
.ctxrestore:
|
||||||
|
#if CH_DBG_SYSTEM_STATE_CHECK
|
||||||
|
bl dbg_check_unlock
|
||||||
|
#endif
|
||||||
lwz %r3, 36(%sp) /* Restores GPR3...GPR12. */
|
lwz %r3, 36(%sp) /* Restores GPR3...GPR12. */
|
||||||
lwz %r4, 40(%sp)
|
lwz %r4, 40(%sp)
|
||||||
lwz %r5, 44(%sp)
|
lwz %r5, 44(%sp)
|
||||||
|
@ -171,5 +185,6 @@ IVOR4:
|
||||||
addi %sp, %sp, 80 /* Back to the previous frame. */
|
addi %sp, %sp, 80 /* Back to the previous frame. */
|
||||||
rfi
|
rfi
|
||||||
|
|
||||||
/** @endcond */
|
#endif /* !defined(__DOXYGEN__) */
|
||||||
|
|
||||||
/** @} */
|
/** @} */
|
||||||
|
|
|
@ -81,7 +81,8 @@ void port_switch(Thread *ntp, Thread *otp) {
|
||||||
* invoked.
|
* invoked.
|
||||||
*/
|
*/
|
||||||
void _port_thread_start(void) {
|
void _port_thread_start(void) {
|
||||||
asm ("wrteei 1");
|
|
||||||
|
chSysUnlock();
|
||||||
asm ("mr %r3, %r31"); /* Thread parameter. */
|
asm ("mr %r3, %r31"); /* Thread parameter. */
|
||||||
asm ("mtctr %r30");
|
asm ("mtctr %r30");
|
||||||
asm ("bctrl"); /* Invoke thread function. */
|
asm ("bctrl"); /* Invoke thread function. */
|
||||||
|
|
Loading…
Reference in New Issue