Changeset ae7d03c in mainline for kernel


Ignore:
Timestamp:
2018-05-10T13:39:19Z (7 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
e8975278
Parents:
b277bef
git-author:
Jiri Svoboda <jiri@…> (2018-05-10 07:38:12)
git-committer:
Jiri Svoboda <jiri@…> (2018-05-10 13:39:19)
Message:

Selected ccheck-proposed comment fixes.

Location:
kernel
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • kernel/arch/amd64/src/userspace.c

    rb277bef rae7d03c  
    5555
    5656        asm volatile (
    57                 "pushq %[udata_des]\n"
    58                 "pushq %[stack_top]\n"
    59                 "pushq %[rflags]\n"
    60                 "pushq %[utext_des]\n"
    61                 "pushq %[entry]\n"
    62                 "movq %[uarg], %%rax\n"
     57            "pushq %[udata_des]\n"
     58            "pushq %[stack_top]\n"
     59            "pushq %[rflags]\n"
     60            "pushq %[utext_des]\n"
     61            "pushq %[entry]\n"
     62            "movq %[uarg], %%rax\n"
    6363
    64                 /* %rdi is defined to hold pcb_ptr - set it to 0 */
    65                 "xorq %%rdi, %%rdi\n"
    66                 "iretq\n"
    67                 :: [udata_des] "i" (GDT_SELECTOR(UDATA_DES) | PL_USER),
    68                    [stack_top] "r" ((uint8_t *) kernel_uarg->uspace_stack +
    69                        kernel_uarg->uspace_stack_size),
    70                    [rflags] "r" (rflags),
    71                    [utext_des] "i" (GDT_SELECTOR(UTEXT_DES) | PL_USER),
    72                    [entry] "r" (kernel_uarg->uspace_entry),
    73                    [uarg] "r" (kernel_uarg->uspace_uarg)
    74                 : "rax"
     64            /* %rdi is defined to hold pcb_ptr - set it to 0 */
     65            "xorq %%rdi, %%rdi\n"
     66            "iretq\n"
     67            :: [udata_des] "i" (GDT_SELECTOR(UDATA_DES) | PL_USER),
     68              [stack_top] "r" ((uint8_t *) kernel_uarg->uspace_stack +
     69              kernel_uarg->uspace_stack_size),
     70              [rflags] "r" (rflags),
     71              [utext_des] "i" (GDT_SELECTOR(UTEXT_DES) | PL_USER),
     72              [entry] "r" (kernel_uarg->uspace_entry),
     73              [uarg] "r" (kernel_uarg->uspace_uarg)
     74            : "rax"
    7575        );
    7676
    7777        /* Unreachable */
    78         while (true);
     78        while (true)
     79                ;
    7980}
    8081
  • kernel/arch/arm32/src/cpu/cpu.c

    rb277bef rae7d03c  
    169169#endif
    170170#ifdef PROCESSOR_ARCH_armv7_a
    171          /* ICache coherency is elaborated on in barrier.h.
    172           * VIPT and PIPT caches need maintenance only on code modify,
    173           * so it should be safe for general use.
    174           * Enable branch predictors too as they follow the same rules
    175           * as ICache and they can be flushed together
    176           */
     171        /* ICache coherency is elaborated on in barrier.h.
     172         * VIPT and PIPT caches need maintenance only on code modify,
     173         * so it should be safe for general use.
     174         * Enable branch predictors too as they follow the same rules
     175         * as ICache and they can be flushed together
     176         */
    177177        if ((CTR_read() & CTR_L1I_POLICY_MASK) != CTR_L1I_POLICY_AIVIVT) {
    178178                control_reg |=
  • kernel/arch/arm32/src/exception.c

    rb277bef rae7d03c  
    6868        /* relative address (related to exc. vector) of the word
    6969         * where handler's address is stored
    70         */
     70         */
    7171        volatile uint32_t handler_address_ptr = EXC_VECTORS_SIZE -
    7272            PREFETCH_OFFSET;
  • kernel/arch/arm32/src/mach/beagleboardxm/beagleboardxm.c

    rb277bef rae7d03c  
    8888        amdm37x_gpt_irq_ack(&beagleboard.timer);
    8989
    90         /*
    91         * We are holding a lock which prevents preemption.
    92         * Release the lock, call clock() and reacquire the lock again.
    93         */
     90        /*
     91        * We are holding a lock which prevents preemption.
     92        * Release the lock, call clock() and reacquire the lock again.
     93        */
    9494        spinlock_unlock(&irq->lock);
    9595        clock();
  • kernel/arch/arm32/src/mach/integratorcp/integratorcp.c

    rb277bef rae7d03c  
    193193{
    194194        /*
    195         * We are holding a lock which prevents preemption.
    196         * Release the lock, call clock() and reacquire the lock again.
    197         */
     195         * We are holding a lock which prevents preemption.
     196         * Release the lock, call clock() and reacquire the lock again.
     197         */
    198198
    199199        spinlock_unlock(&irq->lock);
  • kernel/arch/ia32/src/userspace.c

    rb277bef rae7d03c  
    5353
    5454        asm volatile (
    55                 /* Set up GS register (virtual register segment) */
    56                 "movl %[vreg_des], %%gs\n"
     55            /* Set up GS register (virtual register segment) */
     56            "movl %[vreg_des], %%gs\n"
    5757
    58                 "pushl %[udata_des]\n"
    59                 "pushl %[stack_top]\n"
    60                 "pushl %[eflags]\n"
    61                 "pushl %[utext_des]\n"
    62                 "pushl %[entry]\n"
    63                 "movl %[uarg], %%eax\n"
     58            "pushl %[udata_des]\n"
     59            "pushl %[stack_top]\n"
     60            "pushl %[eflags]\n"
     61            "pushl %[utext_des]\n"
     62            "pushl %[entry]\n"
     63            "movl %[uarg], %%eax\n"
    6464
    65                 /* %edi is defined to hold pcb_ptr - set it to 0 */
    66                 "xorl %%edi, %%edi\n"
     65            /* %edi is defined to hold pcb_ptr - set it to 0 */
     66            "xorl %%edi, %%edi\n"
    6767
    68                 "iret\n"
    69                 :
    70                 : [eflags_mask] "i" (~EFLAGS_NT),
    71                   [udata_des] "i" (GDT_SELECTOR(UDATA_DES) | PL_USER),
    72                   [stack_top] "r" ((uint8_t *) kernel_uarg->uspace_stack +
    73                       kernel_uarg->uspace_stack_size),
    74                   [eflags] "r" ((eflags & ~(EFLAGS_NT)) | EFLAGS_IF),
    75                   [utext_des] "i" (GDT_SELECTOR(UTEXT_DES) | PL_USER),
    76                   [entry] "r" (kernel_uarg->uspace_entry),
    77                   [uarg] "r" (kernel_uarg->uspace_uarg),
    78                   [vreg_des] "r" (GDT_SELECTOR(VREG_DES))
    79                 : "eax");
     68            "iret\n"
     69            :
     70            : [eflags_mask] "i" (~EFLAGS_NT),
     71              [udata_des] "i" (GDT_SELECTOR(UDATA_DES) | PL_USER),
     72              [stack_top] "r" ((uint8_t *) kernel_uarg->uspace_stack +
     73              kernel_uarg->uspace_stack_size),
     74              [eflags] "r" ((eflags & ~(EFLAGS_NT)) | EFLAGS_IF),
     75              [utext_des] "i" (GDT_SELECTOR(UTEXT_DES) | PL_USER),
     76              [entry] "r" (kernel_uarg->uspace_entry),
     77              [uarg] "r" (kernel_uarg->uspace_uarg),
     78              [vreg_des] "r" (GDT_SELECTOR(VREG_DES))
     79            : "eax");
    8080
    8181        /* Unreachable */
    82         while (true);
     82        while (true)
     83                ;
    8384}
    8485
  • kernel/arch/ia64/include/arch/mm/vhpt.h

    rb277bef rae7d03c  
    3131 */
    3232/** @file
    33 */
     33 */
    3434
    3535#ifndef KERN_ia64_VHPT_H_
  • kernel/arch/ia64/src/mm/vhpt.c

    rb277bef rae7d03c  
    11/*
    2 * Copyright (c) 2006 Jakub Vana
    3 * All rights reserved.
    4 *
    5 * Redistribution and use in source and binary forms, with or without
    6 * modification, are permitted provided that the following conditions
    7 * are met:
    8 *
    9 * - Redistributions of source code must retain the above copyright
    10 *   notice, this list of conditions and the following disclaimer.
    11 * - Redistributions in binary form must reproduce the above copyright
    12 *   notice, this list of conditions and the following disclaimer in the
    13 *   documentation and/or other materials provided with the distribution.
    14 * - The name of the author may not be used to endorse or promote products
    15 *   derived from this software without specific prior written permission.
    16 *
    17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
    18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
    19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
    20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
    21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
    22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
    23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
    24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
    25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
    26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     2 * Copyright (c) 2006 Jakub Vana
     3 * All rights reserved.
     4 *
     5 * Redistribution and use in source and binary forms, with or without
     6 * modification, are permitted provided that the following conditions
     7 * are met:
     8 *
     9 * - Redistributions of source code must retain the above copyright
     10 *   notice, this list of conditions and the following disclaimer.
     11 * - Redistributions in binary form must reproduce the above copyright
     12 *   notice, this list of conditions and the following disclaimer in the
     13 *   documentation and/or other materials provided with the distribution.
     14 * - The name of the author may not be used to endorse or promote products
     15 *   derived from this software without specific prior written permission.
     16 *
     17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    2727 */
    2828
     
    3131 */
    3232/** @file
    33 */
     33 */
    3434
    3535#include <mem.h>
  • kernel/generic/src/cpu/cpu.c

    rb277bef rae7d03c  
    1  /*
     1/*
    22 * Copyright (c) 2001-2004 Jakub Jermar
    33 * All rights reserved.
  • kernel/generic/src/log/log.c

    rb277bef rae7d03c  
    6363
    6464/** Kernel log initialized */
    65 static atomic_t log_inited = {false};
     65static atomic_t log_inited = { false };
    6666
    6767/** Position in the cyclic buffer where the first log entry starts */
     
    9797}
    9898
    99 static size_t log_copy_from(uint8_t *data, size_t pos, size_t len) {
     99static size_t log_copy_from(uint8_t *data, size_t pos, size_t len)
     100{
    100101        for (size_t i = 0; i < len; i++, pos = (pos + 1) % LOG_LENGTH) {
    101102                data[i] = log_buffer[pos];
     
    104105}
    105106
    106 static size_t log_copy_to(const uint8_t *data, size_t pos, size_t len) {
     107static size_t log_copy_to(const uint8_t *data, size_t pos, size_t len)
     108{
    107109        for (size_t i = 0; i < len; i++, pos = (pos + 1) % LOG_LENGTH) {
    108110                log_buffer[pos] = data[i];
     
    170172 * This releases the log and output buffer locks.
    171173 */
    172 void log_end(void) {
     174void log_end(void)
     175{
    173176        /* Set the length in the header to correct value */
    174177        log_copy_to((uint8_t *) &log_current_len, log_current_start, sizeof(size_t));
     
    303306
    304307        switch (operation) {
    305                 case KLOG_WRITE:
    306                         data = (char *) malloc(size + 1, 0);
    307                         if (!data)
    308                                 return (sys_errno_t) ENOMEM;
    309 
    310                         rc = copy_from_uspace(data, buf, size);
    311                         if (rc) {
    312                                 free(data);
    313                                 return (sys_errno_t) rc;
     308        case KLOG_WRITE:
     309                data = (char *) malloc(size + 1, 0);
     310                if (!data)
     311                        return (sys_errno_t) ENOMEM;
     312
     313                rc = copy_from_uspace(data, buf, size);
     314                if (rc) {
     315                        free(data);
     316                        return (sys_errno_t) rc;
     317                }
     318                data[size] = 0;
     319
     320                if (level >= LVL_LIMIT)
     321                        level = LVL_NOTE;
     322
     323                log(LF_USPACE, level, "%s", data);
     324
     325                free(data);
     326                return EOK;
     327        case KLOG_READ:
     328                data = (char *) malloc(size, 0);
     329                if (!data)
     330                        return (sys_errno_t) ENOMEM;
     331
     332                size_t entry_len = 0;
     333                size_t copied = 0;
     334
     335                rc = EOK;
     336
     337                spinlock_lock(&log_lock);
     338
     339                while (next_for_uspace < log_used) {
     340                        size_t pos = (log_start + next_for_uspace) % LOG_LENGTH;
     341                        log_copy_from((uint8_t *) &entry_len, pos, sizeof(size_t));
     342
     343                        if (entry_len > PAGE_SIZE) {
     344                                /*
     345                                 * Since we limit data transfer
     346                                 * to uspace to a maximum of PAGE_SIZE
     347                                 * bytes, skip any entries larger
     348                                 * than this limit to prevent
     349                                 * userspace being stuck trying to
     350                                 * read them.
     351                                 */
     352                                next_for_uspace += entry_len;
     353                                continue;
    314354                        }
    315                         data[size] = 0;
    316 
    317                         if (level >= LVL_LIMIT)
    318                                 level = LVL_NOTE;
    319 
    320                         log(LF_USPACE, level, "%s", data);
    321 
     355
     356                        if (size < copied + entry_len) {
     357                                if (copied == 0)
     358                                        rc = EOVERFLOW;
     359                                break;
     360                        }
     361
     362                        log_copy_from((uint8_t *) (data + copied), pos, entry_len);
     363                        copied += entry_len;
     364                        next_for_uspace += entry_len;
     365                }
     366
     367                spinlock_unlock(&log_lock);
     368
     369                if (rc != EOK) {
    322370                        free(data);
    323                         return EOK;
    324                 case KLOG_READ:
    325                         data = (char *) malloc(size, 0);
    326                         if (!data)
    327                                 return (sys_errno_t) ENOMEM;
    328 
    329                         size_t entry_len = 0;
    330                         size_t copied = 0;
    331 
    332                         rc = EOK;
    333 
    334                         spinlock_lock(&log_lock);
    335 
    336                         while (next_for_uspace < log_used) {
    337                                 size_t pos = (log_start + next_for_uspace) % LOG_LENGTH;
    338                                 log_copy_from((uint8_t *) &entry_len, pos, sizeof(size_t));
    339 
    340                                 if (entry_len > PAGE_SIZE) {
    341                                         /*
    342                                          * Since we limit data transfer
    343                                          * to uspace to a maximum of PAGE_SIZE
    344                                          * bytes, skip any entries larger
    345                                          * than this limit to prevent
    346                                          * userspace being stuck trying to
    347                                          * read them.
    348                                          */
    349                                         next_for_uspace += entry_len;
    350                                         continue;
    351                                 }
    352 
    353                                 if (size < copied + entry_len) {
    354                                         if (copied == 0)
    355                                                 rc = EOVERFLOW;
    356                                         break;
    357                                 }
    358 
    359                                 log_copy_from((uint8_t *) (data + copied), pos, entry_len);
    360                                 copied += entry_len;
    361                                 next_for_uspace += entry_len;
    362                         }
    363 
    364                         spinlock_unlock(&log_lock);
    365 
    366                         if (rc != EOK) {
    367                                 free(data);
    368                                 return (sys_errno_t) rc;
    369                         }
    370 
    371                         rc = copy_to_uspace(buf, data, size);
    372 
    373                         free(data);
    374 
    375                         if (rc != EOK)
    376                                 return (sys_errno_t) rc;
    377 
    378                         return copy_to_uspace(uspace_nread, &copied, sizeof(copied));
    379                         return EOK;
    380                 default:
    381                         return (sys_errno_t) ENOTSUP;
     371                        return (sys_errno_t) rc;
     372                }
     373
     374                rc = copy_to_uspace(buf, data, size);
     375
     376                free(data);
     377
     378                if (rc != EOK)
     379                        return (sys_errno_t) rc;
     380
     381                return copy_to_uspace(uspace_nread, &copied, sizeof(copied));
     382                return EOK;
     383        default:
     384                return (sys_errno_t) ENOTSUP;
    382385        }
    383386}
  • kernel/generic/src/mm/as.c

    rb277bef rae7d03c  
    641641
    642642        /*
    643          * Create the sharing info structure.
    644          * We do this in advance for every new area, even if it is not going
    645          * to be shared.
    646          */
     643         * Create the sharing info structure.
     644         * We do this in advance for every new area, even if it is not going
     645         * to be shared.
     646         */
    647647        if (!(attrs & AS_AREA_ATTR_PARTIAL)) {
    648648                si = (share_info_t *) malloc(sizeof(share_info_t), 0);
  • kernel/generic/src/proc/task.c

    rb277bef rae7d03c  
    572572         * The notification is always available, but unless udebug is enabled,
    573573         * that's all you get.
    574         */
     574         */
    575575        if (notify) {
    576576                /* Notify the subscriber that a fault occurred. */
Note: See TracChangeset for help on using the changeset viewer.