The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/arm/xscale/ixp425/avila_machdep.c

Version: -  FREEBSD  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-2  -  FREEBSD-11-1  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-4  -  FREEBSD-10-3  -  FREEBSD-10-2  -  FREEBSD-10-1  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-3  -  FREEBSD-9-2  -  FREEBSD-9-1  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-4  -  FREEBSD-8-3  -  FREEBSD-8-2  -  FREEBSD-8-1  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-4  -  FREEBSD-7-3  -  FREEBSD-7-2  -  FREEBSD-7-1  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-4  -  FREEBSD-6-3  -  FREEBSD-6-2  -  FREEBSD-6-1  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-5  -  FREEBSD-5-4  -  FREEBSD-5-3  -  FREEBSD-5-2  -  FREEBSD-5-1  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  linux-2.6  -  linux-2.4.22  -  MK83  -  MK84  -  PLAN9  -  DFBSD  -  NETBSD  -  NETBSD5  -  NETBSD4  -  NETBSD3  -  NETBSD20  -  OPENBSD  -  xnu-517  -  xnu-792  -  xnu-792.6.70  -  xnu-1228  -  xnu-1456.1.26  -  xnu-1699.24.8  -  xnu-2050.18.24  -  OPENSOLARIS  -  minix-3-1-1 
SearchContext: -  none  -  3  -  10 

    1 /*      $NetBSD: hpc_machdep.c,v 1.70 2003/09/16 08:18:22 agc Exp $     */
    2 
    3 /*-
    4  * Copyright (c) 1994-1998 Mark Brinicombe.
    5  * Copyright (c) 1994 Brini.
    6  * All rights reserved.
    7  *
    8  * This code is derived from software written for Brini by Mark Brinicombe
    9  *
   10  * Redistribution and use in source and binary forms, with or without
   11  * modification, are permitted provided that the following conditions
   12  * are met:
   13  * 1. Redistributions of source code must retain the above copyright
   14  *    notice, this list of conditions and the following disclaimer.
   15  * 2. Redistributions in binary form must reproduce the above copyright
   16  *    notice, this list of conditions and the following disclaimer in the
   17  *    documentation and/or other materials provided with the distribution.
   18  * 3. All advertising materials mentioning features or use of this software
   19  *    must display the following acknowledgement:
   20  *      This product includes software developed by Brini.
   21  * 4. The name of the company nor the name of the author may be used to
   22  *    endorse or promote products derived from this software without specific
   23  *    prior written permission.
   24  *
   25  * THIS SOFTWARE IS PROVIDED BY BRINI ``AS IS'' AND ANY EXPRESS OR IMPLIED
   26  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
   27  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
   28  * IN NO EVENT SHALL BRINI OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
   29  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
   30  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
   31  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   32  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   33  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   34  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   35  * SUCH DAMAGE.
   36  *
   37  * RiscBSD kernel project
   38  *
   39  * machdep.c
   40  *
   41  * Machine dependant functions for kernel setup
   42  *
   43  * This file needs a lot of work. 
   44  *
   45  * Created      : 17/09/94
   46  */
   47 
   48 #include <sys/cdefs.h>
   49 __FBSDID("$FreeBSD: stable/9/sys/arm/xscale/ixp425/avila_machdep.c 263018 2014-03-11 13:03:05Z jhay $");
   50 
   51 #define _ARM32_BUS_DMA_PRIVATE
   52 #include <sys/param.h>
   53 #include <sys/systm.h>
   54 #include <sys/sysproto.h>
   55 #include <sys/signalvar.h>
   56 #include <sys/imgact.h>
   57 #include <sys/kernel.h>
   58 #include <sys/ktr.h>
   59 #include <sys/linker.h>
   60 #include <sys/lock.h>
   61 #include <sys/malloc.h>
   62 #include <sys/mutex.h>
   63 #include <sys/pcpu.h>
   64 #include <sys/proc.h>
   65 #include <sys/ptrace.h>
   66 #include <sys/cons.h>
   67 #include <sys/bio.h>
   68 #include <sys/bus.h>
   69 #include <sys/buf.h>
   70 #include <sys/exec.h>
   71 #include <sys/kdb.h>
   72 #include <sys/msgbuf.h>
   73 #include <machine/reg.h>
   74 #include <machine/cpu.h>
   75 
   76 #include <vm/vm.h>
   77 #include <vm/pmap.h>
   78 #include <vm/vm_object.h>
   79 #include <vm/vm_page.h>
   80 #include <vm/vm_pager.h>
   81 #include <vm/vm_map.h>
   82 #include <vm/vnode_pager.h>
   83 #include <machine/pmap.h>
   84 #include <machine/vmparam.h>
   85 #include <machine/pcb.h>
   86 #include <machine/undefined.h>
   87 #include <machine/machdep.h>
   88 #include <machine/metadata.h>
   89 #include <machine/armreg.h>
   90 #include <machine/bus.h>
   91 #include <sys/reboot.h>
   92 
   93 #include <arm/xscale/ixp425/ixp425reg.h>
   94 #include <arm/xscale/ixp425/ixp425var.h>
   95 
   96 /* kernel text starts where we were loaded at boot */
   97 #define KERNEL_TEXT_OFF         (KERNPHYSADDR  - PHYSADDR)
   98 #define KERNEL_TEXT_BASE        (KERNBASE + KERNEL_TEXT_OFF)
   99 #define KERNEL_TEXT_PHYS        (PHYSADDR + KERNEL_TEXT_OFF)
  100 
  101 #define KERNEL_PT_SYS           0       /* Page table for mapping proc0 zero page */
  102 #define KERNEL_PT_IO            1
  103 #define KERNEL_PT_IO_NUM        3
  104 #define KERNEL_PT_BEFOREKERN    KERNEL_PT_IO + KERNEL_PT_IO_NUM
  105 #define KERNEL_PT_AFKERNEL      KERNEL_PT_BEFOREKERN + 1        /* L2 table for mapping after kernel */
  106 #define KERNEL_PT_AFKERNEL_NUM  9
  107 
  108 /* this should be evenly divisable by PAGE_SIZE / L2_TABLE_SIZE_REAL (or 4) */
  109 #define NUM_KERNEL_PTS          (KERNEL_PT_AFKERNEL + KERNEL_PT_AFKERNEL_NUM)
  110 
  111 /* Define various stack sizes in pages */
  112 #define IRQ_STACK_SIZE  1
  113 #define ABT_STACK_SIZE  1
  114 #define UND_STACK_SIZE  1
  115 
  116 extern u_int data_abort_handler_address;
  117 extern u_int prefetch_abort_handler_address;
  118 extern u_int undefined_handler_address;
  119 
  120 struct pv_addr kernel_pt_table[NUM_KERNEL_PTS];
  121 
  122 extern void *_end;
  123 
  124 extern int *end;
  125 
  126 struct pcpu __pcpu;
  127 struct pcpu *pcpup = &__pcpu;
  128 
  129 /* Physical and virtual addresses for some global pages */
  130 
  131 vm_paddr_t phys_avail[10];
  132 vm_paddr_t dump_avail[4];
  133 vm_offset_t physical_pages;
  134 
  135 struct pv_addr systempage;
  136 struct pv_addr msgbufpv;
  137 struct pv_addr irqstack;
  138 struct pv_addr undstack;
  139 struct pv_addr abtstack;
  140 struct pv_addr kernelstack;
  141 struct pv_addr minidataclean;
  142 
  143 static struct trapframe proc0_tf;
  144 
  145 /* Static device mappings. */
  146 static const struct pmap_devmap ixp425_devmap[] = {
  147         /* Physical/Virtual address for I/O space */
  148     { IXP425_IO_VBASE, IXP425_IO_HWBASE, IXP425_IO_SIZE,
  149       VM_PROT_READ|VM_PROT_WRITE, PTE_NOCACHE, },
  150 
  151         /* Expansion Bus */
  152     { IXP425_EXP_VBASE, IXP425_EXP_HWBASE, IXP425_EXP_SIZE,
  153       VM_PROT_READ|VM_PROT_WRITE, PTE_NOCACHE, },
  154 
  155         /* CFI Flash on the Expansion Bus */
  156     { IXP425_EXP_BUS_CS0_VBASE, IXP425_EXP_BUS_CS0_HWBASE,
  157       IXP425_EXP_BUS_CS0_SIZE, VM_PROT_READ|VM_PROT_WRITE, PTE_NOCACHE, },
  158 
  159         /* IXP425 PCI Configuration */
  160     { IXP425_PCI_VBASE, IXP425_PCI_HWBASE, IXP425_PCI_SIZE,
  161       VM_PROT_READ|VM_PROT_WRITE, PTE_NOCACHE, },
  162 
  163         /* SDRAM Controller */
  164     { IXP425_MCU_VBASE, IXP425_MCU_HWBASE, IXP425_MCU_SIZE,
  165       VM_PROT_READ|VM_PROT_WRITE, PTE_NOCACHE, },
  166 
  167         /* PCI Memory Space */
  168     { IXP425_PCI_MEM_VBASE, IXP425_PCI_MEM_HWBASE, IXP425_PCI_MEM_SIZE,
  169       VM_PROT_READ|VM_PROT_WRITE, PTE_NOCACHE, },
  170 
  171         /* Q-Mgr Memory Space */
  172     { IXP425_QMGR_VBASE, IXP425_QMGR_HWBASE, IXP425_QMGR_SIZE,
  173       VM_PROT_READ|VM_PROT_WRITE, PTE_NOCACHE, },
  174 
  175     { 0 },
  176 };
  177 
  178 /* Static device mappings. */
  179 static const struct pmap_devmap ixp435_devmap[] = {
  180         /* Physical/Virtual address for I/O space */
  181     { IXP425_IO_VBASE, IXP425_IO_HWBASE, IXP425_IO_SIZE,
  182       VM_PROT_READ|VM_PROT_WRITE, PTE_NOCACHE, },
  183 
  184     { IXP425_EXP_VBASE, IXP425_EXP_HWBASE, IXP425_EXP_SIZE,
  185       VM_PROT_READ|VM_PROT_WRITE, PTE_NOCACHE, },
  186 
  187         /* IXP425 PCI Configuration */
  188     { IXP425_PCI_VBASE, IXP425_PCI_HWBASE, IXP425_PCI_SIZE,
  189       VM_PROT_READ|VM_PROT_WRITE, PTE_NOCACHE, },
  190 
  191         /* DDRII Controller NB: mapped same place as IXP425 */
  192     { IXP425_MCU_VBASE, IXP435_MCU_HWBASE, IXP425_MCU_SIZE,
  193       VM_PROT_READ|VM_PROT_WRITE, PTE_NOCACHE, },
  194 
  195         /* PCI Memory Space */
  196     { IXP425_PCI_MEM_VBASE, IXP425_PCI_MEM_HWBASE, IXP425_PCI_MEM_SIZE,
  197       VM_PROT_READ|VM_PROT_WRITE, PTE_NOCACHE, },
  198 
  199         /* Q-Mgr Memory Space */
  200     { IXP425_QMGR_VBASE, IXP425_QMGR_HWBASE, IXP425_QMGR_SIZE,
  201       VM_PROT_READ|VM_PROT_WRITE, PTE_NOCACHE, },
  202 
  203         /* CFI Flash on the Expansion Bus */
  204     { IXP425_EXP_BUS_CS0_VBASE, IXP425_EXP_BUS_CS0_HWBASE,
  205       IXP425_EXP_BUS_CS0_SIZE, VM_PROT_READ|VM_PROT_WRITE, PTE_NOCACHE, },
  206 
  207         /* USB1 Memory Space */
  208     { IXP435_USB1_VBASE, IXP435_USB1_HWBASE, IXP435_USB1_SIZE,
  209       VM_PROT_READ|VM_PROT_WRITE, PTE_NOCACHE, },
  210         /* USB2 Memory Space */
  211     { IXP435_USB2_VBASE, IXP435_USB2_HWBASE, IXP435_USB2_SIZE,
  212       VM_PROT_READ|VM_PROT_WRITE, PTE_NOCACHE, },
  213 
  214         /* GPS Memory Space */
  215     { CAMBRIA_GPS_VBASE, CAMBRIA_GPS_HWBASE, CAMBRIA_GPS_SIZE,
  216       VM_PROT_READ|VM_PROT_WRITE, PTE_NOCACHE, },
  217 
  218         /* RS485 Memory Space */
  219     { CAMBRIA_RS485_VBASE, CAMBRIA_RS485_HWBASE, CAMBRIA_RS485_SIZE,
  220       VM_PROT_READ|VM_PROT_WRITE, PTE_NOCACHE, },
  221 
  222     { 0 }
  223 };
  224 
  225 extern vm_offset_t xscale_cache_clean_addr;
  226 
  227 void *
  228 initarm(void *arg, void *arg2)
  229 {
  230 #define next_chunk2(a,b)        (((a) + (b)) &~ ((b)-1))
  231 #define next_page(a)            next_chunk2(a,PAGE_SIZE)
  232         struct pv_addr  kernel_l1pt;
  233         struct pv_addr  dpcpu;
  234         int loop, i;
  235         u_int l1pagetable;
  236         vm_offset_t freemempos;
  237         vm_offset_t freemem_pt;
  238         vm_offset_t afterkern;
  239         vm_offset_t freemem_after;
  240         vm_offset_t lastaddr;
  241         uint32_t memsize;
  242 
  243         set_cpufuncs();         /* NB: sets cputype */
  244         lastaddr = fake_preload_metadata();
  245         pcpu_init(pcpup, 0, sizeof(struct pcpu));
  246         PCPU_SET(curthread, &thread0);
  247 
  248         if (envmode == 1)
  249                 kern_envp = static_env;
  250         /* Do basic tuning, hz etc */
  251         init_param1();
  252                 
  253         /*
  254          * We allocate memory downwards from where we were loaded
  255          * by RedBoot; first the L1 page table, then NUM_KERNEL_PTS
  256          * entries in the L2 page table.  Past that we re-align the
  257          * allocation boundary so later data structures (stacks, etc)
  258          * can be mapped with different attributes (write-back vs
  259          * write-through).  Note this leaves a gap for expansion
  260          * (or might be repurposed).
  261          */
  262         freemempos = KERNPHYSADDR;
  263 
  264         /* macros to simplify initial memory allocation */
  265 #define alloc_pages(var, np) do {                                       \
  266         freemempos -= (np * PAGE_SIZE);                                 \
  267         (var) = freemempos;                                             \
  268         /* NB: this works because locore maps PA=VA */                  \
  269         memset((char *)(var), 0, ((np) * PAGE_SIZE));                   \
  270 } while (0)
  271 #define valloc_pages(var, np) do {                                      \
  272         alloc_pages((var).pv_pa, (np));                                 \
  273         (var).pv_va = (var).pv_pa + (KERNVIRTADDR - KERNPHYSADDR);      \
  274 } while (0)
  275 
  276         /* force L1 page table alignment */
  277         while (((freemempos - L1_TABLE_SIZE) & (L1_TABLE_SIZE - 1)) != 0)
  278                 freemempos -= PAGE_SIZE;
  279         /* allocate contiguous L1 page table */
  280         valloc_pages(kernel_l1pt, L1_TABLE_SIZE / PAGE_SIZE);
  281         /* now allocate L2 page tables; they are linked to L1 below */
  282         for (loop = 0; loop < NUM_KERNEL_PTS; ++loop) {
  283                 if (!(loop % (PAGE_SIZE / L2_TABLE_SIZE_REAL))) {
  284                         valloc_pages(kernel_pt_table[loop],
  285                             L2_TABLE_SIZE / PAGE_SIZE);
  286                 } else {
  287                         kernel_pt_table[loop].pv_pa = freemempos +
  288                             (loop % (PAGE_SIZE / L2_TABLE_SIZE_REAL)) *
  289                             L2_TABLE_SIZE_REAL;
  290                         kernel_pt_table[loop].pv_va = 
  291                             kernel_pt_table[loop].pv_pa +
  292                                 (KERNVIRTADDR - KERNPHYSADDR);
  293                 }
  294         }
  295         freemem_pt = freemempos;                /* base of allocated pt's */
  296 
  297         /*
  298          * Re-align allocation boundary so we can map the area
  299          * write-back instead of write-through for the stacks and
  300          * related structures allocated below.
  301          */
  302         freemempos = PHYSADDR + 0x100000;
  303         /*
  304          * Allocate a page for the system page mapped to V0x00000000
  305          * This page will just contain the system vectors and can be
  306          * shared by all processes.
  307          */
  308         valloc_pages(systempage, 1);
  309 
  310         /* Allocate dynamic per-cpu area. */
  311         valloc_pages(dpcpu, DPCPU_SIZE / PAGE_SIZE);
  312         dpcpu_init((void *)dpcpu.pv_va, 0);
  313 
  314         /* Allocate stacks for all modes */
  315         valloc_pages(irqstack, IRQ_STACK_SIZE);
  316         valloc_pages(abtstack, ABT_STACK_SIZE);
  317         valloc_pages(undstack, UND_STACK_SIZE);
  318         valloc_pages(kernelstack, KSTACK_PAGES);
  319         alloc_pages(minidataclean.pv_pa, 1);
  320         valloc_pages(msgbufpv, round_page(msgbufsize) / PAGE_SIZE);
  321 #ifdef ARM_USE_SMALL_ALLOC
  322         freemempos -= PAGE_SIZE;
  323         freemem_pt = trunc_page(freemem_pt);
  324         freemem_after = freemempos - ((freemem_pt - (PHYSADDR + 0x100000)) /
  325             PAGE_SIZE) * sizeof(struct arm_small_page);
  326         arm_add_smallalloc_pages(
  327             (void *)(freemem_after + (KERNVIRTADDR - KERNPHYSADDR)),
  328             (void *)0xc0100000,
  329             freemem_pt - (PHYSADDR + 0x100000), 1);
  330         freemem_after -= ((freemem_after - (PHYSADDR + 0x1000)) / PAGE_SIZE) *
  331             sizeof(struct arm_small_page);
  332         arm_add_smallalloc_pages(
  333             (void *)(freemem_after + (KERNVIRTADDR - KERNPHYSADDR)),
  334             (void *)0xc0001000,
  335             trunc_page(freemem_after) - (PHYSADDR + 0x1000), 0);
  336         freemempos = trunc_page(freemem_after);
  337         freemempos -= PAGE_SIZE;
  338 #endif
  339 
  340         /*
  341          * Now construct the L1 page table.  First map the L2
  342          * page tables into the L1 so we can replace L1 mappings
  343          * later on if necessary
  344          */
  345         l1pagetable = kernel_l1pt.pv_va;
  346 
  347         /* Map the L2 pages tables in the L1 page table */
  348         pmap_link_l2pt(l1pagetable, ARM_VECTORS_HIGH & ~(0x00100000 - 1),
  349             &kernel_pt_table[KERNEL_PT_SYS]);
  350         pmap_link_l2pt(l1pagetable, IXP425_IO_VBASE,
  351             &kernel_pt_table[KERNEL_PT_IO]);
  352         pmap_link_l2pt(l1pagetable, IXP425_MCU_VBASE,
  353             &kernel_pt_table[KERNEL_PT_IO + 1]);
  354         pmap_link_l2pt(l1pagetable, IXP425_PCI_MEM_VBASE,
  355             &kernel_pt_table[KERNEL_PT_IO + 2]);
  356         pmap_link_l2pt(l1pagetable, KERNBASE,
  357             &kernel_pt_table[KERNEL_PT_BEFOREKERN]);
  358         pmap_map_chunk(l1pagetable, KERNBASE, PHYSADDR, 0x100000,
  359             VM_PROT_READ|VM_PROT_WRITE, PTE_CACHE);
  360         pmap_map_chunk(l1pagetable, KERNBASE + 0x100000, PHYSADDR + 0x100000,
  361             0x100000, VM_PROT_READ|VM_PROT_WRITE, PTE_PAGETABLE);
  362         pmap_map_chunk(l1pagetable, KERNEL_TEXT_BASE, KERNEL_TEXT_PHYS,
  363             next_chunk2(((uint32_t)lastaddr) - KERNEL_TEXT_BASE, L1_S_SIZE),
  364             VM_PROT_READ|VM_PROT_WRITE, PTE_CACHE);
  365         freemem_after = next_page((int)lastaddr);
  366         afterkern = round_page(next_chunk2((vm_offset_t)lastaddr, L1_S_SIZE));
  367         for (i = 0; i < KERNEL_PT_AFKERNEL_NUM; i++) {
  368                 pmap_link_l2pt(l1pagetable, afterkern + i * 0x00100000,
  369                     &kernel_pt_table[KERNEL_PT_AFKERNEL + i]);
  370         }
  371         pmap_map_entry(l1pagetable, afterkern, minidataclean.pv_pa, 
  372             VM_PROT_READ|VM_PROT_WRITE, PTE_CACHE);
  373 
  374 #ifdef ARM_USE_SMALL_ALLOC
  375         if ((freemem_after + 2 * PAGE_SIZE) <= afterkern) {
  376                 arm_add_smallalloc_pages((void *)(freemem_after),
  377                     (void*)(freemem_after + PAGE_SIZE),
  378                     afterkern - (freemem_after + PAGE_SIZE), 0);
  379                     
  380         }
  381 #endif
  382 
  383         /* Map the Mini-Data cache clean area. */
  384         xscale_setup_minidata(l1pagetable, afterkern,
  385             minidataclean.pv_pa);
  386 
  387         /* Map the vector page. */
  388         pmap_map_entry(l1pagetable, ARM_VECTORS_HIGH, systempage.pv_pa,
  389             VM_PROT_READ|VM_PROT_WRITE, PTE_CACHE);
  390         if (cpu_is_ixp43x())
  391                 pmap_devmap_bootstrap(l1pagetable, ixp435_devmap);
  392         else
  393                 pmap_devmap_bootstrap(l1pagetable, ixp425_devmap);
  394         /*
  395          * Give the XScale global cache clean code an appropriately
  396          * sized chunk of unmapped VA space starting at 0xff000000
  397          * (our device mappings end before this address).
  398          */
  399         xscale_cache_clean_addr = 0xff000000U;
  400 
  401         cpu_domains((DOMAIN_CLIENT << (PMAP_DOMAIN_KERNEL*2)) | DOMAIN_CLIENT);
  402         setttb(kernel_l1pt.pv_pa);
  403         cpu_tlb_flushID();
  404         cpu_domains(DOMAIN_CLIENT << (PMAP_DOMAIN_KERNEL*2));
  405 
  406         /*
  407          * Pages were allocated during the secondary bootstrap for the
  408          * stacks for different CPU modes.
  409          * We must now set the r13 registers in the different CPU modes to
  410          * point to these stacks.
  411          * Since the ARM stacks use STMFD etc. we must set r13 to the top end
  412          * of the stack memory.
  413          */
  414         set_stackptr(PSR_IRQ32_MODE, irqstack.pv_va + IRQ_STACK_SIZE*PAGE_SIZE);
  415         set_stackptr(PSR_ABT32_MODE, abtstack.pv_va + ABT_STACK_SIZE*PAGE_SIZE);
  416         set_stackptr(PSR_UND32_MODE, undstack.pv_va + UND_STACK_SIZE*PAGE_SIZE);
  417 
  418         /*
  419          * We must now clean the cache again....
  420          * Cleaning may be done by reading new data to displace any
  421          * dirty data in the cache. This will have happened in setttb()
  422          * but since we are boot strapping the addresses used for the read
  423          * may have just been remapped and thus the cache could be out
  424          * of sync. A re-clean after the switch will cure this.
  425          * After booting there are no gross relocations of the kernel thus
  426          * this problem will not occur after initarm().
  427          */
  428         cpu_idcache_wbinv_all();
  429         /* ready to setup the console (XXX move earlier if possible) */
  430         cninit();
  431         /*
  432          * Fetch the RAM size from the MCU registers.  The
  433          * expansion bus was mapped above so we can now read 'em.
  434          */
  435         if (cpu_is_ixp43x())
  436                 memsize = ixp435_ddram_size();
  437         else
  438                 memsize = ixp425_sdram_size();
  439         physmem = memsize / PAGE_SIZE;
  440 
  441         /* Set stack for exception handlers */
  442 
  443         data_abort_handler_address = (u_int)data_abort_handler;
  444         prefetch_abort_handler_address = (u_int)prefetch_abort_handler;
  445         undefined_handler_address = (u_int)undefinedinstruction_bounce;
  446         undefined_init();
  447 
  448         proc_linkup0(&proc0, &thread0);
  449         thread0.td_kstack = kernelstack.pv_va;
  450         thread0.td_pcb = (struct pcb *)
  451                 (thread0.td_kstack + KSTACK_PAGES * PAGE_SIZE) - 1;
  452         thread0.td_pcb->pcb_flags = 0;
  453         thread0.td_frame = &proc0_tf;
  454         pcpup->pc_curpcb = thread0.td_pcb;
  455 
  456         arm_vector_init(ARM_VECTORS_HIGH, ARM_VEC_ALL);
  457 
  458         pmap_curmaxkvaddr = afterkern + PAGE_SIZE;
  459         dump_avail[0] = PHYSADDR;
  460         dump_avail[1] = PHYSADDR + memsize;
  461         dump_avail[2] = 0;
  462         dump_avail[3] = 0;
  463 
  464         pmap_bootstrap(pmap_curmaxkvaddr, 0xd0000000, &kernel_l1pt);
  465         msgbufp = (void*)msgbufpv.pv_va;
  466         msgbufinit(msgbufp, msgbufsize);
  467         mutex_init();
  468 
  469         i = 0;
  470 #ifdef ARM_USE_SMALL_ALLOC
  471         phys_avail[i++] = PHYSADDR;
  472         phys_avail[i++] = PHYSADDR + PAGE_SIZE;         /*
  473                                          *XXX: Gross hack to get our
  474                                          * pages in the vm_page_array.
  475                                          */
  476 #endif
  477         phys_avail[i++] = round_page(virtual_avail - KERNBASE + PHYSADDR);
  478         phys_avail[i++] = trunc_page(PHYSADDR + memsize - 1);
  479         phys_avail[i++] = 0;
  480         phys_avail[i] = 0;
  481 
  482         init_param2(physmem);
  483         kdb_init();
  484 
  485         /* use static kernel environment if so configured */
  486         if (envmode == 1)
  487                 kern_envp = static_env;
  488 
  489         return ((void *)(kernelstack.pv_va + USPACE_SVC_STACK_TOP -
  490             sizeof(struct pcb)));
  491 #undef next_page
  492 #undef next_chunk2
  493 }

Cache object: 9b2a25965a0ee11490e8e6d026ac2d45


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.