Skip to contentSkip to conversation

common: move startup function prototypes in init.h

PATCH New Patrick Delaunay 2 participants 11 messages Mar 13, 2018 – Mar 18, 2018 x86

lore
Share & tools
lore
#0 lore raw

v2 cover common: move startup function prototypes in init.h

I push this serie after Masahiro Yamada's comment on patch "common: add a prototype for mach_cpu_init()"

The serie depends on v3 of this patch for the added file init.h

I just moved the function used in:
common/board_f.c
common/init/board_init.c
common/board_r.c
common/board_info.c
and solve the checkpatch issue.

It is a step for common.h cleanup and I don't add
documentation for the moved functions.

I don't know if other functions need to be moved:
$(BOARD)/$(BOARD).c ?
$(CPU)/start.S ?

or if the order of the new file init.h is correct.

Changes in v2:
- solve compilation error: add weak for arch_reserve_stacks in board_f.c as it is no more present in init.h

Patrick Delaunay (5):
common: move board_f.c prototypes in init.h
common: move board_init.c prototypes in init.h
common: move board_r.c prototypes in init.h
common: move board_info.c prototypes in init.h
common: move init_helpers.h prototypes in init.h

 arch/x86/lib/spl.c     |   1 -
 common/board_f.c       |   3 +-
 common/board_r.c       |   1 -
 include/common.h       | 128 +++---------------------------------------------
 include/init.h         | 129 +++++++++++++++++++++++++++++++++++++++++++++++++
 include/init_helpers.h |  18 -------
 6 files changed, 136 insertions(+), 144 deletions(-)
 delete mode 100644 include/init_helpers.h
Signature · 1 line
2.7.4
#1 lore raw

PATCH v2 1/5 common: move board_f.c prototypes in init.h

Move prototypes for function used in common/board_f.c from common.h to init.h
Remove weak for arch_reserve_stacks in prototype (checkpatch issue)

---

Changes in v2:
- solve compilation error: add weak for arch_reserve_stacks in board_f.c as it is no more present in init.h

 common/board_f.c |  2 +-
 include/common.h | 70 +++-----------------------------------------------------
 include/init.h   | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 70 insertions(+), 68 deletions(-)
common/board_f.c +1 -1
index c6bc53e..4df52f1 100644
@@ -489,7 +489,7 @@ static int reserve_bootstage(void)
 	return 0;
 }
 
-int arch_reserve_stacks(void)
+__weak int arch_reserve_stacks(void)
 {
 	return 0;
 }
include/common.h +3 -67

113 lines not on this page · raw message

include/init.h +66 -0

84 lines not on this page · raw message

Signature · 1 line
2.7.4
#2 lore raw

PATCH v2 1/5 common: move board_f.c prototypes in init.h

Quoted 6 lines · Patrick Delaunay

Move prototypes for function used in common/board_f.c from common.h to init.h
Remove weak for arch_reserve_stacks in prototype (checkpatch issue)

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180318/32708ae9/attachment.sig>
#3 lore raw

PATCH v2 2/5 common: move board_init.c prototypes in init.h

In reply to Patrick Delaunay

Move function prototypes for common/init/board_init.c from common.h to init.h

---

Changes in v2: None

 include/common.h | 38 +-------------------------------------
 include/init.h   | 39 +++++++++++++++++++++++++++++++++++++++
 2 files changed, 40 insertions(+), 37 deletions(-)
include/common.h +1 -37
index 6176195..62630db 100644
@@ -64,6 +64,7 @@ typedef void (interrupt_handler_t)(void *);
 
 /* startup functions, used in:
  * common/board_f.c
+ * common/init/board_init.c
  */
 #include <init.h>
 
@@ -97,48 +98,11 @@ int run_command_list(const char *cmd, int len, int flag);
 /* arch/$(ARCH)/lib/board.c */
 void board_init_r(gd_t *, ulong) __attribute__ ((noreturn));
 
-/**
- * ulong board_init_f_alloc_reserve - allocate reserved area
- *
- * This function is called by each architecture very early in the start-up
- * code to allow the C runtime to reserve space on the stack for writable
- * 'globals' such as GD and the malloc arena.
- *
- * @top:	top of the reserve area, growing down.
- * @return:	bottom of reserved area
- */
-ulong board_init_f_alloc_reserve(ulong top);
-
-/**
- * board_init_f_init_reserve - initialize the reserved area(s)
- *
- * This function is called once the C runtime has allocated the reserved
- * area on the stack. It must initialize the GD at the base of that area.
- *
- * @base:	top from which reservation was done
- */
-void board_init_f_init_reserve(ulong base);
-
-/**
- * arch_setup_gd() - Set up the global_data pointer
- *
- * This pointer is special in some architectures and cannot easily be assigned
- * to. For example on x86 it is implemented by adding a specific record to its
- * Global Descriptor Table! So we we provide a function to carry out this task.
- * For most architectures this can simply be:
- *
- *    gd = gd_ptr;
- *
- * @gd_ptr:	Pointer to global data
- */
-void arch_setup_gd(gd_t *gd_ptr);
-
 int checkboard(void);
 int show_board_info(void);
 int checkflash(void);
 int checkdram(void);
 int last_stage_init(void);
-extern ulong monitor_flash_len;
 int mac_read_from_eeprom(void);
 extern u8 __dtb_dt_begin[];	/* embedded device tree blob */
 extern u8 __dtb_dt_spl_begin[];	/* embedded device tree blob for SPL/TPL */
include/init.h +39 -0
index f57a438..f952602 100644
@@ -109,6 +109,45 @@ int misc_init_f(void);
 int embedded_dtb_select(void);
 #endif
 
+/* common/init/board_init.c */
+extern ulong monitor_flash_len;
+
+/**
+ * ulong board_init_f_alloc_reserve - allocate reserved area
+ *
+ * This function is called by each architecture very early in the start-up
+ * code to allow the C runtime to reserve space on the stack for writable
+ * 'globals' such as GD and the malloc arena.
+ *
+ * @top:	top of the reserve area, growing down.
+ * @return:	bottom of reserved area
+ */
+ulong board_init_f_alloc_reserve(ulong top);
+
+/**
+ * board_init_f_init_reserve - initialize the reserved area(s)
+ *
+ * This function is called once the C runtime has allocated the reserved
+ * area on the stack. It must initialize the GD at the base of that area.
+ *
+ * @base:	top from which reservation was done
+ */
+void board_init_f_init_reserve(ulong base);
+
+/**
+ * arch_setup_gd() - Set up the global_data pointer
+ *
+ * This pointer is special in some architectures and cannot easily be assigned
+ * to. For example on x86 it is implemented by adding a specific record to its
+ * Global Descriptor Table! So we we provide a function to carry out this task.
+ * For most architectures this can simply be:
+ *
+ *    gd = gd_ptr;
+ *
+ * @gd_ptr:	Pointer to global data
+ */
+void arch_setup_gd(gd_t *gd_ptr);
+
 /* common/board_r.c */
 
 #endif	/* __ASSEMBLY__ */
Signature · 1 line
2.7.4
#4 lore raw

PATCH v2 2/5 common: move board_init.c prototypes in init.h

Quoted 4 lines · Patrick Delaunay

Move function prototypes for common/init/board_init.c from common.h to init.h

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180318/e1cff25d/attachment.sig>
#5 lore raw

PATCH v2 3/5 common: move board_r.c prototypes in init.h

In reply to Patrick Delaunay

Move function prototypes used in common/board_r.c
from common.h to init.h

---

Changes in v2: None

 include/common.h | 17 +----------------
 include/init.h   | 14 ++++++++++++++
 2 files changed, 15 insertions(+), 16 deletions(-)
