57
									
								
								.cproject
									
									
									
									
									
								
							
							
						
						
									
										57
									
								
								.cproject
									
									
									
									
									
								
							@@ -23,22 +23,22 @@
 | 
			
		||||
							<tool id="org.eclipse.cdt.build.core.settings.holder.libs.583579175" name="holder for library settings" superClass="org.eclipse.cdt.build.core.settings.holder.libs"/>
 | 
			
		||||
							<tool id="org.eclipse.cdt.build.core.settings.holder.804428440" name="Assembly" superClass="org.eclipse.cdt.build.core.settings.holder">
 | 
			
		||||
								<option id="org.eclipse.cdt.build.core.settings.holder.incpaths.1612628392" name="Include Paths" superClass="org.eclipse.cdt.build.core.settings.holder.incpaths" valueType="includePath">
 | 
			
		||||
									<listOptionValue builtIn="false" value="/usr/lib/arm-none-eabi/include"/>
 | 
			
		||||
									<listOptionValue builtIn="false" value="/usr/lib/gcc/arm-none-eabi/4.8/include/"/>
 | 
			
		||||
									<listOptionValue builtIn="false" value="/opt/arm-2011.09/arm-none-eabi/include"/>
 | 
			
		||||
									<listOptionValue builtIn="false" value="/opt/arm-2011.09/lib/gcc/arm-none-eabi/4.6.1/include"/>
 | 
			
		||||
								</option>
 | 
			
		||||
								<inputType id="org.eclipse.cdt.build.core.settings.holder.inType.1218410972" languageId="org.eclipse.cdt.core.assembly" languageName="Assembly" sourceContentType="org.eclipse.cdt.core.asmSource" superClass="org.eclipse.cdt.build.core.settings.holder.inType"/>
 | 
			
		||||
							</tool>
 | 
			
		||||
							<tool id="org.eclipse.cdt.build.core.settings.holder.1838895569" name="GNU C++" superClass="org.eclipse.cdt.build.core.settings.holder">
 | 
			
		||||
								<option id="org.eclipse.cdt.build.core.settings.holder.incpaths.1874409566" name="Include Paths" superClass="org.eclipse.cdt.build.core.settings.holder.incpaths" valueType="includePath">
 | 
			
		||||
									<listOptionValue builtIn="false" value="/usr/lib/arm-none-eabi/include"/>
 | 
			
		||||
									<listOptionValue builtIn="false" value="/usr/lib/gcc/arm-none-eabi/4.8/include/"/>
 | 
			
		||||
									<listOptionValue builtIn="false" value="/opt/arm-2011.09/arm-none-eabi/include"/>
 | 
			
		||||
									<listOptionValue builtIn="false" value="/opt/arm-2011.09/lib/gcc/arm-none-eabi/4.6.1/include"/>
 | 
			
		||||
								</option>
 | 
			
		||||
								<inputType id="org.eclipse.cdt.build.core.settings.holder.inType.258587679" languageId="org.eclipse.cdt.core.g++" languageName="GNU C++" sourceContentType="org.eclipse.cdt.core.cxxSource,org.eclipse.cdt.core.cxxHeader" superClass="org.eclipse.cdt.build.core.settings.holder.inType"/>
 | 
			
		||||
							</tool>
 | 
			
		||||
							<tool id="org.eclipse.cdt.build.core.settings.holder.433020597" name="GNU C" superClass="org.eclipse.cdt.build.core.settings.holder">
 | 
			
		||||
								<option id="org.eclipse.cdt.build.core.settings.holder.incpaths.7772132" name="Include Paths" superClass="org.eclipse.cdt.build.core.settings.holder.incpaths" valueType="includePath">
 | 
			
		||||
									<listOptionValue builtIn="false" value="/usr/lib/arm-none-eabi/include"/>
 | 
			
		||||
									<listOptionValue builtIn="false" value="/usr/lib/gcc/arm-none-eabi/4.8/include/"/>
 | 
			
		||||
									<listOptionValue builtIn="false" value="/opt/arm-2011.09/arm-none-eabi/include"/>
 | 
			
		||||
									<listOptionValue builtIn="false" value="/opt/arm-2011.09/lib/gcc/arm-none-eabi/4.6.1/include"/>
 | 
			
		||||
								</option>
 | 
			
		||||
								<inputType id="org.eclipse.cdt.build.core.settings.holder.inType.761231156" languageId="org.eclipse.cdt.core.gcc" languageName="GNU C" sourceContentType="org.eclipse.cdt.core.cSource,org.eclipse.cdt.core.cHeader" superClass="org.eclipse.cdt.build.core.settings.holder.inType"/>
 | 
			
		||||
							</tool>
 | 
			
		||||
