Subversion Repositories HelenOS

Compare Revisions

Ignore whitespace Rev 3149 → Rev 3150

/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