diff options
author | Mark A. Greer <mgreer@mvista.com> | 2006-09-19 00:05:08 -0400 |
---|---|---|
committer | Paul Mackerras <paulus@samba.org> | 2006-09-20 01:09:58 -0400 |
commit | b2c5f61920eeee9c4e78698de4fde4586fe5ae79 (patch) | |
tree | 53927c324413786b34db4f0e79cd0aa436d3f930 /arch/powerpc/boot/ops.h | |
parent | a4dc7ff08915a2035aa6d6decc53fa1deaa410bb (diff) |
[POWERPC] Start arch/powerpc/boot code reorganization
This abstracts the operations used in the bootwrapper, and defines
the operations needed for the bootwrapper to run on an OF platform.
The operations have been divided up into platform ops (platform_ops),
firmware ops (fw_ops), device tree ops (dt_ops), and console ops
(console_ops).
The proper operations will be hooked up at runtime to provide the
functionality that you need.
Signed-off-by: Mark A. Greer <mgreer@mvista.com>
Signed-off-by: Paul Mackerras <paulus@samba.org>
Diffstat (limited to 'arch/powerpc/boot/ops.h')
-rw-r--r-- | arch/powerpc/boot/ops.h | 100 |
1 files changed, 100 insertions, 0 deletions
diff --git a/arch/powerpc/boot/ops.h b/arch/powerpc/boot/ops.h new file mode 100644 index 000000000000..135eb4bb03b4 --- /dev/null +++ b/arch/powerpc/boot/ops.h | |||
@@ -0,0 +1,100 @@ | |||
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 | ||
9 | * or implied. | ||
10 | */ | ||
11 | #ifndef _PPC_BOOT_OPS_H_ | ||
12 | #define _PPC_BOOT_OPS_H_ | ||
13 | |||
14 | #include "types.h" | ||
15 | |||
16 | #define COMMAND_LINE_SIZE 512 | ||
17 | #define MAX_PATH_LEN 256 | ||
18 | #define MAX_PROP_LEN 256 /* What should this be? */ | ||
19 | |||
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, u32 size); | ||
26 | void (*exit)(void); | ||
27 | }; | ||
28 | extern struct platform_ops platform_ops; | ||
29 | |||
30 | /* Device Tree operations */ | ||
31 | struct dt_ops { | ||
32 | void * (*finddevice)(const char *name); | ||
33 | int (*getprop)(const void *node, const char *name, void *buf, | ||
34 | const int buflen); | ||
35 | int (*setprop)(const void *node, const char *name, | ||
36 | const void *buf, const int buflen); | ||
37 | u64 (*translate_addr)(const char *path, const u32 *in_addr, | ||
38 | const u32 addr_len); | ||
39 | unsigned long (*ft_addr)(void); | ||
40 | }; | ||
41 | extern struct dt_ops dt_ops; | ||
42 | |||
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; | ||
50 | }; | ||
51 | extern struct console_ops console_ops; | ||
52 | |||
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); | ||
60 | }; | ||
61 | |||
62 | extern int platform_init(void *promptr); | ||
63 | extern void simple_alloc_init(void); | ||
64 | extern void ft_init(void *dt_blob); | ||
65 | extern int serial_console_init(void); | ||
66 | |||
67 | static inline void *finddevice(const char *name) | ||
68 | { | ||
69 | return (dt_ops.finddevice) ? dt_ops.finddevice(name) : NULL; | ||
70 | } | ||
71 | |||
72 | static 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; | ||
75 | } | ||
76 | |||
77 | static inline int setprop(void *devp, const char *name, void *buf, int buflen) | ||
78 | { | ||
79 | return (dt_ops.setprop) ? dt_ops.setprop(devp, name, buf, buflen) : -1; | ||
80 | } | ||
81 | |||
82 | static inline void *malloc(u32 size) | ||
83 | { | ||
84 | return (platform_ops.malloc) ? platform_ops.malloc(size) : NULL; | ||
85 | } | ||
86 | |||
87 | static inline void free(void *ptr, u32 size) | ||
88 | { | ||
89 | if (platform_ops.free) | ||
90 | platform_ops.free(ptr, size); | ||
91 | } | ||
92 | |||
93 | static inline void exit(void) | ||
94 | { | ||
95 | if (platform_ops.exit) | ||
96 | platform_ops.exit(); | ||
97 | for(;;); | ||
98 | } | ||
99 | |||
100 | #endif /* _PPC_BOOT_OPS_H_ */ | ||