@@ -70,22 +70,22 @@
 | 
			
		||||
							<tool id="org.eclipse.cdt.build.core.settings.holder.libs.232481989" name="holder for library settings" superClass="org.eclipse.cdt.build.core.settings.holder.libs"/>
 | 
			
		||||
							<tool id="org.eclipse.cdt.build.core.settings.holder.562391475" name="Assembly" superClass="org.eclipse.cdt.build.core.settings.holder">
 | 
			
		||||
								<option id="org.eclipse.cdt.build.core.settings.holder.incpaths.1491856129" name="Include Paths" superClass="org.eclipse.cdt.build.core.settings.holder.incpaths" valueType="includePath">
 | 
			
		||||
									<listOptionValue builtIn="false" value="/usr/lib/arm-none-eabi/include"/>
 | 
			
		||||
									<listOptionValue builtIn="false" value="/usr/lib/gcc/arm-none-eabi/4.8/include/"/>
 | 
			
		||||
									<listOptionValue builtIn="false" value="/opt/arm-2011.09/arm-none-eabi/include"/>
 | 
			
		||||
									<listOptionValue builtIn="false" value="/opt/arm-2011.09/lib/gcc/arm-none-eabi/4.6.1/include"/>
 | 
			
		||||
								</option>
 | 
			
		||||
								<inputType id="org.eclipse.cdt.build.core.settings.holder.inType.275129533" languageId="org.eclipse.cdt.core.assembly" languageName="Assembly" sourceContentType="org.eclipse.cdt.core.asmSource" superClass="org.eclipse.cdt.build.core.settings.holder.inType"/>
 | 
			
		||||
							</tool>
 | 
			
		||||
							<tool id="org.eclipse.cdt.build.core.settings.holder.193886409" name="GNU C++" superClass="org.eclipse.cdt.build.core.settings.holder">
 | 
			
		||||
								<option id="org.eclipse.cdt.build.core.settings.holder.incpaths.715382618" name="Include Paths" superClass="org.eclipse.cdt.build.core.settings.holder.incpaths" valueType="includePath">
 | 
			
		||||
									<listOptionValue builtIn="false" value="/usr/lib/arm-none-eabi/include"/>
 | 
			
		||||
									<listOptionValue builtIn="false" value="/usr/lib/gcc/arm-none-eabi/4.8/include/"/>
 | 
			
		||||
									<listOptionValue builtIn="false" value="/opt/arm-2011.09/arm-none-eabi/include"/>
 | 
			
		||||
									<listOptionValue builtIn="false" value="/opt/arm-2011.09/lib/gcc/arm-none-eabi/4.6.1/include"/>
 | 
			
		||||
								</option>
 | 
			
		||||
								<inputType id="org.eclipse.cdt.build.core.settings.holder.inType.1629243941" languageId="org.eclipse.cdt.core.g++" languageName="GNU C++" sourceContentType="org.eclipse.cdt.core.cxxSource,org.eclipse.cdt.core.cxxHeader" superClass="org.eclipse.cdt.build.core.settings.holder.inType"/>
 | 
			
		||||
							</tool>
 | 
			
		||||
							<tool id="org.eclipse.cdt.build.core.settings.holder.1854601715" name="GNU C" superClass="org.eclipse.cdt.build.core.settings.holder">
 | 
			
		||||
								<option id="org.eclipse.cdt.build.core.settings.holder.incpaths.1688578924" name="Include Paths" superClass="org.eclipse.cdt.build.core.settings.holder.incpaths" valueType="includePath">
 | 
			
		||||
									<listOptionValue builtIn="false" value="/usr/lib/arm-none-eabi/include"/>
 | 
			
		||||
									<listOptionValue builtIn="false" value="/usr/lib/gcc/arm-none-eabi/4.8/include/"/>
 | 
			
		||||
									<listOptionValue builtIn="false" value="/opt/arm-2011.09/arm-none-eabi/include"/>
 | 
			
		||||
									<listOptionValue builtIn="false" value="/opt/arm-2011.09/lib/gcc/arm-none-eabi/4.6.1/include"/>
 | 
			
		||||
								</option>
 | 
			
		||||
								<inputType id="org.eclipse.cdt.build.core.settings.holder.inType.683508981" languageId="org.eclipse.cdt.core.gcc" languageName="GNU C" sourceContentType="org.eclipse.cdt.core.cSource,org.eclipse.cdt.core.cHeader" superClass="org.eclipse.cdt.build.core.settings.holder.inType"/>
 | 
			
		||||
							</tool>
 | 
			
		||||
