Skip to contentSkip to conversation

xen: arm: assemble support for Allwinner A31

PATCH Superseded Bamvor Jian Zhang 4 participants 19 messages Jul 2, 2013 – Jul 3, 2013

v2 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

v2 cover xen: arm: assemble support for Allwinner A31

These series patch enable Allwinner A31(code name sun6i) support in assemble. with these patches, the cpu 0 of sun6i SOC could successful boot into the c environment.

Bamvor Jian Zhang (2):
xen: arm: introduce Cortex-A7 support
xen: arm: implement early prink for 8250 uart

 docs/misc/arm/early-printk.txt        |  1 +
 xen/arch/arm/Rules.mk                 |  5 ++++
 xen/arch/arm/arm32/Makefile           |  2 ++
 xen/arch/arm/arm32/asm-offsets.c      |  5 ++++
 xen/arch/arm/arm32/debug-8250.inc     | 48 +++++++++++++++++++++++++++++++++++
 xen/arch/arm/arm32/head.S             | 29 +++++++++++++++++----
 xen/arch/arm/arm32/proc-ca15.S        | 12 +++++----
 xen/arch/arm/arm32/proc-ca7.S         | 38 +++++++++++++++++++++++++++
 xen/arch/arm/arm32/proc-v7.S          | 36 ++++++++++++++++++++++++++
 xen/arch/arm/xen.lds.S                |  5 ++++
 xen/include/asm-arm/arm32/processor.h |  2 ++
 xen/include/asm-arm/arm32/procinfo.h  | 30 ++++++++++++++++++++++
 xen/include/asm-arm/processor-ca15.h  |  4 ---
 xen/include/asm-arm/processor-ca7.h   | 19 ++++++++++++++
 14 files changed, 222 insertions(+), 14 deletions(-)
 create mode 100644 xen/arch/arm/arm32/debug-8250.inc
 create mode 100644 xen/arch/arm/arm32/proc-ca7.S
 create mode 100644 xen/arch/arm/arm32/proc-v7.S
 create mode 100644 xen/include/asm-arm/arm32/procinfo.h
 create mode 100644 xen/include/asm-arm/processor-ca7.h
Signature · 1 line
1.8.1.4
#1 lore raw

PATCH v2 1/2 xen: arm: introduce Cortex-A7 support

Introduce Cortex-A7 with a scalable proc_info_list which including cpu id and cpu initialize function.
In head.S, search cpu specific MIDR in procinfo and call such initialize function. Currently, support Cortex-A7 and Cortex-A15.

---
 xen/arch/arm/arm32/Makefile           |  2 ++
 xen/arch/arm/arm32/asm-offsets.c      |  5 +++++
 xen/arch/arm/arm32/head.S             | 29 +++++++++++++++++++++-----
 xen/arch/arm/arm32/proc-ca15.S        | 12 ++++++-----
 xen/arch/arm/arm32/proc-ca7.S         | 38 +++++++++++++++++++++++++++++++++++
 xen/arch/arm/arm32/proc-v7.S          | 36 +++++++++++++++++++++++++++++++++
 xen/arch/arm/xen.lds.S                |  5 +++++
 xen/include/asm-arm/arm32/processor.h |  2 ++
 xen/include/asm-arm/arm32/procinfo.h  | 30 +++++++++++++++++++++++++++
 xen/include/asm-arm/processor-ca15.h  |  4 ----
 xen/include/asm-arm/processor-ca7.h   | 19 ++++++++++++++++++
 11 files changed, 168 insertions(+), 14 deletions(-)
 create mode 100644 xen/arch/arm/arm32/proc-ca7.S
 create mode 100644 xen/arch/arm/arm32/proc-v7.S
 create mode 100644 xen/include/asm-arm/arm32/procinfo.h
 create mode 100644 xen/include/asm-arm/processor-ca7.h
xen/arch/arm/arm32/Makefile +2 -0
index aaf277a..5e4b74d 100644
@@ -3,6 +3,8 @@ subdir-y += lib
 obj-y += entry.o
 obj-y += mode_switch.o
 obj-y += proc-ca15.o
+obj-y += proc-ca7.o
+obj-y += proc-v7.o
 
 obj-y += traps.o
 obj-y += domain.o
xen/arch/arm/arm32/asm-offsets.c +5 -0
index 776c974..8a6e4f4 100644
@@ -11,6 +11,7 @@
 #include <xen/bitops.h>
 #include <public/xen.h>
 #include <asm/current.h>
+#include <asm/arm32/procinfo.h>
 
 #define DEFINE(_sym, _val) \
     __asm__ __volatile__ ( "\n->" #_sym " %0 " #_val : : "i" (_val) )
@@ -62,6 +63,10 @@ void __dummy__(void)
    DEFINE(CPUINFO_sizeof, sizeof(struct cpu_info));
 
    OFFSET(VCPU_arch_saved_context, struct vcpu, arch.saved_context);
+
+   BLANK();
+   DEFINE(PROCINFO_sizeof, sizeof(struct proc_info_list));
+   OFFSET(PROCINFO_cpu_init, struct proc_info_list, cpu_init);
 }
 
 /*
xen/arch/arm/arm32/head.S +24 -5
index 0588d54..d62401d 100644
@@ -20,6 +20,7 @@
 #include <asm/config.h>
 #include <asm/page.h>
 #include <asm/processor-ca15.h>
+#include <asm/processor-ca7.h>
 #include <asm/asm_defns.h>
 
 #define ZIMAGE_MAGIC_NUMBER 0x016f2818
@@ -188,15 +189,33 @@ skip_bss:
 
         PRINT("- Setting up control registers -\r\n")
 
-        /* Read CPU ID */
+        /* Get processor specific proc info */
         mrc   CP32(r0, MIDR)
         ldr   r1, =(MIDR_MASK)
         and   r0, r0, r1
-        /* Is this a Cortex A15? */
-        ldr   r1, =(CORTEX_A15_ID)
-        teq   r0, r1
-        bleq  cortex_a15_init
+        ldr   r1, = __proc_info_start
+        add   r1, r1, r10
+        ldr   r2, = __proc_info_end
+        add   r2, r2, r10
+1:      ldr   r3, [r1]
+        teq   r0, r3
+        beq   2f
+        add   r1, r1, #PROCINFO_sizeof
+        cmp   r1, r2
+        blo   1b
+        mov   r4, r0
+        PRINT("- Missing processor info: ")
+        mov   r0, r4
+        bl    putn
+        PRINT(" -\r\n")
+        b     fail
+2:
 
+        /* Set return address(PIC) */
+        /* XXX: it only work while thumb2 is not enable in xen */
+        adr   lr, 1f
+        add   pc, r1, #PROCINFO_cpu_init
+1:
         /* Set up memory attribute type tables */
         ldr   r0, =MAIR0VAL
         ldr   r1, =MAIR1VAL
xen/arch/arm/arm32/proc-ca15.S +7 -5
index dcdd42e..eda070d 100644
@@ -21,12 +21,14 @@
 
 .globl cortex_a15_init
 cortex_a15_init:
-        /* Set up the SMP bit in ACTLR */
-        mrc   CP32(r0, ACTLR)
-        orr   r0, r0, #(ACTLR_CA15_SMP) /* enable SMP bit */
-        mcr   CP32(r0, ACTLR)
-        mov   pc, lr
+        b     v7_init
 
