/branches/dynload/kernel/generic/include/mm/as.h |
---|
304,6 → 304,7 |
* This flags is passed when running the loader, otherwise elf_load() |
* would return with a EE_LOADER error code. |
*/ |
#define ELD_F_NONE 0 |
#define ELD_F_LOADER 1 |
extern unsigned int elf_load(elf_header_t *header, as_t *as, int flags); |
/branches/dynload/kernel/generic/include/syscall/syscall.h |
---|
44,6 → 44,7 |
SYS_THREAD_GET_ID, |
SYS_TASK_GET_ID, |
SYS_TASK_SPAWN, |
SYS_TASK_SPAWN_LOADER, |
SYS_FUTEX_SLEEP, |
/branches/dynload/kernel/generic/src/proc/task.c |
---|
249,7 → 249,7 |
* |
* @return Task of the running program or NULL on error. |
*/ |
task_t *task_create_from_as(as_t *as, uintptr_t entry_addr, char *name |
task_t *task_create_from_as(as_t *as, uintptr_t entry_addr, char *name, |
thread_t **thr) |
{ |
as_area_t *a; |
310,7 → 310,7 |
rc = elf_load((elf_header_t *) program_addr, as, 0); |
if (rc != EE_OK) { |
as_destroy(as); |
*task = NULL; |
*t = NULL; |
if (rc != EE_LOADER) |
return ENOTSUP; |
338,6 → 338,7 |
as_t *as; |
unsigned int rc; |
void *loader; |
thread_t *thr; |
as = as_create(0); |
ASSERT(as); |
352,7 → 353,7 |
} |
*t = task_create_from_as( |
as, ((elf_header_t *) program_loader)->e_entry, name); |
as, ((elf_header_t *) program_loader)->e_entry, name, &thr); |
return EOK; |
} |
467,7 → 468,7 |
return ENOMEM; |
} |
unsigned int erc = elf_load((elf_header_t *) kimage, as); |
unsigned int erc = elf_load((elf_header_t *) kimage, as, ELD_F_NONE); |
if (erc != EE_OK) { |
as_destroy(as); |
free(kernel_uarg); |
/branches/dynload/kernel/generic/src/proc/thread.c |
---|
706,7 → 706,7 |
return NULL; |
} |
rc = elf_load((elf_header_t *) program_addr, as); |
rc = elf_load((elf_header_t *) program_addr, as, ELD_F_NONE); |
if (rc != EE_OK) { |
free(kernel_uarg); |
as_destroy(as); |
/branches/dynload/kernel/generic/src/syscall/syscall.c |
---|
93,7 → 93,7 |
/** Print a hex integer into klog */ |
static unative_t sys_debug_putint(unative_t i) |
{ |
klog_printf("[task:0x%x]", i); |
printf("[task:0x%x]", i); |
return 0; |
} |
/branches/dynload/kernel/generic/src/ipc/ipc.c |
---|
573,7 → 573,7 |
spinlock_lock(&task->answerbox.lock); |
printf("ABOX - CALLS:\n"); |
for (tmp = task->answerbox.calls.next; tmp != &task->answerbox.calls; |
tmp = tmp->next) { |
tmp = tmp->next) { |
call = list_get_instance(tmp, call_t, link); |
printf("Callid: %p Srctask:%" PRIu64 " M:%" PRIun |
" A1:%" PRIun " A2:%" PRIun " A3:%" PRIun |
586,8 → 586,8 |
/* Print answerbox - calls */ |
printf("ABOX - DISPATCHED CALLS:\n"); |
for (tmp = task->answerbox.dispatched_calls.next; |
tmp != &task->answerbox.dispatched_calls; |
tmp = tmp->next) { |
tmp != &task->answerbox.dispatched_calls; |
tmp = tmp->next) { |
call = list_get_instance(tmp, call_t, link); |
printf("Callid: %p Srctask:%" PRIu64 " M:%" PRIun |
" A1:%" PRIun " A2:%" PRIun " A3:%" PRIun |
600,7 → 600,7 |
/* Print answerbox - calls */ |
printf("ABOX - ANSWERS:\n"); |
for (tmp = task->answerbox.answers.next; tmp != &task->answerbox.answers; |
tmp = tmp->next) { |
tmp = tmp->next) { |
call = list_get_instance(tmp, call_t, link); |
printf("Callid:%p M:%" PRIun " A1:%" PRIun " A2:%" PRIun |
" A3:%" PRIun " A4:%" PRIun " A5:%" PRIun " Flags:%x\n", |
/branches/dynload/uspace/app/init/init.c |
---|
34,30 → 34,107 |
* @file |
*/ |
#include <stdio.h> |
#include <unistd.h> |
#include <vfs/vfs.h> |
#include <bool.h> |
#include <errno.h> |
#include <fcntl.h> |
#include <task.h> |
#include <malloc.h> |
#include "init.h" |
#include "version.h" |
#include <stdio.h> |
static void test_console(void) |
#define BUF_SIZE 150000 |
static char *buf; |
static void console_wait(void) |
{ |
int c; |
while (get_cons_phone() < 0) |
usleep(50000); // FIXME |
} |
while ((c = getchar()) != EOF) |
putchar(c); |
static bool mount_tmpfs(void) |
{ |
int rc = -1; |
while (rc < 0) { |
rc = mount("tmpfs", "/", "initrd"); |
switch (rc) { |
case EOK: |
printf(NAME ": Root filesystem mounted\n"); |
break; |
case EBUSY: |
printf(NAME ": Root filesystem already mounted\n"); |
break; |
case ELIMIT: |
printf(NAME ": Unable to mount root filesystem\n"); |
return false; |
default: |
sleep(5); // FIXME |
} |
} |
return true; |
} |
static void spawn(char *fname) |
{ |
printf(NAME ": Spawning %s\n", fname); |
int fd = open(fname, O_RDONLY); |
if (fd >= 0) { |
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 |
} |
close(fd); |
} |
} |
int main(int argc, char *argv[]) |
{ |
info_print(); |
sleep(5); // FIXME |
if (!mount_tmpfs()) { |
printf(NAME ": Exiting\n"); |
return -1; |
} |
buf = malloc(BUF_SIZE); |
// FIXME: spawn("/sbin/pci"); |
spawn("/sbin/fb"); |
spawn("/sbin/kbd"); |
spawn("/sbin/console"); |
console_wait(); |
version_print(); |
printf("This is init\n"); |
test_console(); |
printf("\nBye.\n"); |
spawn("/sbin/fat"); |
spawn("/sbin/tetris"); |
// FIXME: spawn("/sbin/tester"); |
// FIXME: spawn("/sbin/klog"); |
free(buf); |
return 0; |
} |
/** @} |
*/ |
/branches/dynload/uspace/app/init/version.c |
---|
35,6 → 35,7 |
#include <unistd.h> |
#include <stdio.h> |
#include "init.h" |
#include "version.h" |
char *release = RELEASE; |
51,6 → 52,11 |
char *timestamp = ""; |
#endif |
void info_print(void) |
{ |
printf(NAME ": HelenOS init\n"); |
} |
/** Print version information. */ |
void version_print(void) |
{ |
/branches/dynload/uspace/app/init/init.h |
---|
36,7 → 36,7 |
#ifndef __INIT_H__ |
#define __INIT_H__ |
#include "version.h" |
#define NAME "init" |
#endif |
/branches/dynload/uspace/app/init/version.h |
---|
36,6 → 36,7 |
#ifndef __VERSION_H__ |
#define __VERSION_H__ |
extern void info_print(void); |
extern void version_print(void); |
#endif |
/branches/dynload/uspace/app/tester/devmap/devmap1.c |
---|
32,7 → 32,7 |
#include <ipc/services.h> |
#include <async.h> |
#include <errno.h> |
#include <../../../srv/devmap/devmap.h> |
#include <ipc/devmap.h> |
#include "../tester.h" |
#include <time.h> |
/branches/dynload/uspace/app/tetris/scores.c |
---|
52,7 → 52,7 |
/* #include <err.h> */ |
/* #include <fcntl.h> */ |
/* #include <pwd.h> */ |
#include <stdio.h> |
#include <stdio.h> |
/* #include <stdlib.h> */ |
#include <string.h> |
/* #include <time.h> */ |
/branches/dynload/uspace/lib/libc/include/task.h |
---|
40,7 → 40,8 |
typedef uint64_t task_id_t; |
extern task_id_t task_get_id(void); |
task_id_t task_spawn(const char *path, const char *argv[]); |
task_id_t task_spawn_ex(const char *path, const char *argv[]); |
extern int task_spawn(void *image, size_t size); |
#endif |
/branches/dynload/uspace/lib/libc/include/libc.h |
---|
49,7 → 49,6 |
__syscall(p1, p2, p3, p4, p5, p6,id) |
extern void __main(void); |
extern void __io_init(void); |
extern void __exit(void); |
#endif |
/branches/dynload/uspace/lib/libc/include/io/stream.h |
---|
39,8 → 39,7 |
#define EMFILE -17 |
extern void open_stdin(void); |
extern void open_stdout(void); |
extern void open_console(void); |
extern ssize_t read_stdin(void *, size_t); |
extern ssize_t write_stdout(const void *, size_t); |
/branches/dynload/uspace/lib/libc/include/ipc/devmap.h |
---|
0,0 → 1,99 |
/* |
* Copyright (c) 2007 Josef Cejka |
* 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 devmap |
* @{ |
*/ |
#ifndef DEVMAP_DEVMAP_H_ |
#define DEVMAP_DEVMAP_H_ |
#include <ipc/ipc.h> |
#include <libadt/list.h> |
#define DEVMAP_NAME_MAXLEN 512 |
typedef enum { |
DEVMAP_DRIVER_REGISTER = IPC_FIRST_USER_METHOD, |
DEVMAP_DRIVER_UNREGISTER, |
DEVMAP_DEVICE_REGISTER, |
DEVMAP_DEVICE_UNREGISTER, |
DEVMAP_DEVICE_GET_NAME, |
DEVMAP_DEVICE_GET_HANDLE |
} devmap_request_t; |
/** Representation of device driver. |
* Each driver is responsible for a set of devices. |
*/ |
typedef struct { |
/** Pointers to previous and next drivers in linked list */ |
link_t drivers; |
/** Pointer to the linked list of devices controlled by |
* this driver */ |
link_t devices; |
/** Phone asociated with this driver */ |
ipcarg_t phone; |
/** Device driver name */ |
char *name; |
/** Futex for list of devices owned by this driver */ |
atomic_t devices_futex; |
} devmap_driver_t; |
/** Info about registered device |
* |
*/ |
typedef struct { |
/** Pointer to the previous and next device in the list of all devices */ |
link_t devices; |
/** Pointer to the previous and next device in the list of devices |
owned by one driver */ |
link_t driver_devices; |
/** Unique device identifier */ |
int handle; |
/** Device name */ |
char *name; |
/** Device driver handling this device */ |
devmap_driver_t *driver; |
} devmap_device_t; |
/** Interface provided by devmap. |
* Every process that connects to devmap must ask one of following |
* interfaces otherwise connection will be refused. |
*/ |
typedef enum { |
/** Connect as device driver */ |
DEVMAP_DRIVER = 1, |
/** Connect as client */ |
DEVMAP_CLIENT, |
/** Create new connection to instance of device that |
* is specified by second argument of call. */ |
DEVMAP_CONNECT_TO_DEVICE |
} devmap_interface_t; |
#endif |
/branches/dynload/uspace/lib/libc/include/ipc/services.h |
---|
42,7 → 42,6 |
SERVICE_KEYBOARD, |
SERVICE_VIDEO, |
SERVICE_CONSOLE, |
SERVICE_RD, |
SERVICE_VFS, |
SERVICE_DEVMAP |
} services_t; |
/branches/dynload/uspace/lib/libc/generic/task.c |
---|
54,7 → 54,7 |
{ |
int phone_id, rc; |
rc = __SYSCALL1(SYS_TASK_SPAWN, (sysarg_t) &phone_id); |
rc = __SYSCALL1(SYS_TASK_SPAWN_LOADER, (sysarg_t) &phone_id); |
if (rc != 0) |
return rc; |
67,7 → 67,7 |
* @param argv command-line arguments |
* @return ID of the newly created task or zero on error. |
*/ |
task_id_t task_spawn(const char *path, const char *argv[]) |
task_id_t task_spawn_ex(const char *path, const char *argv[]) |
{ |
int phone_id; |
ipc_call_t answer; |
105,5 → 105,10 |
return 1; |
} |
int task_spawn(void *image, size_t size) |
{ |
return __SYSCALL2(SYS_TASK_SPAWN, (sysarg_t) image, (sysarg_t) size); |
} |
/** @} |
*/ |
/branches/dynload/uspace/lib/libc/generic/libc.c |
---|
64,14 → 64,10 |
_async_init(); |
f = fibril_setup(); |
__tcb_set(f->tcb); |
open_console(); |
} |
void __io_init(void) |
{ |
open_stdin(); |
open_stdout(); |
} |
void __exit(void) |
{ |
fibril_teardown(__tcb_get()->fibril_data); |
/branches/dynload/uspace/lib/libc/generic/vfs/vfs.c |
---|
48,6 → 48,7 |
#include <futex.h> |
#include <errno.h> |
#include <string.h> |
#include <ipc/devmap.h> |
#include "../../srv/vfs/vfs.h" |
int vfs_phone = -1; |
102,14 → 103,49 |
return vfs_phone; |
} |
static int device_get_handle(char *name, dev_handle_t *handle) |
{ |
int phone = ipc_connect_me_to(PHONE_NS, SERVICE_DEVMAP, DEVMAP_CLIENT, 0); |
if (phone < 0) |
return phone; |
ipc_call_t answer; |
aid_t req = async_send_2(phone, DEVMAP_DEVICE_GET_HANDLE, 0, 0, |
&answer); |
ipcarg_t retval = ipc_data_write_start(phone, name, strlen(name) + 1); |
if (retval != EOK) { |
async_wait_for(req, NULL); |
ipc_hangup(phone); |
return retval; |
} |
async_wait_for(req, &retval); |
if (handle != NULL) |
*handle = -1; |
if (retval == EOK) { |
if (handle != NULL) |
*handle = (dev_handle_t) IPC_GET_ARG1(answer); |
} |
ipc_hangup(phone); |
return retval; |
} |
int mount(const char *fs_name, const char *mp, const char *dev) |
{ |
int res; |
ipcarg_t rc; |
aid_t req; |
dev_handle_t dev_handle = 0; /* TODO */ |
dev_handle_t dev_handle; |
res = device_get_handle(dev, &dev_handle); |
if (res != EOK) |
return res; |
size_t mpa_len; |
char *mpa = absolutize(mp, &mpa_len); |
if (!mpa) |
/branches/dynload/uspace/lib/libc/generic/io/stream.c |
---|
56,52 → 56,47 |
ssize_t read_stdin(void *buf, size_t count) |
{ |
ipcarg_t r0, r1; |
size_t i = 0; |
while (i < count) { |
if (async_req_0_2(console_phone, CONSOLE_GETCHAR, &r0, |
&r1) < 0) { |
return -1; |
open_console(); |
if (console_phone >= 0) { |
ipcarg_t r0, r1; |
size_t i = 0; |
while (i < count) { |
if (async_req_0_2(console_phone, CONSOLE_GETCHAR, &r0, &r1) < 0) |
return -1; |
((char *) buf)[i++] = r0; |
} |
((char *) buf)[i++] = r0; |
return i; |
} |
return i; |
} |
ssize_t write_stdout(const void *buf, size_t count) |
{ |
int i; |
for (i = 0; i < count; i++) |
async_msg_1(console_phone, CONSOLE_PUTCHAR, |
((const char *) buf)[i]); |
open_console(); |
if (console_phone >= 0) { |
int i; |
return count; |
for (i = 0; i < count; i++) |
async_msg_1(console_phone, CONSOLE_PUTCHAR, |
((const char *) buf)[i]); |
return count; |
} else |
return __SYSCALL3(SYS_IO, 1, (sysarg_t) buf, count); |
} |
void open_stdin(void) |
void open_console(void) |
{ |
if (console_phone < 0) { |
while ((console_phone = ipc_connect_me_to(PHONE_NS, |
SERVICE_CONSOLE, 0, 0)) < 0) { |
usleep(10000); |
} |
int phone = ipc_connect_me_to(PHONE_NS, SERVICE_CONSOLE, 0, 0); |
if (phone >= 0) |
console_phone = phone; |
} |
} |
void open_stdout(void) |
{ |
if (console_phone < 0) { |
while ((console_phone = ipc_connect_me_to(PHONE_NS, |
SERVICE_CONSOLE, 0, 0)) < 0) { |
usleep(10000); |
} |
} |
} |
int get_cons_phone(void) |
{ |
open_console(); |
return console_phone; |
} |
/branches/dynload/uspace/lib/libc/arch/sparc64/src/entry.s |
---|
31,7 → 31,6 |
.org 0 |
.globl __entry |
.globl __entry_driver |
## User-space task entry point |
# |
40,18 → 39,7 |
sethi %hi(_gp), %l7 |
call __main |
or %l7, %lo(_gp), %l7 |
call __io_init |
nop |
call main |
nop |
call __exit |
nop |
__entry_driver: |
sethi %hi(_gp), %l7 |
call __main |
or %l7, %lo(_gp), %l7 |
call main |
nop |
call __exit |
nop |
/branches/dynload/uspace/lib/libc/arch/ppc32/src/entry.s |
---|
31,7 → 31,6 |
.org 0 |
.globl __entry |
.globl __entry_driver |
## User-space task entry point |
# |
38,11 → 37,5 |
# |
__entry: |
bl __main |
bl __io_init |
bl main |
bl __exit |
__entry_driver: |
bl __main |
bl main |
bl __exit |
/branches/dynload/uspace/lib/libc/arch/amd64/src/entry.s |
---|
31,7 → 31,6 |
.org 0 |
.globl __entry |
.globl __entry_driver |
## User-space task entry point |
# |
38,11 → 37,5 |
# |
__entry: |
call __main |
call __io_init |
call main |
call __exit |
__entry_driver: |
call __main |
call main |
call __exit |
/branches/dynload/uspace/lib/libc/arch/ia32/include/config.h |
---|
36,7 → 36,7 |
#define LIBC_ia32_CONFIG_H_ |
#define PAGE_WIDTH 12 |
#define PAGE_SIZE (1<<PAGE_WIDTH) |
#define PAGE_SIZE (1 << PAGE_WIDTH) |
#define PAGE_COLOR_BITS 0 /* dummy */ |
#endif |
/branches/dynload/uspace/lib/libc/arch/ia32/src/entry.s |
---|
31,7 → 31,6 |
.org 0 |
.globl __entry |
.globl __entry_driver |
## User-space task entry point |
# |
44,17 → 43,5 |
# Do not set %gs, it contains descriptor that can see TLS |
call __main |
call __io_init |
call main |
call __exit |
__entry_driver: |
mov %ss, %ax |
mov %ax, %ds |
mov %ax, %es |
mov %ax, %fs |
# Do not set %gs, it contains descriptor that can see TLS |
call __main |
call main |
call __exit |
/branches/dynload/uspace/lib/libc/arch/ia32/src/syscall.S |
---|
53,4 → 53,3 |
popl %esi |
popl %ebx |
ret |
/branches/dynload/uspace/srv/kbd/generic/kbd.c |
---|
50,7 → 50,7 |
#include <async.h> |
#include <keys.h> |
#define NAME "KBD" |
#define NAME "kbd" |
int cons_connected = 0; |
int phone2cons = -1; |
121,6 → 121,8 |
int main(int argc, char **argv) |
{ |
printf(NAME ": HelenOS Keyboard service\n"); |
ipcarg_t phonead; |
/* Initialize arch dependent parts */ |
135,7 → 137,8 |
/* Register service at nameserver */ |
if (ipc_connect_to_me(PHONE_NS, SERVICE_KEYBOARD, 0, 0, &phonead) != 0) |
return -1; |
printf(NAME ": Accepting connections\n"); |
async_manager(); |
/* Never reached */ |
145,4 → 148,3 |
/** |
* @} |
*/ |
/branches/dynload/uspace/srv/kbd/Makefile |
---|
72,11 → 72,9 |
genarch/src/kbd.c |
endif |
ifeq ($(ARCH), arm32) |
ifeq ($(MACHINE), gxemul_testarm) |
ARCH_SOURCES += \ |
arch/$(ARCH)/src/kbd_gxemul.c |
endif |
endif |
GENERIC_OBJECTS := $(addsuffix .o,$(basename $(GENERIC_SOURCES))) |
100,7 → 98,7 |
$(CC) $(DEFS) $(CFLAGS) -M $(SOURCES) > Makefile.depend |
$(OUTPUT): $(ARCH_OBJECTS) $(GENERIC_OBJECTS) $(GENARCH_OBJECTS) $(LIBS) |
$(LD) -T $(LIBC_PREFIX)/arch/$(ARCH)/_link.ld -e __entry_driver $(GENERIC_OBJECTS) $(ARCH_OBJECTS) $(GENARCH_OBJECTS) $(LIBS) $(LFLAGS) -o $@ -Map $(OUTPUT).map |
$(LD) -T $(LIBC_PREFIX)/arch/$(ARCH)/_link.ld $(GENERIC_OBJECTS) $(ARCH_OBJECTS) $(GENARCH_OBJECTS) $(LIBS) $(LFLAGS) -o $@ -Map $(OUTPUT).map |
disasm: |
$(OBJDUMP) -d $(OUTPUT) >$(OUTPUT).disasm |
/branches/dynload/uspace/srv/ns/ns.c |
---|
50,7 → 50,7 |
#include <ddi.h> |
#include <as.h> |
#define NAME "NS" |
#define NAME "ns" |
#define NS_HASH_TABLE_CHAINS 20 |
104,6 → 104,8 |
int main(int argc, char **argv) |
{ |
printf(NAME ": HelenOS IPC Naming Service\n"); |
ipc_call_t call; |
ipc_callid_t callid; |
111,9 → 113,11 |
if (!hash_table_create(&ns_hash_table, NS_HASH_TABLE_CHAINS, 3, |
&ns_hash_table_ops)) { |
printf(NAME ": No memory available\n"); |
return ENOMEM; |
} |
printf(NAME ": Accepting connections\n"); |
while (1) { |
callid = ipc_wait_for_call(&call); |
switch (IPC_GET_METHOD(call)) { |
156,6 → 160,9 |
ipc_answer_0(callid, retval); |
} |
} |
/* Not reached */ |
return 0; |
} |
/** Register service. |
/branches/dynload/uspace/srv/ns/Makefile |
---|
57,7 → 57,7 |
$(CC) $(DEFS) $(CFLAGS) -M $(SOURCES) > Makefile.depend |
$(OUTPUT): $(OBJECTS) $(LIBS) |
$(LD) -T $(LIBC_PREFIX)/arch/$(ARCH)/_link.ld -e __entry_driver $(OBJECTS) $(LIBS) $(LFLAGS) -o $@ -Map $(OUTPUT).map |
$(LD) -T $(LIBC_PREFIX)/arch/$(ARCH)/_link.ld $(OBJECTS) $(LIBS) $(LFLAGS) -o $@ -Map $(OUTPUT).map |
disasm: |
$(OBJDUMP) -d $(OUTPUT) >$(OUTPUT).disasm |
/branches/dynload/uspace/srv/console/console.c |
---|
46,12 → 46,13 |
#include <libadt/fifo.h> |
#include <screenbuffer.h> |
#include <sys/mman.h> |
#include <stdio.h> |
#include "gcons.h" |
#define MAX_KEYREQUESTS_BUFFERED 32 |
#define NAME "CONSOLE" |
#define NAME "console" |
/** Index of currently used virtual console. |
*/ |
474,6 → 475,8 |
int main(int argc, char *argv[]) |
{ |
printf(NAME ": HelenOS Console service\n"); |
ipcarg_t phonehash; |
int kbd_phone; |
int i; |
550,10 → 553,11 |
connections[active_console].screenbuffer.is_cursor_visible); |
/* Register at NS */ |
if (ipc_connect_to_me(PHONE_NS, SERVICE_CONSOLE, 0, 0, &phonehash) != 0) { |
if (ipc_connect_to_me(PHONE_NS, SERVICE_CONSOLE, 0, 0, &phonehash) != 0) |
return -1; |
} |
// FIXME: avoid connectiong to itself, keep using klog |
// printf(NAME ": Accepting connections\n"); |
async_manager(); |
return 0; |
/branches/dynload/uspace/srv/console/Makefile |
---|
70,7 → 70,7 |
$(CC) $(DEFS) $(CFLAGS) -M $(SOURCES) > Makefile.depend |
$(OUTPUT): $(ARCH_OBJECTS) $(GENERIC_OBJECTS) $(LIBS) |
$(LD) -T $(LIBC_PREFIX)/arch/$(ARCH)/_link.ld -e __entry_driver $(GENERIC_OBJECTS) $(ARCH_OBJECTS) $(LIBS) $(LFLAGS) -o $@ -Map $(OUTPUT).map |
$(LD) -T $(LIBC_PREFIX)/arch/$(ARCH)/_link.ld $(GENERIC_OBJECTS) $(ARCH_OBJECTS) $(LIBS) $(LFLAGS) -o $@ -Map $(OUTPUT).map |
disasm: |
$(OBJDUMP) -d $(OUTPUT) >$(OUTPUT).disasm |
/branches/dynload/uspace/srv/rd/rd.c |
---|
51,8 → 51,12 |
#include <align.h> |
#include <async.h> |
#include <futex.h> |
#include <stdio.h> |
#include <ipc/devmap.h> |
#include "rd.h" |
#define NAME "rd" |
/** Pointer to the ramdisk's image. */ |
static void *rd_addr; |
/** Size of the ramdisk. */ |
104,7 → 108,8 |
* Now we wait for the client to send us its communication as_area. |
*/ |
size_t size; |
if (ipc_share_out_receive(&callid, &size, NULL)) { |
int flags; |
if (ipc_share_out_receive(&callid, &size, &flags)) { |
if (size >= BLOCK_SIZE) { |
/* |
* The client sends an as_area that can absorb the whole |
149,7 → 154,7 |
break; |
} |
futex_down(&rd_futex); |
memcpy(fs_va, rd_addr + offset, BLOCK_SIZE); |
memcpy(fs_va, rd_addr + offset * BLOCK_SIZE, BLOCK_SIZE); |
futex_up(&rd_futex); |
retval = EOK; |
break; |
163,7 → 168,7 |
break; |
} |
futex_up(&rd_futex); |
memcpy(rd_addr + offset, fs_va, BLOCK_SIZE); |
memcpy(rd_addr + offset * BLOCK_SIZE, fs_va, BLOCK_SIZE); |
futex_down(&rd_futex); |
retval = EOK; |
break; |
181,46 → 186,119 |
} |
} |
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(PHONE_NS, SERVICE_DEVMAP, DEVMAP_DRIVER, 0); |
while (phone < 0) { |
usleep(10000); |
phone = ipc_connect_me_to(PHONE_NS, SERVICE_DEVMAP, |
DEVMAP_DRIVER, 0); |
} |
req = async_send_2(phone, DEVMAP_DRIVER_REGISTER, 0, 0, &answer); |
retval = ipc_data_write_start(phone, (char *) name, strlen(name) + 1); |
if (retval != EOK) { |
async_wait_for(req, NULL); |
return -1; |
} |
async_set_client_connection(rd_connection); |
ipc_connect_to_me(phone, 0, 0, 0, &callback_phonehash); |
async_wait_for(req, &retval); |
return phone; |
} |
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, strlen(name) + 1); |
if (retval != EOK) { |
async_wait_for(req, NULL); |
return retval; |
} |
async_wait_for(req, &retval); |
if (handle != NULL) |
*handle = -1; |
if (EOK == retval) { |
if (NULL != handle) |
*handle = (int) IPC_GET_ARG1(answer); |
} |
return retval; |
} |
/** Prepare the ramdisk image for operation. */ |
static bool rd_init(void) |
{ |
int retval, flags; |
rd_size = sysinfo_value("rd.size"); |
void *rd_ph_addr = (void *) sysinfo_value("rd.address.physical"); |
if (rd_size == 0) |
if (rd_size == 0) { |
printf(NAME ": No RAM disk found\n"); |
return false; |
} |
rd_addr = as_get_mappable_page(rd_size); |
flags = AS_AREA_READ | AS_AREA_WRITE | AS_AREA_CACHEABLE; |
retval = physmem_map(rd_ph_addr, rd_addr, |
int flags = AS_AREA_READ | AS_AREA_WRITE | AS_AREA_CACHEABLE; |
int retval = physmem_map(rd_ph_addr, rd_addr, |
ALIGN_UP(rd_size, PAGE_SIZE) >> PAGE_WIDTH, flags); |
if (retval < 0) |
if (retval < 0) { |
printf(NAME ": Error mapping RAM disk\n"); |
return false; |
} |
printf(NAME ": Found RAM disk at %p, %d bytes\n", rd_ph_addr, rd_size); |
int driver_phone = driver_register(NAME); |
if (driver_phone < 0) { |
printf(NAME ": Unable to register driver\n"); |
return false; |
} |
int dev_handle; |
if (EOK != device_register(driver_phone, "initrd", &dev_handle)) { |
ipc_hangup(driver_phone); |
printf(NAME ": Unable to register device\n"); |
return false; |
} |
return true; |
} |
int main(int argc, char **argv) |
{ |
if (rd_init()) { |
ipcarg_t phonead; |
async_set_client_connection(rd_connection); |
/* Register service at nameserver */ |
if (ipc_connect_to_me(PHONE_NS, SERVICE_RD, 0, 0, &phonead) != 0) |
return -1; |
async_manager(); |
/* Never reached */ |
return 0; |
} |
printf(NAME ": HelenOS RAM disk server\n"); |
return -1; |
if (!rd_init()) |
return -1; |
printf(NAME ": Accepting connections\n"); |
async_manager(); |
/* Never reached */ |
return 0; |
} |
/** |
/branches/dynload/uspace/srv/rd/Makefile |
---|
57,7 → 57,7 |
$(CC) $(DEFS) $(CFLAGS) -M $(SOURCES) > Makefile.depend |
$(OUTPUT): $(OBJECTS) $(LIBS) |
$(LD) -T $(LIBC_PREFIX)/arch/$(ARCH)/_link.ld -e __entry_driver $(OBJECTS) $(LIBS) $(LFLAGS) -o $@ -Map $(OUTPUT).map |
$(LD) -T $(LIBC_PREFIX)/arch/$(ARCH)/_link.ld $(OBJECTS) $(LIBS) $(LFLAGS) -o $@ -Map $(OUTPUT).map |
disasm: |
$(OBJDUMP) -d $(OUTPUT) >$(OUTPUT).disasm |
/branches/dynload/uspace/srv/fb/sysio.h |
---|
File deleted |
/branches/dynload/uspace/srv/fb/sysio.c |
---|
File deleted |
/branches/dynload/uspace/srv/fb/main.c |
---|
33,12 → 33,14 |
#include <as.h> |
#include <align.h> |
#include <errno.h> |
#include <stdio.h> |
#include "fb.h" |
#include "sysio.h" |
#include "ega.h" |
#include "main.h" |
#define NAME "fb" |
void receive_comm_area(ipc_callid_t callid, ipc_call_t *call, void **area) |
{ |
void *dest; |
53,6 → 55,8 |
int main(int argc, char *argv[]) |
{ |
printf(NAME ": HelenOS Framebuffer service\n"); |
ipcarg_t phonead; |
int initialized = 0; |
70,11 → 74,12 |
#endif |
if (!initialized) |
sysio_init(); |
return -1; |
if (ipc_connect_to_me(PHONE_NS, SERVICE_VIDEO, 0, 0, &phonead) != 0) |
return -1; |
printf(NAME ": Accepting connections\n"); |
async_manager(); |
/* Never reached */ |
return 0; |
/branches/dynload/uspace/srv/fb/Makefile |
---|
43,7 → 43,6 |
OUTPUT = fb |
SOURCES = \ |
main.c \ |
sysio.c \ |
ppm.c |
ifneq ($(ARCH), ia64) |
82,7 → 81,7 |
$(CC) $(DEFS) $(CFLAGS) -M $(SOURCES) > Makefile.depend |
$(OUTPUT): $(OBJECTS) $(LIBS) |
$(LD) -T $(LIBC_PREFIX)/arch/$(ARCH)/_link.ld -e __entry_driver $(OBJECTS) $(LIBS) $(LFLAGS) -o $@ -Map $(OUTPUT).map |
$(LD) -T $(LIBC_PREFIX)/arch/$(ARCH)/_link.ld $(OBJECTS) $(LIBS) $(LFLAGS) -o $@ -Map $(OUTPUT).map |
disasm: |
$(OBJDUMP) -d $(OUTPUT) >$(OUTPUT).disasm |
/branches/dynload/uspace/srv/fs/tmpfs/tmpfs.c |
---|
50,7 → 50,9 |
#include <libfs.h> |
#include "../../vfs/vfs.h" |
#define NAME "tmpfs" |
vfs_info_t tmpfs_vfs_info = { |
.name = "tmpfs", |
.ops = { |
132,7 → 134,7 |
{ |
int vfs_phone; |
printf("TMPFS: HelenOS TMPFS file system server.\n"); |
printf(NAME ": HelenOS TMPFS file system server\n"); |
vfs_phone = ipc_connect_me_to(PHONE_NS, SERVICE_VFS, 0, 0); |
while (vfs_phone < EOK) { |
144,13 → 146,11 |
rc = fs_register(vfs_phone, &tmpfs_reg, &tmpfs_vfs_info, |
tmpfs_connection); |
if (rc != EOK) { |
printf("Failed to register the TMPFS file system (%d)\n", rc); |
printf(NAME ": Failed to register file system (%d)\n", rc); |
return rc; |
} |
dprintf("TMPFS filesystem registered, fs_handle=%d.\n", |
tmpfs_reg.fs_handle); |
printf(NAME ": Accepting connections\n"); |
async_manager(); |
/* not reached */ |
return 0; |
/branches/dynload/uspace/srv/fs/tmpfs/tmpfs_ops.c |
---|
50,6 → 50,10 |
#include <libadt/hash_table.h> |
#include <as.h> |
#include <libfs.h> |
#include <ipc/services.h> |
#include <ipc/devmap.h> |
#include <sys/mman.h> |
#include <byteorder.h> |
#define min(a, b) ((a) < (b) ? (a) : (b)) |
#define max(a, b) ((a) > (b) ? (a) : (b)) |
58,6 → 62,10 |
#define NAMES_BUCKETS 4 |
#define BLOCK_SIZE 1024 // FIXME |
#define RD_BASE 1024 // FIXME |
#define RD_READ_BLOCK (RD_BASE + 1) |
/* |
* For now, we don't distinguish between different dev_handles/instances. All |
* requests resolve to the only instance, rooted in the following variable. |
140,6 → 148,11 |
/** Hash table of all directory entries. */ |
hash_table_t dentries; |
struct rdentry { |
uint8_t type; |
uint32_t len; |
} __attribute__((packed)); |
/* Implementation of hash table interface for the dentries hash table. */ |
static hash_index_t dentries_hash(unsigned long *key) |
{ |
237,6 → 250,177 |
return true; |
} |
static bool tmpfs_blockread(int phone, void *buffer, size_t *bufpos, size_t *buflen, size_t *pos, void *dst, size_t size) |
{ |
size_t offset = 0; |
size_t left = size; |
while (left > 0) { |
size_t rd; |
if (*bufpos + left < *buflen) |
rd = left; |
else |
rd = *buflen - *bufpos; |
if (rd > 0) { |
memcpy(dst + offset, buffer + *bufpos, rd); |
offset += rd; |
*bufpos += rd; |
*pos += rd; |
left -= rd; |
} |
if (*bufpos == *buflen) { |
int retval; |
int rc = ipc_call_sync_2_1(phone, RD_READ_BLOCK, *pos / BLOCK_SIZE, BLOCK_SIZE, (sysarg_t *) &retval); |
if ((rc != EOK) || (retval != EOK)) |
return false; |
*bufpos = 0; |
*buflen = BLOCK_SIZE; |
} |
} |
return true; |
} |
static bool tmpfs_restore_recursion(int phone, void *block, size_t *bufpos, size_t *buflen, size_t *pos, tmpfs_dentry_t *parent) |
{ |
struct rdentry entry; |
do { |
char *fname; |
tmpfs_dentry_t *node; |
uint32_t size; |
if (!tmpfs_blockread(phone, block, bufpos, buflen, pos, &entry, sizeof(entry))) |
return false; |
entry.len = uint32_t_le2host(entry.len); |
switch (entry.type) { |
case 0: |
break; |
case 1: |
fname = malloc(entry.len + 1); |
if (fname == NULL) |
return false; |
node = (tmpfs_dentry_t *) tmpfs_create_node(L_FILE); |
if (node == NULL) { |
free(fname); |
return false; |
} |
if (!tmpfs_blockread(phone, block, bufpos, buflen, pos, fname, entry.len)) { |
tmpfs_destroy_node((void *) node); |
free(fname); |
return false; |
} |
fname[entry.len] = 0; |
if (!tmpfs_link_node((void *) parent, (void *) node, fname)) { |
tmpfs_destroy_node((void *) node); |
free(fname); |
return false; |
} |
free(fname); |
if (!tmpfs_blockread(phone, block, bufpos, buflen, pos, &size, sizeof(size))) |
return false; |
size = uint32_t_le2host(size); |
node->data = malloc(size); |
if (node->data == NULL) |
return false; |
node->size = size; |
if (!tmpfs_blockread(phone, block, bufpos, buflen, pos, node->data, size)) |
return false; |
break; |
case 2: |
fname = malloc(entry.len + 1); |
if (fname == NULL) |
return false; |
node = (tmpfs_dentry_t *) tmpfs_create_node(L_DIRECTORY); |
if (node == NULL) { |
free(fname); |
return false; |
} |
if (!tmpfs_blockread(phone, block, bufpos, buflen, pos, fname, entry.len)) { |
tmpfs_destroy_node((void *) node); |
free(fname); |
return false; |
} |
fname[entry.len] = 0; |
if (!tmpfs_link_node((void *) parent, (void *) node, fname)) { |
tmpfs_destroy_node((void *) node); |
free(fname); |
return false; |
} |
free(fname); |
if (!tmpfs_restore_recursion(phone, block, bufpos, buflen, pos, node)) |
return false; |
break; |
default: |
return false; |
} |
} while (entry.type != 0); |
return true; |
} |
static bool tmpfs_restore(dev_handle_t dev) |
{ |
void *block = mmap(NULL, BLOCK_SIZE, |
PROTO_READ | PROTO_WRITE, MAP_ANONYMOUS | MAP_PRIVATE, 0, 0); |
if (block == NULL) |
return false; |
int phone = ipc_connect_me_to(PHONE_NS, SERVICE_DEVMAP, DEVMAP_CONNECT_TO_DEVICE, dev); |
if (phone < 0) { |
munmap(block, BLOCK_SIZE); |
return false; |
} |
if (ipc_share_out_start(phone, block, AS_AREA_READ | AS_AREA_WRITE) != EOK) |
goto error; |
size_t bufpos = 0; |
size_t buflen = 0; |
size_t pos = 0; |
char tag[6]; |
if (!tmpfs_blockread(phone, block, &bufpos, &buflen, &pos, tag, 5)) |
goto error; |
tag[5] = 0; |
if (strcmp(tag, "TMPFS") != 0) |
goto error; |
if (!tmpfs_restore_recursion(phone, block, &bufpos, &buflen, &pos, root)) |
goto error; |
ipc_hangup(phone); |
munmap(block, BLOCK_SIZE); |
return true; |
error: |
ipc_hangup(phone); |
munmap(block, BLOCK_SIZE); |
return false; |
} |
/** Compare one component of path to a directory entry. |
* |
* @param parentp Pointer to node from which we descended. |
395,16 → 579,24 |
void tmpfs_mount(ipc_callid_t rid, ipc_call_t *request) |
{ |
dev_handle_t mr_dev_handle = (dev_handle_t)IPC_GET_ARG1(*request); |
fs_index_t mr_index = (fs_index_t)IPC_GET_ARG2(*request); |
fs_handle_t mp_fs_handle = (fs_handle_t)IPC_GET_ARG3(*request); |
dev_handle_t mp_dev_handle = (dev_handle_t)IPC_GET_ARG4(*request); |
fs_index_t mp_index = (fs_index_t)IPC_GET_ARG5(*request); |
dev_handle_t mr_dev_handle = (dev_handle_t) IPC_GET_ARG1(*request); |
fs_index_t mr_index = (fs_index_t) IPC_GET_ARG2(*request); |
fs_handle_t mp_fs_handle = (fs_handle_t) IPC_GET_ARG3(*request); |
dev_handle_t mp_dev_handle = (dev_handle_t) IPC_GET_ARG4(*request); |
fs_index_t mp_index = (fs_index_t) IPC_GET_ARG5(*request); |
if ((mr_index == root->index) && |
(mp_fs_handle == tmpfs_reg.fs_handle) && |
(mp_index == mr_index)) |
ipc_answer_0(rid, EOK); |
else |
(mp_fs_handle == tmpfs_reg.fs_handle) && |
(mp_index == mr_index)) { |
if (mr_dev_handle >= 0) { |
if (tmpfs_restore(mr_dev_handle)) |
ipc_answer_0(rid, EOK); |
else |
ipc_answer_0(rid, ELIMIT); |
} else |
ipc_answer_0(rid, EOK); |
} else |
ipc_answer_0(rid, ENOTSUP); |
} |
/branches/dynload/uspace/srv/devmap/devmap.h |
---|
File deleted |
/branches/dynload/uspace/srv/devmap/devmap.c |
---|
44,8 → 44,9 |
#include <futex.h> |
#include <stdlib.h> |
#include <string.h> |
#include <ipc/devmap.h> |
#include "devmap.h" |
#define NAME "devmap" |
LIST_INITIALIZE(devices_list); |
112,10 → 113,8 |
item = item->next; |
} |
if (item == &devices_list) { |
printf("DEVMAP: no device named %s.\n", name); |
if (item == &devices_list) |
return NULL; |
} |
device = list_get_instance(item, devmap_device_t, devices); |
return device; |
203,7 → 202,6 |
* Get driver name |
*/ |
if (!ipc_data_write_receive(&callid, &name_size)) { |
printf("Unexpected request.\n"); |
free(driver); |
ipc_answer_0(callid, EREFUSED); |
ipc_answer_0(iid, EREFUSED); |
211,8 → 209,6 |
} |
if (name_size > DEVMAP_NAME_MAXLEN) { |
printf("Too logn name: %u: maximum is %u.\n", name_size, |
DEVMAP_NAME_MAXLEN); |
free(driver); |
ipc_answer_0(callid, EINVAL); |
ipc_answer_0(iid, EREFUSED); |
223,7 → 219,6 |
* Allocate buffer for device name. |
*/ |
if (NULL == (driver->name = (char *)malloc(name_size + 1))) { |
printf("Cannot allocate space for driver name.\n"); |
free(driver); |
ipc_answer_0(callid, ENOMEM); |
ipc_answer_0(iid, EREFUSED); |
234,7 → 229,6 |
* Send confirmation to sender and get data into buffer. |
*/ |
if (EOK != ipc_data_write_finalize(callid, driver->name, name_size)) { |
printf("Cannot read driver name.\n"); |
free(driver->name); |
free(driver); |
ipc_answer_0(iid, EREFUSED); |
243,8 → 237,6 |
driver->name[name_size] = 0; |
printf("Read driver name: '%s'.\n", driver->name); |
/* Initialize futex for list of devices owned by this driver */ |
futex_initialize(&(driver->devices_futex), 1); |
259,8 → 251,6 |
callid = async_get_call(&call); |
if (IPC_M_CONNECT_TO_ME != IPC_GET_METHOD(call)) { |
printf("DEVMAP: Unexpected method: %u.\n", |
IPC_GET_METHOD(call)); |
ipc_answer_0(callid, ENOTSUP); |
free(driver->name); |
288,10 → 278,8 |
futex_up(&drivers_list_futex); |
ipc_answer_0(iid, EOK); |
printf("Driver registered.\n"); |
*odriver = driver; |
return; |
} |
/** Unregister device driver, unregister all its devices and free driver |
301,12 → 289,9 |
{ |
devmap_device_t *device; |
if (NULL == driver) { |
printf("Error: driver == NULL.\n"); |
if (NULL == driver) |
return EEXISTS; |
} |
printf("Unregister driver '%s'.\n", driver->name); |
futex_down(&drivers_list_futex); |
ipc_hangup(driver->phone); |
322,7 → 307,6 |
while (!list_empty(&(driver->devices))) { |
device = list_get_instance(driver->devices.next, |
devmap_device_t, driver_devices); |
printf("Unregister device '%s'.\n", device->name); |
devmap_device_unregister_core(device); |
} |
337,8 → 321,6 |
free(driver); |
printf("Driver unregistered.\n"); |
return EOK; |
} |
354,7 → 336,6 |
devmap_device_t *device; |
if (NULL == driver) { |
printf("Invalid driver registration.\n"); |
ipc_answer_0(iid, EREFUSED); |
return; |
} |
361,8 → 342,7 |
/* Create new device entry */ |
if (NULL == |
(device = (devmap_device_t *)malloc(sizeof(devmap_device_t)))) { |
printf("Cannot allocate new device.\n"); |
(device = (devmap_device_t *) malloc(sizeof(devmap_device_t)))) { |
ipc_answer_0(iid, ENOMEM); |
return; |
} |
370,24 → 350,21 |
/* Get device name */ |
if (!ipc_data_write_receive(&callid, &size)) { |
free(device); |
printf("Cannot read device name.\n"); |
ipc_answer_0(iid, EREFUSED); |
return; |
} |
if (size > DEVMAP_NAME_MAXLEN) { |
printf("Too long device name: %u.\n", size); |
free(device); |
ipc_answer_0(callid, EINVAL); |
ipc_answer_0(iid, EREFUSED); |
return; |
} |
/* +1 for terminating \0 */ |
device->name = (char *) malloc(size + 1); |
/* +1 for terminating \0 */ |
device->name = (char *)malloc(size + 1); |
if (NULL == device->name) { |
printf("Cannot read device name.\n"); |
free(device); |
ipc_answer_0(callid, ENOMEM); |
ipc_answer_0(iid, EREFUSED); |
404,7 → 381,7 |
/* Check that device with such name is not already registered */ |
if (NULL != devmap_device_find_name(device->name)) { |
printf("Device '%s' already registered.\n", device->name); |
printf(NAME ": Device '%s' already registered\n", device->name); |
futex_up(&devices_list_futex); |
free(device->name); |
free(device); |
428,10 → 405,7 |
futex_up(&device->driver->devices_futex); |
futex_up(&devices_list_futex); |
printf("Device '%s' registered.\n", device->name); |
ipc_answer_1(iid, EOK, device->handle); |
return; |
} |
/** |
461,8 → 435,6 |
dev = devmap_device_find_handle(handle); |
if (NULL == dev) { |
printf("DEVMAP: No registered device with handle %d.\n", |
handle); |
ipc_answer_0(callid, ENOENT); |
return; |
} |
469,7 → 441,6 |
ipc_forward_fast(callid, dev->driver->phone, (ipcarg_t)(dev->handle), |
IPC_GET_ARG3(*call), 0, IPC_FF_NONE); |
return; |
} |
/** Find handle for device instance identified by name. |
484,7 → 455,6 |
ipc_callid_t callid; |
ipcarg_t retval; |
/* |
* Wait for incoming message with device name (but do not |
* read the name itself until the buffer is allocated). |
528,16 → 498,11 |
* Device was not found. |
*/ |
if (NULL == dev) { |
printf("DEVMAP: device %s has not been registered.\n", name); |
ipc_answer_0(iid, ENOENT); |
return; |
} |
printf("DEVMAP: device %s has handler %d.\n", name, dev->handle); |
ipc_answer_1(iid, EOK, dev->handle); |
return; |
} |
/** Find name of device identified by id and send it to caller. |
574,15 → 539,12 |
} |
*/ |
/* TODO: send name in response */ |
return; |
} |
/** Handle connection with device driver. |
* |
*/ |
static void |
devmap_connection_driver(ipc_callid_t iid, ipc_call_t *icall) |
static void devmap_connection_driver(ipc_callid_t iid, ipc_call_t *icall) |
{ |
ipc_callid_t callid; |
ipc_call_t call; |
593,10 → 555,8 |
devmap_driver_register(&driver); |
if (NULL == driver) { |
printf("DEVMAP: driver registration failed.\n"); |
if (NULL == driver) |
return; |
} |
while (cont) { |
callid = async_get_call(&call); |
603,13 → 563,10 |
switch (IPC_GET_METHOD(call)) { |
case IPC_M_PHONE_HUNGUP: |
printf("DEVMAP: connection hung up.\n"); |
cont = false; |
continue; /* Exit thread */ |
case DEVMAP_DRIVER_UNREGISTER: |
printf("DEVMAP: unregister driver.\n"); |
if (NULL == driver) { |
printf("DEVMAP: driver was not registered!\n"); |
ipc_answer_0(callid, ENOENT); |
} else { |
ipc_answer_0(callid, EOK); |
649,8 → 606,7 |
/** Handle connection with device client. |
* |
*/ |
static void |
devmap_connection_client(ipc_callid_t iid, ipc_call_t *icall) |
static void devmap_connection_client(ipc_callid_t iid, ipc_call_t *icall) |
{ |
ipc_callid_t callid; |
ipc_call_t call; |
663,7 → 619,6 |
switch (IPC_GET_METHOD(call)) { |
case IPC_M_PHONE_HUNGUP: |
printf("DEVMAP: connection hung up.\n"); |
cont = false; |
continue; /* Exit thread */ |
686,14 → 641,10 |
/** Function for handling connections to devmap |
* |
*/ |
static void |
devmap_connection(ipc_callid_t iid, ipc_call_t *icall) |
static void devmap_connection(ipc_callid_t iid, ipc_call_t *icall) |
{ |
printf("DEVMAP: new connection.\n"); |
/* Select interface */ |
switch ((ipcarg_t)(IPC_GET_ARG1(*icall))) { |
/* Select interface */ |
switch ((ipcarg_t) (IPC_GET_ARG1(*icall))) { |
case DEVMAP_DRIVER: |
devmap_connection_driver(iid, icall); |
break; |
701,21 → 652,14 |
devmap_connection_client(iid, icall); |
break; |
case DEVMAP_CONNECT_TO_DEVICE: |
/* Connect client to selected device */ |
printf("DEVMAP: connect to device %d.\n", |
IPC_GET_ARG2(*icall)); |
/* Connect client to selected device */ |
devmap_forward(iid, icall); |
break; |
default: |
ipc_answer_0(iid, ENOENT); /* No such interface */ |
printf("DEVMAP: Unknown interface %u.\n", |
(ipcarg_t)(IPC_GET_ARG1(*icall))); |
} |
/* Cleanup */ |
printf("DEVMAP: connection closed.\n"); |
return; |
} |
/** |
723,16 → 667,16 |
*/ |
int main(int argc, char *argv[]) |
{ |
printf(NAME ": HelenOS Device Mapper\n"); |
ipcarg_t phonead; |
printf("DEVMAP: HelenOS device mapper.\n"); |
if (devmap_init() != 0) { |
printf("Error while initializing DEVMAP service.\n"); |
printf(NAME ": Error while initializing service\n"); |
return -1; |
} |
/* Set a handler of incomming connections */ |
/* Set a handler of incomming connections */ |
async_set_client_connection(devmap_connection); |
/* Register device mapper at naming service */ |
739,6 → 683,7 |
if (ipc_connect_to_me(PHONE_NS, SERVICE_DEVMAP, 0, 0, &phonead) != 0) |
return -1; |
printf(NAME ": Accepting connections\n"); |
async_manager(); |
/* Never reached */ |
return 0; |
747,4 → 692,3 |
/** |
* @} |
*/ |
/branches/dynload/uspace/srv/vfs/vfs.c |
---|
47,6 → 47,8 |
#include <atomic.h> |
#include "vfs.h" |
#define NAME "vfs" |
#define dprintf(...) printf(__VA_ARGS__) |
static void vfs_connection(ipc_callid_t iid, ipc_call_t *icall) |
53,8 → 55,6 |
{ |
bool keep_on_going = 1; |
printf("Connection opened from %p\n", icall->in_phone_hash); |
/* |
* The connection was opened via the IPC_CONNECT_ME_TO call. |
* This call needs to be answered. |
77,8 → 77,6 |
callid = async_get_call(&call); |
printf("Received call, method=%d\n", IPC_GET_METHOD(call)); |
switch (IPC_GET_METHOD(call)) { |
case IPC_M_PHONE_HUNGUP: |
keep_on_going = false; |
131,7 → 129,7 |
{ |
ipcarg_t phonead; |
printf("VFS: HelenOS VFS server\n"); |
printf(NAME ": HelenOS VFS server\n"); |
/* |
* Initialize the list of registered file systems. |
142,7 → 140,7 |
* Initialize VFS node hash table. |
*/ |
if (!vfs_nodes_init()) { |
printf("Failed to initialize the VFS node hash table.\n"); |
printf(NAME ": Failed to initialize VFS node hash table\n"); |
return ENOMEM; |
} |
152,12 → 150,12 |
list_initialize(&plb_head); |
plb = as_get_mappable_page(PLB_SIZE); |
if (!plb) { |
printf("Cannot allocate a mappable piece of address space\n"); |
printf(NAME ": Cannot allocate a mappable piece of address space\n"); |
return ENOMEM; |
} |
if (as_area_create(plb, PLB_SIZE, AS_AREA_READ | AS_AREA_WRITE | |
AS_AREA_CACHEABLE) != plb) { |
printf("Cannot create address space area.\n"); |
printf(NAME ": Cannot create address space area\n"); |
return ENOMEM; |
} |
memset(plb, 0, PLB_SIZE); |
175,6 → 173,7 |
/* |
* Start accepting connections. |
*/ |
printf(NAME ": Accepting connections\n"); |
async_manager(); |
return 0; |
} |
/branches/dynload/uspace/srv/vfs/vfs_ops.c |
---|
444,7 → 444,7 |
*/ |
int fd = IPC_GET_ARG1(*request); |
/* Lookup the file structure corresponding to the file descriptor. */ |
vfs_file_t *file = vfs_file_get(fd); |
if (!file) { |
451,7 → 451,7 |
ipc_answer_0(rid, ENOENT); |
return; |
} |
/* |
* Now we need to receive a call with client's |
* IPC_M_DATA_READ/IPC_M_DATA_WRITE request. |
467,13 → 467,13 |
ipc_answer_0(rid, EINVAL); |
return; |
} |
/* |
* Lock the open file structure so that no other thread can manipulate |
* the same open file at a time. |
*/ |
futex_down(&file->lock); |
/* |
* Lock the file's node so that no other client can read/write to it at |
* the same time. |
482,7 → 482,7 |
rwlock_read_lock(&file->node->contents_rwlock); |
else |
rwlock_write_lock(&file->node->contents_rwlock); |
int fs_phone = vfs_grab_phone(file->node->fs_handle); |
/* Make a VFS_READ/VFS_WRITE request at the destination FS server. */ |
500,14 → 500,14 |
* don't have to bother. |
*/ |
ipc_forward_fast(callid, fs_phone, 0, 0, 0, IPC_FF_ROUTE_FROM_ME); |
vfs_release_phone(fs_phone); |
/* Wait for reply from the FS server. */ |
ipcarg_t rc; |
async_wait_for(msg, &rc); |
size_t bytes = IPC_GET_ARG1(answer); |
/* Unlock the VFS node. */ |
if (read) |
rwlock_read_unlock(&file->node->contents_rwlock); |
517,12 → 517,12 |
file->node->size = IPC_GET_ARG2(answer); |
rwlock_write_unlock(&file->node->contents_rwlock); |
} |
/* Update the position pointer and unlock the open file. */ |
if (rc == EOK) |
file->pos += bytes; |
futex_up(&file->lock); |
/* |
* FS server's reply is the final result of the whole operation we |
* return to the client. |
/branches/dynload/uspace/srv/vfs/vfs.h |
---|
40,8 → 40,11 |
#include <sys/types.h> |
#include <bool.h> |
#define dprintf(...) printf(__VA_ARGS__) |
// FIXME: according to CONFIG_DEBUG |
// #define dprintf(...) printf(__VA_ARGS__) |
#define dprintf(...) |
#define VFS_FIRST IPC_FIRST_USER_METHOD |
#define IPC_METHOD_TO_VFS_OP(m) ((m) - VFS_FIRST) |