@@ -117,21 +117,6 @@
 | 
			
		||||
		</configuration>
 | 
			
		||||
	</storageModule>
 | 
			
		||||
	<storageModule moduleId="org.eclipse.cdt.internal.ui.text.commentOwnerProjectMappings"/>
 | 
			
		||||
	<storageModule moduleId="scannerConfiguration">
 | 
			
		||||
		<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
 | 
			
		||||
		<scannerConfigBuildInfo instanceId="0.1571827594.174997613.1900689539">
 | 
			
		||||
			<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
 | 
			
		||||
		</scannerConfigBuildInfo>
 | 
			
		||||
		<scannerConfigBuildInfo instanceId="0.1571827594.174997613">
 | 
			
		||||
			<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
 | 
			
		||||
		</scannerConfigBuildInfo>
 | 
			
		||||
		<scannerConfigBuildInfo instanceId="0.1571827594">
 | 
			
		||||
			<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
 | 
			
		||||
		</scannerConfigBuildInfo>
 | 
			
		||||
		<scannerConfigBuildInfo instanceId="0.1571827594.174997613.1900689539.492450098">
 | 
			
		||||
			<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
 | 
			
		||||
		</scannerConfigBuildInfo>
 | 
			
		||||
	</storageModule>
 | 
			
		||||
	<storageModule moduleId="org.eclipse.cdt.make.core.buildtargets">
 | 
			
		||||
		<buildTargets>
 | 
			
		||||
			<target name="all" path="software/source/test/firmware/kernel/list" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
 | 
			
		||||
@@ -343,4 +328,22 @@
 | 
			
		||||
			</target>
 | 
			
		||||
		</buildTargets>
 | 
			
		||||
	</storageModule>
 | 
			
		||||
	<storageModule moduleId="scannerConfiguration">
 | 
			
		||||
		<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
 | 
			
		||||
		<scannerConfigBuildInfo instanceId="0.1571827594.174997613.1900689539">
 | 
			
		||||
			<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
 | 
			
		||||
		</scannerConfigBuildInfo>
 | 
			
		||||
		<scannerConfigBuildInfo instanceId="0.1571827594.174997613">
 | 
			
		||||
			<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
 | 
			
		||||
		</scannerConfigBuildInfo>
 | 
			
		||||
		<scannerConfigBuildInfo instanceId="0.1571827594">
 | 
			
		||||
			<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
 | 
			
		||||
		</scannerConfigBuildInfo>
 | 
			
		||||
		<scannerConfigBuildInfo instanceId="0.1571827594.174997613.1900689539.492450098">
 | 
			
		||||
			<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
 | 
			
		||||
		</scannerConfigBuildInfo>
 | 
			
		||||
		<scannerConfigBuildInfo instanceId="0.1571827594.511870544">
 | 
			
		||||
			<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
 | 
			
		||||
		</scannerConfigBuildInfo>
 | 
			
		||||
	</storageModule>
 | 
			
		||||
</cproject>
 | 
			
		||||
 
 | 
			
		||||
@@ -1,7 +1,7 @@
 | 
			
		||||
variables:
 | 
			
		||||
  SW_KERNEL: "0"
 | 
			
		||||
  SW_MAJOR: "0"
 | 
			
		||||
  SW_MINOR: "3"
 | 
			
		||||
  SW_MINOR: "4"
 | 
			
		||||
 | 
			
		||||
before_script:
 | 
			
		||||
  - "echo $CI_BUILD_ID"
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										2
									
								
								Makefile
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								Makefile
									
									
									
									
									
								
							@@ -17,8 +17,6 @@ BIN_FILE = $(EXE_DIR)/$(TEST_APP)$(BIN_EXT)
 | 
			
		||||