+        .section ".init.proc.info", #alloc, #execinstr
+        .type __v7_ca15mp_proc_info, #object
+__v7_ca15mp_proc_info:
+        .long 0x410FC0F0             /* Cortex-A15 */
+        b     cortex_a15_init
+        .size __v7_ca15mp_proc_info, . - __v7_ca15mp_proc_info
 /*
  * Local variables:
  * mode: ASM
xen/arch/arm/arm32/proc-ca7.S new file +38 -0
new file mode 100644
index 0000000..8d11d02
@@ -0,0 +1,38 @@
+/*
+ * xen/arch/arm/proc-ca7.S
+ *
+ * Cortex A7 specific initializations
+ *
+ * Bamvor Jian Zhang <[email protected]>
+ * Copyright (c) 2013 SUSE
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include <asm/asm_defns.h>
+#include <asm/processor-ca7.h>
+
+.globl cortex_a7_init
+cortex_a7_init:
+        b     v7_init
+
+        .section ".init.proc.info", #alloc, #execinstr
+        .type __v7_ca7mp_proc_info, #object
+__v7_ca7mp_proc_info:
+        .long 0x410FC070             /* Cortex-A7 */
+        b     cortex_a7_init
+        .size __v7_ca7mp_proc_info, . - __v7_ca7mp_proc_info
+/*
+ * Local variables:
+ * mode: ASM
+ * indent-tabs-mode: nil
+ * End:
+ */
xen/arch/arm/arm32/proc-v7.S new file +36 -0
new file mode 100644
index 0000000..2d46dca
@@ -0,0 +1,36 @@
+/*
+ * xen/arch/arm/proc-v7.S
+ *
+ * rename from xen/arch/arm/proc-ca15.S
+ * arm v7 specific initializations
+ *
+ * Copyright (c) 2011 Citrix Systems.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include <asm/asm_defns.h>
+#include <asm/arm32/processor.h>
+
+.globl v7_init
+v7_init:
+        /* Set up the SMP bit in ACTLR */
+        mrc   CP32(r0, ACTLR)
+        orr   r0, r0, #(ACTLR_V7_SMP) /* enable SMP bit */
+        mcr   CP32(r0, ACTLR)
+        mov   pc, lr
+
+/*
+ * Local variables:
+ * mode: ASM
+ * indent-tabs-mode: nil
+ * End:
+ */
xen/arch/arm/xen.lds.S +5 -0
index 3b60668..e8b4f47 100644
@@ -116,6 +116,11 @@ SECTIONS
        *(.init.setup)
        __setup_end = .;
   } :text
+  .init.proc.info : {
+       __proc_info_start = .;
+       *(.init.proc.info)
+       __proc_info_end = .;
+  } :text
   .initcall.init : {
        __initcall_start = .;
        *(.initcallpresmp.init)
xen/include/asm-arm/arm32/processor.h +2 -0
index d26fc85..b266252 100644
@@ -1,6 +1,8 @@
 #ifndef __ASM_ARM_ARM32_PROCESSOR_H
 #define __ASM_ARM_ARM32_PROCESSOR_H
 
+#define ACTLR_V7_SMP    (1<<6)
+
 #ifndef __ASSEMBLY__
 /* On stack VCPU state */
 struct cpu_user_regs
xen/include/asm-arm/arm32/procinfo.h new file +30 -0
new file mode 100644
index 0000000..7e7a775
@@ -0,0 +1,30 @@
+/*
+ * include/asm-arm/arm32/procinfo.h
+ *
+ * Bamvor Jian Zhang <[email protected]>
+ * Copyright (c) 2013 SUSE
+ *
+ * base on linux/arch/arm/include/asm/procinfo.h
+ *
+ * Copyright (C) 1996-1999 Russell King
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#ifndef __ASM_ARM_ARM32_PROCINFO_H
+#define __ASM_ARM_ARM32_PROCINFO_H
+
+struct proc_info_list {
+	unsigned int		cpu_val;
+	unsigned long		cpu_init;        /* used by head.S */
+};
+
+#endif
xen/include/asm-arm/processor-ca15.h +0 -4
index 06cdbdd..96438f0 100644
@@ -1,9 +1,6 @@
 #ifndef __ASM_ARM_PROCESSOR_CA15_H
 #define __ASM_ARM_PROCESSOR_CA15_H
 
-
-#define CORTEX_A15_ID     (0x410FC0F0)
-
 /* ACTLR Auxiliary Control Register, Cortex A15 */
 #define ACTLR_CA15_SNOOP_DELAYED      (1<<31)
 #define ACTLR_CA15_MAIN_CLOCK         (1<<30)
@@ -26,7 +23,6 @@
 #define ACTLR_CA15_OPT                (1<<9)
 #define ACTLR_CA15_WFI                (1<<8)
 #define ACTLR_CA15_WFE                (1<<7)
-#define ACTLR_CA15_SMP                (1<<6)
 #define ACTLR_CA15_PLD                (1<<5)
 #define ACTLR_CA15_IP                 (1<<4)
 #define ACTLR_CA15_MICRO_BTB          (1<<3)
xen/include/asm-arm/processor-ca7.h new file +19 -0
new file mode 100644
index 0000000..261009f
@@ -0,0 +1,19 @@
+#ifndef __ASM_ARM_PROCESSOR_CA7_H
+#define __ASM_ARM_PROCESSOR_CA7_H
+
+/* ACTLR Auxiliary Control Register, Cortex A7 */
+#define ACTLR_CA7_DDI                 (1<<28)
+#define ACTLR_CA7_DDVM                (1<<15)
+#define ACTLR_CA7_L1RADIS             (1<<12)
+#define ACTLR_CA7_L2RADIS             (1<<11)
+#define ACTLR_CA7_DODMBS              (1<<10)
+
+#endif /* __ASM_ARM_PROCESSOR_CA7_H */
+/*
+ * Local variables:
+ * mode: C
+ * c-file-style: "BSD"
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
Signature · 1 line
1.8.1.4
#7 lore raw

PATCH v2 2/2 xen: arm: implement early prink for 8250 uart

In reply to Bamvor Jian Zhang

implement early printk for 8250 uart which is used by lots of arm SOC, such as Allwinner A31(sun6i) and OMAP5432.

---
 docs/misc/arm/early-printk.txt    |  1 +
 xen/arch/arm/Rules.mk             |  5 ++++
 xen/arch/arm/arm32/debug-8250.inc | 48 +++++++++++++++++++++++++++++++++++++++
 3 files changed, 54 insertions(+)
 create mode 100644 xen/arch/arm/arm32/debug-8250.inc
docs/misc/arm/early-printk.txt +1 -0
index fbc3208..eaa66a1 100644
@@ -13,6 +13,7 @@ where mach is the name of the machine:
   - exynos5250: printk with the second UART
   - midway: printk with the pl011 on Calxeda Midway processors
   - fastmodel: printk on ARM Fastmodel software emulators
+  - sun6i: printk with 8250 on Allwinner A31 processors
 
 The base address and baud rate is hardcoded in xen/arch/arm/Rules.mk,
 see there when adding support for new machines.
xen/arch/arm/Rules.mk +5 -0
index 422ed04..51e823d 100644
@@ -64,6 +64,11 @@ EARLY_PRINTK_INC := pl011
 EARLY_PRINTK_BAUD := 115200
 EARLY_UART_BASE_ADDRESS := 0xfff36000
 endif
+ifeq ($(CONFIG_EARLY_PRINTK), sun6i)
+# uart configured at 115200 by bootloader
+EARLY_PRINTK_INC := 8250
+EARLY_UART_BASE_ADDRESS := 0x01c28000
+endif
 
 ifneq ($(EARLY_PRINTK_INC),)
 EARLY_PRINTK := y
xen/arch/arm/arm32/debug-8250.inc new file +48 -0

48 lines not on this page · raw message

Signature · 1 line
1.8.1.4
#2 lore raw

Re: [PATCH V2 1/2] xen: arm: introduce Cortex-A7 support

In reply to Bamvor Jian Zhang
Quoted 4 lines · Bamvor Jian Zhang

Introduce Cortex-A7 with a scalable proc_info_list which including cpu id and cpu initialize function.
In head.S, search cpu specific MIDR in procinfo and call such initialize function. Currently, support Cortex-A7 and Cortex-A15.

I like the general shape of it, thanks!

A few comments below.

Quoted 34 lines
xen/arch/arm/arm32/head.S +9 -5
index 0588d54..d62401d 100644
@@ -20,6 +20,7 @@
 #include <asm/config.h>
 #include <asm/page.h>
 #include <asm/processor-ca15.h>
+#include <asm/processor-ca7.h>
 #include <asm/asm_defns.h>
 
 #define ZIMAGE_MAGIC_NUMBER 0x016f2818
@@ -188,15 +189,33 @@ skip_bss:
 
         PRINT("- Setting up control registers -\r\n")
 
-        /* Read CPU ID */
+        /* Get processor specific proc info */
         mrc   CP32(r0, MIDR)
         ldr   r1, =(MIDR_MASK)
         and   r0, r0, r1
