blob: cad4eee599fbf824c33b582936ff9f1502f881c0 [file] [log] [blame]
Mark A. Greerb2c5f612006-09-19 14:05:08 +10001/*
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 */
21struct platform_ops {
22 void (*fixups)(void);
23 void (*image_hdr)(const void *);
24 void * (*malloc)(u32 size);
Mark A. Greerc8885542006-10-16 13:49:27 -070025 void (*free)(void *ptr);
26 void * (*realloc)(void *ptr, unsigned long size);
Mark A. Greerb2c5f612006-09-19 14:05:08 +100027 void (*exit)(void);
David Gibson79c85412007-03-05 14:24:52 +110028 void * (*vmlinux_alloc)(unsigned long size);
Mark A. Greerb2c5f612006-09-19 14:05:08 +100029};
30extern struct platform_ops platform_ops;
31
32/* Device Tree operations */
33struct dt_ops {
34 void * (*finddevice)(const char *name);
Mark A. Greerc8885542006-10-16 13:49:27 -070035 int (*getprop)(const void *phandle, const char *name, void *buf,
Mark A. Greerb2c5f612006-09-19 14:05:08 +100036 const int buflen);
Mark A. Greerc8885542006-10-16 13:49:27 -070037 int (*setprop)(const void *phandle, const char *name,
Mark A. Greerb2c5f612006-09-19 14:05:08 +100038 const void *buf, const int buflen);
David Gibson35af89e2006-11-21 11:37:37 +110039 unsigned long (*finalize)(void);
Mark A. Greerb2c5f612006-09-19 14:05:08 +100040};
41extern struct dt_ops dt_ops;
42
43/* Console operations */
44struct 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};
51extern struct console_ops console_ops;
52
53/* Serial console operations */
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
David Gibsoncd197ff2007-03-05 14:24:52 +110062struct loader_info {
63 void *promptr;
64 unsigned long initrd_addr, initrd_size;
65};
66extern struct loader_info loader_info;
67
68void start(void *sp);
Mark A. Greerc8885542006-10-16 13:49:27 -070069int ft_init(void *dt_blob, unsigned int max_size, unsigned int max_find_device);
70int serial_console_init(void);
71int ns16550_console_init(void *devp, struct serial_console_data *scdp);
72void *simple_alloc_init(char *base, u32 heap_size, u32 granularity,
73 u32 max_allocs);
74
Mark A. Greerb2c5f612006-09-19 14:05:08 +100075
76static inline void *finddevice(const char *name)
77{
78 return (dt_ops.finddevice) ? dt_ops.finddevice(name) : NULL;
79}
80
81static inline int getprop(void *devp, const char *name, void *buf, int buflen)
82{
83 return (dt_ops.getprop) ? dt_ops.getprop(devp, name, buf, buflen) : -1;
84}
85
86static inline int setprop(void *devp, const char *name, void *buf, int buflen)
87{
88 return (dt_ops.setprop) ? dt_ops.setprop(devp, name, buf, buflen) : -1;
89}
90
91static inline void *malloc(u32 size)
92{
93 return (platform_ops.malloc) ? platform_ops.malloc(size) : NULL;
94}
95
Mark A. Greerc8885542006-10-16 13:49:27 -070096static inline void free(void *ptr)
Mark A. Greerb2c5f612006-09-19 14:05:08 +100097{
98 if (platform_ops.free)
Mark A. Greerc8885542006-10-16 13:49:27 -070099 platform_ops.free(ptr);
Mark A. Greerb2c5f612006-09-19 14:05:08 +1000100}
101
102static inline void exit(void)
103{
104 if (platform_ops.exit)
105 platform_ops.exit();
106 for(;;);
107}
108
David Gibsoncd197ff2007-03-05 14:24:52 +1100109#define BSS_STACK(size) \
110 static char _bss_stack[size]; \
111 void *_platform_stack_top = _bss_stack + sizeof(_bss_stack);
112
Mark A. Greerb2c5f612006-09-19 14:05:08 +1000113#endif /* _PPC_BOOT_OPS_H_ */