Changeset b60c582 in mainline


Ignore:
Timestamp:
2009-04-03T08:02:30Z (15 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
2398ee9
Parents:
9be1d58
Message:

update for string changes

Location:
kernel
Files:
29 edited

Legend:

Unmodified
Added
Removed
  • kernel/arch/arm32/src/arm32.c

    r9be1d58 rb60c582  
    6363                init.tasks[i].addr = bootinfo->tasks[i].addr;
    6464                init.tasks[i].size = bootinfo->tasks[i].size;
    65                 strncpy(init.tasks[i].name, bootinfo->tasks[i].name,
     65                str_ncpy(init.tasks[i].name, bootinfo->tasks[i].name,
    6666                        CONFIG_TASK_NAME_BUFLEN);
    6767        }
  • kernel/arch/arm32/src/asm.S

    r9be1d58 rb60c582  
    3131
    3232.global memsetb
     33.global memsetw
    3334.global memcpy
    3435.global memcpy_from_uspace
     
    3940memsetb:
    4041        b _memsetb
     42
     43memsetw:
     44        b _memsetw
    4145
    4246memcpy:
  • kernel/arch/ia64/src/cpu/cpu.c

    r9be1d58 rb60c582  
    5656        *((uint64_t *) &vendor[0 * sizeof(uint64_t)]) = CPU->arch.cpuid0;
    5757        *((uint64_t *) &vendor[1 * sizeof(uint64_t)]) = CPU->arch.cpuid1;
    58         vendor[sizeof(vendor) - 1] = '\0';
     58        vendor[sizeof(vendor) - 1] = 0;
    5959       
    6060        switch(m->arch.cpuid3.family) {
  • kernel/arch/ia64/src/ia64.c

    r9be1d58 rb60c582  
    8888                    VRN_MASK;
    8989                init.tasks[i].size = bootinfo->taskmap.tasks[i].size;
    90                 strncpy(init.tasks[i].name, bootinfo->taskmap.tasks[i].name,
     90                str_ncpy(init.tasks[i].name, bootinfo->taskmap.tasks[i].name,
    9191                        CONFIG_TASK_NAME_BUFLEN);
    9292        }
  • kernel/arch/ia64/src/interrupt.c

    r9be1d58 rb60c582  
    5555#include <mm/tlb.h>
    5656#include <symtab.h>
     57#include <putchar.h>
    5758
    5859#define VECTORS_64_BUNDLE       20
  • kernel/arch/ia64/src/ski/ski.c

    r9be1d58 rb60c582  
    4242#include <arch/asm.h>
    4343#include <arch/drivers/kbd.h>
     44#include <string.h>
    4445#include <arch.h>
    4546
     
    4950static bool kbd_disabled;
    5051
     52static void ski_do_putchar(const wchar_t ch)
     53{
     54        asm volatile (
     55                "mov r15 = %[cmd]\n"
     56                "mov r32 = %[ch]\n"   /* r32 is in0 */
     57                "break 0x80000\n"  /* modifies r8 */
     58                :
     59                : [cmd] "i" (SKI_PUTCHAR), [ch] "r" (ch)
     60                : "r15", "in0", "r8"
     61        );
     62}
     63
    5164/** Display character on debug console
    5265 *
     
    5770 * @param ch Character to be printed.
    5871 */
    59 static void ski_putchar(outdev_t *d, const char ch, bool silent)
     72static void ski_putchar(outdev_t *d, const wchar_t ch, bool silent)
    6073{
    6174        if (!silent) {
    62                 asm volatile (
    63                         "mov r15 = %0\n"
    64                         "mov r32 = %1\n"   /* r32 is in0 */
    65                         "break 0x80000\n"  /* modifies r8 */
    66                         :
    67                         : "i" (SKI_PUTCHAR), "r" (ch)
    68                         : "r15", "in0", "r8"
    69                 );
    70                
    71                 if (ch == '\n')
    72                         ski_putchar(d, '\r', false);
     75                if (ascii_check(ch)) {
     76                        if (ch == '\n')
     77                                ski_do_putchar('\r');
     78                       
     79                        ski_do_putchar(ch);
     80                } else
     81                        ski_do_putchar(invalch);
    7382        }
    7483}
  • kernel/arch/mips32/src/asm.S

    r9be1d58 rb60c582  
    6161memsetb:
    6262        j _memsetb
     63        nop
     64
     65
     66.global memsetw
     67memsetw:
     68        j _memsetw
    6369        nop
    6470
  • kernel/arch/mips32/src/mips32.c

    r9be1d58 rb60c582  
    9292                init.tasks[i].addr = bootinfo->tasks[i].addr;
    9393                init.tasks[i].size = bootinfo->tasks[i].size;
    94                 strncpy(init.tasks[i].name, bootinfo->tasks[i].name,
     94                str_ncpy(init.tasks[i].name, bootinfo->tasks[i].name,
    9595                        CONFIG_TASK_NAME_BUFLEN);
    9696        }
  • kernel/arch/ppc32/src/asm.S

    r9be1d58 rb60c582  
    3535.global iret_syscall
    3636.global memsetb
     37.global memsetw
    3738.global memcpy
    3839.global memcpy_from_uspace
     
    202203
    203204        rfi
    204        
     205
    205206memsetb:
    206207        b _memsetb
     208
     209memsetw:
     210        b _memsetw
    207211
    208212memcpy:
  • kernel/arch/ppc32/src/ppc32.c

    r9be1d58 rb60c582  
    6262                init.tasks[i].addr = PA2KA(bootinfo.taskmap.tasks[i].addr);
    6363                init.tasks[i].size = bootinfo.taskmap.tasks[i].size;
    64                 strncpy(init.tasks[i].name, bootinfo.taskmap.tasks[i].name,
     64                str_ncpy(init.tasks[i].name, bootinfo.taskmap.tasks[i].name,
    6565                        CONFIG_TASK_NAME_BUFLEN);
    6666        }
  • kernel/arch/sparc64/include/drivers/sgcn.h

    r9be1d58 rb60c582  
    3939#include <console/chardev.h>
    4040
    41 /* number of bytes in the TOC magic, including the terminating '\0' */
     41/* number of bytes in the TOC magic, including the NULL-terminator */
    4242#define TOC_MAGIC_BYTES         8
    4343
    44 /* number of bytes in the TOC key, including the terminating '\0' */
     44/* number of bytes in the TOC key, including the NULL-terminator */
    4545#define TOC_KEY_SIZE            8
    4646
     
    4848#define MAX_TOC_ENTRIES         32
    4949
    50 /* number of bytes in the SGCN buffer magic, including the terminating '\0' */
     50/* number of bytes in the SGCN buffer magic, including the NULL-terminator */
    5151#define SGCN_MAGIC_BYTES        4
    5252
  • kernel/arch/sparc64/src/console.c

    r9be1d58 rb60c582  
    119119        prop = ofw_tree_getprop(aliases, "def-cn");
    120120       
    121         if ((!prop) || (!prop->value) || (strcmp(prop->value, "/sgcn") != 0)) {
     121        if ((!prop) || (!prop->value) || (str_cmp(prop->value, "/sgcn") != 0)) {
    122122                standard_console_init(aliases);
    123123        } else {
  • kernel/arch/sparc64/src/drivers/kbd.c

    r9be1d58 rb60c582  
    8787         * Determine keyboard serial controller type.
    8888         */
    89         if (strcmp(name, "zs") == 0)
     89        if (str_cmp(name, "zs") == 0)
    9090                kbd_type = KBD_Z8530;
    91         else if (strcmp(name, "su") == 0)
     91        else if (str_cmp(name, "su") == 0)
    9292                kbd_type = KBD_NS16550;
    9393       
  • kernel/arch/sparc64/src/drivers/pci.c

    r9be1d58 rb60c582  
    184184         * First, verify this is a PCI node.
    185185         */
    186         ASSERT(strcmp(ofw_tree_node_name(node), "pci") == 0);
     186        ASSERT(str_cmp(ofw_tree_node_name(node), "pci") == 0);
    187187
    188188        /*
     
    193193                return NULL;
    194194       
    195         if (strcmp(prop->value, "SUNW,sabre") == 0) {
     195        if (str_cmp(prop->value, "SUNW,sabre") == 0) {
    196196                /*
    197197                 * PCI controller Sabre.
     
    199199                 */
    200200                return pci_sabre_init(node);
    201         } else if (strcmp(prop->value, "SUNW,psycho") == 0) {
     201        } else if (str_cmp(prop->value, "SUNW,psycho") == 0) {
    202202                /*
    203203                 * PCI controller Psycho.
  • kernel/arch/sparc64/src/drivers/scr.c

    r9be1d58 rb60c582  
    6464        name = ofw_tree_node_name(node);
    6565       
    66         if (strcmp(name, "SUNW,m64B") == 0)
     66        if (str_cmp(name, "SUNW,m64B") == 0)
    6767                scr_type = SCR_ATYFB;
    68         else if (strcmp(name, "SUNW,XVR-100") == 0)
     68        else if (str_cmp(name, "SUNW,XVR-100") == 0)
    6969                scr_type = SCR_XVR;
    70         else if (strcmp(name, "SUNW,ffb") == 0)
     70        else if (str_cmp(name, "SUNW,ffb") == 0)
    7171                scr_type = SCR_FFB;
    72         else if (strcmp(name, "cgsix") == 0)
     72        else if (str_cmp(name, "cgsix") == 0)
    7373                scr_type = SCR_CGSIX;
    7474       
  • kernel/arch/sparc64/src/drivers/sgcn.c

    r9be1d58 rb60c582  
    208208        init_sram_begin();
    209209               
    210         ASSERT(strcmp(SRAM_TOC->magic, SRAM_TOC_MAGIC) == 0);
     210        ASSERT(str_cmp(SRAM_TOC->magic, SRAM_TOC_MAGIC) == 0);
    211211       
    212212        /* lookup TOC entry with the correct key */
    213213        uint32_t i;
    214214        for (i = 0; i < MAX_TOC_ENTRIES; i++) {
    215                 if (strcmp(SRAM_TOC->keys[i].key, CONSOLE_KEY) == 0)
     215                if (str_cmp(SRAM_TOC->keys[i].key, CONSOLE_KEY) == 0)
    216216                        break;
    217217        }
  • kernel/arch/sparc64/src/mm/page.c

    r9be1d58 rb60c582  
    6363uintptr_t hw_map(uintptr_t physaddr, size_t size)
    6464{
    65         return PA2KA(physaddr);
     65        if (last_frame + ALIGN_UP(size, PAGE_SIZE) > KA2PA(KERNEL_ADDRESS_SPACE_END_ARCH))
     66                panic("Unable to map physical memory %p (%d bytes).", physaddr, size)
     67       
     68        uintptr_t virtaddr = PA2KA(last_frame);
     69        pfn_t i;
     70        for (i = 0; i < ADDR2PFN(ALIGN_UP(size, PAGE_SIZE)); i++) {
     71                uintptr_t addr = PFN2ADDR(i);
     72                page_mapping_insert(AS_KERNEL, virtaddr + addr, physaddr + addr, PAGE_NOT_CACHEABLE | PAGE_WRITE);
     73        }
     74       
     75        last_frame = ALIGN_UP(last_frame + size, FRAME_SIZE);
     76       
     77        return virtaddr;
    6678}
    6779
  • kernel/arch/sparc64/src/sparc64.c

    r9be1d58 rb60c582  
    6262                init.tasks[i].addr = (uintptr_t) bootinfo.taskmap.tasks[i].addr;
    6363                init.tasks[i].size = bootinfo.taskmap.tasks[i].size;
    64                 strncpy(init.tasks[i].name, bootinfo.taskmap.tasks[i].name,
     64                str_ncpy(init.tasks[i].name, bootinfo.taskmap.tasks[i].name,
    6565                        CONFIG_TASK_NAME_BUFLEN);
    6666        }
  • kernel/genarch/src/drivers/dsrln/dsrlnout.c

    r9be1d58 rb60c582  
    4141#include <console/console.h>
    4242#include <sysinfo/sysinfo.h>
     43#include <string.h>
    4344
    4445static ioport8_t *dsrlnout_base;
    4546
    46 static void dsrlnout_putchar(outdev_t *dev __attribute__((unused)), const char ch, bool silent)
     47static void dsrlnout_putchar(outdev_t *dev __attribute__((unused)), const wchar_t ch, bool silent)
    4748{
    48         if (!silent)
    49                 pio_write_8(dsrlnout_base, ch);
     49        if (!silent) {
     50                if (ascii_check(ch))
     51                        pio_write_8(dsrlnout_base, ch);
     52                else
     53                        pio_write_8(dsrlnout_base, invalch);
     54        }
    5055}
    5156
  • kernel/genarch/src/multiboot/multiboot.c

    r9be1d58 rb60c582  
    4242/** Extract command name from the multiboot module command line.
    4343 *
    44  * @param buf      Destination buffer (will always null-terminate).
    45  * @param n        Size of destination buffer.
     44 * @param buf      Destination buffer (will always NULL-terminate).
     45 * @param sz       Size of destination buffer (in bytes).
    4646 * @param cmd_line Input string (the command line).
    4747 *
    4848 */
    49 static void extract_command(char *buf, size_t n, const char *cmd_line)
     49static void extract_command(char *buf, size_t sz, const char *cmd_line)
    5050{
    51         const char *start, *end, *cp;
    52         size_t max_len;
    53        
    5451        /* Find the first space. */
    55         end = strchr(cmd_line, ' ');
     52        const char *end = str_chr(cmd_line, ' ');
    5653        if (end == NULL)
    5754                end = cmd_line + str_size(cmd_line);
     
    6158         * next character. Otherwise, place start at beginning of buffer.
    6259         */
    63         cp = end;
    64         start = buf;
     60        const char *cp = end;
     61        const char *start = buf;
     62       
    6563        while (cp != start) {
    6664                if (*cp == '/') {
     
    6866                        break;
    6967                }
    70                 --cp;
     68                cp--;
    7169        }
    7270       
    73         /* Copy the command and null-terminate the string. */
    74         max_len = min(n - 1, (size_t) (end - start));
    75         strncpy(buf, start, max_len + 1);
    76         buf[max_len] = '\0';
     71        /* Copy the command. */
     72        str_ncpy(buf, start, min(sz, (size_t) (end - start) + 1));
    7773}
    7874
     
    8884{
    8985        uint32_t flags;
    90         multiboot_mod_t *mods;
    91         uint32_t i;
    9286       
    9387        if (signature == MULTIBOOT_LOADER_MAGIC)
     
    9993       
    10094        /* Copy module information. */
    101        
     95        uint32_t i;
    10296        if ((flags & MBINFO_FLAGS_MODS) != 0) {
    10397                init.cnt = min(mi->mods_count, CONFIG_INIT_TASKS);
    104                 mods = (multiboot_mod_t *) MULTIBOOT_PTR(mi->mods_addr);
     98                multiboot_mod_t *mods
     99                    = (multiboot_mod_t *) MULTIBOOT_PTR(mi->mods_addr);
    105100               
    106101                for (i = 0; i < init.cnt; i++) {
     
    114109                                    MULTIBOOT_PTR(mods[i].string));
    115110                        } else
    116                                 init.tasks[i].name[0] = '\0';
     111                                init.tasks[i].name[0] = 0;
    117112                }
    118113        } else
     
    121116        /* Copy memory map. */
    122117       
    123         int32_t mmap_length;
    124         multiboot_mmap_t *mme;
    125         uint32_t size;
    126        
    127118        if ((flags & MBINFO_FLAGS_MMAP) != 0) {
    128                 mmap_length = mi->mmap_length;
    129                 mme = MULTIBOOT_PTR(mi->mmap_addr);
     119                int32_t mmap_length = mi->mmap_length;
     120                multiboot_mmap_t *mme = MULTIBOOT_PTR(mi->mmap_addr);
    130121                e820counter = 0;
    131122               
     
    135126                       
    136127                        /* Compute address of next structure. */
    137                         size = sizeof(mme->size) + mme->size;
     128                        uint32_t size = sizeof(mme->size) + mme->size;
    138129                        mme = ((void *) mme) + size;
    139130                        mmap_length -= size;
  • kernel/genarch/src/ofw/ebus.c

    r9be1d58 rb60c582  
    128128                return false;
    129129               
    130         if (strcmp(ofw_tree_node_name(controller), "pci") != 0) {
     130        if (str_cmp(ofw_tree_node_name(controller), "pci") != 0) {
    131131                /*
    132132                 * This is not a PCI node.
  • kernel/genarch/src/ofw/fhc.c

    r9be1d58 rb60c582  
    6767                                return true;
    6868                        }
    69                         if (strcmp(ofw_tree_node_name(node->parent), "central") != 0)
     69                        if (str_cmp(ofw_tree_node_name(node->parent), "central") != 0)
    7070                                panic("Unexpected parent node: %s.", ofw_tree_node_name(node->parent));
    7171                       
  • kernel/genarch/src/ofw/ofw_tree.c

    r9be1d58 rb60c582  
    6767       
    6868        for (i = 0; i < node->properties; i++) {
    69                 if (strcmp(node->property[i].name, name) == 0)
     69                if (str_cmp(node->property[i].name, name) == 0)
    7070                        return &node->property[i];
    7171        }
     
    110110         */
    111111        for (cur = node->child; cur; cur = cur->peer) {
    112                 if (strcmp(cur->da_name, name) == 0)
     112                if (str_cmp(cur->da_name, name) == 0)
    113113                        return cur;
    114114        }
     
    122122         */
    123123        for (cur = node->child; cur; cur = cur->peer) {
    124                 if (strcmp(ofw_tree_node_name(cur), name) == 0)
     124                if (str_cmp(ofw_tree_node_name(cur), name) == 0)
    125125                        return cur;
    126126        }
     
    147147                if (!prop || !prop->value)
    148148                        continue;
    149                 if (strcmp(prop->value, name) == 0)
     149                if (str_cmp(prop->value, name) == 0)
    150150                        return cur;
    151151        }
     
    204204                if (!prop || !prop->value)
    205205                        continue;
    206                 if (strcmp(prop->value, name) == 0)
     206                if (str_cmp(prop->value, name) == 0)
    207207                        return cur;
    208208        }
     
    230230                if (!prop || !prop->value)
    231231                        continue;
    232                 if (strcmp(prop->value, name) == 0)
     232                if (str_cmp(prop->value, name) == 0)
    233233                        return cur;
    234234        }
     
    253253                return NULL;
    254254       
    255         for (i = 1; i < str_size(path) && node; i = j + 1) {
    256                 for (j = i; j < str_size(path) && path[j] != '/'; j++)
    257                         ;
    258                 if (i == j)     /* skip extra slashes */
     255        for (i = 1; (i < str_size(path)) && (node); i = j + 1) {
     256                for (j = i; (j < str_size(path)) && (path[j] != '/'); j++);
     257               
     258                /* Skip extra slashes */
     259                if (i == j)
    259260                        continue;
    260                        
     261               
    261262                memcpy(buf, &path[i], j - i);
    262                 buf[j - i] = '\0';
     263                buf[j - i] = 0;
    263264                node = ofw_tree_find_child(node, buf);
    264265        }
  • kernel/genarch/src/ofw/pci.c

    r9be1d58 rb60c582  
    5959        prop = ofw_tree_getprop(node, "ranges");
    6060        if (!prop) {
    61                 if (strcmp(ofw_tree_node_name(node->parent), "pci") == 0)
     61                if (str_cmp(ofw_tree_node_name(node->parent), "pci") == 0)
    6262                        return ofw_pci_apply_ranges(node->parent, reg, pa);
    6363                return false;
  • kernel/generic/src/main/kinit.c

    r9be1d58 rb60c582  
    187187               
    188188                name = init.tasks[i].name;
    189                 if (name[0] == '\0')
     189                if (name[0] == 0)
    190190                        name = "<unknown>";
    191191               
    192192                ASSERT(TASK_NAME_BUFLEN >= INIT_PREFIX_LEN);
    193                 strncpy(namebuf, INIT_PREFIX, TASK_NAME_BUFLEN);
    194                 strncpy(namebuf + INIT_PREFIX_LEN, name,
     193                str_ncpy(namebuf, INIT_PREFIX, TASK_NAME_BUFLEN);
     194                str_ncpy(namebuf + INIT_PREFIX_LEN, name,
    195195                    TASK_NAME_BUFLEN - INIT_PREFIX_LEN);
    196196               
  • kernel/generic/src/proc/program.c

    r9be1d58 rb60c582  
    214214                return (unative_t) rc;
    215215
    216         namebuf[name_len] = '\0';
     216        namebuf[name_len] = 0;
    217217
    218218        /* Spawn the new task. */
  • kernel/generic/src/proc/task.c

    r9be1d58 rb60c582  
    152152
    153153        memcpy(ta->name, name, TASK_NAME_BUFLEN);
    154         ta->name[TASK_NAME_BUFLEN - 1] = '\0';
     154        ta->name[TASK_NAME_BUFLEN - 1] = 0;
    155155
    156156        atomic_set(&ta->refcount, 0);
     
    274274                return (unative_t) rc;
    275275
    276         namebuf[name_len] = '\0';
    277         strncpy(TASK->name, namebuf, TASK_NAME_BUFLEN);
     276        namebuf[name_len] = 0;
     277        str_ncpy(TASK->name, namebuf, TASK_NAME_BUFLEN);
    278278
    279279        return EOK;
  • kernel/generic/src/proc/thread.c

    r9be1d58 rb60c582  
    317317       
    318318        memcpy(t->name, name, THREAD_NAME_BUFLEN);
    319         t->name[THREAD_NAME_BUFLEN - 1] = '\0';
     319        t->name[THREAD_NAME_BUFLEN - 1] = 0;
    320320       
    321321        t->thread_code = func;
     
    724724                return (unative_t) rc;
    725725
    726         namebuf[name_len] = '\0';
     726        namebuf[name_len] = 0;
    727727
    728728        /*
  • kernel/generic/src/synch/spinlock.c

    r9be1d58 rb60c582  
    3333/**
    3434 * @file
    35  * @brief       Spinlocks.
     35 * @brief Spinlocks.
    3636 */
    37  
     37
    3838#include <synch/spinlock.h>
    3939#include <atomic.h>
Note: See TracChangeset for help on using the changeset viewer.