[POWERPC] zImage: Cleanup and improve prep_kernel()
[linux-2.6/sactl.git] / arch / powerpc / boot / ops.h
blobfa62ff223e70e9554777279419d5d47b46621195
1 /*
2 * Global definition of all the bootwrapper operations.
4 * Author: Mark A. Greer <mgreer@mvista.com>
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
9 * or implied.
11 #ifndef _PPC_BOOT_OPS_H_
12 #define _PPC_BOOT_OPS_H_
14 #include "types.h"
16 #define COMMAND_LINE_SIZE 512
17 #define MAX_PATH_LEN 256
18 #define MAX_PROP_LEN 256 /* What should this be? */
20 /* Platform specific operations */
21 struct platform_ops {
22 void (*fixups)(void);
23 void (*image_hdr)(const void *);
24 void * (*malloc)(u32 size);
25 void (*free)(void *ptr);
26 void * (*realloc)(void *ptr, unsigned long size);
27 void (*exit)(void);
28 void * (*vmlinux_alloc)(unsigned long size);
30 extern struct platform_ops platform_ops;
32 /* Device Tree operations */
33 struct dt_ops {
34 void * (*finddevice)(const char *name);
35 int (*getprop)(const void *phandle, const char *name, void *buf,
36 const int buflen);
37 int (*setprop)(const void *phandle, const char *name,
38 const void *buf, const int buflen);
39 unsigned long (*finalize)(void);
41 extern struct dt_ops dt_ops;
43 /* Console operations */
44 struct console_ops {
45 int (*open)(void);
46 void (*write)(char *buf, int len);
47 void (*edit_cmdline)(char *buf, int len);
48 void (*close)(void);
49 void *data;
51 extern struct console_ops console_ops;
53 /* Serial console operations */
54 struct 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);
62 int platform_init(void *promptr, char *dt_blob_start, char *dt_blob_end);
63 int ft_init(void *dt_blob, unsigned int max_size, unsigned int max_find_device);
64 int serial_console_init(void);
65 int ns16550_console_init(void *devp, struct serial_console_data *scdp);
66 void *simple_alloc_init(char *base, u32 heap_size, u32 granularity,
67 u32 max_allocs);
70 static inline void *finddevice(const char *name)
72 return (dt_ops.finddevice) ? dt_ops.finddevice(name) : NULL;
75 static inline int getprop(void *devp, const char *name, void *buf, int buflen)
77 return (dt_ops.getprop) ? dt_ops.getprop(devp, name, buf, buflen) : -1;
80 static inline int setprop(void *devp, const char *name, void *buf, int buflen)
82 return (dt_ops.setprop) ? dt_ops.setprop(devp, name, buf, buflen) : -1;
85 static inline void *malloc(u32 size)
87 return (platform_ops.malloc) ? platform_ops.malloc(size) : NULL;
90 static inline void free(void *ptr)
92 if (platform_ops.free)
93 platform_ops.free(ptr);
96 static inline void exit(void)
98 if (platform_ops.exit)
99 platform_ops.exit();
100 for(;;);
103 #endif /* _PPC_BOOT_OPS_H_ */