include/common.h +1 -16
index 62630db..7d181da 100644
@@ -65,6 +65,7 @@ typedef void (interrupt_handler_t)(void *);
 /* startup functions, used in:
  * common/board_f.c
  * common/init/board_init.c
+ * common/board_r.c
  */
 #include <init.h>
 
@@ -95,21 +96,13 @@ int run_command_repeatable(const char *cmd, int flag);
  */
 int run_command_list(const char *cmd, int len, int flag);
 
-/* arch/$(ARCH)/lib/board.c */
-void board_init_r(gd_t *, ulong) __attribute__ ((noreturn));
-
 int checkboard(void);
 int show_board_info(void);
 int checkflash(void);
 int checkdram(void);
-int last_stage_init(void);
-int mac_read_from_eeprom(void);
 extern u8 __dtb_dt_begin[];	/* embedded device tree blob */
 extern u8 __dtb_dt_spl_begin[];	/* embedded device tree blob for SPL/TPL */
-int set_cpu_clk_info(void);
 int mdm_init(void);
-int update_flash_size(int flash_size);
-int arch_early_init_r(void);
 
 /*
  * setup_board_extra() - Fill in extra details in the bd_t structure
@@ -263,14 +256,8 @@ int env_complete(char *var, int maxv, char *cmdv[], int maxsz, char *buf);
 #endif
 int get_env_id (void);
 
-void	pci_init      (void);
 void	pci_init_board(void);
 
-int	misc_init_r   (void);
-#if defined(CONFIG_VID)
-int	init_func_vid(void);
-#endif
-
 /* common/exports.c */
 void	jumptable_init(void);
 
@@ -396,8 +383,6 @@ int	get_clocks (void);
 ulong	get_bus_freq  (ulong);
 int get_serial_clock(void);
 
-int	cpu_init_r    (void);
-
 /* $(CPU)/interrupts.c */
 int	interrupt_init	   (void);
 void	timer_interrupt	   (struct pt_regs *);
include/init.h +14 -0
index f952602..89e48f2 100644
@@ -149,6 +149,20 @@ void board_init_f_init_reserve(ulong base);
 void arch_setup_gd(gd_t *gd_ptr);
 
 /* common/board_r.c */
+void board_init_r(gd_t *id, ulong dest_addr) __attribute__ ((noreturn));
+
+int cpu_init_r(void);
+int last_stage_init(void);
+int mac_read_from_eeprom(void);
+int set_cpu_clk_info(void);
+int update_flash_size(int flash_size);
+int arch_early_init_r(void);
+void pci_init(void);
+int misc_init_r(void);
+#if defined(CONFIG_VID)
+int init_func_vid(void);
+#endif
+
 
 #endif	/* __ASSEMBLY__ */
 /* Put only stuff here that the assembler can digest */
Signature · 1 line
2.7.4
#6 lore raw

PATCH v2 3/5 common: move board_r.c prototypes in init.h

Quoted 4 lines · Patrick Delaunay

Move function prototypes used in common/board_r.c
from common.h to init.h

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180318/d896a21a/attachment.sig>
#7 lore raw

PATCH v2 4/5 common: move board_info.c prototypes in init.h

In reply to Patrick Delaunay

Move function prototype for common/init/board_init.c from common.h to init.h

---

Changes in v2: None

 include/common.h | 3 +--
 include/init.h   | 3 +++
 2 files changed, 4 insertions(+), 2 deletions(-)
include/common.h +1 -2
index 7d181da..a0633f3 100644
@@ -66,6 +66,7 @@ typedef void (interrupt_handler_t)(void *);
  * common/board_f.c
  * common/init/board_init.c
  * common/board_r.c
+ * common/board_info.c
  */
 #include <init.h>
 
@@ -96,8 +97,6 @@ int run_command_repeatable(const char *cmd, int flag);
  */
 int run_command_list(const char *cmd, int len, int flag);
 
