/uspace/trunk/ns/ns.c |
---|
45,8 → 45,6 |
#define NS_HASH_TABLE_CHAINS 20 |
extern int __DONT_OPEN_STDIO__=1; |
static int register_service(ipcarg_t service, ipcarg_t phone, ipc_call_t *call); |
static int connect_to_service(ipcarg_t service, ipc_call_t *call, ipc_callid_t callid); |
/uspace/trunk/fb/fb.c |
---|
54,8 → 54,6 |
#define EFB (-1) |
extern int __DONT_OPEN_STDIO__=1; |
#define DEFAULT_BGCOLOR 0x000080 |
#define DEFAULT_FGCOLOR 0xffff00 |
#define DEFAULT_LOGOCOLOR 0x0000ff |
/uspace/trunk/libc/include/io/stream.h |
---|
6,11 → 6,7 |
typedef int fd_t; |
typedef ssize_t (*pwritefn_t)(void *,const void *,size_t); |
typedef ssize_t (*pwritefn_t)(void *, const void *, size_t); |
typedef ssize_t (*preadfn_t)(void); |
fd_t open(const char *fname,int flags); |
fd_t open(const char *fname, int flags); |
/uspace/trunk/libc/include/ipc/fb.h |
---|
11,50 → 11,41 |
#define METHOD_WIDTH 16 |
#define ITEM_WIDTH 16 |
#define COUNT_WIDTH 16 /*Should be 8 times integer*/ |
#define COUNT_WIDTH 16 /* Should be 8 times integer */ |
struct _fb_method |
{ |
unsigned m : METHOD_WIDTH; |
unsigned item : ITEM_WIDTH; |
} __attribute__ ((packed)); |
struct _fb_method { |
unsigned m : METHOD_WIDTH; |
unsigned item : ITEM_WIDTH; |
} __attribute__((packed)); |
union fb_method |
{ |
union fb_method { |
struct _fb_method m; |
__native fill; |
}__attribute__ ((packed)); |
} __attribute__((packed)); |
struct fb_call_args |
{ |
struct fb_call_args { |
union fb_method method; |
union |
{ |
struct |
{ |
unsigned count :COUNT_WIDTH; |
char chars[3*sizeof(__native)-(COUNT_WIDTH>>3)]; |
}putchar __attribute__ ((packed)); |
}data ; //__attribute__ ((packed)); |
}__attribute__ ((packed)); |
union { |
struct { |
unsigned count : COUNT_WIDTH; |
char chars[3 * sizeof(__native) - (COUNT_WIDTH >> 3)]; |
} putchar __attribute__((packed)); |
} data ; // __attribute__((packed)); |
} __attribute__((packed)); |
struct fb_ipc_args |
{ |
struct fb_ipc_args { |
__native method; |
__native arg1; |
__native arg2; |
__native arg3; |
} __attribute__ ((packed)); |
} __attribute__((packed)); |
union fb_args |
{ |
union fb_args { |
struct fb_call_args fb_args; |
struct fb_ipc_args ipc_args; |
}__attribute__ ((packed)); |
} __attribute__((packed)); |
typedef union fb_args fb_args_t; |
#endif |
/uspace/trunk/libc/generic/io/io.c |
---|
92,12 → 92,3 |
return EOF; |
} |
/* |
ssize_t write(int fd, const void * buf, size_t count) |
{ |
return (ssize_t) __SYSCALL3(SYS_IO, (sysarg_t) fd, (sysarg_t) buf, (sysarg_t) count); |
}*/ |
/uspace/trunk/libc/generic/io/stream.c |
---|
10,22 → 10,20 |
#define FDS 32 |
typedef struct stream_t |
{ |
typedef struct stream_t { |
pwritefn_t w; |
preadfn_t r; |
void * param; |
}stream_t; |
} stream_t; |
typedef struct vfb_descriptor_t |
{ |
typedef struct vfb_descriptor_t { |
int phone; |
int vfb; |
}vfb_descriptor_t; |
} vfb_descriptor_t; |
stream_t streams[FDS]={{0,0,0}}; |
stream_t streams[FDS] = {{0, 0, 0}}; |
/* |
ssize_t write_stdout(void *param, const void * buf, size_t count); |
34,16 → 32,17 |
return (ssize_t) __SYSCALL3(SYS_IO, 1, (sysarg_t) buf, (sysarg_t) count); |
}*/ |
static void vfb_send_char(vfb_descriptor_t *d,char c) |
static void vfb_send_char(vfb_descriptor_t *d, char c) |
{ |
ipcarg_t r0,r1; |
ipc_call_sync_2(d->phone,FB_PUTCHAR,d->vfb,c,&r0,&r1); |
ipc_call_sync_2(d->phone, FB_PUTCHAR, d->vfb, c, &r0, &r1); |
} |
static ssize_t write_vfb(void *param, const void * buf, size_t count) |
static ssize_t write_vfb(void *param, const void *buf, size_t count) |
{ |
int i; |
for(i=0;i<count;i++) vfb_send_char((vfb_descriptor_t *)param,((char*)buf)[i]); |
for (i = 0; i < count; i++) |
vfb_send_char((vfb_descriptor_t *) param, ((char *) buf)[i]); |
return count; |
//return (ssize_t) __SYSCALL3(SYS_IO, 1, (sysarg_t) buf, (sysarg_t) count); |
50,7 → 49,7 |
} |
static ssize_t write_stderr(void *param, const void * buf, size_t count) |
static ssize_t write_stderr(void *param, const void *buf, size_t count) |
{ |
return count; |
//return (ssize_t) __SYSCALL3(SYS_IO, 1, (sysarg_t) buf, (sysarg_t) count); |
57,7 → 56,6 |
} |
stream_t open_vfb(void); |
stream_t open_vfb(void) |
{ |
stream_t stream; |
66,58 → 64,56 |
int res; |
ipcarg_t vfb_no; |
while((phoneid=ipc_connect_me_to(PHONE_NS,SERVICE_VIDEO,0))<0) |
{ |
while ((phoneid = ipc_connect_me_to(PHONE_NS, SERVICE_VIDEO, 0)) < 0) { |
volatile int a; |
for(a=0;a<1048576;a++); |
for (a = 0; a < 1048576; a++); |
} |
ipc_call_sync(phoneid,FB_GET_VFB,0,&vfb_no); |
vfb=malloc(sizeof(vfb_descriptor_t)); |
ipc_call_sync(phoneid, FB_GET_VFB, 0, &vfb_no); |
vfb = malloc(sizeof(vfb_descriptor_t)); |
vfb->phone=phoneid; |
vfb->vfb=vfb_no; |
vfb->phone = phoneid; |
vfb->vfb = vfb_no; |
stream.w=write_vfb; |
stream.param=vfb; |
stream.w = write_vfb; |
stream.param = vfb; |
return stream; |
} |
fd_t open(const char *fname,int flags) |
fd_t open(const char *fname, int flags) |
{ |
int c=0; |
while(((streams[c].w)||(streams[c].r))&&(c<FDS))c++; |
if(c==FDS) return EMFILE; |
if(!strcmp(fname,"stdin")) |
{ |
streams[c].r=(preadfn_t)1; |
int c = 0; |
while (((streams[c].w) || (streams[c].r)) && (c < FDS)) |
c++; |
if (c == FDS) |
return EMFILE; |
if (!strcmp(fname, "stdin")) { |
streams[c].r = (preadfn_t)1; |
return c; |
} |
if(!strcmp(fname,"stdout")) |
{ |
//streams[c].w=write_stdout; |
if (!strcmp(fname, "stdout")) { |
//streams[c].w = write_stdout; |
//return c; |
streams[c]=open_vfb(); |
streams[c] = open_vfb(); |
return c; |
} |
if(!strcmp(fname,"stderr")) |
{ |
streams[c].w=write_stderr; |
if (!strcmp(fname, "stderr")) { |
streams[c].w = write_stderr; |
return c; |
} |
} |
ssize_t write(int fd, const void * buf, size_t count) |
ssize_t write(int fd, const void *buf, size_t count) |
{ |
if(fd<FDS) return streams[fd].w(streams[fd].param,buf,count); |
if (fd < FDS) |
return streams[fd].w(streams[fd].param, buf, count); |
return 0; |
} |
/uspace/trunk/libc/generic/libc.c |
---|
32,12 → 32,8 |
#include <malloc.h> |
#include <psthread.h> |
#include <io/stream.h> |
#include <ipc/ipc.h> |
int __DONT_OPEN_STDIO__; |
/* We should probably merge libc and libipc together */ |
extern void _ipc_init(void); |
void _exit(int status) { |
thread_exit(status); |
} |
45,17 → 41,14 |
void __main(void) { |
tcb_t *tcb; |
if(!__DONT_OPEN_STDIO__) |
{ |
open("stdin",0); |
open("stdout",0); |
open("stderr",0); |
} |
tcb = __make_tls(); |
__tcb_set(tcb); |
psthread_setup(tcb); |
_ipc_init(); |
open("stdin", 0); |
open("stdout", 0); |
open("stderr", 0); |
} |
void __exit(void) { |
/uspace/trunk/libc/Makefile |
---|
79,13 → 79,12 |
ln -sfn ../../../kernel/generic/include include/kernel |
ln -sfn kernel/arch include/arch |
ln -sfn ../arch/$(ARCH)/include include/libarch |
ln -sfn ../../libipc/include include/libipc |
ln -sfn ../../libadt/include include/libadt |
-include Makefile.depend |
clean: |
-rm -f include/kernel include/arch include/libarch include/libipc include/libadt libc.a arch/$(ARCH)/_link.ld Makefile.depend |
-rm -f include/kernel include/arch include/libarch include/libadt libc.a arch/$(ARCH)/_link.ld Makefile.depend |
find generic/ arch/$(ARCH)/ -name '*.o' -follow -exec rm \{\} \; |
depend: kerninc |