HEX_FILE = $(EXE_DIR)/$(TEST_APP)$(HEX_EXT)
 | 
			
		||||
SIZE_FILE = $(SIZE_DIR)/$(TEST_APP)$(SIZE_EXT)
 | 
			
		||||
 | 
			
		||||
INCLUDES += $(SRC_DIR)
 | 
			
		||||
 | 
			
		||||
SUB_FOLDER :=
 | 
			
		||||
CHECK_FOLDER :=
 | 
			
		||||
SOURCES := $(wildcard $(SRC_DIR)/*.c)
 | 
			
		||||
 
 | 
			
		||||
@@ -9,6 +9,11 @@ endif
 | 
			
		||||
OS_LIB = kosmos-$(ARCH)-$(BOARD)$(DBG_EXT)
 | 
			
		||||
LIBS += $(OS_LIB)
 | 
			
		||||
 | 
			
		||||
INCLUDES += \
 | 
			
		||||
	$(SRC_DIR) \
 | 
			
		||||
	$(SRC_DIR)/firmware
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
CFLAGS += \
 | 
			
		||||
	-Wno-unused-function \
 | 
			
		||||
	-O$(OPTIM) \
 | 
			
		||||
 
 | 
			
		||||
@@ -351,7 +351,7 @@ const struct driver gpio_c2 = {
 | 
			
		||||
 | 
			
		||||
// GPIO_C3
 | 
			
		||||
static const GPIO_InitTypeDef port_cfg_C3 = {
 | 
			
		||||
		GPIO_Pin_1,
 | 
			
		||||
		GPIO_Pin_3,
 | 
			
		||||
		GPIO_Mode_OUT,
 | 
			
		||||
		GPIO_Speed_100MHz,
 | 
			
		||||
		GPIO_OType_PP,
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										17
									
								
								source/firmware/kernel/include/shell_commands.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										17
									
								
								source/firmware/kernel/include/shell_commands.h
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,17 @@
 | 
			
		||||
/*
 | 
			
		||||
 * shell_commands.h
 | 
			
		||||
 *
 | 
			
		||||
 *  Created on: Aug 11, 2016
 | 
			
		||||
 *      Author: tkl
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#ifndef SOURCE_FIRMWARE_KERNEL_INCLUDE_SHELL_COMMANDS_H_
 | 
			
		||||
#define SOURCE_FIRMWARE_KERNEL_INCLUDE_SHELL_COMMANDS_H_
 | 
			
		||||
 | 
			
		||||
struct command cmd_kosmos_version;
 | 
			
		||||
struct command cmd_list_all_commands;
 | 
			
		||||
struct command cmd_echo_on;
 | 
			
		||||
struct command cmd_echo_off;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#endif /* SOURCE_FIRMWARE_KERNEL_INCLUDE_SHELL_COMMANDS_H_ */
 | 
			
		||||
							
								
								
									
										19
									
								
								source/firmware/kernel/include/shell_data.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										19
									
								
								source/firmware/kernel/include/shell_data.h
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,19 @@
 | 
			
		||||
/*
 | 
			
		||||
 * shell_data.h
 | 
			
		||||
 *
 | 
			
		||||
 *  Created on: Aug 11, 2016
 | 
			
		||||
 *      Author: tkl
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#ifndef SOURCE_FIRMWARE_KERNEL_INCLUDE_SHELL_DATA_H_
 | 
			
		||||
#define SOURCE_FIRMWARE_KERNEL_INCLUDE_SHELL_DATA_H_
 | 
			
		||||
 | 
			
		||||
struct shell_object {
 | 
			
		||||
	struct list command_list;
 | 
			
		||||
	const struct driver *shell_device;
 | 
			
		||||
	bool echo_on;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
struct shell_object shell_object;
 | 
			
		||||
 | 
			
		||||
#endif /* SOURCE_FIRMWARE_KERNEL_INCLUDE_SHELL_DATA_H_ */
 | 
			
		||||
@@ -20,5 +20,6 @@ struct list {
 | 
			
		||||
 | 
			
		||||
int list_init(struct list *head);
 | 
			
		||||
int list_add(struct list *head, struct list_node *node);
 | 
			
		||||
int list_get_len(struct list *head);
 | 
			
		||||
 | 
			
		||||
#endif /* SOURCE_FIRMWARE_KERNEL_LIST_H_ */
 | 
			
		||||
 
 | 
			
		||||
@@ -12,6 +12,7 @@ typedef void *(*command_callback)(const char*);
 | 
			
		||||
 | 
			
		||||
struct command {
 | 
			
		||||
	const char *command;
 | 
			
		||||
	const char *description;
 | 
			
		||||
	const command_callback command_callback;
 | 
			
		||||
	struct list_node item;
 | 
			
		||||
};
 | 
			
		||||
 
 | 
			
		||||
@@ -34,3 +34,16 @@ int list_add(struct list *head, struct list_node *node)
 | 
			
		||||
	}
 | 
			
		||||
	return 1;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int list_get_len(struct list *head)
 | 
			
		||||
{
 | 
			
		||||
	int ret = 0;
 | 
			
		||||
	if(NULL == head)
 | 
			
		||||
		return -1;
 | 
			
		||||
	struct list_node *it = head->front;
 | 
			
		||||
	while(NULL != it) {
 | 
			
		||||
		ret++;
 | 
			
		||||
		it = it->next;
 | 
			
		||||
	}
 | 
			
		||||
	return ret;
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -14,14 +14,10 @@
 | 
			
		||||
#include "driver.h"
 | 
			
		||||
#include "kernel.h"
 | 
			
		||||
#include "list.h"
 | 
			
		||||
#include "shell_data.h"
 | 
			
		||||
#include "shell.h"
 | 
			
		||||
#include "shell_commands.h"
 | 
			
		||||
 | 
			
		||||
struct shell_object {
 | 
			
		||||
	struct list command_list;
 | 
			
		||||
	const struct driver *shell_device;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
struct shell_object shell_object;
 | 
			
		||||
 | 
			
		||||
#define TH_STACK_SIZE  256
 | 
			
		||||
stack_t th_stack[TH_STACK_SIZE];
 | 
			
		||||
@@ -52,7 +48,17 @@ static void rx_func(void *arg)
 | 
			
		||||
		ret = read(shell_object.shell_device, &buffer[index],
 | 
			
		||||
				sizeof(buffer) / sizeof(buffer[0]) - index - 1);
 | 
			
		||||
		if(ret) {
 | 
			
		||||
			write(shell_object.shell_device, &buffer[index], ret);	// echo
 | 
			
		||||
			if(shell_object.echo_on) {
 | 
			
		||||
				if((buffer[index + ret - 1] == '\n') && (buffer[index + ret -2] != '\r')) {
 | 
			
		||||
					write(shell_object.shell_device, "\r\n", 2);
 | 
			
		||||
				}
 | 
			
		||||
				else if((buffer[index + ret - 1] == '\r') && (buffer[index + ret -2] != '\n')) {
 | 
			
		||||
					write(shell_object.shell_device, "\r\n", 2);
 | 
			
		||||
				}
 | 
			
		||||
				else {
 | 
			
		||||
					write(shell_object.shell_device, &buffer[index], ret);	// echo
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
			if((buffer[index + ret - 1] == '\n') || (buffer[index + ret - 1] == '\r')) {
 | 
			
		||||
				buffer[index + ret - 1] = '\n';
 | 
			
		||||
				parse(buffer, index + ret);
 | 
			
		||||
@@ -71,6 +77,13 @@ int shell_init(const struct driver *shell_device)
 | 
			
		||||
		return -1;
 | 
			
		||||
	list_init(&shell_object.command_list);
 | 
			
		||||
	shell_object.shell_device = shell_device;
 | 
			
		||||
	shell_object.echo_on = true;
 | 
			
		||||
 | 
			
		||||
	shell_add_command(&cmd_kosmos_version);
 | 
			
		||||
	shell_add_command(&cmd_list_all_commands);
 | 
			
		||||
	shell_add_command(&cmd_echo_on);
 | 
			
		||||
	shell_add_command(&cmd_echo_off);
 | 
			
		||||
 | 
			
		||||
	thread_create(&th_ctx, th_stack, TH_STACK_SIZE, rx_func, NULL, THREAD_PRIO_LOW);
 | 
			
		||||
	return 0;
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										91
									
								
								source/firmware/kernel/shell_commands.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										91
									
								
								source/firmware/kernel/shell_commands.c
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,91 @@
 | 
			
		||||
/*
 | 
			
		||||
 * shell_commands.c
 | 
			
		||||
 *
 | 
			
		||||
 *  Created on: Aug 11, 2016
 | 
			
		||||
 *      Author: tkl
 | 
			
		||||
 */
 | 
			
		||||
#include <stdbool.h>
 | 
			
		||||
#include <stddef.h>
 | 
			
		||||
#include <string.h>
 | 
			
		||||
 | 
			
		||||
#include "list.h"
 | 
			
		||||
#include "driver.h"
 | 
			
		||||
#include "shell_data.h"
 | 
			
		||||
#include "shell.h"
 | 
			
		||||
#include "version.h"
 | 
			
		||||
#include "shell_commands.h"
 | 
			
		||||
 | 
			
		||||
static void *cmd_kosmos_version_cb(const char *cmd);
 | 
			
		||||
static void *cmd_list_all_commands_cb(const char *cmd);
 | 
			
		||||
static void *cmd_echo_on_cb(const char *cmd);
 | 
			
		||||
static void *cmd_echo_off_cb(const char *cmd);
 | 
			
		||||
 | 
			
		||||
struct command cmd_kosmos_version = {
 | 
			
		||||
		.command = "uname",
 | 
			
		||||
		.description = "Print current kosmos version.",
 | 
			
		||||
		.command_callback = cmd_kosmos_version_cb
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
struct command cmd_list_all_commands = {
 | 
			
		||||
		.command = "ls",
 | 
			
		||||
		.description = "List all installed commands.",
 | 
			
		||||
		.command_callback = cmd_list_all_commands_cb
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
struct command cmd_echo_on = {
 | 
			
		||||
		.command = "echo on",
 | 
			
		||||
		.description = "Switch echo on.",
 | 
			
		||||
		.command_callback = cmd_echo_on_cb
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
struct command cmd_echo_off = {
 | 
			
		||||
		.command = "echo off",
 | 
			
		||||
		.description = "Switch echo off.",
 | 
			
		||||
		.command_callback = cmd_echo_off_cb
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
static void *cmd_kosmos_version_cb(const char *cmd)
 | 
			
		||||
{
 | 
			
		||||
	char *greeter = "Kosmos Version: ";
 | 
			
		||||
 | 
			
		||||
	write(shell_object.shell_device, greeter, strlen(greeter));
 | 
			
		||||
	write(shell_object.shell_device, KERNEL_VERSION, strlen(KERNEL_VERSION));
 | 
			
		||||
	write(shell_object.shell_device, ".", 1);
 | 
			
		||||
	write(shell_object.shell_device, MAJOR_VERSION, strlen(MAJOR_VERSION));
 | 
			
		||||
	write(shell_object.shell_device, ".", 1);
 | 
			
		||||
	write(shell_object.shell_device, MINOR_VERSION, strlen(MINOR_VERSION));
 | 
			
		||||
	return NULL;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void *cmd_list_all_commands_cb(const char *cmd)
 | 
			
		||||
{
 | 
			
		||||
	char *greeter = "Command list: \r\n";
 | 
			
		||||
	struct list_node *it = shell_object.command_list.front;
 | 
			
		||||
	int i, len = list_get_len(&shell_object.command_list);
 | 
			
		||||
 | 
			
		||||
	write(shell_object.shell_device, greeter, strlen(greeter));
 | 
			
		||||
	for(i = 0; i < (len - 1); i++) {
 | 
			
		||||
		if(NULL != it) {
 | 
			
		||||
			struct command *cmd = (struct command *)it->data;
 | 
			
		||||
			write(shell_object.shell_device, cmd->command, strlen(cmd->command));
 | 
			
		||||
			write(shell_object.shell_device, " - ", 3);
 | 
			
		||||
			write(shell_object.shell_device, cmd->description, strlen(cmd->description));
 | 
			
		||||
			write(shell_object.shell_device, "\r\n", 2);
 | 
			
		||||
			it = it->next;
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return NULL;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void *cmd_echo_on_cb(const char *cmd)
 | 
			
		||||
{
 | 
			
		||||
	shell_object.echo_on = true;
 | 
			
		||||
	return NULL;
 | 
			
		||||
}
 | 
			
		||||
static void *cmd_echo_off_cb(const char *cmd)
 | 
			
		||||
{
 | 
			
		||||
	shell_object.echo_on = false;
 | 
			
		||||
	return NULL;
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user