git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@1660 35acf78f-673a-0410-8e92-d51de3d6d3f4

master
gdisirio 2010-02-22 16:29:48 +00:00
parent 7d19745641
commit 582ace5597
8 changed files with 152 additions and 22 deletions

View File

@ -49,6 +49,7 @@ void hwinit1(void) {
SIU.PCR[GPIO_BUTTON3].R = 0x0100; /* IBE. */
SIU.PCR[GPIO_BUTTON4].R = 0x0100; /* IBE. */
SIU.PCR[GPIO_SCI_A_TX].R = 0x0500; /* Primary | IBE. */
SIU.PCR[GPIO_SCI_A_RX].R = 0x0500; /* Primary | IBE. */
/*
* HAL initialization.

View File

@ -41,6 +41,7 @@
* I/O definitions.
*/
#define GPIO_SCI_A_TX 89
#define GPIO_SCI_A_RX 90
#define GPIO_BUTTON1 179
#define GPIO_BUTTON2 181

View File

@ -55,7 +55,8 @@ CSRC = $(PORTSRC) \
$(PLATFORMSRC) \
$(BOARDSRC) \
$(CHIBIOS)/os/various/evtimer.c \
$(CHIBIOS)/os/various/memstreams.c \
$(CHIBIOS)/os/various/shell.c \
$(CHIBIOS)/os/various/syscalls.c \
main.c
# C++ sources here.
@ -109,7 +110,7 @@ CPPWARN = -Wall -Wextra
#
# List all default C defines here, like -D_DEBUG=1
DDEFS =
DDEFS = -DPPC_VARIANT=PPC_VARIANT_e200z3
# List all default ASM defines here, like -D_DEBUG=1
DADEFS =

View File

@ -17,13 +17,97 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdio.h>
#include "ch.h"
#include "hal.h"
#include "test.h"
#include "memstreams.h"
#include "shell.h"
int a = 1234;
uint8_t report_buffer[8192];
#define SHELL_WA_SIZE THD_WA_SIZE(1024)
#define TEST_WA_SIZE THD_WA_SIZE(256)
static void cmd_mem(BaseChannel *chp, int argc, char *argv[]) {
size_t n, size;
char buf[52];
(void)argv;
if (argc > 0) {
shellPrintLine(chp, "Usage: mem");
return;
}
n = chHeapStatus(NULL, &size);
siprintf(buf, "core free memory : %i bytes", chCoreFree());
shellPrintLine(chp, buf);
siprintf(buf, "heap fragments : %i", n);
shellPrintLine(chp, buf);
siprintf(buf, "heap free total : %i bytes", size);
shellPrintLine(chp, buf);
}
static void cmd_threads(BaseChannel *chp, int argc, char *argv[]) {
static const char *states[] = {
"READY",
"CURRENT",
"SUSPENDED",
"WTSEM",
"WTMTX",
"WTCOND",
"SLEEPING",
"WTEXIT",
"WTOREVT",
"WTANDEVT",
"SNDMSG",
"WTMSG",
"FINAL"
};
Thread *tp;
char buf[60];
(void)argv;
if (argc > 0) {
shellPrintLine(chp, "Usage: threads");
return;
}
shellPrintLine(chp, " addr stack prio refs state time");
tp = chRegFirstThread();
do {
siprintf(buf, "%8p %8p %4u %4i %9s %u",
tp, tp->p_ctx.sp, (unsigned int)tp->p_prio, tp->p_refs - 1,
states[tp->p_state], (unsigned int)tp->p_time);
shellPrintLine(chp, buf);
tp = chRegNextThread(tp);
} while (tp != NULL);
}
static void cmd_test(BaseChannel *chp, int argc, char *argv[]) {
Thread *tp;
(void)argv;
if (argc > 0) {
shellPrintLine(chp, "Usage: test");
return;
}
tp = chThdCreateFromHeap(NULL, TEST_WA_SIZE, chThdGetPriority(),
TestThread, chp);
if (tp == NULL) {
shellPrintLine(chp, "out of memory");
return;
}
chThdWait(tp);
}
static const ShellCommand commands[] = {
{"mem", cmd_mem},
{"threads", cmd_threads},
{"test", cmd_test},
{NULL, NULL}
};
static const ShellConfig shell_cfg1 = {
(BaseChannel *)&SD1,
commands
};
/*
* LEDs blinker thread, times are in milliseconds.
@ -32,7 +116,7 @@ static WORKING_AREA(waThread1, 128);
static msg_t Thread1(void *arg) {
(void)arg;
SIU.GPDO[GPIO_LED1].R = 1;
SIU.GPDO[GPIO_LED2].R = 1;
SIU.GPDO[GPIO_LED3].R = 1;
@ -64,6 +148,7 @@ static msg_t Thread1(void *arg) {
* on entry.
*/
int main(int argc, char **argv) {
Thread *shelltp = NULL;
(void)argc;
(void)argv;
@ -73,6 +158,11 @@ int main(int argc, char **argv) {
*/
sdStart(&SD1, NULL);
/*
* Shell manager initialization.
*/
shellInit();
/*
* Creates the blinker thread.
*/
@ -82,6 +172,13 @@ int main(int argc, char **argv) {
* Normal main() thread activity.
*/
while (TRUE) {
if (!shelltp)
shelltp = shellCreate(&shell_cfg1, SHELL_WA_SIZE, NORMALPRIO);
else if (chThdTerminated(shelltp)) {
chThdRelease(shelltp); /* Recovers memory of the previous shell. */
shelltp = NULL; /* Triggers spawning of a new shell. */
}
if (SIU.GPDI[GPIO_BUTTON1].B.PDI) {
volatile msg_t result;
#if 0

View File

@ -46,9 +46,7 @@
#define CH_ARCHITECTURE_VARIANT_NAME ""
/**
* @brief Base type for stack alignment.
* @details This type is used only for stack alignment reasons thus can be
* anything from a char to a double.
* @brief Base type for stack and memory alignment.
*/
typedef uint8_t stkalign_t;

View File

@ -40,7 +40,7 @@
* override the weak symbol declared here.
*/
.section .vectors
.align 2
.align 4
.globl _vectors
_vectors:
.long vector0

View File

@ -39,27 +39,46 @@
#define ENABLE_WFI_IDLE 0
#endif
/* Core variants identifiers.*/
#define PPC_VARIANT_e200z3 3 /**< e200z3 core identifier. */
#define PPC_VARIANT_e200z4 4 /**< e200z4 core identifier. */
/**
* @brief Core variant selector.
* @details This setting affects the predefined architecture strings and
* possibly code paths and structures into the port layer.
*/
#if !defined(PPC_VARIANT) || defined(__DOXYGEN__)
#define PPC_VARIANT PPC_VARIANT_e200z3
#endif
/**
* @brief Unique macro for the implemented architecture.
*/
#define CH_ARCHITECTURE_PPCE200Z
#define CH_ARCHITECTURE_PPC
/**
* @brief Name of the implemented architecture.
*/
#define CH_ARCHITECTURE_NAME "PowerPC"
#define CH_ARCHITECTURE_NAME "PowerPC"
/**
* @brief Name of the architecture variant (optional).
* @brief Name of the architecture variant.
*/
#define CH_CORE_VARIANT_NAME "e200zX"
#if (PPC_VARIANT == PPC_VARIANT_e200z3) || defined(__DOXYGEN__)
#define CH_CORE_VARIANT_NAME "e200z3"
#elif PPC_VARIANT == PPC_VARIANT_e200z4
#define CH_CORE_VARIANT_NAME "e200z4"
#else
#error "unknown PowerPC variant specified"
#endif
/**
* @brief Base type for stack alignment.
* @details This type is used only for stack alignment reasons thus can be
* anything from a char to a double.
* @brief Base type for stack and memory alignment.
*/
typedef uint64_t stkalign_t;
typedef struct {
uint8_t a[8];
} stkalign_t __attribute__((aligned(8)));
/**
* @brief Generic PPC register.

View File

@ -28,6 +28,7 @@
#include <string.h>
#include "ch.h"
#include "hal.h"
#include "shell.h"
#if SHELL_USE_IPRINTF
@ -84,13 +85,25 @@ static void cmd_info(BaseChannel *chp, int argc, char *argv[]) {
return;
}
shellPrint(chp, "Kernel version ");
shellPrint(chp, "Kernel version: ");
shellPrintLine(chp, CH_KERNEL_VERSION);
shellPrint(chp, "Architecture ");
shellPrintLine(chp, CH_ARCHITECTURE_NAME);
#ifdef __GNUC__
shellPrint(chp, "GCC Version ");
shellPrint(chp, "GCC Version: ");
shellPrintLine(chp, __VERSION__);
#endif
shellPrint(chp, "Architecture: ");
shellPrintLine(chp, CH_ARCHITECTURE_NAME);
#ifdef CH_CORE_VARIANT_NAME
shellPrint(chp, "Core Variant: ");
shellPrintLine(chp, CH_CORE_VARIANT_NAME);
#endif
#ifdef PLATFORM_NAME
shellPrint(chp, "Platform: ");
shellPrintLine(chp, PLATFORM_NAME);
#endif
#ifdef BOARD_NAME
shellPrint(chp, "Board: ");
shellPrintLine(chp, BOARD_NAME);
#endif
}