add basic mshell
-> help -> exit -> path/to/elf
This commit is contained in:
parent
bb80eec6e4
commit
9137549a42
4 changed files with 48 additions and 4 deletions
|
@ -119,7 +119,7 @@ static int STDCALL join_test(void* arg)
|
|||
|
||||
int test_init(void)
|
||||
{
|
||||
char* argv[] = {"/bin/hangman", NULL};
|
||||
char* argv[] = {"/bin/mshell", NULL};
|
||||
|
||||
//sem_init(&producing, 1);
|
||||
//sem_init(&consuming, 0);
|
||||
|
@ -131,7 +131,7 @@ int test_init(void)
|
|||
//create_kernel_task(NULL, consumer, NULL);
|
||||
//create_kernel_task(NULL, ping, NULL);
|
||||
//create_user_task(NULL, "/bin/hello", argv);
|
||||
create_user_task(NULL, "/bin/hangman", argv);
|
||||
create_user_task(NULL, "/bin/mshell", argv);
|
||||
//create_user_task(NULL, "/bin/jacobi", argv);
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -11,7 +11,7 @@ LDFLAGS =
|
|||
|
||||
default: all
|
||||
|
||||
all: hello tests jacobi hangman
|
||||
all: hello tests jacobi hangman mshell
|
||||
|
||||
jacobi: jacobi.o
|
||||
$(CC_FOR_TARGET) -T link.ld -o $@ $(LDFLAGS) $< -lm
|
||||
|
@ -37,9 +37,14 @@ hangman: hangman.o
|
|||
$(OBJCOPY_FOR_TARGET) $(STRIP_DEBUG) $@
|
||||
chmod a-x $@.sym
|
||||
|
||||
mshell: mshell.o
|
||||
$(CC_FOR_TARGET) -T link.ld -o $@ $(LDFLAGS) $<
|
||||
$(OBJCOPY_FOR_TARGET) $(KEEP_DEBUG) $@ $@.sym
|
||||
$(OBJCOPY_FOR_TARGET) $(STRIP_DEBUG) $@
|
||||
chmod a-x $@.sym
|
||||
|
||||
clean:
|
||||
$(RM) hello tests *.sym *.o *~
|
||||
$(RM) hello hangman jacobi mshell tests *.sym *.o *~
|
||||
|
||||
depend:
|
||||
$(CC_FOR_TARGET) -MM $(CFLAGS) *.c > Makefile.dep
|
||||
|
|
BIN
newlib/examples/mshell
Executable file
BIN
newlib/examples/mshell
Executable file
Binary file not shown.
39
newlib/examples/mshell.c
Normal file
39
newlib/examples/mshell.c
Normal file
|
@ -0,0 +1,39 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
void showlogo() {
|
||||
printf("\n\n");
|
||||
printf("================================================================================\n");
|
||||
printf(" m(etalsvm)shell\n\n");
|
||||
printf(" Copyright 2010 Stefan Lankes, Chair for Operating Systems,\n");
|
||||
printf(" RWTH Aachen University\n\n");
|
||||
printf("================================================================================\n");
|
||||
}
|
||||
|
||||
void help() {
|
||||
printf("possible commands: \n");
|
||||
printf("exit > exit shell \n");
|
||||
}
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
char* command = malloc(1024*sizeof(char));
|
||||
int size;
|
||||
system("clear");
|
||||
showlogo();
|
||||
while(1) {
|
||||
size = scanf("%s", command);
|
||||
if(!strcmp(command, "exit")) {
|
||||
return 0;
|
||||
}
|
||||
if(!strcmp(command, "help")) {
|
||||
help();
|
||||
}
|
||||
else {
|
||||
char* argv[] = {command, NULL};
|
||||
execve(command, argv, NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Add table
Reference in a new issue