From 0a26b1364f14852bc9a51db0ca63c5250c775627 Mon Sep 17 00:00:00 2001 From: Paul Mackerras Date: Tue, 28 Mar 2006 10:22:10 +1100 Subject: ppc: Remove CHRP, POWER3 and POWER4 support from arch/ppc 32-bit CHRP machines are now supported only in arch/powerpc, as are all 64-bit PowerPC processors. This means that we don't use Open Firmware on any platform in arch/ppc any more. This makes PReP support a single-platform option like every other platform support option in arch/ppc now, thus CONFIG_PPC_MULTIPLATFORM is gone from arch/ppc. CONFIG_PPC_PREP is the option that selects PReP support and is generally what has replaced CONFIG_PPC_MULTIPLATFORM within arch/ppc. _machine is all but dead now, being #defined to 0. Updated Makefiles, comments and Kconfig options generally to reflect these changes. Signed-off-by: Paul Mackerras --- arch/ppc/boot/Makefile | 7 +- arch/ppc/boot/openfirmware/Makefile | 109 --------------------- arch/ppc/boot/openfirmware/chrpmain.c | 101 -------------------- arch/ppc/boot/openfirmware/common.c | 146 ---------------------------- arch/ppc/boot/openfirmware/dummy.c | 4 - arch/ppc/boot/openfirmware/misc.S | 67 ------------- arch/ppc/boot/openfirmware/start.c | 172 --------------------------------- arch/ppc/boot/simple/mpc10x_memory.c | 4 +- arch/ppc/boot/simple/relocate.S | 2 +- arch/ppc/boot/utils/addnote.c | 175 ---------------------------------- arch/ppc/boot/utils/hack-coff.c | 84 ---------------- arch/ppc/boot/utils/mknote.c | 44 --------- 12 files changed, 6 insertions(+), 909 deletions(-) delete mode 100644 arch/ppc/boot/openfirmware/Makefile delete mode 100644 arch/ppc/boot/openfirmware/chrpmain.c delete mode 100644 arch/ppc/boot/openfirmware/common.c delete mode 100644 arch/ppc/boot/openfirmware/dummy.c delete mode 100644 arch/ppc/boot/openfirmware/misc.S delete mode 100644 arch/ppc/boot/openfirmware/start.c delete mode 100644 arch/ppc/boot/utils/addnote.c delete mode 100644 arch/ppc/boot/utils/hack-coff.c delete mode 100644 arch/ppc/boot/utils/mknote.c (limited to 'arch/ppc/boot') diff --git a/arch/ppc/boot/Makefile b/arch/ppc/boot/Makefile index 84eec0bef93..b739e25d472 100644 --- a/arch/ppc/boot/Makefile +++ b/arch/ppc/boot/Makefile @@ -19,14 +19,13 @@ HOSTCFLAGS += -Iarch/$(ARCH)/boot/include BOOT_TARGETS = zImage zImage.initrd znetboot znetboot.initrd bootdir-y := simple -bootdir-$(CONFIG_PPC_OF) += openfirmware subdir-y := lib common images -subdir-$(CONFIG_PPC_MULTIPLATFORM) += of1275 +subdir-$(CONFIG_PPC_PREP) += of1275 # for cleaning -subdir- += simple openfirmware +subdir- += simple -hostprogs-y := $(addprefix utils/, addnote mknote hack-coff mkprep mkbugboot mktree) +hostprogs-y := $(addprefix utils/, mkprep mkbugboot mktree) PHONY += $(BOOT_TARGETS) $(bootdir-y) diff --git a/arch/ppc/boot/openfirmware/Makefile b/arch/ppc/boot/openfirmware/Makefile deleted file mode 100644 index 66b73974375..00000000000 --- a/arch/ppc/boot/openfirmware/Makefile +++ /dev/null @@ -1,109 +0,0 @@ -# Makefile for making bootable images on various OpenFirmware machines. -# -# This file is included by the global makefile so that you can add your own -# architecture-specific flags and dependencies. -# -# Paul Mackerras January 1997 -# XCOFF bootable images for PowerMacs -# Geert Uytterhoeven September 1997 -# ELF bootable iamges for CHRP machines. -# Tom Rini January 2001 -# Cleaned up, moved into arch/ppc/boot/pmac -# Tom Rini July/August 2002 -# Merged 'chrp' and 'pmac' into 'openfirmware', and cleaned up the -# rules. - -zImage.initrd znetboot.initrd: del-ramdisk-sec := -R .ramdisk -zImage.initrd znetboot.initrd: initrd := .initrd - - -boot := arch/ppc/boot -common := $(boot)/common -utils := $(boot)/utils -bootlib := $(boot)/lib -of1275 := $(boot)/of1275 -images := $(boot)/images - -CHRP_LD_ARGS := -T $(srctree)/$(boot)/ld.script -e _start -Ttext 0x00800000 - -COMMONOBJS := start.o misc.o common.o -CHRPOBJS := crt0.o $(COMMONOBJS) chrpmain.o - -targets := $(CHRPOBJS) dummy.o -CHRPOBJS := $(addprefix $(obj)/, $(CHRPOBJS)) - -LIBS := lib/lib.a $(bootlib)/lib.a $(of1275)/lib.a $(common)/lib.a - -ifdef CONFIG_SMP -END := .smp -endif -ifdef CONFIG_PPC64BRIDGE -END += .64 -endif - - -$(images)/ramdisk.image.gz: - @echo ' MISSING $@' - @echo ' RAM disk image must be provided separately' - @/bin/false - -quiet_cmd_genimage = GEN $@ - cmd_genimage = $(OBJCOPY) -R .comment \ - --add-section=.image=$(images)/vmlinux.gz \ - --set-section-flags=.image=contents,alloc,load,readonly,data $< $@ - -targets += image.o -$(obj)/image.o: $(obj)/dummy.o $(images)/vmlinux.gz FORCE - $(call if_changed,genimage) - -# Place the ramdisk in the initrd image. -quiet_cmd_genimage-initrd = GEN $@ - cmd_genimage-initrd = $(OBJCOPY) $< $@ \ - --add-section=.ramdisk=$(images)/ramdisk.image.gz \ - --set-section-flags=.ramdisk=contents,alloc,load,readonly,data -targets += image.initrd.o -$(obj)/image.initrd.o: $(obj)/image.o $(images)/ramdisk.image.gz FORCE - $(call if_changed,genimage-initrd) - - -targets += crt0.o -$(obj)/crt0.o: $(common)/crt0.S FORCE - $(call if_changed_dep,as_o_S) - -quiet_cmd_gen-chrp = CHRP $@ - cmd_gen-chrp = $(LD) $(CHRP_LD_ARGS) -o $@ $(CHRPOBJS) $< $(LIBS) && \ - $(OBJCOPY) $@ $@ -R .comment $(del-ramdisk-sec) - -$(images)/zImage.chrp: $(obj)/image.o $(CHRPOBJS) $(LIBS) \ - $(srctree)/$(boot)/ld.script - $(call cmd,gen-chrp) -$(images)/zImage.initrd.chrp: $(obj)/image.initrd.o $(CHRPOBJS) $(LIBS) \ - $(srctree)/$(boot)/ld.script - $(call cmd,gen-chrp) - -quiet_cmd_addnote = ADDNOTE $@ - cmd_addnote = cat $< > $@ && $(utils)/addnote $@ -$(images)/zImage.chrp-rs6k $(images)/zImage.initrd.chrp-rs6k: \ - %-rs6k: % - $(call cmd,addnote) - -# The targets used on the make command-line - -PHONY += zImage zImage.initrd -zImage: $(images)/zImage.chrp \ - $(images)/zImage.chrp-rs6k - @echo ' kernel: $@ is ready ($<)' -zImage.initrd: $(images)/zImage.initrd.chrp \ - $(images)/zImage.initrd.chrp-rs6k - @echo ' kernel: $@ is ready ($<)' - -TFTPIMAGE := /tftpboot/zImage - -PHONY += znetboot znetboot.initrd -znetboot: $(images)/zImage.chrp - cp $(images)/zImage.chrp $(TFTPIMAGE).chrp$(END) - @echo ' kernel: $@ is ready ($<)' -znetboot.initrd:$(images)/zImage.initrd.chrp - cp $(images)/zImage.initrd.chrp $(TFTPIMAGE).chrp$(END) - @echo ' kernel: $@ is ready ($<)' - diff --git a/arch/ppc/boot/openfirmware/chrpmain.c b/arch/ppc/boot/openfirmware/chrpmain.c deleted file mode 100644 index 245dbd9fc12..00000000000 --- a/arch/ppc/boot/openfirmware/chrpmain.c +++ /dev/null @@ -1,101 +0,0 @@ -/* - * 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 - * 2 of the License, or (at your option) any later version. - */ -#include -#include "nonstdio.h" -#include "of1275.h" -#include -#include - -/* Passed from the linker */ -extern char __image_begin, __image_end; -extern char __ramdisk_begin, __ramdisk_end; -extern char _start, _end; - -extern unsigned int heap_max; -extern void flush_cache(void *, unsigned long); -extern void gunzip(void *, int, unsigned char *, int *); -extern void make_bi_recs(unsigned long addr, char *name, unsigned int mach, - unsigned int progend); - -char *avail_ram; -char *begin_avail, *end_avail; -char *avail_high; - -#define RAM_START 0x00000000 -#define RAM_END (64<<20) - -#define BOOT_START ((unsigned long)_start) -#define BOOT_END ((unsigned long)(_end + 0xFFF) & ~0xFFF) - -#define RAM_FREE ((unsigned long)(_end+0x1000)&~0xFFF) -#define PROG_START 0x00010000 -#define PROG_SIZE 0x007f0000 /* 8MB */ - -#define SCRATCH_SIZE (128 << 10) - -static char scratch[SCRATCH_SIZE]; /* 128k of scratch space for gunzip */ - -typedef void (*kernel_start_t)(int, int, void *, unsigned int, unsigned int); - -void -boot(int a1, int a2, void *prom) -{ - unsigned sa, len; - void *dst; - unsigned char *im; - unsigned int initrd_size, initrd_start; - - printf("chrpboot starting: loaded at 0x%p\n\r", &_start); - - initrd_size = &__ramdisk_end - &__ramdisk_begin; - if (initrd_size) { - initrd_start = (RAM_END - initrd_size) & ~0xFFF; - a1 = initrd_start; - a2 = initrd_size; - claim(initrd_start, RAM_END - initrd_start, 0); - printf("initial ramdisk moving 0x%x <- 0x%p (%x bytes)\n\r", - initrd_start, &__ramdisk_begin, initrd_size); - memcpy((char *)initrd_start, &__ramdisk_begin, initrd_size); - } else { - initrd_start = 0; - initrd_size = 0; - a2 = 0xdeadbeef; - } - - im = &__image_begin; - len = &__image_end - &__image_begin; - /* claim 4MB starting at PROG_START */ - claim(PROG_START, PROG_SIZE - PROG_START, 0); - dst = (void *) PROG_START; - if (im[0] == 0x1f && im[1] == 0x8b) { - avail_ram = scratch; - begin_avail = avail_high = avail_ram; - end_avail = scratch + sizeof(scratch); - printf("gunzipping (0x%p <- 0x%p:0x%p)...", dst, im, im+len); - gunzip(dst, PROG_SIZE - PROG_START, im, &len); - printf("done %u bytes\n\r", len); - printf("%u bytes of heap consumed, max in use %u\n\r", - avail_high - begin_avail, heap_max); - } else { - memmove(dst, im, len); - } - - flush_cache(dst, len); - make_bi_recs(((unsigned long) dst + len), "chrpboot", _MACH_chrp, - (PROG_START + PROG_SIZE)); - - sa = PROG_START; - printf("start address = 0x%x\n\r", sa); - - (*(kernel_start_t)sa)(a1, a2, prom, initrd_start, initrd_size); - - printf("returned?\n\r"); - - pause(); -} diff --git a/arch/ppc/boot/openfirmware/common.c b/arch/ppc/boot/openfirmware/common.c deleted file mode 100644 index 0f46756a903..00000000000 --- a/arch/ppc/boot/openfirmware/common.c +++ /dev/null @@ -1,146 +0,0 @@ -/* - * 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 - * 2 of the License, or (at your option) any later version. - */ - -#include "nonstdio.h" -#include "of1275.h" -#include -#include -#include -#include - -/* Information from the linker */ - -extern int strcmp(const char *s1, const char *s2); -extern char *avail_ram, *avail_high; -extern char *end_avail; - -unsigned int heap_use, heap_max; - -struct memchunk { - unsigned int size; - struct memchunk *next; -}; - -static struct memchunk *freechunks; - -static void *zalloc(unsigned size) -{ - void *p; - struct memchunk **mpp, *mp; - - size = (size + 7) & -8; - heap_use += size; - if (heap_use > heap_max) - heap_max = heap_use; - for (mpp = &freechunks; (mp = *mpp) != 0; mpp = &mp->next) { - if (mp->size == size) { - *mpp = mp->next; - return mp; - } - } - p = avail_ram; - avail_ram += size; - if (avail_ram > avail_high) - avail_high = avail_ram; - if (avail_ram > end_avail) { - printf("oops... out of memory\n\r"); - pause(); - } - return p; -} - -#define HEAD_CRC 2 -#define EXTRA_FIELD 4 -#define ORIG_NAME 8 -#define COMMENT 0x10 -#define RESERVED 0xe0 - -void gunzip(void *dst, int dstlen, unsigned char *src, int *lenp) -{ - z_stream s; - int r, i, flags; - - /* skip header */ - i = 10; - flags = src[3]; - if (src[2] != Z_DEFLATED || (flags & RESERVED) != 0) { - printf("bad gzipped data\n\r"); - exit(); - } - if ((flags & EXTRA_FIELD) != 0) - i = 12 + src[10] + (src[11] << 8); - if ((flags & ORIG_NAME) != 0) - while (src[i++] != 0) - ; - if ((flags & COMMENT) != 0) - while (src[i++] != 0) - ; - if ((flags & HEAD_CRC) != 0) - i += 2; - if (i >= *lenp) { - printf("gunzip: ran out of data in header\n\r"); - exit(); - } - - /* Initialize ourself. */ - s.workspace = zalloc(zlib_inflate_workspacesize()); - r = zlib_inflateInit2(&s, -MAX_WBITS); - if (r != Z_OK) { - printf("zlib_inflateInit2 returned %d\n\r", r); - exit(); - } - s.next_in = src + i; - s.avail_in = *lenp - i; - s.next_out = dst; - s.avail_out = dstlen; - r = zlib_inflate(&s, Z_FINISH); - if (r != Z_OK && r != Z_STREAM_END) { - printf("inflate returned %d msg: %s\n\r", r, s.msg); - exit(); - } - *lenp = s.next_out - (unsigned char *) dst; - zlib_inflateEnd(&s); -} - -/* Make a bi_rec in OF. We need to be passed a name for BI_BOOTLOADER_ID, - * a machine type for BI_MACHTYPE, and the location where the end of the - * bootloader is (PROG_START + PROG_SIZE) - */ -void make_bi_recs(unsigned long addr, char *name, unsigned int mach, - unsigned long progend) -{ - struct bi_record *rec; - - - /* leave a 1MB gap then align to the next 1MB boundary */ - addr = _ALIGN(addr+ (1<<20) - 1, (1<<20)); - /* oldworld machine seem very unhappy about this. -- Tom */ - if (addr >= progend) - claim(addr, 0x1000, 0); - - rec = (struct bi_record *)addr; - rec->tag = BI_FIRST; - rec->size = sizeof(struct bi_record); - rec = (struct bi_record *)((unsigned long)rec + rec->size); - - rec->tag = BI_BOOTLOADER_ID; - sprintf( (char *)rec->data, name); - rec->size = sizeof(struct bi_record) + strlen(name) + 1; - rec = (struct bi_record *)((unsigned long)rec + rec->size); - - rec->tag = BI_MACHTYPE; - rec->data[0] = mach; - rec->data[1] = 1; - rec->size = sizeof(struct bi_record) + 2 * sizeof(unsigned long); - rec = (struct bi_record *)((unsigned long)rec + rec->size); - - rec->tag = BI_LAST; - rec->size = sizeof(struct bi_record); - rec = (struct bi_record *)((unsigned long)rec + rec->size); -} diff --git a/arch/ppc/boot/openfirmware/dummy.c b/arch/ppc/boot/openfirmware/dummy.c deleted file mode 100644 index 31dbf45bf99..00000000000 --- a/arch/ppc/boot/openfirmware/dummy.c +++ /dev/null @@ -1,4 +0,0 @@ -int main(void) -{ - return 0; -} diff --git a/arch/ppc/boot/openfirmware/misc.S b/arch/ppc/boot/openfirmware/misc.S deleted file mode 100644 index ab9e897cadd..00000000000 --- a/arch/ppc/boot/openfirmware/misc.S +++ /dev/null @@ -1,67 +0,0 @@ -/* - * 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 - * 2 of the License, or (at your option) any later version. - */ - .text - -/* - * Use the BAT2 & 3 registers to map the 1st 16MB of RAM to - * the address given as the 1st argument. - */ - .globl setup_bats -setup_bats: - mfpvr 5 - rlwinm 5,5,16,16,31 /* r3 = 1 for 601, 4 for 604 */ - cmpwi 0,5,1 - li 0,0 - bne 4f - mtibatl 3,0 /* invalidate BAT first */ - ori 3,3,4 /* set up BAT registers for 601 */ - li 4,0x7f - mtibatu 2,3 - mtibatl 2,4 - oris 3,3,0x80 - oris 4,4,0x80 - mtibatu 3,3 - mtibatl 3,4 - b 5f -4: mtdbatu 3,0 /* invalidate BATs first */ - mtibatu 3,0 - ori 3,3,0xff /* set up BAT registers for 604 */ - li 4,2 - mtdbatl 2,4 - mtdbatu 2,3 - mtibatl 2,4 - mtibatu 2,3 - oris 3,3,0x80 - oris 4,4,0x80 - mtdbatl 3,4 - mtdbatu 3,3 - mtibatl 3,4 - mtibatu 3,3 -5: sync - isync - blr - -/* - * Flush the dcache and invalidate the icache for a range of addresses. - * - * flush_cache(addr, len) - */ - .global flush_cache -flush_cache: - addi 4,4,0x1f /* len = (len + 0x1f) / 0x20 */ - rlwinm. 4,4,27,5,31 - mtctr 4 - beqlr -1: dcbf 0,3 - icbi 0,3 - addi 3,3,0x20 - bdnz 1b - sync - isync - blr diff --git a/arch/ppc/boot/openfirmware/start.c b/arch/ppc/boot/openfirmware/start.c deleted file mode 100644 index 1617a26956b..00000000000 --- a/arch/ppc/boot/openfirmware/start.c +++ /dev/null @@ -1,172 +0,0 @@ -/* - * 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 - * 2 of the License, or (at your option) any later version. - */ -#include -#include "of1275.h" - -extern int strlen(const char *s); -extern void boot(int a1, int a2, void *prom); - -phandle stdin; -phandle stdout; -phandle stderr; - -void printk(char *fmt, ...); - -void -start(int a1, int a2, void *promptr) -{ - ofinit(promptr); - if (ofstdio(&stdin, &stdout, &stderr)) - exit(); - - boot(a1, a2, promptr); - for (;;) - exit(); -} - -int writestring(void *f, char *ptr, int nb) -{ - int w = 0, i; - char *ret = "\r"; - - for (i = 0; i < nb; ++i) { - if (ptr[i] == '\n') { - if (i > w) { - write(f, ptr + w, i - w); - w = i; - } - write(f, ret, 1); - } - } - if (w < nb) - write(f, ptr + w, nb - w); - return nb; -} - -int -putc(int c, void *f) -{ - char ch = c; - - return writestring(f, &ch, 1) == 1? c: -1; -} - -int -putchar(int c) -{ - return putc(c, stdout); -} - -int -fputs(char *str, void *f) -{ - int n = strlen(str); - - return writestring(f, str, n) == n? 0: -1; -} - -int -readchar(void) -{ - char ch; - - for (;;) { - switch (read(stdin, &ch, 1)) { - case 1: - return ch; - case -1: - printk("read(stdin) returned -1\n"); - return -1; - } - } -} - -static char line[256]; -static char *lineptr; -static int lineleft; - -int -getchar(void) -{ - int c; - - if (lineleft == 0) { - lineptr = line; - for (;;) { - c = readchar(); - if (c == -1 || c == 4) - break; - if (c == '\r' || c == '\n') { - *lineptr++ = '\n'; - putchar('\n'); - break; - } - switch (c) { - case 0177: - case '\b': - if (lineptr > line) { - putchar('\b'); - putchar(' '); - putchar('\b'); - --lineptr; - } - break; - case 'U' & 0x1F: - while (lineptr > line) { - putchar('\b'); - putchar(' '); - putchar('\b'); - --lineptr; - } - break; - default: - if (lineptr >= &line[sizeof(line) - 1]) - putchar('\a'); - else { - putchar(c); - *lineptr++ = c; - } - } - } - lineleft = lineptr - line; - lineptr = line; - } - if (lineleft == 0) - return -1; - --lineleft; - return *lineptr++; -} - -extern int vsprintf(char *buf, const char *fmt, va_list args); -static char sprint_buf[1024]; - -void -printk(char *fmt, ...) -{ - va_list args; - int n; - - va_start(args, fmt); - n = vsprintf(sprint_buf, fmt, args); - va_end(args); - writestring(stdout, sprint_buf, n); -} - -int -printf(char *fmt, ...) -{ - va_list args; - int n; - - va_start(args, fmt); - n = vsprintf(sprint_buf, fmt, args); - va_end(args); - writestring(stdout, sprint_buf, n); - return n; -} diff --git a/arch/ppc/boot/simple/mpc10x_memory.c b/arch/ppc/boot/simple/mpc10x_memory.c index c24290823f7..8da8f576031 100644 --- a/arch/ppc/boot/simple/mpc10x_memory.c +++ b/arch/ppc/boot/simple/mpc10x_memory.c @@ -50,10 +50,10 @@ MPC10X_PCI_OP(read, dword, u32 *, in_le32, 0) * the system. This assumes that the firmware has correctly set up the memory * controller registers. On CONFIG_PPC_PREP, we know we are being called * under a PReP memory map. On all other machines, we assume we are under - * a CHRP memory map. Further, on CONFIG_PPC_MULTIPLATFORM we must rename + * a CHRP memory map. Further, on CONFIG_PPC_PREP we must rename * this function. */ -#ifdef CONFIG_PPC_MULTIPLATFORM +#ifdef CONFIG_PPC_PREP #define get_mem_size mpc10x_get_mem_size #endif unsigned long diff --git a/arch/ppc/boot/simple/relocate.S b/arch/ppc/boot/simple/relocate.S index 7efddc50756..2533113c1cc 100644 --- a/arch/ppc/boot/simple/relocate.S +++ b/arch/ppc/boot/simple/relocate.S @@ -194,7 +194,7 @@ start_ldr: /* * Start at the begining. */ -#ifdef CONFIG_PPC_MULTIPLATFORM +#ifdef CONFIG_PPC_PREP li r9,0xc mtlr r9 /* tell kernel we're prep, by putting 0xdeadc0de at KERNELLOAD, diff --git a/arch/ppc/boot/utils/addnote.c b/arch/ppc/boot/utils/addnote.c deleted file mode 100644 index 6c52b18f2d0..00000000000 --- a/arch/ppc/boot/utils/addnote.c +++ /dev/null @@ -1,175 +0,0 @@ -/* - * Program to hack in a PT_NOTE program header entry in an ELF file. - * This is needed for OF on RS/6000s to load an image correctly. - * Note that OF needs a program header entry for the note, not an - * ELF section. - * - * Copyright 2000 Paul Mackerras. - * - * 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 - * 2 of the License, or (at your option) any later version. - * - * Usage: addnote zImage - */ -#include -#include -#include -#include -#include - -char arch[] = "PowerPC"; - -#define N_DESCR 6 -unsigned int descr[N_DESCR] = { -#if 1 - /* values for IBM RS/6000 machines */ - 0xffffffff, /* real-mode = true */ - 0x00c00000, /* real-base, i.e. where we expect OF to be */ - 0xffffffff, /* real-size */ - 0xffffffff, /* virt-base */ - 0xffffffff, /* virt-size */ - 0x4000, /* load-base */ -#else - /* values for longtrail CHRP */ - 0, /* real-mode = false */ - 0xffffffff, /* real-base */ - 0xffffffff, /* real-size */ - 0xffffffff, /* virt-base */ - 0xffffffff, /* virt-size */ - 0x00600000, /* load-base */ -#endif -}; - -unsigned char buf[512]; - -#define GET_16BE(off) ((buf[off] << 8) + (buf[(off)+1])) -#define GET_32BE(off) ((GET_16BE(off) << 16) + GET_16BE((off)+2)) - -#define PUT_16BE(off, v) (buf[off] = ((v) >> 8) & 0xff, \ - buf[(off) + 1] = (v) & 0xff) -#define PUT_32BE(off, v) (PUT_16BE((off), (v) >> 16), \ - PUT_16BE((off) + 2, (v))) - -/* Structure of an ELF file */ -#define E_IDENT 0 /* ELF header */ -#define E_PHOFF 28 -#define E_PHENTSIZE 42 -#define E_PHNUM 44 -#define E_HSIZE 52 /* size of ELF header */ - -#define EI_MAGIC 0 /* offsets in E_IDENT area */ -#define EI_CLASS 4 -#define EI_DATA 5 - -#define PH_TYPE 0 /* ELF program header */ -#define PH_OFFSET 4 -#define PH_FILESZ 16 -#define PH_HSIZE 32 /* size of program header */ - -#define PT_NOTE 4 /* Program header type = note */ - -#define ELFCLASS32 1 -#define ELFDATA2MSB 2 - -unsigned char elf_magic[4] = { 0x7f, 'E', 'L', 'F' }; - -int main(int ac, char **av) -{ - int fd, n, i; - int ph, ps, np; - int nnote, ns; - - if (ac != 2) { - fprintf(stderr, "Usage: %s elf-file\n", av[0]); - exit(1); - } - fd = open(av[1], O_RDWR); - if (fd < 0) { - perror(av[1]); - exit(1); - } - - nnote = strlen(arch) + 1 + (N_DESCR + 3) * 4; - - n = read(fd, buf, sizeof(buf)); - if (n < 0) { - perror("read"); - exit(1); - } - - if (n < E_HSIZE || memcmp(&buf[E_IDENT+EI_MAGIC], elf_magic, 4) != 0) - goto notelf; - - if (buf[E_IDENT+EI_CLASS] != ELFCLASS32 - || buf[E_IDENT+EI_DATA] != ELFDATA2MSB) { - fprintf(stderr, "%s is not a big-endian 32-bit ELF image\n", - av[1]); - exit(1); - } - - ph = GET_32BE(E_PHOFF); - ps = GET_16BE(E_PHENTSIZE); - np = GET_16BE(E_PHNUM); - if (ph < E_HSIZE || ps < PH_HSIZE || np < 1) - goto notelf; - if (ph + (np + 1) * ps + nnote > n) - goto nospace; - - for (i = 0; i < np; ++i) { - if (GET_32BE(ph + PH_TYPE) == PT_NOTE) { - fprintf(stderr, "%s already has a note entry\n", - av[1]); - exit(0); - } - ph += ps; - } - - /* XXX check that the area we want to use is all zeroes */ - for (i = 0; i < ps + nnote; ++i) - if (buf[ph + i] != 0) - goto nospace; - - /* fill in the program header entry */ - ns = ph + ps; - PUT_32BE(ph + PH_TYPE, PT_NOTE); - PUT_32BE(ph + PH_OFFSET, ns); - PUT_32BE(ph + PH_FILESZ, nnote); - - /* fill in the note area we point to */ - /* XXX we should probably make this a proper section */ - PUT_32BE(ns, strlen(arch) + 1); - PUT_32BE(ns + 4, N_DESCR * 4); - PUT_32BE(ns + 8, 0x1275); - strcpy(&buf[ns + 12], arch); - ns += 12 + strlen(arch) + 1; - for (i = 0; i < N_DESCR; ++i) - PUT_32BE(ns + i * 4, descr[i]); - - /* Update the number of program headers */ - PUT_16BE(E_PHNUM, np + 1); - - /* write back */ - lseek(fd, (long) 0, SEEK_SET); - i = write(fd, buf, n); - if (i < 0) { - perror("write"); - exit(1); - } - if (i < n) { - fprintf(stderr, "%s: write truncated\n", av[1]); - exit(1); - } - - exit(0); - - notelf: - fprintf(stderr, "%s does not appear to be an ELF file\n", av[0]); - exit(1); - - nospace: - fprintf(stderr, "sorry, I can't find space in %s to put the note\n", - av[0]); - exit(1); -} diff --git a/arch/ppc/boot/utils/hack-coff.c b/arch/ppc/boot/utils/hack-coff.c deleted file mode 100644 index 5e5a6573a1e..00000000000 --- a/arch/ppc/boot/utils/hack-coff.c +++ /dev/null @@ -1,84 +0,0 @@ -/* - * hack-coff.c - hack the header of an xcoff file to fill in - * a few fields needed by the Open Firmware xcoff loader on - * Power Macs but not initialized by objcopy. - * - * 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 - * 2 of the License, or (at your option) any later version. - */ -#include -#include -#include -#include -#include -#include "rs6000.h" - -#define AOUT_MAGIC 0x010b - -#define get_16be(x) ((((unsigned char *)(x))[0] << 8) \ - + ((unsigned char *)(x))[1]) -#define put_16be(x, v) (((unsigned char *)(x))[0] = (v) >> 8, \ - ((unsigned char *)(x))[1] = (v) & 0xff) -#define get_32be(x) ((((unsigned char *)(x))[0] << 24) \ - + (((unsigned char *)(x))[1] << 16) \ - + (((unsigned char *)(x))[2] << 8) \ - + ((unsigned char *)(x))[3]) - -int -main(int ac, char **av) -{ - int fd; - int i, nsect; - int aoutsz; - struct external_filehdr fhdr; - AOUTHDR aout; - struct external_scnhdr shdr; - - if (ac != 2) { - fprintf(stderr, "Usage: hack-coff coff-file\n"); - exit(1); - } - if ((fd = open(av[1], 2)) == -1) { - perror(av[2]); - exit(1); - } - if (read(fd, &fhdr, sizeof(fhdr)) != sizeof(fhdr)) - goto readerr; - i = get_16be(fhdr.f_magic); - if (i != U802TOCMAGIC && i != U802WRMAGIC && i != U802ROMAGIC) { - fprintf(stderr, "%s: not an xcoff file\n", av[1]); - exit(1); - } - aoutsz = get_16be(fhdr.f_opthdr); - if (read(fd, &aout, aoutsz) != aoutsz) - goto readerr; - nsect = get_16be(fhdr.f_nscns); - for (i = 0; i < nsect; ++i) { - if (read(fd, &shdr, sizeof(shdr)) != sizeof(shdr)) - goto readerr; - if (strcmp(shdr.s_name, ".text") == 0) { - put_16be(aout.o_snentry, i+1); - put_16be(aout.o_sntext, i+1); - } else if (strcmp(shdr.s_name, ".data") == 0) { - put_16be(aout.o_sndata, i+1); - } else if (strcmp(shdr.s_name, ".bss") == 0) { - put_16be(aout.o_snbss, i+1); - } - } - put_16be(aout.magic, AOUT_MAGIC); - if (lseek(fd, (long) sizeof(struct external_filehdr), 0) == -1 - || write(fd, &aout, aoutsz) != aoutsz) { - fprintf(stderr, "%s: write error\n", av[1]); - exit(1); - } - close(fd); - exit(0); - -readerr: - fprintf(stderr, "%s: read error or file too short\n", av[1]); - exit(1); -} diff --git a/arch/ppc/boot/utils/mknote.c b/arch/ppc/boot/utils/mknote.c deleted file mode 100644 index b9fbb2cbfc8..00000000000 --- a/arch/ppc/boot/utils/mknote.c +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (C) Cort Dougan 1999. - * - * 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 - * 2 of the License, or (at your option) any later version. - * - * Generate a note section as per the CHRP specification. - * - */ - -#include -#include - -#define PL(x) printf("%c%c%c%c", ((x)>>24)&0xff, ((x)>>16)&0xff, ((x)>>8)&0xff, (x)&0xff ); - -int main(void) -{ -/* header */ - /* namesz */ - PL(strlen("PowerPC")+1); - /* descrsz */ - PL(6*4); - /* type */ - PL(0x1275); - /* name */ - printf("PowerPC"); printf("%c", 0); - -/* descriptor */ - /* real-mode */ - PL(0xffffffff); - /* real-base */ - PL(0x00c00000); - /* real-size */ - PL(0xffffffff); - /* virt-base */ - PL(0xffffffff); - /* virt-size */ - PL(0xffffffff); - /* load-base */ - PL(0x4000); - return 0; -} -- cgit v1.2.3