Print this page
bcm2835: remove workaround for u-boot
Since we are not using u-boot, we don't need a work-around for it.
bcm2835: enable access to p10 and p11
When determining whether or not we are running on a supported processor, we
call arm_cpuid_vfpidreg.  This function attempts to get the FPSID which
involves talking to p10.  It however turns out that after a reset only p14
and p15 are accessible.  So, before handing off control to _fakebop_start,
let's enable access to p10 and p11 (privileged mode only).
NOTE: qemu doesn't seem to behave the same - it lets us access p10 & p11
without us doing anything special.
   1 /*
   2  * This file and its contents are supplied under the terms of the
   3  * Common Development and Distribution License ("CDDL"), version 1.0.
   4  * You may only use this file in accordance with the terms of version
   5  * 1.0 of the CDDL.
   6  *
   7  * A full copy of the text of the CDDL should have accompanied this
   8  * source.  A copy of the CDDL is also available via the Internet at
   9  * http://www.illumos.org/license/CDDL.
  10  */
  11 
  12 /*
  13  * Copyright 2013 (c) Joyent, Inc. All rights reserved.

  14  */
  15 
  16 #include <sys/asm_linkage.h>
  17 #include <sys/machparam.h>
  18 #include <sys/cpu_asm.h>
  19 
  20 /*
  21  * Every story needs a beginning. This is ours.
  22  */
  23 
  24 /*
  25  * We are in a primordial world here. The BMC2835 is going to come along and
  26  * boot us at _start. Normally we would go ahead and use a main() function, but
  27  * for now, we'll do that ourselves. As we've started the world, we also need to
  28  * set up a few things about us, for example our stack pointer. To help us out,
  29  * it's useful to remember the rough memory map. Remember, this is for physcial
  30  * addresses. There is no virtual memory here. These sizes are often manipulated
  31  * by the 'configuration' in the bootloader.
  32  *
  33  * +----------------+ <---- Max physical memory


  84         cps #(CPU_MODE_ABT)
  85         mov sp, #-1
  86         cps #(CPU_MODE_FIQ)
  87         mov sp, #-1
  88         cps #(CPU_MODE_IRQ)
  89         mov sp, #-1
  90         cps #(CPU_MODE_SVC)
  91 
  92         /* Enable highvecs (moves the base of the exception vector) */
  93         mrc     p15, 0, r3, c1, c0, 0
  94         mov     r4, #1
  95         lsl     r4, r4, #13
  96         orr     r3, r3, r4
  97         mcr     p15, 0, r3, c1, c0, 0
  98 
  99         /* Disable A (disables strict alignment checks) */
 100         mrc     p15, 0, r3, c1, c0, 0
 101         bic     r3, r3, #2
 102         mcr     p15, 0, r3, c1, c0, 0
 103 
 104         /*
 105          * XXX Currently we're using u-boot to allow us to make forward progress
 106          * while the .data section is a bit tumultuous. It loads that, but we
 107          * can say for certain that it does not correctly pass in the machid and
 108          * tagstart. Since we know what it is, we manually fix it up here.
 109          */
 110         mov r2,#0x100
 111         bl _fakebop_start
 112         SET_SIZE(_start)
 113 
 114         ENTRY(arm_reg_read)
 115         ldr r0, [r0]
 116         bx lr
 117         SET_SIZE(arm_reg_read)
 118 
 119         ENTRY(arm_reg_write)
 120         str r1, [r0]
 121         bx lr
 122         SET_SIZE(arm_reg_write)
   1 /*
   2  * This file and its contents are supplied under the terms of the
   3  * Common Development and Distribution License ("CDDL"), version 1.0.
   4  * You may only use this file in accordance with the terms of version
   5  * 1.0 of the CDDL.
   6  *
   7  * A full copy of the text of the CDDL should have accompanied this
   8  * source.  A copy of the CDDL is also available via the Internet at
   9  * http://www.illumos.org/license/CDDL.
  10  */
  11 
  12 /*
  13  * Copyright 2013 (c) Joyent, Inc. All rights reserved.
  14  * Copyright 2015 (c) Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
  15  */
  16 
  17 #include <sys/asm_linkage.h>
  18 #include <sys/machparam.h>
  19 #include <sys/cpu_asm.h>
  20 
  21 /*
  22  * Every story needs a beginning. This is ours.
  23  */
  24 
  25 /*
  26  * We are in a primordial world here. The BMC2835 is going to come along and
  27  * boot us at _start. Normally we would go ahead and use a main() function, but
  28  * for now, we'll do that ourselves. As we've started the world, we also need to
  29  * set up a few things about us, for example our stack pointer. To help us out,
  30  * it's useful to remember the rough memory map. Remember, this is for physcial
  31  * addresses. There is no virtual memory here. These sizes are often manipulated
  32  * by the 'configuration' in the bootloader.
  33  *
  34  * +----------------+ <---- Max physical memory


  85         cps #(CPU_MODE_ABT)
  86         mov sp, #-1
  87         cps #(CPU_MODE_FIQ)
  88         mov sp, #-1
  89         cps #(CPU_MODE_IRQ)
  90         mov sp, #-1
  91         cps #(CPU_MODE_SVC)
  92 
  93         /* Enable highvecs (moves the base of the exception vector) */
  94         mrc     p15, 0, r3, c1, c0, 0
  95         mov     r4, #1
  96         lsl     r4, r4, #13
  97         orr     r3, r3, r4
  98         mcr     p15, 0, r3, c1, c0, 0
  99 
 100         /* Disable A (disables strict alignment checks) */
 101         mrc     p15, 0, r3, c1, c0, 0
 102         bic     r3, r3, #2
 103         mcr     p15, 0, r3, c1, c0, 0
 104 
 105         /* Enable access to p10 and p11 (privileged mode only) */
 106         mrc     p15, 0, r0, c1, c0, 2
 107         orr     r0, #0x00500000
 108         mcr     p15, 0, r0, c1, c0, 2
 109 


 110         bl _fakebop_start
 111         SET_SIZE(_start)
 112 
 113         ENTRY(arm_reg_read)
 114         ldr r0, [r0]
 115         bx lr
 116         SET_SIZE(arm_reg_read)
 117 
 118         ENTRY(arm_reg_write)
 119         str r1, [r0]
 120         bx lr
 121         SET_SIZE(arm_reg_write)