Skip to content

Commit b2533e3

Browse files
committed
system_init: e310 updated
Signed-off-by: Conke Hu <conke.hu@maxwit.com>
1 parent 9e42369 commit b2533e3

File tree

11 files changed

+51
-24
lines changed

11 files changed

+51
-24
lines changed

arch/arm/Makefile

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1 @@
11
obj-y = head.o cpuid.o
2-
3-
PHONY += head.S

arch/arm/head.S

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,11 @@ handle_reset:
4242
#endif
4343

4444
bl system_init
45+
cmp r0, #0
46+
bne hang
4547

4648
bl main
49+
4750
b hang
4851

4952
#if 1

arch/risc-v/cpuid.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
unsigned long read_cpu_id(void)
22
{
3-
return 0;
3+
extern unsigned long __stack_base;
4+
5+
return __stack_base;
46
}

arch/risc-v/head.S

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,14 @@
22
.globl _start
33

44
_start:
5-
li a0, 0x10012000
5+
lw sp, stack_base
66

7-
lw a1, 8(a0)
8-
ori a1, a1, 1 << 5
9-
sw a1, 8(a0)
7+
call system_init
108

11-
lw a1, 0xc(a0)
12-
ori a1, a1, 1 << 5
13-
sw a1, 0xc(a0)
14-
15-
li sp, 0x80010000
169
call main
17-
j hang
1810

1911
hang:
2012
j hang
13+
14+
stack_base:
15+
.word __stack_base

board/e310/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
obj-y = gpio.o
1+
obj-y = led.o

board/e310/gpio.c

Whitespace-only changes.

board/e310/led.c

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#include <types.h>
2+
#include <init.h>
3+
4+
// TODO: move to reg.h
5+
#define E310_GPIO_BASE 0x10012000
6+
7+
struct e310_gpio {
8+
__u32 input_val;
9+
__u32 input_en;
10+
__u32 output_en;
11+
__u32 output_val;
12+
};
13+
14+
static int __init redv_led_on()
15+
{
16+
volatile struct e310_gpio *gpio = (struct e310_gpio *)E310_GPIO_BASE;
17+
18+
gpio->output_en |= 1 << CONFIG_GPIO_LED;
19+
gpio->output_val |= 1 << CONFIG_GPIO_LED;
20+
21+
return 0;
22+
}
23+
24+
arch_init(redv_led_on);

build/configs/armvirt_defconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ CONFIG_PLAT = armvirt
55
CONFIG_ARCH_VER = armv6k
66

77
CONFIG_DEBUG = y
8+
CONFIG_VERBOSE = y
89

910
CONFIG_UART = y
1011
CONFIG_ARMVIRT_UART = y

build/configs/e310_defconfig

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ CONFIG_ARCH = risc-v
22
CONFIG_ARCH_VER = rv32imac
33
CONFIG_PLAT = e310
44

5+
CONFIG_GPIO_LED = 5
6+
57
CONFIG_DEFAULT_LOADER = LM_NAND
68

79
CONFIG_DEBUG = y

core/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,5 @@ obj-y = init.o
33
obj-$(CONFIG_NAND) += nand_loader.o
44
obj-$(CONFIG_KERMIT) += kermit_loader.o
55
obj-$(CONFIG_YMODEM) += ymodem_loader.o
6+
7+
PHONY += init.c

lib/stdio.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@
22

33
#define BUF_LEN 32 // FIXME
44

5-
// __WEAK__ void __io_putchar(char ch)
6-
// {
7-
// #ifdef CONFIG_UART
8-
// uart_send_byte(ch);
9-
// // if ('\n' == ch)
10-
// // uart_send_byte('\r');
11-
// // else if ('\r' == ch)
12-
// // uart_send_byte('\n');
13-
// #endif
14-
// }
5+
__WEAK__ void __io_putchar(char ch)
6+
{
7+
#ifdef CONFIG_UART
8+
uart_send_byte(ch);
9+
// if ('\n' == ch)
10+
// uart_send_byte('\r');
11+
// else if ('\r' == ch)
12+
// uart_send_byte('\n');
13+
#endif
14+
}
1515

1616
static const char *int_to_hex_str(__u32 val, char str[])
1717
{

0 commit comments

Comments
 (0)