2004-02-15 20:46:45 +00:00
|
|
|
/*
|
|
|
|
*
|
2005-10-10 21:51:02 +00:00
|
|
|
* (c) 2004-2005 Laurent Vivier <LaurentVivier@wanadoo.fr>
|
2004-02-15 20:46:45 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <malloc.h>
|
2004-02-21 01:43:51 +00:00
|
|
|
#include <string.h>
|
2004-06-22 21:28:36 +00:00
|
|
|
#include <unistd.h>
|
2004-02-15 20:46:45 +00:00
|
|
|
|
2004-02-17 22:52:33 +00:00
|
|
|
#include "lowmem.h"
|
2004-02-19 11:34:18 +00:00
|
|
|
#include "bank.h"
|
2004-02-15 20:46:45 +00:00
|
|
|
#include "memory.h"
|
2005-09-19 22:10:41 +00:00
|
|
|
#if defined(ARCH_M68K)
|
|
|
|
#if defined(__LINUX__)
|
2004-02-15 20:46:45 +00:00
|
|
|
#include "bootinfo.h"
|
2005-09-19 22:10:41 +00:00
|
|
|
#elif defined(__NETBSD__)
|
|
|
|
#include "bootenv.h"
|
|
|
|
#endif
|
2005-05-12 05:48:27 +00:00
|
|
|
#endif
|
|
|
|
#ifdef ARCH_PPC
|
|
|
|
#include "bootx.h"
|
|
|
|
#endif
|
2004-02-26 22:51:37 +00:00
|
|
|
#include "arch.h"
|
|
|
|
#include "misc.h"
|
2004-06-01 22:00:21 +00:00
|
|
|
#include "glue.h"
|
|
|
|
#include "load.h"
|
2004-06-22 21:28:36 +00:00
|
|
|
#include "console.h"
|
|
|
|
#include "vga.h"
|
2005-10-10 21:51:02 +00:00
|
|
|
#include "driver.h"
|
2005-09-19 22:10:41 +00:00
|
|
|
#if defined(USE_CLI) && defined(__LINUX__)
|
2005-08-27 21:25:33 +00:00
|
|
|
#include "cli.h"
|
|
|
|
#endif
|
2004-02-15 20:46:45 +00:00
|
|
|
|
2005-05-13 17:25:13 +00:00
|
|
|
#ifdef ARCH_M68K
|
|
|
|
|
2005-09-19 19:03:39 +00:00
|
|
|
typedef void (*entry_t) (unsigned long , unsigned long , unsigned long, unsigned long );
|
2004-06-09 17:34:40 +00:00
|
|
|
typedef void (*disable_cache_t) (void);
|
2004-02-24 21:27:48 +00:00
|
|
|
|
2005-09-19 19:03:39 +00:00
|
|
|
extern void enter_kernelnoMMU(unsigned long addr, unsigned long size, unsigned long dest, unsigned long entry);
|
2005-05-16 21:38:33 +00:00
|
|
|
extern char end_enter_kernelnoMMU;
|
|
|
|
extern void noMMU_disable_cache(void);
|
2005-09-19 19:03:39 +00:00
|
|
|
extern void enter_kernel030(unsigned long addr, unsigned long size, unsigned long dest, unsigned long entry);
|
2004-03-06 01:10:31 +00:00
|
|
|
extern char end_enter_kernel030;
|
2004-06-09 17:34:40 +00:00
|
|
|
extern void MMU030_disable_cache(void);
|
2005-09-19 19:03:39 +00:00
|
|
|
extern void enter_kernel040(unsigned long addr, unsigned long size, unsigned long dest, unsigned long entry);
|
2004-03-06 01:10:31 +00:00
|
|
|
extern char end_enter_kernel040;
|
2004-06-09 17:34:40 +00:00
|
|
|
extern void MMU040_disable_cache(void);
|
2004-02-15 20:46:45 +00:00
|
|
|
|
2004-02-24 21:27:48 +00:00
|
|
|
#define PAGE_SHIFT 12
|
|
|
|
#define PAGE_SIZE (1UL << PAGE_SHIFT)
|
|
|
|
#define PAGE_MASK (~(PAGE_SIZE-1))
|
|
|
|
|
|
|
|
#define KERNEL_ALIGN (256L * 1024L) // Kernel alignment, on 256K boundary
|
2005-09-19 22:10:41 +00:00
|
|
|
#if defined(__LINUX__)
|
2005-05-13 17:25:13 +00:00
|
|
|
#define BI_ALLOC_SIZE (4096L) // Allocate 4K for bootinfo
|
2005-09-19 22:10:41 +00:00
|
|
|
#elif defined(__NETBSD__)
|
|
|
|
#define BI_ALLOC_SIZE (4096L)
|
|
|
|
#endif
|
2005-05-13 17:25:13 +00:00
|
|
|
|
|
|
|
#endif
|
|
|
|
#ifdef ARCH_PPC
|
|
|
|
#include "enter_kernelPPC.h"
|
|
|
|
#endif
|
2004-02-15 20:46:45 +00:00
|
|
|
|
2004-06-22 21:28:36 +00:00
|
|
|
int start(emile_l2_header_t* info)
|
2004-02-15 20:46:45 +00:00
|
|
|
{
|
|
|
|
char * kernel;
|
2005-05-12 05:48:27 +00:00
|
|
|
#ifdef ARCH_M68K
|
2005-05-22 21:16:57 +00:00
|
|
|
unsigned long physical;
|
2005-05-13 17:25:13 +00:00
|
|
|
entry_t entry;
|
|
|
|
unsigned long physImage;
|
2004-06-09 17:34:40 +00:00
|
|
|
disable_cache_t disable_cache;
|
2005-09-19 22:10:41 +00:00
|
|
|
#ifdef __LINUX__
|
2005-05-12 21:04:29 +00:00
|
|
|
unsigned long aligned_size;
|
|
|
|
unsigned long aligned_addr;
|
2005-09-19 22:10:41 +00:00
|
|
|
#endif /* __LINUX__ */
|
2004-03-06 01:10:31 +00:00
|
|
|
unsigned long enter_kernel;
|
|
|
|
unsigned long end_enter_kernel;
|
2005-05-13 17:25:13 +00:00
|
|
|
unsigned long start_mem;
|
2005-09-19 19:03:39 +00:00
|
|
|
unsigned long entry_point;
|
2005-09-19 22:10:41 +00:00
|
|
|
#endif /* ARCH_M68K */
|
2005-05-13 17:25:13 +00:00
|
|
|
#ifdef ARCH_PPC
|
|
|
|
PPCRegisterList regs;
|
|
|
|
#endif
|
|
|
|
int ret;
|
2004-06-03 22:39:38 +00:00
|
|
|
unsigned long ramdisk_start;
|
2005-05-16 21:38:33 +00:00
|
|
|
int bootstrap_size;
|
2004-02-15 20:46:45 +00:00
|
|
|
|
2005-05-22 23:16:54 +00:00
|
|
|
printf("Early Macintosh Image LoadEr"
|
2005-09-19 22:10:41 +00:00
|
|
|
#if defined(__LINUX__) && defined(__NETBSD__)
|
|
|
|
#error Cannot support LINUX AND NETBSD
|
|
|
|
#elif defined(__LINUX__)
|
|
|
|
" for Linux"
|
|
|
|
#elif defined(__NETBSD__)
|
|
|
|
" for NetBSD"
|
|
|
|
#endif
|
2005-05-16 21:38:33 +00:00
|
|
|
#if defined(ARCH_M68K) && defined(ARCH_PPC)
|
2005-05-22 23:16:54 +00:00
|
|
|
" (mixed mode)\n");
|
2005-05-16 21:38:33 +00:00
|
|
|
#elif defined(ARCH_M68K)
|
2005-09-19 22:10:41 +00:00
|
|
|
" on Motorola 680x0\n");
|
2005-05-10 21:49:28 +00:00
|
|
|
#elif defined(ARCH_PPC)
|
2005-09-19 22:10:41 +00:00
|
|
|
" on PowerPC\n");
|
2005-05-10 21:49:28 +00:00
|
|
|
#else
|
2005-05-22 23:16:54 +00:00
|
|
|
" (unknown processor)\n");
|
2005-05-10 21:49:28 +00:00
|
|
|
#endif
|
|
|
|
printf("EMILE v"VERSION" (c) 2004,2005 Laurent Vivier\n");
|
2004-02-15 20:46:45 +00:00
|
|
|
printf("This is free software, redistribute it under GPL\n");
|
|
|
|
|
2005-06-09 19:58:49 +00:00
|
|
|
if (!EMILE_COMPAT(EMILE_05_SIGNATURE, info->signature))
|
2004-06-22 21:28:36 +00:00
|
|
|
error("Bad header signature !\n");
|
|
|
|
|
2004-05-26 18:32:49 +00:00
|
|
|
arch_init();
|
|
|
|
|
|
|
|
init_memory_map();
|
|
|
|
|
2004-06-04 22:29:43 +00:00
|
|
|
#ifdef BANK_DUMP
|
|
|
|
bank_dump();
|
|
|
|
#endif
|
|
|
|
|
2004-12-25 00:53:59 +00:00
|
|
|
printf("Available Memory: %ld kB\n", bank_mem_avail() / 1024);
|
|
|
|
|
2004-10-07 09:09:58 +00:00
|
|
|
if (info->gestaltID != 0) {
|
|
|
|
machine_id = info->gestaltID;
|
|
|
|
printf("User forces gestalt ID to %ld\n", machine_id);
|
|
|
|
}
|
|
|
|
|
2004-12-25 01:35:31 +00:00
|
|
|
/* where is mapped my boot function ? */
|
|
|
|
|
2005-05-10 21:49:28 +00:00
|
|
|
#ifdef ARCH_M68K
|
2005-05-12 05:48:27 +00:00
|
|
|
if (arch_type == gestalt68k)
|
2004-12-25 01:35:31 +00:00
|
|
|
{
|
2005-05-12 05:48:27 +00:00
|
|
|
if (mmu_type == gestalt68040MMU)
|
|
|
|
{
|
2005-05-16 21:38:33 +00:00
|
|
|
printf("Using 68040 MMU\n");
|
2005-05-12 05:48:27 +00:00
|
|
|
enter_kernel = (unsigned long)enter_kernel040;
|
|
|
|
end_enter_kernel = (unsigned long)&end_enter_kernel040;
|
|
|
|
disable_cache = MMU040_disable_cache;
|
|
|
|
}
|
|
|
|
else if (mmu_type == gestalt68030MMU)
|
|
|
|
{
|
2005-05-16 21:38:33 +00:00
|
|
|
printf("Using 68030 MMU\n");
|
2005-05-12 05:48:27 +00:00
|
|
|
enter_kernel = (unsigned long)enter_kernel030;
|
|
|
|
end_enter_kernel = (unsigned long)&end_enter_kernel030;
|
|
|
|
disable_cache = MMU030_disable_cache;
|
|
|
|
}
|
|
|
|
else if (mmu_type == gestalt68851)
|
|
|
|
{
|
|
|
|
error("MMU 68851 is not supported");
|
|
|
|
}
|
|
|
|
else if (mmu_type == gestaltNoMMU)
|
|
|
|
{
|
2005-05-16 21:38:33 +00:00
|
|
|
printf("No MMU detected\n");
|
|
|
|
enter_kernel = (unsigned long)enter_kernelnoMMU;
|
|
|
|
end_enter_kernel = (unsigned long)&end_enter_kernelnoMMU;
|
|
|
|
disable_cache = noMMU_disable_cache;
|
2005-05-12 05:48:27 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
error("Unknown MMU");
|
2005-05-16 21:38:33 +00:00
|
|
|
|
2005-09-19 22:10:41 +00:00
|
|
|
#if defined(__LINUX__)
|
2005-05-16 21:38:33 +00:00
|
|
|
/* and BI_ALLOC_SIZE for bootinfo */
|
|
|
|
|
|
|
|
bootstrap_size = BI_ALLOC_SIZE +
|
|
|
|
end_enter_kernel - enter_kernel;
|
2005-09-19 22:10:41 +00:00
|
|
|
#elif defined(__NETBSD__)
|
|
|
|
bootstrap_size = BI_ALLOC_SIZE +
|
|
|
|
end_enter_kernel - enter_kernel;
|
|
|
|
#endif
|
2004-12-25 01:35:31 +00:00
|
|
|
}
|
2005-05-12 06:00:38 +00:00
|
|
|
else
|
|
|
|
#ifndef ARCH_PPC
|
|
|
|
error("EMILE doesn't support your architecture");
|
|
|
|
#endif
|
2005-05-10 21:49:28 +00:00
|
|
|
#endif
|
|
|
|
#ifdef ARCH_PPC
|
2005-05-16 21:38:33 +00:00
|
|
|
if (arch_type == gestaltPowerPC)
|
|
|
|
{
|
|
|
|
enter_kernel = NULL;
|
|
|
|
end_enter_kernel = NULL;
|
|
|
|
disable_cache = NULL;
|
|
|
|
bootstrap_size = 0;
|
|
|
|
}
|
|
|
|
else
|
2005-05-12 06:00:38 +00:00
|
|
|
error("EMILE doesn't support your architecture");
|
2005-05-10 21:49:28 +00:00
|
|
|
#endif
|
2004-12-25 01:35:31 +00:00
|
|
|
|
2004-06-01 22:00:21 +00:00
|
|
|
/* load kernel */
|
|
|
|
|
2005-06-09 19:58:49 +00:00
|
|
|
if (info->kernel_image_size == 0)
|
|
|
|
error("Kernel is missing !!!!\n");
|
|
|
|
|
2005-09-19 22:10:41 +00:00
|
|
|
#if defined(USE_CLI) && defined(__LINUX__)
|
2005-08-28 21:42:18 +00:00
|
|
|
printf("Parameters: ");
|
|
|
|
console_cursor_save();
|
|
|
|
printf("%s", info->command_line);
|
|
|
|
console_cursor_on();
|
2005-08-27 21:25:33 +00:00
|
|
|
if (console_keypressed(5 * 60))
|
|
|
|
{
|
2005-08-28 21:42:18 +00:00
|
|
|
console_cursor_restore();
|
2005-09-19 22:10:41 +00:00
|
|
|
cli_edit(info->command_line, COMMAND_LINE_LENGTH);
|
2005-08-27 21:25:33 +00:00
|
|
|
}
|
2005-08-28 21:42:18 +00:00
|
|
|
console_cursor_off();
|
2005-08-27 21:25:33 +00:00
|
|
|
putchar('\n');
|
2005-09-19 22:10:41 +00:00
|
|
|
#else
|
|
|
|
#ifdef __LINUX__
|
|
|
|
printf("%s\n", info->command_line);
|
|
|
|
#endif
|
|
|
|
#endif
|
2004-12-03 00:16:30 +00:00
|
|
|
#ifdef SCSI_SUPPORT
|
|
|
|
info->kernel_image_offset = (unsigned long)info->kernel_image_offset + (unsigned long)info;
|
|
|
|
#endif
|
2004-06-22 21:28:36 +00:00
|
|
|
printf("Kernel image size is %d Bytes\n", info->kernel_image_size);
|
2004-12-25 01:35:31 +00:00
|
|
|
|
|
|
|
/* allocate memory for kernel */
|
|
|
|
|
2005-06-09 19:58:49 +00:00
|
|
|
printf("Allocating %d bytes for kernel\n", info->kernel_size);
|
|
|
|
kernel = (char*)malloc_contiguous(info->kernel_size + 4 +
|
|
|
|
bootstrap_size
|
2005-05-13 17:25:13 +00:00
|
|
|
);
|
2005-06-09 19:58:49 +00:00
|
|
|
if (kernel == 0)
|
|
|
|
{
|
|
|
|
printf("cannot allocate %d bytes\n", info->kernel_size);
|
|
|
|
while(1);
|
|
|
|
}
|
2004-12-25 01:35:31 +00:00
|
|
|
|
2005-06-09 19:58:49 +00:00
|
|
|
/* align kernel address to a 4 byte word */
|
2004-12-25 00:53:59 +00:00
|
|
|
|
2005-06-09 19:58:49 +00:00
|
|
|
kernel = (unsigned char*)(((unsigned long)kernel + 3) & 0xFFFFFFFC);
|
2004-12-25 01:35:31 +00:00
|
|
|
|
2005-06-27 22:22:37 +00:00
|
|
|
printf("Kernel image base at %p\n", kernel);
|
2004-06-01 22:00:21 +00:00
|
|
|
|
2005-06-09 19:58:49 +00:00
|
|
|
if (!check_full_in_bank((unsigned long)kernel, info->kernel_size))
|
|
|
|
error("Kernel between two banks, contact maintainer\n");
|
2004-02-26 22:51:37 +00:00
|
|
|
|
2005-06-09 19:58:49 +00:00
|
|
|
/* load kernel */
|
|
|
|
|
|
|
|
printf("Loading kernel...\n");
|
|
|
|
if (info->kernel_size == info->kernel_image_size) /* means uncompressed */
|
2004-02-15 20:46:45 +00:00
|
|
|
{
|
2005-06-09 19:58:49 +00:00
|
|
|
/* load kernel */
|
2004-06-01 22:00:21 +00:00
|
|
|
|
2005-06-09 19:58:49 +00:00
|
|
|
ret = load_image((unsigned long)info->kernel_image_offset,
|
|
|
|
info->kernel_size, kernel);
|
|
|
|
if (ret == -1)
|
|
|
|
error("Cannot load kernel image\n");
|
2004-12-25 01:35:31 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2005-06-09 19:58:49 +00:00
|
|
|
/* load and uncompress kernel */
|
2004-02-15 20:46:45 +00:00
|
|
|
|
2005-06-09 19:58:49 +00:00
|
|
|
ret = load_gzip((unsigned long)info->kernel_image_offset,
|
|
|
|
info->kernel_image_size, kernel);
|
|
|
|
if (ret == -1)
|
|
|
|
error("Cannot load and uncompress kernel image\n");
|
2004-12-24 22:36:45 +00:00
|
|
|
}
|
2004-06-07 18:52:31 +00:00
|
|
|
|
2005-05-13 17:25:13 +00:00
|
|
|
#ifdef ARCH_M68K
|
2005-05-16 21:38:33 +00:00
|
|
|
if (arch_type == gestalt68k)
|
|
|
|
{
|
2005-09-19 22:10:41 +00:00
|
|
|
unsigned long enter_size = end_enter_kernel - enter_kernel;
|
|
|
|
|
2005-05-16 21:38:33 +00:00
|
|
|
/* copy enter_kernel at end of kernel */
|
2004-02-15 20:46:45 +00:00
|
|
|
|
2005-09-19 22:10:41 +00:00
|
|
|
memcpy((char*)kernel +
|
|
|
|
info->kernel_size + bootstrap_size - enter_size,
|
|
|
|
(char*)enter_kernel, enter_size);
|
2004-06-01 22:00:21 +00:00
|
|
|
|
2005-09-19 22:10:41 +00:00
|
|
|
end_enter_kernel = (unsigned long)kernel +
|
|
|
|
info->kernel_size + bootstrap_size;
|
|
|
|
enter_kernel = (unsigned long)kernel +
|
|
|
|
bootstrap_size - enter_size + info->kernel_size;
|
2005-05-16 21:38:33 +00:00
|
|
|
}
|
2005-05-13 17:25:13 +00:00
|
|
|
#endif
|
2004-06-01 22:00:21 +00:00
|
|
|
|
|
|
|
/* load ramdisk if needed */
|
|
|
|
|
2004-06-04 22:29:43 +00:00
|
|
|
if (info->ramdisk_size != 0)
|
2004-06-01 22:00:21 +00:00
|
|
|
{
|
2004-06-22 21:28:36 +00:00
|
|
|
printf("RAMDISK size is %d Bytes\n", info->ramdisk_size);
|
2005-09-05 21:11:12 +00:00
|
|
|
ramdisk_start = (unsigned long)malloc_top(
|
2004-12-25 00:53:59 +00:00
|
|
|
info->ramdisk_size + 4);
|
|
|
|
ramdisk_start = (ramdisk_start + 3) & 0xFFFFFFFC;
|
|
|
|
printf("RAMDISK base at 0x%lx\n", ramdisk_start);
|
|
|
|
|
|
|
|
printf("Loading RAMDISK...\n");
|
|
|
|
ret = load_image((unsigned long)info->ramdisk_offset,
|
|
|
|
info->ramdisk_size, (char*)ramdisk_start);
|
|
|
|
if (ret == -1)
|
|
|
|
error("Cannot load ramdisk\n");
|
|
|
|
|
2004-07-12 21:32:44 +00:00
|
|
|
if (!check_full_in_bank(ramdisk_start, info->ramdisk_size))
|
2004-12-24 22:36:45 +00:00
|
|
|
error("ramdisk between two banks, contact maintainer\n");
|
2004-06-01 22:00:21 +00:00
|
|
|
}
|
2004-06-03 08:11:23 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
ramdisk_start = 0;
|
|
|
|
printf("no RAMDISK\n");
|
|
|
|
}
|
2004-06-16 17:22:22 +00:00
|
|
|
|
2005-05-12 05:48:27 +00:00
|
|
|
#ifdef ARCH_M68K
|
|
|
|
if (arch_type == gestalt68k)
|
|
|
|
{
|
2005-06-14 19:39:43 +00:00
|
|
|
/* compute final address of kernel */
|
2004-02-23 00:20:11 +00:00
|
|
|
|
2005-06-14 19:39:43 +00:00
|
|
|
if (mmu_type == gestaltNoMMU)
|
|
|
|
{
|
|
|
|
unsigned long size = end_enter_kernel - enter_kernel;
|
|
|
|
|
2005-09-19 22:10:41 +00:00
|
|
|
#if defined(__LINUX__)
|
2005-09-07 00:29:22 +00:00
|
|
|
/* initialize bootinfo structure */
|
|
|
|
|
|
|
|
bootinfo_init(info->command_line,
|
|
|
|
(char*)ramdisk_start, info->ramdisk_size);
|
|
|
|
|
|
|
|
/* set bootinfo at end of kernel image */
|
|
|
|
|
|
|
|
set_kernel_bootinfo(kernel + info->kernel_size);
|
|
|
|
|
2005-06-14 20:15:46 +00:00
|
|
|
physImage = (unsigned long)kernel;
|
2005-06-30 08:55:28 +00:00
|
|
|
start_mem = KERNEL_BASEADDR + 0x1000;
|
2005-09-19 19:03:39 +00:00
|
|
|
entry_point = start_mem;
|
2005-09-19 22:10:41 +00:00
|
|
|
#elif defined(__NETBSD__)
|
|
|
|
start_mem = 0;
|
|
|
|
entry_point = 0x2e00;
|
|
|
|
#endif
|
2005-06-14 19:39:43 +00:00
|
|
|
entry = (entry_t)(start_mem - size);
|
2005-05-14 01:12:46 +00:00
|
|
|
|
2005-06-14 19:39:43 +00:00
|
|
|
printf("\n");
|
|
|
|
printf("Physical address of kernel will be 0x%08lx\n",
|
|
|
|
start_mem);
|
|
|
|
printf("Ok, booting the kernel.\n");
|
2004-02-23 00:20:11 +00:00
|
|
|
|
2005-06-14 19:39:43 +00:00
|
|
|
memcpy(entry, (char*)enter_kernel, size);
|
|
|
|
}
|
|
|
|
else
|
2005-05-12 05:48:27 +00:00
|
|
|
{
|
2005-06-14 19:39:43 +00:00
|
|
|
ret = logical2physical((unsigned long)kernel, &physImage);
|
2005-09-07 00:29:22 +00:00
|
|
|
|
2005-06-14 19:39:43 +00:00
|
|
|
/* disable and flush cache */
|
|
|
|
|
|
|
|
disable_cache();
|
2004-02-21 01:43:51 +00:00
|
|
|
|
2005-09-19 22:10:41 +00:00
|
|
|
#if defined(__LINUX__)
|
2005-09-07 00:29:22 +00:00
|
|
|
/* initialize bootinfo structure */
|
|
|
|
|
|
|
|
bootinfo_init(info->command_line,
|
|
|
|
(char*)ramdisk_start, info->ramdisk_size);
|
|
|
|
|
2005-06-14 19:39:43 +00:00
|
|
|
/* add KERNEL_ALIGN if we have to align */
|
|
|
|
|
|
|
|
aligned_size = boot_info.memory[0].addr & (KERNEL_ALIGN - 1);
|
|
|
|
if ( aligned_size > 0 )
|
|
|
|
{
|
|
|
|
aligned_size = KERNEL_ALIGN - aligned_size;
|
|
|
|
aligned_addr = boot_info.memory[0].addr + aligned_size;
|
|
|
|
aligned_size = boot_info.memory[0].size - aligned_size;
|
|
|
|
boot_info.memory[0].addr = aligned_addr;
|
|
|
|
boot_info.memory[0].size = aligned_size;
|
|
|
|
}
|
|
|
|
|
2005-09-07 00:29:22 +00:00
|
|
|
/* set bootinfo at end of kernel image */
|
|
|
|
|
|
|
|
set_kernel_bootinfo(kernel + info->kernel_size);
|
|
|
|
|
2005-06-14 19:39:43 +00:00
|
|
|
start_mem = boot_info.memory[0].addr + PAGE_SIZE;
|
2005-09-19 19:03:39 +00:00
|
|
|
entry_point = start_mem;
|
2005-09-19 22:10:41 +00:00
|
|
|
#elif defined(__NETBSD__)
|
|
|
|
bootenv_init(kernel + info->kernel_size);
|
|
|
|
start_mem = 0;
|
|
|
|
entry_point = 0x2e00;
|
|
|
|
#endif
|
2005-06-14 19:39:43 +00:00
|
|
|
|
|
|
|
printf("\n");
|
|
|
|
printf("Physical address of kernel will be 0x%08lx\n",
|
|
|
|
start_mem);
|
|
|
|
printf("Ok, booting the kernel.\n");
|
|
|
|
|
|
|
|
ret = logical2physical(enter_kernel, &physical);
|
2005-05-22 21:16:57 +00:00
|
|
|
entry = (entry_t)physical;
|
2005-06-14 19:39:43 +00:00
|
|
|
|
|
|
|
if ( (ret == 0) && (enter_kernel != (unsigned long)entry) )
|
|
|
|
{
|
|
|
|
unsigned long logi;
|
|
|
|
unsigned long size = end_enter_kernel - enter_kernel;
|
|
|
|
|
|
|
|
logi = vga_get_video();
|
|
|
|
ret = logical2physical(logi, &physical);
|
|
|
|
entry = (entry_t)physical;
|
2004-02-21 01:43:51 +00:00
|
|
|
|
2005-06-14 19:39:43 +00:00
|
|
|
memcpy((char*)logi, (char*)enter_kernel, size);
|
|
|
|
memcpy((char*)entry, (char*)enter_kernel, size);
|
|
|
|
}
|
2005-05-12 05:48:27 +00:00
|
|
|
}
|
|
|
|
}
|
2005-05-12 06:00:38 +00:00
|
|
|
else
|
|
|
|
#ifndef ARCH_PPC
|
|
|
|
error("EMILE doesn't support your architecture");
|
|
|
|
#endif
|
2005-05-12 05:48:27 +00:00
|
|
|
#endif /* ARCH_M68K */
|
|
|
|
#ifdef ARCH_PPC
|
|
|
|
if (arch_type == gestaltPowerPC)
|
|
|
|
{
|
|
|
|
bootx_init(info->command_line,
|
|
|
|
(char*)ramdisk_start, info->ramdisk_size);
|
2005-05-13 17:25:13 +00:00
|
|
|
|
|
|
|
regs.PC = (u_int32_t)kernel;
|
|
|
|
#define BOOT_KERNEL_STACK_SIZE 65536
|
|
|
|
regs.GPR[1] = (u_int32_t)malloc_contiguous(BOOT_KERNEL_STACK_SIZE)
|
|
|
|
+ BOOT_KERNEL_STACK_SIZE - 512;
|
|
|
|
regs.GPR[2] = 0;
|
|
|
|
regs.GPR[3] = 'BooX';
|
|
|
|
regs.GPR[4] = (u_int32_t)&bootx_infos;
|
2005-05-13 22:35:58 +00:00
|
|
|
|
|
|
|
/* Set up the info for BAT mapping on Nubus */
|
|
|
|
|
|
|
|
regs.GPR[5] = vga_get_videobase() & 0xFF800000UL;
|
|
|
|
regs.GPR[11] = 1;
|
2005-05-13 17:25:13 +00:00
|
|
|
|
|
|
|
printf("\n");
|
|
|
|
printf("Physical address of kernel will be 0x%08lx\n",
|
|
|
|
(unsigned long)kernel);
|
2005-05-14 01:12:46 +00:00
|
|
|
printf("Ok, booting the kernel.\n");
|
2004-02-21 01:43:51 +00:00
|
|
|
}
|
2005-05-14 01:12:46 +00:00
|
|
|
else
|
|
|
|
error("EMILE doesn't support your architecture");
|
2005-05-12 05:48:27 +00:00
|
|
|
#endif
|
2005-10-10 21:51:02 +00:00
|
|
|
|
|
|
|
turn_off_interrupts();
|
|
|
|
|
2005-05-25 22:05:35 +00:00
|
|
|
asm("ori.w #0x0700,%sr");
|
2005-05-12 05:48:27 +00:00
|
|
|
|
2004-06-09 17:34:40 +00:00
|
|
|
/* kick off */
|
|
|
|
|
2005-05-13 17:25:13 +00:00
|
|
|
#ifdef ARCH_M68K
|
|
|
|
if (arch_type == gestalt68k)
|
2005-09-19 19:03:39 +00:00
|
|
|
entry(physImage, info->kernel_size + BI_ALLOC_SIZE, start_mem, entry_point);
|
2005-05-13 17:25:13 +00:00
|
|
|
#endif
|
|
|
|
#ifdef ARCH_PPC
|
|
|
|
if (arch_type == gestaltPowerPC)
|
|
|
|
enter_kernelPPC((unsigned long)kernel, ®s);
|
|
|
|
#endif
|
2004-02-15 20:46:45 +00:00
|
|
|
|
2005-05-13 22:35:58 +00:00
|
|
|
error("Kernel startup failed");
|
|
|
|
|
2004-02-15 20:46:45 +00:00
|
|
|
return 0;
|
|
|
|
}
|