Changeset 8fb1bf82 in mainline for kernel/generic


Ignore:
Timestamp:
2010-11-25T13:42:50Z (15 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
8df8415
Parents:
a93d79a (diff), eb667613 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge mainline changes.

Location:
kernel/generic
Files:
14 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/include/ddi/ddi.h

    ra93d79a r8fb1bf82  
    5454extern unative_t sys_physmem_map(unative_t, unative_t, unative_t, unative_t);
    5555extern unative_t sys_iospace_enable(ddi_ioarg_t *);
     56extern unative_t sys_interrupt_enable(int irq, int enable);
    5657
    5758/*
     
    6061extern int ddi_iospace_enable_arch(task_t *, uintptr_t, size_t);
    6162
     63
    6264#endif
    6365
  • kernel/generic/include/syscall/syscall.h

    ra93d79a r8fb1bf82  
    8080        SYS_PHYSMEM_MAP,
    8181        SYS_IOSPACE_ENABLE,
     82        SYS_INTERRUPT_ENABLE,
    8283       
    8384        SYS_SYSINFO_GET_TAG,
  • kernel/generic/include/typedefs.h

    ra93d79a r8fb1bf82  
    4040#include <arch/types.h>
    4141
    42 #define NULL  0
     42#define NULL    ((void *) 0)
    4343
    4444#define false  0
  • kernel/generic/src/adt/bitmap.c

    ra93d79a r8fb1bf82  
    3232/**
    3333 * @file
    34  * @brief       Implementation of bitmap ADT.
     34 * @brief Implementation of bitmap ADT.
    3535 *
    3636 * This file implements bitmap ADT and provides functions for
     
    5151 * No portion of the bitmap is set or cleared by this function.
    5252 *
    53  * @param bitmap Bitmap structure.
    54  * @param map Address of the memory used to hold the map.
    55  * @param bits Number of bits stored in bitmap.
     53 * @param bitmap        Bitmap structure.
     54 * @param map           Address of the memory used to hold the map.
     55 * @param bits          Number of bits stored in bitmap.
    5656 */
    5757void bitmap_initialize(bitmap_t *bitmap, uint8_t *map, size_t bits)
     
    6363/** Set range of bits.
    6464 *
    65  * @param bitmap Bitmap structure.
    66  * @param start Starting bit.
    67  * @param bits Number of bits to set.
     65 * @param bitmap        Bitmap structure.
     66 * @param start         Starting bit.
     67 * @param bits          Number of bits to set.
    6868 */
    6969void bitmap_set_range(bitmap_t *bitmap, size_t start, size_t bits)
     
    7171        size_t i = 0;
    7272        size_t aligned_start;
    73         size_t lub;             /* leading unaligned bits */
    74         size_t amb;             /* aligned middle bits */
    75         size_t tab;             /* trailing aligned bits */
     73        size_t lub;     /* leading unaligned bits */
     74        size_t amb;     /* aligned middle bits */
     75        size_t tab;     /* trailing aligned bits */
    7676       
    7777        ASSERT(start + bits <= bitmap->bits);
     
    8282        tab = amb % 8;
    8383       
    84         if ( start + bits < aligned_start ) {
    85             /*
    86             * Set bits in the middle of byte
    87             */
    88             bitmap->map[start / 8] |= ((1 << lub)-1) << (start&7);
    89             return;
     84        if (!bits)
     85                return;
     86
     87        if (start + bits < aligned_start) {
     88                /* Set bits in the middle of byte. */
     89                bitmap->map[start / 8] |= ((1 << lub) - 1) << (start & 7);
     90                return;
    9091        }
    9192       
    9293        if (lub) {
    93                 /*
    94                  * Make sure to set any leading unaligned bits.
    95                  */
     94                /* Make sure to set any leading unaligned bits. */
    9695                bitmap->map[start / 8] |= ~((1 << (8 - lub)) - 1);
    9796        }
    9897        for (i = 0; i < amb / 8; i++) {
    99                 /*
    100                  * The middle bits can be set byte by byte.
    101                  */
     98                /* The middle bits can be set byte by byte. */
    10299                bitmap->map[aligned_start / 8 + i] = ALL_ONES;
    103100        }
    104101        if (tab) {
    105                 /*
    106                  * Make sure to set any trailing aligned bits.
    107                  */
     102                /* Make sure to set any trailing aligned bits. */
    108103                bitmap->map[aligned_start / 8 + i] |= (1 << tab) - 1;
    109104        }
     
    113108/** Clear range of bits.
    114109 *
    115  * @param bitmap Bitmap structure.
    116  * @param start Starting bit.
    117  * @param bits Number of bits to clear.
     110 * @param bitmap        Bitmap structure.
     111 * @param start         Starting bit.
     112 * @param bits          Number of bits to clear.
    118113 */
    119114void bitmap_clear_range(bitmap_t *bitmap, size_t start, size_t bits)
     
    121116        size_t i = 0;
    122117        size_t aligned_start;
    123         size_t lub;             /* leading unaligned bits */
    124         size_t amb;             /* aligned middle bits */
    125         size_t tab;             /* trailing aligned bits */
     118        size_t lub;     /* leading unaligned bits */
     119        size_t amb;     /* aligned middle bits */
     120        size_t tab;     /* trailing aligned bits */
    126121       
    127122        ASSERT(start + bits <= bitmap->bits);
     
    132127        tab = amb % 8;
    133128
    134         if ( start + bits < aligned_start )
    135         {
    136             /*
    137             * Set bits in the middle of byte
    138             */
    139             bitmap->map[start / 8] &= ~(((1 << lub)-1) << (start&7));
    140             return;
     129        if (!bits)
     130                return;
     131
     132        if (start + bits < aligned_start) {
     133                /* Set bits in the middle of byte */
     134                bitmap->map[start / 8] &= ~(((1 << lub) - 1) << (start & 7));
     135                return;
    141136        }
    142137
    143 
    144138        if (lub) {
    145                 /*
    146                  * Make sure to clear any leading unaligned bits.
    147                  */
     139                /* Make sure to clear any leading unaligned bits. */
    148140                bitmap->map[start / 8] &= (1 << (8 - lub)) - 1;
    149141        }
    150142        for (i = 0; i < amb / 8; i++) {
    151                 /*
    152                  * The middle bits can be cleared byte by byte.
    153                  */
     143                /* The middle bits can be cleared byte by byte. */
    154144                bitmap->map[aligned_start / 8 + i] = ALL_ZEROES;
    155145        }
    156146        if (tab) {
    157                 /*
    158                  * Make sure to clear any trailing aligned bits.
    159                  */
     147                /* Make sure to clear any trailing aligned bits. */
    160148                bitmap->map[aligned_start / 8 + i] &= ~((1 << tab) - 1);
    161149        }
     
    165153/** Copy portion of one bitmap into another bitmap.
    166154 *
    167  * @param dst Destination bitmap.
    168  * @param src Source bitmap.
    169  * @param bits Number of bits to copy.
     155 * @param dst           Destination bitmap.
     156 * @param src           Source bitmap.
     157 * @param bits          Number of bits to copy.
    170158 */
    171159void bitmap_copy(bitmap_t *dst, bitmap_t *src, size_t bits)
  • kernel/generic/src/adt/btree.c

    ra93d79a r8fb1bf82  
    888888                *leaf_node = cur;
    889889               
     890                if (cur->keys == 0)
     891                        return NULL;
     892
    890893                /*
    891894                 * The key can be in the leftmost subtree.
     
    926929                                return key == cur->key[i - 1] ? val : NULL;
    927930                }
    928                 descend:
     931descend:
    929932                ;
    930933        }
  • kernel/generic/src/ddi/ddi.c

    ra93d79a r8fb1bf82  
    258258}
    259259
     260/** Disable or enable specified interrupts.
     261 *
     262 * @param irq the interrupt to be enabled/disabled.
     263 * @param enable if true enable the interrupt, disable otherwise.
     264 *
     265 * @retutn Zero on success, error code otherwise.
     266 */
     267unative_t sys_interrupt_enable(int irq, int enable)
     268{
     269/* FIXME: this needs to be generic code, or better not be in kernel at all. */
     270#if 0
     271        cap_t task_cap = cap_get(TASK);
     272        if (!(task_cap & CAP_IRQ_REG))
     273                return EPERM;
     274               
     275        if (irq < 0 || irq > 16) {
     276                return EINVAL;
     277        }
     278       
     279        uint16_t irq_mask = (uint16_t)(1 << irq);
     280        if (enable) {
     281                trap_virtual_enable_irqs(irq_mask);
     282        } else {
     283                trap_virtual_disable_irqs(irq_mask);
     284        }
     285       
     286#endif
     287        return 0;
     288}
     289
    260290/** @}
    261291 */
  • kernel/generic/src/ipc/kbox.c

    ra93d79a r8fb1bf82  
    107107                /* Terminate debugging session (if any). */
    108108                LOG("Terminate debugging session.");
    109                 irq_spinlock_lock(&TASK->lock, true);
     109                mutex_lock(&TASK->udebug.lock);
    110110                udebug_task_cleanup(TASK);
    111                 irq_spinlock_unlock(&TASK->lock, true);
     111                mutex_unlock(&TASK->udebug.lock);
    112112        } else {
    113113                LOG("Was not debugger.");
  • kernel/generic/src/main/main.c

    ra93d79a r8fb1bf82  
    9797/** Boot allocations. */
    9898ballocs_t ballocs = {
    99         .base = NULL,
     99        .base = (uintptr_t) NULL,
    100100        .size = 0
    101101};
  • kernel/generic/src/mm/as.c

    ra93d79a r8fb1bf82  
    312312         *
    313313         */
    314         if (overlaps(va, size, NULL, PAGE_SIZE))
     314        if (overlaps(va, size, (uintptr_t) NULL, PAGE_SIZE))
    315315                return false;
    316316       
  • kernel/generic/src/mm/frame.c

    ra93d79a r8fb1bf82  
    878878                 * the assert
    879879                 */
    880                 ASSERT(confframe != NULL);
     880                ASSERT(confframe != ADDR2PFN((uintptr_t ) NULL));
    881881               
    882882                /* If confframe is supposed to be inside our zone, then make sure
     
    11041104         */
    11051105        pfn_t pfn = ADDR2PFN(frame);
    1106         size_t znum = find_zone(pfn, 1, NULL);
     1106        size_t znum = find_zone(pfn, 1, 0);
    11071107       
    11081108        ASSERT(znum != (size_t) -1);
     
    11411141         * First, find host frame zone for addr.
    11421142         */
    1143         size_t znum = find_zone(pfn, 1, NULL);
     1143        size_t znum = find_zone(pfn, 1, 0);
    11441144       
    11451145        ASSERT(znum != (size_t) -1);
  • kernel/generic/src/synch/smc.c

    ra93d79a r8fb1bf82  
    4444unative_t sys_smc_coherence(uintptr_t va, size_t size)
    4545{
    46         if (overlaps(va, size, NULL, PAGE_SIZE))
     46        if (overlaps(va, size, (uintptr_t) NULL, PAGE_SIZE))
    4747                return EINVAL;
    4848
  • kernel/generic/src/syscall/copy.c

    ra93d79a r8fb1bf82  
    6868        if (!KERNEL_ADDRESS_SPACE_SHADOWED) {
    6969                if (overlaps((uintptr_t) uspace_src, size,
    70                         KERNEL_ADDRESS_SPACE_START, KERNEL_ADDRESS_SPACE_END-KERNEL_ADDRESS_SPACE_START)) {
     70                        KERNEL_ADDRESS_SPACE_START,
     71                        KERNEL_ADDRESS_SPACE_END - KERNEL_ADDRESS_SPACE_START)) {
    7172                        /*
    7273                         * The userspace source block conflicts with kernel address space.
     
    7576                }
    7677        }
     78
     79#ifdef ADDRESS_SPACE_HOLE_START
     80        /*
     81         * Check whether the address is outside the address space hole.
     82         */
     83        if (overlaps((uintptr_t) uspace_src, size, ADDRESS_SPACE_HOLE_START,
     84            ADDRESS_SPACE_HOLE_END - ADDRESS_SPACE_HOLE_START))
     85                return EPERM;
     86#endif
    7787       
    7888        ipl = interrupts_disable();
     
    109119        if (!KERNEL_ADDRESS_SPACE_SHADOWED) {
    110120                if (overlaps((uintptr_t) uspace_dst, size,
    111                         KERNEL_ADDRESS_SPACE_START, KERNEL_ADDRESS_SPACE_END-KERNEL_ADDRESS_SPACE_START)) {
     121                        KERNEL_ADDRESS_SPACE_START,
     122                        KERNEL_ADDRESS_SPACE_END - KERNEL_ADDRESS_SPACE_START)) {
    112123                        /*
    113124                         * The userspace destination block conflicts with kernel address space.
     
    116127                }
    117128        }
     129
     130#ifdef ADDRESS_SPACE_HOLE_START
     131        /*
     132         * Check whether the address is outside the address space hole.
     133         */
     134        if (overlaps((uintptr_t) uspace_dst, size, ADDRESS_SPACE_HOLE_START,
     135            ADDRESS_SPACE_HOLE_END - ADDRESS_SPACE_HOLE_START))
     136                return EPERM;
     137#endif
    118138       
    119139        ipl = interrupts_disable();
  • kernel/generic/src/syscall/syscall.c

    ra93d79a r8fb1bf82  
    159159        (syshandler_t) sys_physmem_map,
    160160        (syshandler_t) sys_iospace_enable,
     161        (syshandler_t) sys_interrupt_enable,
    161162       
    162163        /* Sysinfo syscalls */
  • kernel/generic/src/udebug/udebug_ops.c

    ra93d79a r8fb1bf82  
    428428 * @param data_size Place to store size of the data.
    429429 *
    430  * @returns EOK.
     430 * @return EOK.
    431431 *
    432432 */
Note: See TracChangeset for help on using the changeset viewer.