diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/clock_legacy.h | 14 | ||||
-rw-r--r-- | include/common.h | 149 | ||||
-rw-r--r-- | include/compiler.h | 4 | ||||
-rw-r--r-- | include/cpu_func.h | 2 | ||||
-rw-r--r-- | include/eeprom.h | 4 | ||||
-rw-r--r-- | include/exports.h | 3 | ||||
-rw-r--r-- | include/fdt_support.h | 14 | ||||
-rw-r--r-- | include/fdtdec.h | 3 | ||||
-rw-r--r-- | include/flash.h | 7 | ||||
-rw-r--r-- | include/fs.h | 22 | ||||
-rw-r--r-- | include/hang.h | 22 | ||||
-rw-r--r-- | include/image.h | 91 | ||||
-rw-r--r-- | include/init.h | 29 | ||||
-rw-r--r-- | include/linux/kernel.h | 13 | ||||
-rw-r--r-- | include/linux/types.h | 4 | ||||
-rw-r--r-- | include/net.h | 19 | ||||
-rw-r--r-- | include/ns87308.h | 233 | ||||
-rw-r--r-- | include/time.h | 2 | ||||
-rw-r--r-- | include/u-boot/aes.h | 44 | ||||
-rw-r--r-- | include/uboot_aes.h | 39 |
20 files changed, 325 insertions, 393 deletions
diff --git a/include/clock_legacy.h b/include/clock_legacy.h new file mode 100644 index 00000000000..b0a8333ea6e --- /dev/null +++ b/include/clock_legacy.h @@ -0,0 +1,14 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * (C) Copyright 2000-2009 + * Wolfgang Denk, DENX Software Engineering, wd@denx.de. + */ + +#ifndef __CLOCK_LEGACY_H +#define __CLOCK_LEGACY_H + +int get_clocks(void); +unsigned long get_bus_freq(unsigned long dummy); +int get_serial_clock(void); + +#endif diff --git a/include/common.h b/include/common.h index 52c02185f40..0ef8505fc79 100644 --- a/include/common.h +++ b/include/common.h @@ -2,9 +2,8 @@ /* * Common header file for U-Boot * - * This file still includes quite a bit of stuff that should be in separate - * headers. Please think before adding more things. - * Patches to remove things are welcome. + * This file still includes quite a few headers that should be included + * individually as needed. Patches to remove things are welcome. * * (C) Copyright 2000-2009 * Wolfgang Denk, DENX Software Engineering, wd@denx.de. @@ -14,11 +13,6 @@ #define __COMMON_H_ 1 #ifndef __ASSEMBLY__ /* put C only stuff in this section */ - -typedef volatile unsigned long vu_long; -typedef volatile unsigned short vu_short; -typedef volatile unsigned char vu_char; - #include <config.h> #include <errno.h> #include <time.h> @@ -34,159 +28,20 @@ typedef volatile unsigned char vu_char; #include <stdarg.h> #include <stdio.h> #include <linux/kernel.h> - #include <part.h> #include <flash.h> #include <image.h> - -#ifdef __LP64__ -#define CONFIG_SYS_SUPPORT_64BIT_DATA -#endif - #include <log.h> - #include <asm/u-boot.h> /* boot information for Linux kernel */ #include <asm/global_data.h> /* global data used for startup functions */ - -/* startup functions, used in: - * common/board_f.c - * common/init/board_init.c - * common/board_r.c - * common/board_info.c - */ #include <init.h> - -/* - * Function Prototypes - */ -void hang (void) __attribute__ ((noreturn)); - #include <display_options.h> - -/* common/main.c */ -void main_loop (void); - -int checkflash(void); -int checkdram(void); -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); - -/** - * arch_fixup_fdt() - Write arch-specific information to fdt - * - * Defined in arch/$(ARCH)/lib/bootm-fdt.c - * - * @blob: FDT blob to write to - * @return 0 if ok, or -ve FDT_ERR_... on failure - */ -int arch_fixup_fdt(void *blob); - -/* common/flash.c */ -void flash_perror (int); - -/* common/cmd_source.c */ -int source (ulong addr, const char *fit_uname); - -extern ulong load_addr; /* Default Load Address */ -extern ulong save_addr; /* Default Save Address */ -extern ulong save_size; /* Default Save Size */ - -/* common/cmd_net.c */ -int do_tftpb(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]); - -/* common/cmd_fat.c */ -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 []); - -/* common/exports.c */ -void jumptable_init(void); - -/* common/kallsysm.c */ -const char *symbol_lookup(unsigned long addr, unsigned long *caddr); - -/* common/memsize.c */ -long get_ram_size (long *, long); -phys_size_t get_effective_memsize(void); - -/* $(BOARD)/$(BOARD).c */ -void reset_phy (void); -void fdc_hw_init (void); - -#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 - -#if defined(CONFIG_SYS_DRAM_TEST) -int testdram(void); -#endif /* CONFIG_SYS_DRAM_TEST */ - -#if defined(CONFIG_ARM) -void relocate_code(ulong); -#else -void relocate_code(ulong, gd_t *, ulong) __attribute__ ((noreturn)); -#endif - -void s_init(void); - -void upmconfig (unsigned int, unsigned int *, unsigned int); -ulong get_tbclk (void); -void reset_misc (void); -void reset_cpu (ulong addr); -void ft_cpu_setup(void *blob, bd_t *bd); -void ft_pci_setup(void *blob, bd_t *bd); - -/* $(CPU)/speed.c */ -int get_clocks (void); -ulong get_bus_freq (ulong); -int get_serial_clock(void); - -/* lib/uuid.c */ #include <uuid.h> - -/* lib/vsprintf.c */ #include <vsprintf.h> - -/* lib/net_utils.c */ #include <net.h> - #include <bootstage.h> - -#else /* __ASSEMBLY__ */ - #endif /* __ASSEMBLY__ */ -/* Put only stuff here that the assembler can digest */ - -#ifdef CONFIG_POST -#define CONFIG_HAS_POST -#ifndef CONFIG_POST_ALT_LIST -#define CONFIG_POST_STD_LIST -#endif -#endif - -#define ROUND(a,b) (((a) + (b) - 1) & ~((b) - 1)) - -/* - * check_member() - Check the offset of a structure member - * - * @structure: Name of structure (e.g. global_data) - * @member: Name of member (e.g. baudrate) - * @offset: Expected offset in bytes - */ -#define check_member(structure, member, offset) _Static_assert( \ - offsetof(struct structure, member) == offset, \ - "`struct " #structure "` offset for `" #member "` is not " #offset) - -/* Avoid using CONFIG_EFI_STUB directly as we may boot from other loaders */ -#ifdef CONFIG_EFI_STUB -#define ll_boot_init() false -#else -#define ll_boot_init() true -#endif - /* Pull in stuff for the build system */ #ifdef DO_DEPS_ONLY # include <env_internal.h> diff --git a/include/compiler.h b/include/compiler.h index 90372f239c0..ed74c272b8c 100644 --- a/include/compiler.h +++ b/include/compiler.h @@ -144,4 +144,8 @@ typedef unsigned long int uintptr_t; #define likely(x) __builtin_expect(!!(x), 1) #define unlikely(x) __builtin_expect(!!(x), 0) +#ifdef __LP64__ +#define MEM_SUPPORT_64BIT_DATA +#endif + #endif diff --git a/include/cpu_func.h b/include/cpu_func.h index 46f3d92459b..f701f02bfef 100644 --- a/include/cpu_func.h +++ b/include/cpu_func.h @@ -83,5 +83,7 @@ enum { * @param flags Flags to control what is done */ int cleanup_before_linux_select(int flags); + +void reset_cpu(ulong addr); ; #endif diff --git a/include/eeprom.h b/include/eeprom.h index 61eb826a734..79118eb83de 100644 --- a/include/eeprom.h +++ b/include/eeprom.h @@ -21,4 +21,8 @@ int eeprom_write(uint dev_addr, uint offset, uchar *buffer, uint cnt); #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 + #endif diff --git a/include/exports.h b/include/exports.h index 35f463287fb..cbd16fc5185 100644 --- a/include/exports.h +++ b/include/exports.h @@ -13,6 +13,9 @@ struct spi_slave; +/* Set up the jump table for use by the API */ +void jumptable_init(void); + /* These are declarations of exported functions available in C code */ unsigned long get_version(void); int getc(void); diff --git a/include/fdt_support.h b/include/fdt_support.h index 3f4bc643d44..ba14acd7f62 100644 --- a/include/fdt_support.h +++ b/include/fdt_support.h @@ -12,6 +12,20 @@ #include <asm/u-boot.h> #include <linux/libfdt.h> +/** + * arch_fixup_fdt() - Write arch-specific information to fdt + * + * Defined in arch/$(ARCH)/lib/bootm-fdt.c + * + * @blob: FDT blob to write to + * @return 0 if ok, or -ve FDT_ERR_... on failure + */ +int arch_fixup_fdt(void *blob); + +void ft_cpu_setup(void *blob, bd_t *bd); + +void ft_pci_setup(void *blob, bd_t *bd); + u32 fdt_getprop_u32_default_node(const void *fdt, int off, int cell, const char *prop, const u32 dflt); u32 fdt_getprop_u32_default(const void *fdt, const char *path, diff --git a/include/fdtdec.h b/include/fdtdec.h index 696e0fd024d..c8a143db5f1 100644 --- a/include/fdtdec.h +++ b/include/fdtdec.h @@ -111,6 +111,9 @@ struct fdt_pci_addr { u32 phys_lo; }; +extern u8 __dtb_dt_begin[]; /* embedded device tree blob */ +extern u8 __dtb_dt_spl_begin[]; /* embedded device tree blob for SPL/TPL */ + /** * Compute the size of a resource. * diff --git a/include/flash.h b/include/flash.h index 807800b524e..2655c72087f 100644 --- a/include/flash.h +++ b/include/flash.h @@ -117,6 +117,13 @@ extern int jedec_flash_match(flash_info_t *info, ulong base); #define CFI_CMDSET_AMD_LEGACY 0xFFF0 #endif +/** + * flash_perror() - Print a flash error + * + * @err: Error number of message to print (ERR_... as below) + */ +void flash_perror(int err); + /*----------------------------------------------------------------------- * return codes from flash_write(): */ diff --git a/include/fs.h b/include/fs.h index 742a535b5f0..37e35c21206 100644 --- a/include/fs.h +++ b/include/fs.h @@ -14,6 +14,28 @@ #define FS_TYPE_UBIFS 4 #define FS_TYPE_BTRFS 5 +/** + * do_fat_fsload - Run the fatload command + * + * @cmdtp: Command information for fatload + * @flag: Command flags (CMD_FLAG_...) + * @argc: Number of arguments + * @argv: List of arguments + * @return result (see enum command_ret_t) + */ +int do_fat_fsload(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[]); + +/** + * do_ext2load - Run the ext2load command + * + * @cmdtp: Command information for ext2load + * @flag: Command flags (CMD_FLAG_...) + * @argc: Number of arguments + * @argv: List of arguments + * @return result (see enum command_ret_t) + */ +int do_ext2load(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[]); + /* * Tell the fs layer which block device an partition to use for future * commands. This also internally identifies the filesystem that is present diff --git a/include/hang.h b/include/hang.h new file mode 100644 index 00000000000..27cda493592 --- /dev/null +++ b/include/hang.h @@ -0,0 +1,22 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * (C) Copyright 2000-2009 + * Wolfgang Denk, DENX Software Engineering, wd@denx.de. + */ + +#ifndef __HANG_H +#define __HANG_H + +#ifndef __ASSEMBLY__ +/** + * hang() - Print a message and stop execution + * + * This shows a 'hang' message where possible and then goes into an infinite + * loop. This is called by panic() if CONFIG_PANIC_HANG is enabled. + * + * This function does not return. + */ +void hang(void) __attribute__ ((noreturn)); +#endif + +#endif diff --git a/include/image.h b/include/image.h index 4a280b78e74..9c6b6d6054b 100644 --- a/include/image.h +++ b/include/image.h @@ -112,6 +112,10 @@ struct fdt_region; # define IMAGE_OF_SYSTEM_SETUP 0 #endif +extern ulong image_load_addr; /* Default Load Address */ +extern ulong image_save_addr; /* Default Save Address */ +extern ulong image_save_size; /* Default Save Size */ + enum ih_category { IH_ARCH, IH_COMP, @@ -670,6 +674,18 @@ int fit_image_load(bootm_headers_t *images, ulong addr, int arch, int image_type, int bootstage_id, enum fit_load_op load_op, ulong *datap, ulong *lenp); +/** + * image_source_script() - Execute a script + * + * Executes a U-Boot script at a particular address in memory. The script should + * have a header (FIT or legacy) with the script type (IH_TYPE_SCRIPT). + * + * @addr: Address of script + * @fit_uname: FIT subimage name + * @return result code (enum command_ret_t) + */ +int image_source_script(ulong addr, const char *fit_uname); + #ifndef USE_HOSTCC /** * fit_get_node_from_config() - Look up an image a FIT by type @@ -930,6 +946,10 @@ int booti_setup(ulong image, ulong *relocated_addr, ulong *size, #define FIT_IGNORE_PROP "uboot-ignore" #define FIT_SIG_NODENAME "signature" +/* cipher node */ +#define FIT_CIPHER_NODENAME "cipher" +#define FIT_ALGO_PROP "algo" + /* image node */ #define FIT_DATA_PROP "data" #define FIT_DATA_POSITION_PROP "data-position" @@ -1019,6 +1039,8 @@ int fit_image_get_data_offset(const void *fit, int noffset, int *data_offset); int fit_image_get_data_position(const void *fit, int noffset, int *data_position); int fit_image_get_data_size(const void *fit, int noffset, int *data_size); +int fit_image_get_data_size_unciphered(const void *fit, int noffset, + size_t *data_size); int fit_image_get_data_and_size(const void *fit, int noffset, const void **data, size_t *size); @@ -1028,6 +1050,10 @@ int fit_image_hash_get_value(const void *fit, int noffset, uint8_t **value, int fit_set_timestamp(void *fit, int noffset, time_t timestamp); +int fit_cipher_data(const char *keydir, void *keydest, void *fit, + const char *comment, int require_keys, + const char *engine_id, const char *cmdname); + /** * fit_add_verification_data() - add verification data to FIT image nodes * @@ -1058,6 +1084,7 @@ int fit_image_verify_with_data(const void *fit, int image_noffset, int fit_image_verify(const void *fit, int noffset); int fit_config_verify(const void *fit, int conf_noffset); int fit_all_image_verify(const void *fit); +int fit_config_decrypt(const void *fit, int conf_noffset); int fit_image_check_os(const void *fit, int noffset, uint8_t os); int fit_image_check_arch(const void *fit, int noffset, uint8_t arch); int fit_image_check_type(const void *fit, int noffset, uint8_t type); @@ -1138,6 +1165,7 @@ struct image_sign_info { const char *require_keys; /* Value for 'required' property */ const char *engine_id; /* Engine to use for signing */ }; + #endif /* Allow struct image_region to always be defined for rsa.h */ /* A part of an image, used for hashing */ @@ -1284,6 +1312,11 @@ int fit_image_verify_required_sigs(const void *fit, int image_noffset, int fit_image_check_sig(const void *fit, int noffset, const void *data, size_t size, int required_keynode, char **err_msgp); +int fit_image_decrypt_data(const void *fit, + int image_noffset, int cipher_noffset, + const void *data, size_t size, + void **data_unciphered, size_t *size_unciphered); + /** * fit_region_make_list() - Make a list of regions to hash * @@ -1310,6 +1343,64 @@ static inline int fit_image_check_target_arch(const void *fdt, int node) #endif } +/* + * At present we only support ciphering on the host, and unciphering on the + * device + */ +#if defined(USE_HOSTCC) +# if defined(CONFIG_FIT_CIPHER) +# define IMAGE_ENABLE_ENCRYPT 1 +# define IMAGE_ENABLE_DECRYPT 1 +# include <openssl/evp.h> +# else +# define IMAGE_ENABLE_ENCRYPT 0 +# define IMAGE_ENABLE_DECRYPT 0 +# endif +#else +# define IMAGE_ENABLE_ENCRYPT 0 +# define IMAGE_ENABLE_DECRYPT CONFIG_IS_ENABLED(FIT_CIPHER) +#endif + +/* Information passed to the ciphering routines */ +struct image_cipher_info { + const char *keydir; /* Directory containing keys */ + const char *keyname; /* Name of key to use */ + const char *ivname; /* Name of IV to use */ + const void *fit; /* Pointer to FIT blob */ + int node_noffset; /* Offset of the cipher node */ + const char *name; /* Algorithm name */ + struct cipher_algo *cipher; /* Cipher algorithm information */ + const void *fdt_blob; /* FDT containing key and IV */ + const void *key; /* Value of the key */ + const void *iv; /* Value of the IV */ + size_t size_unciphered; /* Size of the unciphered data */ +}; + +struct cipher_algo { + const char *name; /* Name of algorithm */ + int key_len; /* Length of the key */ + int iv_len; /* Length of the IV */ + +#if IMAGE_ENABLE_ENCRYPT + const EVP_CIPHER * (*calculate_type)(void); +#endif + + int (*encrypt)(struct image_cipher_info *info, + const unsigned char *data, int data_len, + unsigned char **cipher, int *cipher_len); + + int (*add_cipher_data)(struct image_cipher_info *info, + void *keydest); + + int (*decrypt)(struct image_cipher_info *info, + const void *cipher, size_t cipher_len, + void **data, size_t *data_len); +}; + +int fit_image_cipher_get_algo(const void *fit, int noffset, char **algo); + +struct cipher_algo *image_get_cipher_algo(const char *full_name); + #ifdef CONFIG_FIT_VERBOSE #define fit_unsupported(msg) printf("! %s:%d " \ "FIT images not supported for '%s'\n", \ diff --git a/include/init.h b/include/init.h index 970a39a6a08..2a33a3fd1e4 100644 --- a/include/init.h +++ b/include/init.h @@ -12,8 +12,17 @@ #include <linux/types.h> +struct global_data; + #ifndef __ASSEMBLY__ /* put C only stuff in this section */ +/* Avoid using CONFIG_EFI_STUB directly as we may boot from other loaders */ +#ifdef CONFIG_EFI_STUB +#define ll_boot_init() false +#else +#define ll_boot_init() true +#endif + /* * Function Prototypes */ @@ -97,6 +106,11 @@ int dram_init(void); */ int dram_init_banksize(void); +long get_ram_size(long *base, long size); +phys_size_t get_effective_memsize(void); + +int testdram(void); + /** * arch_reserve_stacks() - Reserve all necessary stacks * @@ -221,6 +235,21 @@ void pci_init_board(void); void trap_init(unsigned long reloc_addr); +/** + * main_loop() - Enter the main loop of U-Boot + * + * This normally runs the command line. + */ +void main_loop(void); + +#if defined(CONFIG_ARM) +void relocate_code(ulong addr_moni); +#else +void relocate_code(ulong start_addr_sp, struct global_data *new_gd, + ulong relocaddr) + __attribute__ ((noreturn)); +#endif + #endif /* __ASSEMBLY__ */ /* Put only stuff here that the assembler can digest */ diff --git a/include/linux/kernel.h b/include/linux/kernel.h index 564819a1c0a..b88c2100659 100644 --- a/include/linux/kernel.h +++ b/include/linux/kernel.h @@ -69,6 +69,8 @@ #define DIV_ROUND_UP_ULL(ll, d) DIV_ROUND_DOWN_ULL((ll) + (d) - 1, (d)) +#define ROUND(a, b) (((a) + (b) - 1) & ~((b) - 1)) + #if BITS_PER_LONG == 32 # define DIV_ROUND_UP_SECTOR_T(ll,d) DIV_ROUND_UP_ULL(ll, d) #else @@ -268,4 +270,15 @@ const typeof( ((type *)0)->member ) *__mptr = (ptr); \ (type *)( (char *)__mptr - offsetof(type,member) );}) +/* + * check_member() - Check the offset of a structure member + * + * @structure: Name of structure (e.g. global_data) + * @member: Name of member (e.g. baudrate) + * @offset: Expected offset in bytes + */ +#define check_member(structure, member, offset) _Static_assert( \ + offsetof(struct structure, member) == (offset), \ + "`struct " #structure "` offset for `" #member "` is not " #offset) + #endif diff --git a/include/linux/types.h b/include/linux/types.h index bd912bcb42f..baa2c491ea5 100644 --- a/include/linux/types.h +++ b/include/linux/types.h @@ -163,4 +163,8 @@ struct ustat { #define DECLARE_BITMAP(name, bits) \ unsigned long name[BITS_TO_LONGS(bits)] +typedef volatile unsigned long vu_long; +typedef volatile unsigned short vu_short; +typedef volatile unsigned char vu_char; + #endif /* _LINUX_TYPES_H */ diff --git a/include/net.h b/include/net.h index 834f2449826..8a02c923a40 100644 --- a/include/net.h +++ b/include/net.h @@ -51,6 +51,17 @@ struct in_addr { }; /** + * do_tftpb - Run the tftpboot command + * + * @cmdtp: Command information for tftpboot + * @flag: Command flags (CMD_FLAG_...) + * @argc: Number of arguments + * @argv: List of arguments + * @return result (see enum command_ret_t) + */ +int do_tftpb(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[]); + +/** * An incoming packet handler. * @param pkt pointer to the application packet * @param dport destination UDP port @@ -906,4 +917,12 @@ static inline struct in_addr env_get_ip(char *var) { return string_to_ip(env_get(var)); } + +/** + * reset_phy() - Reset the Ethernet PHY + * + * This should be implemented by boards if CONFIG_RESET_PHY_R is enabled + */ +void reset_phy(void); + #endif /* __NET_H__ */ diff --git a/include/ns87308.h b/include/ns87308.h deleted file mode 100644 index d5ccd3ba3be..00000000000 --- a/include/ns87308.h +++ /dev/null @@ -1,233 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0+ */ -/* - * (C) Copyright 2000 - * Rob Taylor, Flying Pig Systems. robt@flyingpig.com. - */ - -#ifndef _NS87308_H_ -#define _NS87308_H_ - -#include <asm/pci_io.h> - -/* Note: I couldn't find a full data sheet for the ns87308, but the ns87307 seems to be pretty - functionally- (and pin-) equivalent to the 87308, but the 308 has better ir support. */ - -void initialise_ns87308(void); - -/* - * The following struct represents the GPIO registers on the NS87308/NS97307 - */ -struct GPIO -{ - unsigned char dta1; /* 0 data port 1 */ - unsigned char dir1; /* 1 direction port 1 */ - unsigned char out1; /* 2 output type port 1 */ - unsigned char puc1; /* 3 pull-up control port 1 */ - unsigned char dta2; /* 4 data port 2 */ - unsigned char dir2; /* 5 direction port 2 */ - unsigned char out2; /* 6 output type port 2 */ - unsigned char puc2; /* 7 pull-up control port 2 */ -}; - -/* - * The following represents the power management registers on the NS87308/NS97307 - */ -#define PWM_FER1 0 /* 0 function enable reg. 1 */ -#define PWM_FER2 1 /* 1 function enable reg. 2 */ -#define PWM_PMC1 2 /* 2 power mgmt. control 1 */ -#define PWM_PMC2 3 /* 3 power mgmt. control 2 */ -#define PWM_PMC3 4 /* 4 power mgmt. control 3 */ -#define PWM_WDTO 5 /* 5 watchdog time-out */ -#define PWM_WDCF 6 /* 6 watchdog config. */ -#define PWM_WDST 7 /* 7 watchdog status */ - -/*PNP config registers: - * these depend on the stated of BADDR1 and BADDR0 on startup - * so there's three versions here with the last two digits indicating - * for which configuration their valid - * the 1st of the two digits indicates the state of BADDR1 - * the 2st of the two digits indicates the state of BADDR0 - */ - - -#define IO_INDEX_OFFSET_0x 0x0279 /* full PnP isa Mode */ -#define IO_INDEX_OFFSET_10 0x015C /* PnP motherboard mode */ -#define IO_INDEX_OFFSET_11 0x002E /* PnP motherboard mode */ -#define IO_DATA_OFFSET_0x 0x0A79 /* full PnP isa Mode */ -#define IO_DATA_OFFSET_10 0x015D /* PnP motherboard mode */ -#define IO_DATA_OFFSET_11 0x002F /* PnP motherboard mode */ - -#if defined(CONFIG_SYS_NS87308_BADDR_0x) -#define IO_INDEX (CONFIG_SYS_ISA_IO + IO_INDEX_OFFSET_0x) -#define IO_DATA (CONFIG_SYS_ISA_IO + IO_DATA_OFFSET_0x) -#elif defined(CONFIG_SYS_NS87308_BADDR_10) -#define IO_INDEX (CONFIG_SYS_ISA_IO + IO_INDEX_OFFSET_10) -#define IO_DATA (CONFIG_SYS_ISA_IO + IO_DATA_OFFSET_10) -#elif defined(CONFIG_SYS_NS87308_BADDR_11) -#define IO_INDEX (CONFIG_SYS_ISA_IO + IO_INDEX_OFFSET_11) -#define IO_DATA (CONFIG_SYS_ISA_IO + IO_DATA_OFFSET_11) -#endif - -/* PnP register definitions */ - -#define SET_RD_DATA_PORT 0x00 -#define SERIAL_ISOLATION 0x01 -#define CONFIG_CONTROL 0x02 -#define WAKE_CSN 0x03 -#define RES_DATA 0x04 -#define STATUS 0x05 -#define SET_CSN 0x06 -#define LOGICAL_DEVICE 0x07 - -/*vendor defined values */ -#define SID_REG 0x20 -#define SUPOERIO_CONF1 0x21 -#define SUPOERIO_CONF2 0x22 -#define PGCS_INDEX 0x23 -#define PGCS_DATA 0x24 - -/* values above 30 are different for each logical device - but I can't be arsed to enter them all. the ones here - are pretty consistent between all logical devices - feel free to correct the situation if you want.. ;) - */ -#define ACTIVATE 0x30 -#define ACTIVATE_OFF 0x00 -#define ACTIVATE_ON 0x01 - -#define BASE_ADDR_HIGH 0x60 -#define BASE_ADDR_LOW 0x61 -#define LUN_CONFIG_REG 0xF0 -#define DBASE_HIGH 0x60 /* SIO KBC data base address, 15:8 */ -#define DBASE_LOW 0x61 /* SIO KBC data base address, 7:0 */ -#define CBASE_HIGH 0x62 /* SIO KBC command base addr, 15:8 */ -#define CBASE_LOW 0x63 /* SIO KBC command base addr, 7:0 */ - -/* the logical devices*/ -#define LDEV_KBC1 0x00 /* 2 devices for keyboard and mouse controller*/ -#define LDEV_KBC2 0x01 -#define LDEV_MOUSE 0x01 -#define LDEV_RTC_APC 0x02 /*Real Time Clock and Advanced Power Control*/ -#define LDEV_FDC 0x03 /*floppy disk controller*/ -#define LDEV_PARP 0x04 /*Parallel port*/ -#define LDEV_UART2 0x05 -#define LDEV_UART1 0x06 -#define LDEV_GPIO 0x07 /*General Purpose IO and chip select output signals*/ -#define LDEV_POWRMAN 0x08 /*Power Managment*/ - -#define CONFIG_SYS_NS87308_KBC1 (1 << LDEV_KBC1) -#define CONFIG_SYS_NS87308_KBC2 (1 << LDEV_KBC2) -#define CONFIG_SYS_NS87308_MOUSE (1 << LDEV_MOUSE) -#define CONFIG_SYS_NS87308_RTC_APC (1 << LDEV_RTC_APC) -#define CONFIG_SYS_NS87308_FDC (1 << LDEV_FDC) -#define CONFIG_SYS_NS87308_PARP (1 << LDEV_PARP) -#define CONFIG_SYS_NS87308_UART2 (1 << LDEV_UART2) -#define CONFIG_SYS_NS87308_UART1 (1 << LDEV_UART1) -#define CONFIG_SYS_NS87308_GPIO (1 << LDEV_GPIO) -#define CONFIG_SYS_NS87308_POWRMAN (1 << LDEV_POWRMAN) - -/*some functions and macro's for doing configuration */ - -static inline void read_pnp_config(unsigned char index, unsigned char *data) -{ - pci_writeb(index,IO_INDEX); - pci_readb(IO_DATA, *data); -} - -static inline void write_pnp_config(unsigned char index, unsigned char data) -{ - pci_writeb(index,IO_INDEX); - pci_writeb(data, IO_DATA); -} - -static inline void pnp_set_device(unsigned char dev) -{ - write_pnp_config(LOGICAL_DEVICE, dev); -} - -static inline void write_pm_reg(unsigned short base, unsigned char index, unsigned char data) -{ - pci_writeb(index, CONFIG_SYS_ISA_IO + base); - eieio(); - pci_writeb(data, CONFIG_SYS_ISA_IO + base + 1); -} - -/*void write_pnp_config(unsigned char index, unsigned char data); -void pnp_set_device(unsigned char dev); -*/ - -#define PNP_SET_DEVICE_BASE(dev,base) \ - pnp_set_device(dev); \ - write_pnp_config(ACTIVATE, ACTIVATE_OFF); \ - write_pnp_config(BASE_ADDR_HIGH, ((base) >> 8) & 0xff ); \ - write_pnp_config(BASE_ADDR_LOW, (base) &0xff); \ - write_pnp_config(ACTIVATE, ACTIVATE_ON); - -#define PNP_ACTIVATE_DEVICE(dev) \ - pnp_set_device(dev); \ - write_pnp_config(ACTIVATE, ACTIVATE_ON); - -#define PNP_DEACTIVATE_DEVICE(dev) \ - pnp_set_device(dev); \ - write_pnp_config(ACTIVATE, ACTIVATE_OFF); - - -static inline void write_pgcs_config(unsigned char index, unsigned char data) -{ - write_pnp_config(PGCS_INDEX, index); - write_pnp_config(PGCS_DATA, data); -} - -/* these macrose configure the 3 CS lines - on the sandpoint board these controll NVRAM - CS0 is connected to NVRAMCS - CS1 is connected to NVRAMAS0 - CS2 is connected to NVRAMAS1 - */ -#define PGCS_CS_ASSERT_ON_WRITE 0x10 -#define PGCS_CS_ASSERT_ON_READ 0x20 - -#define PNP_PGCS_CSLINE_BASE(cs, base) \ - write_pgcs_config((cs) << 2, ((base) >> 8) & 0xff ); \ - write_pgcs_config(((cs) << 2) + 1, (base) & 0xff ); - -#define PNP_PGCS_CSLINE_CONF(cs, conf) \ - write_pgcs_config(((cs) << 2) + 2, (conf) ); - - -/* The following sections are for 87308 extensions to the standard compoents it emulates */ - -/* extensions to 16550*/ - -#define MCR_MDSL_MSK 0xe0 /*mode select mask*/ -#define MCR_MDSL_UART 0x00 /*uart, default*/ -#define MCR_MDSL_SHRPIR 0x02 /*Sharp IR*/ -#define MCR_MDSL_SIR 0x03 /*SIR*/ -#define MCR_MDSL_CIR 0x06 /*Consumer IR*/ - -#define FCR_TXFTH0 0x10 /* these bits control threshod of data level in fifo */ -#define FCR_TXFTH1 0x20 /* for interrupt trigger */ - -/* - * Default NS87308 configuration - */ -#ifndef CONFIG_SYS_NS87308_KBC1_BASE -#define CONFIG_SYS_NS87308_KBC1_BASE 0x0060 -#endif -#ifndef CONFIG_SYS_NS87308_RTC_BASE -#define CONFIG_SYS_NS87308_RTC_BASE 0x0070 -#endif -#ifndef CONFIG_SYS_NS87308_FDC_BASE -#define CONFIG_SYS_NS87308_FDC_BASE 0x03F0 -#endif -#ifndef CONFIG_SYS_NS87308_LPT_BASE -#define CONFIG_SYS_NS87308_LPT_BASE 0x0278 -#endif -#ifndef CONFIG_SYS_NS87308_UART1_BASE -#define CONFIG_SYS_NS87308_UART1_BASE 0x03F8 -#endif -#ifndef CONFIG_SYS_NS87308_UART2_BASE -#define CONFIG_SYS_NS87308_UART2_BASE 0x02F8 -#endif - -#endif /*_NS87308_H_*/ diff --git a/include/time.h b/include/time.h index 71446c31714..e99f9c80127 100644 --- a/include/time.h +++ b/include/time.h @@ -6,6 +6,8 @@ #include <linux/typecheck.h> #include <linux/types.h> +ulong get_tbclk(void); + unsigned long get_timer(unsigned long base); /* diff --git a/include/u-boot/aes.h b/include/u-boot/aes.h new file mode 100644 index 00000000000..32281041de2 --- /dev/null +++ b/include/u-boot/aes.h @@ -0,0 +1,44 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * Copyright (c) 2019, Softathome + */ + +#ifndef _AES_H +#define _AES_H + +#include <errno.h> +#include <image.h> + +#if IMAGE_ENABLE_ENCRYPT +int image_aes_encrypt(struct image_cipher_info *info, + const unsigned char *data, int size, + unsigned char **cipher, int *cipher_len); +int image_aes_add_cipher_data(struct image_cipher_info *info, void *keydest); +#else +int image_aes_encrypt(struct image_cipher_info *info, + const unsigned char *data, int size, + unsigned char **cipher, int *cipher_len) +{ + return -ENXIO; +} + +int image_aes_add_cipher_data(struct image_cipher_info *info, void *keydest) +{ + return -ENXIO; +} +#endif /* IMAGE_ENABLE_ENCRYPT */ + +#if IMAGE_ENABLE_DECRYPT +int image_aes_decrypt(struct image_cipher_info *info, + const void *cipher, size_t cipher_len, + void **data, size_t *size); +#else +int image_aes_decrypt(struct image_cipher_info *info, + const void *cipher, size_t cipher_len, + void **data, size_t *size) +{ + return -ENXIO; +} +#endif /* IMAGE_ENABLE_DECRYPT */ + +#endif diff --git a/include/uboot_aes.h b/include/uboot_aes.h index 2fda384e3b7..d2583bed992 100644 --- a/include/uboot_aes.h +++ b/include/uboot_aes.h @@ -18,16 +18,24 @@ typedef unsigned int u32; * AES encryption library, with small code size, supporting only 128-bit AES * * AES is a stream cipher which works a block at a time, with each block - * in this case being AES_KEY_LENGTH bytes. + * in this case being AES_BLOCK_LENGTH bytes. */ enum { AES_STATECOLS = 4, /* columns in the state & expanded key */ - AES_KEYCOLS = 4, /* columns in a key */ - AES_ROUNDS = 10, /* rounds in encryption */ - - AES_KEY_LENGTH = 128 / 8, - AES_EXPAND_KEY_LENGTH = 4 * AES_STATECOLS * (AES_ROUNDS + 1), + AES128_KEYCOLS = 4, /* columns in a key for aes128 */ + AES192_KEYCOLS = 6, /* columns in a key for aes128 */ + AES256_KEYCOLS = 8, /* columns in a key for aes128 */ + AES128_ROUNDS = 10, /* rounds in encryption for aes128 */ + AES192_ROUNDS = 12, /* rounds in encryption for aes192 */ + AES256_ROUNDS = 14, /* rounds in encryption for aes256 */ + AES128_KEY_LENGTH = 128 / 8, + AES192_KEY_LENGTH = 192 / 8, + AES256_KEY_LENGTH = 256 / 8, + AES128_EXPAND_KEY_LENGTH = 4 * AES_STATECOLS * (AES128_ROUNDS + 1), + AES192_EXPAND_KEY_LENGTH = 4 * AES_STATECOLS * (AES192_ROUNDS + 1), + AES256_EXPAND_KEY_LENGTH = 4 * AES_STATECOLS * (AES256_ROUNDS + 1), + AES_BLOCK_LENGTH = 128 / 8, }; /** @@ -36,33 +44,36 @@ enum { * Expand a key into a key schedule, which is then used for the other * operations. * - * @key Key, of length AES_KEY_LENGTH bytes + * @key Key + * @key_size Size of the key (in bits) * @expkey Buffer to place expanded key, AES_EXPAND_KEY_LENGTH */ -void aes_expand_key(u8 *key, u8 *expkey); +void aes_expand_key(u8 *key, u32 key_size, u8 *expkey); /** * aes_encrypt() - Encrypt single block of data with AES 128 * + * @key_size Size of the aes key (in bits) * @in Input data * @expkey Expanded key to use for encryption (from aes_expand_key()) * @out Output data */ -void aes_encrypt(u8 *in, u8 *expkey, u8 *out); +void aes_encrypt(u32 key_size, u8 *in, u8 *expkey, u8 *out); /** * aes_decrypt() - Decrypt single block of data with AES 128 * + * @key_size Size of the aes key (in bits) * @in Input data * @expkey Expanded key to use for decryption (from aes_expand_key()) * @out Output data */ -void aes_decrypt(u8 *in, u8 *expkey, u8 *out); +void aes_decrypt(u32 key_size, u8 *in, u8 *expkey, u8 *out); /** * Apply chain data to the destination using EOR * - * Each array is of length AES_KEY_LENGTH. + * Each array is of length AES_BLOCK_LENGTH. * * @cbc_chain_data Chain data * @src Source data @@ -73,25 +84,27 @@ void aes_apply_cbc_chain_data(u8 *cbc_chain_data, u8 *src, u8 *dst); /** * aes_cbc_encrypt_blocks() - Encrypt multiple blocks of data with AES CBC. * + * @key_size Size of the aes key (in bits) * @key_exp Expanded key to use * @iv Initialization vector * @src Source data to encrypt * @dst Destination buffer * @num_aes_blocks Number of AES blocks to encrypt */ -void aes_cbc_encrypt_blocks(u8 *key_exp, u8 *iv, u8 *src, u8 *dst, +void aes_cbc_encrypt_blocks(u32 key_size, u8 *key_exp, u8 *iv, u8 *src, u8 *dst, u32 num_aes_blocks); /** * Decrypt multiple blocks of data with AES CBC. * + * @key_size Size of the aes key (in bits) * @key_exp Expanded key to use * @iv Initialization vector * @src Source data to decrypt * @dst Destination buffer * @num_aes_blocks Number of AES blocks to decrypt */ -void aes_cbc_decrypt_blocks(u8 *key_exp, u8 *iv, u8 *src, u8 *dst, +void aes_cbc_decrypt_blocks(u32 key_size, u8 *key_exp, u8 *iv, u8 *src, u8 *dst, u32 num_aes_blocks); #endif /* _AES_REF_H_ */ |