ops.h (8a84fc15ae5cafcc366dd85cf8e1ab2040679abc) ops.h (c888554bf95a5a0a6ac3e2389c6bf1e03e9480ba)
1/*
2 * Global definition of all the bootwrapper operations.
3 *
4 * Author: Mark A. Greer <mgreer@mvista.com>
5 *
6 * 2006 (c) MontaVista Software, Inc. This file is licensed under
7 * the terms of the GNU General Public License version 2. This program
8 * is licensed "as is" without any warranty of any kind, whether express

--- 8 unchanged lines hidden (view full) ---

17#define MAX_PATH_LEN 256
18#define MAX_PROP_LEN 256 /* What should this be? */
19
20/* Platform specific operations */
21struct platform_ops {
22 void (*fixups)(void);
23 void (*image_hdr)(const void *);
24 void * (*malloc)(u32 size);
1/*
2 * Global definition of all the bootwrapper operations.
3 *
4 * Author: Mark A. Greer <mgreer@mvista.com>
5 *
6 * 2006 (c) MontaVista Software, Inc. This file is licensed under
7 * the terms of the GNU General Public License version 2. This program
8 * is licensed "as is" without any warranty of any kind, whether express

--- 8 unchanged lines hidden (view full) ---

17#define MAX_PATH_LEN 256
18#define MAX_PROP_LEN 256 /* What should this be? */
19
20/* Platform specific operations */
21struct platform_ops {
22 void (*fixups)(void);
23 void (*image_hdr)(const void *);
24 void * (*malloc)(u32 size);
25 void (*free)(void *ptr, u32 size);
25 void (*free)(void *ptr);
26 void * (*realloc)(void *ptr, unsigned long size);
26 void (*exit)(void);
27};
28extern struct platform_ops platform_ops;
29
30/* Device Tree operations */
31struct dt_ops {
32 void * (*finddevice)(const char *name);
27 void (*exit)(void);
28};
29extern struct platform_ops platform_ops;
30
31/* Device Tree operations */
32struct dt_ops {
33 void * (*finddevice)(const char *name);
33 int (*getprop)(const void *node, const char *name, void *buf,
34 int (*getprop)(const void *phandle, const char *name, void *buf,
34 const int buflen);
35 const int buflen);
35 int (*setprop)(const void *node, const char *name,
36 int (*setprop)(const void *phandle, const char *name,
36 const void *buf, const int buflen);
37 const void *buf, const int buflen);
37 u64 (*translate_addr)(const char *path, const u32 *in_addr,
38 const u32 addr_len);
38 void (*ft_pack)(void);
39 unsigned long (*ft_addr)(void);
40};
41extern struct dt_ops dt_ops;
42
43/* Console operations */
44struct console_ops {
45 int (*open)(void);
46 void (*write)(char *buf, int len);

--- 7 unchanged lines hidden (view full) ---

54struct serial_console_data {
55 int (*open)(void);
56 void (*putc)(unsigned char c);
57 unsigned char (*getc)(void);
58 u8 (*tstc)(void);
59 void (*close)(void);
60};
61
39 unsigned long (*ft_addr)(void);
40};
41extern struct dt_ops dt_ops;
42
43/* Console operations */
44struct console_ops {
45 int (*open)(void);
46 void (*write)(char *buf, int len);

--- 7 unchanged lines hidden (view full) ---

54struct serial_console_data {
55 int (*open)(void);
56 void (*putc)(unsigned char c);
57 unsigned char (*getc)(void);
58 u8 (*tstc)(void);
59 void (*close)(void);
60};
61
62extern int platform_init(void *promptr);
63extern void simple_alloc_init(void);
64extern void ft_init(void *dt_blob);
65extern int serial_console_init(void);
62int platform_init(void *promptr, char *dt_blob_start, char *dt_blob_end);
63int ft_init(void *dt_blob, unsigned int max_size, unsigned int max_find_device);
64int serial_console_init(void);
65int ns16550_console_init(void *devp, struct serial_console_data *scdp);
66void *simple_alloc_init(char *base, u32 heap_size, u32 granularity,
67 u32 max_allocs);
66
68
69
67static inline void *finddevice(const char *name)
68{
69 return (dt_ops.finddevice) ? dt_ops.finddevice(name) : NULL;
70}
71
72static inline int getprop(void *devp, const char *name, void *buf, int buflen)
73{
74 return (dt_ops.getprop) ? dt_ops.getprop(devp, name, buf, buflen) : -1;

--- 4 unchanged lines hidden (view full) ---

79 return (dt_ops.setprop) ? dt_ops.setprop(devp, name, buf, buflen) : -1;
80}
81
82static inline void *malloc(u32 size)
83{
84 return (platform_ops.malloc) ? platform_ops.malloc(size) : NULL;
85}
86
70static inline void *finddevice(const char *name)
71{
72 return (dt_ops.finddevice) ? dt_ops.finddevice(name) : NULL;
73}
74
75static inline int getprop(void *devp, const char *name, void *buf, int buflen)
76{
77 return (dt_ops.getprop) ? dt_ops.getprop(devp, name, buf, buflen) : -1;

--- 4 unchanged lines hidden (view full) ---

82 return (dt_ops.setprop) ? dt_ops.setprop(devp, name, buf, buflen) : -1;
83}
84
85static inline void *malloc(u32 size)
86{
87 return (platform_ops.malloc) ? platform_ops.malloc(size) : NULL;
88}
89
87static inline void free(void *ptr, u32 size)
90static inline void free(void *ptr)
88{
89 if (platform_ops.free)
91{
92 if (platform_ops.free)
90 platform_ops.free(ptr, size);
93 platform_ops.free(ptr);
91}
92
93static inline void exit(void)
94{
95 if (platform_ops.exit)
96 platform_ops.exit();
97 for(;;);
98}
99
100#endif /* _PPC_BOOT_OPS_H_ */
94}
95
96static inline void exit(void)
97{
98 if (platform_ops.exit)
99 platform_ops.exit();
100 for(;;);
101}
102
103#endif /* _PPC_BOOT_OPS_H_ */