mirror of
https://source.denx.de/u-boot/u-boot.git
synced 2026-06-13 15:03:58 +03:00
Merge branch '2019-12-02-master-imports'
- A large series of clean-ups to reduce common.h contents
This commit is contained in:
@@ -59,6 +59,16 @@ int dm_bootcount_set(struct udevice *dev, u32 bootcount);
|
||||
|
||||
#endif
|
||||
|
||||
/** bootcount_store() - store the current bootcount */
|
||||
void bootcount_store(ulong);
|
||||
|
||||
/**
|
||||
* bootcount_load() - load the current bootcount
|
||||
*
|
||||
* @return bootcount, read from the appropriate location
|
||||
*/
|
||||
ulong bootcount_load(void);
|
||||
|
||||
#if defined(CONFIG_SPL_BOOTCOUNT_LIMIT) || defined(CONFIG_BOOTCOUNT_LIMIT)
|
||||
|
||||
#if !defined(CONFIG_SYS_BOOTCOUNT_LE) && !defined(CONFIG_SYS_BOOTCOUNT_BE)
|
||||
@@ -127,10 +137,6 @@ static inline void bootcount_inc(void)
|
||||
#endif /* !CONFIG_SPL_BUILD */
|
||||
}
|
||||
|
||||
#if defined(CONFIG_SPL_BUILD) && !defined(CONFIG_SPL_BOOTCOUNT_LIMIT)
|
||||
void bootcount_store(ulong a) {};
|
||||
ulong bootcount_load(void) { return 0; }
|
||||
#endif /* CONFIG_SPL_BUILD && !CONFIG_SPL_BOOTCOUNT_LIMIT */
|
||||
#else
|
||||
static inline int bootcount_error(void) { return 0; }
|
||||
static inline void bootcount_inc(void) {}
|
||||
|
||||
@@ -199,6 +199,22 @@ void fixup_cmdtable(cmd_tbl_t *cmdtp, int size);
|
||||
* @return 0 if OK, 1 for error
|
||||
*/
|
||||
int board_run_command(const char *cmdline);
|
||||
|
||||
int run_command(const char *cmd, int flag);
|
||||
int run_command_repeatable(const char *cmd, int flag);
|
||||
|
||||
/**
|
||||
* Run a list of commands separated by ; or even \0
|
||||
*
|
||||
* Note that if 'len' is not -1, then the command does not need to be nul
|
||||
* terminated, Memory will be allocated for the command in that case.
|
||||
*
|
||||
* @param cmd List of commands to run, each separated bu semicolon
|
||||
* @param len Length of commands excluding terminator if known (-1 if not)
|
||||
* @param flag Execution flags (CMD_FLAG_...)
|
||||
* @return 0 on success, or != 0 on error.
|
||||
*/
|
||||
int run_command_list(const char *cmd, int len, int flag);
|
||||
#endif /* __ASSEMBLY__ */
|
||||
|
||||
/*
|
||||
|
||||
212
include/common.h
212
include/common.h
@@ -3,8 +3,8 @@
|
||||
* Common header file for U-Boot
|
||||
*
|
||||
* This file still includes quite a bit of stuff that should be in separate
|
||||
* headers like command.h, cpu.h and timer.h. Please think before adding more
|
||||
* things. Patches to remove things are welcome.
|
||||
* headers. Please think before adding more things.
|
||||
* Patches to remove things are welcome.
|
||||
*
|
||||
* (C) Copyright 2000-2009
|
||||
* Wolfgang Denk, DENX Software Engineering, wd@denx.de.
|
||||
@@ -46,8 +46,6 @@ typedef volatile unsigned char vu_char;
|
||||
|
||||
#include <log.h>
|
||||
|
||||
typedef void (interrupt_handler_t)(void *);
|
||||
|
||||
#include <asm/u-boot.h> /* boot information for Linux kernel */
|
||||
#include <asm/global_data.h> /* global data used for startup functions */
|
||||
|
||||
@@ -64,27 +62,10 @@ typedef void (interrupt_handler_t)(void *);
|
||||
*/
|
||||
void hang (void) __attribute__ ((noreturn));
|
||||
|
||||
int cpu_init(void);
|
||||
|
||||
#include <display_options.h>
|
||||
|
||||
/* common/main.c */
|
||||
void main_loop (void);
|
||||
int run_command(const char *cmd, int flag);
|
||||
int run_command_repeatable(const char *cmd, int flag);
|
||||
|
||||
/**
|
||||
* Run a list of commands separated by ; or even \0
|
||||
*
|
||||
* Note that if 'len' is not -1, then the command does not need to be nul
|
||||
* terminated, Memory will be allocated for the command in that case.
|
||||
*
|
||||
* @param cmd List of commands to run, each separated bu semicolon
|
||||
* @param len Length of commands excluding terminator if known (-1 if not)
|
||||
* @param flag Execution flags (CMD_FLAG_...)
|
||||
* @return 0 on success, or != 0 on error.
|
||||
*/
|
||||
int run_command_list(const char *cmd, int len, int flag);
|
||||
|
||||
int checkflash(void);
|
||||
int checkdram(void);
|
||||
@@ -92,26 +73,6 @@ extern u8 __dtb_dt_begin[]; /* embedded device tree blob */
|
||||
extern u8 __dtb_dt_spl_begin[]; /* embedded device tree blob for SPL/TPL */
|
||||
int mdm_init(void);
|
||||
|
||||
/**
|
||||
* Show the DRAM size in a board-specific way
|
||||
*
|
||||
* This is used by boards to display DRAM information in their own way.
|
||||
*
|
||||
* @param size Size of DRAM (which should be displayed along with other info)
|
||||
*/
|
||||
void board_show_dram(phys_size_t size);
|
||||
|
||||
/**
|
||||
* Get the uppermost pointer that is valid to access
|
||||
*
|
||||
* Some systems may not map all of their address space. This function allows
|
||||
* boards to indicate what their highest support pointer value is for DRAM
|
||||
* access.
|
||||
*
|
||||
* @param total_size Size of U-Boot (unused?)
|
||||
*/
|
||||
ulong board_get_usable_ram_top(ulong total_size);
|
||||
|
||||
/**
|
||||
* arch_fixup_fdt() - Write arch-specific information to fdt
|
||||
*
|
||||
@@ -141,8 +102,6 @@ int do_fat_fsload(cmd_tbl_t *, int, int, char * const []);
|
||||
/* common/cmd_ext2.c */
|
||||
int do_ext2load(cmd_tbl_t *, int, int, char * const []);
|
||||
|
||||
void pci_init_board(void);
|
||||
|
||||
/* common/exports.c */
|
||||
void jumptable_init(void);
|
||||
|
||||
@@ -157,77 +116,22 @@ phys_size_t get_effective_memsize(void);
|
||||
void reset_phy (void);
|
||||
void fdc_hw_init (void);
|
||||
|
||||
/* $(BOARD)/eeprom.c */
|
||||
#ifdef CONFIG_CMD_EEPROM
|
||||
void eeprom_init (int bus);
|
||||
int eeprom_read (unsigned dev_addr, unsigned offset, uchar *buffer, unsigned cnt);
|
||||
int eeprom_write (unsigned dev_addr, unsigned offset, uchar *buffer, unsigned cnt);
|
||||
#else
|
||||
/*
|
||||
* Some EEPROM code is depecated because it used the legacy I2C interface. Add
|
||||
* some macros here so we don't have to touch every one of those uses
|
||||
*/
|
||||
#define eeprom_init(bus)
|
||||
#define eeprom_read(dev_addr, offset, buffer, cnt) ((void)-ENOSYS)
|
||||
#define eeprom_write(dev_addr, offset, buffer, cnt) ((void)-ENOSYS)
|
||||
#endif
|
||||
|
||||
#if !defined(CONFIG_ENV_EEPROM_IS_ON_I2C) && defined(CONFIG_SYS_I2C_EEPROM_ADDR)
|
||||
# define CONFIG_SYS_DEF_EEPROM_ADDR CONFIG_SYS_I2C_EEPROM_ADDR
|
||||
#endif
|
||||
|
||||
/* $(BOARD)/$(BOARD).c */
|
||||
int board_early_init_f (void);
|
||||
int board_fix_fdt (void *rw_fdt_blob); /* manipulate the U-Boot fdt before its relocation */
|
||||
int board_late_init (void);
|
||||
int board_postclk_init (void); /* after clocks/timebase, before env/serial */
|
||||
int board_early_init_r (void);
|
||||
|
||||
#if defined(CONFIG_SYS_DRAM_TEST)
|
||||
int testdram(void);
|
||||
#endif /* CONFIG_SYS_DRAM_TEST */
|
||||
|
||||
/* $(CPU)/start.S */
|
||||
int icache_status (void);
|
||||
void icache_enable (void);
|
||||
void icache_disable(void);
|
||||
int dcache_status (void);
|
||||
void dcache_enable (void);
|
||||
void dcache_disable(void);
|
||||
void mmu_disable(void);
|
||||
#if defined(CONFIG_ARM)
|
||||
void relocate_code(ulong);
|
||||
#else
|
||||
void relocate_code(ulong, gd_t *, ulong) __attribute__ ((noreturn));
|
||||
#endif
|
||||
ulong get_endaddr (void);
|
||||
void trap_init (ulong);
|
||||
|
||||
/* $(CPU)/cpu.c */
|
||||
static inline int cpumask_next(int cpu, unsigned int mask)
|
||||
{
|
||||
for (cpu++; !((1 << cpu) & mask); cpu++)
|
||||
;
|
||||
|
||||
return cpu;
|
||||
}
|
||||
|
||||
#define for_each_cpu(iter, cpu, num_cpus, mask) \
|
||||
for (iter = 0, cpu = cpumask_next(-1, mask); \
|
||||
iter < num_cpus; \
|
||||
iter++, cpu = cpumask_next(cpu, mask)) \
|
||||
|
||||
int cpu_numcores (void);
|
||||
int cpu_num_dspcores(void);
|
||||
u32 cpu_mask (void);
|
||||
u32 cpu_dsp_mask(void);
|
||||
int is_core_valid (unsigned int);
|
||||
|
||||
void s_init(void);
|
||||
|
||||
int checkcpu (void);
|
||||
int checkicache (void);
|
||||
int checkdcache (void);
|
||||
void upmconfig (unsigned int, unsigned int *, unsigned int);
|
||||
ulong get_tbclk (void);
|
||||
void reset_misc (void);
|
||||
@@ -235,134 +139,22 @@ void reset_cpu (ulong addr);
|
||||
void ft_cpu_setup(void *blob, bd_t *bd);
|
||||
void ft_pci_setup(void *blob, bd_t *bd);
|
||||
|
||||
void smp_set_core_boot_addr(unsigned long addr, int corenr);
|
||||
void smp_kick_all_cpus(void);
|
||||
|
||||
/* $(CPU)/serial.c */
|
||||
int serial_init (void);
|
||||
void serial_setbrg (void);
|
||||
void serial_putc (const char);
|
||||
void serial_putc_raw(const char);
|
||||
void serial_puts (const char *);
|
||||
int serial_getc (void);
|
||||
int serial_tstc (void);
|
||||
|
||||
/* $(CPU)/speed.c */
|
||||
int get_clocks (void);
|
||||
ulong get_bus_freq (ulong);
|
||||
int get_serial_clock(void);
|
||||
|
||||
/* $(CPU)/interrupts.c */
|
||||
int interrupt_init (void);
|
||||
void timer_interrupt (struct pt_regs *);
|
||||
void external_interrupt (struct pt_regs *);
|
||||
void irq_install_handler(int, interrupt_handler_t *, void *);
|
||||
void irq_free_handler (int);
|
||||
void reset_timer (void);
|
||||
|
||||
/* Return value of monotonic microsecond timer */
|
||||
unsigned long timer_get_us(void);
|
||||
|
||||
void enable_interrupts (void);
|
||||
int disable_interrupts (void);
|
||||
|
||||
/* $(CPU)/.../commproc.c */
|
||||
void bootcount_store (ulong);
|
||||
ulong bootcount_load (void);
|
||||
|
||||
/* $(CPU)/.../<eth> */
|
||||
void mii_init (void);
|
||||
|
||||
/* arch/$(ARCH)/lib/cache.c */
|
||||
void enable_caches(void);
|
||||
void flush_cache (unsigned long, unsigned long);
|
||||
void flush_dcache_all(void);
|
||||
void flush_dcache_range(unsigned long start, unsigned long stop);
|
||||
void invalidate_dcache_range(unsigned long start, unsigned long stop);
|
||||
void invalidate_dcache_all(void);
|
||||
void invalidate_icache_all(void);
|
||||
|
||||
enum {
|
||||
/* Disable caches (else flush caches but leave them active) */
|
||||
CBL_DISABLE_CACHES = 1 << 0,
|
||||
CBL_SHOW_BOOTSTAGE_REPORT = 1 << 1,
|
||||
|
||||
CBL_ALL = 3,
|
||||
};
|
||||
|
||||
/**
|
||||
* Clean up ready for linux
|
||||
*
|
||||
* @param flags Flags to control what is done
|
||||
*/
|
||||
int cleanup_before_linux_select(int flags);
|
||||
|
||||
/* arch/$(ARCH)/lib/ticks.S */
|
||||
uint64_t get_ticks(void);
|
||||
void wait_ticks (unsigned long);
|
||||
|
||||
/* arch/$(ARCH)/lib/time.c */
|
||||
ulong usec2ticks (unsigned long usec);
|
||||
ulong ticks2usec (unsigned long ticks);
|
||||
|
||||
/* lib/lz4_wrapper.c */
|
||||
int ulz4fn(const void *src, size_t srcn, void *dst, size_t *dstn);
|
||||
|
||||
/* lib/qsort.c */
|
||||
void qsort(void *base, size_t nmemb, size_t size,
|
||||
int(*compar)(const void *, const void *));
|
||||
int strcmp_compar(const void *, const void *);
|
||||
|
||||
/* lib/uuid.c */
|
||||
#include <uuid.h>
|
||||
|
||||
/* lib/vsprintf.c */
|
||||
#include <vsprintf.h>
|
||||
|
||||
/* lib/strmhz.c */
|
||||
char * strmhz(char *buf, unsigned long hz);
|
||||
|
||||
/* lib/crc32.c */
|
||||
#include <u-boot/crc.h>
|
||||
|
||||
/* lib/rand.c */
|
||||
#define RAND_MAX -1U
|
||||
void srand(unsigned int seed);
|
||||
unsigned int rand(void);
|
||||
unsigned int rand_r(unsigned int *seedp);
|
||||
|
||||
/*
|
||||
* STDIO based functions (can always be used)
|
||||
*/
|
||||
/* serial stuff */
|
||||
int serial_printf (const char *fmt, ...)
|
||||
__attribute__ ((format (__printf__, 1, 2)));
|
||||
|
||||
/* lib/net_utils.c */
|
||||
#include <net.h>
|
||||
static inline struct in_addr env_get_ip(char *var)
|
||||
{
|
||||
return string_to_ip(env_get(var));
|
||||
}
|
||||
|
||||
#ifdef CONFIG_LED_STATUS
|
||||
# include <status_led.h>
|
||||
#endif
|
||||
|
||||
#include <bootstage.h>
|
||||
|
||||
#ifdef CONFIG_SHOW_ACTIVITY
|
||||
void show_activity(int arg);
|
||||
#endif
|
||||
|
||||
/* Multicore arch functions */
|
||||
#ifdef CONFIG_MP
|
||||
int cpu_status(u32 nr);
|
||||
int cpu_reset(u32 nr);
|
||||
int cpu_disable(u32 nr);
|
||||
int cpu_release(u32 nr, int argc, char * const argv[]);
|
||||
#endif
|
||||
|
||||
#else /* __ASSEMBLY__ */
|
||||
|
||||
#endif /* __ASSEMBLY__ */
|
||||
|
||||
87
include/cpu_func.h
Normal file
87
include/cpu_func.h
Normal file
@@ -0,0 +1,87 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0+ */
|
||||
/*
|
||||
* (C) Copyright 2000-2009
|
||||
* Wolfgang Denk, DENX Software Engineering, wd@denx.de.
|
||||
* Copyright 2019 Google LLC
|
||||
*/
|
||||
|
||||
#ifndef __CPU_LEGACY_H
|
||||
#define __CPU_LEGACY_H
|
||||
|
||||
#include <linux/types.h>
|
||||
|
||||
/*
|
||||
* Multicore arch functions
|
||||
*
|
||||
* These should be moved to use the CPU uclass.
|
||||
*/
|
||||
int cpu_status(u32 nr);
|
||||
int cpu_reset(u32 nr);
|
||||
int cpu_disable(u32 nr);
|
||||
int cpu_release(u32 nr, int argc, char * const argv[]);
|
||||
|
||||
static inline int cpumask_next(int cpu, unsigned int mask)
|
||||
{
|
||||
for (cpu++; !((1 << cpu) & mask); cpu++)
|
||||
;
|
||||
|
||||
return cpu;
|
||||
}
|
||||
|
||||
#define for_each_cpu(iter, cpu, num_cpus, mask) \
|
||||
for (iter = 0, cpu = cpumask_next(-1, mask); \
|
||||
iter < num_cpus; \
|
||||
iter++, cpu = cpumask_next(cpu, mask)) \
|
||||
|
||||
int cpu_numcores(void);
|
||||
int cpu_num_dspcores(void);
|
||||
u32 cpu_mask(void);
|
||||
u32 cpu_dsp_mask(void);
|
||||
int is_core_valid(unsigned int core);
|
||||
|
||||
/**
|
||||
* checkcpu() - perform an early check of the CPU
|
||||
*
|
||||
* This is used on PowerPC, SH and X86 machines as a CPU init mechanism. It is
|
||||
* called during the pre-relocation init sequence in board_init_f().
|
||||
*
|
||||
* @return 0 if oK, -ve on error
|
||||
*/
|
||||
int checkcpu(void);
|
||||
|
||||
void smp_set_core_boot_addr(unsigned long addr, int corenr);
|
||||
void smp_kick_all_cpus(void);
|
||||
|
||||
int icache_status(void);
|
||||
void icache_enable(void);
|
||||
void icache_disable(void);
|
||||
int dcache_status(void);
|
||||
void dcache_enable(void);
|
||||
void dcache_disable(void);
|
||||
void mmu_disable(void);
|
||||
|
||||
/* arch/$(ARCH)/lib/cache.c */
|
||||
void enable_caches(void);
|
||||
void flush_cache(unsigned long addr, unsigned long size);
|
||||
void flush_dcache_all(void);
|
||||
void flush_dcache_range(unsigned long start, unsigned long stop);
|
||||
void invalidate_dcache_range(unsigned long start, unsigned long stop);
|
||||
void invalidate_dcache_all(void);
|
||||
void invalidate_icache_all(void);
|
||||
|
||||
enum {
|
||||
/* Disable caches (else flush caches but leave them active) */
|
||||
CBL_DISABLE_CACHES = 1 << 0,
|
||||
CBL_SHOW_BOOTSTAGE_REPORT = 1 << 1,
|
||||
|
||||
CBL_ALL = 3,
|
||||
};
|
||||
|
||||
/**
|
||||
* Clean up ready for linux
|
||||
*
|
||||
* @param flags Flags to control what is done
|
||||
*/
|
||||
int cleanup_before_linux_select(int flags);
|
||||
;
|
||||
#endif
|
||||
24
include/eeprom.h
Normal file
24
include/eeprom.h
Normal file
@@ -0,0 +1,24 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0+ */
|
||||
/*
|
||||
* (C) Copyright 2000-2009
|
||||
* Wolfgang Denk, DENX Software Engineering, wd@denx.de.
|
||||
*/
|
||||
|
||||
#ifndef __EEPROM_LEGACY_H
|
||||
#define __EEPROM_LEGACY_H
|
||||
|
||||
#ifdef CONFIG_CMD_EEPROM
|
||||
void eeprom_init(int bus);
|
||||
int eeprom_read(uint dev_addr, uint offset, uchar *buffer, uint cnt);
|
||||
int eeprom_write(uint dev_addr, uint offset, uchar *buffer, uint cnt);
|
||||
#else
|
||||
/*
|
||||
* Some EEPROM code is depecated because it used the legacy I2C interface. Add
|
||||
* some macros here so we don't have to touch every one of those uses
|
||||
*/
|
||||
#define eeprom_init(bus)
|
||||
#define eeprom_read(dev_addr, offset, buffer, cnt) ((void)-ENOSYS)
|
||||
#define eeprom_write(dev_addr, offset, buffer, cnt) ((void)-ENOSYS)
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -1,12 +1,16 @@
|
||||
#ifndef __EXPORTS_H__
|
||||
#define __EXPORTS_H__
|
||||
|
||||
#include <irq_func.h>
|
||||
|
||||
#ifndef __ASSEMBLY__
|
||||
#ifdef CONFIG_PHY_AQUANTIA
|
||||
#include <env.h>
|
||||
#include <phy_interface.h>
|
||||
#endif
|
||||
|
||||
#include <irq_func.h>
|
||||
|
||||
struct spi_slave;
|
||||
|
||||
/* These are declarations of exported functions available in C code */
|
||||
|
||||
@@ -10,6 +10,8 @@
|
||||
#ifndef __INIT_H_
|
||||
#define __INIT_H_ 1
|
||||
|
||||
#include <linux/types.h>
|
||||
|
||||
#ifndef __ASSEMBLY__ /* put C only stuff in this section */
|
||||
|
||||
/*
|
||||
@@ -149,6 +151,8 @@ ulong board_init_f_alloc_reserve(ulong top);
|
||||
*/
|
||||
void board_init_f_init_reserve(ulong base);
|
||||
|
||||
struct global_data;
|
||||
|
||||
/**
|
||||
* arch_setup_gd() - Set up the global_data pointer
|
||||
* @gd_ptr: Pointer to global data
|
||||
@@ -160,10 +164,11 @@ void board_init_f_init_reserve(ulong base);
|
||||
*
|
||||
* gd = gd_ptr;
|
||||
*/
|
||||
void arch_setup_gd(gd_t *gd_ptr);
|
||||
void arch_setup_gd(struct global_data *gd_ptr);
|
||||
|
||||
/* common/board_r.c */
|
||||
void board_init_r(gd_t *id, ulong dest_addr) __attribute__ ((noreturn));
|
||||
void board_init_r(struct global_data *id, ulong dest_addr)
|
||||
__attribute__ ((noreturn));
|
||||
|
||||
int cpu_init_r(void);
|
||||
int last_stage_init(void);
|
||||
@@ -181,6 +186,30 @@ int init_func_vid(void);
|
||||
int checkboard(void);
|
||||
int show_board_info(void);
|
||||
|
||||
/**
|
||||
* Get the uppermost pointer that is valid to access
|
||||
*
|
||||
* Some systems may not map all of their address space. This function allows
|
||||
* boards to indicate what their highest support pointer value is for DRAM
|
||||
* access.
|
||||
*
|
||||
* @param total_size Size of U-Boot (unused?)
|
||||
*/
|
||||
ulong board_get_usable_ram_top(ulong total_size);
|
||||
|
||||
int board_early_init_f(void);
|
||||
|
||||
/* manipulate the U-Boot fdt before its relocation */
|
||||
int board_fix_fdt(void *rw_fdt_blob);
|
||||
int board_late_init(void);
|
||||
int board_postclk_init(void); /* after clocks/timebase, before env/serial */
|
||||
int board_early_init_r(void);
|
||||
|
||||
/* TODO(sjg@chromium.org): Drop this when DM_PCI migration is completed */
|
||||
void pci_init_board(void);
|
||||
|
||||
void trap_init(unsigned long reloc_addr);
|
||||
|
||||
#endif /* __ASSEMBLY__ */
|
||||
/* Put only stuff here that the assembler can digest */
|
||||
|
||||
|
||||
26
include/irq_func.h
Normal file
26
include/irq_func.h
Normal file
@@ -0,0 +1,26 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0+ */
|
||||
/*
|
||||
* Header file for interrupt functions
|
||||
*
|
||||
* (C) Copyright 2000-2009
|
||||
* Wolfgang Denk, DENX Software Engineering, wd@denx.de.
|
||||
*/
|
||||
|
||||
#ifndef __IRQ_FUNC_H
|
||||
#define __IRQ_FUNC_H
|
||||
|
||||
struct pt_regs;
|
||||
|
||||
typedef void (interrupt_handler_t)(void *arg);
|
||||
|
||||
int interrupt_init(void);
|
||||
void timer_interrupt(struct pt_regs *regs);
|
||||
void external_interrupt(struct pt_regs *regs);
|
||||
void irq_install_handler(int vec, interrupt_handler_t *handler, void *arg);
|
||||
void irq_free_handler(int vec);
|
||||
void reset_timer(void);
|
||||
|
||||
void enable_interrupts(void);
|
||||
int disable_interrupts(void);
|
||||
|
||||
#endif
|
||||
@@ -1,23 +0,0 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0+ */
|
||||
/*
|
||||
* Copyright (c) 2013 Google, Inc
|
||||
*/
|
||||
|
||||
|
||||
#ifndef __linux_crc8_h
|
||||
#define __linux_crc8_h
|
||||
|
||||
/**
|
||||
* crc8() - Calculate and return CRC-8 of the data
|
||||
*
|
||||
* This uses an x^8 + x^2 + x + 1 polynomial. A table-based algorithm would
|
||||
* be faster, but for only a few bytes it isn't worth the code size
|
||||
*
|
||||
* @crc_start: CRC8 start value
|
||||
* @vptr: Buffer to checksum
|
||||
* @len: Length of buffer in bytes
|
||||
* @return CRC8 checksum
|
||||
*/
|
||||
unsigned int crc8(unsigned int crc_start, const unsigned char *vptr, int len);
|
||||
|
||||
#endif
|
||||
@@ -225,4 +225,6 @@ static inline u8 mii_resolve_flowctrl_fdx(u16 lcladv, u16 rmtadv)
|
||||
return cap;
|
||||
}
|
||||
|
||||
void mii_init(void);
|
||||
|
||||
#endif /* __LINUX_MII_H__ */
|
||||
|
||||
24
include/lz4.h
Normal file
24
include/lz4.h
Normal file
@@ -0,0 +1,24 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0+ */
|
||||
/*
|
||||
* Copyright 2019 Google LLC
|
||||
*/
|
||||
|
||||
#ifndef __LZ4_H
|
||||
#define __LZ4_H
|
||||
|
||||
/**
|
||||
* ulz4fn() - Decompress LZ4 data
|
||||
*
|
||||
* @src: Source data to decompress
|
||||
* @srcn: Length of source data
|
||||
* @dst: Destination for uncompressed data
|
||||
* @dstn: Returns length of uncompressed data
|
||||
* @return 0 if OK, -EPROTONOSUPPORT if the magic number or version number are
|
||||
* not recognised or independent blocks are used, -EINVAL if the reserved
|
||||
* fields are non-zero, or input is overrun, -EENOBUFS if the destination
|
||||
* buffer is overrun, -EEPROTO if the compressed data causes an error in
|
||||
* the decompression algorithm
|
||||
*/
|
||||
int ulz4fn(const void *src, size_t srcn, void *dst, size_t *dstn);
|
||||
|
||||
#endif
|
||||
@@ -16,6 +16,7 @@
|
||||
#include <asm/byteorder.h> /* for nton* / ntoh* stuff */
|
||||
#include <env.h>
|
||||
#include <linux/if_ether.h>
|
||||
#include <rand.h>
|
||||
|
||||
#define DEBUG_LL_STATE 0 /* Link local state machine changes */
|
||||
#define DEBUG_DEV_PKT 0 /* Packets or info directed to the device */
|
||||
@@ -828,7 +829,13 @@ static inline void net_random_ethaddr(uchar *addr)
|
||||
/* Convert an IP address to a string */
|
||||
void ip_to_string(struct in_addr x, char *s);
|
||||
|
||||
/* Convert a string to ip address */
|
||||
/**
|
||||
* string_to_ip() - Convert a string to ip address
|
||||
*
|
||||
* @s: String to conver, in the format format a.b.c.d, where each value is a
|
||||
* decimal number from 0 to 255
|
||||
* @return IP address, or 0 if invalid
|
||||
*/
|
||||
struct in_addr string_to_ip(const char *s);
|
||||
|
||||
/* Convert a VLAN id to a string */
|
||||
@@ -886,4 +893,17 @@ int update_tftp(ulong addr, char *interface, char *devstring);
|
||||
*/
|
||||
void eth_parse_enetaddr(const char *addr, uint8_t *enetaddr);
|
||||
|
||||
/**
|
||||
* env_get_ip() - Convert an environment value to to an ip address
|
||||
*
|
||||
* @var: Environment variable to convert. The value of this variable must be
|
||||
* in the format format a.b.c.d, where each value is a decimal number from
|
||||
* 0 to 255
|
||||
* @return IP address, or 0 if invalid
|
||||
*/
|
||||
static inline struct in_addr env_get_ip(char *var)
|
||||
{
|
||||
return string_to_ip(env_get(var));
|
||||
}
|
||||
|
||||
#endif /* __NET_H__ */
|
||||
|
||||
40
include/rand.h
Normal file
40
include/rand.h
Normal file
@@ -0,0 +1,40 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0+ */
|
||||
/*
|
||||
* (C) Copyright 2000-2009
|
||||
* Wolfgang Denk, DENX Software Engineering, wd@denx.de.
|
||||
*/
|
||||
|
||||
#ifndef __RAND_H
|
||||
#define __RAND_H
|
||||
|
||||
#define RAND_MAX -1U
|
||||
|
||||
/**
|
||||
* srand() - Set the random-number seed value
|
||||
*
|
||||
* This can be used to restart the pseudo-random-number sequence from a known
|
||||
* point. This affects future calls to rand() to start from that point
|
||||
*
|
||||
* @seed: New seed
|
||||
*/
|
||||
void srand(unsigned int seed);
|
||||
|
||||
/**
|
||||
* rand() - Get a 32-bit pseudo-random number
|
||||
*
|
||||
* @returns next random number in the sequence
|
||||
*/
|
||||
unsigned int rand(void);
|
||||
|
||||
/**
|
||||
* rand_r() - Get a 32-bit pseudo-random number
|
||||
*
|
||||
* This version of the function allows multiple sequences to be used at the
|
||||
* same time, since it requires the caller to store the seed value.
|
||||
*
|
||||
* @seed value to use, updated on exit
|
||||
* @returns next random number in the sequence
|
||||
*/
|
||||
unsigned int rand_r(unsigned int *seedp);
|
||||
|
||||
#endif
|
||||
@@ -50,18 +50,20 @@ extern void serial_reinit_all(void);
|
||||
/* For usbtty */
|
||||
#ifdef CONFIG_USB_TTY
|
||||
|
||||
extern int usbtty_getc(void);
|
||||
extern void usbtty_putc(const char c);
|
||||
extern void usbtty_puts(const char *str);
|
||||
extern int usbtty_tstc(void);
|
||||
struct stdio_dev;
|
||||
|
||||
int usbtty_getc(struct stdio_dev *dev);
|
||||
void usbtty_putc(struct stdio_dev *dev, const char c);
|
||||
void usbtty_puts(struct stdio_dev *dev, const char *str);
|
||||
int usbtty_tstc(struct stdio_dev *dev);
|
||||
|
||||
#else
|
||||
|
||||
/* stubs */
|
||||
#define usbtty_getc() 0
|
||||
#define usbtty_putc(a)
|
||||
#define usbtty_puts(a)
|
||||
#define usbtty_tstc() 0
|
||||
#define usbtty_getc(dev) 0
|
||||
#define usbtty_putc(dev, a)
|
||||
#define usbtty_puts(dev, a)
|
||||
#define usbtty_tstc(dev) 0
|
||||
|
||||
#endif /* CONFIG_USB_TTY */
|
||||
|
||||
@@ -322,4 +324,23 @@ void pl01x_serial_initialize(void);
|
||||
void pxa_serial_initialize(void);
|
||||
void sh_serial_initialize(void);
|
||||
|
||||
/**
|
||||
* serial_printf() - Write a formatted string to the serial console
|
||||
*
|
||||
* The total size of the output must be less than CONFIG_SYS_PBSIZE.
|
||||
*
|
||||
* @fmt: Printf format string, followed by format arguments
|
||||
* @return number of characters written
|
||||
*/
|
||||
int serial_printf(const char *fmt, ...)
|
||||
__attribute__ ((format (__printf__, 1, 2)));
|
||||
|
||||
int serial_init(void);
|
||||
void serial_setbrg(void);
|
||||
void serial_putc(const char ch);
|
||||
void serial_putc_raw(const char ch);
|
||||
void serial_puts(const char *str);
|
||||
int serial_getc(void);
|
||||
int serial_tstc(void);
|
||||
|
||||
#endif
|
||||
|
||||
34
include/sort.h
Normal file
34
include/sort.h
Normal file
@@ -0,0 +1,34 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0+ */
|
||||
/*
|
||||
* Copyright 2019 Google LLC
|
||||
*/
|
||||
|
||||
#ifndef __SORT_H
|
||||
#define __SORT_H
|
||||
|
||||
/**
|
||||
* qsort() - Use the quicksort algorithm to sort some values
|
||||
*
|
||||
* @base: Base address of array to sort
|
||||
* @nmemb: Number of members to sort
|
||||
* @size: Size of each member in bytes
|
||||
* @compar: Comparison function which should return:
|
||||
* < 0 if element at s1 < element at s2,
|
||||
* 0 if element at s1 == element at s2,
|
||||
* > 0 if element at s1 > element at s2,
|
||||
*/
|
||||
void qsort(void *base, size_t nmemb, size_t size,
|
||||
int (*compar)(const void *s1, const void *s2));
|
||||
|
||||
/**
|
||||
* strcmp_compar() - compar function for string arrays
|
||||
*
|
||||
* This can be passed to qsort when a string array is being sorted
|
||||
*
|
||||
* @s1: First string to compare
|
||||
* @s2: Second string to compare
|
||||
* @return comparison value (less than, equal to, or greater than 0)
|
||||
*/
|
||||
int strcmp_compar(const void *s1, const void *s2);
|
||||
|
||||
#endif
|
||||
@@ -36,8 +36,8 @@
|
||||
#endif /* CONFIG_LED_STATUS5 */
|
||||
|
||||
void status_led_init(void);
|
||||
void status_led_tick (unsigned long timestamp);
|
||||
void status_led_set (int led, int state);
|
||||
void status_led_tick(unsigned long timestamp);
|
||||
void status_led_set(int led, int state);
|
||||
|
||||
/***** MVS v1 **********************************************************/
|
||||
#if (defined(CONFIG_MVS) && CONFIG_MVS < 2)
|
||||
|
||||
@@ -70,4 +70,47 @@ uint64_t usec_to_tick(unsigned long usec);
|
||||
(time_after_eq(a,b) && \
|
||||
time_before(a,c))
|
||||
|
||||
/**
|
||||
* usec2ticks() - Convert microseconds to internal ticks
|
||||
*
|
||||
* @usec: Value of microseconds to convert
|
||||
* @return Corresponding internal ticks value, calculated using get_tbclk()
|
||||
*/
|
||||
ulong usec2ticks(unsigned long usec);
|
||||
|
||||
/**
|
||||
* ticks2usec() - Convert internal ticks to microseconds
|
||||
*
|
||||
* @ticks: Value of ticks to convert
|
||||
* @return Corresponding microseconds value, calculated using get_tbclk()
|
||||
*/
|
||||
ulong ticks2usec(unsigned long ticks);
|
||||
|
||||
/**
|
||||
* wait_ticks() - waits a given number of ticks
|
||||
*
|
||||
* This is an internal function typically used to implement udelay() and
|
||||
* similar. Normally you should use udelay() or mdelay() instead.
|
||||
*
|
||||
* @ticks: Number of ticks to wait
|
||||
*/
|
||||
void wait_ticks(unsigned long ticks);
|
||||
|
||||
/**
|
||||
* timer_get_us() - Get monotonic microsecond timer
|
||||
*
|
||||
* @return value of monotonic microsecond timer
|
||||
*/
|
||||
unsigned long timer_get_us(void);
|
||||
|
||||
/**
|
||||
* get_ticks() - Get the current tick value
|
||||
*
|
||||
* This is an internal value used by the timer on the system. Ticks increase
|
||||
* monotonically at the rate given by get_tbclk().
|
||||
*
|
||||
* @return current tick value
|
||||
*/
|
||||
uint64_t get_ticks(void);
|
||||
|
||||
#endif /* _TIME_H */
|
||||
|
||||
@@ -8,7 +8,19 @@
|
||||
#ifndef _UBOOT_CRC_H
|
||||
#define _UBOOT_CRC_H
|
||||
|
||||
/* lib/crc8.c */
|
||||
/**
|
||||
* crc8() - Calculate and return CRC-8 of the data
|
||||
*
|
||||
* This uses an x^8 + x^2 + x + 1 polynomial. A table-based algorithm would
|
||||
* be faster, but for only a few bytes it isn't worth the code size
|
||||
*
|
||||
* lib/crc8.c
|
||||
*
|
||||
* @crc_start: CRC8 start value
|
||||
* @vptr: Buffer to checksum
|
||||
* @len: Length of buffer in bytes
|
||||
* @return CRC8 checksum
|
||||
*/
|
||||
unsigned int crc8(unsigned int crc_start, const unsigned char *vptr, int len);
|
||||
|
||||
/* lib/crc16.c - 16 bit CRC with polynomial x^16+x^12+x^5+1 (CRC-CCITT) */
|
||||
@@ -26,9 +38,47 @@ void crc16_ccitt_wd_buf(const uint8_t *in, uint len,
|
||||
uint8_t *out, uint chunk_sz);
|
||||
|
||||
/* lib/crc32.c */
|
||||
uint32_t crc32 (uint32_t, const unsigned char *, uint);
|
||||
uint32_t crc32_wd (uint32_t, const unsigned char *, uint, uint);
|
||||
uint32_t crc32_no_comp (uint32_t, const unsigned char *, uint);
|
||||
|
||||
/**
|
||||
* crc32 - Calculate the CRC32 for a block of data
|
||||
*
|
||||
* @crc: Input crc to chain from a previous calculution (use 0 to start a new
|
||||
* calculation)
|
||||
* @buf: Bytes to checksum
|
||||
* @len: Number of bytes to checksum
|
||||
* @return checksum value
|
||||
*/
|
||||
uint32_t crc32(uint32_t crc, const unsigned char *buf, uint len);
|
||||
|
||||
/**
|
||||
* crc32_wd - Calculate the CRC32 for a block of data (watchdog version)
|
||||
*
|
||||
* This checksums the data @chunk_sz bytes at a time, calling WATCHDOG_RESET()
|
||||
* after each chunk, to prevent the watchdog from firing.
|
||||
*
|
||||
* @crc: Input crc to chain from a previous calculution (use 0 to start a new
|
||||
* calculation)
|
||||
* @buf: Bytes to checksum
|
||||
* @len: Number of bytes to checksum
|
||||
* @chunk_sz: Chunk size to use between watchdog resets
|
||||
* @return checksum
|
||||
*/
|
||||
uint32_t crc32_wd(uint32_t crc, const unsigned char *buf, uint len,
|
||||
uint chunk_sz);
|
||||
|
||||
/**
|
||||
* crc32_no_comp - Calculate the CRC32 for a block of data (no one's compliment)
|
||||
*
|
||||
* This version uses a different algorithm which doesn't use one's compliment.
|
||||
* JFFS2 (and other things?) use this.
|
||||
*
|
||||
* @crc: Input crc to chain from a previous calculution (use 0 to start a new
|
||||
* calculation)
|
||||
* @buf: Bytes to checksum
|
||||
* @len: Number of bytes to checksum
|
||||
* @return checksum value
|
||||
*/
|
||||
uint32_t crc32_no_comp(uint32_t crc, const unsigned char *buf, uint len);
|
||||
|
||||
/**
|
||||
* crc32_wd_buf - Perform CRC32 on a buffer and return result in buffer
|
||||
@@ -38,11 +88,34 @@ uint32_t crc32_no_comp (uint32_t, const unsigned char *, uint);
|
||||
* @output: Place to put checksum result (4 bytes)
|
||||
* @chunk_sz: Trigger watchdog after processing this many bytes
|
||||
*/
|
||||
void crc32_wd_buf(const unsigned char *input, uint ilen,
|
||||
unsigned char *output, uint chunk_sz);
|
||||
void crc32_wd_buf(const uint8_t *input, uint ilen, uint8_t *output,
|
||||
uint chunk_sz);
|
||||
|
||||
/* lib/crc32c.c */
|
||||
void crc32c_init(uint32_t *, uint32_t);
|
||||
uint32_t crc32c_cal(uint32_t, const char *, int, uint32_t *);
|
||||
|
||||
/**
|
||||
* crc32c_init() - Set up a the CRC32 table
|
||||
*
|
||||
* This sets up 256-item table to aid in CRC32 calculation
|
||||
*
|
||||
* @crc32c_table: Place to put table
|
||||
* @pol: polynomial to use
|
||||
*/
|
||||
void crc32c_init(uint32_t *crc32c_table, uint32_t pol);
|
||||
|
||||
/**
|
||||
* crc32c_cal() - Perform CRC32 on a buffer given a table
|
||||
*
|
||||
* This algorithm uses the table (set up by crc32c_init() to speed up
|
||||
* processing.
|
||||
*
|
||||
* @crc: Previous crc (use 0 at start)
|
||||
* @data: Data bytes to checksum
|
||||
* @length: Number of bytes to process
|
||||
* @crc32c_table:: CRC table
|
||||
* @return checksum value
|
||||
*/
|
||||
uint32_t crc32c_cal(uint32_t crc, const char *data, int length,
|
||||
uint32_t *crc32c_table);
|
||||
|
||||
#endif /* _UBOOT_CRC_H */
|
||||
|
||||
@@ -212,4 +212,14 @@ void print_grouped_ull(unsigned long long int_val, int digits);
|
||||
|
||||
bool str2off(const char *p, loff_t *num);
|
||||
bool str2long(const char *p, ulong *num);
|
||||
|
||||
/**
|
||||
* strmhz() - Convert a value to a Hz string
|
||||
*
|
||||
* This creates a string indicating the number of MHz of a value. For example,
|
||||
* 2700000 produces "2.7".
|
||||
* @buf: Buffer to hold output string, which must be large enough
|
||||
* @hz: Value to convert
|
||||
*/
|
||||
char *strmhz(char *buf, unsigned long hz);
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user