Changeset 2f57690 in mainline


Ignore:
Timestamp:
2009-03-03T12:41:39Z (15 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
deca67b
Parents:
561db3f
Message:

cstyle

Files:
5 edited

Legend:

Unmodified
Added
Removed
  • kernel/arch/ia32/src/boot/cboot.c

    r561db3f r2f57690  
    4747/** Extract command name from the multiboot module command line.
    4848 *
    49  * @param buf           Destination buffer (will always null-terminate).
    50  * @param n             Size of destination buffer.
    51  * @param cmd_line      Input string (the command line).                       
     49 * @param buf      Destination buffer (will always null-terminate).
     50 * @param n        Size of destination buffer.
     51 * @param cmd_line Input string (the command line).
     52 *
    5253 */
    5354static void extract_command(char *buf, size_t n, const char *cmd_line)
     
    5556        const char *start, *end, *cp;
    5657        size_t max_len;
    57 
     58       
    5859        /* Find the first space. */
    5960        end = strchr(cmd_line, ' ');
    60         if (end == NULL) end = cmd_line + strlen(cmd_line);
    61 
     61        if (end == NULL)
     62                end = cmd_line + strlen(cmd_line);
     63       
    6264        /*
    6365         * Find last occurence of '/' before 'end'. If found, place start at
     
    7375                --cp;
    7476        }
    75 
     77       
    7678        /* Copy the command and null-terminate the string. */
    7779        max_len = min(n - 1, (size_t) (end - start));
     
    8183
    8284/** C part of ia32 boot sequence.
    83  * @param signature     Should contain the multiboot signature.
    84  * @param mi            Pointer to the multiboot information structure.
     85 *
     86 * @param signature Should contain the multiboot signature.
     87 * @param mi        Pointer to the multiboot information structure.
    8588 */
    8689void ia32_cboot(uint32_t signature, const mb_info_t *mi)
     
    8992        mb_mod_t *mods;
    9093        uint32_t i;
    91 
    92         if (signature == MULTIBOOT_LOADER_MAGIC) {
     94       
     95        if (signature == MULTIBOOT_LOADER_MAGIC)
    9396                flags = mi->flags;
    94         } else {
     97        else {
    9598                /* No multiboot info available. */
    9699                flags = 0;
    97100        }
    98 
     101       
    99102        /* Copy module information. */
    100 
     103       
    101104        if ((flags & MBINFO_FLAGS_MODS) != 0) {
    102105                init.cnt = mi->mods_count;
    103106                mods = mi->mods_addr;
    104 
     107               
    105108                for (i = 0; i < init.cnt; i++) {
    106109                        init.tasks[i].addr = mods[i].start + 0x80000000;
    107110                        init.tasks[i].size = mods[i].end - mods[i].start;
    108 
     111                       
    109112                        /* Copy command line, if available. */
    110113                        if (mods[i].string) {
     
    112115                                    CONFIG_TASK_NAME_BUFLEN,
    113116                                    mods[i].string);
    114                         } else {
     117                        } else
    115118                                init.tasks[i].name[0] = '\0';
    116                         }
    117119                }
    118         } else {
     120        } else
    119121                init.cnt = 0;
    120         }
    121 
     122       
    122123        /* Copy memory map. */
    123 
     124       
    124125        int32_t mmap_length;
    125126        mb_mmap_t *mme;
    126127        uint32_t size;
    127 
     128       
    128129        if ((flags & MBINFO_FLAGS_MMAP) != 0) {
    129130                mmap_length = mi->mmap_length;
    130131                mme = mi->mmap_addr;
    131132                e820counter = 0;
    132 
     133               
    133134                i = 0;
    134135                while (mmap_length > 0) {
    135136                        e820table[i++] = mme->mm_info;
    136 
     137                       
    137138                        /* Compute address of next structure. */
    138139                        size = sizeof(mme->size) + mme->size;
     
    140141                        mmap_length -= size;
    141142                }
    142 
     143               
    143144                e820counter = i;
    144         } else {
     145        } else
    145146                e820counter = 0;
    146         }
    147 
     147       
    148148#ifdef CONFIG_SMP
    149149        /* Copy AP bootstrap routines below 1 MB. */
     
    151151            (size_t) &_hardcoded_unmapped_size);
    152152#endif
    153 
     153       
    154154        main_bsp();
    155155}
  • kernel/generic/include/string.h

    r561db3f r2f57690  
    2727 */
    2828
    29 /** @addtogroup generic 
     29/** @addtogroup generic
    3030 * @{
    3131 */
  • kernel/generic/src/lib/string.c

    r561db3f r2f57690  
    2727 */
    2828
    29 /** @addtogroup generic 
     29/** @addtogroup generic
    3030 * @{
    3131 */
     
    3333/**
    3434 * @file
    35  * @brief       Miscellaneous functions.
     35 * @brief Miscellaneous functions.
    3636 */
    3737
     
    4848 *
    4949 * @return Number of characters in str.
     50 *
    5051 */
    5152size_t strlen(const char *str)
     
    5354        int i;
    5455       
    55         for (i = 0; str[i]; i++)
    56                 ;
     56        for (i = 0; str[i]; i++);
    5757       
    5858        return i;
     
    8181        if (*src == *dst)
    8282                return 0;
     83       
    8384        if (!*src)
    8485                return -1;
     86       
    8587        return 1;
    8688}
     
    108110                if (*src < *dst)
    109111                        return -1;
     112               
    110113                if (*src > *dst)
    111114                        return 1;
    112115        }
     116       
    113117        if (i == len || *src == *dst)
    114118                return 0;
     119       
    115120        if (!*src)
    116121                return -1;
     122       
    117123        return 1;
    118124}
     
    126132 * last copied character.
    127133 *
    128  * @param src Source string.
     134 * @param src  Source string.
    129135 * @param dest Destination buffer.
    130  * @param len Size of destination buffer.
     136 * @param len  Size of destination buffer.
     137 *
    131138 */
    132139void strncpy(char *dest, const char *src, size_t len)
    133140{
    134141        unsigned int i;
    135 
     142       
    136143        for (i = 0; i < len; i++) {
    137144                if (!(dest[i] = src[i]))
    138145                        return;
    139146        }
    140 
     147       
    141148        dest[i - 1] = '\0';
    142149}
     
    144151/** Find first occurence of character in string.
    145152 *
    146  * @param s     String to search.
    147  * @param i     Character to look for.
     153 * @param s String to search.
     154 * @param i Character to look for.
    148155 *
    149  * @return      Pointer to character in @a s or NULL if not found.
     156 * @return Pointer to character in @a s or NULL if not found.
    150157 */
    151158extern char *strchr(const char *s, int i)
    152159{
    153160        while (*s != '\0') {
    154                 if (*s == i) return (char *) s;
     161                if (*s == i)
     162                        return (char *) s;
    155163                ++s;
    156164        }
    157 
     165       
    158166        return NULL;
    159167}
  • kernel/generic/src/main/kinit.c

    r561db3f r2f57690  
    3333/**
    3434 * @file
    35  * @brief       Kernel initialization thread.
     35 * @brief Kernel initialization thread.
    3636 *
    3737 * This file contains kinit kernel thread which carries out
     
    8181#endif
    8282
    83 #define BOOT_PREFIX             "boot:"
    84 #define BOOT_PREFIX_LEN         5
     83#define BOOT_PREFIX      "boot:"
     84#define BOOT_PREFIX_LEN  5
    8585
    8686/** Kernel initialization thread.
     
    9898        thread_t *thread;
    9999#endif
    100 
     100       
    101101        /*
    102102         * Detach kinit as nobody will call thread_join_timeout() on it.
    103103         */
    104104        thread_detach(THREAD);
    105 
     105       
    106106        interrupts_disable();
    107 
    108 #ifdef CONFIG_SMP                       
     107       
     108#ifdef CONFIG_SMP
    109109        if (config.cpu_count > 1) {
    110110                waitq_initialize(&ap_completion_wq);
     
    126126                thread_detach(thread);
    127127        }
    128 #endif /* CONFIG_SMP */
    129        
    130 #ifdef CONFIG_SMP
     128       
    131129        if (config.cpu_count > 1) {
    132130                count_t i;
     
    144142                        } else
    145143                                printf("Unable to create kcpulb thread for cpu" PRIc "\n", i);
    146 
    147144                }
    148145        }
     
    153150         */
    154151        arch_post_smp_init();
    155 
     152       
    156153#ifdef CONFIG_KCONSOLE
    157154        if (stdin) {
     
    180177                        continue;
    181178                }
    182 
     179               
    183180                /*
    184181                 * Construct task name from the 'boot:' prefix and the
    185182                 * name stored in the init structure (if any).
    186183                 */
    187 
    188                 char namebuf[TASK_NAME_BUFLEN], *name;
    189 
     184               
     185                char namebuf[TASK_NAME_BUFLEN];
     186                char *name;
     187               
    190188                name = init.tasks[i].name;
    191                 if (name[0] == '\0') name = "<unknown>";
    192 
     189                if (name[0] == '\0')
     190                        name = "<unknown>";
     191               
    193192                ASSERT(TASK_NAME_BUFLEN >= BOOT_PREFIX_LEN);
    194193                strncpy(namebuf, BOOT_PREFIX, TASK_NAME_BUFLEN);
     
    234233                }
    235234        }
    236 
     235       
    237236#ifdef CONFIG_KCONSOLE
    238237        if (!stdin) {
  • uspace/srv/loader/main.c

    r561db3f r2f57690  
    2828
    2929/** @addtogroup loader
    30  * @brief       Loads and runs programs from VFS.
     30 * @brief Loads and runs programs from VFS.
    3131 * @{
    32  */ 
     32 */
    3333/**
    3434 * @file
    35  * @brief       Loads and runs programs from VFS.
     35 * @brief Loads and runs programs from VFS.
    3636 *
    3737 * The program loader is a special init binary. Its image is used
     
    8989        task_id_t task_id;
    9090        size_t len;
    91 
     91       
    9292        task_id = task_get_id();
    93 
     93       
    9494        if (!ipc_data_read_receive(&callid, &len)) {
    9595                ipc_answer_0(callid, EINVAL);
     
    9797                return;
    9898        }
    99 
    100         if (len > sizeof(task_id)) len = sizeof(task_id);
    101 
     99       
     100        if (len > sizeof(task_id))
     101                len = sizeof(task_id);
     102       
    102103        ipc_data_read_finalize(callid, &task_id, len);
    103104        ipc_answer_0(rid, EOK);
     
    115116        size_t len;
    116117        char *name_buf;
    117 
     118       
    118119        if (!ipc_data_write_receive(&callid, &len)) {
    119120                ipc_answer_0(callid, EINVAL);
     
    121122                return;
    122123        }
    123 
     124       
    124125        name_buf = malloc(len + 1);
    125126        if (!name_buf) {
     
    128129                return;
    129130        }
    130 
     131       
    131132        ipc_data_write_finalize(callid, name_buf, len);
    132133        ipc_answer_0(rid, EOK);
    133 
     134       
    134135        if (pathname != NULL) {
    135136                free(pathname);
    136137                pathname = NULL;
    137138        }
    138 
     139       
    139140        name_buf[len] = '\0';
    140141        pathname = name_buf;
     
    152153        char *p;
    153154        int n;
    154 
     155       
    155156        if (!ipc_data_write_receive(&callid, &buf_len)) {
    156157                ipc_answer_0(callid, EINVAL);
     
    158159                return;
    159160        }
    160 
     161       
    161162        if (arg_buf != NULL) {
    162163                free(arg_buf);
    163164                arg_buf = NULL;
    164165        }
    165 
     166       
    166167        if (argv != NULL) {
    167168                free(argv);
    168169                argv = NULL;
    169170        }
    170 
     171       
    171172        arg_buf = malloc(buf_len + 1);
    172173        if (!arg_buf) {
     
    175176                return;
    176177        }
    177 
     178       
    178179        ipc_data_write_finalize(callid, arg_buf, buf_len);
    179180        ipc_answer_0(rid, EOK);
    180 
     181       
    181182        arg_buf[buf_len] = '\0';
    182 
     183       
    183184        /*
    184185         * Count number of arguments
     
    191192                ++n;
    192193        }
    193 
     194       
    194195        /* Allocate argv */
    195196        argv = malloc((n + 1) * sizeof(char *));
    196 
     197       
    197198        if (argv == NULL) {
    198199                free(arg_buf);
     
    201202                return;
    202203        }
    203 
     204       
    204205        /*
    205206         * Fill argv with argument pointers
     
    209210        while (p < arg_buf + buf_len) {
    210211                argv[n] = p;
    211 
     212               
    212213                arg_len = strlen(p);
    213214                p = p + arg_len + 1;
    214215                ++n;
    215216        }
    216 
     217       
    217218        argc = n;
    218219        argv[n] = NULL;
     
    228229{
    229230        int rc;
    230 
     231       
    231232        rc = elf_load_file(pathname, 0, &prog_info);
    232233        if (rc < 0) {
     
    235236                return 1;
    236237        }
    237 
     238       
    238239        elf_create_pcb(&prog_info, &pcb);
    239 
     240       
    240241        pcb.argc = argc;
    241242        pcb.argv = argv;
    242 
     243       
    243244        if (prog_info.interp == NULL) {
    244245                /* Statically linked program */
     
    247248                return 0;
    248249        }
    249 
     250       
    250251        rc = elf_load_file(prog_info.interp, 0, &interp_info);
    251252        if (rc < 0) {
     
    255256                return 1;
    256257        }
    257 
     258       
    258259        is_dyn_linked = true;
    259260        ipc_answer_0(rid, EOK);
    260 
     261       
    261262        return 0;
    262263}
     
    272273{
    273274        const char *cp;
    274 
     275       
    275276        /* Set the task name. */
    276277        cp = strrchr(pathname, '/');
    277278        cp = (cp == NULL) ? pathname : (cp + 1);
    278279        task_set_name(cp);
    279 
     280       
    280281        if (is_dyn_linked == true) {
    281282                /* Dynamically linked program */
     
    283284                DPRINTF("Entry point: 0x%lx\n", interp_info.entry);
    284285                close_console();
    285 
     286               
    286287                ipc_answer_0(rid, EOK);
    287288                elf_run(&interp_info, &pcb);
    288 
    289289        } else {
    290290                /* Statically linked program */
     
    307307        ipc_call_t call;
    308308        int retval;
    309 
     309       
    310310        /* Already have a connection? */
    311311        if (connected) {
     
    313313                return;
    314314        }
    315 
     315       
    316316        connected = true;
    317317       
    318318        /* Accept the connection */
    319319        ipc_answer_0(iid, EOK);
    320 
     320       
    321321        /* Ignore parameters, the connection is already open */
    322         (void)iid; (void)icall;
    323 
     322        (void) iid;
     323        (void) icall;
     324       
    324325        while (1) {
    325326                callid = async_get_call(&call);
    326 
     327               
    327328                switch (IPC_GET_METHOD(call)) {
    328329                case IPC_M_PHONE_HUNGUP:
     
    361362{
    362363        ipcarg_t phonead;
    363 
     364       
    364365        connected = false;
    365366       
    366367        /* Set a handler of incomming connections. */
    367368        async_set_client_connection(loader_connection);
    368 
     369       
    369370        /* Register at naming service. */
    370371        if (ipc_connect_to_me(PHONE_NS, SERVICE_LOAD, 0, 0, &phonead) != 0)
     
    372373       
    373374        async_manager();
    374 
     375       
    375376        /* Never reached */
    376377        return 0;
Note: See TracChangeset for help on using the changeset viewer.