Changeset 04552a80 in mainline


Ignore:
Timestamp:
2006-05-17T20:51:08Z (19 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
25f9823
Parents:
04a73cdf
Message:

code cleanup (somebody should read the coding style guide)
remove DONT_OPEN_STDIO (this has to be done in a different way, ppc32 linker segfaults on initiating extern variable)
remove deprecated libipc stuff

Files:
8 edited

Legend:

Unmodified
Added
Removed
  • fb/fb.c

    r04a73cdf r04552a80  
    5454
    5555#define EFB (-1)
    56 
    57 extern int __DONT_OPEN_STDIO__=1;
    5856
    5957#define DEFAULT_BGCOLOR         0x000080
  • libc/Makefile

    r04a73cdf r04552a80  
    8080        ln -sfn kernel/arch include/arch
    8181        ln -sfn ../arch/$(ARCH)/include include/libarch
    82         ln -sfn ../../libipc/include include/libipc
    8382        ln -sfn ../../libadt/include include/libadt
    8483
     
    8685
    8786clean:
    88         -rm -f include/kernel include/arch include/libarch include/libipc include/libadt libc.a arch/$(ARCH)/_link.ld Makefile.depend
     87        -rm -f include/kernel include/arch include/libarch include/libadt libc.a arch/$(ARCH)/_link.ld Makefile.depend
    8988        find generic/ arch/$(ARCH)/ -name '*.o' -follow -exec rm \{\} \;
    9089
  • libc/generic/io/io.c

    r04a73cdf r04552a80  
    9393        return EOF;
    9494}
    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  
    1111#define FDS 32
    1212
    13 typedef struct stream_t
    14 {
     13typedef struct stream_t {
    1514        pwritefn_t w;
    1615        preadfn_t r;
    1716        void * param;
    18 }stream_t;
     17} stream_t;
    1918
    2019
    21 typedef struct vfb_descriptor_t
    22 {
     20typedef struct vfb_descriptor_t {
    2321        int phone;
    2422        int vfb;
    25 }vfb_descriptor_t;
     23} vfb_descriptor_t;
    2624
    2725
    28 stream_t streams[FDS]={{0,0,0}};
     26stream_t streams[FDS] = {{0, 0, 0}};
    2927
    3028/*
     
    3533}*/
    3634
    37 static void vfb_send_char(vfb_descriptor_t *d,char c)
     35static void vfb_send_char(vfb_descriptor_t *d, char c)
    3836{
    3937        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);
    4139}
    4240                               
    43 static ssize_t write_vfb(void *param, const void * buf, size_t count)
     41static ssize_t write_vfb(void *param, const void *buf, size_t count)
    4442{
    4543        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]);
    4746       
    4847        return count;
     
    5150
    5251
    53 static ssize_t write_stderr(void *param, const void * buf, size_t count)
     52static ssize_t write_stderr(void *param, const void *buf, size_t count)
    5453{
    5554        return count;
     
    5857
    5958
    60 stream_t open_vfb(void);
    6159stream_t open_vfb(void)
    6260{
     
    6765        ipcarg_t vfb_no;
    6866       
    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) {
    7168                volatile int a;
    72                 for(a=0;a<1048576;a++);
     69               
     70                for (a = 0; a < 1048576; a++);
    7371        }
    7472       
    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));
    7775       
    78         vfb->phone=phoneid;
    79         vfb->vfb=vfb_no;
     76        vfb->phone = phoneid;
     77        vfb->vfb = vfb_no;
    8078       
    81        
    82         stream.w=write_vfb;
    83         stream.param=vfb;
     79        stream.w = write_vfb;
     80        stream.param = vfb;
    8481        return stream;
    8582}
    8683
    8784
    88 fd_t open(const char *fname,int flags)
     85fd_t open(const char *fname, int flags)
    8986{
    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;
    9896                return c;
    9997        }
    10098       
    101         if(!strcmp(fname,"stdout"))
    102         {
    103                 //streams[c].w=write_stdout;
     99        if (!strcmp(fname, "stdout")) {
     100                //streams[c].w = write_stdout;
    104101                //return c;
    105                 streams[c]=open_vfb();
     102                streams[c] = open_vfb();
    106103                return c;
    107104        }
    108105       
    109         if(!strcmp(fname,"stderr"))
    110         {
    111                 streams[c].w=write_stderr;
     106        if (!strcmp(fname, "stderr")) {
     107                streams[c].w = write_stderr;
    112108                return c;
    113109        }
     
    115111
    116112
    117 ssize_t write(int fd, const void * buf, size_t count)
     113ssize_t write(int fd, const void *buf, size_t count)
    118114{
    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       
    120118        return 0;
    121119}
    122 
    123 
  • libc/generic/libc.c

    r04a73cdf r04552a80  
    3333#include <psthread.h>
    3434#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>
    4036
    4137void _exit(int status) {
     
    4642        tcb_t *tcb;
    4743       
    48         if(!__DONT_OPEN_STDIO__)
    49         {
    50                 open("stdin",0);
    51                 open("stdout",0);
    52                 open("stderr",0);
    53         }       
    54        
    5544        tcb = __make_tls();
    5645        __tcb_set(tcb);
    5746        psthread_setup(tcb);
    5847        _ipc_init();
     48       
     49        open("stdin", 0);
     50        open("stdout", 0);
     51        open("stderr", 0);
    5952}
    6053
  • libc/include/io/stream.h

    r04a73cdf r04552a80  
    77
    88
    9 typedef ssize_t (*pwritefn_t)(void *,const void *,size_t);
     9typedef ssize_t (*pwritefn_t)(void *, const void *, size_t);
    1010typedef ssize_t (*preadfn_t)(void);
    1111
    12 fd_t open(const char *fname,int flags);
    13 
    14 
    15 
    16 
     12fd_t open(const char *fname, int flags);
  • libc/include/ipc/fb.h

    r04a73cdf r04552a80  
    1212#define METHOD_WIDTH 16
    1313#define ITEM_WIDTH 16
    14 #define COUNT_WIDTH 16 /*Should be 8 times integer*/
     14#define COUNT_WIDTH 16 /* Should be 8 times integer */
    1515
    1616
    17 struct _fb_method
    18 {
    19         unsigned m     : METHOD_WIDTH;
    20         unsigned item  : ITEM_WIDTH;
    21 } __attribute__ ((packed));
     17struct _fb_method {
     18        unsigned m : METHOD_WIDTH;
     19        unsigned item : ITEM_WIDTH;
     20} __attribute__((packed));
    2221
    23 union fb_method
    24 {
     22union fb_method {
    2523        struct _fb_method m;
    2624        __native fill;
    27 }__attribute__ ((packed));
     25} __attribute__((packed));
    2826
    29 struct fb_call_args
    30 {
     27struct fb_call_args {
    3128        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));
    4136
    42 struct fb_ipc_args
    43 {
     37struct fb_ipc_args {
    4438        __native method;
    4539        __native arg1;
    4640        __native arg2;
    4741        __native arg3;
    48 } __attribute__ ((packed));
     42} __attribute__((packed));
    4943
    50 union fb_args
    51 {
     44union fb_args {
    5245        struct fb_call_args fb_args;
    5346        struct fb_ipc_args ipc_args;
    54 }__attribute__ ((packed));
     47} __attribute__((packed));
    5548
    5649typedef union fb_args fb_args_t;
    5750
    5851#endif
    59 
    60 
  • ns/ns.c

    r04a73cdf r04552a80  
    4545
    4646#define NS_HASH_TABLE_CHAINS    20
    47 
    48 extern int __DONT_OPEN_STDIO__=1;
    4947
    5048static int register_service(ipcarg_t service, ipcarg_t phone, ipc_call_t *call);
Note: See TracChangeset for help on using the changeset viewer.