-        /* Is this a Cortex A15? */
-        ldr   r1, =(CORTEX_A15_ID)
-        teq   r0, r1
-        bleq  cortex_a15_init
+        ldr   r1, = __proc_info_start
+        add   r1, r1, r10
+        ldr   r2, = __proc_info_end
+        add   r2, r2, r10
+1:      ldr   r3, [r1]
+        teq   r0, r3
+        beq   2f

xen/arch/arm/arm32/head.S skip_bss: · line 212

Quoted 10 lines
xen/arch/arm/arm32/head.S +10 -0
+        add   r1, r1, #PROCINFO_sizeof
+        cmp   r1, r2
+        blo   1b
+        mov   r4, r0
+        PRINT("- Missing processor info: ")
+        mov   r0, r4
+        bl    putn
+        PRINT(" -\r\n")
+        b     fail
+2:

At the end of all this r1 == physical address of the platform information? Can the initial comment say "Get processor specific proc info into rX" please.

If you could also follow the lead of other code in this file and obsessively comment what it is doing that would be great. e.g. comments like "r1 := physical address of start of table", "r2 := physical address of end of table" etc.

xen/arch/arm/arm32/head.S skip_bss: · line 215

Quoted 3 lines
xen/arch/arm/arm32/head.S +2 -0
+        /* Set return address(PIC) */
+        /* XXX: it only work while thumb2 is not enable in xen */

That's true of lots/all of our asm. Lets ignore that for now (no need to comment).

Since we already have physoffset in r10 would it be clearer to make use of that?

Quoted 13 lines
xen/arch/arm/arm32/head.S +3 -0
+        adr   lr, 1f
+        add   pc, r1, #PROCINFO_cpu_init 
+1:
         /* Set up memory attribute type tables */
         ldr   r0, =MAIR0VAL
         ldr   r1, =MAIR1VAL
 
xen/arch/arm/arm32/proc-v7.S new file +0 -0
new file mode 100644
index 0000000..2d46dca
@@ -0,0 +1,36 @@

[...]

xen/arch/arm/arm32/proc-v7.S line 29

Quoted 10 lines
xen/arch/arm/arm32/proc-v7.S new file +10 -0
+#include <asm/asm_defns.h>
+#include <asm/arm32/processor.h>
+
+.globl v7_init
+v7_init:
+        /* Set up the SMP bit in ACTLR */
+        mrc   CP32(r0, ACTLR)
+        orr   r0, r0, #(ACTLR_V7_SMP) /* enable SMP bit */
+        mcr   CP32(r0, ACTLR)
+        mov   pc, lr

Lets put the __v7_ca7mp_proc_info and __v7_ca15mp_proc_info here, calling v7_init directly and do away with proc-ca15.S and proc-ca7.S.

Quoted 14 lines
xen/arch/arm/arm32/proc-v7.S new file +7 -0
+
+/*
+ * Local variables:
+ * mode: ASM
+ * indent-tabs-mode: nil
+ * End:
+ */
xen/include/asm-arm/arm32/procinfo.h new file +0 -0
new file mode 100644
index 0000000..7e7a775

xen/include/asm-arm/arm32/procinfo.h line 2

Quoted 2 lines
xen/include/asm-arm/arm32/procinfo.h new file +2 -0
@@ -0,0 +1,30 @@
+/*
+ * include/asm-arm/arm32/procinfo.h

I suggest to put this in just include/asm-arm/procinfo.h. The same struct should eventually apply to 64-bit too.

[...]

xen/include/asm-arm/arm32/procinfo.h line 26

Quoted 5 lines
xen/include/asm-arm/arm32/procinfo.h new file +5 -0
+#ifndef __ASM_ARM_ARM32_PROCINFO_H
+#define __ASM_ARM_ARM32_PROCINFO_H
+
+struct proc_info_list {
+	unsigned int		cpu_val;

I think we should include "unsigned int cpu_mask" here too and remove MIDR_MASK. Will need equivalent changes in head.S as well.

Quoted 19 lines
xen/include/asm-arm/arm32/procinfo.h new file +4 -0
+	unsigned long		cpu_init;        /* used by head.S */
+};
+
+#endif
xen/include/asm-arm/processor-ca15.h +0 -3
index 06cdbdd..96438f0 100644
@@ -1,9 +1,6 @@
 #ifndef __ASM_ARM_PROCESSOR_CA15_H
 #define __ASM_ARM_PROCESSOR_CA15_H
 
-
-#define CORTEX_A15_ID     (0x410FC0F0)
-
 /* ACTLR Auxiliary Control Register, Cortex A15 */
 #define ACTLR_CA15_SNOOP_DELAYED      (1<<31)
 #define ACTLR_CA15_MAIN_CLOCK         (1<<30)

xen/include/asm-arm/processor-ca15.h line 29

Quoted 4 lines
xen/include/asm-arm/processor-ca15.h +0 -1
@@ -26,7 +23,6 @@
 #define ACTLR_CA15_OPT                (1<<9)
 #define ACTLR_CA15_WFI                (1<<8)
 #define ACTLR_CA15_WFE                (1<<7)
-#define ACTLR_CA15_SMP                (1<<6)

Lets leave this for completeness even if we aren't using it.

Quoted 3 lines
xen/include/asm-arm/processor-ca15.h +0 -0
 #define ACTLR_CA15_PLD                (1<<5)
 #define ACTLR_CA15_IP                 (1<<4)
 #define ACTLR_CA15_MICRO_BTB          (1<<3)
#8 lore raw

Re: [PATCH V2 2/2] xen: arm: implement early prink for 8250 uart

In reply to Bamvor Jian Zhang
Quoted 18 lines · Bamvor Jian Zhang
xen/arch/arm/arm32/debug-8250.inc new file +12 -0
new file mode 100644
index 0000000..c11357d
@@ -0,0 +1,48 @@
+/*
+ * xen/arch/arm/arm32/debug-8250.inc
+ *
+ * 8250 specific debug code
+ *
+ * Bamvor Jian Zhang <[email protected]>
+ * Copyright (c) 2013 SUSE
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.

xen/arch/arm/arm32/debug-8250.inc line 22

Quoted 10 lines
xen/arch/arm/arm32/debug-8250.inc new file +10 -0
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+
+#define UART_TX           (0x00<<2)    /* Out: Transmit buffer */
+#define UART_LSR          (0x05<<2)    /* In:  Line Status Register */

Is the shift 2 on Baozi's platform too? Perhaps this could be a #define provided in the same style as EARLY_UART_BASE_ADDRESS or via some other means?

The definitions themselves duplicate those in xen/drivers/char/ns16550.c, perhaps we could refactor those into a suitable header?

