Print this page
loader: allow 1MB device maps
There's no reason we shouldn't allow 1MB PTEs for use on device memory.
loader: map as much as possible using 1MB pages
Chances are that we never actually executed this bit of code since all the
maps we ever deal with are either very short or much larger than 1MB.
unix: enable caches in locore
The loader should really be as simple as possible to be as small as
possible.  It should configure the machine so that unix can make certain
assumptions but it should leave more complex initialization to unix.

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/armv6/loader/fakeloader.c
          +++ new/usr/src/uts/armv6/loader/fakeloader.c
↓ open down ↓ 27 lines elided ↑ open up ↑
  28   28  /*
  29   29   * This is the stock ARM fake uniboot loader.
  30   30   *
  31   31   * Here's what we have to do:
  32   32   *   o Read the atag header and find the combined archive header
  33   33   *   o Determine the set of mappings we need to add for the following:
  34   34   *              - unix
  35   35   *              - boot_archive
  36   36   *              - atags
  37   37   *   o Enable unaligned access
  38      - *   o Enable the caches + virtual memory
       38 + *   o Enable virtual memory
  39   39   *
  40   40   * There are several important constraints that we have here:
  41   41   *
  42   42   *   o We cannot use any .data! Several loaders that come before us are broken
  43   43   *     and only provide us with the ability to map our .text and potentially our
  44   44   *     .bss. We should strive to avoid even that if we can.
  45   45   */
  46   46  
  47   47  #ifdef  DEBUG
  48   48  #define FAKELOAD_DPRINTF(x)     fakeload_puts(x)
↓ open down ↓ 107 lines elided ↑ open up ↑
 156  156          armpte_t *pte;
 157  157          arm_l1s_t *l1e;
 158  158  
 159  159          entry = ARMPT_VADDR_TO_L1E(va);
 160  160          pte = &pt_addr[entry];
 161  161          if (ARMPT_L1E_ISVALID(*pte))
 162  162                  fakeload_panic("armboot_mmu: asked to map a mapped region!\n");
 163  163          l1e = (arm_l1s_t *)pte;
 164  164          *pte = 0;
 165  165          l1e->al_type = ARMPT_L1_TYPE_SECT;
 166      -        /* Assume it's not device memory */
 167      -        l1e->al_bbit = 1;
 168      -        l1e->al_cbit = 1;
 169      -        l1e->al_tex = 1;
 170      -        l1e->al_sbit = 1;
      166 +
      167 +        if (prot & PF_DEVICE) {
      168 +                l1e->al_bbit = 1;
      169 +                l1e->al_cbit = 0;
      170 +                l1e->al_tex = 0;
      171 +                l1e->al_sbit = 1;
      172 +        } else {
      173 +                l1e->al_bbit = 1;
      174 +                l1e->al_cbit = 1;
      175 +                l1e->al_tex = 1;
      176 +                l1e->al_sbit = 1;
      177 +        }
 171  178  
 172  179          if (!(prot & PF_X))
 173  180                  l1e->al_xn = 1;
 174  181          l1e->al_domain = 0;
 175  182  
 176  183          if (prot & PF_W) {
 177  184                  l1e->al_ap2 = 1;
 178  185                  l1e->al_ap = 1;
 179  186          } else {
 180  187                  l1e->al_ap2 = 0;
↓ open down ↓ 258 lines elided ↑ open up ↑
 439  446                  }
 440  447  
 441  448                  entry = ARMPT_VADDR_TO_L1E(vstart);
 442  449                  pte = &pt[entry];
 443  450  
 444  451                  if (!ARMPT_L1E_ISVALID(*pte)) {
 445  452                          uintptr_t l2table;
 446  453  
 447  454                          if (!(vstart & MMU_PAGEOFFSET1M) &&
 448  455                              !(pstart & MMU_PAGEOFFSET1M) &&
 449      -                            len == MMU_PAGESIZE1M) {
      456 +                            len >= MMU_PAGESIZE1M) {
 450  457                                  fakeload_map_1mb(pstart, vstart, prot);
 451  458                                  vstart += MMU_PAGESIZE1M;
 452  459                                  pstart += MMU_PAGESIZE1M;
 453  460                                  len -= MMU_PAGESIZE1M;
 454  461                                  continue;
 455  462                          }
 456  463  
 457  464                          l2table = fakeload_alloc_l2pt();
 458  465                          *pte = 0;
 459  466                          l1pt = (arm_l1pt_t *)pte;
↓ open down ↓ 235 lines elided ↑ open up ↑
 695  702          /* Program the page tables */
 696  703          FAKELOAD_DPRINTF("programming cp15 regs\n");
 697  704          fakeload_pt_setup((uintptr_t)pt_addr);
 698  705  
 699  706  
 700  707          /* MMU Enable */
 701  708          FAKELOAD_DPRINTF("see you on the other side\n");
 702  709          fakeload_mmu_enable();
 703  710  
 704  711          FAKELOAD_DPRINTF("why helo thar\n");
 705      -
 706      -        /* Renable caches */
 707      -        armv6_dcache_enable();
 708      -        armv6_icache_enable();
 709  712  
 710  713          /* we should never come back */
 711  714          fakeload_exec(ident, ident2, chain, unix_start);
 712  715          fakeload_panic("hit the end of the world\n");
 713  716  }
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX