/trunk/uspace/app/init/init.c |
---|
45,10 → 45,6 |
#include "init.h" |
#include "version.h" |
#define BUF_SIZE 150000 |
static char *buf; |
static void console_wait(void) |
{ |
while (get_cons_phone() < 0) |
82,30 → 78,18 |
static void spawn(char *fname) |
{ |
char *argv[2]; |
printf(NAME ": Spawning %s\n", fname); |
int fd = open(fname, O_RDONLY); |
if (fd >= 0) { |
argv[0] = fname; |
argv[1] = NULL; |
ssize_t rd; |
size_t len = 0; |
// FIXME: cannot do long reads yet |
do { |
rd = read(fd, buf + len, 1024); |
if (rd > 0) |
len += rd; |
} while (rd > 0); |
if (len > 0) { |
task_spawn(buf, len); |
sleep(1); // FIXME |
if (task_spawn(fname, argv) != 0) { |
/* Success */ |
sleep(1); |
} |
close(fd); |
} |
} |
int main(int argc, char *argv[]) |
{ |
117,8 → 101,6 |
return -1; |
} |
buf = malloc(BUF_SIZE); |
// FIXME: spawn("/sbin/pci"); |
spawn("/sbin/fb"); |
spawn("/sbin/kbd"); |
129,10 → 111,10 |
spawn("/sbin/fat"); |
spawn("/sbin/tetris"); |
spawn("/sbin/cli"); |
// FIXME: spawn("/sbin/tester"); |
spawn("/sbin/klog"); |
free(buf); |
return 0; |
} |
/trunk/uspace/app/tester/tester.c |
---|
107,8 → 107,17 |
printf("*\t\t\tRun all safe tests\n"); |
} |
int main(void) |
int main(int argc, char **argv) |
{ |
printf("Number of arguments: %d\n", argc); |
if (argv) { |
printf("Arguments:"); |
while (*argv) { |
printf(" '%s'", *argv++); |
} |
printf("\n"); |
} |
while (1) { |
char c; |
test_t *test; |
/trunk/uspace/app/cli/cli.c |
---|
0,0 → 1,125 |
/* |
* Copyright (c) 2008 Jiri Svoboda |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions |
* are met: |
* |
* - Redistributions of source code must retain the above copyright |
* notice, this list of conditions and the following disclaimer. |
* - Redistributions in binary form must reproduce the above copyright |
* notice, this list of conditions and the following disclaimer in the |
* documentation and/or other materials provided with the distribution. |
* - The name of the author may not be used to endorse or promote products |
* derived from this software without specific prior written permission. |
* |
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
/** @addtogroup cli cli |
* @brief Trivial command-line interface for running programs. |
* @{ |
*/ |
/** |
* @file |
*/ |
#include <stdio.h> |
#include <stdlib.h> |
#include <task.h> |
#define LINE_BUFFER_SIZE 128 |
static char line_buffer[LINE_BUFFER_SIZE]; |
#define MAX_ARGS 16 |
static char *argv_buf[MAX_ARGS + 1]; |
static void read_line(char *buffer, int n) |
{ |
char c; |
int chars; |
printf("> "); |
chars = 0; |
while (chars < n - 1) { |
c = getchar(); |
if (c < 0) exit(0); |
if (c == '\n') break; |
if (c == '\b') { |
if (chars > 0) { |
putchar('\b'); |
--chars; |
} |
continue; |
} |
putchar(c); |
buffer[chars++] = c; |
} |
putchar('\n'); |
buffer[chars] = '\0'; |
} |
static void program_run(void) |
{ |
char *p; |
int n; |
p = line_buffer; |
n = 0; |
while (n < MAX_ARGS) { |
argv_buf[n++] = p; |
p = strchr(p, ' '); |
if (p == NULL) break; |
*p++ = '\0'; |
} |
argv_buf[n] = NULL; |
printf("spawn task '%s' with %d args\n", argv_buf[0], n); |
printf("args:"); |
int i; |
for (i = 0; i < n; ++i) { |
printf(" '%s'", argv_buf[i]); |
} |
printf("\n"); |
task_spawn(argv_buf[0], argv_buf); |
} |
int main(int argc, char *argv[]) |
{ |
printf("This is CLI\n"); |
while (1) { |
read_line(line_buffer, LINE_BUFFER_SIZE); |
printf("'%s'\n", line_buffer); |
if (strcmp(line_buffer, "exit") == 0) |
break; |
if (line_buffer[0] != '\0') |
program_run(); |
} |
printf("Bye\n"); |
return 0; |
} |
/** @} |
*/ |
/trunk/uspace/app/cli/Makefile |
---|
0,0 → 1,86 |
# |
# Copyright (c) 2005 Martin Decky |
# All rights reserved. |
# |
# Redistribution and use in source and binary forms, with or without |
# modification, are permitted provided that the following conditions |
# are met: |
# |
# - Redistributions of source code must retain the above copyright |
# notice, this list of conditions and the following disclaimer. |
# - Redistributions in binary form must reproduce the above copyright |
# notice, this list of conditions and the following disclaimer in the |
# documentation and/or other materials provided with the distribution. |
# - The name of the author may not be used to endorse or promote products |
# derived from this software without specific prior written permission. |
# |
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
# |
include ../../../version |
include ../../Makefile.config |
## Setup toolchain |
# |
LIBC_PREFIX = ../../lib/libc |
SOFTINT_PREFIX = ../../lib/softint |
include $(LIBC_PREFIX)/Makefile.toolchain |
CFLAGS += -I../../srv/kbd/include |
LIBS = $(LIBC_PREFIX)/libc.a |
DEFS += -DRELEASE=\"$(RELEASE)\" |
ifdef REVISION |
DEFS += "-DREVISION=\"$(REVISION)\"" |
endif |
ifdef TIMESTAMP |
DEFS += "-DTIMESTAMP=\"$(TIMESTAMP)\"" |
endif |
## Sources |
# |
OUTPUT = cli |
SOURCES = \ |
cli.c |
OBJECTS := $(addsuffix .o,$(basename $(SOURCES))) |
.PHONY: all clean depend disasm |
all: $(OUTPUT) disasm |
-include Makefile.depend |
clean: |
-rm -f $(OUTPUT) $(OUTPUT).map $(OUTPUT).disasm Makefile.depend |
depend: |
$(CC) $(DEFS) $(CFLAGS) -M $(SOURCES) > Makefile.depend |
$(OUTPUT): $(OBJECTS) $(LIBS) |
$(LD) -T $(LIBC_PREFIX)/arch/$(ARCH)/_link.ld $(OBJECTS) $(LIBS) $(LFLAGS) -o $@ -Map $(OUTPUT).map |
disasm: |
$(OBJDUMP) -d $(OUTPUT) >$(OUTPUT).disasm |
%.o: %.S |
$(CC) $(DEFS) $(AFLAGS) $(CFLAGS) -D__ASM__ -c $< -o $@ |
%.o: %.s |
$(AS) $(AFLAGS) $< -o $@ |
%.o: %.c |
$(CC) $(DEFS) $(CFLAGS) -c $< -o $@ |