Quoted 26 lines
xen/arch/arm/arm32/debug-8250.inc new file +26 -0
+
+#define UART_LSR_THRE     0x20         /* Xmit holding register empty */
+
+/* 8250 UART wait UART to be ready to transmit
+ * rb: register which contains the UART base address
+ * rc: scratch register */
+.macro early_uart_ready rb, rc
+1:
+        ldr   \rc, [\rb, #UART_LSR]    /* <- UART_LSR (Line Status Register) */
+        tst   \rc, #UART_LSR_THRE      /* Check BUSY bit */
+        beq   1b                       /* Wait for the UART to be ready */
+.endm
+
+/* 8250 UART transmit character
+ * rb: register which contains the UART base address
+ * rt: register which contains the character to transmit */
+.macro early_uart_transmit rb, rt
+        str   \rt, [\rb, #UART_TX]     /* -> UART_TX */
+.endm
+
+/*
+ * Local variables:
+ * mode: ASM
+ * indent-tabs-mode: nil
+ * End:
+ */
#9 lore raw

Re: [PATCH V2 2/2] xen: arm: implement early prink for 8250 uart

Quoted 25 lines · Ian Campbell
Quoted 24 lines · Bamvor Jian Zhang
xen/arch/arm/arm32/debug-8250.inc new file +18 -0
new file mode 100644
index 0000000..c11357d
@@ -0,0 +1,48 @@
+/*
+ * xen/arch/arm/arm32/debug-8250.inc
+ *
+ * 8250 specific debug code
+ *
+ * Bamvor Jian Zhang <[email protected]>
+ * Copyright (c) 2013 SUSE
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
Quoted 8 lines

xen/arch/arm/arm32/debug-8250.inc line 22

Quoted 4 lines
xen/arch/arm/arm32/debug-8250.inc new file +4 -0
+
+
+#define UART_TX           (0x00<<2)    /* Out: Transmit buffer */
+#define UART_LSR          (0x05<<2)    /* In:  Line Status Register */

Is the shift 2 on Baozi's platform too? Perhaps this could be a #define provided in the same style as EARLY_UART_BASE_ADDRESS or via some other means?

Yes, mine has the shift 2 too. It is because every register's size is 4-Bytes on both of our platforms.

However, it seems this patch doesn't work on OMAP543 (I've modified EARLY_UART_BASE_ADDRESS to 0x48020000 which is the correct address). I'm looking for the reasons…

Quoted 4 lines

The definitions themselves duplicate those in xen/drivers/char/ns16550.c, perhaps we could refactor those into a suitable header?

+1

Quoted 29 lines
Quoted 27 lines
xen/arch/arm/arm32/debug-8250.inc new file +26 -0
+
+#define UART_LSR_THRE     0x20         /* Xmit holding register empty */
+
+/* 8250 UART wait UART to be ready to transmit
+ * rb: register which contains the UART base address
+ * rc: scratch register */
+.macro early_uart_ready rb, rc
+1:
+        ldr   \rc, [\rb, #UART_LSR]    /* <- UART_LSR (Line Status Register) */
+        tst   \rc, #UART_LSR_THRE      /* Check BUSY bit */
+        beq   1b                       /* Wait for the UART to be ready */
+.endm
+
+/* 8250 UART transmit character
+ * rb: register which contains the UART base address
+ * rt: register which contains the character to transmit */
+.macro early_uart_transmit rb, rt
+        str   \rt, [\rb, #UART_TX]     /* -> UART_TX */
+.endm
+
+/*
+ * Local variables:
+ * mode: ASM
+ * indent-tabs-mode: nil
+ * End:
+ */
#10 lore raw

Re: [PATCH V2 2/2] xen: arm: implement early prink for 8250 uart

Quoted 36 lines · Chen Baozi
Quoted 25 lines · Ian Campbell
Quoted 24 lines · Bamvor Jian Zhang
xen/arch/arm/arm32/debug-8250.inc new file +18 -0
new file mode 100644
index 0000000..c11357d
@@ -0,0 +1,48 @@
+/*
+ * xen/arch/arm/arm32/debug-8250.inc
+ *
+ * 8250 specific debug code
+ *
+ * Bamvor Jian Zhang <[email protected]>
+ * Copyright (c) 2013 SUSE
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
Quoted 8 lines

xen/arch/arm/arm32/debug-8250.inc line 22

Quoted 4 lines
xen/arch/arm/arm32/debug-8250.inc new file +4 -0
+
+
+#define UART_TX           (0x00<<2)    /* Out: Transmit buffer */
+#define UART_LSR          (0x05<<2)    /* In:  Line Status Register */

Is the shift 2 on Baozi's platform too? Perhaps this could be a #define provided in the same style as EARLY_UART_BASE_ADDRESS or via some other means?

Quoted 3 lines

Yes, mine has the shift 2 too. It is because every register's size is 4-Bytes on both of our platforms.

However, it seems this patch doesn't work on OMAP543 (I've modified EARLY_UART_BASE_ADDRESS to 0x48020000 which is the correct address). I'm looking for the reasons…

After fixing a typo when modifying EARLY_UART_BASE_ADDRESS and making clean the working tree, it works for me. Sorry for my carelessness.

Quoted 37 lines
Quoted 5 lines

The definitions themselves duplicate those in xen/drivers/char/ns16550.c, perhaps we could refactor those into a suitable header?

+1

Quoted 29 lines
Quoted 27 lines
xen/arch/arm/arm32/debug-8250.inc new file +26 -0
+
+#define UART_LSR_THRE     0x20         /* Xmit holding register empty */
+
+/* 8250 UART wait UART to be ready to transmit
+ * rb: register which contains the UART base address
+ * rc: scratch register */
+.macro early_uart_ready rb, rc
+1:
+        ldr   \rc, [\rb, #UART_LSR]    /* <- UART_LSR (Line Status Register) */
+        tst   \rc, #UART_LSR_THRE      /* Check BUSY bit */
+        beq   1b                       /* Wait for the UART to be ready */
+.endm
+
+/* 8250 UART transmit character
+ * rb: register which contains the UART base address
+ * rt: register which contains the character to transmit */
+.macro early_uart_transmit rb, rt
+        str   \rt, [\rb, #UART_TX]     /* -> UART_TX */
+.endm
+
+/*
+ * Local variables:
+ * mode: ASM
+ * indent-tabs-mode: nil
+ * End:
+ */
#11 lore raw

Re: [PATCH V2 2/2] xen: arm: implement early prink for 8250 uart

In reply to Chen Baozi
Quoted 16 lines · Bamvor Jian Zhang

implement early printk for 8250 uart which is used by lots of arm SOC, such as Allwinner A31(sun6i) and OMAP5432.

---
 docs/misc/arm/early-printk.txt    |  1 +
 xen/arch/arm/Rules.mk             |  5 ++++
 xen/arch/arm/arm32/debug-8250.inc | 48 +++++++++++++++++++++++++++++++++++++++
 3 files changed, 54 insertions(+)
 create mode 100644 xen/arch/arm/arm32/debug-8250.inc
docs/misc/arm/early-printk.txt +0 -0
index fbc3208..eaa66a1 100644

docs/misc/arm/early-printk.txt where mach is the name of the machine: · line 16

Quoted 4 lines
docs/misc/arm/early-printk.txt +1 -0
@@ -13,6 +13,7 @@ where mach is the name of the machine:
   - exynos5250: printk with the second UART
   - midway: printk with the pl011 on Calxeda Midway processors
   - fastmodel: printk on ARM Fastmodel software emulators
+  - sun6i: printk with 8250 on Allwinner A31 processors

Could this be better to add:

- omap5432: printk with 8250 compatible UART on OMAP5432 processors

Quoted 8 lines
docs/misc/arm/early-printk.txt +0 -0
 The base address and baud rate is hardcoded in xen/arch/arm/Rules.mk,
 see there when adding support for new machines.
xen/arch/arm/Rules.mk +0 -0
index 422ed04..51e823d 100644

xen/arch/arm/Rules.mk EARLY_PRINTK_INC := pl011 · line 71

Quoted 8 lines
xen/arch/arm/Rules.mk +5 -0
@@ -64,6 +64,11 @@ EARLY_PRINTK_INC := pl011
 EARLY_PRINTK_BAUD := 115200
 EARLY_UART_BASE_ADDRESS := 0xfff36000
 endif
+ifeq ($(CONFIG_EARLY_PRINTK), sun6i)
+# uart configured at 115200 by bootloader
+EARLY_PRINTK_INC := 8250
+EARLY_UART_BASE_ADDRESS := 0x01c28000
+endif

EARLY_UART_BASE_ADDRESS on OMAP5432 is 0x48020000, so I think we'd better to add another case to support it? For example:

+ifeq ($(CONFIG_EARLY_PRINTK), omap5432)
+# uart configured at 115200 by bootloader
+EARLY_PRINTK_INC := 8250
+EARLY_UART_BASE_ADDRESS := 0x48020000
+endif

Quoted 60 lines
xen/arch/arm/Rules.mk +0 -0
 ifneq ($(EARLY_PRINTK_INC),)
 EARLY_PRINTK := y
xen/arch/arm/arm32/debug-8250.inc new file +48 -0
new file mode 100644
index 0000000..c11357d
@@ -0,0 +1,48 @@
+/*
+ * xen/arch/arm/arm32/debug-8250.inc
+ *
+ * 8250 specific debug code
+ *
+ * Bamvor Jian Zhang <bjzhang@xxxxxxxx>
+ * Copyright (c) 2013 SUSE
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+
+#define UART_TX           (0x00<<2)    /* Out: Transmit buffer */
+#define UART_LSR          (0x05<<2)    /* In:  Line Status Register */
+
+#define UART_LSR_THRE     0x20         /* Xmit holding register empty */
+
+/* 8250 UART wait UART to be ready to transmit
+ * rb: register which contains the UART base address
+ * rc: scratch register */
+.macro early_uart_ready rb, rc
+1:
+        ldr   \rc, [\rb, #UART_LSR]    /* <- UART_LSR (Line Status Register) */
+        tst   \rc, #UART_LSR_THRE      /* Check BUSY bit */
+        beq   1b                       /* Wait for the UART to be ready */
+.endm
+
+/* 8250 UART transmit character
+ * rb: register which contains the UART base address
+ * rt: register which contains the character to transmit */
+.macro early_uart_transmit rb, rt
+        str   \rt, [\rb, #UART_TX]     /* -> UART_TX */
+.endm
+
+/*
+ * Local variables:
+ * mode: ASM
+ * indent-tabs-mode: nil
+ * End:
+ */
Signature · 1 line
1.8.1.4
#12 lore raw

Re: [PATCH V2 2/2] xen: arm: implement early prink for 8250 uart

Quoted 37 lines · Chen Baozi
Quoted 16 lines · Bamvor Jian Zhang

implement early printk for 8250 uart which is used by lots of arm SOC, such as Allwinner A31(sun6i) and OMAP5432.

---
 docs/misc/arm/early-printk.txt    |  1 +
 xen/arch/arm/Rules.mk             |  5 ++++
 xen/arch/arm/arm32/debug-8250.inc | 48 +++++++++++++++++++++++++++++++++++++++
 3 files changed, 54 insertions(+)
 create mode 100644 xen/arch/arm/arm32/debug-8250.inc
docs/misc/arm/early-printk.txt +0 -0
index fbc3208..eaa66a1 100644

docs/misc/arm/early-printk.txt where mach is the name of the machine: · line 16

Quoted 4 lines
docs/misc/arm/early-printk.txt +1 -0
@@ -13,6 +13,7 @@ where mach is the name of the machine:
   - exynos5250: printk with the second UART
   - midway: printk with the pl011 on Calxeda Midway processors
   - fastmodel: printk on ARM Fastmodel software emulators
+  - sun6i: printk with 8250 on Allwinner A31 processors

Could this be better to add:

- omap5432: printk with 8250 compatible UART on OMAP5432 processors

Quoted 11 lines
docs/misc/arm/early-printk.txt +0 -0
 The base address and baud rate is hardcoded in xen/arch/arm/Rules.mk,
 see there when adding support for new machines.
xen/arch/arm/Rules.mk +0 -0
index 422ed04..51e823d 100644
@@ -64,6 +64,11 @@ EARLY_PRINTK_INC := pl011
 EARLY_PRINTK_BAUD := 115200
 EARLY_UART_BASE_ADDRESS := 0xfff36000
 endif
Quoted 8 lines

xen/arch/arm/Rules.mk EARLY_PRINTK_INC := pl011 · line 71

Quoted 5 lines
xen/arch/arm/Rules.mk +5 -0
+ifeq ($(CONFIG_EARLY_PRINTK), sun6i)
+# uart configured at 115200 by bootloader
+EARLY_PRINTK_INC := 8250
+EARLY_UART_BASE_ADDRESS := 0x01c28000
+endif

EARLY_UART_BASE_ADDRESS on OMAP5432 is 0x48020000, so I think we'd better to add another case to support it?

Yes, this is exactly what should happen. You could either send a patch on top of Bamvor's or perhaps he would be willing to integrate these bits into his existing patch.

xen/arch/arm/Rules.mk EARLY_PRINTK_INC := pl011 · line 71

Quoted 7 lines

For example:

xen/arch/arm/Rules.mk +5 -0
+ifeq ($(CONFIG_EARLY_PRINTK), omap5432)
+# uart configured at 115200 by bootloader
+EARLY_PRINTK_INC := 8250
+EARLY_UART_BASE_ADDRESS := 0x48020000
+endif

Ian.

#3 lore raw

Re: [PATCH V2 1/2] xen: arm: introduce Cortex-A7 support

In reply to Ian Campbell

Hi, Ian

Quoted 1 line
Quoted 1 line
Quoted 1 line

Wrote "Ian Campbell <[email protected]>"> On Tue,

Quoted 47 lines · Bamvor Jian Zhang
Quoted 4 lines

Introduce Cortex-A7 with a scalable proc_info_list which including cpu id and cpu initialize function.
In head.S, search cpu specific MIDR in procinfo and call such initialize function. Currently, support Cortex-A7 and Cortex-A15.

I like the general shape of it, thanks!
A few comments below.

Quoted 39 lines
xen/arch/arm/arm32/head.S +14 -5
index 0588d54..d62401d 100644
@@ -20,6 +20,7 @@
 #include <asm/config.h>
 #include <asm/page.h>
 #include <asm/processor-ca15.h>
+#include <asm/processor-ca7.h>
 #include <asm/asm_defns.h>
 
 #define ZIMAGE_MAGIC_NUMBER 0x016f2818
@@ -188,15 +189,33 @@ skip_bss:
 
         PRINT("- Setting up control registers -\r\n")
 
-        /* Read CPU ID */
+        /* Get processor specific proc info */
         mrc   CP32(r0, MIDR)
         ldr   r1, =(MIDR_MASK)
         and   r0, r0, r1
-        /* Is this a Cortex A15? */
-        ldr   r1, =(CORTEX_A15_ID)
-        teq   r0, r1
-        bleq  cortex_a15_init
+        ldr   r1, = __proc_info_start
+        add   r1, r1, r10
+        ldr   r2, = __proc_info_end
+        add   r2, r2, r10
+1:      ldr   r3, [r1]
+        teq   r0, r3
+        beq   2f
+        add   r1, r1, #PROCINFO_sizeof
+        cmp   r1, r2
+        blo   1b
+        mov   r4, r0
+        PRINT("- Missing processor info: ")
Quoted 8 lines

xen/arch/arm/arm32/head.S skip_bss: · line 212

Quoted 5 lines
xen/arch/arm/arm32/head.S +5 -0
+        mov   r0, r4
+        bl    putn
+        PRINT(" -\r\n")
+        b     fail
+2:

At the end of all this r1 == physical address of the platform information?

yes

Quoted 1 line

Can the initial comment say "Get processor specific proc info into rX" please.

sure

Quoted 4 lines

If you could also follow the lead of other code in this file and obsessively comment what it is doing that would be great. e.g. comments like "r1 := physical address of start of table", "r2 := physical address of end of table" etc.

ok. i will

Quoted 7 lines

xen/arch/arm/arm32/head.S skip_bss: · line 215

Quoted 4 lines
xen/arch/arm/arm32/head.S +2 -0
+        /* Set return address(PIC) */
+        /* XXX: it only work while thumb2 is not enable in xen */

That's true of lots/all of our asm. Lets ignore that for now (no need to comment).

ok

Quoted 2 lines

Since we already have physoffset in r10 would it be clearer to make use of that?

sorry if i am wrong. do u mean change "adr lr, 1f" to something like "add lr, pc, r10"?

Quoted 15 lines
Quoted 14 lines
xen/arch/arm/arm32/head.S +3 -0
+        adr   lr, 1f
+        add   pc, r1, #PROCINFO_cpu_init 
+1:
         /* Set up memory attribute type tables */
         ldr   r0, =MAIR0VAL
         ldr   r1, =MAIR1VAL
 
xen/arch/arm/arm32/proc-v7.S new file +0 -0
new file mode 100644
index 0000000..2d46dca
@@ -0,0 +1,36 @@

[...]

Quoted 13 lines

xen/arch/arm/arm32/proc-v7.S line 29

Quoted 10 lines
xen/arch/arm/arm32/proc-v7.S new file +10 -0
+#include <asm/asm_defns.h>
+#include <asm/arm32/processor.h>
+
+.globl v7_init
+v7_init:
+        /* Set up the SMP bit in ACTLR */
+        mrc   CP32(r0, ACTLR)
+        orr   r0, r0, #(ACTLR_V7_SMP) /* enable SMP bit */
+        mcr   CP32(r0, ACTLR)
+        mov   pc, lr

Lets put the __v7_ca7mp_proc_info and __v7_ca15mp_proc_info here, calling v7_init directly and do away with proc-ca15.S and proc-ca7.S.

Ok.
So, i will remove proc-ca15.S and proc-ca7.S?

Quoted 9 lines
Quoted 8 lines
xen/arch/arm/arm32/proc-v7.S new file +7 -0
+
+/*
+ * Local variables:
+ * mode: ASM
+ * indent-tabs-mode: nil
+ * End:
+ */
Quoted 11 lines

xen/include/asm-arm/arm32/procinfo.h line 2

Quoted 8 lines
xen/include/asm-arm/arm32/procinfo.h new file +2 -0
new file mode 100644
index 0000000..7e7a775
@@ -0,0 +1,30 @@
+/*
+ * include/asm-arm/arm32/procinfo.h

I suggest to put this in just include/asm-arm/procinfo.h. The same struct should eventually apply to 64-bit too.

ok.

Quoted 10 lines

[...]

xen/include/asm-arm/arm32/procinfo.h line 26

Quoted 5 lines
xen/include/asm-arm/arm32/procinfo.h new file +5 -0
+#ifndef __ASM_ARM_ARM32_PROCINFO_H
+#define __ASM_ARM_ARM32_PROCINFO_H
+
+struct proc_info_list {
+	unsigned int		cpu_val;

I think we should include "unsigned int cpu_mask" here too and remove MIDR_MASK. Will need equivalent changes in head.S as well.

yes, i need to do this for Aarch64 extesion in future.

Quoted 13 lines
Quoted 13 lines
xen/include/asm-arm/arm32/procinfo.h new file +4 -0
+	unsigned long		cpu_init;        /* used by head.S */
+};
+
+#endif
xen/include/asm-arm/processor-ca15.h +0 -0
index 06cdbdd..96438f0 100644
@@ -1,9 +1,6 @@
 #ifndef __ASM_ARM_PROCESSOR_CA15_H
 #define __ASM_ARM_PROCESSOR_CA15_H
 
Quoted 13 lines

xen/include/asm-arm/processor-ca15.h line 29

Quoted 11 lines
xen/include/asm-arm/processor-ca15.h +0 -4
-
-#define CORTEX_A15_ID     (0x410FC0F0)
-
 /* ACTLR Auxiliary Control Register, Cortex A15 */
 #define ACTLR_CA15_SNOOP_DELAYED      (1<<31)
 #define ACTLR_CA15_MAIN_CLOCK         (1<<30)
@@ -26,7 +23,6 @@
 #define ACTLR_CA15_OPT                (1<<9)
 #define ACTLR_CA15_WFI                (1<<8)
 #define ACTLR_CA15_WFE                (1<<7)
-#define ACTLR_CA15_SMP                (1<<6)

Lets leave this for completeness even if we aren't using it.

i was thinking about it. if i define the following
#define ACTLR_CA15_SMP ACTLR_V7_SMP
i need include asm/arm/processor.h which including CP micros.

Bamvor

Quoted 4 lines
Quoted 4 lines
xen/include/asm-arm/processor-ca15.h +0 -0
 #define ACTLR_CA15_PLD                (1<<5)
 #define ACTLR_CA15_IP                 (1<<4)
 #define ACTLR_CA15_MICRO_BTB          (1<<3)
#4 lore raw

Re: [PATCH V2 1/2] xen: arm: introduce Cortex-A7 support

Quoted 4 lines · Bamvor Jian Zhang
Quoted 2 lines

Since we already have physoffset in r10 would it be clearer to make use of that?

sorry if i am wrong. do u mean change "adr lr, 1f" to something like "add lr, pc, r10"?

I think I was thinking

	add r1, r10, [r1, #PROCINFO_cpu_init]
	bl r1

(I'm sure I've got the operands to the add subtly wrong somehow, but hopefully you get the gist of it).

Quoted 11 lines
Quoted 10 lines

[...]

xen/include/asm-arm/arm32/procinfo.h line 26

Quoted 5 lines
xen/include/asm-arm/arm32/procinfo.h new file +5 -0
+#ifndef __ASM_ARM_ARM32_PROCINFO_H
+#define __ASM_ARM_ARM32_PROCINFO_H
+
+struct proc_info_list {
+	unsigned int		cpu_val;

I think we should include "unsigned int cpu_mask" here too and remove MIDR_MASK. Will need equivalent changes in head.S as well.

yes, i need to do this for Aarch64 extesion in future.

Does MIDR differ between 32- and 64-bit? I must confess I've not checked but assumed it was the same format.

Quoted 26 lines
Quoted 13 lines
Quoted 13 lines
xen/include/asm-arm/arm32/procinfo.h new file +4 -0
+	unsigned long		cpu_init;        /* used by head.S */
+};
+
+#endif
xen/include/asm-arm/processor-ca15.h +0 -0
index 06cdbdd..96438f0 100644
@@ -1,9 +1,6 @@
 #ifndef __ASM_ARM_PROCESSOR_CA15_H
 #define __ASM_ARM_PROCESSOR_CA15_H
 
Quoted 13 lines

xen/include/asm-arm/processor-ca15.h line 29

Quoted 11 lines
xen/include/asm-arm/processor-ca15.h +0 -4
-
-#define CORTEX_A15_ID     (0x410FC0F0)
-
 /* ACTLR Auxiliary Control Register, Cortex A15 */
 #define ACTLR_CA15_SNOOP_DELAYED      (1<<31)
 #define ACTLR_CA15_MAIN_CLOCK         (1<<30)
@@ -26,7 +23,6 @@
 #define ACTLR_CA15_OPT                (1<<9)
 #define ACTLR_CA15_WFI                (1<<8)
 #define ACTLR_CA15_WFE                (1<<7)
-#define ACTLR_CA15_SMP                (1<<6)

Lets leave this for completeness even if we aren't using it.

Quoted 2 lines

i was thinking about it. if i define the following
#define ACTLR_CA15_SMP ACTLR_V7_SMP

I meant just leave it as 1<<6.

Quoted 8 lines

i need include asm/arm/processor.h which including CP micros.

Bamvor

Quoted 4 lines
Quoted 4 lines
xen/include/asm-arm/processor-ca15.h +0 -0
 #define ACTLR_CA15_PLD                (1<<5)
 #define ACTLR_CA15_IP                 (1<<4)
 #define ACTLR_CA15_MICRO_BTB          (1<<3)
#5 lore raw

Re: [PATCH V2 1/2] xen: arm: introduce Cortex-A7 support

In reply to Bamvor Jian Zhang
Quoted 8 lines · Bamvor Jian Zhang

Hi, Ian

Quoted 1 line
Quoted 1 line
Quoted 1 line

Wrote "Ian Campbell <[email protected]>"> On Tue,

Quoted 4 lines · Bamvor Jian Zhang
Quoted 3 lines
xen/arch/arm/arm32/head.S +2 -0
+        /* Set return address(PIC) */
+        /* XXX: it only work while thumb2 is not enable in xen */
Quoted 7 lines
Quoted 2 lines

That's true of lots/all of our asm. Lets ignore that for now (no need to comment).

ok

Quoted 2 lines

Since we already have physoffset in r10 would it be clearer to make use of that?

sorry if i am wrong. do u mean change "adr lr, 1f" to something like "add lr, pc, r10"?

No, I think this code is correct as it stands.

But it is a bit strange that the CPUinfo struct contains _code_ to jump to a routine, rather than just containing the address of the routine itself. If it just contained the address, the structures could be defined in C (so we'd be certain that they matched the offset and size constants we use here). And then this asm would indeed use physoffset, something like:

	ldr   r1, [r1, #PROCINFO_cpu_init]   /* r1 := vaddr(init func) */
	adr   lr, 1f                         /* Save return address */
	add   pc, r1, r10                    /* Call paddr(init func) */

1:

The way you've done it is certainly very clever, but we don't need to optimize single instructions out of the boot time and I think this is clearer.

Cheers,

Tim.

#6 lore raw

Re: [PATCH V2 1/2] xen: arm: introduce Cortex-A7 support

Quoted 11 lines · Tim Deegan
Quoted 10 lines · Bamvor Jian Zhang

Hi, Ian

Quoted 1 line
Quoted 1 line
Quoted 1 line

Wrote "Ian Campbell <[email protected]>"> On Tue,

Quoted 6 lines · Bamvor Jian Zhang

xen/arch/arm/arm32/head.S skip_bss: · line 215

Quoted 3 lines
xen/arch/arm/arm32/head.S +2 -0
+        /* Set return address(PIC) */
+        /* XXX: it only work while thumb2 is not enable in xen */

That's true of lots/all of our asm. Lets ignore that for now (no need to comment).

Quoted 7 lines
Quoted 5 lines

ok

Quoted 2 lines

Since we already have physoffset in r10 would it be clearer to make use of that?

sorry if i am wrong. do u mean change "adr lr, 1f" to something like "add lr, pc, r10"?

No, I think this code is correct as it stands.

Tim pointed out IRL that bl can't take a register...

Quoted 2 lines

But it is a bit strange that the CPUinfo struct contains _code_ to jump to a routine,

I hadn't noticed that!

Quoted 23 lines

rather than just containing the address of the routine
itself. If it just contained the address, the structures could be defined in C (so we'd be certain that they matched the offset and size constants we use here). And then this asm would indeed use physoffset, something like:

	ldr   r1, [r1, #PROCINFO_cpu_init]   /* r1 := vaddr(init func) */
	adr   lr, 1f                         /* Save return address */
	add   pc, r1, r10                    /* Call paddr(init func) */

1:

The way you've done it is certainly very clever, but we don't need to optimize single instructions out of the boot time and I think this is clearer.

Cheers,

Tim.

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#15 lore raw

Re: [PATCH V2 2/2] xen: arm: implement early prink for 8250 uart

In reply to Ian Campbell

Hi, Ian

Quoted 35 lines
Quoted 1 line
Quoted 1 line

Wrote "Ian Campbell <[email protected]>"> On Tue

Quoted 18 lines · Bamvor Jian Zhang
xen/arch/arm/arm32/debug-8250.inc new file +12 -0
new file mode 100644
index 0000000..c11357d
@@ -0,0 +1,48 @@
+/*
+ * xen/arch/arm/arm32/debug-8250.inc
+ *
+ * 8250 specific debug code
+ *
+ * Bamvor Jian Zhang <[email protected]>
+ * Copyright (c) 2013 SUSE
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.

xen/arch/arm/arm32/debug-8250.inc line 22

Quoted 10 lines
xen/arch/arm/arm32/debug-8250.inc new file +10 -0
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+
+#define UART_TX           (0x00<<2)    /* Out: Transmit buffer */
+#define UART_LSR          (0x05<<2)    /* In:  Line Status Register */

Is the shift 2 on Baozi's platform too? Perhaps this could be a #define provided in the same style as EARLY_UART_BASE_ADDRESS or via some other means?

Quoted 3 lines

The definitions themselves duplicate those in xen/drivers/char/ns16550.c, perhaps we could refactor those into a suitable header?

yes. it should be. meanwhile considering the shift bit and other things. i am not sure how to merge the headers until i got the ns16550 actual used by arm SOC.

Bamvor

Quoted 27 lines
Quoted 27 lines
xen/arch/arm/arm32/debug-8250.inc new file +26 -0
+
+#define UART_LSR_THRE     0x20         /* Xmit holding register empty */
+
+/* 8250 UART wait UART to be ready to transmit
+ * rb: register which contains the UART base address
+ * rc: scratch register */
+.macro early_uart_ready rb, rc
+1:
+        ldr   \rc, [\rb, #UART_LSR]    /* <- UART_LSR (Line Status Register) */
+        tst   \rc, #UART_LSR_THRE      /* Check BUSY bit */
+        beq   1b                       /* Wait for the UART to be ready */
+.endm
+
+/* 8250 UART transmit character
+ * rb: register which contains the UART base address
+ * rt: register which contains the character to transmit */
+.macro early_uart_transmit rb, rt
+        str   \rt, [\rb, #UART_TX]     /* -> UART_TX */
+.endm
+
+/*
+ * Local variables:
+ * mode: ASM
+ * indent-tabs-mode: nil
+ * End:
+ */
#13 lore raw

Re: [PATCH V2 2/2] xen: arm: implement early prink for 8250 uart

In reply to Ian Campbell

Hi, Ian, Chen

Quoted 48 lines
Quoted 1 line
Quoted 1 line

Wrote "Ian Campbell <[email protected]>"> On Wed,

Quoted 37 lines · Chen Baozi
Quoted 16 lines · Bamvor Jian Zhang

implement early printk for 8250 uart which is used by lots of arm SOC, such as Allwinner A31(sun6i) and OMAP5432.

---
 docs/misc/arm/early-printk.txt    |  1 +
 xen/arch/arm/Rules.mk             |  5 ++++
 xen/arch/arm/arm32/debug-8250.inc | 48 +++++++++++++++++++++++++++++++++++++++
 3 files changed, 54 insertions(+)
 create mode 100644 xen/arch/arm/arm32/debug-8250.inc
docs/misc/arm/early-printk.txt +0 -0
index fbc3208..eaa66a1 100644

docs/misc/arm/early-printk.txt where mach is the name of the machine: · line 16

Quoted 4 lines
docs/misc/arm/early-printk.txt +1 -0
@@ -13,6 +13,7 @@ where mach is the name of the machine:
   - exynos5250: printk with the second UART
   - midway: printk with the pl011 on Calxeda Midway processors
   - fastmodel: printk on ARM Fastmodel software emulators
+  - sun6i: printk with 8250 on Allwinner A31 processors

Could this be better to add:

- omap5432: printk with 8250 compatible UART on OMAP5432 processors

Quoted 11 lines
docs/misc/arm/early-printk.txt +0 -0
 The base address and baud rate is hardcoded in xen/arch/arm/Rules.mk,
 see there when adding support for new machines.
xen/arch/arm/Rules.mk +0 -0
index 422ed04..51e823d 100644
@@ -64,6 +64,11 @@ EARLY_PRINTK_INC := pl011
 EARLY_PRINTK_BAUD := 115200
 EARLY_UART_BASE_ADDRESS := 0xfff36000
 endif
Quoted 8 lines

xen/arch/arm/Rules.mk EARLY_PRINTK_INC := pl011 · line 71

Quoted 5 lines
xen/arch/arm/Rules.mk +5 -0
+ifeq ($(CONFIG_EARLY_PRINTK), sun6i)
+# uart configured at 115200 by bootloader
+EARLY_PRINTK_INC := 8250
+EARLY_UART_BASE_ADDRESS := 0x01c28000
+endif

EARLY_UART_BASE_ADDRESS on OMAP5432 is 0x48020000, so I think we'd better to add another case to support it?

Quoted 3 lines

Yes, this is exactly what should happen. You could either send a patch on top of Bamvor's or perhaps he would be willing to integrate these bits into his existing patch.

yes, i'd like to do it. meanwhile adding omap5432 uart support is a little bit confuse with my cover letter.
how about i send one patch for Cortex-A7 support. and another series patch for 8250 compatibility uart. which including
1/3: debug-8250.inc
2/3: sun6i changes in early-printk.txt and Rules.mk.
3/3: omap5432 changes in early-printk.txt and Rules.mk.

bamvor

Quoted 10 lines

xen/arch/arm/Rules.mk EARLY_PRINTK_INC := pl011 · line 71

Quoted 8 lines

For example:

xen/arch/arm/Rules.mk +5 -0
+ifeq ($(CONFIG_EARLY_PRINTK), omap5432)
+# uart configured at 115200 by bootloader
+EARLY_PRINTK_INC := 8250
+EARLY_UART_BASE_ADDRESS := 0x48020000
+endif

Ian.

#14 lore raw

Re: [PATCH V2 2/2] xen: arm: implement early prink for 8250 uart

Quoted 53 lines · Bamvor Jian Zhang

Hi, Ian, Chen

Quoted 48 lines
Quoted 1 line
Quoted 1 line

Wrote "Ian Campbell <[email protected]>"> On Wed,

Quoted 37 lines · Chen Baozi
Quoted 16 lines · Bamvor Jian Zhang

implement early printk for 8250 uart which is used by lots of arm SOC, such as Allwinner A31(sun6i) and OMAP5432.

---

docs/misc/arm/early-printk.txt    |  1 +
xen/arch/arm/Rules.mk             |  5 ++++
xen/arch/arm/arm32/debug-8250.inc | 48 +++++++++++++++++++++++++++++++++++++++
3 files changed, 54 insertions(+)

create mode 100644 xen/arch/arm/arm32/debug-8250.inc

docs/misc/arm/early-printk.txt +0 -0
index fbc3208..eaa66a1 100644

docs/misc/arm/early-printk.txt where mach is the name of the machine: · line 16

Quoted 4 lines
docs/misc/arm/early-printk.txt +1 -0
@@ -13,6 +13,7 @@ where mach is the name of the machine:
  - exynos5250: printk with the second UART
  - midway: printk with the pl011 on Calxeda Midway processors
  - fastmodel: printk on ARM Fastmodel software emulators
+  - sun6i: printk with 8250 on Allwinner A31 processors

Could this be better to add:

- omap5432: printk with 8250 compatible UART on OMAP5432 processors

Quoted 11 lines
docs/misc/arm/early-printk.txt +0 -0
 The base address and baud rate is hardcoded in xen/arch/arm/Rules.mk,

see there when adding support for new machines.

xen/arch/arm/Rules.mk +0 -0
index 422ed04..51e823d 100644
@@ -64,6 +64,11 @@ EARLY_PRINTK_INC := pl011

EARLY_PRINTK_BAUD := 115200
EARLY_UART_BASE_ADDRESS := 0xfff36000
endif

Quoted 8 lines

xen/arch/arm/Rules.mk EARLY_PRINTK_INC := pl011 · line 71

Quoted 5 lines
xen/arch/arm/Rules.mk +5 -0
+ifeq ($(CONFIG_EARLY_PRINTK), sun6i)
+# uart configured at 115200 by bootloader
+EARLY_PRINTK_INC := 8250
+EARLY_UART_BASE_ADDRESS := 0x01c28000
+endif

EARLY_UART_BASE_ADDRESS on OMAP5432 is 0x48020000, so I think we'd better to add another case to support it?

Quoted 3 lines

Yes, this is exactly what should happen. You could either send a patch on top of Bamvor's or perhaps he would be willing to integrate these bits into his existing patch.

Quoted 7 lines

yes, i'd like to do it. meanwhile adding omap5432 uart support is a little bit confuse with my cover letter.
how about i send one patch for Cortex-A7 support. and another series patch for 8250 compatibility uart. which including
1/3: debug-8250.inc
2/3: sun6i changes in early-printk.txt and Rules.mk.
3/3: omap5432 changes in early-printk.txt and Rules.mk.

I'm OK with it.

Quoted 15 lines

bamvor

Quoted 10 lines

xen/arch/arm/Rules.mk EARLY_PRINTK_INC := pl011 · line 71

Quoted 8 lines

For example:

xen/arch/arm/Rules.mk +5 -0
+ifeq ($(CONFIG_EARLY_PRINTK), omap5432)
+# uart configured at 115200 by bootloader
+EARLY_PRINTK_INC := 8250
+EARLY_UART_BASE_ADDRESS := 0x48020000
+endif

Ian.

#16 lore raw

Re: [PATCH V2 2/2] xen: arm: implement early prink for 8250 uart

In reply to Bamvor Jian Zhang
Quoted 37 lines · Bamvor Jian Zhang

Hi, Ian

Quoted 35 lines
Quoted 1 line
Quoted 1 line

Wrote "Ian Campbell <[email protected]>"> On Tue

Quoted 18 lines · Bamvor Jian Zhang
xen/arch/arm/arm32/debug-8250.inc new file +12 -0
new file mode 100644
index 0000000..c11357d
@@ -0,0 +1,48 @@
+/*
+ * xen/arch/arm/arm32/debug-8250.inc
+ *
+ * 8250 specific debug code
+ *
+ * Bamvor Jian Zhang <[email protected]>
+ * Copyright (c) 2013 SUSE
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.

xen/arch/arm/arm32/debug-8250.inc line 22

Quoted 10 lines
xen/arch/arm/arm32/debug-8250.inc new file +10 -0
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+
+#define UART_TX           (0x00<<2)    /* Out: Transmit buffer */
+#define UART_LSR          (0x05<<2)    /* In:  Line Status Register */

Is the shift 2 on Baozi's platform too? Perhaps this could be a #define provided in the same style as EARLY_UART_BASE_ADDRESS or via some other means?

Quoted 6 lines
Quoted 3 lines

The definitions themselves duplicate those in xen/drivers/char/ns16550.c, perhaps we could refactor those into a suitable header?

yes. it should be. meanwhile considering the shift bit and other things. i am not sure how to merge the headers until i got the ns16550 actual used by arm SOC.

I think move the definitions as is from ns16550.c but add a UART_ prefix. Leave the shift in this code.

Eventually ns16550 will need to learn about shifts (and perhaps io vs memory mapped io).

Ian.

#17 lore raw

Re: [PATCH V2 2/2] xen: arm: implement early prink for 8250 uart

In reply to Bamvor Jian Zhang
Quoted 37 lines · Bamvor Jian Zhang

Hi, Ian

Quoted 35 lines
Quoted 1 line
Quoted 1 line

Wrote "Ian Campbell <[email protected]>"> On Tue

Quoted 18 lines · Bamvor Jian Zhang
xen/arch/arm/arm32/debug-8250.inc new file +12 -0
new file mode 100644
index 0000000..c11357d
@@ -0,0 +1,48 @@
+/*
+ * xen/arch/arm/arm32/debug-8250.inc
+ *
+ * 8250 specific debug code
+ *
+ * Bamvor Jian Zhang <[email protected]>
+ * Copyright (c) 2013 SUSE
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.

xen/arch/arm/arm32/debug-8250.inc line 22

Quoted 10 lines
xen/arch/arm/arm32/debug-8250.inc new file +10 -0
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+
+#define UART_TX           (0x00<<2)    /* Out: Transmit buffer */
+#define UART_LSR          (0x05<<2)    /* In:  Line Status Register */

Is the shift 2 on Baozi's platform too? Perhaps this could be a #define provided in the same style as EARLY_UART_BASE_ADDRESS or via some other means?

Quoted 6 lines
Quoted 3 lines

The definitions themselves duplicate those in xen/drivers/char/ns16550.c, perhaps we could refactor those into a suitable header?

yes. it should be. meanwhile considering the shift bit and other things. i am not sure how to merge the headers until i got the ns16550 actual used by arm SOC.

Actually, I've already modified ns16550 driver to work on my platform. And it also has the shift problem.

If you like, I could send a patch to refactor it, :-)

Baozi

Quoted 31 lines

Bamvor

Quoted 27 lines
Quoted 27 lines
xen/arch/arm/arm32/debug-8250.inc new file +26 -0
+
+#define UART_LSR_THRE     0x20         /* Xmit holding register empty */
+
+/* 8250 UART wait UART to be ready to transmit
+ * rb: register which contains the UART base address
+ * rc: scratch register */
+.macro early_uart_ready rb, rc
+1:
+        ldr   \rc, [\rb, #UART_LSR]    /* <- UART_LSR (Line Status Register) */
+        tst   \rc, #UART_LSR_THRE      /* Check BUSY bit */
+        beq   1b                       /* Wait for the UART to be ready */
+.endm
+
+/* 8250 UART transmit character
+ * rb: register which contains the UART base address
+ * rt: register which contains the character to transmit */
+.macro early_uart_transmit rb, rt
+        str   \rt, [\rb, #UART_TX]     /* -> UART_TX */
+.endm
+
+/*
+ * Local variables:
+ * mode: ASM
+ * indent-tabs-mode: nil
+ * End:
+ */
#18 lore raw

Re: [PATCH V2 2/2] xen: arm: implement early prink for 8250 uart

Quoted 15 lines · Chen Baozi
Quoted 13 lines · Bamvor Jian Zhang
Quoted 13 lines
Quoted 1 line
Quoted 1 line

Wrote "Ian Campbell <[email protected]>"> On Tue

xen/arch/arm/arm32/debug-8250.inc line 22

Quoted 2 lines · Bamvor Jian Zhang
xen/arch/arm/arm32/debug-8250.inc new file +2 -0
+#define UART_TX           (0x00<<2)    /* Out: Transmit buffer */
+#define UART_LSR          (0x05<<2)    /* In:  Line Status Register */

Is the shift 2 on Baozi's platform too? Perhaps this could be a #define provided in the same style as EARLY_UART_BASE_ADDRESS or via some other means?

The definitions themselves duplicate those in xen/drivers/char/ns16550.c, perhaps we could refactor those into a suitable header?

Quoted 6 lines
Quoted 3 lines

yes. it should be. meanwhile considering the shift bit and other things. i am not sure how to merge the headers until i got the ns16550 actual used by arm SOC.

Actually, I've already modified ns16550 driver to work on my platform. And it also has the shift problem.

If you like, I could send a patch to refactor it, :-)

Yes please!