Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2)  * Global definition of all the bootwrapper operations.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  * Author: Mark A. Greer <mgreer@mvista.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  * 2006 (c) MontaVista Software, Inc.  This file is licensed under
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7)  * the terms of the GNU General Public License version 2.  This program
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8)  * is licensed "as is" without any warranty of any kind, whether express
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9)  * or implied.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) #ifndef _PPC_BOOT_OPS_H_
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) #define _PPC_BOOT_OPS_H_
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) #include <stddef.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) #include "types.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) #include "string.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) #define	BOOT_COMMAND_LINE_SIZE	2048
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) #define	MAX_PATH_LEN		256
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) #define	MAX_PROP_LEN		256 /* What should this be? */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) typedef void (*kernel_entry_t)(unsigned long r3, unsigned long r4, void *r5);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) /* Platform specific operations */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) struct platform_ops {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) 	void	(*fixups)(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) 	void	(*image_hdr)(const void *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) 	void *	(*malloc)(unsigned long size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) 	void	(*free)(void *ptr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) 	void *	(*realloc)(void *ptr, unsigned long size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) 	void	(*exit)(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) 	void *	(*vmlinux_alloc)(unsigned long size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) 	void  	(*kentry)(unsigned long fdt_addr, void *vmlinux_addr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) extern struct platform_ops platform_ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) /* Device Tree operations */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) struct dt_ops {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) 	void *	(*finddevice)(const char *name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) 	int	(*getprop)(const void *phandle, const char *name, void *buf,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) 			const int buflen);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) 	int	(*setprop)(const void *phandle, const char *name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) 			const void *buf, const int buflen);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) 	int (*del_node)(const void *phandle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 	void *(*get_parent)(const void *phandle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 	/* The node must not already exist. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 	void *(*create_node)(const void *parent, const char *name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 	void *(*find_node_by_prop_value)(const void *prev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 	                                 const char *propname,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 	                                 const char *propval, int proplen);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 	void *(*find_node_by_compatible)(const void *prev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 	                                 const char *compat);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 	unsigned long (*finalize)(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 	char *(*get_path)(const void *phandle, char *buf, int len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) extern struct dt_ops dt_ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) /* Console operations */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) struct console_ops {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 	int	(*open)(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 	void	(*write)(const char *buf, int len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 	void	(*edit_cmdline)(char *buf, int len, unsigned int getline_timeout);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 	void	(*close)(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 	void	*data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) extern struct console_ops console_ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) /* Serial console operations */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) struct serial_console_data {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 	int		(*open)(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 	void		(*putc)(unsigned char c);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 	unsigned char	(*getc)(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 	u8		(*tstc)(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 	void		(*close)(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) struct loader_info {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 	void *promptr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 	unsigned long initrd_addr, initrd_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 	char *cmdline;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 	int cmdline_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) extern struct loader_info loader_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) void start(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) void fdt_init(void *blob);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) int serial_console_init(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) int ns16550_console_init(void *devp, struct serial_console_data *scdp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) int cpm_console_init(void *devp, struct serial_console_data *scdp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) int mpc5200_psc_console_init(void *devp, struct serial_console_data *scdp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) int opal_console_init(void *devp, struct serial_console_data *scdp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) void *simple_alloc_init(char *base, unsigned long heap_size,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 			unsigned long granularity, unsigned long max_allocs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) extern void flush_cache(void *, unsigned long);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) int dt_xlate_reg(void *node, int res, unsigned long *addr, unsigned long *size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) int dt_xlate_addr(void *node, u32 *buf, int buflen, unsigned long *xlated_addr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) int dt_is_compatible(void *node, const char *compat);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) void dt_get_reg_format(void *node, u32 *naddr, u32 *nsize);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) int dt_get_virtual_reg(void *node, void **addr, int nres);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) static inline void *finddevice(const char *name)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 	return (dt_ops.finddevice) ? dt_ops.finddevice(name) : NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) static inline int getprop(void *devp, const char *name, void *buf, int buflen)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 	return (dt_ops.getprop) ? dt_ops.getprop(devp, name, buf, buflen) : -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) static inline int setprop(void *devp, const char *name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112)                           const void *buf, int buflen)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 	return (dt_ops.setprop) ? dt_ops.setprop(devp, name, buf, buflen) : -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) #define setprop_val(devp, name, val) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 	do { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 		typeof(val) x = (val); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 		setprop((devp), (name), &x, sizeof(x)); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 	} while (0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) static inline int setprop_str(void *devp, const char *name, const char *buf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 	if (dt_ops.setprop)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 		return dt_ops.setprop(devp, name, buf, strlen(buf) + 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 	return -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) static inline int del_node(const void *devp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 	return dt_ops.del_node ? dt_ops.del_node(devp) : -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) static inline void *get_parent(const char *devp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 	return dt_ops.get_parent ? dt_ops.get_parent(devp) : NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) static inline void *create_node(const void *parent, const char *name)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 	return dt_ops.create_node ? dt_ops.create_node(parent, name) : NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) static inline void *find_node_by_prop_value(const void *prev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147)                                             const char *propname,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148)                                             const char *propval, int proplen)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) 	if (dt_ops.find_node_by_prop_value)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) 		return dt_ops.find_node_by_prop_value(prev, propname,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) 		                                      propval, proplen);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) 	return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) static inline void *find_node_by_prop_value_str(const void *prev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158)                                                 const char *propname,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159)                                                 const char *propval)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) 	return find_node_by_prop_value(prev, propname, propval,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) 	                               strlen(propval) + 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) static inline void *find_node_by_devtype(const void *prev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166)                                          const char *type)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) 	return find_node_by_prop_value_str(prev, "device_type", type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) static inline void *find_node_by_alias(const char *alias)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) 	void *devp = finddevice("/aliases");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) 	if (devp) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) 		char path[MAX_PATH_LEN];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) 		if (getprop(devp, alias, path, MAX_PATH_LEN) > 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) 			return finddevice(path);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) 	return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) static inline void *find_node_by_compatible(const void *prev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185)                                             const char *compat)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) 	if (dt_ops.find_node_by_compatible)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) 		return dt_ops.find_node_by_compatible(prev, compat);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) 	return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) void dt_fixup_memory(u64 start, u64 size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) void dt_fixup_cpu_clocks(u32 cpufreq, u32 tbfreq, u32 busfreq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) void dt_fixup_clock(const char *path, u32 freq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) void dt_fixup_mac_address_by_alias(const char *alias, const u8 *addr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) void dt_fixup_mac_address(u32 index, const u8 *addr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) void __dt_fixup_mac_addresses(u32 startindex, ...);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) #define dt_fixup_mac_addresses(...) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) 	__dt_fixup_mac_addresses(0, __VA_ARGS__, NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) static inline void *find_node_by_linuxphandle(const u32 linuxphandle)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) 	return find_node_by_prop_value(NULL, "linux,phandle",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) 			(char *)&linuxphandle, sizeof(u32));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) static inline char *get_path(const void *phandle, char *buf, int len)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) 	if (dt_ops.get_path)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) 		return dt_ops.get_path(phandle, buf, len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) 	return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) static inline void *malloc(unsigned long size)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) 	return (platform_ops.malloc) ? platform_ops.malloc(size) : NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) static inline void free(void *ptr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) 	if (platform_ops.free)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) 		platform_ops.free(ptr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) static inline void exit(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) 	if (platform_ops.exit)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) 		platform_ops.exit();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) 	for(;;);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) #define fatal(args...) { printf(args); exit(); }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) #define BSS_STACK(size) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) 	static char _bss_stack[size]; \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) 	void *_platform_stack_top = _bss_stack + sizeof(_bss_stack);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) extern unsigned long timebase_period_ns;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) void udelay(long delay);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) extern char _start[];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) extern char __bss_start[];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) extern char _end[];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) extern char _vmlinux_start[];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) extern char _vmlinux_end[];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) extern char _initrd_start[];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) extern char _initrd_end[];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) extern char _dtb_start[];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) extern char _dtb_end[];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) extern char _esm_blob_start[];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) extern char _esm_blob_end[];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) static inline __attribute__((const))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) int __ilog2_u32(u32 n)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) 	int bit;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) 	asm ("cntlzw %0,%1" : "=r" (bit) : "r" (n));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) 	return 31 - bit;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) long partial_decompress(void *inbuf, unsigned long input_size, void *outbuf,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) 	unsigned long output_size, unsigned long skip);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) #endif /* _PPC_BOOT_OPS_H_ */