Changeset 04552a80 in mainline
- Timestamp:
- 2006-05-17T20:51:08Z (19 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 25f9823
- Parents:
- 04a73cdf
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
fb/fb.c
r04a73cdf r04552a80 54 54 55 55 #define EFB (-1) 56 57 extern int __DONT_OPEN_STDIO__=1;58 56 59 57 #define DEFAULT_BGCOLOR 0x000080 -
libc/Makefile
r04a73cdf r04552a80 80 80 ln -sfn kernel/arch include/arch 81 81 ln -sfn ../arch/$(ARCH)/include include/libarch 82 ln -sfn ../../libipc/include include/libipc83 82 ln -sfn ../../libadt/include include/libadt 84 83 … … 86 85 87 86 clean: 88 -rm -f include/kernel include/arch include/libarch include/lib ipc include/libadt libc.a arch/$(ARCH)/_link.ld Makefile.depend87 -rm -f include/kernel include/arch include/libarch include/libadt libc.a arch/$(ARCH)/_link.ld Makefile.depend 89 88 find generic/ arch/$(ARCH)/ -name '*.o' -follow -exec rm \{\} \; 90 89 -
libc/generic/io/io.c
r04a73cdf r04552a80 93 93 return EOF; 94 94 } 95 /*96 ssize_t write(int fd, const void * buf, size_t count)97 {98 return (ssize_t) __SYSCALL3(SYS_IO, (sysarg_t) fd, (sysarg_t) buf, (sysarg_t) count);99 }*/100 101 102 103 -
libc/generic/io/stream.c
r04a73cdf r04552a80 11 11 #define FDS 32 12 12 13 typedef struct stream_t 14 { 13 typedef struct stream_t { 15 14 pwritefn_t w; 16 15 preadfn_t r; 17 16 void * param; 18 } stream_t;17 } stream_t; 19 18 20 19 21 typedef struct vfb_descriptor_t 22 { 20 typedef struct vfb_descriptor_t { 23 21 int phone; 24 22 int vfb; 25 } vfb_descriptor_t;23 } vfb_descriptor_t; 26 24 27 25 28 stream_t streams[FDS] ={{0,0,0}};26 stream_t streams[FDS] = {{0, 0, 0}}; 29 27 30 28 /* … … 35 33 }*/ 36 34 37 static void vfb_send_char(vfb_descriptor_t *d, char c)35 static void vfb_send_char(vfb_descriptor_t *d, char c) 38 36 { 39 37 ipcarg_t r0,r1; 40 ipc_call_sync_2(d->phone, FB_PUTCHAR,d->vfb,c,&r0,&r1);38 ipc_call_sync_2(d->phone, FB_PUTCHAR, d->vfb, c, &r0, &r1); 41 39 } 42 40 43 static ssize_t write_vfb(void *param, const void * 41 static ssize_t write_vfb(void *param, const void *buf, size_t count) 44 42 { 45 43 int i; 46 for(i=0;i<count;i++) vfb_send_char((vfb_descriptor_t *)param,((char*)buf)[i]); 44 for (i = 0; i < count; i++) 45 vfb_send_char((vfb_descriptor_t *) param, ((char *) buf)[i]); 47 46 48 47 return count; … … 51 50 52 51 53 static ssize_t write_stderr(void *param, const void * 52 static ssize_t write_stderr(void *param, const void *buf, size_t count) 54 53 { 55 54 return count; … … 58 57 59 58 60 stream_t open_vfb(void);61 59 stream_t open_vfb(void) 62 60 { … … 67 65 ipcarg_t vfb_no; 68 66 69 while((phoneid=ipc_connect_me_to(PHONE_NS,SERVICE_VIDEO,0))<0) 70 { 67 while ((phoneid = ipc_connect_me_to(PHONE_NS, SERVICE_VIDEO, 0)) < 0) { 71 68 volatile int a; 72 for(a=0;a<1048576;a++); 69 70 for (a = 0; a < 1048576; a++); 73 71 } 74 72 75 ipc_call_sync(phoneid, FB_GET_VFB,0,&vfb_no);76 vfb =malloc(sizeof(vfb_descriptor_t));73 ipc_call_sync(phoneid, FB_GET_VFB, 0, &vfb_no); 74 vfb = malloc(sizeof(vfb_descriptor_t)); 77 75 78 vfb->phone =phoneid;79 vfb->vfb =vfb_no;76 vfb->phone = phoneid; 77 vfb->vfb = vfb_no; 80 78 81 82 stream.w=write_vfb; 83 stream.param=vfb; 79 stream.w = write_vfb; 80 stream.param = vfb; 84 81 return stream; 85 82 } 86 83 87 84 88 fd_t open(const char *fname, int flags)85 fd_t open(const char *fname, int flags) 89 86 { 90 int c=0; 91 while(((streams[c].w)||(streams[c].r))&&(c<FDS))c++; 92 if(c==FDS) return EMFILE; 93 94 95 if(!strcmp(fname,"stdin")) 96 { 97 streams[c].r=(preadfn_t)1; 87 int c = 0; 88 89 while (((streams[c].w) || (streams[c].r)) && (c < FDS)) 90 c++; 91 if (c == FDS) 92 return EMFILE; 93 94 if (!strcmp(fname, "stdin")) { 95 streams[c].r = (preadfn_t)1; 98 96 return c; 99 97 } 100 98 101 if(!strcmp(fname,"stdout")) 102 { 103 //streams[c].w=write_stdout; 99 if (!strcmp(fname, "stdout")) { 100 //streams[c].w = write_stdout; 104 101 //return c; 105 streams[c] =open_vfb();102 streams[c] = open_vfb(); 106 103 return c; 107 104 } 108 105 109 if(!strcmp(fname,"stderr")) 110 { 111 streams[c].w=write_stderr; 106 if (!strcmp(fname, "stderr")) { 107 streams[c].w = write_stderr; 112 108 return c; 113 109 } … … 115 111 116 112 117 ssize_t write(int fd, const void * 113 ssize_t write(int fd, const void *buf, size_t count) 118 114 { 119 if(fd<FDS) return streams[fd].w(streams[fd].param,buf,count); 115 if (fd < FDS) 116 return streams[fd].w(streams[fd].param, buf, count); 117 120 118 return 0; 121 119 } 122 123 -
libc/generic/libc.c
r04a73cdf r04552a80 33 33 #include <psthread.h> 34 34 #include <io/stream.h> 35 36 int __DONT_OPEN_STDIO__; 37 38 /* We should probably merge libc and libipc together */ 39 extern void _ipc_init(void); 35 #include <ipc/ipc.h> 40 36 41 37 void _exit(int status) { … … 46 42 tcb_t *tcb; 47 43 48 if(!__DONT_OPEN_STDIO__)49 {50 open("stdin",0);51 open("stdout",0);52 open("stderr",0);53 }54 55 44 tcb = __make_tls(); 56 45 __tcb_set(tcb); 57 46 psthread_setup(tcb); 58 47 _ipc_init(); 48 49 open("stdin", 0); 50 open("stdout", 0); 51 open("stderr", 0); 59 52 } 60 53 -
libc/include/io/stream.h
r04a73cdf r04552a80 7 7 8 8 9 typedef ssize_t (*pwritefn_t)(void *, const void *,size_t);9 typedef ssize_t (*pwritefn_t)(void *, const void *, size_t); 10 10 typedef ssize_t (*preadfn_t)(void); 11 11 12 fd_t open(const char *fname,int flags); 13 14 15 16 12 fd_t open(const char *fname, int flags); -
libc/include/ipc/fb.h
r04a73cdf r04552a80 12 12 #define METHOD_WIDTH 16 13 13 #define ITEM_WIDTH 16 14 #define COUNT_WIDTH 16 /* Should be 8 times integer*/14 #define COUNT_WIDTH 16 /* Should be 8 times integer */ 15 15 16 16 17 struct _fb_method 18 { 19 unsigned m : METHOD_WIDTH; 20 unsigned item : ITEM_WIDTH; 21 } __attribute__ ((packed)); 17 struct _fb_method { 18 unsigned m : METHOD_WIDTH; 19 unsigned item : ITEM_WIDTH; 20 } __attribute__((packed)); 22 21 23 union fb_method 24 { 22 union fb_method { 25 23 struct _fb_method m; 26 24 __native fill; 27 } __attribute__((packed));25 } __attribute__((packed)); 28 26 29 struct fb_call_args 30 { 27 struct fb_call_args { 31 28 union fb_method method; 32 union 33 { 34 struct 35 { 36 unsigned count :COUNT_WIDTH; 37 char chars[3*sizeof(__native)-(COUNT_WIDTH>>3)]; 38 }putchar __attribute__ ((packed)); 39 }data ; //__attribute__ ((packed)); 40 }__attribute__ ((packed)); 29 union { 30 struct { 31 unsigned count : COUNT_WIDTH; 32 char chars[3 * sizeof(__native) - (COUNT_WIDTH >> 3)]; 33 } putchar __attribute__((packed)); 34 } data ; // __attribute__((packed)); 35 } __attribute__((packed)); 41 36 42 struct fb_ipc_args 43 { 37 struct fb_ipc_args { 44 38 __native method; 45 39 __native arg1; 46 40 __native arg2; 47 41 __native arg3; 48 } __attribute__ 42 } __attribute__((packed)); 49 43 50 union fb_args 51 { 44 union fb_args { 52 45 struct fb_call_args fb_args; 53 46 struct fb_ipc_args ipc_args; 54 } __attribute__((packed));47 } __attribute__((packed)); 55 48 56 49 typedef union fb_args fb_args_t; 57 50 58 51 #endif 59 60 -
ns/ns.c
r04a73cdf r04552a80 45 45 46 46 #define NS_HASH_TABLE_CHAINS 20 47 48 extern int __DONT_OPEN_STDIO__=1;49 47 50 48 static int register_service(ipcarg_t service, ipcarg_t phone, ipc_call_t *call);
Note:
See TracChangeset
for help on using the changeset viewer.