-int checkboard(void);
-int show_board_info(void);
 int checkflash(void);
 int checkdram(void);
 extern u8 __dtb_dt_begin[];	/* embedded device tree blob */
include/init.h +3 -0
index 89e48f2..d54d519 100644
@@ -163,6 +163,9 @@ int misc_init_r(void);
 int init_func_vid(void);
 #endif
 
+/* common/board_info.c */
+int checkboard(void);
+int show_board_info(void);
 
 #endif	/* __ASSEMBLY__ */
 /* Put only stuff here that the assembler can digest */
Signature · 1 line
2.7.4
#8 lore raw

PATCH v2 4/5 common: move board_info.c prototypes in init.h

Quoted 4 lines · Patrick Delaunay

Move function prototype for common/init/board_init.c from common.h to init.h

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180318/6b958db1/attachment.sig>
#9 lore raw

PATCH v2 5/5 common: move init_helpers.h prototypes in init.h

In reply to Patrick Delaunay

Merge init_helpers.h in the new file init.h
with only prototypes for init_cache_f_r
used in common/board_f.c

---
modification introduced after Tom Rimi review of V1

Changes in v2: None

 arch/x86/lib/spl.c     |  1 -
 common/board_f.c       |  1 -
 common/board_r.c       |  1 -
 include/init.h         |  7 +++++++
 include/init_helpers.h | 18 ------------------
 5 files changed, 7 insertions(+), 21 deletions(-)
 delete mode 100644 include/init_helpers.h
arch/x86/lib/spl.c +0 -1
index 832a5d7..7c32245 100644
@@ -6,7 +6,6 @@
 
 #include <common.h>
 #include <debug_uart.h>
-#include <init_helpers.h>
 #include <spl.h>
 #include <asm/cpu.h>
 #include <asm/mtrr.h>
common/board_f.c +0 -1
index 4df52f1..62588c5 100644
@@ -18,7 +18,6 @@
 #include <fs.h>
 #include <i2c.h>
 #include <initcall.h>
-#include <init_helpers.h>
 #include <malloc.h>
 #include <mapmem.h>
 #include <os.h>
common/board_r.c +0 -1
index 482f506..89f2e16 100644
@@ -23,7 +23,6 @@
 #include <fdtdec.h>
 #include <ide.h>
 #include <initcall.h>
-#include <init_helpers.h>
 #ifdef CONFIG_PS2KBD
 #include <keyboard.h>
 #endif
include/init.h +7 -0
index d54d519..147ae6b 100644
@@ -101,6 +101,13 @@ int dram_init_banksize(void);
  */
 int arch_reserve_stacks(void);
 
+/**
+ * init_cache_f_r() - Turn on the cache in preparation for relocation
+ *
+ * @return 0 if OK, -ve on error
+ */
+int init_cache_f_r(void);
+
 int print_cpuinfo(void);
 int timer_init(void);
 int reserve_mmu(void);
include/init_helpers.h deleted +0 -18
deleted file mode 100644
index 3efcfdd..0000000
@@ -1,18 +0,0 @@
-/*
- * (C) Copyright 2011
- * Graeme Russ, <[email protected]>
- *
- * SPDX-License-Identifier:	GPL-2.0+
- */
-
-#ifndef _INIT_HELPERS_H_
-#define _INIT_HELPERS_H_
-
-/**
- * init_cache_f_r() - Turn on the cache in preparation for relocation
- *
- * @return 0 if OK, -ve on error
- */
-int init_cache_f_r(void);
-
-#endif	/* _INIT_HELPERS_H_ */
Signature · 1 line
2.7.4
#10 lore raw

PATCH v2 5/5 common: move init_helpers.h prototypes in init.h

Quoted 5 lines · Patrick Delaunay

Merge init_helpers.h in the new file init.h
with only prototypes for init_cache_f_r
used in common/board_f.c

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180318/527d8b23/attachment.sig>