Start arch/powerpc/boot code reorganization
PATCH 1/1 Start arch/powerpc/boot code reorganization
This is a reworked version of Mark's patches 1/6 and 2/6. This boots on powermac (newworld) and pseries (power5 partition) at least.
I intend to commit this with Mark as the author and a suitable commit message, unless there are adverse comments.
Paul.
arch/powerpc/boot/Makefile +2 -1
@@ -36,7 +36,8 @@ zliblinuxheader := zlib.h zconf.h zutil. $(addprefix $(obj)/,$(zlib) main.o): $(addprefix $(obj)/,$(zliblinuxheader)) $(addprefix $(obj)/,$(zlibheader)) #$(addprefix $(obj)/,main.o): $(addprefix $(obj)/,zlib.h) -src-boot := crt0.S string.S prom.c stdio.c main.c div64.S +src-boot-$(CONFIG_PPC_MULTIPLATFORM) := of.c +src-boot := crt0.S string.S stdio.c main.c div64.S $(src-boot-y) src-boot += $(zlib) src-boot := $(addprefix $(obj)/, $(src-boot)) obj-boot := $(addsuffix .o, $(basename $(src-boot)))
arch/powerpc/boot/main.c +129 -121
345 lines not on this page · raw message
arch/powerpc/boot/prom.c deleted +0 -165
165 lines not on this page · raw message
arch/powerpc/boot/prom.h deleted +0 -41
41 lines not on this page · raw message
arch/powerpc/boot/stdio.c +2 -2
@@ -10,7 +10,7 @@ #include <stdarg.h>#include <stddef.h> #include "string.h" #include "stdio.h" -#include "prom.h" +#include "ops.h" size_t strnlen (const char * s,size_t count) {
@@ -320,6 +320,6 @@ printf(const char *fmt, ...)va_start (args, fmt); n =vsprintf (sprint_buf, fmt, args);va_end (args); -write (stdout, sprint_buf, n); + console_ops.write (sprint_buf, n);return n; }
arch/powerpc/boot/stdio.h +8 -0
@@ -1,8 +1,16 @@#ifndef _PPC_BOOT_STDIO_H_#define _PPC_BOOT_STDIO_H_ +#include <stdarg.h> + +#define ENOMEM 12/* Out of Memory */ +#define EINVAL 22/* Invalid argument */ +#define ENOSPC 28/* No space left on device */ +extern int printf (const char *fmt, ...); +#define fprintf(fmt, args...) printf(args) +extern int sprintf (char *buf,const char *fmt, ...);extern int vsprintf (char *buf,const char *fmt,va_list args);
powerpc/boot/flatdevtree.h new file +46 -0
46 lines not on this page · raw message
powerpc/boot/of.c new file +283 -0
283 lines not on this page · raw message
powerpc/boot/types.h new file +23 -0
@@ -0,0 +1,23 @@ +#ifndef _TYPES_H_ +#define _TYPES_H_ + +#define ARRAY_SIZE (x) (sizeof(x) / sizeof((x)[0])) + +typedef unsigned char u8 ; +typedef unsigned short u16 ; +typedef unsigned int u32 ; +typedef unsigned long long u64 ; + +#define min (x,y) ({ \ + typeof(x) _x = (x); \ + typeof(y) _y = (y); \ + (void) (&_x == &_y); \ + _x < _y ? _x : _y; }) + +#define max (x,y) ({ \ + typeof(x) _x = (x); \ + typeof(y) _y = (y); \ + (void) (&_x == &_y); \ + _x > _y ? _x : _y; }) + +#endif /* _TYPES_H_ */
Quoted 12 lines · Paul Mackerras
This is a reworked version of Mark's patches 1/6 and 2/6. This boots on powermac (newworld) and pseries (power5 partition) at least.
powerpc/boot/of.c new file +6
-0@@ -0,0 +1,283 @@ +/* +* Copyright (C) Paul Mackerras 1997. +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License +* as published by the Free Software Foundation; either version
powerpc/boot/of.c line 16
Quoted 10 lines
powerpc/boot/of.c new file +10
-0+* 2 of the License, or (at your option) any later version. +*/ +#include <stdarg.h> +#include <stddef.h> +#include "types.h" +#include "elf.h" +#include "string.h" +#include "stdio.h" +#include "page.h" +#include "ops.h"
Where do I get ops.h?
cheers
Signature · 8 lines
Michael Ellerman OzLabs, IBM Australia Development Lab wwweb: http://michael.ellerman.id.au phone: +61 2 6212 1183 (tie line 70 21183) We do not inherit the earth from our ancestors, we borrow it from our children. - S.M.A.R.T Person
Quoted 1 line · Michael Ellerman
Where do I get
ops.h?
Oops... here it is.
Paul.
arch/powerpc/boot/ops.h new file +100 -0
@@ -0,0 +1,100 @@ +/* +* Global definition of all the bootwrapper operations. +* +* Author: Mark A. Greer <[email protected]> +* +* 2006 (c) MontaVista Software, Inc. This file is licensed under +* the terms of the GNU General Public License version 2. This program +* is licensed "as is" without any warranty of any kind, whether express +* or implied. +*/ +#ifndef _PPC_BOOT_OPS_H_ +#define _PPC_BOOT_OPS_H_ + +#include "types.h" + +#define COMMAND_LINE_SIZE 512 +#define MAX_PATH_LEN 256 +#define MAX_PROP_LEN 256/* What should this be? */ + +/* Platform specific operations */ +struct platform_ops { +void (*fixups)(void ); +void * (*malloc)(u32 size); +void (*free)(void *ptr,u32 size); +void (*exit)(void ); +}; +extern struct platform_ops platform_ops; + +/* Device Tree operations */ +struct dt_ops { +void * (*finddevice)(const char *name); +int (*getprop)(const void *node,const char *name,void *buf, +const int buflen); +int (*setprop)(const void *node,const char *name, +const void *buf,const int buflen); +u64 (*translate_addr)(const char *path,const u32 *in_addr, +const u32 addr_len); +void (*call_kernel)(void *entry_addr,unsigned long a1, +unsigned long a2,void *promptr,void *sp); +}; +extern struct dt_ops dt_ops; + +/* Console operations */ +struct console_ops { +int (*open)(void ); +void (*write)(char *buf,int len); +void (*edit_cmdline)(char *buf,int len); +void (*close)(void ); +void *data; +}; +extern struct console_ops console_ops; + +/* Serial console operations */ +struct serial_console_data { +int (*open)(void ); +void (*putc)(unsigned char c); +unsigned char (*getc)(void ); +u8 (*tstc)(void ); +void (*close)(void ); +}; + +extern int platform_init (void *promptr); +extern void simple_alloc_init (void ); +extern void ft_init (void *dt_blob); +extern int serial_console_init (void ); + +static inline void *finddevice (const char *name) +{ +return (dt_ops.finddevice) ? dt_ops.finddevice (name) :NULL ; +} + +static inline int getprop (void *devp,const char *name,void *buf,int buflen) +{ +return (dt_ops.getprop) ? dt_ops.getprop (devp, name, buf, buflen) :-1 ; +} + +static inline int setprop (void *devp,const char *name,void *buf,int buflen) +{ +return (dt_ops.setprop) ? dt_ops.setprop (devp, name, buf, buflen) :-1 ; +} + +static inline void *malloc (u32 size) +{ +return (platform_ops.malloc) ? platform_ops.malloc (size) :NULL ; +} + +static inline void free (void *ptr,u32 size) +{ +if (platform_ops.free) + platform_ops.free (ptr, size); +} + +static inline void exit (void ) +{ +if (platform_ops.exit) + platform_ops.exit (); +for (;;); +} + +#endif /* _PPC_BOOT_OPS_H_ */