Changeset aaceebc4 in mainline


Ignore:
Timestamp:
2013-03-12T23:10:57Z (11 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
cf39b2e
Parents:
428bd07
Message:

Create DMA zone.

use dma zone for dma_map_anonymous calls.
create non-available zone if all pages in that zone are used.
make occupying pages in non-available zones a no-op

This enables ISA DMA on configurations with more than 16 MB of ram

Location:
kernel
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • kernel/arch/ia32/src/mm/frame.c

    r428bd07 raaceebc4  
    4747
    4848#define PHYSMEM_LIMIT32  UINT64_C(0x100000000)
     49#define PHYSMEM_LIMIT_DMA   UINT64_C(0x1000000)
    4950
    5051size_t hardcoded_unmapped_ktext_size = 0;
     
    9192                                else
    9293                                        conf = minconf;
    93                                 zone_create(pfn, count, conf,
    94                                     ZONE_AVAILABLE | ZONE_LOWMEM);
     94
     95                                if ((pfn * PAGE_SIZE) < PHYSMEM_LIMIT_DMA) {
     96                                        size_t dma_count = min(
     97                                            PHYSMEM_LIMIT_DMA / PAGE_SIZE - pfn,
     98                                            count);
     99                                        zone_create(pfn, dma_count, conf,
     100                                            ZONE_AVAILABLE | ZONE_DMA);
     101                                        count -= dma_count;
     102                                        pfn += dma_count;
     103                                }
     104
     105                                conf = pfn;
     106                                if (count) {
     107                                        zone_create(pfn, count, conf,
     108                                            ZONE_AVAILABLE | ZONE_LOWMEM);
     109                                }
    95110                        } else {
    96111                                conf = zone_external_conf_alloc(count);
    97                                 if (conf != 0)
     112                                if (conf != 0) {
    98113                                        zone_create(pfn, count, conf,
    99114                                            ZONE_AVAILABLE | ZONE_HIGHMEM);
     115                                }
    100116                        }
    101117                } else if ((e820table[i].type == MEMMAP_MEMORY_ACPI) ||
  • kernel/generic/include/mm/frame.h

    r428bd07 raaceebc4  
    6363/** Allocate a frame which cannot be identity-mapped. */
    6464#define FRAME_HIGHMEM     0x20
     65/** Allocate a frame which needs to be from DMA zone. */
     66#define FRAME_DMA         0x40
    6567
    6668typedef uint8_t zone_flags_t;
     
    7779/** Zone contains memory that cannot be identity-mapped */
    7880#define ZONE_HIGHMEM    0x10
     81/** Zone contains memory suitable for old ISA DMA */
     82#define ZONE_DMA        0x20
    7983
    8084/** Mask of zone bits that must be matched exactly. */
     
    8286
    8387#define FRAME_TO_ZONE_FLAGS(ff) \
    84         ((((ff) & FRAME_LOWMEM) ? ZONE_LOWMEM : \
     88        ((((ff) & FRAME_DMA) ? ZONE_DMA : \
     89            (((ff) & FRAME_LOWMEM) ? ZONE_LOWMEM : \
    8590            (((ff) & FRAME_HIGHMEM) ? ZONE_HIGHMEM : \
    86             ZONE_LOWMEM /* | ZONE_HIGHMEM */)) | \
    87             ZONE_AVAILABLE) 
     91            ZONE_LOWMEM /* | ZONE_HIGHMEM */))) | \
     92            ZONE_AVAILABLE)
    8893
    8994#define ZONE_FLAGS_MATCH(zf, f) \
  • kernel/generic/src/ddi/ddi.c

    r428bd07 raaceebc4  
    336336                order = fnzb(pages - 1) + 1;
    337337       
    338         *phys = frame_alloc_noreserve(order, 0);
     338        *phys = frame_alloc_noreserve(order, FRAME_DMA);
    339339        if (*phys == NULL)
    340340                return ENOMEM;
  • kernel/generic/src/mm/frame.c

    r428bd07 raaceebc4  
    518518NO_TRACE static void zone_mark_unavailable(zone_t *zone, size_t frame_idx)
    519519{
    520         ASSERT(zone->flags & ZONE_AVAILABLE);
     520        if (!(zone->flags & ZONE_AVAILABLE))
     521                return;
     522//      ASSERT(zone->flags & ZONE_AVAILABLE);
    521523       
    522524        frame_t *frame = zone_get_frame(zone, frame_idx);
     
    935937                        }
    936938                       
    937                         if (confframe >= start + count)
    938                                 panic("Cannot find configuration data for zone.");
     939                        if (confframe >= start + count) {
     940                                flags &= ~ZONE_AVAILABLE;
     941                                goto nonavail;
     942//                              panic("Cannot find configuration data for zone.");
     943                        }
    939944                }
    940945               
     
    960965                return znum;
    961966        }
    962        
     967nonavail:
     968        (void)0; // label trick
    963969        /* Non-available zone */
    964970        size_t znum = zones_insert_zone(start, count, flags);
Note: See TracChangeset for help on using the changeset viewer.