summaryrefslogtreecommitdiffstats
path: root/arch/mips/boot
diff options
context:
space:
mode:
authorRalf Baechle <ralf@linux-mips.org>1997-07-24 01:37:11 +0000
committerRalf Baechle <ralf@linux-mips.org>1997-07-24 01:37:11 +0000
commita9818dca6bad4ccf5787339627ba6a0dab346d6a (patch)
tree98f276a7a773767c7238ad01ceef98fcf01d82a8 /arch/mips/boot
parenta569c5497513c0f5d021546527b01e32f3c29907 (diff)
Remove the copy of the Milo sources in the kernel sources.
Diffstat (limited to 'arch/mips/boot')
-rw-r--r--arch/mips/boot/a.out.c254
-rw-r--r--arch/mips/boot/loader.h24
-rw-r--r--arch/mips/boot/milo.c316
3 files changed, 0 insertions, 594 deletions
diff --git a/arch/mips/boot/a.out.c b/arch/mips/boot/a.out.c
deleted file mode 100644
index 15515b219..000000000
--- a/arch/mips/boot/a.out.c
+++ /dev/null
@@ -1,254 +0,0 @@
-/*
- * arch/mips/boot/milo.c
- *
- * This file is subject to the terms and conditions of the GNU General Public
- * License. See the file "COPYING" in the main directory of this archive
- * for more details.
- *
- * Copyright (C) 1994, 1995 by Ralf Baechle
- * Copyright (C) 1993 by Hamish Macdonald
- */
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/file.h>
-
-#include "loader.h"
-
-static int kfd;
-static struct exec kexec;
-static off_t filesize;
-static struct nlist *syms;
-static char *strs;
-static long strsize, numsyms;
-
-/*
- * Read a symbol from the kernel executable
- */
-static struct nlist *aout_get_nlist(char *symbol)
-{
- struct nlist *nl, *p = NULL;
-
- for (nl = syms; nl < syms + numsyms; nl++) {
- /*
- * We accept only extern visible .text, .data and .bss symbols.
- */
- if (strcmp (symbol, strs + nl->n_un.n_strx) == 0
- && ((nl->n_type == N_TEXT | N_EXT) ||
- (nl->n_type == N_DATA | N_EXT) ||
- (nl->n_type == N_BSS | N_EXT))) {
- p = (struct nlist *)malloc (sizeof (struct nlist)
- + strlen(strs + nl->n_un.n_strx) + 1);
- if (!p)
- break;
- *p = *nl;
- p->n_un.n_name = (char *)(p+1);
- strcpy (p->n_un.n_name, strs + nl->n_un.n_strx);
- }
- }
- return p;
-}
-
-/*
- * Return a pointer to the internal symbol
- */
-static char *aout_ld_isymbol(char *symbol)
-{
- static char isymbol[64];
-
- strcpy(isymbol, STR(C_LABEL_PREFIX));
- strcat(isymbol, symbol);
-
- return isymbol;
-}
-
-/*
- * Return base address for the loaded kernel
- */
-static u_long aout_get_kbase(void)
-{
- return (u_long) kexec.a_entry;
-}
-
-/*
- * Return size of kernel code + data
- */
-static u_long aout_get_ksize(void)
-{
- return (u_long) (kexec.a_text + kexec.a_data);
-}
-
-/*
- * Load a.out kernel into memory
- */
-static int aout_load_kernel(void *mem)
-{
- if (lseek (kfd, N_TXTOFF(kexec), L_SET) == -1)
- {
- fprintf (stderr, "Failed to seek to text\n\r");
- exit (EXIT_FAILURE);
- }
- if (read (kfd, mem, kexec.a_text) != kexec.a_text)
- {
- fprintf (stderr, "Failed to read text\n\r");
- exit (EXIT_FAILURE);
- }
- if (lseek (kfd, N_DATOFF(kexec), L_SET) == -1)
- {
- fprintf (stderr, "Failed to seek to data\n\r");
- exit (EXIT_FAILURE);
- }
- if (read (kfd, mem + kexec.a_text, kexec.a_data) != kexec.a_data)
- {
- fprintf (stderr, "Failed to read data\n\r");
- exit (EXIT_FAILURE);
- }
- close (kfd);
-
- return 0;
-}
-
-/*
- * Print some statistics about the kernel
- */
-static void aout_print_stats(void)
-{
- printf("Kernel text at 0x%08lx, size %d bytes\n\r",
- kexec.a_entry + N_TXTADDR(kexec), kexec.a_text);
- printf("Kernel data at 0x%08lx, size %d bytes\n\r",
- kexec.a_entry + N_DATADDR(kexec), kexec.a_data );
- printf("Kernel bss at 0x%08lx, size %d bytes\n\r",
- kexec.a_entry + N_BSSADDR(kexec), kexec.a_bss );
-}
-
-static int aout_open_kernel(char *kernel)
-{
- int sfd;
-
- /*
- * open kernel executable and read exec header
- */
- if (debuglevel >= 2)
- {
- printf("aout_open_kernel(): Open kernel file\r\n");
- fflush(stdout);
- }
- if ((kfd = open (kernel, O_RDONLY)) == -1)
- {
- printf ("Unable to open kernel file %s\r\n", kernel);
- exit (EXIT_FAILURE);
- }
- if (debuglevel >= 2)
- {
- printf("aout_open_kernel(): Reading exec header\r\n");
- fflush(stdout);
- }
- if (read (kfd, (void *)&kexec, sizeof(kexec)) != sizeof(kexec))
- {
- printf ("Unable to read exec header from %s\n\r", kernel);
- exit (EXIT_FAILURE);
- }
-
- /*
- * Is this really a kernel???
- * (My Mips docs mention SMAGIC, too, but don't tell about what
- * a SMAGIC file exactly is. If someone knows, please tell me -Ralf)
- *
- * FIXME: QMAGIC doesn't work yet.
- */
- if(N_MAGIC(kexec) != OMAGIC &&
- N_MAGIC(kexec) != NMAGIC &&
- N_MAGIC(kexec) != ZMAGIC &&
- N_MAGIC(kexec) != QMAGIC)
- {
- fprintf(stderr, "Kernel %s is no MIPS binary.\r\n", kernel);
- exit (EXIT_FAILURE);
- }
- if(N_MACHTYPE(kexec) != M_MIPS1 &&
- N_MACHTYPE(kexec) != M_MIPS2)
- {
- fprintf(stderr, "Kernel %s is no MIPS binary.\r\n", kernel);
- exit (EXIT_FAILURE);
- }
-
- /*
- * Read file's symbol table
- */
- /*
- * Open kernel executable and read exec header - we need to
- * use a second open file since the ARC standard doesn't
- * support reverse seeking on files which might run us in
- * trouble later on.
- */
- if (debuglevel >= 2)
- {
- printf("aout_open_kernel(): Open kernel file\r\n");
- fflush(stdout);
- }
- if ((sfd = open (kernel, O_RDONLY)) == -1)
- {
- printf ("Unable to open kernel %s for reading symbols.\r\n", kernel);
- exit (EXIT_FAILURE);
- }
- syms = (struct nlist *)malloc (kexec.a_syms);
- if (!syms)
- {
- return 0;
- }
-
- if (debuglevel >= 2)
- {
- printf("aout_open_kernel(): Seeking to symbol table\r\n");
- fflush(stdout);
- }
- lseek (sfd, N_SYMOFF(kexec), L_SET);
- if (debuglevel >= 2)
- {
- printf("aout_open_kernel(): Reading symbol table\r\n");
- fflush(stdout);
- }
- read (sfd, syms, kexec.a_syms);
- numsyms = kexec.a_syms / sizeof (struct nlist);
- filesize = lseek (sfd, 0L, L_XTND);
- strsize = filesize - N_STROFF(kexec);
- strs = (char *)malloc (strsize);
-
- if (!strs)
- {
- free (syms);
- syms = NULL;
- return 0;
- }
-
- lseek (sfd, N_STROFF(kexec), L_SET);
- read (sfd, strs, strsize);
- close(sfd);
-
- return 0;
-}
-
-static void aout_close_kernel(void)
-{
- if (strs)
- {
- free (strs);
- strs = NULL;
- }
- if (syms)
- {
- free (syms);
- syms = NULL;
- }
- close(kfd);
-}
-
-struct loader loader_aout = {
- aout_get_nlist,
- aout_ld_isymbol,
- aout_get_kbase,
- aout_get_ksize,
- aout_load_kernel,
- aout_print_stats,
- aout_open_kernel,
- aout_close_kernel
-};
diff --git a/arch/mips/boot/loader.h b/arch/mips/boot/loader.h
deleted file mode 100644
index 610111b9a..000000000
--- a/arch/mips/boot/loader.h
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * Defines for Linux/MIPS executable loaders
- *
- * This file is subject to the terms and conditions of the GNU General Public
- * License. See the file "COPYING" in the main directory of this archive
- * for more details.
- *
- * Copyright (C) 1995 by Ralf Baechle
- */
-#ifndef __STAND_LOADER
-#define __STAND_LOADER
-
-struct loader {
- struct nlist *(*ld_get_nlist)(char *symbol);
- char *(*ld_isymbol)(char *);
- u_long (*ld_get_kbase)(void);
- u_long (*ld_get_ksize)(void);
- int (*ld_load_kernel)(void *mem);
- void (*ld_print_stats)(void);
- int (*ld_open_kernel)(char *kernel);
- void (*ld_close_kernel)(void);
-};
-
-#endif /* __STAND_LOADER */
diff --git a/arch/mips/boot/milo.c b/arch/mips/boot/milo.c
deleted file mode 100644
index a8a25dd91..000000000
--- a/arch/mips/boot/milo.c
+++ /dev/null
@@ -1,316 +0,0 @@
-/*
- * Load and launch Linux/MIPS kernel.
- *
- * Copyright (C) 1994, 1995 by Waldorf Electronics,
- * written by Ralf Baechle and Andreas Busse
- *
- * Loosly based on bootstrap.c for Linux/68k,
- * Copyright (C) 1993 by Hamish Macdonald, Greg Harp
- *
- * This file is subject to the terms and conditions of the
- * GNU General Public License. See the file COPYING in the
- * main directory of this archive for more details.
- */
-#include <stdio.h>
-#include <stddef.h>
-#include <stdlib.h>
-#include <unistd.h>
-
-#include <sys/file.h>
-#include <sys/types.h>
-
-#include <linux/string.h>
-#include <linux/tty.h>
-#include <linux/a.out.h>
-
-/*
- * Prototypes
- */
-void usage(void);
-
-/*
- * Defaults, may be overiden by option or environment.
- */
-static char *kernel_name = KERNEL_NAME;
-static char *ramdisk_name = NULL;
-int option_debuglevel = 0;
-int option_verbose = 1;
-int behaviour = BEHAVE_MILO;
-
-extern char *optarg;
-
-extern volatile void launch(char *kptr, char *rdptr,
- u_long kernel_size, u_long rd_size);
-
-static char *kptr; /* kernel will be loaded there */
-static char *rdptr; /* ramdisk will be loaded there */
-
-u_long loadaddr = LOADADDR; /* mallocinit() needs that */
-u_long kernel_base = KERNELBASE; /* whereever that is... */
-u_long start_mem; /* always true on an ARC system */
-u_long mem_size;
-u_long rd_size;
-u_long kernel_entry;
-u_long kernel_size;
-u_long kernel_bss_end;
-
-struct bootinfo bi; /* Linux boot info */
-struct screen_info si; /* Linux screen info */
-struct DisplayInfo *di; /* ARC display info */
-
-
-/*
- * For now we just use the aout loader
- */
-extern struct loader loader_aout;
-struct loader *kld = &loader_aout;
-
-/*
- * main()
- */
-int main(int argc, char *argv[])
-{
- int ch;
-
- /*
- * Print the greet message
- */
- printf("Linux/MIPS ARC Standalone Shell ");
- printf("V" STR(VERSION) "\r\n");
- printf("Copyright (C) Waldorf Electronics and others 1994, 1995\r\n\r\n");
-
- /*
- * Analyse arguments
- */
- if(argc > 1)
- {
- while ((ch = getopt(argc, argv, "dik:r:v")) != EOF)
- switch (ch)
- {
- case 'd':
- option_debuglevel++;
- option_verbose = 1;
- break;
- case 'i':
- interactive = 1;
- break;
- case 'k':
- kernel_name = optarg;
- break;
- case 'r':
- ramdisk_name = optarg;
- break;
- case 'v':
- option_verbose = 1;
- break;
- case '?':
- default:
- usage();
- }
- }
-}
-
-/*
- * Do the actual boot
- */
-int do_boot(char *kernel_name, char *ramdisk_name)
-{
- int kfd, rfd = -1, i;
- u_long memreq;
- struct nlist *nl;
- u_long kbi_offset, ksi_offset;
-
- /*
- * Verify that there is enough RAM
- */
- mem_size = bi.memupper - bi.memlower;
- if (mem_size < 0x800000)
- {
- fprintf(stderr,
- "Insufficient Memory to load Linux/MIPS, aborting\n\r");
- return(5);
- }
-
- if (behaviour == BEHAVE_ARCDB)
- {
- printf("%s: kernel file is `%s'\r\n", NAMEOF_ARCDB, kernel_name);
- if (ramdisk_name)
- printf("%s: ramdisk file is `%s'\r\n", NAMEOF_ARCDB, ramdisk_name);
- }
-
- /*
- * Open kernel and gather some data from the executable
- */
- if (kld->ld_open_kernel(kernel_name) < 0)
- {
- fprintf(stderr, "Error opening kernel file %s.\n\r", kernel_name);
- return 5;
- }
- kernel_base = kld->ld_get_kbase();
- kernel_size = kld->ld_get_ksize();
-
- bi.ramdisk_size = 0; /* default: no ramdisk */
- if (ramdisk_name)
- {
- if ((rfd = open (ramdisk_name, O_RDONLY)) == -1)
- {
- fprintf (stderr,
- "Unable to open ramdisk file %s\n\r", ramdisk_name);
- }
- else
- {
- /*
- * record ramdisk size
- */
- bi.ramdisk_size = (lseek (rfd, 0, L_XTND) + 1023) >> 10;
-
- rd_size = lseek (rfd, 0, L_XTND);
- if (rd_size & ((1<<10)-1))
- {
- /*
- * Most probably the file is no image at all or has been
- * corrupted, so print a warning message.
- */
- printf("Warning: Ramdisk size is not multiple of 1024 bytes.\r\n");
- }
- bi.ramdisk_size = rd_size >> 10;
- }
- }
- bi.ramdisk_base = (u_long)start_mem + mem_size - rd_size;
-
- /*
- * find offset to boot_info structure
- */
- if (!(nl = kld->ld_get_nlist (kld->ld_isymbol("boot_info"))))
- {
- perror("get_nlist1");
- return 1;
- }
- else
- {
- kbi_offset = nl->n_value - kernel_base;
- free(nl);
- }
-
- /*
- * Find offset to screen_info structure
- */
- if (!(nl = kld->ld_get_nlist (kld->ld_isymbol("screen_info"))))
- {
- perror("get_nlist2");
- return 1;
- }
- else
- {
- ksi_offset = nl->n_value - kernel_base;
- free(nl);
- }
-
- /*
- * Find kernel entry point
- */
- if (!(nl = kld->ld_get_nlist (kld->ld_isymbol("kernel_entry"))))
- {
- perror("get_nlist3");
- return 1;
- }
- else
- {
- kernel_entry = nl->n_value;
- free(nl);
- }
-
- /*
- * End of bss segment - ramdisk will be placed there
- */
- if (!(nl = kld->ld_get_nlist (kld->ld_isymbol("_end"))))
- {
- perror("get_nlist3");
- return 1;
- }
- else
- {
- kernel_bss_end = nl->n_value;
- free(nl);
- }
-
- /*
- * allocate buffers for kernel and ramdisk
- */
- if (!(kptr = (char *) malloc(kernel_size)))
- {
- fprintf (stderr, "Unable to allocate %d bytes of memory\n\r", memreq);
- return 1;
- }
- memset (kptr, 0, kernel_size);
-
- if (rd_size)
- {
- if (!(rdptr = (char *) malloc(rd_size)))
- {
- fprintf (stderr,
- "Unable to allocate %d bytes of memory\n\r", memreq);
- return 1;
- }
- memset (rdptr, 0, rd_size);
- }
-
- /*
- * Should check whether kernel & RAMdisk moving doesn't overwrite
- * the bootstraper during startup.
- */
- if (option_verbose)
- {
- /*
- * The following text should be printed by the loader module
- */
- printf ("\r\n");
- kld->ld_print_stats();
- printf ("Kernel entry at 0x%08lx\n\r", kernel_entry);
- }
-
- /*
- * Now do the real loading
- */
- if (kld->ld_load_kernel(kptr) < 0)
- {
- fprintf (stderr, "Failed to load kernel executable\r\n");
- free(kptr);
- exit (EXIT_FAILURE);
- }
- kld->ld_close_kernel();
-
- /*
- * copy the boot and screen info structures to the kernel image,
- * then execute the copy-and-go code
- */
- memcpy ((void *)(kptr + kbi_offset), &bi, sizeof(bi));
- memcpy ((void *)(kptr + ksi_offset), &si, sizeof(si));
-
- /*
- * Write the manipulated kernel back
- */
-
- /*
- * Success...
- */
- return 0;
-}
-
-/*
- * usage()
- *
- * Options:
- * -d - enable debugging (default is no debugging)
- * -i - interactive (default is noninteractive)
- * -k - kernel executable (default multi(0)disk(0)fdisk(0)\VMLINUX)
- * -r - ramdisk image (default is no ramdisk)
- * -v - verbose output
- */
-void usage(void)
-{
- fprintf (stderr, "Usage:\r\n"
- "\tmilo [-d] [-i] [-k kernel_executable] [-r ramdisk_file] [-v]"
- " [option...]\r\n");
- exit (EXIT_FAILURE);
-}