Changeset 20235a3 in mainline for kernel/generic


Ignore:
Timestamp:
2010-09-02T20:55:28Z (15 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
0c39b96
Parents:
0c61955 (diff), 3249673 (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:
3 edited

Legend:

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

    r0c61955 r20235a3  
    4747 * @param s2  Start address of the second interval.
    4848 * @param sz2 Size of the second interval.
     49 *
    4950 */
    50 NO_TRACE static inline int overlaps(uintptr_t s1, size_t sz1, uintptr_t s2,
    51     size_t sz2)
     51NO_TRACE static inline int overlaps(uint64_t s1, uint64_t sz1, uint64_t s2,
     52    uint64_t sz2)
    5253{
    53         uintptr_t e1 = s1 + sz1;
    54         uintptr_t e2 = s2 + sz2;
     54        uint64_t e1 = s1 + sz1;
     55        uint64_t e2 = s2 + sz2;
    5556       
    5657        return ((s1 < e2) && (s2 < e1));
     58}
     59
     60/** Return true if the second interval is within the first interval.
     61 *
     62 * @param s1  Start address of the first interval.
     63 * @param sz1 Size of the first interval.
     64 * @param s2  Start address of the second interval.
     65 * @param sz2 Size of the second interval.
     66 *
     67 */
     68NO_TRACE static inline int iswithin(uint64_t s1, uint64_t sz1, uint64_t s2,
     69    uint64_t sz2)
     70{
     71        uint64_t e1 = s1 + sz1;
     72        uint64_t e2 = s2 + sz2;
     73       
     74        return ((s1 <= s2) && (e1 >= e2));
    5775}
    5876
     
    7492
    7593/* Compute overlapping of physical addresses */
    76 #define PA_overlaps(x, szx, y, szy) \
     94#define PA_OVERLAPS(x, szx, y, szy) \
    7795        overlaps(KA2PA((x)), (szx), KA2PA((y)), (szy))
    7896
  • kernel/generic/src/main/main.c

    r0c61955 r20235a3  
    147147        size_t i;
    148148        for (i = 0; i < init.cnt; i++) {
    149                 if (PA_overlaps(config.stack_base, config.stack_size,
     149                if (PA_OVERLAPS(config.stack_base, config.stack_size,
    150150                    init.tasks[i].addr, init.tasks[i].size))
    151151                        config.stack_base = ALIGN_UP(init.tasks[i].addr +
     
    155155        /* Avoid placing stack on top of boot allocations. */
    156156        if (ballocs.size) {
    157                 if (PA_overlaps(config.stack_base, config.stack_size,
     157                if (PA_OVERLAPS(config.stack_base, config.stack_size,
    158158                    ballocs.base, ballocs.size))
    159159                        config.stack_base = ALIGN_UP(ballocs.base +
  • kernel/generic/src/mm/frame.c

    r0c61955 r20235a3  
    121121 *
    122122 */
    123 NO_TRACE static size_t zones_insert_zone(pfn_t base, size_t count)
     123NO_TRACE static size_t zones_insert_zone(pfn_t base, size_t count,
     124    zone_flags_t flags)
    124125{
    125126        if (zones.count + 1 == ZONES_MAX) {
     
    131132        for (i = 0; i < zones.count; i++) {
    132133                /* Check for overlap */
    133                 if (overlaps(base, count,
    134                     zones.info[i].base, zones.info[i].count)) {
    135                         printf("Zone (%p, %p) overlaps with zone (%p, %p)!\n",
    136                             PFN2ADDR(base), PFN2ADDR(base + count),
    137                             PFN2ADDR(zones.info[i].base),
    138                             PFN2ADDR(zones.info[i].base + zones.info[i].count));
     134                if (overlaps(zones.info[i].base, zones.info[i].count,
     135                    base, count)) {
     136                       
     137                        /*
     138                         * If the overlaping zones are of the same type
     139                         * and the new zone is completely within the previous
     140                         * one, then quietly ignore the new zone.
     141                         *
     142                         */
     143                       
     144                        if ((zones.info[i].flags != flags) ||
     145                            (!iswithin(zones.info[i].base, zones.info[i].count,
     146                            base, count))) {
     147                                printf("Zone (%p, %p) overlaps with previous zone (%p, %p)!\n",
     148                                    PFN2ADDR(base), PFN2ADDR(count),
     149                                    PFN2ADDR(zones.info[i].base),
     150                                    PFN2ADDR(zones.info[i].count));
     151                        }
     152                       
    139153                        return (size_t) -1;
    140154                }
     
    147161        for (j = zones.count; j > i; j--) {
    148162                zones.info[j] = zones.info[j - 1];
    149                 zones.info[j].buddy_system->data =
    150                     (void *) &zones.info[j - 1];
     163                if (zones.info[j].buddy_system != NULL)
     164                        zones.info[j].buddy_system->data =
     165                            (void *) &zones.info[j];
    151166        }
    152167       
     
    748763        for (i = z2 + 1; i < zones.count; i++) {
    749764                zones.info[i - 1] = zones.info[i];
    750                 zones.info[i - 1].buddy_system->data =
    751                     (void *) &zones.info[i - 1];
     765                if (zones.info[i - 1].buddy_system != NULL)
     766                        zones.info[i - 1].buddy_system->data =
     767                            (void *) &zones.info[i - 1];
    752768        }
    753769       
     
    898914                }
    899915               
    900                 size_t znum = zones_insert_zone(start, count);
     916                size_t znum = zones_insert_zone(start, count, flags);
    901917                if (znum == (size_t) -1) {
    902918                        irq_spinlock_unlock(&zones.lock, true);
     
    921937       
    922938        /* Non-available zone */
    923         size_t znum = zones_insert_zone(start, count);
     939        size_t znum = zones_insert_zone(start, count, flags);
    924940        if (znum == (size_t) -1) {
    925941                irq_spinlock_unlock(&zones.lock, true);
Note: See TracChangeset for help on using the changeset viewer.