/branches/dd/uspace/app/init/init.c |
---|
45,7 → 45,6 |
#include <malloc.h> |
#include <macros.h> |
#include <console.h> |
#include <string.h> |
#include "init.h" |
#include "version.h" |
52,13 → 51,9 |
static bool mount_fs(const char *fstype) |
{ |
int rc = -1; |
char *opts = ""; |
if (str_cmp(fstype, "tmpfs") == 0) |
opts = "restore"; |
while (rc < 0) { |
rc = mount(fstype, "/", "initrd", opts, IPC_FLAG_BLOCKING); |
rc = mount(fstype, "/", "initrd", IPC_FLAG_BLOCKING); |
switch (rc) { |
case EOK: |
79,32 → 74,6 |
return true; |
} |
static bool mount_devfs(void) |
{ |
int rc = -1; |
while (rc < 0) { |
rc = mount("devfs", "/dev", "null", "", IPC_FLAG_BLOCKING); |
switch (rc) { |
case EOK: |
printf(NAME ": Device filesystem mounted\n"); |
break; |
case EBUSY: |
printf(NAME ": Device filesystem already mounted\n"); |
break; |
case ELIMIT: |
printf(NAME ": Unable to mount device filesystem\n"); |
return false; |
case ENOENT: |
printf(NAME ": Unknown filesystem type (devfs)\n"); |
return false; |
} |
} |
return true; |
} |
static void spawn(char *fname) |
{ |
char *argv[2]; |
114,8 → 83,12 |
argv[0] = fname; |
argv[1] = NULL; |
if (!task_spawn(fname, argv)) |
if (task_spawn(fname, argv)) { |
/* Add reasonable delay to avoid intermixed klog output. */ |
usleep(10000); |
} else { |
printf(NAME ": Error spawning %s\n", fname); |
} |
} |
int main(int argc, char *argv[]) |
127,13 → 100,6 |
return -1; |
} |
spawn("/srv/devfs"); |
if (!mount_devfs()) { |
return(NAME ": Exiting\n"); |
return -2; |
} |
spawn("/srv/fb"); |
spawn("/srv/kbd"); |
spawn("/srv/console"); |
/branches/dd/uspace/app/init/Makefile |
---|
69,7 → 69,7 |
disasm: $(OUTPUT).disasm |
$(OUTPUT).disasm: $(OUTPUT) |
$(OBJDUMP) -d $< > $@ |
$(OBJDUMP) -d $< >$@ |
%.o: %.S |
$(CC) $(DEFS) $(AFLAGS) $(CFLAGS) -D__ASM__ -c $< -o $@ |
/branches/dd/uspace/app/bdsh/cmds/modules/mv/mv.c |
---|
File deleted |
/branches/dd/uspace/app/bdsh/cmds/modules/mv/mv_def.h |
---|
File deleted |
/branches/dd/uspace/app/bdsh/cmds/modules/mv/entry.h |
---|
File deleted |
/branches/dd/uspace/app/bdsh/cmds/modules/mv/mv.h |
---|
File deleted |
/branches/dd/uspace/app/bdsh/cmds/modules/bdd/entry.h |
---|
File deleted |
/branches/dd/uspace/app/bdsh/cmds/modules/bdd/bdd.c |
---|
File deleted |
/branches/dd/uspace/app/bdsh/cmds/modules/bdd/bdd_def.h |
---|
File deleted |
/branches/dd/uspace/app/bdsh/cmds/modules/bdd/bdd.h |
---|
File deleted |
/branches/dd/uspace/app/bdsh/cmds/modules/mount/mount.c |
---|
File deleted |
/branches/dd/uspace/app/bdsh/cmds/modules/mount/mount_def.h |
---|
File deleted |
/branches/dd/uspace/app/bdsh/cmds/modules/mount/entry.h |
---|
File deleted |
/branches/dd/uspace/app/bdsh/cmds/modules/mount/mount.h |
---|
File deleted |
/branches/dd/uspace/app/bdsh/cmds/modules/modules.h |
---|
20,7 → 20,6 |
#include "help/entry.h" |
#include "mkdir/entry.h" |
#include "rm/entry.h" |
#include "bdd/entry.h" |
#include "cat/entry.h" |
#include "touch/entry.h" |
#include "ls/entry.h" |
27,8 → 26,6 |
#include "pwd/entry.h" |
#include "sleep/entry.h" |
#include "cp/entry.h" |
#include "mv/entry.h" |
#include "mount/entry.h" |
#include "kcon/entry.h" |
/* Each .def function fills the module_t struct with the individual name, entry |
39,7 → 36,6 |
#include "help/help_def.h" |
#include "mkdir/mkdir_def.h" |
#include "rm/rm_def.h" |
#include "bdd/bdd_def.h" |
#include "cat/cat_def.h" |
#include "touch/touch_def.h" |
#include "ls/ls_def.h" |
46,10 → 42,7 |
#include "pwd/pwd_def.h" |
#include "sleep/sleep_def.h" |
#include "cp/cp_def.h" |
#include "mv/mv_def.h" |
#include "mount/mount_def.h" |
#include "kcon/kcon_def.h" |
{NULL, NULL, NULL, NULL} |
}; |
/branches/dd/uspace/app/bdsh/cmds/modules/cat/cat.c |
---|
87,8 → 87,7 |
off_t total = 0; |
char *buff = NULL; |
fd = open(fname, O_RDONLY); |
if (fd < 0) { |
if (-1 == (fd = open(fname, O_RDONLY))) { |
printf("Unable to open %s\n", fname); |
return 1; |
} |
/branches/dd/uspace/app/bdsh/cmds/modules/module_aliases.h |
---|
12,7 → 12,6 |
* the entry point being reached. */ |
char *mod_aliases[] = { |
"ren", "mv", |
NULL, NULL |
}; |
/branches/dd/uspace/app/bdsh/Makefile |
---|
33,13 → 33,12 |
LIBC_PREFIX = ../../lib/libc |
SOFTINT_PREFIX = ../../lib/softint |
LIBBLOCK_PREFIX = ../../lib/libblock |
include $(LIBC_PREFIX)/Makefile.toolchain |
CFLAGS += -I../../srv/kbd/include -I$(LIBBLOCK_PREFIX) |
CFLAGS += -I../../srv/kbd/include |
LIBS = $(LIBBLOCK_PREFIX)/libblock.a $(LIBC_PREFIX)/libc.a |
LIBS = $(LIBC_PREFIX)/libc.a |
DEFS += -DRELEASE=$(RELEASE) |
PROGRAM = bdsh |
52,7 → 51,6 |
cmds/modules/help/ \ |
cmds/modules/mkdir/ \ |
cmds/modules/rm/ \ |
cmds/modules/bdd/ \ |
cmds/modules/cat/ \ |
cmds/modules/touch/ \ |
cmds/modules/ls/ \ |
59,8 → 57,6 |
cmds/modules/pwd/ \ |
cmds/modules/sleep/ \ |
cmds/modules/cp/ \ |
cmds/modules/mv/ \ |
cmds/modules/mount/ \ |
cmds/modules/kcon/ \ |
cmds/builtins/ \ |
cmds/builtins/exit/\ |
70,7 → 66,6 |
cmds/modules/help/help.c \ |
cmds/modules/mkdir/mkdir.c \ |
cmds/modules/rm/rm.c \ |
cmds/modules/bdd/bdd.c \ |
cmds/modules/cat/cat.c \ |
cmds/modules/touch/touch.c \ |
cmds/modules/ls/ls.c \ |
77,8 → 72,6 |
cmds/modules/pwd/pwd.c \ |
cmds/modules/sleep/sleep.c \ |
cmds/modules/cp/cp.c \ |
cmds/modules/mv/mv.c \ |
cmds/modules/mount/mount.c \ |
cmds/modules/kcon/kcon.c \ |
cmds/builtins/exit/exit.c \ |
cmds/builtins/cd/cd.c \ |
/branches/dd/uspace/app/tester/tester.c |
---|
56,7 → 56,6 |
#include "ipc/send_sync.def" |
#include "ipc/answer.def" |
#include "ipc/hangup.def" |
#include "ipc/ping_pong.def" |
#include "devmap/devmap1.def" |
#include "loop/loop1.def" |
#include "vfs/vfs1.def" |
/branches/dd/uspace/app/tester/devmap/devmap1.c |
---|
32,7 → 32,7 |
#include <ipc/services.h> |
#include <async.h> |
#include <errno.h> |
#include <devmap.h> |
#include <ipc/devmap.h> |
#include "../tester.h" |
#include <time.h> |
84,14 → 84,22 |
handle = (int)arg; |
device_phone = devmap_device_connect(handle, 0); |
device_phone = ipc_connect_me_to(PHONE_NS, SERVICE_DEVMAP, |
DEVMAP_CONNECT_TO_DEVICE, handle); |
if (device_phone < 0) { |
printf("Failed to connect to device (handle = %u).\n", |
printf("Failed to connect to devmap as client (handle = %u).\n", |
handle); |
return -1; |
} |
/* |
* device_phone = (int) IPC_GET_ARG5(answer); |
*/ |
printf("Connected to device.\n"); |
ipc_call_sync_1_0(device_phone, 1024, 1025); |
/* |
* ipc_hangup(device_phone); |
*/ |
ipc_hangup(device_phone); |
return EOK; |
113,6 → 121,126 |
return EOK; |
} |
/** |
* |
*/ |
static int driver_register(char *name) |
{ |
ipcarg_t retval; |
aid_t req; |
ipc_call_t answer; |
int phone; |
ipcarg_t callback_phonehash; |
phone = ipc_connect_me_to_blocking(PHONE_NS, SERVICE_DEVMAP, DEVMAP_DRIVER, 0); |
if (phone < 0) { |
printf("Failed to connect to device mapper\n"); |
return -1; |
} |
req = async_send_2(phone, DEVMAP_DRIVER_REGISTER, 0, 0, &answer); |
retval = ipc_data_write_start(phone, (char *)name, str_size(name) + 1); |
if (retval != EOK) { |
async_wait_for(req, NULL); |
return -1; |
} |
async_set_client_connection(driver_client_connection); |
ipc_connect_to_me(phone, 0, 0, 0, &callback_phonehash); |
/* |
if (NULL == async_new_connection(callback_phonehash, 0, NULL, |
driver_client_connection)) { |
printf("Failed to create new fibril.\n"); |
async_wait_for(req, NULL); |
return -1; |
} |
*/ |
async_wait_for(req, &retval); |
printf("Driver '%s' registered.\n", name); |
return phone; |
} |
static int device_get_handle(int driver_phone, char *name, int *handle) |
{ |
ipcarg_t retval; |
aid_t req; |
ipc_call_t answer; |
req = async_send_2(driver_phone, DEVMAP_DEVICE_GET_HANDLE, 0, 0, |
&answer); |
retval = ipc_data_write_start(driver_phone, name, str_size(name) + 1); |
if (retval != EOK) { |
printf("Failed to send device name '%s'.\n", name); |
async_wait_for(req, NULL); |
return retval; |
} |
async_wait_for(req, &retval); |
if (NULL != handle) { |
*handle = -1; |
} |
if (EOK == retval) { |
if (NULL != handle) { |
*handle = (int) IPC_GET_ARG1(answer); |
} |
printf("Device '%s' has handle %u.\n", name, |
(int) IPC_GET_ARG1(answer)); |
} else { |
printf("Failed to get handle for device '%s'.\n", name); |
} |
return retval; |
} |
/** Register new device. |
* @param driver_phone |
* @param name Device name. |
* @param handle Output variable. Handle to the created instance of device. |
*/ |
static int device_register(int driver_phone, char *name, int *handle) |
{ |
ipcarg_t retval; |
aid_t req; |
ipc_call_t answer; |
req = async_send_2(driver_phone, DEVMAP_DEVICE_REGISTER, 0, 0, &answer); |
retval = ipc_data_write_start(driver_phone, (char *)name, |
str_size(name) + 1); |
if (retval != EOK) { |
printf("Failed to send device name '%s'.\n", name); |
async_wait_for(req, NULL); |
return retval; |
} |
async_wait_for(req, &retval); |
if (NULL != handle) { |
*handle = -1; |
} |
if (EOK == retval) { |
if (NULL != handle) { |
*handle = (int) IPC_GET_ARG1(answer); |
} |
printf("Device registered with handle %u.\n", |
(int) IPC_GET_ARG1(answer)); |
} |
return retval; |
} |
/** Test DevMap from the driver's point of view. |
* |
* |
119,71 → 247,64 |
*/ |
char * test_devmap1(bool quiet) |
{ |
const char *retval = NULL; |
int driver_phone; |
int dev1_handle; |
int dev2_handle; |
int dev3_handle; |
int handle; |
/* Register new driver */ |
int rc = devmap_driver_register("TestDriver", driver_client_connection); |
if (rc < 0) { |
retval = "Error: Cannot register driver.\n"; |
goto out; |
driver_phone = driver_register("TestDriver"); |
if (driver_phone < 0) { |
return "Error: Cannot register driver.\n"; |
} |
/* Register new device dev1. */ |
dev_handle_t dev1_handle; |
rc = devmap_device_register(TEST_DEVICE1, &dev1_handle); |
if (rc != EOK) { |
retval = "Error: cannot register device.\n"; |
goto out; |
/* Register new device dev1*/ |
if (EOK != device_register(driver_phone, TEST_DEVICE1, &dev1_handle)) { |
ipc_hangup(driver_phone); |
return "Error: cannot register device.\n"; |
} |
/* |
* Get handle for dev2 (Should fail unless device is already registered |
* by someone else). |
/* Get handle for dev2 (Should fail unless device is already |
* registered by someone else) |
*/ |
dev_handle_t handle; |
rc = devmap_device_get_handle(TEST_DEVICE2, &handle, 0); |
if (rc == EOK) { |
retval = "Error: got handle for dev2 before it was registered.\n"; |
goto out; |
if (EOK == device_get_handle(driver_phone, TEST_DEVICE2, &handle)) { |
ipc_hangup(driver_phone); |
return "Error: got handle for dev2 before it was registered.\n"; |
} |
/* Register new device dev2. */ |
dev_handle_t dev2_handle; |
rc = devmap_device_register(TEST_DEVICE2, &dev2_handle); |
if (rc != EOK) { |
retval = "Error: cannot register device dev2.\n"; |
goto out; |
/* Register new device dev2*/ |
if (EOK != device_register(driver_phone, TEST_DEVICE2, &dev2_handle)) { |
ipc_hangup(driver_phone); |
return "Error: cannot register device dev2.\n"; |
} |
/* Register device dev1 again. */ |
dev_handle_t dev3_handle; |
rc = devmap_device_register(TEST_DEVICE1, &dev3_handle); |
if (rc == EOK) { |
retval = "Error: dev1 registered twice.\n"; |
goto out; |
/* Register again device dev1 */ |
if (EOK == device_register(driver_phone, TEST_DEVICE1, &dev3_handle)) { |
return "Error: dev1 registered twice.\n"; |
} |
/* Get handle for dev1. */ |
rc = devmap_device_get_handle(TEST_DEVICE1, &handle, 0); |
if (rc != EOK) { |
retval = "Error: cannot get handle for 'DEVMAP_DEVICE1'.\n"; |
goto out; |
/* Get handle for dev1*/ |
if (EOK != device_get_handle(driver_phone, TEST_DEVICE1, &handle)) { |
ipc_hangup(driver_phone); |
return "Error: cannot get handle for 'DEVMAP_DEVICE1'.\n"; |
} |
if (handle != dev1_handle) { |
retval = "Error: cannot get handle for 'DEVMAP_DEVICE1'.\n"; |
goto out; |
ipc_hangup(driver_phone); |
return "Error: cannot get handle for 'DEVMAP_DEVICE1'.\n"; |
} |
if (device_client(dev1_handle) != EOK) { |
retval = "Error: failed client test for 'DEVMAP_DEVICE1'.\n"; |
goto out; |
if (EOK != device_client(dev1_handle)) { |
ipc_hangup(driver_phone); |
return "Error: failed client test for 'DEVMAP_DEVICE1'.\n"; |
} |
out: |
devmap_hangup_phone(DEVMAP_DRIVER); |
devmap_hangup_phone(DEVMAP_CLIENT); |
/* TODO: */ |
ipc_hangup(driver_phone); |
return NULL; |
} |
/branches/dd/uspace/app/tester/tester.h |
---|
69,7 → 69,6 |
extern char * test_send_sync(bool quiet); |
extern char * test_answer(bool quiet); |
extern char * test_hangup(bool quiet); |
extern char * test_ping_pong(bool quiet); |
extern char * test_devmap1(bool quiet); |
extern char * test_loop1(bool quiet); |
extern char * test_vfs1(bool quiet); |
/branches/dd/uspace/app/tester/Makefile |
---|
54,7 → 54,6 |
ipc/send_sync.c \ |
ipc/answer.c \ |
ipc/hangup.c \ |
ipc/ping_pong.c \ |
loop/loop1.c \ |
devmap/devmap1.c \ |
console/console1.c \ |
82,7 → 81,7 |
disasm: $(OUTPUT).disasm |
$(OUTPUT).disasm: $(OUTPUT) |
$(OBJDUMP) -d $< > $@ |
$(OBJDUMP) -d $< >$@ |
%.o: %.S |
$(CC) $(DEFS) $(AFLAGS) $(CFLAGS) -D__ASM__ -c $< -o $@ |
/branches/dd/uspace/app/tester/ipc/ping_pong.c |
---|
File deleted |
/branches/dd/uspace/app/tester/ipc/ping_pong.def |
---|
File deleted |
/branches/dd/uspace/app/tester/vfs/vfs1.c |
---|
45,7 → 45,7 |
{ |
int rc; |
rc = mount("tmpfs", "/", "nulldev0", "", 0); |
rc = mount("tmpfs", "/", "nulldev0", 0); |
switch (rc) { |
case EOK: |
if (!quiet) |
/branches/dd/uspace/app/tetris/input.c |
---|
115,7 → 115,7 |
if (!lastchar) { |
again: |
if (!getchar_inprog) { |
cons_phone = console_open(true); |
cons_phone = console_phone_get(true); |
getchar_inprog = async_send_2(cons_phone, |
CONSOLE_GETKEY, 0, 0, &charcall); |
} |
/branches/dd/uspace/app/tetris/Makefile |
---|
27,7 → 27,7 |
disasm: $(OUTPUT).disasm |
$(OUTPUT).disasm: $(OUTPUT) |
$(OBJDUMP) -d $< > $@ |
$(OBJDUMP) -d $< >$@ |
%.o: %.S |
$(CC) $(DEFS) $(AFLAGS) $(CFLAGS) -D__ASM__ -c $< -o $@ |
/branches/dd/uspace/app/klog/Makefile |
---|
64,7 → 64,7 |
disasm: $(OUTPUT).disasm |
$(OUTPUT).disasm: $(OUTPUT) |
$(OBJDUMP) -d $< > $@ |
$(OBJDUMP) -d $< >$@ |
%.o: %.S |
$(CC) $(DEFS) $(AFLAGS) $(CFLAGS) -D__ASM__ -c $< -o $@ |
/branches/dd/uspace/app/trace/trace.c |
---|
666,8 → 666,6 |
arg_def[0] = V_CHAR; |
o = oper_new("putchar", 1, arg_def, V_VOID, 0, resp_def); |
proto_add_oper(p, CONSOLE_PUTCHAR, o); |
o = oper_new("write", 0, arg_def, V_VOID, 0, resp_def); |
proto_add_oper(p, CONSOLE_WRITE, o); |
o = oper_new("clear", 0, arg_def, V_VOID, 0, resp_def); |
proto_add_oper(p, CONSOLE_CLEAR, o); |