hello_world: Use new headers and frequency from syscon
authorBenjamin Herrenschmidt <benh@kernel.crashing.org>
Fri, 8 May 2020 00:42:01 +0000 (10:42 +1000)
committerBenjamin Herrenschmidt <benh@kernel.crashing.org>
Fri, 8 May 2020 11:06:16 +0000 (21:06 +1000)
This uses the new header files for register definitions and
extracts the core frequency from syscon rather than hard coding it.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
fpga/hello_world.hex
hello_world/Makefile
hello_world/console.c
hello_world/hello_world.bin
hello_world/hello_world.elf
hello_world/hello_world.hex
rust_lib_demo/Makefile
tests/Makefile.test

index 6bbe4126a6474c96d60fbe417d9d3f894439c183..609824771198dc139c8dd1501986228bad54bd5e 100644 (file)
@@ -1,23 +1,11 @@
+000000004800012c
+0000000000000000
 4800002408000048
 01006b69a600607d
 a602487d05009f42
 a64b5a7d14004a39
 2402004ca64b7b7d
-3c20000048000004
-782107c660210000
-60212f0064210000
-618c00003d800000
-658c0000798c07c6
-7d8903a6618c113c
-480000004e800421
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
-0000000000000000
+00000000480000f4
 0000000000000000
 0000000000000000
 0000000000000000
@@ -42,6 +30,18 @@ a64b5a7d14004a39
 0000000000000000
 0000000000000000
 0000000000000000
+4800002408000048
+01006b69a600607d
+a602487d05009f42
+a64b5a7d14004a39
+2402004ca64b7b7d
+3c20000048000004
+782107c660210000
+60211f0064210000
+618c00003d800000
+658c0000798c07c6
+7d8903a6618c1014
+480000004e800421
 0000000000000000
 0000000000000000
 0000000000000000
@@ -513,52 +513,74 @@ a64b5a7d14004a39
 e8010010ebc1fff0
 7c0803a6ebe1fff8
 3c4000014e800020
+7c0802a63842a000
+3fe2fffffbe1fff8
+f80100103bff7240
+48000051f821ffd1
+7fe3fb7860000000
+60000000480001d5
+7fe3fb787c641b78
+600000004800017d
+60000000480000ed
+480001295463063e
+4bffffec60000000
+0100000000000000
+3c40000100000180
 3d20c0003842a000
 6129200060000000
 f922800079290020
-394000353d20c000
-7929002061292018
-4e800020f9490000
+612900203d20c000
+7c0004ac79290020
+3d40001c7d204eea
+7d295392614a2000
+394a0018e9428000
+7c0004ac3929ffff
+4e8000207d2057ea
 0000000000000000
 3c40000100000000
 600000003842a000
-390a0010e9428000
-71290001e9280000
-e86a00084082fff8
+394000ffe9228000
+7c0004ac39290020
+4e8000207d404fea
+0000000000000000
+3c40000100000000
+600000003842a000
+39400000e9228000
+7c0004ac39290020
+4e8000207d404fea
+0000000000000000
+3c40000100000000
+600000003842a000
+39290010e9228000
+7d204eea7c0004ac
+4082ffe871290001
+38630008e8628000
+7c601eea7c0004ac
 4e8000205463063e
 0000000000000000
 3c40000100000000
 600000003842a000
-390a0010e9428000
-71290008e9280000
-f86a00004082fff8
-000000004e800020
-0000000000000000
-3842a0003c400001
-fbc1fff07c0802a6
-7fc32214fbe1fff8
-f80100107c7f1b78
-7fbff040f821ffd1
-38210030409e000c
-887f00004bffff10
-4bffff993bff0001
-000000004bffffe4
-0000028001000000
-7d4348ae39200000
-409e000c2f8a0000
-4e8000207d234b78
-4bffffe839290001
+39290010e9228000
+7d204eea7c0004ac
+4082ffe871290008
+7c0004ace9228000
+4e8000207c604fea
 0000000000000000
 3c40000100000000
 7c0802a63842a000
-3fe2fffffbe1fff8
-f80100103bff7190
-4bfffec1f821ffd1
-4bffffad7fe3fb78
-7fe3fb787c641b78
-4bfffee94bffff59
-4bffff195463063e
-000000004bfffff4
-0000018001000000
+fbe1fff8fbc1fff0
+7c7f1b787fc32214
+f821ffd1f8010010
+409e000c7fbff040
+4bfffe0c38210030
+3bff0001887f0000
+4bffffe44bffff8d
+0100000000000000
+3920000000000280
+2f8a00007d4348ae
+7d234b78409e000c
+392900014e800020
+000000004bffffe8
+0000000000000000
 6f57206f6c6c6548
 0000000a0d646c72
