1994-02-11 10:00:37 +03:00
|
|
|
/*
|
1994-03-28 10:15:55 +04:00
|
|
|
* $Id: loadbsd.c,v 1.9 1994/03/28 06:16:54 chopps Exp $
|
1994-02-11 10:00:37 +03:00
|
|
|
*/
|
|
|
|
|
1993-07-05 23:19:41 +04:00
|
|
|
#include <sys/types.h>
|
|
|
|
#include <a.out.h>
|
|
|
|
#include <stdio.h>
|
1994-03-20 13:05:11 +03:00
|
|
|
#include <unistd.h>
|
1993-07-05 23:19:41 +04:00
|
|
|
|
|
|
|
#include <exec/types.h>
|
|
|
|
#include <exec/execbase.h>
|
|
|
|
#include <exec/memory.h>
|
|
|
|
#include <libraries/configregs.h>
|
|
|
|
#include <libraries/expansionbase.h>
|
1994-01-27 00:15:02 +03:00
|
|
|
#include <graphics/gfxbase.h>
|
1993-07-05 23:19:41 +04:00
|
|
|
|
|
|
|
#include <inline/exec.h>
|
|
|
|
#include <inline/expansion.h>
|
1994-01-27 00:15:02 +03:00
|
|
|
#include <inline/graphics.h>
|
1993-07-05 23:19:41 +04:00
|
|
|
|
1993-09-02 22:05:24 +04:00
|
|
|
/* Get definitions for boothowto */
|
|
|
|
#include "reboot.h"
|
|
|
|
|
1994-02-01 14:54:29 +03:00
|
|
|
static char usage[] =
|
|
|
|
"
|
|
|
|
NAME
|
|
|
|
\t%s - loads NetBSD from amiga dos.
|
|
|
|
SYNOPSIS
|
|
|
|
\t%s some-vmunix [-a] [-b] [-k] [-m memory] [-p] [-t] [-V]
|
|
|
|
OPTIONS
|
|
|
|
\t-a Boot up to multiuser mode.
|
|
|
|
\t-b Ask for which root device.
|
|
|
|
\t Its possible to have multiple roots and choose between them.
|
|
|
|
\t-k Reserve the first 4M of fast mem [Some one else
|
|
|
|
\t is going to have to answer what that it is used for].
|
|
|
|
\t-m Tweak amount of available memory, for finding minimum amount
|
|
|
|
\t of memory required to run. Sets fastmem size to specified
|
|
|
|
\t size in Kbytes.
|
|
|
|
\t-p Use highest priority fastmem segement instead of the largest
|
|
|
|
\t segment. The higher priority segment is usually faster
|
|
|
|
\t (i.e. 32 bit memory), but some people have smaller amounts
|
|
|
|
\t of 32 bit memory.
|
|
|
|
\t-t This is a *test* option. It prints out the memory
|
|
|
|
\t list information being passed to the kernel and also
|
|
|
|
\t exits without actually starting NetBSD.
|
1994-03-20 13:05:11 +03:00
|
|
|
\t-S Include kernel symbol table.
|
1994-02-01 14:54:29 +03:00
|
|
|
\t-V Version of loadbsd program.
|
|
|
|
HISTORY
|
|
|
|
This version supports Kernel version 720 +
|
|
|
|
";
|
|
|
|
|
1993-07-05 23:19:41 +04:00
|
|
|
struct ExpansionBase *ExpansionBase;
|
1994-01-27 00:15:02 +03:00
|
|
|
struct GfxBase *GfxBase;
|
1993-07-05 23:19:41 +04:00
|
|
|
|
|
|
|
#undef __LDPGSZ
|
|
|
|
#define __LDPGSZ 8192
|
|
|
|
|
1994-01-27 00:15:02 +03:00
|
|
|
#define MAX_MEM_SEG 16
|
|
|
|
|
1994-02-01 14:54:29 +03:00
|
|
|
/*
|
|
|
|
* Kernel parameter passing version
|
1994-03-20 13:05:11 +03:00
|
|
|
* 1: first version of loadbsd
|
|
|
|
* 2: needs esym location passed in a4
|
1994-02-01 14:54:29 +03:00
|
|
|
*/
|
1994-03-20 13:05:11 +03:00
|
|
|
#define KERNEL_PARAMETER_VERSION 2
|
1994-02-01 14:54:29 +03:00
|
|
|
|
1994-03-28 10:15:55 +04:00
|
|
|
/*
|
|
|
|
* Version history:
|
|
|
|
* 1.x Kernel parameter passing version check
|
|
|
|
* 2.0 Added symbol table end address and symbol table support
|
|
|
|
* 2.1 03/23/94 - round up end of fastram segment
|
|
|
|
* check fastram segment size for minimum of 2M
|
|
|
|
* use largest segment of highest priority if -p option
|
|
|
|
* print out fastram size in KB if not a multiple of MB
|
|
|
|
* 2.2 03/24/94 - zero out all unused registers
|
|
|
|
* started version history comment
|
|
|
|
*/
|
|
|
|
|
1994-01-27 00:15:02 +03:00
|
|
|
struct MEM_LIST {
|
|
|
|
u_long num_mem;
|
|
|
|
struct MEM_SEG {
|
|
|
|
u_long mem_start;
|
|
|
|
u_long mem_size;
|
|
|
|
u_short mem_attrib;
|
|
|
|
short mem_prio;
|
|
|
|
} mem_seg[MAX_MEM_SEG];
|
|
|
|
} mem_list, *kmem_list;
|
|
|
|
|
|
|
|
int k_opt;
|
|
|
|
int a_opt;
|
|
|
|
int b_opt;
|
|
|
|
int p_opt;
|
|
|
|
int t_opt;
|
1994-02-01 14:54:29 +03:00
|
|
|
int m_opt;
|
1994-03-20 13:05:11 +03:00
|
|
|
int S_opt;
|
1994-01-27 00:15:02 +03:00
|
|
|
|
|
|
|
extern char *optarg;
|
|
|
|
extern int optind;
|
|
|
|
|
1993-07-05 23:19:41 +04:00
|
|
|
void get_mem_config (void **fastmem_start, u_long *fastmem_size, u_long *chipmem_size);
|
1994-02-01 14:54:29 +03:00
|
|
|
void Usage (char *program_name);
|
|
|
|
void Version (void);
|
|
|
|
|
1994-03-28 10:15:55 +04:00
|
|
|
static const char _version[] = "$VER: LoadBSD 2.2 (24.3.94)";
|
1993-07-05 23:19:41 +04:00
|
|
|
|
|
|
|
int
|
|
|
|
main (int argc, char *argv[])
|
|
|
|
{
|
|
|
|
struct exec e;
|
|
|
|
int fd;
|
1993-09-02 22:05:24 +04:00
|
|
|
int boothowto = RB_SINGLE;
|
1993-07-05 23:19:41 +04:00
|
|
|
|
|
|
|
if (argc >= 2)
|
|
|
|
{
|
|
|
|
if ((fd = open (argv[1], 0)) >= 0)
|
|
|
|
{
|
|
|
|
if (read (fd, &e, sizeof (e)) == sizeof (e))
|
|
|
|
{
|
|
|
|
if (e.a_magic == NMAGIC)
|
|
|
|
{
|
|
|
|
u_char *kernel;
|
1994-03-20 13:05:11 +03:00
|
|
|
int kernel_size;
|
1993-07-05 23:19:41 +04:00
|
|
|
int text_size;
|
|
|
|
struct ConfigDev *cd;
|
|
|
|
int num_cd;
|
1994-01-27 00:15:02 +03:00
|
|
|
void *fastmem_start;
|
|
|
|
u_long fastmem_size, chipmem_size;
|
|
|
|
int i;
|
1994-02-01 14:54:29 +03:00
|
|
|
u_short *kern_vers;
|
1994-03-20 13:05:11 +03:00
|
|
|
char *esym;
|
|
|
|
int string_size;
|
1993-07-05 23:19:41 +04:00
|
|
|
|
1994-01-27 00:15:02 +03:00
|
|
|
GfxBase = (struct GfxBase *) OpenLibrary ("graphics.library", 0);
|
|
|
|
if (! GfxBase) /* not supposed to fail... */
|
|
|
|
abort();
|
1993-07-05 23:19:41 +04:00
|
|
|
ExpansionBase= (struct ExpansionBase *) OpenLibrary ("expansion.library", 0);
|
|
|
|
if (! ExpansionBase) /* not supposed to fail... */
|
|
|
|
abort();
|
1994-01-27 00:15:02 +03:00
|
|
|
optind = 2;
|
1994-03-20 13:05:11 +03:00
|
|
|
while ((i = getopt (argc, argv, "kabptVm:S")) != EOF)
|
1994-01-27 00:15:02 +03:00
|
|
|
switch (i) {
|
|
|
|
case 'k':
|
|
|
|
k_opt = 1;
|
|
|
|
break;
|
|
|
|
case 'a':
|
|
|
|
a_opt = 1;
|
|
|
|
break;
|
|
|
|
case 'b':
|
|
|
|
b_opt = 1;
|
|
|
|
break;
|
|
|
|
case 'p':
|
|
|
|
p_opt = 1;
|
|
|
|
break;
|
|
|
|
case 't':
|
|
|
|
t_opt = 1;
|
|
|
|
break;
|
1994-02-01 14:54:29 +03:00
|
|
|
case 'm':
|
|
|
|
m_opt = atoi (optarg) * 1024;
|
|
|
|
break;
|
|
|
|
case 'V':
|
|
|
|
Version();
|
|
|
|
break;
|
1994-03-20 13:05:11 +03:00
|
|
|
case 'S':
|
|
|
|
S_opt = 1;
|
|
|
|
break;
|
1994-02-01 14:54:29 +03:00
|
|
|
default:
|
|
|
|
Usage(argv[0]);
|
|
|
|
fprintf(stderr,"Unrecognized option \n");
|
|
|
|
exit(-1);
|
1994-01-27 00:15:02 +03:00
|
|
|
}
|
|
|
|
|
1993-07-05 23:19:41 +04:00
|
|
|
for (cd = 0, num_cd = 0; cd = FindConfigDev (cd, -1, -1); num_cd++) ;
|
1994-01-27 00:15:02 +03:00
|
|
|
get_mem_config (&fastmem_start, &fastmem_size, &chipmem_size);
|
1993-07-05 23:19:41 +04:00
|
|
|
|
|
|
|
text_size = (e.a_text + __LDPGSZ - 1) & (-__LDPGSZ);
|
1994-03-20 13:05:11 +03:00
|
|
|
esym = NULL;
|
|
|
|
kernel_size = text_size + e.a_data + e.a_bss
|
|
|
|
+ num_cd*sizeof(*cd) + 4
|
|
|
|
+ mem_list.num_mem*sizeof(struct MEM_SEG) + 4;
|
|
|
|
/*
|
|
|
|
* get symbol table size & string size
|
|
|
|
* (should check kernel version to see if it will handle it)
|
|
|
|
*/
|
|
|
|
if (S_opt && e.a_syms) {
|
|
|
|
S_opt = 0; /* prepare for failure */
|
|
|
|
if (lseek(fd, e.a_text + e.a_data + e.a_syms, SEEK_CUR) > 0) {
|
|
|
|
if (read (fd, &string_size, 4) == 4) {
|
|
|
|
if (lseek(fd, sizeof(e), SEEK_SET) < 0) {
|
|
|
|
printf ("Error repositioning to text\n");
|
|
|
|
exit(0); /* Give up! */
|
|
|
|
}
|
|
|
|
kernel_size += e.a_syms + 4 + string_size;
|
|
|
|
S_opt = 1; /* sucess! Keep -S option */
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
kernel = (u_char *) malloc (kernel_size);
|
1994-01-27 00:15:02 +03:00
|
|
|
|
|
|
|
if (t_opt)
|
|
|
|
for (i = 0; i < mem_list.num_mem; ++i) {
|
|
|
|
printf ("mem segment %d: start=%08lx size=%08lx attribute=%04lx pri=%d\n",
|
|
|
|
i + 1, mem_list.mem_seg[i].mem_start,
|
|
|
|
mem_list.mem_seg[i].mem_size,
|
|
|
|
mem_list.mem_seg[i].mem_attrib,
|
|
|
|
mem_list.mem_seg[i].mem_prio);
|
|
|
|
}
|
1993-07-05 23:19:41 +04:00
|
|
|
|
|
|
|
if (kernel)
|
|
|
|
{
|
|
|
|
if (read (fd, kernel, e.a_text) == e.a_text
|
|
|
|
&& read (fd, kernel + text_size, e.a_data) == e.a_data)
|
|
|
|
{
|
|
|
|
int *knum_cd;
|
|
|
|
struct ConfigDev *kcd;
|
1994-01-27 00:15:02 +03:00
|
|
|
int mem_ix;
|
1994-03-20 13:05:11 +03:00
|
|
|
|
1994-01-27 00:15:02 +03:00
|
|
|
if (k_opt)
|
1993-07-05 23:19:41 +04:00
|
|
|
{
|
|
|
|
fastmem_start += 4*1024*1024;
|
|
|
|
fastmem_size -= 4*1024*1024;
|
|
|
|
}
|
1994-02-01 14:54:29 +03:00
|
|
|
|
|
|
|
if (m_opt && m_opt <= fastmem_size)
|
|
|
|
{
|
|
|
|
fastmem_size = m_opt;
|
|
|
|
}
|
1993-07-05 23:19:41 +04:00
|
|
|
|
1994-01-27 00:15:02 +03:00
|
|
|
if (a_opt)
|
1993-09-02 22:05:24 +04:00
|
|
|
{
|
|
|
|
printf("Autobooting...");
|
|
|
|
boothowto = RB_AUTOBOOT;
|
|
|
|
}
|
1994-01-27 00:15:02 +03:00
|
|
|
|
|
|
|
if (b_opt)
|
|
|
|
{
|
|
|
|
printf("Askboot...");
|
|
|
|
boothowto |= RB_ASKNAME;
|
|
|
|
}
|
1993-09-02 22:05:24 +04:00
|
|
|
|
1994-03-28 10:15:55 +04:00
|
|
|
printf ("Using %d%c FASTMEM at 0x%x, %dM CHIPMEM\n",
|
|
|
|
(fastmem_size & 0xfffff) ? fastmem_size>>10 :
|
|
|
|
fastmem_size>>20,
|
|
|
|
(fastmem_size & 0xfffff) ? 'K' : 'M',
|
|
|
|
fastmem_start, chipmem_size>>20);
|
1994-02-01 14:54:29 +03:00
|
|
|
kern_vers = (u_short *) (kernel + e.a_entry - 2);
|
|
|
|
if (*kern_vers > KERNEL_PARAMETER_VERSION &&
|
|
|
|
*kern_vers != 0x4e73)
|
|
|
|
{
|
|
|
|
printf ("This kernel requires a newer version of loadbsd: %d\n", *kern_vers);
|
|
|
|
exit (0);
|
|
|
|
}
|
1993-07-05 23:19:41 +04:00
|
|
|
/* give them a chance to read the information... */
|
|
|
|
sleep(2);
|
|
|
|
|
|
|
|
bzero (kernel + text_size + e.a_data, e.a_bss);
|
1994-03-20 13:05:11 +03:00
|
|
|
/*
|
|
|
|
* If symbols wanted (and kernel can handle them),
|
|
|
|
* load symbol table & strings and set esym to end.
|
|
|
|
*/
|
1993-07-05 23:19:41 +04:00
|
|
|
knum_cd = (int *) (kernel + text_size + e.a_data + e.a_bss);
|
1994-03-20 13:05:11 +03:00
|
|
|
if (*kern_vers != 0x4e73 && *kern_vers > 1 && S_opt && e.a_syms) {
|
|
|
|
*knum_cd++ = e.a_syms;
|
|
|
|
read(fd, (char *)knum_cd, e.a_syms);
|
|
|
|
knum_cd = (int *)((char *)knum_cd + e.a_syms);
|
|
|
|
read(fd, (char *)knum_cd, string_size);
|
|
|
|
knum_cd = (int*)((char *)knum_cd + string_size);
|
|
|
|
esym = (char *) (text_size + e.a_data + e.a_bss
|
|
|
|
+ e.a_syms + 4 + string_size);
|
|
|
|
}
|
1993-07-05 23:19:41 +04:00
|
|
|
*knum_cd = num_cd;
|
1994-01-27 00:15:02 +03:00
|
|
|
for (kcd = (struct ConfigDev *) (knum_cd+1);
|
|
|
|
cd = FindConfigDev (cd, -1, -1);
|
1994-02-01 14:54:29 +03:00
|
|
|
*kcd++ = *cd)
|
|
|
|
;
|
1994-01-27 00:15:02 +03:00
|
|
|
kmem_list = (struct MEM_LIST *)kcd;
|
|
|
|
kmem_list->num_mem = mem_list.num_mem;
|
|
|
|
for (mem_ix = 0; mem_ix < mem_list.num_mem; mem_ix++)
|
|
|
|
kmem_list->mem_seg[mem_ix] = mem_list.mem_seg[mem_ix];
|
1994-03-20 13:05:11 +03:00
|
|
|
if (t_opt) /* if test option */
|
|
|
|
exit (0); /* don't start kernel */
|
|
|
|
/* AGA startup - may need more */
|
1994-01-27 00:15:02 +03:00
|
|
|
LoadView (NULL);
|
1994-03-20 13:05:11 +03:00
|
|
|
startit (kernel, kernel_size,
|
1993-07-05 23:19:41 +04:00
|
|
|
e.a_entry, fastmem_start,
|
1993-09-02 22:05:24 +04:00
|
|
|
fastmem_size, chipmem_size,
|
1994-03-20 13:05:11 +03:00
|
|
|
boothowto, esym );
|
1993-07-05 23:19:41 +04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
fprintf (stderr, "Executable corrupt!\n");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
fprintf (stderr, "Out of memory! (%d)\n", text_size + e.a_data + e.a_bss
|
1994-01-27 00:15:02 +03:00
|
|
|
+ num_cd*sizeof(*cd) + 4
|
|
|
|
+ mem_list.num_mem*sizeof(struct MEM_SEG) + 4);
|
1993-07-05 23:19:41 +04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
fprintf (stderr, "Unsupported executable: %o\n", e.a_magic);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
fprintf (stderr, "Can't read header of %s\n", argv[1]);
|
|
|
|
|
|
|
|
close (fd);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
perror ("open");
|
|
|
|
}
|
|
|
|
else
|
1994-02-01 14:54:29 +03:00
|
|
|
Usage(argv[0]);
|
|
|
|
Version();
|
|
|
|
}/* main() */
|
1993-07-05 23:19:41 +04:00
|
|
|
|
|
|
|
void
|
|
|
|
get_mem_config (void **fastmem_start, u_long *fastmem_size, u_long *chipmem_size)
|
|
|
|
{
|
|
|
|
extern struct ExecBase *SysBase;
|
|
|
|
struct MemHeader *mh, *nmh;
|
1994-01-27 00:15:02 +03:00
|
|
|
int num_mem = 0;
|
|
|
|
u_int seg_size;
|
|
|
|
u_int seg_start;
|
|
|
|
u_int seg_end;
|
1994-03-28 10:15:55 +04:00
|
|
|
char mem_pri = -128;
|
1993-07-05 23:19:41 +04:00
|
|
|
|
|
|
|
*fastmem_size = 0;
|
|
|
|
*chipmem_size = 0;
|
|
|
|
|
|
|
|
/* walk thru the exec memory list */
|
|
|
|
Forbid ();
|
|
|
|
for (mh = (struct MemHeader *) SysBase->MemList.lh_Head;
|
|
|
|
nmh = (struct MemHeader *) mh->mh_Node.ln_Succ;
|
1994-01-27 00:15:02 +03:00
|
|
|
mh = nmh, num_mem++)
|
1993-07-05 23:19:41 +04:00
|
|
|
{
|
1994-01-27 00:15:02 +03:00
|
|
|
mem_list.mem_seg[num_mem].mem_attrib = mh->mh_Attributes;
|
|
|
|
mem_list.mem_seg[num_mem].mem_prio = mh->mh_Node.ln_Pri;
|
|
|
|
seg_start = (u_int)mh->mh_Lower;
|
|
|
|
seg_end = (u_int)mh->mh_Upper;
|
|
|
|
seg_size = seg_end - seg_start;
|
|
|
|
mem_list.mem_seg[num_mem].mem_size = seg_size;
|
|
|
|
mem_list.mem_seg[num_mem].mem_start = seg_start;
|
|
|
|
|
1993-07-05 23:19:41 +04:00
|
|
|
if (mh->mh_Attributes & MEMF_CHIP)
|
|
|
|
{
|
|
|
|
/* there should hardly be more than one entry for chip mem, but
|
|
|
|
handle it the same nevertheless */
|
1994-01-27 00:15:02 +03:00
|
|
|
/* chipmem always starts at 0, so include vector area */
|
1994-02-01 14:54:29 +03:00
|
|
|
mem_list.mem_seg[num_mem].mem_start = seg_start = 0;
|
1994-01-27 00:15:02 +03:00
|
|
|
/* round to multiple of 512K */
|
|
|
|
seg_size = (seg_size + 512*1024 - 1) & -(512*1024);
|
|
|
|
mem_list.mem_seg[num_mem].mem_size = seg_size;
|
|
|
|
if (seg_size > *chipmem_size)
|
1993-07-05 23:19:41 +04:00
|
|
|
{
|
1994-01-27 00:15:02 +03:00
|
|
|
*chipmem_size = seg_size;
|
1993-07-05 23:19:41 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
1994-01-27 00:15:02 +03:00
|
|
|
/* some heuristics.. */
|
|
|
|
seg_start &= -__LDPGSZ;
|
1994-03-28 10:15:55 +04:00
|
|
|
seg_end = (seg_end + __LDPGSZ - 1) & -__LDPGSZ;
|
1994-01-27 00:15:02 +03:00
|
|
|
/* get the mem back stolen by incore kickstart on A3000 with
|
|
|
|
V36 bootrom. */
|
|
|
|
if (seg_end == 0x07f80000)
|
|
|
|
seg_end = 0x08000000;
|
|
|
|
|
|
|
|
/* or by zkick on a A2000. */
|
|
|
|
if (seg_start == 0x280000
|
|
|
|
&& strcmp (mh->mh_Node.ln_Name, "zkick memory") == 0)
|
|
|
|
seg_start = 0x200000;
|
|
|
|
|
|
|
|
seg_size = seg_end - seg_start;
|
|
|
|
mem_list.mem_seg[num_mem].mem_start = seg_start;
|
|
|
|
mem_list.mem_seg[num_mem].mem_size = seg_size;
|
1994-03-28 10:15:55 +04:00
|
|
|
/*
|
|
|
|
* If this segment is smaller than 2M,
|
|
|
|
* don't use it to load the kernel
|
|
|
|
*/
|
|
|
|
if (seg_size < 2 * 1024 * 1024)
|
|
|
|
continue;
|
1994-01-27 00:15:02 +03:00
|
|
|
/* if p_opt is set, select memory by priority instead of size */
|
1994-02-01 14:54:29 +03:00
|
|
|
if ((!p_opt && seg_size > *fastmem_size) ||
|
1994-03-28 10:15:55 +04:00
|
|
|
(p_opt && mem_pri <= mh->mh_Node.ln_Pri && seg_size > *fastmem_size))
|
1993-07-05 23:19:41 +04:00
|
|
|
{
|
1994-01-27 00:15:02 +03:00
|
|
|
*fastmem_size = seg_size;
|
|
|
|
*fastmem_start = (void *)seg_start;
|
1994-03-28 10:15:55 +04:00
|
|
|
mem_pri = mh->mh_Node.ln_Pri;
|
1993-07-05 23:19:41 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
1994-01-27 00:15:02 +03:00
|
|
|
mem_list.num_mem = num_mem;
|
1993-07-05 23:19:41 +04:00
|
|
|
Permit();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
asm ("
|
|
|
|
.set ABSEXECBASE,4
|
|
|
|
|
|
|
|
.text
|
|
|
|
.globl _startit
|
|
|
|
|
|
|
|
_startit:
|
|
|
|
movel sp,a3
|
|
|
|
movel 4:w,a6
|
|
|
|
lea pc@(start_super-.+2),a5
|
|
|
|
jmp a6@(-0x1e) | supervisor-call
|
|
|
|
|
|
|
|
start_super:
|
|
|
|
movew #0x2700,sr
|
|
|
|
|
|
|
|
| the BSD kernel wants values into the following registers:
|
|
|
|
| a0: fastmem-start
|
|
|
|
| d0: fastmem-size
|
|
|
|
| d1: chipmem-size
|
1994-01-27 00:15:02 +03:00
|
|
|
| d5: AttnFlags (cpuid)
|
1993-09-02 22:05:24 +04:00
|
|
|
| d7: boothowto
|
1994-03-20 13:05:11 +03:00
|
|
|
| a4: esym location
|
1993-07-05 23:19:41 +04:00
|
|
|
|
|
|
|
movel a3@(4),a1 | loaded kernel
|
|
|
|
movel a3@(8),d2 | length of loaded kernel
|
1994-03-28 10:15:55 +04:00
|
|
|
movel a3@(12),sp@- | entry point [save on stack for rts]
|
1993-07-05 23:19:41 +04:00
|
|
|
movel a3@(16),a0 | fastmem-start
|
|
|
|
movel a3@(20),d0 | fastmem-size
|
|
|
|
movel a3@(24),d1 | chipmem-size
|
1994-01-27 00:15:02 +03:00
|
|
|
movel #0,d5
|
|
|
|
movew (ABSEXECBASE)@(0x128),d5 | SysBase->AttnFlags
|
1993-09-02 22:05:24 +04:00
|
|
|
movel a3@(28),d7 | boothowto
|
1994-03-20 13:05:11 +03:00
|
|
|
movel a3@(32),a4 | esym
|
|
|
|
subl a5,a5 | target, load to 0
|
1993-07-05 23:19:41 +04:00
|
|
|
|
1994-01-27 00:15:02 +03:00
|
|
|
btst #3,(ABSEXECBASE)@(0x129) | AFB_68040,SysBase->AttnFlags
|
|
|
|
beq not040
|
|
|
|
|
|
|
|
| Turn off 68040 MMU
|
|
|
|
|
1994-03-20 13:05:11 +03:00
|
|
|
.word 0x4e7b,0xd003 | movec a5,tc
|
|
|
|
.word 0x4e7b,0xd806 | movec a5,urp
|
|
|
|
.word 0x4e7b,0xd807 | movec a5,srp
|
|
|
|
.word 0x4e7b,0xd004 | movec a5,itt0
|
|
|
|
.word 0x4e7b,0xd005 | movec a5,itt1
|
|
|
|
.word 0x4e7b,0xd006 | movec a5,dtt0
|
|
|
|
.word 0x4e7b,0xd007 | movec a5,dtt1
|
1994-01-27 00:15:02 +03:00
|
|
|
bra nott
|
|
|
|
|
|
|
|
not040:
|
1993-07-05 23:19:41 +04:00
|
|
|
lea pc@(zero-.+2),a3
|
|
|
|
pmove a3@,tc | Turn off MMU
|
|
|
|
lea pc@(nullrp-.+2),a3
|
|
|
|
pmove a3@,crp | Turn off MMU some more
|
|
|
|
pmove a3@,srp | Really, really, turn off MMU
|
|
|
|
|
|
|
|
| Turn off 68030 TT registers
|
|
|
|
|
|
|
|
btst #2,(ABSEXECBASE)@(0x129) | AFB_68030,SysBase->AttnFlags
|
|
|
|
beq nott | Skip TT registers if not 68030
|
|
|
|
lea pc@(zero-.+2),a3
|
|
|
|
.word 0xf013,0x0800 | pmove a3@,tt0 (gas only knows about 68851 ops..)
|
|
|
|
.word 0xf013,0x0c00 | pmove a3@,tt1 (gas only knows about 68851 ops..)
|
|
|
|
|
|
|
|
nott:
|
|
|
|
|
|
|
|
movew #(1<<9),0xdff096 | disable DMA
|
|
|
|
|
|
|
|
L0:
|
1994-03-20 13:05:11 +03:00
|
|
|
moveb a1@+,a5@+
|
1993-07-05 23:19:41 +04:00
|
|
|
subl #1,d2
|
|
|
|
bcc L0
|
|
|
|
|
|
|
|
|
1994-03-28 10:15:55 +04:00
|
|
|
moveq #0,d2 | zero out unused registers
|
|
|
|
moveq #0,d3 | (might make future compatibility
|
|
|
|
moveq #0,d4 | a little easier, since all registers
|
|
|
|
moveq #0,d6 | would have known contents)
|
|
|
|
movel d6,a1
|
|
|
|
movel d6,a2
|
|
|
|
movel d6,a3
|
|
|
|
movel d6,a5
|
|
|
|
movel d6,a6
|
|
|
|
rts | return to kernel entry point
|
1993-07-05 23:19:41 +04:00
|
|
|
|
|
|
|
|
|
|
|
| A do-nothing MMU root pointer (includes the following long as well)
|
|
|
|
|
|
|
|
nullrp: .long 0x7fff0001
|
|
|
|
zero: .long 0
|
|
|
|
|
|
|
|
|
|
|
|
");
|
|
|
|
|
1994-02-01 14:54:29 +03:00
|
|
|
void Usage(char *program_name)
|
|
|
|
{
|
|
|
|
fprintf(stderr,usage,program_name,program_name);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Version()
|
|
|
|
{
|
|
|
|
fprintf(stderr,"%s\n",_version + 6);
|
|
|
|
}
|