diff options
author | Olaf Hering <olh@suse.de> | 2005-08-07 23:24:38 -0400 |
---|---|---|
committer | Paul Mackerras <paulus@samba.org> | 2005-08-28 20:53:31 -0400 |
commit | decd300b30e499fe6be1bbfc5650fc971de8c1fa (patch) | |
tree | ef4c2842b943b951130abcd0fdf844fcb53720fd /arch | |
parent | 02b3e4e2d71b6058ec11cc01c72ac651eb3ded2b (diff) |
[PATCH] ppc64: make arch/ppc64/boot standalone
Make the bootheader for ppc64 independent from kernel and libc headers.
* add -nostdinc -isystem $gccincludes to not include libc headers
* declare all functions in header files, also the stuff from string.S
* declare some functions static
* use stddef.h to get size_t (hopefully ok)
* remove ppc32-types.h, only elf.h used the __NN types
With further modifications by Paul Mackerras and Stephen Rothwell.
Signed-off-by: Olaf Hering <olh@suse.de>
Signed-off-by: Paul Mackerras <paulus@samba.org>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/ppc64/boot/Makefile | 4 | ||||
-rw-r--r-- | arch/ppc64/boot/addnote.c | 4 | ||||
-rw-r--r-- | arch/ppc64/boot/crt0.S | 2 | ||||
-rw-r--r-- | arch/ppc64/boot/div64.S | 2 | ||||
-rw-r--r-- | arch/ppc64/boot/elf.h | 149 | ||||
-rw-r--r-- | arch/ppc64/boot/main.c | 55 | ||||
-rw-r--r-- | arch/ppc64/boot/page.h | 34 | ||||
-rw-r--r-- | arch/ppc64/boot/ppc32-types.h | 36 | ||||
-rw-r--r-- | arch/ppc64/boot/ppc_asm.h | 62 | ||||
-rw-r--r-- | arch/ppc64/boot/prom.c | 196 | ||||
-rw-r--r-- | arch/ppc64/boot/prom.h | 18 | ||||
-rw-r--r-- | arch/ppc64/boot/stdio.h | 16 | ||||
-rw-r--r-- | arch/ppc64/boot/string.S | 2 | ||||
-rw-r--r-- | arch/ppc64/boot/string.h | 16 | ||||
-rw-r--r-- | arch/ppc64/boot/zlib.c | 2 |
15 files changed, 350 insertions, 248 deletions
diff --git a/arch/ppc64/boot/Makefile b/arch/ppc64/boot/Makefile index 683b2d43c15f..2c5f5e73d00c 100644 --- a/arch/ppc64/boot/Makefile +++ b/arch/ppc64/boot/Makefile | |||
@@ -22,8 +22,8 @@ | |||
22 | 22 | ||
23 | 23 | ||
24 | HOSTCC := gcc | 24 | HOSTCC := gcc |
25 | BOOTCFLAGS := $(HOSTCFLAGS) $(LINUXINCLUDE) -fno-builtin | 25 | BOOTCFLAGS := $(HOSTCFLAGS) -fno-builtin -nostdinc -isystem $(shell $(CROSS32CC) -print-file-name=include) |
26 | BOOTAFLAGS := -D__ASSEMBLY__ $(BOOTCFLAGS) -traditional | 26 | BOOTAFLAGS := -D__ASSEMBLY__ $(BOOTCFLAGS) -traditional -nostdinc |
27 | BOOTLFLAGS := -Ttext 0x00400000 -e _start -T $(srctree)/$(src)/zImage.lds | 27 | BOOTLFLAGS := -Ttext 0x00400000 -e _start -T $(srctree)/$(src)/zImage.lds |
28 | OBJCOPYFLAGS := contents,alloc,load,readonly,data | 28 | OBJCOPYFLAGS := contents,alloc,load,readonly,data |
29 | 29 | ||
diff --git a/arch/ppc64/boot/addnote.c b/arch/ppc64/boot/addnote.c index 719663a694bb..8041a9845ab7 100644 --- a/arch/ppc64/boot/addnote.c +++ b/arch/ppc64/boot/addnote.c | |||
@@ -157,7 +157,7 @@ main(int ac, char **av) | |||
157 | PUT_32BE(ns, strlen(arch) + 1); | 157 | PUT_32BE(ns, strlen(arch) + 1); |
158 | PUT_32BE(ns + 4, N_DESCR * 4); | 158 | PUT_32BE(ns + 4, N_DESCR * 4); |
159 | PUT_32BE(ns + 8, 0x1275); | 159 | PUT_32BE(ns + 8, 0x1275); |
160 | strcpy(&buf[ns + 12], arch); | 160 | strcpy((char *) &buf[ns + 12], arch); |
161 | ns += 12 + strlen(arch) + 1; | 161 | ns += 12 + strlen(arch) + 1; |
162 | for (i = 0; i < N_DESCR; ++i, ns += 4) | 162 | for (i = 0; i < N_DESCR; ++i, ns += 4) |
163 | PUT_32BE(ns, descr[i]); | 163 | PUT_32BE(ns, descr[i]); |
@@ -172,7 +172,7 @@ main(int ac, char **av) | |||
172 | PUT_32BE(ns, strlen(rpaname) + 1); | 172 | PUT_32BE(ns, strlen(rpaname) + 1); |
173 | PUT_32BE(ns + 4, sizeof(rpanote)); | 173 | PUT_32BE(ns + 4, sizeof(rpanote)); |
174 | PUT_32BE(ns + 8, 0x12759999); | 174 | PUT_32BE(ns + 8, 0x12759999); |
175 | strcpy(&buf[ns + 12], rpaname); | 175 | strcpy((char *) &buf[ns + 12], rpaname); |
176 | ns += 12 + ROUNDUP(strlen(rpaname) + 1); | 176 | ns += 12 + ROUNDUP(strlen(rpaname) + 1); |
177 | for (i = 0; i < N_RPA_DESCR; ++i, ns += 4) | 177 | for (i = 0; i < N_RPA_DESCR; ++i, ns += 4) |
178 | PUT_32BE(ns, rpanote[i]); | 178 | PUT_32BE(ns, rpanote[i]); |
diff --git a/arch/ppc64/boot/crt0.S b/arch/ppc64/boot/crt0.S index 04d3e74cd72f..3861e7f9cf19 100644 --- a/arch/ppc64/boot/crt0.S +++ b/arch/ppc64/boot/crt0.S | |||
@@ -9,7 +9,7 @@ | |||
9 | * NOTE: this code runs in 32 bit mode and is packaged as ELF32. | 9 | * NOTE: this code runs in 32 bit mode and is packaged as ELF32. |
10 | */ | 10 | */ |
11 | 11 | ||
12 | #include <asm/ppc_asm.h> | 12 | #include "ppc_asm.h" |
13 | 13 | ||
14 | .text | 14 | .text |
15 | .globl _start | 15 | .globl _start |
diff --git a/arch/ppc64/boot/div64.S b/arch/ppc64/boot/div64.S index 38f7e466d7d6..722f360a32a9 100644 --- a/arch/ppc64/boot/div64.S +++ b/arch/ppc64/boot/div64.S | |||
@@ -13,7 +13,7 @@ | |||
13 | * as published by the Free Software Foundation; either version | 13 | * as published by the Free Software Foundation; either version |
14 | * 2 of the License, or (at your option) any later version. | 14 | * 2 of the License, or (at your option) any later version. |
15 | */ | 15 | */ |
16 | #include <asm/ppc_asm.h> | 16 | #include "ppc_asm.h" |
17 | 17 | ||
18 | .globl __div64_32 | 18 | .globl __div64_32 |
19 | __div64_32: | 19 | __div64_32: |
diff --git a/arch/ppc64/boot/elf.h b/arch/ppc64/boot/elf.h new file mode 100644 index 000000000000..d4828fcf1cb9 --- /dev/null +++ b/arch/ppc64/boot/elf.h | |||
@@ -0,0 +1,149 @@ | |||
1 | #ifndef _PPC_BOOT_ELF_H_ | ||
2 | #define _PPC_BOOT_ELF_H_ | ||
3 | |||
4 | /* 32-bit ELF base types. */ | ||
5 | typedef unsigned int Elf32_Addr; | ||
6 | typedef unsigned short Elf32_Half; | ||
7 | typedef unsigned int Elf32_Off; | ||
8 | typedef signed int Elf32_Sword; | ||
9 | typedef unsigned int Elf32_Word; | ||
10 | |||
11 | /* 64-bit ELF base types. */ | ||
12 | typedef unsigned long long Elf64_Addr; | ||
13 | typedef unsigned short Elf64_Half; | ||
14 | typedef signed short Elf64_SHalf; | ||
15 | typedef unsigned long long Elf64_Off; | ||
16 | typedef signed int Elf64_Sword; | ||
17 | typedef unsigned int Elf64_Word; | ||
18 | typedef unsigned long long Elf64_Xword; | ||
19 | typedef signed long long Elf64_Sxword; | ||
20 | |||
21 | /* These constants are for the segment types stored in the image headers */ | ||
22 | #define PT_NULL 0 | ||
23 | #define PT_LOAD 1 | ||
24 | #define PT_DYNAMIC 2 | ||
25 | #define PT_INTERP 3 | ||
26 | #define PT_NOTE 4 | ||
27 | #define PT_SHLIB 5 | ||
28 | #define PT_PHDR 6 | ||
29 | #define PT_TLS 7 /* Thread local storage segment */ | ||
30 | #define PT_LOOS 0x60000000 /* OS-specific */ | ||
31 | #define PT_HIOS 0x6fffffff /* OS-specific */ | ||
32 | #define PT_LOPROC 0x70000000 | ||
33 | #define PT_HIPROC 0x7fffffff | ||
34 | #define PT_GNU_EH_FRAME 0x6474e550 | ||
35 | |||
36 | #define PT_GNU_STACK (PT_LOOS + 0x474e551) | ||
37 | |||
38 | /* These constants define the different elf file types */ | ||
39 | #define ET_NONE 0 | ||
40 | #define ET_REL 1 | ||
41 | #define ET_EXEC 2 | ||
42 | #define ET_DYN 3 | ||
43 | #define ET_CORE 4 | ||
44 | #define ET_LOPROC 0xff00 | ||
45 | #define ET_HIPROC 0xffff | ||
46 | |||
47 | /* These constants define the various ELF target machines */ | ||
48 | #define EM_NONE 0 | ||
49 | #define EM_PPC 20 /* PowerPC */ | ||
50 | #define EM_PPC64 21 /* PowerPC64 */ | ||
51 | |||
52 | #define EI_NIDENT 16 | ||
53 | |||
54 | typedef struct elf32_hdr { | ||
55 | unsigned char e_ident[EI_NIDENT]; | ||
56 | Elf32_Half e_type; | ||
57 | Elf32_Half e_machine; | ||
58 | Elf32_Word e_version; | ||
59 | Elf32_Addr e_entry; /* Entry point */ | ||
60 | Elf32_Off e_phoff; | ||
61 | Elf32_Off e_shoff; | ||
62 | Elf32_Word e_flags; | ||
63 | Elf32_Half e_ehsize; | ||
64 | Elf32_Half e_phentsize; | ||
65 | Elf32_Half e_phnum; | ||
66 | Elf32_Half e_shentsize; | ||
67 | Elf32_Half e_shnum; | ||
68 | Elf32_Half e_shstrndx; | ||
69 | } Elf32_Ehdr; | ||
70 | |||
71 | typedef struct elf64_hdr { | ||
72 | unsigned char e_ident[16]; /* ELF "magic number" */ | ||
73 | Elf64_Half e_type; | ||
74 | Elf64_Half e_machine; | ||
75 | Elf64_Word e_version; | ||
76 | Elf64_Addr e_entry; /* Entry point virtual address */ | ||
77 | Elf64_Off e_phoff; /* Program header table file offset */ | ||
78 | Elf64_Off e_shoff; /* Section header table file offset */ | ||
79 | Elf64_Word e_flags; | ||
80 | Elf64_Half e_ehsize; | ||
81 | Elf64_Half e_phentsize; | ||
82 | Elf64_Half e_phnum; | ||
83 | Elf64_Half e_shentsize; | ||
84 | Elf64_Half e_shnum; | ||
85 | Elf64_Half e_shstrndx; | ||
86 | } Elf64_Ehdr; | ||
87 | |||
88 | /* These constants define the permissions on sections in the program | ||
89 | header, p_flags. */ | ||
90 | #define PF_R 0x4 | ||
91 | #define PF_W 0x2 | ||
92 | #define PF_X 0x1 | ||
93 | |||
94 | typedef struct elf32_phdr { | ||
95 | Elf32_Word p_type; | ||
96 | Elf32_Off p_offset; | ||
97 | Elf32_Addr p_vaddr; | ||
98 | Elf32_Addr p_paddr; | ||
99 | Elf32_Word p_filesz; | ||
100 | Elf32_Word p_memsz; | ||
101 | Elf32_Word p_flags; | ||
102 | Elf32_Word p_align; | ||
103 | } Elf32_Phdr; | ||
104 | |||
105 | typedef struct elf64_phdr { | ||
106 | Elf64_Word p_type; | ||
107 | Elf64_Word p_flags; | ||
108 | Elf64_Off p_offset; /* Segment file offset */ | ||
109 | Elf64_Addr p_vaddr; /* Segment virtual address */ | ||
110 | Elf64_Addr p_paddr; /* Segment physical address */ | ||
111 | Elf64_Xword p_filesz; /* Segment size in file */ | ||
112 | Elf64_Xword p_memsz; /* Segment size in memory */ | ||
113 | Elf64_Xword p_align; /* Segment alignment, file & memory */ | ||
114 | } Elf64_Phdr; | ||
115 | |||
116 | #define EI_MAG0 0 /* e_ident[] indexes */ | ||
117 | #define EI_MAG1 1 | ||
118 | #define EI_MAG2 2 | ||
119 | #define EI_MAG3 3 | ||
120 | #define EI_CLASS 4 | ||
121 | #define EI_DATA 5 | ||
122 | #define EI_VERSION 6 | ||
123 | #define EI_OSABI 7 | ||
124 | #define EI_PAD 8 | ||
125 | |||
126 | #define ELFMAG0 0x7f /* EI_MAG */ | ||
127 | #define ELFMAG1 'E' | ||
128 | #define ELFMAG2 'L' | ||
129 | #define ELFMAG3 'F' | ||
130 | #define ELFMAG "\177ELF" | ||
131 | #define SELFMAG 4 | ||
132 | |||
133 | #define ELFCLASSNONE 0 /* EI_CLASS */ | ||
134 | #define ELFCLASS32 1 | ||
135 | #define ELFCLASS64 2 | ||
136 | #define ELFCLASSNUM 3 | ||
137 | |||
138 | #define ELFDATANONE 0 /* e_ident[EI_DATA] */ | ||
139 | #define ELFDATA2LSB 1 | ||
140 | #define ELFDATA2MSB 2 | ||
141 | |||
142 | #define EV_NONE 0 /* e_version, EI_VERSION */ | ||
143 | #define EV_CURRENT 1 | ||
144 | #define EV_NUM 2 | ||
145 | |||
146 | #define ELFOSABI_NONE 0 | ||
147 | #define ELFOSABI_LINUX 3 | ||
148 | |||
149 | #endif /* _PPC_BOOT_ELF_H_ */ | ||
diff --git a/arch/ppc64/boot/main.c b/arch/ppc64/boot/main.c index 199d9804f61c..99e68cfbe688 100644 --- a/arch/ppc64/boot/main.c +++ b/arch/ppc64/boot/main.c | |||
@@ -8,36 +8,28 @@ | |||
8 | * as published by the Free Software Foundation; either version | 8 | * as published by the Free Software Foundation; either version |
9 | * 2 of the License, or (at your option) any later version. | 9 | * 2 of the License, or (at your option) any later version. |
10 | */ | 10 | */ |
11 | #include "ppc32-types.h" | 11 | #include <stdarg.h> |
12 | #include <stddef.h> | ||
13 | #include "elf.h" | ||
14 | #include "page.h" | ||
15 | #include "string.h" | ||
16 | #include "stdio.h" | ||
17 | #include "prom.h" | ||
12 | #include "zlib.h" | 18 | #include "zlib.h" |
13 | #include <linux/elf.h> | 19 | |
14 | #include <linux/string.h> | 20 | static void gunzip(void *, int, unsigned char *, int *); |
15 | #include <asm/processor.h> | 21 | extern void flush_cache(void *, unsigned long); |
16 | #include <asm/page.h> | 22 | |
17 | |||
18 | extern void *finddevice(const char *); | ||
19 | extern int getprop(void *, const char *, void *, int); | ||
20 | extern void printf(const char *fmt, ...); | ||
21 | extern int sprintf(char *buf, const char *fmt, ...); | ||
22 | void gunzip(void *, int, unsigned char *, int *); | ||
23 | void *claim(unsigned int, unsigned int, unsigned int); | ||
24 | void flush_cache(void *, unsigned long); | ||
25 | void pause(void); | ||
26 | extern void exit(void); | ||
27 | |||
28 | unsigned long strlen(const char *s); | ||
29 | void *memmove(void *dest, const void *src, unsigned long n); | ||
30 | void *memcpy(void *dest, const void *src, unsigned long n); | ||
31 | 23 | ||
32 | /* Value picked to match that used by yaboot */ | 24 | /* Value picked to match that used by yaboot */ |
33 | #define PROG_START 0x01400000 | 25 | #define PROG_START 0x01400000 |
34 | #define RAM_END (256<<20) // Fixme: use OF */ | 26 | #define RAM_END (256<<20) // Fixme: use OF */ |
35 | 27 | ||
36 | char *avail_ram; | 28 | static char *avail_ram; |
37 | char *begin_avail, *end_avail; | 29 | static char *begin_avail, *end_avail; |
38 | char *avail_high; | 30 | static char *avail_high; |
39 | unsigned int heap_use; | 31 | static unsigned int heap_use; |
40 | unsigned int heap_max; | 32 | static unsigned int heap_max; |
41 | 33 | ||
42 | extern char _start[]; | 34 | extern char _start[]; |
43 | extern char _vmlinux_start[]; | 35 | extern char _vmlinux_start[]; |
@@ -52,9 +44,9 @@ struct addr_range { | |||
52 | unsigned long size; | 44 | unsigned long size; |
53 | unsigned long memsize; | 45 | unsigned long memsize; |
54 | }; | 46 | }; |
55 | struct addr_range vmlinux = {0, 0, 0}; | 47 | static struct addr_range vmlinux = {0, 0, 0}; |
56 | struct addr_range vmlinuz = {0, 0, 0}; | 48 | static struct addr_range vmlinuz = {0, 0, 0}; |
57 | struct addr_range initrd = {0, 0, 0}; | 49 | static struct addr_range initrd = {0, 0, 0}; |
58 | 50 | ||
59 | static char scratch[128<<10]; /* 128kB of scratch space for gunzip */ | 51 | static char scratch[128<<10]; /* 128kB of scratch space for gunzip */ |
60 | 52 | ||
@@ -64,13 +56,6 @@ typedef void (*kernel_entry_t)( unsigned long, | |||
64 | void *); | 56 | void *); |
65 | 57 | ||
66 | 58 | ||
67 | int (*prom)(void *); | ||
68 | |||
69 | void *chosen_handle; | ||
70 | void *stdin; | ||
71 | void *stdout; | ||
72 | void *stderr; | ||
73 | |||
74 | #undef DEBUG | 59 | #undef DEBUG |
75 | 60 | ||
76 | static unsigned long claim_base = PROG_START; | 61 | static unsigned long claim_base = PROG_START; |
@@ -277,7 +262,7 @@ void zfree(void *x, void *addr, unsigned nb) | |||
277 | 262 | ||
278 | #define DEFLATED 8 | 263 | #define DEFLATED 8 |
279 | 264 | ||
280 | void gunzip(void *dst, int dstlen, unsigned char *src, int *lenp) | 265 | static void gunzip(void *dst, int dstlen, unsigned char *src, int *lenp) |
281 | { | 266 | { |
282 | z_stream s; | 267 | z_stream s; |
283 | int r, i, flags; | 268 | int r, i, flags; |
diff --git a/arch/ppc64/boot/page.h b/arch/ppc64/boot/page.h new file mode 100644 index 000000000000..14eca30fef64 --- /dev/null +++ b/arch/ppc64/boot/page.h | |||
@@ -0,0 +1,34 @@ | |||
1 | #ifndef _PPC_BOOT_PAGE_H | ||
2 | #define _PPC_BOOT_PAGE_H | ||
3 | /* | ||
4 | * Copyright (C) 2001 PPC64 Team, IBM Corp | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or | ||
7 | * modify it under the terms of the GNU General Public License | ||
8 | * as published by the Free Software Foundation; either version | ||
9 | * 2 of the License, or (at your option) any later version. | ||
10 | */ | ||
11 | |||
12 | #ifdef __ASSEMBLY__ | ||
13 | #define ASM_CONST(x) x | ||
14 | #else | ||
15 | #define __ASM_CONST(x) x##UL | ||
16 | #define ASM_CONST(x) __ASM_CONST(x) | ||
17 | #endif | ||
18 | |||
19 | /* PAGE_SHIFT determines the page size */ | ||
20 | #define PAGE_SHIFT 12 | ||
21 | #define PAGE_SIZE (ASM_CONST(1) << PAGE_SHIFT) | ||
22 | #define PAGE_MASK (~(PAGE_SIZE-1)) | ||
23 | |||
24 | /* align addr on a size boundary - adjust address up/down if needed */ | ||
25 | #define _ALIGN_UP(addr,size) (((addr)+((size)-1))&(~((size)-1))) | ||
26 | #define _ALIGN_DOWN(addr,size) ((addr)&(~((size)-1))) | ||
27 | |||
28 | /* align addr on a size boundary - adjust address up if needed */ | ||
29 | #define _ALIGN(addr,size) _ALIGN_UP(addr,size) | ||
30 | |||
31 | /* to align the pointer to the (next) page boundary */ | ||
32 | #define PAGE_ALIGN(addr) _ALIGN(addr, PAGE_SIZE) | ||
33 | |||
34 | #endif /* _PPC_BOOT_PAGE_H */ | ||
diff --git a/arch/ppc64/boot/ppc32-types.h b/arch/ppc64/boot/ppc32-types.h deleted file mode 100644 index f7b8884f8f70..000000000000 --- a/arch/ppc64/boot/ppc32-types.h +++ /dev/null | |||
@@ -1,36 +0,0 @@ | |||
1 | #ifndef _PPC64_TYPES_H | ||
2 | #define _PPC64_TYPES_H | ||
3 | |||
4 | typedef __signed__ char __s8; | ||
5 | typedef unsigned char __u8; | ||
6 | |||
7 | typedef __signed__ short __s16; | ||
8 | typedef unsigned short __u16; | ||
9 | |||
10 | typedef __signed__ int __s32; | ||
11 | typedef unsigned int __u32; | ||
12 | |||
13 | typedef __signed__ long long __s64; | ||
14 | typedef unsigned long long __u64; | ||
15 | |||
16 | typedef signed char s8; | ||
17 | typedef unsigned char u8; | ||
18 | |||
19 | typedef signed short s16; | ||
20 | typedef unsigned short u16; | ||
21 | |||
22 | typedef signed int s32; | ||
23 | typedef unsigned int u32; | ||
24 | |||
25 | typedef signed long long s64; | ||
26 | typedef unsigned long long u64; | ||
27 | |||
28 | typedef struct { | ||
29 | __u32 u[4]; | ||
30 | } __attribute((aligned(16))) __vector128; | ||
31 | |||
32 | #define BITS_PER_LONG 32 | ||
33 | |||
34 | typedef __vector128 vector128; | ||
35 | |||
36 | #endif /* _PPC64_TYPES_H */ | ||
diff --git a/arch/ppc64/boot/ppc_asm.h b/arch/ppc64/boot/ppc_asm.h new file mode 100644 index 000000000000..1c2c2817f9b7 --- /dev/null +++ b/arch/ppc64/boot/ppc_asm.h | |||
@@ -0,0 +1,62 @@ | |||
1 | #ifndef _PPC64_PPC_ASM_H | ||
2 | #define _PPC64_PPC_ASM_H | ||
3 | /* | ||
4 | * | ||
5 | * Definitions used by various bits of low-level assembly code on PowerPC. | ||
6 | * | ||
7 | * Copyright (C) 1995-1999 Gary Thomas, Paul Mackerras, Cort Dougan. | ||
8 | * | ||
9 | * This program is free software; you can redistribute it and/or | ||
10 | * modify it under the terms of the GNU General Public License | ||
11 | * as published by the Free Software Foundation; either version | ||
12 | * 2 of the License, or (at your option) any later version. | ||
13 | */ | ||
14 | |||
15 | /* Condition Register Bit Fields */ | ||
16 | |||
17 | #define cr0 0 | ||
18 | #define cr1 1 | ||
19 | #define cr2 2 | ||
20 | #define cr3 3 | ||
21 | #define cr4 4 | ||
22 | #define cr5 5 | ||
23 | #define cr6 6 | ||
24 | #define cr7 7 | ||
25 | |||
26 | |||
27 | /* General Purpose Registers (GPRs) */ | ||
28 | |||
29 | #define r0 0 | ||
30 | #define r1 1 | ||
31 | #define r2 2 | ||
32 | #define r3 3 | ||
33 | #define r4 4 | ||
34 | #define r5 5 | ||
35 | #define r6 6 | ||
36 | #define r7 7 | ||
37 | #define r8 8 | ||
38 | #define r9 9 | ||
39 | #define r10 10 | ||
40 | #define r11 11 | ||
41 | #define r12 12 | ||
42 | #define r13 13 | ||
43 | #define r14 14 | ||
44 | #define r15 15 | ||
45 | #define r16 16 | ||
46 | #define r17 17 | ||
47 | #define r18 18 | ||
48 | #define r19 19 | ||
49 | #define r20 20 | ||
50 | #define r21 21 | ||
51 | #define r22 22 | ||
52 | #define r23 23 | ||
53 | #define r24 24 | ||
54 | #define r25 25 | ||
55 | #define r26 26 | ||
56 | #define r27 27 | ||
57 | #define r28 28 | ||
58 | #define r29 29 | ||
59 | #define r30 30 | ||
60 | #define r31 31 | ||
61 | |||
62 | #endif /* _PPC64_PPC_ASM_H */ | ||
diff --git a/arch/ppc64/boot/prom.c b/arch/ppc64/boot/prom.c index 5e48b80ff5a0..4bea2f4dcb06 100644 --- a/arch/ppc64/boot/prom.c +++ b/arch/ppc64/boot/prom.c | |||
@@ -7,43 +7,19 @@ | |||
7 | * 2 of the License, or (at your option) any later version. | 7 | * 2 of the License, or (at your option) any later version. |
8 | */ | 8 | */ |
9 | #include <stdarg.h> | 9 | #include <stdarg.h> |
10 | #include <linux/types.h> | 10 | #include <stddef.h> |
11 | #include <linux/string.h> | 11 | #include "string.h" |
12 | #include <linux/ctype.h> | 12 | #include "stdio.h" |
13 | 13 | #include "prom.h" | |
14 | extern __u32 __div64_32(unsigned long long *dividend, __u32 divisor); | ||
15 | |||
16 | /* The unnecessary pointer compare is there | ||
17 | * to check for type safety (n must be 64bit) | ||
18 | */ | ||
19 | # define do_div(n,base) ({ \ | ||
20 | __u32 __base = (base); \ | ||
21 | __u32 __rem; \ | ||
22 | (void)(((typeof((n)) *)0) == ((unsigned long long *)0)); \ | ||
23 | if (((n) >> 32) == 0) { \ | ||
24 | __rem = (__u32)(n) % __base; \ | ||
25 | (n) = (__u32)(n) / __base; \ | ||
26 | } else \ | ||
27 | __rem = __div64_32(&(n), __base); \ | ||
28 | __rem; \ | ||
29 | }) | ||
30 | 14 | ||
31 | int (*prom)(void *); | 15 | int (*prom)(void *); |
32 | 16 | ||
33 | void *chosen_handle; | 17 | void *chosen_handle; |
18 | |||
34 | void *stdin; | 19 | void *stdin; |
35 | void *stdout; | 20 | void *stdout; |
36 | void *stderr; | 21 | void *stderr; |
37 | 22 | ||
38 | void exit(void); | ||
39 | void *finddevice(const char *name); | ||
40 | int getprop(void *phandle, const char *name, void *buf, int buflen); | ||
41 | void chrpboot(int a1, int a2, void *prom); /* in main.c */ | ||
42 | |||
43 | int printf(char *fmt, ...); | ||
44 | |||
45 | /* there is no convenient header to get this from... -- paulus */ | ||
46 | extern unsigned long strlen(const char *); | ||
47 | 23 | ||
48 | int | 24 | int |
49 | write(void *handle, void *ptr, int nb) | 25 | write(void *handle, void *ptr, int nb) |
@@ -210,107 +186,6 @@ fputs(char *str, void *f) | |||
210 | return write(f, str, n) == n? 0: -1; | 186 | return write(f, str, n) == n? 0: -1; |
211 | } | 187 | } |
212 | 188 | ||
213 | int | ||
214 | readchar(void) | ||
215 | { | ||
216 | char ch; | ||
217 | |||
218 | for (;;) { | ||
219 | switch (read(stdin, &ch, 1)) { | ||
220 | case 1: | ||
221 | return ch; | ||
222 | case -1: | ||
223 | printf("read(stdin) returned -1\r\n"); | ||
224 | return -1; | ||
225 | } | ||
226 | } | ||
227 | } | ||
228 | |||
229 | static char line[256]; | ||
230 | static char *lineptr; | ||
231 | static int lineleft; | ||
232 | |||
233 | int | ||
234 | getchar(void) | ||
235 | { | ||
236 | int c; | ||
237 | |||
238 | if (lineleft == 0) { | ||
239 | lineptr = line; | ||
240 | for (;;) { | ||
241 | c = readchar(); | ||
242 | if (c == -1 || c == 4) | ||
243 | break; | ||
244 | if (c == '\r' || c == '\n') { | ||
245 | *lineptr++ = '\n'; | ||
246 | putchar('\n'); | ||
247 | break; | ||
248 | } | ||
249 | switch (c) { | ||
250 | case 0177: | ||
251 | case '\b': | ||
252 | if (lineptr > line) { | ||
253 | putchar('\b'); | ||
254 | putchar(' '); | ||
255 | putchar('\b'); | ||
256 | --lineptr; | ||
257 | } | ||
258 | break; | ||
259 | case 'U' & 0x1F: | ||
260 | while (lineptr > line) { | ||
261 | putchar('\b'); | ||
262 | putchar(' '); | ||
263 | putchar('\b'); | ||
264 | --lineptr; | ||
265 | } | ||
266 | break; | ||
267 | default: | ||
268 | if (lineptr >= &line[sizeof(line) - 1]) | ||
269 | putchar('\a'); | ||
270 | else { | ||
271 | putchar(c); | ||
272 | *lineptr++ = c; | ||
273 | } | ||
274 | } | ||
275 | } | ||
276 | lineleft = lineptr - line; | ||
277 | lineptr = line; | ||
278 | } | ||
279 | if (lineleft == 0) | ||
280 | return -1; | ||
281 | --lineleft; | ||
282 | return *lineptr++; | ||
283 | } | ||
284 | |||
285 | |||
286 | |||
287 | /* String functions lifted from lib/vsprintf.c and lib/ctype.c */ | ||
288 | unsigned char _ctype[] = { | ||
289 | _C,_C,_C,_C,_C,_C,_C,_C, /* 0-7 */ | ||
290 | _C,_C|_S,_C|_S,_C|_S,_C|_S,_C|_S,_C,_C, /* 8-15 */ | ||
291 | _C,_C,_C,_C,_C,_C,_C,_C, /* 16-23 */ | ||
292 | _C,_C,_C,_C,_C,_C,_C,_C, /* 24-31 */ | ||
293 | _S|_SP,_P,_P,_P,_P,_P,_P,_P, /* 32-39 */ | ||
294 | _P,_P,_P,_P,_P,_P,_P,_P, /* 40-47 */ | ||
295 | _D,_D,_D,_D,_D,_D,_D,_D, /* 48-55 */ | ||
296 | _D,_D,_P,_P,_P,_P,_P,_P, /* 56-63 */ | ||
297 | _P,_U|_X,_U|_X,_U|_X,_U|_X,_U|_X,_U|_X,_U, /* 64-71 */ | ||
298 | _U,_U,_U,_U,_U,_U,_U,_U, /* 72-79 */ | ||
299 | _U,_U,_U,_U,_U,_U,_U,_U, /* 80-87 */ | ||
300 | _U,_U,_U,_P,_P,_P,_P,_P, /* 88-95 */ | ||
301 | _P,_L|_X,_L|_X,_L|_X,_L|_X,_L|_X,_L|_X,_L, /* 96-103 */ | ||
302 | _L,_L,_L,_L,_L,_L,_L,_L, /* 104-111 */ | ||
303 | _L,_L,_L,_L,_L,_L,_L,_L, /* 112-119 */ | ||
304 | _L,_L,_L,_P,_P,_P,_P,_C, /* 120-127 */ | ||
305 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 128-143 */ | ||
306 | 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 144-159 */ | ||
307 | _S|_SP,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P, /* 160-175 */ | ||
308 | _P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P,_P, /* 176-191 */ | ||
309 | _U,_U,_U,_U,_U,_U,_U,_U,_U,_U,_U,_U,_U,_U,_U,_U, /* 192-207 */ | ||
310 | _U,_U,_U,_U,_U,_U,_U,_P,_U,_U,_U,_U,_U,_U,_U,_L, /* 208-223 */ | ||
311 | _L,_L,_L,_L,_L,_L,_L,_L,_L,_L,_L,_L,_L,_L,_L,_L, /* 224-239 */ | ||
312 | _L,_L,_L,_L,_L,_L,_L,_P,_L,_L,_L,_L,_L,_L,_L,_L}; /* 240-255 */ | ||
313 | |||
314 | size_t strnlen(const char * s, size_t count) | 189 | size_t strnlen(const char * s, size_t count) |
315 | { | 190 | { |
316 | const char *sc; | 191 | const char *sc; |
@@ -320,44 +195,30 @@ size_t strnlen(const char * s, size_t count) | |||
320 | return sc - s; | 195 | return sc - s; |
321 | } | 196 | } |
322 | 197 | ||
323 | unsigned long simple_strtoul(const char *cp,char **endp,unsigned int base) | 198 | extern unsigned int __div64_32(unsigned long long *dividend, |
324 | { | 199 | unsigned int divisor); |
325 | unsigned long result = 0,value; | ||
326 | 200 | ||
327 | if (!base) { | 201 | /* The unnecessary pointer compare is there |
328 | base = 10; | 202 | * to check for type safety (n must be 64bit) |
329 | if (*cp == '0') { | 203 | */ |
330 | base = 8; | 204 | # define do_div(n,base) ({ \ |
331 | cp++; | 205 | unsigned int __base = (base); \ |
332 | if ((*cp == 'x') && isxdigit(cp[1])) { | 206 | unsigned int __rem; \ |
333 | cp++; | 207 | (void)(((typeof((n)) *)0) == ((unsigned long long *)0)); \ |
334 | base = 16; | 208 | if (((n) >> 32) == 0) { \ |
335 | } | 209 | __rem = (unsigned int)(n) % __base; \ |
336 | } | 210 | (n) = (unsigned int)(n) / __base; \ |
337 | } | 211 | } else \ |
338 | while (isxdigit(*cp) && | 212 | __rem = __div64_32(&(n), __base); \ |
339 | (value = isdigit(*cp) ? *cp-'0' : toupper(*cp)-'A'+10) < base) { | 213 | __rem; \ |
340 | result = result*base + value; | 214 | }) |
341 | cp++; | ||
342 | } | ||
343 | if (endp) | ||
344 | *endp = (char *)cp; | ||
345 | return result; | ||
346 | } | ||
347 | |||
348 | long simple_strtol(const char *cp,char **endp,unsigned int base) | ||
349 | { | ||
350 | if(*cp=='-') | ||
351 | return -simple_strtoul(cp+1,endp,base); | ||
352 | return simple_strtoul(cp,endp,base); | ||
353 | } | ||
354 | 215 | ||
355 | static int skip_atoi(const char **s) | 216 | static int skip_atoi(const char **s) |
356 | { | 217 | { |
357 | int i=0; | 218 | int i, c; |
358 | 219 | ||
359 | while (isdigit(**s)) | 220 | for (i = 0; '0' <= (c = **s) && c <= '9'; ++*s) |
360 | i = i*10 + *((*s)++) - '0'; | 221 | i = i*10 + c - '0'; |
361 | return i; | 222 | return i; |
362 | } | 223 | } |
363 | 224 | ||
@@ -436,9 +297,6 @@ static char * number(char * str, unsigned long long num, int base, int size, int | |||
436 | return str; | 297 | return str; |
437 | } | 298 | } |
438 | 299 | ||
439 | /* Forward decl. needed for IP address printing stuff... */ | ||
440 | int sprintf(char * buf, const char *fmt, ...); | ||
441 | |||
442 | int vsprintf(char *buf, const char *fmt, va_list args) | 300 | int vsprintf(char *buf, const char *fmt, va_list args) |
443 | { | 301 | { |
444 | int len; | 302 | int len; |
@@ -477,7 +335,7 @@ int vsprintf(char *buf, const char *fmt, va_list args) | |||
477 | 335 | ||
478 | /* get field width */ | 336 | /* get field width */ |
479 | field_width = -1; | 337 | field_width = -1; |
480 | if (isdigit(*fmt)) | 338 | if ('0' <= *fmt && *fmt <= '9') |
481 | field_width = skip_atoi(&fmt); | 339 | field_width = skip_atoi(&fmt); |
482 | else if (*fmt == '*') { | 340 | else if (*fmt == '*') { |
483 | ++fmt; | 341 | ++fmt; |
@@ -493,7 +351,7 @@ int vsprintf(char *buf, const char *fmt, va_list args) | |||
493 | precision = -1; | 351 | precision = -1; |
494 | if (*fmt == '.') { | 352 | if (*fmt == '.') { |
495 | ++fmt; | 353 | ++fmt; |
496 | if (isdigit(*fmt)) | 354 | if ('0' <= *fmt && *fmt <= '9') |
497 | precision = skip_atoi(&fmt); | 355 | precision = skip_atoi(&fmt); |
498 | else if (*fmt == '*') { | 356 | else if (*fmt == '*') { |
499 | ++fmt; | 357 | ++fmt; |
@@ -628,7 +486,7 @@ int sprintf(char * buf, const char *fmt, ...) | |||
628 | static char sprint_buf[1024]; | 486 | static char sprint_buf[1024]; |
629 | 487 | ||
630 | int | 488 | int |
631 | printf(char *fmt, ...) | 489 | printf(const char *fmt, ...) |
632 | { | 490 | { |
633 | va_list args; | 491 | va_list args; |
634 | int n; | 492 | int n; |
diff --git a/arch/ppc64/boot/prom.h b/arch/ppc64/boot/prom.h new file mode 100644 index 000000000000..96ab5aec740c --- /dev/null +++ b/arch/ppc64/boot/prom.h | |||
@@ -0,0 +1,18 @@ | |||
1 | #ifndef _PPC_BOOT_PROM_H_ | ||
2 | #define _PPC_BOOT_PROM_H_ | ||
3 | |||
4 | extern int (*prom) (void *); | ||
5 | extern void *chosen_handle; | ||
6 | |||
7 | extern void *stdin; | ||
8 | extern void *stdout; | ||
9 | extern void *stderr; | ||
10 | |||
11 | extern int write(void *handle, void *ptr, int nb); | ||
12 | extern int read(void *handle, void *ptr, int nb); | ||
13 | extern void exit(void); | ||
14 | extern void pause(void); | ||
15 | extern void *finddevice(const char *); | ||
16 | extern void *claim(unsigned long virt, unsigned long size, unsigned long align); | ||
17 | extern int getprop(void *phandle, const char *name, void *buf, int buflen); | ||
18 | #endif /* _PPC_BOOT_PROM_H_ */ | ||
diff --git a/arch/ppc64/boot/stdio.h b/arch/ppc64/boot/stdio.h new file mode 100644 index 000000000000..24bd3a8dee94 --- /dev/null +++ b/arch/ppc64/boot/stdio.h | |||
@@ -0,0 +1,16 @@ | |||
1 | #ifndef _PPC_BOOT_STDIO_H_ | ||
2 | #define _PPC_BOOT_STDIO_H_ | ||
3 | |||
4 | extern int printf(const char *fmt, ...); | ||
5 | |||
6 | extern int sprintf(char *buf, const char *fmt, ...); | ||
7 | |||
8 | extern int vsprintf(char *buf, const char *fmt, va_list args); | ||
9 | |||
10 | extern int putc(int c, void *f); | ||
11 | extern int putchar(int c); | ||
12 | extern int getchar(void); | ||
13 | |||
14 | extern int fputs(char *str, void *f); | ||
15 | |||
16 | #endif /* _PPC_BOOT_STDIO_H_ */ | ||
diff --git a/arch/ppc64/boot/string.S b/arch/ppc64/boot/string.S index ba5f2d21c9ea..7ade87ae7718 100644 --- a/arch/ppc64/boot/string.S +++ b/arch/ppc64/boot/string.S | |||
@@ -9,7 +9,7 @@ | |||
9 | * NOTE: this code runs in 32 bit mode and is packaged as ELF32. | 9 | * NOTE: this code runs in 32 bit mode and is packaged as ELF32. |
10 | */ | 10 | */ |
11 | 11 | ||
12 | #include <asm/ppc_asm.h> | 12 | #include "ppc_asm.h" |
13 | 13 | ||
14 | .text | 14 | .text |
15 | .globl strcpy | 15 | .globl strcpy |
diff --git a/arch/ppc64/boot/string.h b/arch/ppc64/boot/string.h new file mode 100644 index 000000000000..9289258bcbd6 --- /dev/null +++ b/arch/ppc64/boot/string.h | |||
@@ -0,0 +1,16 @@ | |||
1 | #ifndef _PPC_BOOT_STRING_H_ | ||
2 | #define _PPC_BOOT_STRING_H_ | ||
3 | |||
4 | extern char *strcpy(char *dest, const char *src); | ||
5 | extern char *strncpy(char *dest, const char *src, size_t n); | ||
6 | extern char *strcat(char *dest, const char *src); | ||
7 | extern int strcmp(const char *s1, const char *s2); | ||
8 | extern size_t strlen(const char *s); | ||
9 | extern size_t strnlen(const char *s, size_t count); | ||
10 | |||
11 | extern void *memset(void *s, int c, size_t n); | ||
12 | extern void *memmove(void *dest, const void *src, unsigned long n); | ||
13 | extern void *memcpy(void *dest, const void *src, unsigned long n); | ||
14 | extern int memcmp(const void *s1, const void *s2, size_t n); | ||
15 | |||
16 | #endif /* _PPC_BOOT_STRING_H_ */ | ||
diff --git a/arch/ppc64/boot/zlib.c b/arch/ppc64/boot/zlib.c index 78837e884b8b..0d910cd2079d 100644 --- a/arch/ppc64/boot/zlib.c +++ b/arch/ppc64/boot/zlib.c | |||
@@ -107,7 +107,7 @@ extern void *memcpy(void *, const void *, unsigned long); | |||
107 | 107 | ||
108 | /* Diagnostic functions */ | 108 | /* Diagnostic functions */ |
109 | #ifdef DEBUG_ZLIB | 109 | #ifdef DEBUG_ZLIB |
110 | # include <stdio.h> | 110 | # include "stdio.h" |
111 | # ifndef verbose | 111 | # ifndef verbose |
112 | # define verbose 0 | 112 | # define verbose 0 |
113 | # endif | 113 | # endif |