Subversion Repositories HelenOS-historic

Compare Revisions

Ignore whitespace Rev 1464 → Rev 1465

/uspace/trunk/console/console.c
99,8 → 99,11
return;
case KBD_PUSHCHAR:
/* got key from keyboard driver */
/* find active console */
/* if client is awaiting key, send it */
/*FIXME: else store key to its buffer */
retval = 0;
i = IPC_GET_ARG1(call) & 0xff;
112,7 → 115,7
keybuffer_push(&(connections[active_client].keybuffer), i);
/* Send it to first FB, DEBUG */
// ipc_call_async_2(connections[0].vfb_phone, FB_PUTCHAR, 0, IPC_GET_ARG1(call),NULL,NULL);
ipc_call_sync_2(connections[0].vfb_phone, FB_PUTCHAR, 0, IPC_GET_ARG1(call),NULL,NULL);
// ipc_call_sync_2(connections[0].vfb_phone, FB_PUTCHAR, 0, IPC_GET_ARG1(call),NULL,NULL);
 
break;
default:
148,19 → 151,20
ipc_answer_fast(callid, 0,0,0);
return;
case CONSOLE_PUTCHAR:
/* TODO: send message to fb */
/* Send message to fb */
ipc_call_async_2(connections[consnum].vfb_phone, FB_PUTCHAR, IPC_GET_ARG1(call), IPC_GET_ARG2(call), NULL, NULL);
break;
case CONSOLE_GETCHAR:
/* FIXME: */
if (!keybuffer_pop(&(connections[active_client].keybuffer), (char *)&arg1)) {
/* FIXME: Only temporary solution until request storage will be created */
while (!keybuffer_pop(&(connections[active_client].keybuffer), (char *)&arg1)) {
/* FIXME: buffer empty -> store request */
arg1 = 'X'; /* Only temporary */
usleep(10000);
};
//ipc_call_async_2(connections[active_client].vfb_phone, FB_PUTCHAR, ' ', arg1, NULL, (void *)NULL);
break;
}
ipc_answer_fast(callid, 0,0,0);
ipc_answer_fast(callid, 0, arg1, 0);
}
}
 
189,8 → 193,8
keybuffer_init(&(connections[i].keybuffer));
/* TODO: init key_buffer */
while ((connections[i].vfb_phone = ipc_connect_me_to(PHONE_NS, SERVICE_VIDEO, 0)) < 0) {
ipc_call_async_2(connections[i].vfb_phone, FB_PUTCHAR, 'a', 'b', NULL, (void *)NULL);
usleep(10000);
//ipc_call_async_2(connections[i].vfb_phone, FB_PUTCHAR, 'a', 'b', NULL, (void *)NULL);
}
}
/uspace/trunk/init/init.c
415,6 → 415,15
}
}
 
static void test_console(void)
{
int c;
 
while ((c = getchar()) != EOF)
putchar(c);
}
 
 
int main(int argc, char *argv[])
{
pstid_t ptid;
422,6 → 431,8
// version_print();
 
printf("Hello\nThis is Init\n");
// test_printf();
// test_printf2();
// test_ping();
436,9 → 447,9
// test_time();
// test_async_kbd();
// test_fb();
test_console();
 
printf("Hello\nThis is Init\n\nBye.");
printf("\nBye.\n");
 
/*
printf("Userspace task, taskid=%llX\n", task_get_id());
/uspace/trunk/libc/include/unistd.h
36,6 → 36,7
#define getpagesize() (PAGE_SIZE)
 
extern ssize_t write(int fd, const void * buf, size_t count);
extern ssize_t read(int fd, void * buf, size_t count);
extern void _exit(int status);
void *sbrk(ssize_t incr);
void usleep(unsigned long usec);
/uspace/trunk/libc/include/io/stream.h
1,5 → 1,32
/*
* Copyright (C) 2006 Jakub Vana
* 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 <libarch/types.h>
#include <unistd.h>
 
#define EMFILE -17
 
7,6 → 34,6
 
 
typedef ssize_t (*pwritefn_t)(void *, const void *, size_t);
typedef char (*preadfn_t)(void);
typedef ssize_t (*preadfn_t)(void *, void *, size_t);
 
fd_t open(const char *fname, int flags);
/uspace/trunk/libc/include/io/io.h
34,5 → 34,6
int putnchars(const char * buf, size_t count);
int putstr(const char * str);
int putchar(int c);
int getchar(void);
 
#endif
/uspace/trunk/libc/include/stdio.h
34,6 → 34,8
 
#define EOF (-1)
 
extern int getchar(void);
 
extern int puts(const char * str);
extern int putchar(int c);
 
/uspace/trunk/libc/generic/io/io.c
92,3 → 92,15
return EOF;
}
 
int getchar(void)
{
unsigned char c;
if (read(0, (void *)&c , 1) == 1) {
return c;
}
return EOF;
}
 
 
/uspace/trunk/libc/generic/io/stream.c
1,3 → 1,33
/*
* Copyright (C) 2006 Josef Cejka
* Copyright (C) 2006 Jakub Vana
* 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 <io/io.h>
#include <io/stream.h>
#include <string.h>
8,6 → 38,7
#include <ipc/fb.h>
#include <ipc/services.h>
#include <console.h>
#include <unistd.h>
 
#define FDS 32
 
34,14 → 65,21
//return (ssize_t) __SYSCALL3(SYS_IO, 1, (sysarg_t) buf, (sysarg_t) count);
}
 
static char read_stdin(void)
static ssize_t read_stdin(void *param, void *buf, size_t count)
{
ipcarg_t r0,r1;
ipc_call_sync_2(console_phone, CONSOLE_GETCHAR, 0, 0, &r0, &r1);
return r0;
size_t i = 0;
 
while (i < count) {
if (ipc_call_sync_2(console_phone, CONSOLE_GETCHAR, 0, 0, &r0, &r1) < 0) {
return -1;
}
((char *)buf)[i++] = r0;
}
return i;
//return (ssize_t) __SYSCALL3(SYS_IO, 1, (sysarg_t) buf, (sysarg_t) count);
}
 
static ssize_t write_stdout(void *param, const void *buf, size_t count)
{
int i;
125,3 → 163,12
return 0;
}
 
ssize_t read(int fd, void *buf, size_t count)
{
if (fd < FDS)
return streams[fd].r(streams[fd].param, buf, count);
return 0;
}