index a6091998a608fa7a3f440fb95cad0a10e0585887..9051e7dc2b483d8ffe4d70eb4bf7236ed553491d 100644 (file)
@@ -9,7 +9,7 @@ CC = $(CROSS_COMPILE)gcc
 LD = $(CROSS_COMPILE)ld
 OBJCOPY = $(CROSS_COMPILE)objcopy
 
-CFLAGS = -Os -g -Wall -std=c99 -msoft-float -mno-string -mno-multiple -mno-vsx -mno-altivec -mlittle-endian -fno-stack-protector -mstrict-align -ffreestanding -fdata-sections -ffunction-sections
+CFLAGS = -Os -g -Wall -std=c99 -msoft-float -mno-string -mno-multiple -mno-vsx -mno-altivec -mlittle-endian -fno-stack-protector -mstrict-align -ffreestanding -fdata-sections -ffunction-sections -I../include
 ASFLAGS = $(CFLAGS)
 LDFLAGS = -T powerpc.lds
 
index 40692441daa2cf4060a4e9e5c0ec97d0949a0188..6c1c31198c52a0220c0e2c138da45086b95f6bd9 100644 (file)
@@ -2,6 +2,10 @@
 #include <stdbool.h>
 
 #include "console.h"
+#include "microwatt_soc.h"
+#include "io.h"
+
+#define UART_FREQ 115200
 
 /*
  * Core UART functions to implement for a port
 
 static uint64_t potato_uart_base;
 
-#define PROC_FREQ 100000000
-#define UART_FREQ 115200
-#define UART_BASE 0xc0002000
-
-#define POTATO_CONSOLE_TX              0x00
-#define POTATO_CONSOLE_RX              0x08
-#define POTATO_CONSOLE_STATUS          0x10
-#define   POTATO_CONSOLE_STATUS_RX_EMPTY               0x01
-#define   POTATO_CONSOLE_STATUS_TX_EMPTY               0x02
-#define   POTATO_CONSOLE_STATUS_RX_FULL                        0x04
-#define   POTATO_CONSOLE_STATUS_TX_FULL                        0x08
-#define POTATO_CONSOLE_CLOCK_DIV       0x18
-#define POTATO_CONSOLE_IRQ_EN          0x20
-
 static uint64_t potato_uart_reg_read(int offset)
 {
-       uint64_t val;
-
-       __asm__ volatile("ldcix %0,%1,%2" : "=r" (val) : "b" (potato_uart_base), "r" (offset));
-
-       return val;
+       return readq(potato_uart_base + offset);
 }
 
 static void potato_uart_reg_write(int offset, uint64_t val)
 {
-       __asm__ volatile("stdcix %0,%1,%2" : : "r" (val), "b" (potato_uart_base), "r" (offset));
+       writeq(val, potato_uart_base + offset);
 }
 
 static int potato_uart_rx_empty(void)
@@ -86,9 +72,12 @@ static unsigned long potato_uart_divisor(unsigned long proc_freq, unsigned long
 
 void potato_uart_init(void)
 {
+       uint64_t proc_freq;
+
        potato_uart_base = UART_BASE;
+       proc_freq = readq(SYSCON_BASE + SYS_REG_CLKINFO);
 
-       potato_uart_reg_write(POTATO_CONSOLE_CLOCK_DIV, potato_uart_divisor(PROC_FREQ, UART_FREQ));
+       potato_uart_reg_write(POTATO_CONSOLE_CLOCK_DIV, potato_uart_divisor(proc_freq, UART_FREQ));
 }
 
 void potato_uart_irq_en(void)
index 73bc181a46073d0bccc3f5eb37f54f36447de921..ae4c4a8311b39e5cdef455ff1672da7b2cac9c4b 100755 (executable)
Binary files a/hello_world/hello_world.bin and b/hello_world/hello_world.bin differ
index 02a362d1b126d4379cac2550c5e30050b8e5f506..e65843824b7b7ff33f700d011187a7108c0d84e7 100755 (executable)
Binary files a/hello_world/hello_world.elf and b/hello_world/hello_world.elf differ
index 633e218d369e552e9af2614f7aed3709b00e354f..609824771198dc139c8dd1501986228bad54bd5e 100644 (file)
@@ -515,53 +515,72 @@ e8010010ebc1fff0
 3c4000014e800020
 7c0802a63842a000
 3fe2fffffbe1fff8
-f80100103bff71a8
+f80100103bff7240
 48000051f821ffd1
 7fe3fb7860000000
-6000000048000139
+60000000480001d5
 7fe3fb787c641b78
-60000000480000e1
-6000000048000065
-480000955463063e
+600000004800017d
+60000000480000ed
+480001295463063e
 4bffffec60000000
 0100000000000000
 3c40000100000180
 3d20c0003842a000
 6129200060000000
-7929002039000018
-3940001af9228000
-4e8000207d4947ea
+f922800079290020
+612900203d20c000
+7c0004ac79290020
+3d40001c7d204eea
+7d295392614a2000
+394a0018e9428000
+7c0004ac3929ffff
+4e8000207d2057ea
 0000000000000000
 3c40000100000000
 600000003842a000
-39000010e9228000
-794707e17d4946ea
-386000084082fff8
-5463063e7c691eea
-000000004e800020
-0000000000000000
-3842a0003c400001
-e942800060000000
-7d2a46ea39000010
-4082fff87927efe3
-7c6a4fea39200000
-000000004e800020
-0000000000000000
-3842a0003c400001
-fbc1fff07c0802a6
-3884fffffbe1fff8
-7fe322143bc3ffff
-f821ffd1f8010010
-419e00107fbef840
-4bffff9d8c7e0001
-382100304bfffff0
-000000004bfffe98
-0000028001000000
-7d4348ae39200000
-419e000c2f8a0000
-4bfffff039290001
-4e8000207d234b78
+394000ffe9228000
+7c0004ac39290020
+4e8000207d404fea
+0000000000000000
+3c40000100000000
+600000003842a000
+39400000e9228000
+7c0004ac39290020
+4e8000207d404fea
+0000000000000000
+3c40000100000000
+600000003842a000
+39290010e9228000
+7d204eea7c0004ac
+4082ffe871290001
+38630008e8628000
+7c601eea7c0004ac
+4e8000205463063e
 0000000000000000
+3c40000100000000
+600000003842a000
+39290010e9228000
+7d204eea7c0004ac
+4082ffe871290008
+7c0004ace9228000
+4e8000207c604fea
+0000000000000000
+3c40000100000000
+7c0802a63842a000
+fbe1fff8fbc1fff0
+7c7f1b787fc32214
+f821ffd1f8010010
+409e000c7fbff040
+4bfffe0c38210030
+3bff0001887f0000
+4bffffe44bffff8d
+0100000000000000
+3920000000000280
+2f8a00007d4348ae
+7d234b78409e000c
+392900014e800020
+000000004bffffe8
 0000000000000000
 6f57206f6c6c6548
 0000000a0d646c72
index fdbb18b3d82d25767f612fb4fa823262f88e2cb0..607b533d00c634219c6cf4ed54c80b658b51f4ea 100644 (file)
@@ -9,7 +9,7 @@ CC = $(CROSS_COMPILE)gcc
 LD = $(CROSS_COMPILE)ld
 OBJCOPY = $(CROSS_COMPILE)objcopy
 
-CFLAGS = -Os -g -Wall -std=c99 -msoft-float -mno-string -mno-multiple -mno-vsx -mno-altivec -mlittle-endian -fno-stack-protector -mstrict-align -ffreestanding -fdata-sections -ffunction-sections
+CFLAGS = -Os -g -Wall -std=c99 -msoft-float -mno-string -mno-multiple -mno-vsx -mno-altivec -mlittle-endian -fno-stack-protector -mstrict-align -ffreestanding -fdata-sections -ffunction-sections -I../include
 ASFLAGS = $(CFLAGS)
 LDFLAGS = -T powerpc.lds
 
index 250135d7b01e6fa73ad4efea69f7dccd0a655830..9241e3f06af4998d77f33a8b0a73df98fadbcaea 100644 (file)
@@ -9,7 +9,7 @@ CC = $(CROSS_COMPILE)gcc
 LD = $(CROSS_COMPILE)ld
 OBJCOPY = $(CROSS_COMPILE)objcopy
 
-CFLAGS = -Os -g -Wall -std=c99 -msoft-float -mno-string -mno-multiple -mno-vsx -mno-altivec -mlittle-endian -fno-stack-protector -mstrict-align -ffreestanding -fdata-sections -ffunction-sections -I ../../hello_world
+CFLAGS = -Os -g -Wall -std=c99 -msoft-float -mno-string -mno-multiple -mno-vsx -mno-altivec -mlittle-endian -fno-stack-protector -mstrict-align -ffreestanding -fdata-sections -ffunction-sections -I ../../hello_world -I ../../include
 ASFLAGS = $(CFLAGS)
 LDFLAGS = -T powerpc.lds