Changeset 2644


Ignore:
Timestamp:
Oct 22, 2011, 10:40:13 AM (4 years ago)
Author:
wmb
Message:

OLPC XO-1.75 - Fixed emacs by revamping the DMA allocation code, separating the DMA memory list from the physical memlist. DMA memory is mapped uncached, while other memory is cacheable, so conflating them is not a good idea.

Location:
cpu/arm
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • cpu/arm/linux.fth

    r2501 r2644  
    10100 value linux-memtop
    1111
     12defer memory-limit
    1213\ Find the end of the largest piece of memory
    13 : memory-limit  ( -- limit )
     14: (memory-limit)  ( -- limit )
    1415   \ If we have already loaded a RAMdisk in high memory, its base is the memory limit
    1516   ramdisk-adr  ?dup  if  exit  then
     
    3132   +                                 ( limit )
    3233;
     34' (memory-limit) to memory-limit  \ Override by platform code if necessary
    3335
    3436\ see http://www.simtec.co.uk/products/SWLINUX/files/booting_article.html
  • cpu/arm/mmp2/rootnode.fth

    r2593 r2644  
    3535;
    3636
    37 : dma-range  ( -- start end )  dma-mem-va >physical  dup /dma-mem +  ;
    38 
     37[ifdef] virtual-mode
    3938h# 0 constant dma-map-mode              \ XXX what should this be?
    40 
    41 \ Used with "find-node" to locate a physical memory node containing
    42 \ enough memory in the DMA range.
    43 \ We first compute the intersection between the memory piece and the
    44 \ range reachable by DMA.  If the regions are disjoint, then ok-high
    45 \ will be (unsigned) less than ok-low.  We then subtract ok-low from
    46 \ ok-high to give the (possibly negative) size of the intersection.
    47 : in-range?  ( size mem-low mem-high range-low range-high -- flag )
    48    rot umin -rot              ( size min-high mem-low mem-high )
    49    umax                       ( size min-high max-low )
    50    - <=                       ( flag )
    51 ;
    52 
    53 : dma-ok?  ( size node-adr -- size flag )
    54    node-range                            ( size mem-adr mem-len )
    55    over +                                ( size mem-adr mem-end )
    56 
    57    3dup dma-range in-range?  if          ( size mem-adr mem-end )
    58       2drop true exit                    ( size true )
    59    then                                  ( size mem-adr mem-end )
    60 
    61    2drop false                           ( size false )
    62 ;
    63 
    64 \ Find an available physical address range suitable for DMA.  This word
    65 \ doesn't actually claim the memory (that is done later), but simply locates
    66 \ a suitable range that can be successfully claimed.
    67 : find-dma-address  ( size -- true | adr false )
    68    " physavail" memory-node @ $call-method      ( list )
    69    ['] dma-ok?  find-node is next-node  drop    ( size' )
    70    next-node 0=  if  drop true exit  then       ( size' )
    71    next-end                                     ( size mem-end )
    72    dma-range                                    ( size mem-end range-l,h )
    73    nip umin  swap -   false                     ( adr false )
    74 ;
     39[then]
    7540
    7641headers
    7742: dma-alloc  ( size -- virt )
    78    pagesize round-up
    79 
    80    \ Locate a suitable physical range
    81    dup  find-dma-address  throw                 ( size' phys )
    82 
    83    \ Claim it
    84    over 0  mem-claim                            ( size' phys )
     43   \ Allocate the physical memory
     44   dup " allocate-dma-phys" $call-mem-method    ( size' phys )
    8545
    8646[ifdef] virtual-mode
     
    11272[then]
    11373[then]
    114    mem-release                                  ( )
     74   " free-dma-phys" $call-mem-method            ( )
    11575;
    11676
  • cpu/arm/olpc/1.75/fw.bth

    r2641 r2644  
    2727
    2828fload ${BP}/cpu/arm/linux.fth
     29
     30\ The bottom of extra-mem is the top of DMA memory.
     31\ We give everything up to that address to Linux.
     32: olpc-memory-limit  ( -- adr )  extra-mem-va >physical  ;
     33' olpc-memory-limit to memory-limit
    2934
    3035: usb-quiet  ( -- )
  • cpu/arm/olpc/1.75/probemem.fth

    r2638 r2644  
    99headerless
    1010
    11 h# ffff.ffff value low
    12 h#         0 value high
     11list: dmaavail  0 dmaavail !
    1312
    14 : log&release  ( adr len -- )
    15    over    low  umin to low   ( adr len )
    16    2dup +  high umax to high  ( adr len )
    17    release
     13headers
     14: allocate-dma-phys  ( size -- phys )
     15   \ Minumum granularity of memory chunks is 1 page
     16   pagesize round-up                    ( size' )
     17
     18   pagesize over dmaavail               ( size alignment size list )
     19   allocate-memrange                    ( size [ adr ] error? )
     20   abort" Insufficient DMA memory"      ( size adr )
     21   dup rot clear-mem                    ( phys )
     22;
     23
     24: free-dma-phys  ( phys size -- )
     25   >page-boundaries                     ( adr' size' )
     26   ['] 2drop  is ?splice                ( adr' size' )
     27   dmaavail free-memrange
    1828;
    1929
    2030headers
    2131: probe  ( -- )
    22    0  fb-mem-va >physical   /fb-mem +  log&release
     32   0  fb-mem-va >physical   /fb-mem +  release
    2333
    2434   0 0 encode-bytes                                   ( adr 0 )
     
    3040   fw-mem-va    >physical   /fw-mem     0 claim  drop
    3141   extra-mem-va >physical   /extra-mem  0 claim  drop
     42   dma-mem-va   >physical   /dma-mem    0 claim  drop
     43
     44   dma-mem-va   >physical   /dma-mem    free-dma-phys
    3245
    3346   0 pagesize  0 claim  drop       \ Vector table
Note: See TracChangeset for help on using the changeset viewer.